diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2010-01-27 15:02:23 +0100 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2010-01-27 15:02:23 +0100 |
commit | 65d792a0b8508a931221451c6e1e5072681fd3db (patch) | |
tree | 6a4584e43897cb499b352daeedd16fb4a1dc6748 | |
parent | 80cde3fce610d599e28a33d8ec6f06cf268be4d1 (diff) | |
parent | b64f5b9cbdb1e0b508eb0f6a0c4e90815c9b3e18 (diff) |
CWS-TOOLING: integrate CWS swunolocking1ooo/DEV300_m71
220 files changed, 15480 insertions, 11802 deletions
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx index 1f44308ff4..3c9970bfe2 100644 --- a/sw/inc/calbck.hxx +++ b/sw/inc/calbck.hxx @@ -202,7 +202,7 @@ class SwClientIter friend SwClient* SwModify::_Remove(SwClient *); // fuer Ptr-Korrektur friend void SwModify::Add(SwClient *); // nur fuer ASSERT ! - SwModify& rRoot; + SwModify const& rRoot; SwClient *pAkt, *pDelNext; // fuers Updaten der aller Iteratoren beim Einfuegen/Loeschen von // Clients, wenn der Iterator gerade draufsteht. @@ -213,11 +213,10 @@ class SwClientIter TypeId aSrchId; // fuer First/Next - suche diesen Type public: - SW_DLLPUBLIC SwClientIter( SwModify& ); + SW_DLLPUBLIC SwClientIter( SwModify const& ); SW_DLLPUBLIC ~SwClientIter(); const SwModify& GetModify() const { return rRoot; } - SwModify& GetModify() { return rRoot; } #ifndef CFRONT SwClient* operator++(int); // zum Naechsten diff --git a/sw/inc/chpfld.hxx b/sw/inc/chpfld.hxx index 2e53c66386..992c73dcfc 100644 --- a/sw/inc/chpfld.hxx +++ b/sw/inc/chpfld.hxx @@ -32,9 +32,11 @@ #include "fldbas.hxx" + class SwFrm; +class SwCntntNode; class SwTxtNode; -#include <unoobj.hxx> + enum SwChapterFormat { diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx index 8860f0e38f..0f5ca9b9b3 100644 --- a/sw/inc/dcontact.hxx +++ b/sw/inc/dcontact.hxx @@ -191,11 +191,11 @@ public: } RndStdIds GetAnchorId() const { return GetAnchorFmt().GetAnchorId(); } - bool ObjAnchoredAtPage() const { return GetAnchorId() == FLY_PAGE; } - bool ObjAnchoredAtFly() const { return GetAnchorId() == FLY_AT_FLY; } - bool ObjAnchoredAtPara() const { return GetAnchorId() == FLY_AT_CNTNT; } - bool ObjAnchoredAtChar() const { return GetAnchorId() == FLY_AUTO_CNTNT; } - bool ObjAnchoredAsChar() const { return GetAnchorId() == FLY_IN_CNTNT; } + bool ObjAnchoredAtPage() const { return GetAnchorId() == FLY_AT_PAGE; } + bool ObjAnchoredAtFly() const { return GetAnchorId() == FLY_AT_FLY; } + bool ObjAnchoredAtPara() const { return GetAnchorId() == FLY_AT_PARA; } + bool ObjAnchoredAtChar() const { return GetAnchorId() == FLY_AT_CHAR; } + bool ObjAnchoredAsChar() const { return GetAnchorId() == FLY_AS_CHAR; } const SwPosition& GetCntntAnchor() const { diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index c39e6efaa0..c5c31bf721 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -201,7 +201,6 @@ class SwLayouter; class SdrView; class SdrMarkList; class SwAuthEntry; -class SwUnoCallBack; class SwLayoutCache; class IStyleAccess; struct SwCallMouseEvent; @@ -398,7 +397,7 @@ class SW_DLLPUBLIC SwDoc : SwLayoutCache *pLayoutCache; // Layout cache to read and save with the // document for a faster formatting - SwUnoCallBack *pUnoCallBack; + SwModify *pUnoCallBack; IGrammarContact *mpGrammarContact; // for grammar checking in paragraphs during editing mutable comphelper::ImplementationReference< SwChartDataProvider diff --git a/sw/inc/fmtanchr.hxx b/sw/inc/fmtanchr.hxx index e3b241aebf..d2f6d76c12 100644 --- a/sw/inc/fmtanchr.hxx +++ b/sw/inc/fmtanchr.hxx @@ -55,7 +55,7 @@ class SW_DLLPUBLIC SwFmtAnchor: public SfxPoolItem static sal_uInt32 mnOrderCounter; public: - SwFmtAnchor( RndStdIds eRnd = FLY_PAGE, USHORT nPageNum = 0 ); + SwFmtAnchor( RndStdIds eRnd = FLY_AT_PAGE, USHORT nPageNum = 0 ); SwFmtAnchor( const SwFmtAnchor &rCpy ); ~SwFmtAnchor(); @@ -86,7 +86,7 @@ public: }; inline const SwFmtAnchor &SwAttrSet::GetAnchor(BOOL bInP) const - { return (const SwFmtAnchor&)Get( RES_ANCHOR,bInP); } + { return static_cast<const SwFmtAnchor&>(Get(RES_ANCHOR, bInP)); } inline const SwFmtAnchor &SwFmt::GetAnchor(BOOL bInP) const { return aSet.GetAnchor(bInP); } diff --git a/sw/inc/fmtmeta.hxx b/sw/inc/fmtmeta.hxx index f676469b90..616c4cddc1 100644..100755 --- a/sw/inc/fmtmeta.hxx +++ b/sw/inc/fmtmeta.hxx @@ -31,6 +31,8 @@ #ifndef SW_FMTMETA_HXX #define SW_FMTMETA_HXX +#include <cppuhelper/weakref.hxx> + #include <svl/poolitem.hxx> #include <sfx2/Metadatable.hxx> @@ -122,8 +124,8 @@ public: virtual SfxPoolItem * Clone( SfxItemPool *pPool = 0 ) const; // TYPEINFO(); - // notify clients registered at m_pMeta that this meta is being removed - void NotifyRemoval(); + /// notify clients registered at m_pMeta that this meta is being (re-)moved + void NotifyChangeTxtNode(SwTxtNode *const pTxtNode); static SwFmtMeta * CreatePoolDefault( const USHORT i_nWhich ); ::sw::Meta * GetMeta() { return m_pMeta.get(); } /// this method <em>must</em> be called when the hint is actually copied @@ -140,8 +142,11 @@ class Meta , public SwModify { protected: - friend class ::SwFmtMeta; // SetFmtMeta - friend class ::SwXMeta; // GetTxtNode, GetTxtAttr + friend class ::SwFmtMeta; // SetFmtMeta, NotifyChangeTxtNode + friend class ::SwXMeta; // GetTxtNode, GetTxtAttr, Get/SetXMeta + + ::com::sun::star::uno::WeakReference< + ::com::sun::star::rdf::XMetadatable> m_wXMeta; SwFmtMeta * m_pFmt; @@ -151,6 +156,15 @@ protected: SwFmtMeta * GetFmtMeta() const { return m_pFmt; } void SetFmtMeta( SwFmtMeta * const i_pFmt ) { m_pFmt = i_pFmt; }; + void NotifyChangeTxtNode(); + + ::com::sun::star::uno::WeakReference< + ::com::sun::star::rdf::XMetadatable> const& GetXMeta() const + { return m_wXMeta; } + void SetXMeta(::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable> const& xMeta) + { m_wXMeta = xMeta; } + public: explicit Meta(SwFmtMeta * const i_pFmt = 0); virtual ~Meta(); diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index 12ef87e948..9b77c79991 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -30,11 +30,14 @@ #ifndef _FRMFMT_HXX #define _FRMFMT_HXX -#include <format.hxx> - // --> OD 2004-08-06 #i28749# #include <com/sun/star/text/PositionLayoutDir.hpp> // <-- + +#include <cppuhelper/weakref.hxx> + +#include <format.hxx> + #include "swdllapi.h" class SwFlyFrm; @@ -51,8 +54,9 @@ class SW_DLLPUBLIC SwFrmFmt: public SwFmt { friend class SwDoc; friend class SwPageDesc; //darf den protected CTor rufen. -// friend class SwSwgReader; // der SW2-Reader auch! -// friend class Sw3IoImp; // der SW3-Reader auch! + + ::com::sun::star::uno::WeakReference< + ::com::sun::star::uno::XInterface> m_wXObject; protected: SwFrmFmt( SwAttrPool& rPool, const sal_Char* pFmtNm, @@ -136,6 +140,13 @@ public: virtual String GetDescription() const; + SW_DLLPRIVATE ::com::sun::star::uno::WeakReference< + ::com::sun::star::uno::XInterface> const& GetXObject() const + { return m_wXObject; } + SW_DLLPRIVATE void SetXObject(::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface> const& xObject) + { m_wXObject = xObject; } + DECL_FIXEDMEMPOOL_NEWDEL_DLL(SwFrmFmt) }; diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 37aa87b202..635052103e 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -30,6 +30,8 @@ #ifndef _NDTXT_HXX #define _NDTXT_HXX +#include <cppuhelper/weakref.hxx> + #include "swdllapi.h" #include <error.h> #include <node.hxx> @@ -76,9 +78,12 @@ class SwScriptInfo; struct SwDocStat; struct SwParaIdleData_Impl; -namespace com { namespace sun { namespace star { namespace uno { - template < class > class Sequence; -}}}} +namespace com { namespace sun { namespace star { + namespace uno { + template < class > class Sequence; + } + namespace text { class XTextContent; } +} } } typedef std::set< xub_StrLen > SwSoftPageBreakList; @@ -132,6 +137,8 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode, public ::sfx2::Metadatable SwList* mpList; // <-- + ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextContent> m_wXParagraph; SW_DLLPRIVATE SwTxtNode( const SwNodeIndex &rWhere, SwTxtFmtColl *pTxtColl, const SfxItemSet* pAutoAttr = 0 ); @@ -813,6 +820,13 @@ public: USHORT GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd ) const; + SW_DLLPRIVATE ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextContent> const& GetXParagraph() const + { return m_wXParagraph; } + SW_DLLPRIVATE void SetXParagraph(::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent> const& xParagraph) + { m_wXParagraph = xParagraph; } + // sfx2::Metadatable virtual ::sfx2::IXmlIdRegistry& GetRegistry(); virtual bool IsInClipboard() const; diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx index dd80b7f94f..3c734f4d5a 100644 --- a/sw/inc/pagedesc.hxx +++ b/sw/inc/pagedesc.hxx @@ -344,4 +344,7 @@ public: operator SwPageDesc() const; // #i7983# }; + +SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName); + #endif //_PAGEDESC_HXX diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx index 9d401aeb90..9c290e55b1 100644 --- a/sw/inc/section.hxx +++ b/sw/inc/section.hxx @@ -41,6 +41,11 @@ #include <svl/svarray.hxx> #include <frmfmt.hxx> + +namespace com { namespace sun { namespace star { + namespace text { class XTextSection; } +} } } + // Forward Deklaration class SwSectionFmt; class SwDoc; @@ -230,6 +235,13 @@ class SW_DLLPUBLIC SwSectionFmt : public SwFrmFmt { friend class SwDoc; + /** why does this exist in addition to the m_wXObject in SwFrmFmt? + in case of an index, both a SwXDocumentIndex and a SwXTextSection + register at this SwSectionFmt, so we need to have two refs. + */ + ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextSection> m_wXTextSection; + /* SW_DLLPUBLIC */ SwSection* _GetSection() const; SW_DLLPRIVATE void UpdateParent(); // Parent wurde veraendert @@ -271,6 +283,14 @@ public: // ist die Section eine gueltige fuers GlobalDocument? const SwSection* GetGlobalDocSection() const; + + SW_DLLPRIVATE ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextSection> const& GetXTextSection() const + { return m_wXTextSection; } + SW_DLLPRIVATE void SetXTextSection(::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextSection> const& xTextSection) + { m_wXTextSection = xTextSection; } + }; // -------------- inlines --------------------------------- diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx index a5695c6352..e506bbe0fe 100644 --- a/sw/inc/swtable.hxx +++ b/sw/inc/swtable.hxx @@ -299,7 +299,7 @@ public: virtual BOOL GetInfo( SfxPoolItem& ) const; // suche im Format nach der angemeldeten Tabelle - static SwTable* FindTable( SwFrmFmt* pFmt ); + static SwTable * FindTable( SwFrmFmt const*const pFmt ); // Struktur ein wenig aufraeumen void GCLines(); diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx index 7bc90a4e76..70bebb09fe 100644 --- a/sw/inc/swtypes.hxx +++ b/sw/inc/swtypes.hxx @@ -166,11 +166,11 @@ const short lOutlineMinTextDistance = 216; // 0.15 inch = 0.38 cm //Schnittstellen Bedeutung haben (SwDoc). enum RndStdIds { - FLY_AT_CNTNT, //Absatzgebundener Rahmen - FLY_IN_CNTNT, //Zeichengebundener Rahmen - FLY_PAGE, //Seitengebundener Rahmen - FLY_AT_FLY, //Rahmengebundener Rahmen ( LAYER_IMPL ) - FLY_AUTO_CNTNT, //Automatisch positionierter, absatzgebundener Rahmen + FLY_AT_PARA, // anchored at paragraph + FLY_AS_CHAR, // anchored as character + FLY_AT_PAGE, // anchored at page + FLY_AT_FLY, // anchored at frame + FLY_AT_CHAR, // anchored at character //Der Rest wird nur fuer SS benutzt. RND_STD_HEADER, RND_STD_FOOTER, diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx index 74bebda882..88ab5c3010 100644 --- a/sw/inc/tox.hxx +++ b/sw/inc/tox.hxx @@ -27,8 +27,10 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _TOX_HXX -#define _TOX_HXX +#ifndef SW_TOX_HXX +#define SW_TOX_HXX + +#include <cppuhelper/weakref.hxx> #include <i18npool/lang.h> #include <tools/string.hxx> @@ -47,6 +49,11 @@ #define INCLUDED_VECTOR #endif + +namespace com { namespace sun { namespace star { + namespace text { class XDocumentIndexMark; } +} } } + class SwTOXType; class SwTOXMark; class SwTxtTOXMark; @@ -61,7 +68,9 @@ SV_DECL_PTRARR(SwTOXMarks, SwTOXMark*, 0, 10) #define IVER_TOXMARK_STRPOOL ((USHORT)1) #define IVER_TOXMARK_NEWTOX ((USHORT)2) -class SW_DLLPUBLIC SwTOXMark : public SfxPoolItem, public SwClient +class SW_DLLPUBLIC SwTOXMark + : public SfxPoolItem + , public SwModify { friend void _InitCore(); friend class SwTxtTOXMark; @@ -80,6 +89,8 @@ class SW_DLLPUBLIC SwTOXMark : public SfxPoolItem, public SwClient BOOL bAutoGenerated : 1; // generated using a concordance file BOOL bMainEntry : 1; // main entry emphasized by character style + ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XDocumentIndexMark> m_wXDocumentIndexMark; SwTOXMark(); // to create the dflt. atr. in _InitCore @@ -97,6 +108,11 @@ public: virtual int operator==( const SfxPoolItem& ) const; virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const; + // SwClient + virtual void Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ); + + void InvalidateTOXMark(); + String GetText() const; inline BOOL IsAlternativeText() const; @@ -131,6 +147,14 @@ public: const SwTxtTOXMark* GetTxtTOXMark() const { return pTxtAttr; } SwTxtTOXMark* GetTxtTOXMark() { return pTxtAttr; } + + SW_DLLPRIVATE ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XDocumentIndexMark> const& GetXTOXMark() const + { return m_wXDocumentIndexMark; } + SW_DLLPRIVATE void SetXTOXMark(::com::sun::star::uno::Reference< + ::com::sun::star::text::XDocumentIndexMark> const& xMark) + { m_wXDocumentIndexMark = xMark; } + }; /*-------------------------------------------------------------------- @@ -769,4 +793,4 @@ inline void SwTOXBase::SetOptions(USHORT nOpt) } -#endif // _TOX_HXX +#endif // SW_TOX_HXX diff --git a/sw/inc/txtatr.hxx b/sw/inc/txtatr.hxx index 3af8e54bf6..e8163914eb 100644 --- a/sw/inc/txtatr.hxx +++ b/sw/inc/txtatr.hxx @@ -80,7 +80,7 @@ public: const xub_StrLen i_nStart, const xub_StrLen i_nEnd ); virtual ~SwTxtMeta(); - void ChgTxtNode( SwTxtNode * const pNode ) { m_pTxtNode = pNode; } + void ChgTxtNode(SwTxtNode * const pNode); SwTxtNode * GetTxtNode() const { return m_pTxtNode; } }; diff --git a/sw/inc/unobaseclass.hxx b/sw/inc/unobaseclass.hxx index 7bc5c3a19c..5c04700776 100644 --- a/sw/inc/unobaseclass.hxx +++ b/sw/inc/unobaseclass.hxx @@ -27,21 +27,151 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _UNOBASECLASS_HXX -#define _UNOBASECLASS_HXX +#ifndef SW_UNOBASECLASS_HXX +#define SW_UNOBASECLASS_HXX -#include <calbck.hxx> +#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/container/XEnumeration.hpp> + #include <cppuhelper/implbase2.hxx> -typedef -cppu::WeakImplHelper2 -< - ::com::sun::star::container::XEnumeration, - ::com::sun::star::lang::XServiceInfo + +class SfxPoolItem; +class SwClient; +class SwDoc; + + +typedef ::cppu::WeakImplHelper2 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumeration > -SwSimpleEnumerationBaseClass; +SwSimpleEnumeration_Base; + + +/* -----------------29.04.98 07:35------------------- + * + * --------------------------------------------------*/ +enum CursorType +{ + CURSOR_INVALID, + CURSOR_BODY, + CURSOR_FRAME, + CURSOR_TBLTEXT, + CURSOR_FOOTNOTE, + CURSOR_HEADER, + CURSOR_FOOTER, + CURSOR_REDLINE, + CURSOR_ALL, // for Search&Replace + CURSOR_SELECTION, // create a paragraph enumeration from + // a text range or cursor + CURSOR_SELECTION_IN_TABLE, + CURSOR_META, // meta/meta-field +}; + +/*-----------------04.03.98 11:54------------------- + Start/EndAction or Start/EndAllAction + -------------------------------------------------- */ +class UnoActionContext +{ + private: + SwDoc * m_pDoc; + + public: + UnoActionContext(SwDoc *const pDoc); + ~UnoActionContext(); + + void InvalidateDocument() { m_pDoc = 0; } +}; + +/* -----------------07.07.98 12:03------------------- + interrupt Actions for a little while + -------------------------------------------------- */ +class UnoActionRemoveContext +{ + private: + SwDoc *const m_pDoc; + + public: + UnoActionRemoveContext(SwDoc *const pDoc); + ~UnoActionRemoveContext(); +}; + + +::com::sun::star::uno::Sequence< sal_Int8 > CreateUnoTunnelId(); + +/// helper function for implementing SwClient::Modify +void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); + + +#include <boost/utility.hpp> +#include <osl/diagnose.h> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> + +namespace sw { + + template<typename T> class UnoImplPtr + : private ::boost::noncopyable + { + private: + T * m_p; + + public: + UnoImplPtr(T *const i_p) + : m_p(i_p) + { + OSL_ENSURE(i_p, "UnoImplPtr: null"); + } + + ~UnoImplPtr() + { + ::vos::OGuard g(Application::GetSolarMutex()); + delete m_p; // #i105557#: call dtor with locked solar mutex + m_p = 0; + } + + T & operator * () const { return *m_p; } + + T * operator ->() const { return m_p; } + + T * get () const { return m_p; } + }; + + template< class C > C * + UnoTunnelGetImplementation( + ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XUnoTunnel > const & xUnoTunnel) + { + if (!xUnoTunnel.is()) { return 0; } + C *const pC( reinterpret_cast< C* >( + ::sal::static_int_cast< sal_IntPtr >( + xUnoTunnel->getSomething(C::getUnoTunnelId())))); + return pC; + } + + template< class C > sal_Int64 + UnoTunnelImpl(const ::com::sun::star::uno::Sequence< sal_Int8 > & rId, + C *const pThis) + { + if ((rId.getLength() == 16) && + (0 == rtl_compareMemory(C::getUnoTunnelId().getConstArray(), + rId.getConstArray(), 16))) + { + return ::sal::static_int_cast< sal_Int64 >( + reinterpret_cast< sal_IntPtr >(pThis) ); + } + return 0; + } + + ::com::sun::star::uno::Sequence< ::rtl::OUString > + GetSupportedServiceNamesImpl( + size_t const nServices, char const*const pServices[]); + sal_Bool SupportsServiceImpl( + size_t const nServices, char const*const pServices[], + ::rtl::OUString const & rServiceName); + +} // namespace sw -#endif +#endif // SW_UNOBASECLASS_HXX diff --git a/sw/inc/unobookmark.hxx b/sw/inc/unobookmark.hxx new file mode 100644 index 0000000000..46d0054551 --- /dev/null +++ b/sw/inc/unobookmark.hxx @@ -0,0 +1,244 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOBOOKMARK_HXX +#define SW_UNOBOOKMARK_HXX + +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/text/XTextContent.hpp> +#include <com/sun/star/text/XFormField.hpp> + +#include <cppuhelper/implbase5.hxx> + +#include <sfx2/Metadatable.hxx> + +#include <unobaseclass.hxx> +#include <IDocumentMarkAccess.hxx> + + +class SwDoc; + + +typedef ::cppu::ImplInheritanceHelper5 +< ::sfx2::MetadatableMixin +, ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::container::XNamed +, ::com::sun::star::text::XTextContent +> SwXBookmark_Base; + +class SwXBookmark + : public SwXBookmark_Base +{ + +private: + + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + +protected: + + void attachToRangeEx( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange, + IDocumentMarkAccess::MarkType eType) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException ); + virtual 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); + + const ::sw::mark::IMark* GetBookmark() const; + + virtual ~SwXBookmark(); + + /// @param pDoc and pMark != 0, but not & because of ImplInheritanceHelper + SwXBookmark(::sw::mark::IMark *const pMark, SwDoc *const pDoc); + +public: + + /// descriptor + SwXBookmark(); + + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent> + CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark & rBookmark); + + /// @return IMark for this, but only if it lives in pDoc + static ::sw::mark::IMark const* GetBookmarkInDoc(SwDoc const*const pDoc, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XUnoTunnel> & xUT); + + // MetadatableMixin + virtual ::sfx2::Metadatable* GetCoreObject(); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > GetModel(); + + 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 >& 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); + +}; + +typedef cppu::ImplInheritanceHelper1< SwXBookmark, + ::com::sun::star::text::XFormField > SwXFieldmark_Base; + +class SwXFieldmark + : public SwXFieldmark_Base +{ + +private: + + bool isReplacementObject; + +public: + + SwXFieldmark(bool isReplacementObject, + ::sw::mark::IMark* pBkm = 0, SwDoc* pDoc = 0); + + virtual 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); + + virtual ::rtl::OUString SAL_CALL getDescription() + throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getType() + throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getRes() + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setDescription(const ::rtl::OUString& rDescription) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setType(::sal_Int16 fieldType) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRes(::sal_Int16 res) + throw (::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOBOOKMARK_HXX + diff --git a/sw/inc/unochart.hxx b/sw/inc/unochart.hxx index 870b107bb6..a251851c31 100644 --- a/sw/inc/unochart.hxx +++ b/sw/inc/unochart.hxx @@ -32,6 +32,8 @@ #include <map> #include <set> + +#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/chart2/data/XDataProvider.hpp> #include <com/sun/star/chart2/data/XDataSource.hpp> #include <com/sun/star/chart2/data/XDataSequence.hpp> @@ -48,8 +50,8 @@ #include <com/sun/star/util/XModifiable.hpp> #include <com/sun/star/util/XModifyBroadcaster.hpp> #include <com/sun/star/util/XModifyListener.hpp> - #include <com/sun/star/chart/ChartDataRowSource.hpp> + #include <cppuhelper/interfacecontainer.h> //OMultiTypeInterfaceContainerHelper #include <cppuhelper/implbase2.hxx> // helper for implementations #include <cppuhelper/implbase4.hxx> // helper for implementations @@ -57,17 +59,21 @@ #include <cppuhelper/implbase10.hxx> // helper for implementations #include <cppuhelper/weakref.hxx> +#include <tools/string.hxx> +#include <tools/link.hxx> +#include <vcl/timer.hxx> #include <calbck.hxx> -#include <unoobj.hxx> +class SfxItemPropertySet; class SwDoc; class SwTable; class SwTableBox; class SwUnoCrsr; struct SwRangeDescriptor; class SwSelBoxes; +class SwFrmFmt; ////////////////////////////////////////////////////////////////////// diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx index a1d5139897..8a90e6541a 100644 --- a/sw/inc/unocoll.hxx +++ b/sw/inc/unocoll.hxx @@ -481,7 +481,6 @@ class SwXBookmarks : public SwCollectionBaseClass, 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 SwXBookmark* GetObject( ::sw::mark::IMark& rBkm, SwDoc* pDoc); }; class SwXNumberingRulesCollection : public cppu::WeakImplHelper1 diff --git a/sw/inc/unocrsrhelper.hxx b/sw/inc/unocrsrhelper.hxx index 27a511d969..2a25fb24ac 100644 --- a/sw/inc/unocrsrhelper.hxx +++ b/sw/inc/unocrsrhelper.hxx @@ -30,12 +30,25 @@ #ifndef _UNOCRSRHELPER_HXX #define _UNOCRSRHELPER_HXX -#include <com/sun/star/beans/XPropertyState.hpp> -#include <unocrsr.hxx> #include <map> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +#include <swtypes.hxx> +#include <pam.hxx> + + +class String; +class SfxItemSet; +class SfxItemPropertySet; struct SfxItemPropertySimpleEntry; +class SwTxtNode; class SwPaM; +class SwCursor; +class SwUnoCrsr; +class SwFmtColl; +struct SwSortOptions; class SwDoc; namespace com{ namespace sun{ namespace star{ @@ -46,7 +59,18 @@ namespace com{ namespace sun{ namespace star{ struct PropertyValue; } }}} - + +/* -----------------03.12.98 12:16------------------- + * + * --------------------------------------------------*/ +enum SwGetPropertyStatesCaller +{ + SW_PROPERTY_STATE_CALLER_DEFAULT, + SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION, + SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY, + SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT +}; + /* -----------------------------14.12.00 15:06-------------------------------- ---------------------------------------------------------------------------*/ @@ -62,6 +86,7 @@ namespace SwUnoCursorHelper void SetValue( USHORT nWhichId, USHORT nMemberId, const com::sun::star::uno::Any& rAny ); bool FillValue( USHORT nWhichId, USHORT nMemberId, const com::sun::star::uno::Any*& pAny ); }; + sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry , SwPaM& rPam , com::sun::star::uno::Any *pAny @@ -102,6 +127,88 @@ namespace SwUnoCursorHelper const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + /// @param bTableMode: attributes should be applied to a table selection + void SetCrsrAttr(SwPaM & rPam, const SfxItemSet & rSet, + const SetAttrMode nAttrMode, + const bool bTableMode = false); + void GetCrsrAttr(SwPaM & rPam, SfxItemSet & rSet, + const bool bOnlyTxtAttr = false, + const bool bGetFromChrFmt = true); + void GetTextFromPam(SwPaM & rPam, ::rtl::OUString & rBuffer); + SwFmtColl * GetCurTxtFmtColl(SwPaM & rPam, const bool bConditional); + + void SelectPam(SwPaM & rPam, const bool bExpand); + void SetString(SwCursor & rCursor, const ::rtl::OUString & rString); + + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > + CreateSortDescriptor(const bool bFromTable); + sal_Bool ConvertSortProperties( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& rDescriptor, + SwSortOptions & rSortOpt); + + /// @param bTableMode: attributes should be applied to a table selection + void SetPropertyValue( + SwPaM& rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName, + const ::com::sun::star::uno::Any & rValue, + const SetAttrMode nAttrMode = nsSetAttrMode::SETATTR_DEFAULT, + const bool bTableMode = false) + 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); + ::com::sun::star::uno::Any GetPropertyValue( + SwPaM& rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > GetPropertyStates( + SwPaM & rPaM, + const SfxItemPropertySet & rPropSet, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const SwGetPropertyStatesCaller eCaller = + SW_PROPERTY_STATE_CALLER_DEFAULT) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + ::com::sun::star::beans::PropertyState GetPropertyState( + SwPaM & rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + void SetPropertyToDefault( + SwPaM & rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Any GetPropertyDefault( + SwPaM & rPaM, + const SfxItemPropertySet & rPropSet, + const ::rtl::OUString & rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + bool SetPageDesc( + const ::com::sun::star::uno::Any& rValue, + SwDoc & rDoc, SfxItemSet & rSet); + void SetTxtFmtColl(const ::com::sun::star::uno::Any & rAny, SwPaM & rPaM) + throw (::com::sun::star::lang::IllegalArgumentException); + bool SetCursorPropertyValue( + SfxItemPropertySimpleEntry const& rEntry, + ::com::sun::star::uno::Any const& rValue, + SwPaM & rPam, SfxItemSet & rItemSet) + throw (::com::sun::star::lang::IllegalArgumentException); + } // namespace SwUnoCursorHelper #endif diff --git a/sw/inc/unofield.hxx b/sw/inc/unofield.hxx index abbd3f9e8f..db14db8957 100644 --- a/sw/inc/unofield.hxx +++ b/sw/inc/unofield.hxx @@ -30,14 +30,18 @@ #ifndef _UNOFIELD_HXX #define _UNOFIELD_HXX -#include <com/sun/star/text/XDependentTextField.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/util/XRefreshable.hpp> #include <com/sun/star/util/XUpdatable.hpp> +#include <com/sun/star/text/XDependentTextField.hpp> + +#include <cppuhelper/implbase5.hxx> + #include <calbck.hxx> -#include <unoobj.hxx> #include <unocoll.hxx> #include <RefreshListenerContainer.hxx> + class SwFieldType; class SwDoc; class SwFmtFld; diff --git a/sw/inc/unofootnote.hxx b/sw/inc/unofootnote.hxx new file mode 100644 index 0000000000..8d9a65d963 --- /dev/null +++ b/sw/inc/unofootnote.hxx @@ -0,0 +1,233 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOFOOTNOTE_HXX +#define SW_UNOFOOTNOTE_HXX + +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/text/XTextContent.hpp> +#include <com/sun/star/text/XFootnote.hpp> + +#include <cppuhelper/implbase5.hxx> + +#include <unotext.hxx> + + +class SwDoc; +class SwModify; +class SwFmtFtn; + + +/*-----------------12.02.98 08:01------------------- + +--------------------------------------------------*/ +typedef ::cppu::WeakImplHelper5 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::text::XFootnote +> SwXFootnote_Base; + +class SwXFootnote + : public SwXFootnote_Base + , public SwXText +{ + +private: + + friend class SwXFootnotes; + + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + + +protected: + + virtual const SwStartNode *GetStartNode() const; + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > + CreateCursor() + throw (::com::sun::star::uno::RuntimeException); + + virtual ~SwXFootnote(); + + SwXFootnote(SwDoc & rDoc, const SwFmtFtn & rFmt); + +public: + + SwXFootnote(const bool bEndnote); + + static SwXFootnote * + CreateXFootnote(SwDoc & rDoc, SwFmtFtn const& rFootnoteFmt); + /// may return 0 + static SwXFootnote * + GetXFootnote(SwModify const& rUnoCB, SwFmtFtn const& rFootnoteFmt); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw() { OWeakObject::release(); } + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > + SAL_CALL getTypes() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() + throw (::com::sun::star::uno::RuntimeException); + + 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 >& 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); + + // 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); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + 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); + + // XFootnote + virtual ::rtl::OUString SAL_CALL getLabel() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLabel(const ::rtl::OUString& rLabel) + throw (::com::sun::star::uno::RuntimeException); + + // XSimpleText + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursor() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursorByRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextPosition) + throw (::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOFOOTNOTE_HXX + diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index 2775db8690..1d7b17cf22 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -30,20 +30,35 @@ #ifndef _UNOFRAME_HXX #define _UNOFRAME_HXX -#include <unoobj.hxx> -#include <sfx2/objsh.hxx> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp> #include <com/sun/star/text/XTextFrame.hpp> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/util/XModifyListener.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/document/XEventsSupplier.hpp> - /* -#include <com/sun/star/container/XNameAccess.hpp> - */ -class SwDoc; +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase6.hxx> + +#include <sfx2/objsh.hxx> + +#include <flyenum.hxx> +#include <frmfmt.hxx> +#include <unoevtlstnr.hxx> +#include <unotext.hxx> + + class SfxItemPropertSet; +class SdrObject; +class SwDoc; +class SwFmt; +class SwFlyFrmFmt; + + /*-----------------12.02.98 11:21------------------- --------------------------------------------------*/ @@ -171,12 +186,18 @@ class SwXTextFrame : public SwXTextFrameBaseClass, protected: virtual const SwStartNode *GetStartNode() const; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > + CreateCursor() + throw (::com::sun::star::uno::RuntimeException); + virtual ~SwXTextFrame(); public: SwXTextFrame(SwDoc *pDoc); SwXTextFrame(SwFrmFmt& rFmt); - + + // FIXME: EVIL HACK: make available for SwXFrame::attachToRange + void SetDoc(SwDoc *const pDoc) { SwXText::SetDoc(pDoc); }; virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL acquire( ) throw(); diff --git a/sw/inc/unoidx.hxx b/sw/inc/unoidx.hxx index 544399d544..d262e1784a 100644 --- a/sw/inc/unoidx.hxx +++ b/sw/inc/unoidx.hxx @@ -30,313 +30,341 @@ #ifndef _UNOIDX_HXX #define _UNOIDX_HXX +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/text/XDocumentIndexMark.hpp> #include <com/sun/star/text/XDocumentIndex.hpp> -#include <com/sun/star/container/XIndexReplace.hpp> -#include <unoobj.hxx> + +#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/implbase5.hxx> + #include <unocoll.hxx> #include <toxe.hxx> + + class SwTOXBaseSection; class SwTOXMark; 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; - - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - SwDoc* m_pDoc; - const SwTOXBaseSection* pBase; - TOXTypes eTOXType; - //Descriptor-Interface - sal_Bool bIsDescriptor; - SwDocIdxProperties_Impl* pProps; +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; - SwXIndexStyleAccess_Impl* pStyleAccess; - SwXIndexTokenAccess_Impl* pTokenAccess; +class SwXDocumentIndex + : public SwXDocumentIndex_Base +{ - SwSectionFmt* GetFmt()const {return (SwSectionFmt*)GetRegisteredIn();} +private: - 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;} + class StyleAccess_Impl; + class TokenAccess_Impl; - SwXIndexStyleAccess_Impl* GetStyleAccess() const {return pStyleAccess;} - void SetStyleAccess(SwXIndexStyleAccess_Impl* pSet) - {pStyleAccess = pSet;} + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; - 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); - - - TYPEINFO(); - - 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); - //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); + SwXDocumentIndex(SwTOXBaseSection const&, SwDoc &); - //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 ); +public: - //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 ); + /// descriptor + SwXDocumentIndex(const TOXTypes eToxType, SwDoc& rDoc); - //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 ); + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XDocumentIndex> + CreateXDocumentIndex(SwDoc & rDoc, SwTOXBaseSection const& rSection); - //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 ); + static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); + // 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); - 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------------------- * * --------------------------------------------------*/ -class SwXDocumentIndexMark : public cppu::WeakImplHelper4 -< - ::com::sun::star::text::XDocumentIndexMark, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XUnoTunnel ->, - public SwClient +typedef ::cppu::WeakImplHelper4 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::text::XDocumentIndexMark +> SwXDocumentIndexMark_Base; + +class SwXDocumentIndexMark + : public SwXDocumentIndexMark_Base { - SwEventListenerContainer aLstnrCntnr; - SwDepend aTypeDepend; - SwDoc* m_pDoc; - const SwTOXMark* m_pTOXMark; - const SfxItemPropertySet* m_pPropSet; - - sal_Bool bIsDescriptor; - sal_Bool bMainEntry; - TOXTypes eType; - sal_uInt16 nLevel; - String sAltText; - String sPrimaryKey; - String sSecondaryKey; - String sTextReading; - String sPrimaryKeyReading; - String sSecondaryKeyReading; - String sUserIndexName; - - void InitMap(TOXTypes eToxType); -protected: - virtual ~SwXDocumentIndexMark(); -public: - SwXDocumentIndexMark(TOXTypes eToxType); - SwXDocumentIndexMark(const SwTOXType* pType, - const SwTOXMark* pMark, - SwDoc* pDc); - - - TYPEINFO(); - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); +private: - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; - virtual rtl::OUString SAL_CALL getMarkEntry(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setMarkEntry(const rtl::OUString& aIndexEntry) 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(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual ~SwXDocumentIndexMark(); - //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 ); + SwXDocumentIndexMark(SwDoc & rDoc, + SwTOXType & rType, SwTOXMark & rMark); - //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); +public: - //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 ); + /// descriptor + SwXDocumentIndexMark(const TOXTypes eToxType); - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XDocumentIndexMark> + CreateXDocumentIndexMark(SwDoc & rDoc, + SwTOXType & rType, SwTOXMark & rMark); - 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 ); + static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - SwTOXType* GetTOXType() const {return (SwTOXType*)aTypeDepend.GetRegisteredIn();} - const SwTOXMark* GetTOXMark() const {return m_pTOXMark;} + // 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); + + // 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); + + // XDocumentIndexMark + virtual rtl::OUString SAL_CALL getMarkEntry() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMarkEntry(const rtl::OUString& rIndexEntry) + throw (::com::sun::star::uno::RuntimeException); - static SwXDocumentIndexMark* GetObject(SwTOXType* pType, const SwTOXMark* pMark, - 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 ); - -// 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) - -// 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 ); - - - //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 ); - - //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); - - //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 ); - - static SwXDocumentIndex* GetObject(const SwTOXBaseSection* pTOX); -}; -/* -----------------13.09.99 16:39------------------- - - --------------------------------------------------*/ -class SwXIndexStyleAccess_Impl : public cppu::WeakImplHelper2 -< - ::com::sun::star::container::XIndexReplace, - ::com::sun::star::lang::XServiceInfo -> -{ - SwXDocumentIndex& rParent; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XDocumentIndex > xParent; -protected: - virtual ~SwXIndexStyleAccess_Impl(); -public: - SwXIndexStyleAccess_Impl(SwXDocumentIndex& rParentIdx); - - - //XIndexReplace - virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::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); - //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 ); +private: -}; - -/* -----------------13.09.99 16:39------------------- + virtual ~SwXDocumentIndexes(); - --------------------------------------------------*/ -class SwXIndexTokenAccess_Impl : public cppu::WeakImplHelper2 -< - ::com::sun::star::container::XIndexReplace, - ::com::sun::star::lang::XServiceInfo -> -{ - SwXDocumentIndex& rParent; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XDocumentIndex > xParent; - sal_Int32 nCount; -protected: - virtual ~SwXIndexTokenAccess_Impl(); public: - SwXIndexTokenAccess_Impl(SwXDocumentIndex& rParentIdx); - - - - //XIndexReplace - virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::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); - - //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 ); + SwXDocumentIndexes(SwDoc *const pDoc); + + // 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); + + // 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); + + // 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); }; #endif - diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx deleted file mode 100644 index 5fa7d155ef..0000000000 --- a/sw/inc/unoobj.hxx +++ /dev/null @@ -1,1493 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: unoobj.hxx,v $ - * - * $Revision: 1.49 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _UNOOBJ_HXX -#define _UNOOBJ_HXX - -#include <unoevtlstnr.hxx> -#include <unobaseclass.hxx> -#include <unocrsr.hxx> -#include <svl/itemprop.hxx> -#include <svl/svarray.hxx> -#include <frmfmt.hxx> -#include <flyenum.hxx> -#include <fldbas.hxx> -#include <fmtcntnt.hxx> -#include <pam.hxx> -#include <toxe.hxx> -#include <sortopt.hxx> -#include <com/sun/star/document/XDocumentInsertable.hpp> -#include <com/sun/star/text/XTextCursor.hpp> -#include <com/sun/star/text/XWordCursor.hpp> -#include <com/sun/star/text/XParagraphCursor.hpp> -#include <com/sun/star/text/XSentenceCursor.hpp> -#include <com/sun/star/text/XFootnote.hpp> -#include <com/sun/star/text/XTextSection.hpp> -#include <com/sun/star/text/XTextField.hpp> -#include <com/sun/star/text/XTextRange.hpp> -#include <com/sun/star/text/XText.hpp> -#include <com/sun/star/text/XTextContent.hpp> -#include <com/sun/star/util/XSortable.hpp> -#include <com/sun/star/container/XEnumerationAccess.hpp> -#include <com/sun/star/container/XContentEnumerationAccess.hpp> -#include <com/sun/star/container/XIndexAccess.hpp> -#include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/XMultiPropertySet.hpp> -#include <com/sun/star/beans/XTolerantMultiPropertySet.hpp> -#include <com/sun/star/beans/XPropertyState.hpp> -#include <com/sun/star/beans/XMultiPropertyStates.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> -#include <com/sun/star/text/XTextRangeCompare.hpp> -#include <com/sun/star/text/XRelativeTextContentInsert.hpp> -#include <com/sun/star/text/XRelativeTextContentRemove.hpp> -#include <com/sun/star/text/XTextAppendAndConvert.hpp> -#include <com/sun/star/text/XRedline.hpp> -#include <cppuhelper/weak.hxx> -#include <cppuhelper/factory.hxx> // helper for factories - -#include <cppuhelper/implbase1.hxx> // helper for implementations -#include <cppuhelper/implbase3.hxx> // helper for implementations -#include <cppuhelper/implbase4.hxx> // helper for implementations -#include <cppuhelper/implbase5.hxx> // helper for implementations -#include <cppuhelper/implbase6.hxx> // helper for implementations -#include <cppuhelper/implbase7.hxx> // helper for implementations -#include <cppuhelper/implbase8.hxx> -#include <cppuhelper/implbase9.hxx> -#include <cppuhelper/implbase10.hxx> -#include <cppuhelper/implbase12.hxx> // helper for implementations -#include "TextCursorHelper.hxx" -#include <comphelper/uno3.hxx> -#include <cppuhelper/weakref.hxx> -#include <com/sun/star/text/XFormField.hpp> - -#include <unomid.h> -#include <tools/link.hxx> - -#include <IDocumentMarkAccess.hxx> -#include <sfx2/Metadatable.hxx> - -#include <deque> -#include <boost/shared_ptr.hpp> - - -class SwFmtFtn; -class SwFmtRefMark; -class GetCurTxtFmtColl; - - -struct FrameDependSortListEntry { - xub_StrLen nIndex; - sal_uInt32 nOrder; - ::boost::shared_ptr<SwDepend> pFrameDepend; - FrameDependSortListEntry (xub_StrLen const i_nIndex, - sal_uInt32 const i_nOrder, SwDepend * const i_pDepend) - : nIndex(i_nIndex), nOrder(i_nOrder), pFrameDepend(i_pDepend) { } -}; -typedef ::std::deque< FrameDependSortListEntry > - FrameDependSortList_t; - -typedef ::std::deque< ::boost::shared_ptr<SwDepend> > - FrameDependList_t; - -/* -----------------29.04.98 07:35------------------- - * - * --------------------------------------------------*/ -enum CursorType -{ - CURSOR_INVALID, - CURSOR_BODY, - CURSOR_FRAME, - CURSOR_TBLTEXT, - CURSOR_FOOTNOTE, - CURSOR_HEADER, - CURSOR_FOOTER, - CURSOR_REDLINE, - CURSOR_ALL, // fuer Search&Replace - CURSOR_SELECTION, // create a paragraph enumeration from a text range or cursor - CURSOR_SELECTION_IN_TABLE, - CURSOR_META, // meta/meta-field -}; - - -/* -----------------26.06.98 16:18------------------- - * - * --------------------------------------------------*/ - -SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName); -::com::sun::star::uno::Sequence< sal_Int8 > CreateUnoTunnelId(); - -// OD 2004-05-07 #i28701# - adjust 4th parameter -void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, - FrameDependSortList_t & rFrames, - const bool _bAtCharAnchoredObjs ); - -/* -----------------29.04.98 07:35------------------- - * - * --------------------------------------------------*/ -class SwUnoInternalPaM : public SwPaM -{ - SwUnoInternalPaM( const SwUnoInternalPaM& ); -public: - SwUnoInternalPaM(SwDoc& rDoc); - ~SwUnoInternalPaM(); - - SwUnoInternalPaM& operator=(const SwPaM& rPaM); -}; - -/*-----------------04.03.98 11:54------------------- - Start/EndAction oder Start/EndAllAction ---------------------------------------------------*/ -class UnoActionContext -{ - SwDoc* pDoc; - public: - UnoActionContext(SwDoc* pDoc); - ~UnoActionContext(); - - void InvalidateDocument() {pDoc = 0;} -}; -/* -----------------07.07.98 12:03------------------- - * Actions kurzfristig unterbrechen - * --------------------------------------------------*/ -class UnoActionRemoveContext -{ - SwDoc* pDoc; - public: - UnoActionRemoveContext(SwDoc* pDoc); - ~UnoActionRemoveContext(); -}; - -/****************************************************************************** - * - ******************************************************************************/ -typedef com::sun::star::uno::Reference< com::sun::star::text::XTextRange > * XTextRangeRefPtr; -SV_DECL_PTRARR(XTextRangeArr, XTextRangeRefPtr, 4, 4) - -void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); - -/* -----------------03.12.98 12:22------------------- - * - * --------------------------------------------------*/ -class SwXTextRange; -class SwXTextCursor; -class SwXText : public ::com::sun::star::lang::XTypeProvider, - public ::com::sun::star::text::XTextRangeCompare, - public ::com::sun::star::text::XRelativeTextContentInsert, - public ::com::sun::star::text::XRelativeTextContentRemove, - public ::com::sun::star::beans::XPropertySet, - public ::com::sun::star::lang::XUnoTunnel, - public ::com::sun::star::text::XTextAppendAndConvert -{ - SwDoc* pDoc; - BOOL bObjectValid; - CursorType eCrsrType; - const SfxItemPropertySet* m_pPropSet; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL finishOrAppendParagraph( - bool bFinish, - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & CharacterAndParagraphProperties ) - throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - virtual void PrepareForAttach( ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > & xRange, - const SwXTextRange* const pRange, const SwPaM * const pPam); - -public: /*not protected because C++ is retarded*/ - virtual const SwStartNode *GetStartNode() const; - -public: - SwXText(SwDoc* pDc, CursorType eType); - virtual ~SwXText(); - - const SwDoc* GetDoc()const {return pDoc;} - SwDoc* GetDoc() {return pDoc;} - - // wenn ein SwXText attached wird, wird das Doc gesetzt - void SetDoc(SwDoc* pDc) - {DBG_ASSERT(!pDoc || !pDc, "Doc schon gesetzt?"); - pDoc = pDc; - bObjectValid = 0 != pDc; - } - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); - - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - - //XText - virtual void SAL_CALL insertString(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, const rtl::OUString& aString, BOOL bAbsorb) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL insertControlCharacter(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, sal_Int16 nControlCharacter, BOOL bAbsorb) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL insertTextContent(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xRange, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > & xContent, BOOL bAbsorb) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeTextContent(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > & xContent) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); - - //XTextRange - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual rtl::OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException ); - - //XTextRangeCompare - sal_Int16 SAL_CALL compareRegionStarts( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xR1, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xR2 ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - sal_Int16 SAL_CALL compareRegionEnds( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xR1, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xR2 ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XRelativeTextContentInsert - virtual void SAL_CALL insertTextContentBefore(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xNewContent, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xSuccessor) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL insertTextContentAfter(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xNewContent, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xPredecessor) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XRelativeTextContentRemove - virtual void SAL_CALL removeTextContentBefore(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xSuccessor) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeTextContentAfter(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent>& xPredecessor) throw(::com::sun::star::lang::IllegalArgumentException, ::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); - - //XUnoTunnel - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XParagraphAppend - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL appendParagraph( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & CharacterAndParagraphProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL finishParagraph( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & CharacterAndParagraphProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XTextPortionAppend - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL appendTextPortion( const ::rtl::OUString& Text, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & CharacterAndParagraphProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XTextContentAppend - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL appendTextContent( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >& TextContent, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& CharacterAndParagraphProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XTextConvert - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > SAL_CALL convertToTextFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& Start, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& End, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& FrameProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextTable > SAL_CALL convertToTable( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > > > >& TableRanges, - const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > >& CellProperties, - const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& RowProperties, - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& TableProperties - ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - - // - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException); - INT16 ComparePositions(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange>& xPos1, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange>& xPos2) throw (com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException); - BOOL CheckForOwnMember(const SwXTextRange* pRange1, const OTextCursorHelper* pCursor1)throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - // - void Invalidate() {bObjectValid = sal_False;} - BOOL IsValid()const {return bObjectValid;} - - CursorType GetTextType() {return eCrsrType;} -}; - -/* -----------------03.12.98 12:16------------------- - * - * --------------------------------------------------*/ -enum SwGetPropertyStatesCaller -{ - SW_PROPERTY_STATE_CALLER_DEFAULT, - SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION, - SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY, - SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT -}; -#define CRSR_ATTR_MODE_TABLE 1 //attributes should be applied to a table selection -#define CRSR_ATTR_MODE_DONTREPLACE 2 //attributes should be added, not replaced - -typedef cppu::WeakImplHelper12< - ::com::sun::star::text::XSentenceCursor, - ::com::sun::star::text::XWordCursor, - ::com::sun::star::text::XParagraphCursor, - ::com::sun::star::text::XRedline, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::beans::XPropertyState, - ::com::sun::star::document::XDocumentInsertable, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::util::XSortable, - ::com::sun::star::container::XContentEnumerationAccess, - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::beans::XMultiPropertyStates - > SwXTextCursor_Base; -class SwXTextCursor : public SwXTextCursor_Base, - public SwClient, - public OTextCursorHelper -{ - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - SwSortOptions* pLastSortOptions; - - CursorType eType; - - // --> FME 2006-03-07 #126177# We need to track if the RemoveCursor_Impl - // user event has been posted. In this case we have to remove the user - // event in ~SwXTextCursor(). - ULONG mnUserEventId; - bool mbRemoveUserEvent; - // <-- - - DECL_STATIC_LINK( SwXTextCursor, RemoveCursor_Impl, - ::com::sun::star::uno::Reference< - ::com::sun::star::uno::XInterface>* ); - -protected: - virtual ~SwXTextCursor(); -public: - void DeleteAndInsert(const String& rText, const bool bForceExpandHints); - SwXTextCursor(::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent, const SwPosition& rPos, - CursorType eSet, SwDoc* pDoc, const SwPosition* pMark = 0); - SwXTextCursor(::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent, SwUnoCrsr* pSourceCrsr, CursorType eSet = CURSOR_ALL); - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - DECLARE_XINTERFACE() - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XTextCursor - neu - virtual void SAL_CALL collapseToStart( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL collapseToEnd( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL isCollapsed( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL goLeft( sal_Int16 nCount, BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL goRight( sal_Int16 nCount, BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL gotoStart( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL gotoEnd( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL gotoRange( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xRange, BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - - //XWordCursor - neu - virtual BOOL SAL_CALL isStartOfWord( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL isEndOfWord( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoNextWord( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoPreviousWord( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoEndOfWord( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoStartOfWord( BOOL bExpand ) throw(::com::sun::star::uno::RuntimeException); - - //XSentenceCursor - neu - virtual BOOL SAL_CALL isStartOfSentence( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL isEndOfSentence( ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoNextSentence( BOOL Expand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoPreviousSentence( BOOL Expand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoStartOfSentence( BOOL Expand ) throw(::com::sun::star::uno::RuntimeException); - virtual BOOL SAL_CALL gotoEndOfSentence( BOOL Expand ) throw(::com::sun::star::uno::RuntimeException); - - //ParagraphCursor - neu - virtual BOOL SAL_CALL isStartOfParagraph(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL isEndOfParagraph(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL gotoStartOfParagraph(BOOL Expand) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL gotoEndOfParagraph(BOOL Expand) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL gotoNextParagraph(BOOL Expand) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL gotoPreviousParagraph(BOOL Expand) throw( ::com::sun::star::uno::RuntimeException ); - - //XRedline - virtual void SAL_CALL makeRedline( const ::rtl::OUString& RedlineType, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //XTextRange - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual rtl::OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setString(const rtl::OUString& aString) 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); - - //XPropertyState - virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - static void SetPropertyValue( - SwPaM& rPaM, - const SfxItemPropertySet& rPropSet, - const rtl::OUString& rPropertyName, - const ::com::sun::star::uno::Any& aValue, - USHORT nAttrMode = 0) - 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); - static ::com::sun::star::uno::Any GetPropertyValue( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const ::rtl::OUString& rPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > GetPropertyStates( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, SwGetPropertyStatesCaller eCaller = SW_PROPERTY_STATE_CALLER_DEFAULT) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::beans::PropertyState GetPropertyState( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const ::rtl::OUString& rPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - static void SetPropertyToDefault( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const rtl::OUString& rPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Any GetPropertyDefault( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const ::rtl::OUString& rPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XDocumentInsertable - neu - virtual void SAL_CALL insertDocumentFromURL(const rtl::OUString& rURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aOptions) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException ); - - //XSortable - neu - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL createSortDescriptor(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL sort(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& xDescriptor) throw( ::com::sun::star::uno::RuntimeException ); - - //XContentEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) 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); - - //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 ); - - //XMultiPropertyStates - //virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setAllPropertiesToDefault( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertiesToDefault( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyDefaults( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - virtual const SwPaM* GetPaM() const; - virtual SwPaM* GetPaM(); - virtual const SwDoc* GetDoc() const; - virtual SwDoc* GetDoc(); - SwUnoCrsr* GetCrsr(){return (SwUnoCrsr*)GetRegisteredIn();} - const SwUnoCrsr* GetCrsr()const{return (SwUnoCrsr*)GetRegisteredIn();} - - static void SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAttrMode ); - // --> OD 2006-07-12 #i63870# - // split third parameter <bCurrentAttrOnly> into new parameters <bOnlyTxtAttr> - // and <bGetFromChrFmt> to get better control about resulting <SfxItemSet> -// static void GetCrsrAttr(SwPaM& rPam, SfxItemSet& rSet, BOOL bCurrentAttrOnly = FALSE); - static void GetCrsrAttr( SwPaM& rPam, - SfxItemSet& rSet, - BOOL bOnlyTxtAttr = FALSE, - BOOL bGetFromChrFmt = TRUE ); - // <-- - static void getTextFromPam(SwPaM& aCrsr, rtl::OUString& rBuffer); - static SwFmtColl* GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional); - - static void SelectPam(SwPaM& rCrsr, sal_Bool bExpand); - static void SetString(SwCursor& rCrsr, const rtl::OUString& rString); - - static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > - createSortDescriptor(sal_Bool bFromTable); - static sal_Bool convertSortProperties( - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rDescriptor, - SwSortOptions& rSortOpt); - - // --> FME 2006-03-07 #126177# - void DoNotRemoveUserEvent() { mbRemoveUserEvent = false; } - // <-- - - bool IsAtEndOfMeta() const; -}; -/*-----------------20.03.98 07:47------------------- - ---------------------------------------------------*/ -/* das wird zunaechst nicht gebraucht - bisher fuer den XPropertySetCloner -class SwXPropertySet : public ::com::sun::star::beans::XPropertySet, - public UsrObject -{ - ::com::sun::star::uno::Sequence<::com::sun::star::uno::Any>* pAny; - ::com::sun::star::uno::Sequence< Property >* pInfo; - -public: - // Eigentumsuebergang der Pointer! - SwXPropertySet( ::com::sun::star::uno::Sequence<::com::sun::star::uno::Any>* pAny, - ::com::sun::star::uno::Sequence<Property>* pInfo ); - virtual ~SwXPropertySet(); - - SMART_UNO_DECLARATION( SwXPropertySet, UsrObject ); - - //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); - -}; -*/ -/*-----------------20.03.98 08:26------------------- - ---------------------------------------------------*/ -/* das wird zunaechst nicht gebraucht - bisher fuer den XPropertySetCloner - -class SwXPropertySetInfo: public ::com::sun::star::beans::XPropertySetInfo, UsrObject -{ - ::com::sun::star::uno::Sequence< Property >* pSeq; - -public: - SwXPropertySetInfo( const ::com::sun::star::uno::Sequence<Property>& rInfo ); - virtual ~SwXPropertySetInfo(); - - SMART_UNO_DECLARATION( SwXPropertySetInfo, UsrObject ); - - virtual ::com::sun::star::uno::Sequence< Property > getProperties(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual Property getPropertyByName(const rtl::OUString& Name) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL hasPropertyByName(const rtl::OUString& Name) throw( ::com::sun::star::uno::RuntimeException ); -}; -*/ - -typedef ::cppu::ImplInheritanceHelper5 -< - ::sfx2::MetadatableMixin, - ::com::sun::star::text::XTextContent, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XNamed, - ::com::sun::star::lang::XUnoTunnel -> -SwBookmarkBaseClass; - -class SwXBookmark - : public SwBookmarkBaseClass - , private SwClient -{ - private: - SwEventListenerContainer m_aLstnrCntnr; - SwDoc* m_pDoc; - String m_aName; - ::sw::mark::IMark* m_pRegisteredBookmark; - - void registerInMark(::sw::mark::IMark* const pBkmk) - { - if(pBkmk) - pBkmk->Add(this); - else if(m_pRegisteredBookmark) - { - m_aName = m_pRegisteredBookmark->GetName(); - m_pRegisteredBookmark->Remove(this); - } - m_pRegisteredBookmark = pBkmk; - } - - protected: - virtual ~SwXBookmark(); - public: - SwXBookmark(::sw::mark::IMark* pMark = 0, SwDoc* pDoc = 0); - - TYPEINFO(); - - 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); - - //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); - - //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& rName) 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 ); - - //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); - - void attachToRangeEx(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange, IDocumentMarkAccess::MarkType eType) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); - virtual 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 ); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); - - // MetadatableMixin - virtual ::sfx2::Metadatable* GetCoreObject(); - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > GetModel(); - - const ::sw::mark::IMark* GetBookmark() const - { return m_pRegisteredBookmark; } - ::sw::mark::IMark* GetBookmark() - { return m_pRegisteredBookmark; } - SwDoc* GetDoc() - { return m_pDoc; } -}; - -typedef cppu::ImplInheritanceHelper1< SwXBookmark, ::com::sun::star::text::XFormField > SwXFieldmark_BASE; - -class SwXFieldmark : public SwXFieldmark_BASE -{ - private: - bool isReplacementObject; - public: - SwXFieldmark(bool isReplacementObject, ::sw::mark::IMark* pBkm = 0, SwDoc* pDoc = 0); - - virtual 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 ); - virtual ::rtl::OUString SAL_CALL getDescription(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::sal_Int16 SAL_CALL getType( ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int16 SAL_CALL getRes( ) throw (::com::sun::star::uno::RuntimeException); - - virtual void SAL_CALL setType( ::sal_Int16 fieldType ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setRes( ::sal_Int16 res ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setDescription( const ::rtl::OUString& description ) throw (::com::sun::star::uno::RuntimeException); -}; - -/*-----------------23.02.98 10:45------------------- - ---------------------------------------------------*/ - -typedef cppu::WeakAggImplHelper2 -< - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::lang::XServiceInfo -> SwXBodyTextBaseClass; -class SwXBodyText : public SwXBodyTextBaseClass, - public SwXText -{ -protected: - virtual ~SwXBodyText(); -public: - SwXBodyText(SwDoc* pDoc); - - - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL acquire( ) throw(){OWeakObject::acquire();} - virtual void SAL_CALL release( ) throw(){OWeakObject::release();} - - //XAggregation - virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); - - //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); - - //XText - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursor(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursorByRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & aTextPosition) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - frueher XParagraphEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) 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); - - //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 ); - - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > CreateTextCursor(BOOL bIgnoreTables = sal_False); -}; - -class SW_DLLPUBLIC SwXTextRange : public cppu::WeakImplHelper8 -< - ::com::sun::star::text::XTextRange, - ::com::sun::star::lang::XUnoTunnel, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XContentEnumerationAccess, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::beans::XPropertyState, - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::text::XRedline ->, private SwClient -{ - friend class SwXText; - enum RangePosition - { - RANGE_IN_TEXT, // 'normaler' ::com::sun::star::text::TextRange - RANGE_IN_FRAME,// TextPosition wurde mit einem Rahmen angelegt, der kein Uno-Objekt besitzt - RANGE_IN_CELL, // TextPosition wurde mit einer Zelle angelegt, die kein Uno-Objekt besitzt - RANGE_IS_TABLE, // Anker einer Tabelle - RANGE_INVALID // von NewInstance erzeugt - } eRangePosition; - - SwDoc* pDoc; - SwTableBox* pBox; - const SwStartNode* pBoxStartNode; - SwDepend aObjectDepend; //Format der Tabelle oder des Rahmens anmelden - const SfxItemPropertySet* m_pPropSet; - //SwDepend aFrameDepend; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - ::sw::mark::IMark* pMark; - - void _CreateNewBookmark(SwPaM& rPam); - //TODO: new exception type for protected content - void DeleteAndInsert(const String& rText, const bool bForceExpandHints) - throw( ::com::sun::star::uno::RuntimeException ); -protected: - virtual ~SwXTextRange(); - -public: - SwXTextRange(SwPaM& rPam, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > & rxParent, enum RangePosition eRange = RANGE_IN_TEXT); - // only for RANGE_IS_TABLE - SwXTextRange(SwFrmFmt& rTblFmt); - - TYPEINFO(); - - 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); - - //XTextRange - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual rtl::OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException ); - - //XContentEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) 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); - - //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 ); - - //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); - - //XPropertyState - virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - //XRedline - virtual void SAL_CALL makeRedline( const ::rtl::OUString& RedlineType, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - //SwClient - virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); - BOOL GetPositions(SwPaM& rToFill) const; - const SwDoc* GetDoc() const - { return pDoc; } - SwDoc* GetDoc() - { return pDoc; } - const ::sw::mark::IMark * GetBookmark() const - { return pMark; } - - static BOOL XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, - const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange); - static ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > CreateTextRangeFromPosition( - SwDoc* pDoc, - const SwPosition& rPos, const SwPosition* pMark); - static ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > CreateParentXText(SwDoc* pDoc, - const SwPosition& rPos); -}; - -/* -----------------15.05.98 08:29------------------- - * - * --------------------------------------------------*/ -typedef cppu::WeakImplHelper3 -< - ::com::sun::star::container::XIndexAccess, - ::com::sun::star::lang::XUnoTunnel, - ::com::sun::star::lang::XServiceInfo -> -SwXTextRangesBaseClass; -class SwXTextRanges : public SwXTextRangesBaseClass, - public SwClient -{ - XTextRangeArr* pRangeArr; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - XTextRangeArr* GetRangesArray(); - SwUnoCrsr* GetCrsr() const { return (SwUnoCrsr*)GetRegisteredIn(); } -protected: - virtual ~SwXTextRanges(); -public: - SwXTextRanges(); - SwXTextRanges(SwPaM* pCrsr); - - - 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); - - - //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); - - //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); - const SwUnoCrsr* GetCursor() const { return (const SwUnoCrsr*)GetRegisteredIn(); } -}; - -/*-----------------09.03.98 13:57------------------- - ---------------------------------------------------*/ - -class SwXTextSection; -class SwXTextSectionClient : public SwClient -{ - friend class SwXTextSection; - SwXTextSection* m_pSection; - ::com::sun::star::uno::WeakReference< ::com::sun::star::text::XTextSection > m_xReference; - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - SwXTextSectionClient( - SwSectionFmt& rFmt, - SwXTextSection& rTextSection, - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > xSection ); - virtual ~SwXTextSectionClient(); - DECL_STATIC_LINK( SwXTextSectionClient, RemoveSectionClient_Impl, - SwXTextSectionClient* ); - -public: - TYPEINFO(); - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > GetXTextSection(); - - static ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > - CreateXTextSection(SwSectionFmt* pFmt = 0, BOOL bIndexHeader = FALSE ); - static SwXTextSectionClient* Create( - SwXTextSection& rSection, - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > xSection, - SwSectionFmt& rFmt ); -}; - -struct SwTextSectionProperties_Impl; -class SwXTextSection : public cppu::WeakImplHelper7 -< - ::com::sun::star::text::XTextSection, - ::com::sun::star::beans::XPropertyState, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::beans::XMultiPropertySet, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XNamed, - ::com::sun::star::lang::XUnoTunnel ->/*, - public SwClient*/ -{ - friend class SwXTextSectionClient; - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - - BOOL m_bIsDescriptor; - BOOL m_bIndexHeader; - String m_sName; - SwTextSectionProperties_Impl* pProps; - SwXTextSectionClient* m_pClient; -protected: - void SAL_CALL SetPropertyValues_Impl( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) 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); - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL GetPropertyValues_Impl( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - SwXTextSection(sal_Bool bWithFormat, sal_Bool bIndexHeader = FALSE); - virtual ~SwXTextSection(); - void ResetClient() {m_pClient = 0;} - void SetClient( SwXTextSectionClient* pClient ){m_pClient = pClient;} - -public: - 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); - - //XTextSection - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > SAL_CALL getParentSection(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextSection > > SAL_CALL getChildSections(void) 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); - - //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 ); - - //XMultiPropertySet -// virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw(::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::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& 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& 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); - - //XPropertyState - virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::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 ); - - SwSectionFmt* GetFmt()const; - static SwXTextSection* GetImplementation(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xRef ); -}; -/*-----------------12.02.98 08:01------------------- - ---------------------------------------------------*/ -typedef -cppu::WeakImplHelper5 -< - ::com::sun::star::text::XFootnote, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XUnoTunnel -> -SwXFootnoteBaseClass; -class SwXFootnote : public SwXFootnoteBaseClass, - public SwXText, - public SwClient -{ - friend class SwXFootnotes; - - SwEventListenerContainer aLstnrCntnr; - const SwFmtFtn* pFmtFtn; - BOOL m_bIsDescriptor; - String m_sLabel; - BOOL m_bIsEndnote; - -protected: - virtual const SwStartNode *GetStartNode() const; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException); - virtual ~SwXFootnote(); -public: - SwXFootnote(BOOL bEndnote); - SwXFootnote(SwDoc* pDoc, const SwFmtFtn& rFmt); - - - TYPEINFO(); - - 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); - - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL acquire( ) throw(){SwXFootnoteBaseClass::acquire();} - virtual void SAL_CALL release( ) throw(){SwXFootnoteBaseClass::release();} - - //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); - - //XFootnote - virtual rtl::OUString SAL_CALL getLabel(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setLabel(const rtl::OUString& aLabel) 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); - - //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 ); - - //XText - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursor(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursorByRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & aTextPosition) throw( ::com::sun::star::uno::RuntimeException ); - - //XEnumerationAccess - frueher XParagraphEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) 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); - - //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 ); - - //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); - - //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 ); - - const SwFmtFtn* FindFmt() const {return GetDoc() ? pFmtFtn : 0;} - void Invalidate(); -}; - -/*-----------------07.04.98 08:10------------------- - ---------------------------------------------------*/ -class SwXParagraphEnumeration : public SwSimpleEnumerationBaseClass, - public SwClient -{ - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xNextPara; - - const SwTable * pOwnTable; - const SwStartNode * pOwnStartNode; // start node of the cell the enumeration - // belongs to. - // Used to restrict the movement of the - // UNO cursor to the cell and its - // embedded tables. - sal_Int32 nFirstParaStart; - sal_Int32 nLastParaEnd; - ULONG nEndIndex; - CursorType eCursorType; - BOOL bFirstParagraph; - - SwUnoCrsr* GetCrsr(){return (SwUnoCrsr*)GetRegisteredIn();} - -protected: - virtual ~SwXParagraphEnumeration(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > SAL_CALL NextElement_Impl(void) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - -public: - SwXParagraphEnumeration(SwXText* pParent, SwPosition& rPos, CursorType eType); - SwXParagraphEnumeration(SwXText* pParent, SwUnoCrsr* pCrsr, CursorType eType); - - - - //XEnumeration - virtual BOOL SAL_CALL hasMoreElements(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL nextElement(void) throw( ::com::sun::star::container::NoSuchElementException, ::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 ); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - //non-Uno functions - - void SetOwnTable( const SwTable* pTable ) { pOwnTable = pTable; } - const SwTable* GetOwnTable() const { return pOwnTable; } - void SetOwnStartNode( const SwStartNode* pNode ) { pOwnStartNode = pNode; } - const SwStartNode* GetOwnStartNode() const { return pOwnStartNode; } -}; -/*-----------------07.04.98 08:15------------------- - ---------------------------------------------------*/ -class SwXParagraph : public cppu::ImplInheritanceHelper10 -< - ::sfx2::MetadatableMixin, - ::com::sun::star::beans::XTolerantMultiPropertySet, - ::com::sun::star::beans::XMultiPropertySet, - ::com::sun::star::text::XTextRange, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::lang::XUnoTunnel, - ::com::sun::star::beans::XPropertyState, - ::com::sun::star::container::XEnumerationAccess, - ::com::sun::star::text::XTextContent, - ::com::sun::star::container::XContentEnumerationAccess ->, - public SwClient -{ - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - rtl::OUString m_sText; - sal_Int32 nSelectionStartPos; - sal_Int32 nSelectionEndPos; - BOOL m_bIsDescriptor; - - -protected: - void SAL_CALL SetPropertyValues_Impl( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) 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); - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL GetPropertyValues_Impl( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL GetPropertyValuesTolerant_Impl( - const ::com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames, - sal_Bool bDirectValuesOnly ) throw (::com::sun::star::uno::RuntimeException); - - virtual ~SwXParagraph(); -public: - SwXParagraph(); - SwXParagraph(::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const & i_xParent, SwTxtNode * i_pTxtNode, sal_Int32 nSelStart = -1, sal_Int32 nSelEnd = - 1); - - TYPEINFO(); - - 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); - - //XTolerantMultiPropertySet - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::SetPropertyTolerantFailed > SAL_CALL setPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException); - - //XMultiPropertySet -// virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw(::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::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& 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& 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); - - //XPropertyState - virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) 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( ) 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 ); - - //XEnumerationAccess - war XTextPortionEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) 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); - - //XTextRange - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual rtl::OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL setString(const rtl::OUString& aString) 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 ); - - //XContentEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //MetadatableMixin - virtual ::sfx2::Metadatable* GetCoreObject(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > - GetModel(); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - - BOOL IsDescriptor() const {return m_bIsDescriptor;} - - const SwTxtNode * GetTxtNode() const; - SwTxtNode * GetTxtNode(); - - static BOOL getDefaultTextContentValue(::com::sun::star::uno::Any& rAny, - const rtl::OUString& rPropertyName, USHORT nWID = 0); - static SwXParagraph* GetImplementation(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xRef ); - //falls es mal als Service erzeugt werden kann - //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 ); - void attachToText(SwXText* pParent, SwUnoCrsr* pCrsr); -}; -/* -----------------23.03.99 12:57------------------- - * - * --------------------------------------------------*/ -#define PARAFRAME_PORTION_PARAGRAPH 0 -#define PARAFRAME_PORTION_CHAR 1 -#define PARAFRAME_PORTION_TEXTRANGE 2 - -class SwXParaFrameEnumeration : public cppu::WeakImplHelper2 -< - ::com::sun::star::container::XEnumeration, - ::com::sun::star::lang::XServiceInfo ->, - public SwClient -{ - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > - m_xNextObject; // created by hasMoreElements - FrameDependList_t m_Frames; - - SwUnoCrsr* GetCursor() const - {return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));} - -public: - SwXParaFrameEnumeration(const SwPaM& rPaM, - sal_uInt8 nParaFrameMode, SwFrmFmt* pFmt = 0); - ~SwXParaFrameEnumeration(); - - // XEnumeration - virtual sal_Bool SAL_CALL hasMoreElements() - throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL nextElement() - throw( ::com::sun::star::container::NoSuchElementException, - ::com::sun::star::lang::WrappedTargetException, - ::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& ServiceName) - throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL - getSupportedServiceNames() - throw( ::com::sun::star::uno::RuntimeException ); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); -}; - - -/* -----------------29.09.98 09:01------------------- - * - * --------------------------------------------------*/ -/* os: 04.12.98 11:40 hier gibt es noch keine sinnvolle Definition -#define MAX_SORT_FIELDS 3 // das ist eher willkuerlich (wie im Dialog) -class SwXTextSortDescriptor : public XTextSortDescriptor, - public UsrObject -{ - SwSortOptions aSortOptions; - BOOL bUseHeader; -public: - SwXTextSortDescriptor(BOOL bUsedInTable); - virtual ~SwXTextSortDescriptor(); - - //XTextSortDescriptor - virtual sal_Unicode getTextColumnSeparator(void) const; - virtual void setTextColumnSeparator(sal_Unicode TextColumnSeparator_); - - //XSortDescriptor - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::util::SortField > getSortFields(void) const; - virtual void setSortFields(const ::com::sun::star::uno::Sequence< ::com::sun::star::util::SortField >& SortFields_); - virtual sal_uInt16 getMaxFieldCount(void) const; - virtual ColumnsOrRows getOrientation(void) const; - virtual void setOrientation(ColumnsOrRows Orientation_); - virtual BOOL getUseHeader(void) const; - virtual void setUseHeader(BOOL UseHeader_); - - const SwSortOptions& GetSortOptions() const {return aSortOptions;} - void SetSortOptions(const SwSortOptions& rSortOpt); -}; -*/ -/* -----------------25.08.98 11:02------------------- - * - * --------------------------------------------------*/ -typedef -cppu::WeakImplHelper2 -< - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XEnumerationAccess -> -SwXHeadFootTextBaseClass; -class SwXHeadFootText : public SwXHeadFootTextBaseClass, - public SwXText, - public SwClient -{ - SwFrmFmt* GetFmt() const { return (SwFrmFmt*)GetRegisteredIn(); } - BOOL bIsHeader; -protected: - virtual const SwStartNode *GetStartNode() const; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException); -public: - SwXHeadFootText(SwFrmFmt& rHeadFootFmt, BOOL bHeader); - ~SwXHeadFootText(); - - TYPEINFO(); - - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL acquire( ) throw(){SwXHeadFootTextBaseClass::acquire();} - virtual void SAL_CALL release( ) throw(){SwXHeadFootTextBaseClass::release();} - - //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); - - //XText - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursor(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursorByRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & aTextPosition) 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 ); - - //XEnumerationAccess - frueher XParagraphEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(void) 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); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); -}; -/* -----------------27.08.98 15:11------------------- - * - * --------------------------------------------------*/ -typedef ::cppu::WeakImplHelper5 -< - ::com::sun::star::text::XTextContent, - ::com::sun::star::beans::XPropertySet, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::container::XNamed, - ::com::sun::star::lang::XUnoTunnel -> -SwRefMarkBaseClass; - -class SwXReferenceMark : public SwRefMarkBaseClass, - public SwClient -{ - SwEventListenerContainer aLstnrCntnr; - SwDoc* pDoc; - const SwFmtRefMark* pMark; - String sMarkName; - BOOL m_bIsDescriptor; - - BOOL IsValid() const {return 0 != GetRegisteredIn();} - void InsertRefMark( SwPaM& rPam, SwXTextCursor * pCursor ); -public: - SwXReferenceMark(SwDoc* pDoc, const SwFmtRefMark* pMark); - ~SwXReferenceMark(); - - TYPEINFO(); - - 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); - - //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); - - //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 ); - - //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); - - //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 ); - - const SwFmtRefMark* GetMark()const {return pMark;} - const String& GetMarkName() const {return sMarkName;} - SwDoc* GetDoc() const{return pDoc;} - void Invalidate(); -}; -#endif - - diff --git a/sw/inc/unoparaframeenum.hxx b/sw/inc/unoparaframeenum.hxx new file mode 100644 index 0000000000..7e5b43f1e6 --- /dev/null +++ b/sw/inc/unoparaframeenum.hxx @@ -0,0 +1,131 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOPARAFRAMEENUM_HXX +#define SW_UNOPARAFRAMEENUM_HXX + +#include <deque> + +#include <boost/shared_ptr.hpp> + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XEnumeration.hpp> +#include <com/sun/star/text/XTextContent.hpp> + +#include <cppuhelper/implbase2.hxx> + +#include <unobaseclass.hxx> + + +class SwDepend; +class SwNodeIndex; +class SwPaM; +class SwFrmFmt; + + +struct FrameDependSortListEntry +{ + xub_StrLen nIndex; + sal_uInt32 nOrder; + ::boost::shared_ptr<SwDepend> pFrameDepend; + + FrameDependSortListEntry (xub_StrLen const i_nIndex, + sal_uInt32 const i_nOrder, SwDepend * const i_pDepend) + : nIndex(i_nIndex), nOrder(i_nOrder), pFrameDepend(i_pDepend) { } +}; + +typedef ::std::deque< FrameDependSortListEntry > + FrameDependSortList_t; + +typedef ::std::deque< ::boost::shared_ptr<SwDepend> > + FrameDependList_t; + + +// OD 2004-05-07 #i28701# - adjust 4th parameter +void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, + FrameDependSortList_t & rFrames, + const bool _bAtCharAnchoredObjs ); + + +/* -----------------23.03.99 12:57------------------- + * + * --------------------------------------------------*/ + +enum ParaFrameMode +{ + PARAFRAME_PORTION_PARAGRAPH, + PARAFRAME_PORTION_CHAR, + PARAFRAME_PORTION_TEXTRANGE, +}; + +typedef ::cppu::WeakImplHelper2 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumeration +> SwXParaFrameEnumeration_Base; + +class SwXParaFrameEnumeration + : public SwXParaFrameEnumeration_Base +{ + +private: + + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + + virtual ~SwXParaFrameEnumeration(); + +public: + + SwXParaFrameEnumeration(const SwPaM& rPaM, + const enum ParaFrameMode eParaFrameMode, SwFrmFmt *const pFmt = 0); + + // 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); + + // XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL nextElement() + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOPARAFRAMEENUM_HXX + diff --git a/sw/inc/unoparagraph.hxx b/sw/inc/unoparagraph.hxx new file mode 100644 index 0000000000..8743737c33 --- /dev/null +++ b/sw/inc/unoparagraph.hxx @@ -0,0 +1,369 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOPARAGRAPH_HXX +#define SW_UNOPARAGRAPH_HXX + +#include <memory> + +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/beans/XTolerantMultiPropertySet.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XContentEnumerationAccess.hpp> +#include <com/sun/star/text/XTextContent.hpp> +#include <com/sun/star/text/XTextRange.hpp> + +#include <cppuhelper/implbase10.hxx> + +#include <sfx2/Metadatable.hxx> + +#include <unobaseclass.hxx> + + +struct SwPosition; +class SwPaM; +class SwUnoCrsr; +class SwStartNode; +class SwTxtNode; +class SwTable; +class SwXText; + + +/*-----------------07.04.98 08:15------------------- + +--------------------------------------------------*/ +typedef ::cppu::ImplInheritanceHelper10 +< ::sfx2::MetadatableMixin +, ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::beans::XPropertyState +, ::com::sun::star::beans::XMultiPropertySet +, ::com::sun::star::beans::XTolerantMultiPropertySet +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::container::XContentEnumerationAccess +, ::com::sun::star::text::XTextContent +, ::com::sun::star::text::XTextRange +> SwXParagraph_Base; + +class SwXParagraph + : public SwXParagraph_Base +{ + +private: + + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + + virtual ~SwXParagraph(); + + SwXParagraph(::com::sun::star::uno::Reference< + ::com::sun::star::text::XText > const & xParent, + SwTxtNode & rTxtNode, + const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = - 1); + +public: + + /// descriptor + SwXParagraph(); + + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent> + CreateXParagraph(SwDoc & rDoc, SwTxtNode& rTxtNode, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> + const& xParentText = 0, + const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = - 1); + + const SwTxtNode * GetTxtNode() const; + bool IsDescriptor() const; + /// make rPaM select the paragraph + bool SelectPaM(SwPaM & rPaM); + /// for SwXText + void attachToText(SwXText & rParent, SwTxtNode & rTxtNode); + + // MetadatableMixin + virtual ::sfx2::Metadatable* GetCoreObject(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + GetModel(); + + 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 >& 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); + + // XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL + getPropertyState(const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > SAL_CALL + getPropertyStates( + const ::com::sun::star::uno::Sequence< + ::rtl::OUString >& rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XMultiPropertySet + virtual void SAL_CALL setPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& rValues) + throw (::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::Sequence< ::com::sun::star::uno::Any > + SAL_CALL getPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertiesChangeListener( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertiesChangeListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL firePropertiesChangeEvent( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XTolerantMultiPropertySet + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::SetPropertyTolerantFailed > SAL_CALL + setPropertyValuesTolerant( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& rValues) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::GetPropertyTolerantResult > SAL_CALL + getPropertyValuesTolerant( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::GetDirectPropertyTolerantResult > SAL_CALL + getDirectPropertyValuesTolerant( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + 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); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XContentEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createContentEnumeration(const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getAvailableServiceNames() + 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); + + // XTextRange + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + SAL_CALL getText() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getStart() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(const ::rtl::OUString& rString) + throw (::com::sun::star::uno::RuntimeException); + +}; + + +/*-----------------07.04.98 08:10------------------- + +--------------------------------------------------*/ +class SwXParagraphEnumeration + : public SwSimpleEnumeration_Base +{ + +private: + + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + + virtual ~SwXParagraphEnumeration(); + +public: + + /// takes ownership of cursor + SwXParagraphEnumeration( + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + const & xParent, + ::std::auto_ptr<SwUnoCrsr> pCursor, + const CursorType eType, + SwStartNode const*const pStartNode = 0, + SwTable const*const pTable = 0); + + // 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); + + // XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL nextElement() + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOPARAGRAPH_HXX + diff --git a/sw/inc/unoredline.hxx b/sw/inc/unoredline.hxx index 508bbb2a7a..a2449c6f0a 100644 --- a/sw/inc/unoredline.hxx +++ b/sw/inc/unoredline.hxx @@ -31,9 +31,11 @@ #define _UNOREDLINE_HXX #include <unoport.hxx> -#include <unoobj.hxx> +#include <unotext.hxx> + class SwRedline; + /* -----------------------------19.12.00 11:35-------------------------------- ---------------------------------------------------------------------------*/ diff --git a/sw/inc/unoredlines.hxx b/sw/inc/unoredlines.hxx index 8f932617f4..f87ac44188 100644 --- a/sw/inc/unoredlines.hxx +++ b/sw/inc/unoredlines.hxx @@ -78,8 +78,9 @@ public: /* -----------------------------12.01.01 14:58-------------------------------- ---------------------------------------------------------------------------*/ -class SwXRedlineEnumeration : public SwSimpleEnumerationBaseClass, - public SwClient +class SwXRedlineEnumeration + : public SwSimpleEnumeration_Base + , public SwClient { SwDoc* pDoc; USHORT nCurrentIndex; diff --git a/sw/inc/unorefmark.hxx b/sw/inc/unorefmark.hxx new file mode 100644 index 0000000000..61b6d09df0 --- /dev/null +++ b/sw/inc/unorefmark.hxx @@ -0,0 +1,178 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOREFMARK_HXX +#define SW_UNOREFMARK_HXX + +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/text/XTextContent.hpp> + +#include <cppuhelper/implbase5.hxx> + +#include <unobaseclass.hxx> + + +class SwDoc; +class SwModify; +class SwFmtRefMark; + + +/* -----------------27.08.98 15:11------------------- + * + * --------------------------------------------------*/ +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::XTextContent +> SwXReferenceMark_Base; + +class SwXReferenceMark + : public SwXReferenceMark_Base +{ + +private: + + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + + virtual ~SwXReferenceMark(); + +public: + + SwXReferenceMark(SwDoc *const pDoc, const SwFmtRefMark *const pMark); + + static SwXReferenceMark * + CreateXReferenceMark(SwDoc & rDoc, SwFmtRefMark const& rMarkFmt); + /// may return 0 + static SwXReferenceMark * + GetReferenceMark(SwModify const& rUnoCB, SwFmtRefMark const& rMarkFmt); + + 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 >& 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); + +}; + +#endif // SW_UNOREFMARK_HXX + diff --git a/sw/inc/unosection.hxx b/sw/inc/unosection.hxx new file mode 100644 index 0000000000..6f3eb1794c --- /dev/null +++ b/sw/inc/unosection.hxx @@ -0,0 +1,251 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOSECTION_HXX +#define SW_UNOSECTION_HXX + +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/text/XTextContent.hpp> +#include <com/sun/star/text/XTextSection.hpp> + +#include <cppuhelper/implbase7.hxx> + +#include <unobaseclass.hxx> + + +class SwSectionFmt; + + +/*-----------------09.03.98 13:57------------------- + +--------------------------------------------------*/ + + +struct SwTextSectionProperties_Impl; + +typedef ::cppu::WeakImplHelper7 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::beans::XPropertyState +, ::com::sun::star::beans::XMultiPropertySet +, ::com::sun::star::container::XNamed +, ::com::sun::star::text::XTextSection +> SwXTextSection_Base; + +class SwXTextSection + : public SwXTextSection_Base +{ + +private: + + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + + SwXTextSection(SwSectionFmt *const pFmt, const bool bIndexHeader = false); + + virtual ~SwXTextSection(); + +public: + + SwSectionFmt* GetFmt() const; + + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextSection > + CreateXTextSection(SwSectionFmt *const pFmt = 0, + const bool bIndexHeader = false); + + 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 >& 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); + + // XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL + getPropertyState(const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > SAL_CALL + getPropertyStates( + const ::com::sun::star::uno::Sequence< + ::rtl::OUString >& rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XMultiPropertySet + virtual void SAL_CALL setPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& rValues) + throw (::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::Sequence< ::com::sun::star::uno::Any > + SAL_CALL getPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertiesChangeListener( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertiesChangeListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL firePropertiesChangeEvent( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertiesChangeListener >& xListener) + throw (::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); + + // XTextSection + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextSection > SAL_CALL + getParentSection() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextSection > > SAL_CALL + getChildSections() + throw (::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOSECTION_HXX + diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index 05983afdba..7b2272b090 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -30,7 +30,9 @@ #ifndef _UNOTBL_HXX #define _UNOTBL_HXX -#include <unoobj.hxx> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/util/XSortable.hpp> #include <com/sun/star/chart/XChartData.hpp> #include <com/sun/star/chart/XChartDataArray.hpp> #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp> @@ -39,17 +41,30 @@ #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/sheet/XCellRangeData.hpp> #include <com/sun/star/table/XAutoFormattable.hpp> -#include <cppuhelper/implbase10.hxx> // helper for implementations -#include <cppuhelper/implbase7.hxx> // helper for implementations -#include <cppuhelper/implbase5.hxx> // helper for implementations -class SwTableBoxFmt; +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/implbase5.hxx> +#include <cppuhelper/implbase7.hxx> +#include <cppuhelper/implbase10.hxx> + +#include <comphelper/uno3.hxx> +#include <tools/string.hxx> + +#include <calbck.hxx> +#include <TextCursorHelper.hxx> +#include <unoevtlstnr.hxx> +#include <unotext.hxx> + + +class SwUnoCrsr; +class SwTable; +class SwTableBox; class SwTableLine; class SwTableCursor; class SwTableBoxFmt; -class SwTableLine; -class SwTableCursor; class SwChartDataProvider; +class SwFrmFmt; /* -----------------------------22.09.00 11:10-------------------------------- @@ -91,14 +106,16 @@ class SwXCell : public SwXCellBaseClass, // table position where pBox was found last sal_uInt16 nFndPos; - using SwXText::IsValid; - protected: virtual const SwStartNode *GetStartNode() const; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException); - - sal_Bool IsValid(); - + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > + CreateCursor() + throw (::com::sun::star::uno::RuntimeException); + + bool IsValid() const; + virtual ~SwXCell(); public: diff --git a/sw/inc/unotext.hxx b/sw/inc/unotext.hxx new file mode 100644 index 0000000000..3c805da512 --- /dev/null +++ b/sw/inc/unotext.hxx @@ -0,0 +1,343 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOTEXT_HXX +#define SW_UNOTEXT_HXX + +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/text/XTextRangeCompare.hpp> +#include <com/sun/star/text/XRelativeTextContentInsert.hpp> +#include <com/sun/star/text/XRelativeTextContentRemove.hpp> +#include <com/sun/star/text/XTextAppendAndConvert.hpp> + +#include <unobaseclass.hxx> + + +namespace com { namespace sun { namespace star { + namespace text { + class XTextContent; + } +} } } + +class SfxItemPropertySet; +class SwDoc; +class SwStartNode; +class SwPaM; +class OTextCursorHelper; +class SwXTextRange; + + +/* -----------------03.12.98 12:22------------------- + * + * --------------------------------------------------*/ + +class SwXText + : public ::com::sun::star::lang::XTypeProvider + , public ::com::sun::star::lang::XUnoTunnel + , public ::com::sun::star::beans::XPropertySet + , public ::com::sun::star::text::XTextAppendAndConvert + , public ::com::sun::star::text::XTextRangeCompare + , public ::com::sun::star::text::XRelativeTextContentInsert + , public ::com::sun::star::text::XRelativeTextContentRemove +{ + +private: + + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + + virtual void PrepareForAttach( + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + SwPaM const & rPam); + virtual bool CheckForOwnMemberMeta( + const SwPaM & rPam, const bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + +protected: + + bool IsValid() const; + void Invalidate(); + void SetDoc(SwDoc *const pDoc); + + virtual ~SwXText(); + +public: /*not protected because C++ is retarded*/ + virtual const SwStartNode *GetStartNode() const; + +public: + + SwXText(SwDoc *const pDoc, const enum CursorType eType); + + const SwDoc* GetDoc() const; + SwDoc* GetDoc(); + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > + CreateCursor() + throw (::com::sun::star::uno::RuntimeException); + + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > + SAL_CALL getTypes() + throw (::com::sun::star::uno::RuntimeException); + + 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 >& rIdentifier) + 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); + + // XTextRange + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + SAL_CALL getText() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getStart() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(const ::rtl::OUString& rString) + throw (::com::sun::star::uno::RuntimeException); + + // XSimpleText + virtual void SAL_CALL insertString( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + const ::rtl::OUString& aString, sal_Bool bAbsorb) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertControlCharacter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XText + virtual void SAL_CALL insertTextContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > & xContent, + sal_Bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeTextContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > & xContent) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + + // XParagraphAppend + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL + appendParagraph( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL + finishParagraph( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XTextPortionAppend + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL + appendTextPortion( + const ::rtl::OUString& rText, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XTextContentAppend + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL + appendTextContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent >& xTextContent, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XTextConvert + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > SAL_CALL + convertToTextFrame( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xStart, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xEnd, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& xFrameProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextTable > SAL_CALL + convertToTable( + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > > > > const& + rTableRanges, + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > > > const& + rCellProperties, + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > > const& + rRowProperties, + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > const& + rTableProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XTextRangeCompare + sal_Int16 SAL_CALL compareRegionStarts( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xR1, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xR2) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + sal_Int16 SAL_CALL compareRegionEnds( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xR1, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xR2) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XRelativeTextContentInsert + virtual void SAL_CALL insertTextContentBefore( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xNewContent, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xSuccessor) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertTextContentAfter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xNewContent, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xPredecessor) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XRelativeTextContentRemove + virtual void SAL_CALL removeTextContentBefore( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xSuccessor) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeTextContentAfter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>& xPredecessor) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOTEXT_HXX + diff --git a/sw/inc/unotextbodyhf.hxx b/sw/inc/unotextbodyhf.hxx new file mode 100644 index 0000000000..8fd4e8c2a4 --- /dev/null +++ b/sw/inc/unotextbodyhf.hxx @@ -0,0 +1,214 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOTEXTBODYHF_HXX +#define SW_UNOTEXTBODYHF_HXX + +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> + +#include <cppuhelper/implbase2.hxx> + +#include <unotext.hxx> + + +class SwDoc; +class SwFrmFmt; +class SwXTextCursor; + + +typedef ::cppu::WeakAggImplHelper2 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumerationAccess +> SwXBodyText_Base; + +class SwXBodyText + : public SwXBodyText_Base + , public SwXText +{ + +protected: + + virtual ~SwXBodyText(); + +public: + + SwXBodyText(SwDoc *const pDoc); + + SwXTextCursor * CreateTextCursor(const bool bIgnoreTables = false); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw() { OWeakObject::release(); } + + // XAggregation + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > + SAL_CALL getTypes() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() + 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); + + // 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); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XSimpleText + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursor() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursorByRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextPosition) + throw (::com::sun::star::uno::RuntimeException); + +}; + + +/* -----------------25.08.98 11:02------------------- + * + * --------------------------------------------------*/ +typedef ::cppu::WeakImplHelper2 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumerationAccess +> SwXHeadFootText_Base; + +class SwXHeadFootText + : public SwXHeadFootText_Base + , public SwXText +{ + +private: + + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + +protected: + + virtual const SwStartNode *GetStartNode() const; + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > + CreateCursor() + throw (::com::sun::star::uno::RuntimeException); + + virtual ~SwXHeadFootText(); + + SwXHeadFootText(SwFrmFmt & rHeadFootFmt, const bool bIsHeader); + +public: + + static ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + CreateXHeadFootText(SwFrmFmt & rHeadFootFmt, const bool bIsHeader); + static bool IsXHeadFootText(SwClient *const pClient); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type& rType) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw() { OWeakObject::release(); } + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > + SAL_CALL getTypes() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() + 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); + + // 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); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XSimpleText + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursor() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursorByRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextPosition) + throw (::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOTEXTBODYHF_HXX + diff --git a/sw/inc/unotextcursor.hxx b/sw/inc/unotextcursor.hxx new file mode 100644 index 0000000000..e976af91e1 --- /dev/null +++ b/sw/inc/unotextcursor.hxx @@ -0,0 +1,351 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOTEXTCURSOR_HXX +#define SW_UNOTEXTCURSOR_HXX + +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/beans/XMultiPropertyStates.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XContentEnumerationAccess.hpp> +#include <com/sun/star/util/XSortable.hpp> +#include <com/sun/star/document/XDocumentInsertable.hpp> +#include <com/sun/star/text/XSentenceCursor.hpp> +#include <com/sun/star/text/XWordCursor.hpp> +#include <com/sun/star/text/XParagraphCursor.hpp> +#include <com/sun/star/text/XRedline.hpp> + +#include <cppuhelper/implbase12.hxx> + +#include <comphelper/uno3.hxx> + +#include <unobaseclass.hxx> +#include <TextCursorHelper.hxx> + + +class SwDoc; +struct SwPosition; +class SwUnoCrsr; + + +typedef ::cppu::WeakImplHelper12 +< ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::beans::XPropertyState +, ::com::sun::star::beans::XMultiPropertyStates +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::container::XContentEnumerationAccess +, ::com::sun::star::util::XSortable +, ::com::sun::star::document::XDocumentInsertable +, ::com::sun::star::text::XSentenceCursor +, ::com::sun::star::text::XWordCursor +, ::com::sun::star::text::XParagraphCursor +, ::com::sun::star::text::XRedline +> SwXTextCursor_Base; + +class SwXTextCursor + : public SwXTextCursor_Base + , public OTextCursorHelper +{ + +private: + + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + + virtual ~SwXTextCursor(); + +public: + + SwXTextCursor( + SwDoc & rDoc, + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XText > const& xParent, + const enum CursorType eType, + SwPosition const& rPos, + SwPosition const*const pMark = 0); + SwXTextCursor( + ::com::sun::star::uno::Reference< + ::com::sun::star::text::XText > const& xParent, + SwPaM const& rSourceCursor, + const enum CursorType eType = CURSOR_ALL); + + SwUnoCrsr * GetCursor(); + const SwUnoCrsr * GetCursor() const; + + bool IsAtEndOfMeta() const; + + void DeleteAndInsert(::rtl::OUString const& rText, + const bool bForceExpandHints); + + // OTextCursorHelper + virtual const SwPaM* GetPaM() const; + virtual SwPaM* GetPaM(); + virtual const SwDoc* GetDoc() const; + virtual SwDoc* GetDoc(); + + DECLARE_XINTERFACE() + + 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 >& 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); + + // 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); + + // XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL + getPropertyState(const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > SAL_CALL + getPropertyStates( + const ::com::sun::star::uno::Sequence< + ::rtl::OUString >& rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XMultiPropertyStates + virtual void SAL_CALL setAllPropertiesToDefault() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertiesToDefault( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > + SAL_CALL getPropertyDefaults( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& + rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::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); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XContentEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createContentEnumeration(const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getAvailableServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XSortable + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > SAL_CALL + createSortDescriptor() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL sort( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& xDescriptor) + throw (::com::sun::star::uno::RuntimeException); + + // XDocumentInsertable + virtual void SAL_CALL insertDocumentFromURL( + const ::rtl::OUString& rURL, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& rOptions) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::io::IOException, + ::com::sun::star::uno::RuntimeException); + + // XTextRange + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + SAL_CALL getText() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getStart() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(const ::rtl::OUString& rString) + throw (::com::sun::star::uno::RuntimeException); + + // XTextCursor + virtual void SAL_CALL collapseToStart() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL collapseToEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCollapsed() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL gotoStart(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL gotoEnd(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL gotoRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange >& xRange, + sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + + // XWordCursor + virtual sal_Bool SAL_CALL isStartOfWord() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isEndOfWord() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) + throw (::com::sun::star::uno::RuntimeException); + + // XSentenceCursor + virtual sal_Bool SAL_CALL isStartOfSentence() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isEndOfSentence() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + + // XParagraphCursor + virtual sal_Bool SAL_CALL isStartOfParagraph() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isEndOfParagraph() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand) + throw (::com::sun::star::uno::RuntimeException); + + // XRedline + virtual void SAL_CALL makeRedline( + const ::rtl::OUString& rRedlineType, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& RedlineProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + +}; + +#endif // SW_UNOTEXTCURSOR_HXX + diff --git a/sw/inc/unotextrange.hxx b/sw/inc/unotextrange.hxx new file mode 100644 index 0000000000..164b35b703 --- /dev/null +++ b/sw/inc/unotextrange.hxx @@ -0,0 +1,342 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unoobj.hxx,v $ + * + * $Revision: 1.49 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOTEXTRANGE_HXX +#define SW_UNOTEXTRANGE_HXX + +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XContentEnumerationAccess.hpp> +#include <com/sun/star/text/XTextRange.hpp> +#include <com/sun/star/text/XRedline.hpp> + +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase8.hxx> + +#include <pam.hxx> +#include <unobaseclass.hxx> + + +class SwDoc; +struct SwPosition; +class SwPaM; +class SwUnoCrsr; +class SwFrmFmt; + +/* -----------------29.04.98 07:35------------------- + * + * --------------------------------------------------*/ +class SwUnoInternalPaM + : public SwPaM +{ + +private: + SwUnoInternalPaM(const SwUnoInternalPaM&); + SwUnoInternalPaM& operator=(const SwPaM& rPaM); + +public: + SwUnoInternalPaM(SwDoc& rDoc); + virtual ~SwUnoInternalPaM(); + +}; + + +namespace sw { + + void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget); + + bool XTextRangeToSwPaM(SwUnoInternalPaM& rToFill, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange); + + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + CreateParentXText(SwDoc & rDoc, const SwPosition& rPos); + + bool GetDefaultTextContentValue(::com::sun::star::uno::Any& rAny, + const ::rtl::OUString& rPropertyName, USHORT nWID = 0); + +} // namespace sw + + +typedef ::cppu::WeakImplHelper8 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::beans::XPropertyState +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::container::XContentEnumerationAccess +, ::com::sun::star::text::XTextRange +, ::com::sun::star::text::XRedline +> SwXTextRange_Base; + +class SW_DLLPUBLIC SwXTextRange + : public SwXTextRange_Base +{ + +private: + + friend class SwXText; + + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + + enum RangePosition + { + RANGE_IN_TEXT, // "ordinary" ::com::sun::star::text::TextRange + RANGE_IN_CELL, // position created with a cell that has no uno object + RANGE_IS_TABLE, // anchor of a table + }; + + void SetPositions(SwPaM const& rPam); + //TODO: new exception type for protected content + void DeleteAndInsert( + const ::rtl::OUString& rText, const bool bForceExpandHints) + throw (::com::sun::star::uno::RuntimeException); + void Invalidate(); + + virtual ~SwXTextRange(); + +public: + + SwXTextRange(SwPaM& rPam, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XText > & xParent, + const enum RangePosition eRange = RANGE_IN_TEXT); + // only for RANGE_IS_TABLE + SwXTextRange(SwFrmFmt& rTblFmt); + + const SwDoc* GetDoc() const; + SwDoc* GetDoc(); + bool GetPositions(SwPaM & rToFill) const; + + static ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > CreateXTextRange( + SwDoc & rDoc, + const SwPosition& rPos, const SwPosition *const pMark); + + 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 >& 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); + + // 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); + + // XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL + getPropertyState(const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyState > SAL_CALL + getPropertyStates( + const ::com::sun::star::uno::Sequence< + ::rtl::OUString >& rPropertyNames) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( + const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::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); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // XContentEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createContentEnumeration(const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getAvailableServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XTextRange + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + SAL_CALL getText() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getStart() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getString() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(const ::rtl::OUString& rString) + throw (::com::sun::star::uno::RuntimeException); + + // XRedline + virtual void SAL_CALL makeRedline( + const ::rtl::OUString& rRedlineType, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& RedlineProperties) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + +}; + +/* -----------------15.05.98 08:29------------------- + * + * --------------------------------------------------*/ + +typedef ::cppu::WeakImplHelper3 +< ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XIndexAccess +> SwXTextRanges_Base; + +class SwXTextRanges + : public SwXTextRanges_Base +{ + +private: + + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; + + virtual ~SwXTextRanges(); + +public: + + SwXTextRanges(SwPaM *const pCrsr); + + const SwUnoCrsr* GetCursor() const; + + 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 >& 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); + + // 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); + +}; + +#endif // SW_UNOTEXTRANGE_HXX + diff --git a/sw/qa/complex/writer/TextPortionEnumerationTest.java b/sw/qa/complex/writer/TextPortionEnumerationTest.java index a07b3cccad..8110c82a6e 100755 --- a/sw/qa/complex/writer/TextPortionEnumerationTest.java +++ b/sw/qa/complex/writer/TextPortionEnumerationTest.java @@ -3097,7 +3097,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xPortion); String type = (String) xPropSet.getPropertyValue("TextPortionType"); - assure("first: not text", type.equals("Text")); + assure("first: not text: " + type, type.equals("Text")); String txt = xPortion.getString(); assure("first: text differs: " + txt, "45".equals(txt)); } diff --git a/sw/source/core/access/accframe.cxx b/sw/source/core/access/accframe.cxx index ce6c2ad0e1..573383b7c7 100644 --- a/sw/source/core/access/accframe.cxx +++ b/sw/source/core/access/accframe.cxx @@ -438,7 +438,7 @@ const SwFrm *SwAccessibleFrame::GetParent( const SwFrmOrObj& rFrmOrObj, const SwFlyFrm *pFly = static_cast< const SwFlyFrm *>( pFrm ); if( pFly->IsFlyInCntFrm() ) { - // For FLY_IN_CNTNT the parent is the anchor + // For FLY_AS_CHAR the parent is the anchor aParent = pFly->GetAnchorFrm(); ASSERT( aParent.IsAccessible( bInPagePreview ), "parent is not accessible" ); @@ -471,9 +471,9 @@ const SwFrm *SwAccessibleFrame::GetParent( const SwFrmOrObj& rFrmOrObj, { const SwFrmFmt *pFrmFmt = pContact->GetFmt(); ASSERT( pFrmFmt, "frame format is missing" ); - if( pFrmFmt && FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId() ) + if (pFrmFmt && FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId()) { - // For FLY_IN_CNTNT the parent is the anchor + // For FLY_AS_CHAR the parent is the anchor aParent = pContact->GetAnchorFrm(); ASSERT( aParent.IsAccessible( bInPagePreview ), "parent is not accessible" ); diff --git a/sw/source/core/access/accfrmobj.cxx b/sw/source/core/access/accfrmobj.cxx index 3102cc958e..88b6b0e8b8 100644 --- a/sw/source/core/access/accfrmobj.cxx +++ b/sw/source/core/access/accfrmobj.cxx @@ -59,8 +59,10 @@ sal_Bool SwFrmOrObj::IsBoundAsChar() const else { const SwFrmFmt *pFrmFmt = pObj ? ::FindFrmFmt( pObj ) : 0; - return pFrmFmt ? static_cast<sal_Bool>(FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId()) - : sal_False; + return (pFrmFmt) + ? static_cast<sal_Bool>(FLY_AS_CHAR == + pFrmFmt->GetAnchor().GetAnchorId()) + : sal_False; } } diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index a48e36d134..d931f65a18 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -30,10 +30,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <txtfrm.hxx> #include <ndtxt.hxx> #include <pam.hxx> -#include <unoobj.hxx> +#include <unotextrange.hxx> +#include <unocrsrhelper.hxx> #include <crstate.hxx> #include <accmap.hxx> #include "fesh.hxx" @@ -63,7 +65,6 @@ #include <unotools/charclass.hxx> // for GetWordBoundary // for get/setCharacterAttribute(...) #include "unocrsr.hxx" -#include "unoobj.hxx" #include "unoport.hxx" #include "doc.hxx" #include "crsskip.hxx" @@ -1532,7 +1533,7 @@ void SwAccessibleParagraph::_getRunAttributesImpl( SfxItemSet aCharAttrsAtPaM( pPaM->GetDoc()->GetAttrPool(), RES_CHRATR_BEGIN, RES_CHRATR_END -1, 0 ); - SwXTextCursor::GetCrsrAttr( *pPaM, aCharAttrsAtPaM, TRUE, TRUE ); + SwUnoCursorHelper::GetCrsrAttr(*pPaM, aCharAttrsAtPaM, TRUE, TRUE); aSet.Put( aCharAttrsAtPaM ); } // <-- @@ -2104,8 +2105,10 @@ sal_Bool SwAccessibleParagraph::replaceText( aEndPos.nContent = nEnd; // now create XTextRange as helper and set string - SwXTextRange::CreateTextRangeFromPosition( - pNode->GetDoc(), aStartPos, &aEndPos)->setString(sReplacement); + const uno::Reference<text::XTextRange> xRange( + SwXTextRange::CreateXTextRange( + *pNode->GetDoc(), aStartPos, &aEndPos)); + xRange->setString(sReplacement); // delete portion data ClearPortionData(); diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx index 56b04e410d..860178c5b9 100644 --- a/sw/source/core/attr/calbck.cxx +++ b/sw/source/core/attr/calbck.cxx @@ -463,7 +463,7 @@ BOOL SwDepend::GetInfo( SfxPoolItem& rInfo ) const /********************************************************************/ -SwClientIter::SwClientIter( SwModify& rModify ) +SwClientIter::SwClientIter( SwModify const& rModify ) : rRoot( rModify ) { // hinten einketten! diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 8918058c31..403daf4db3 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -42,13 +42,14 @@ #include <svx/linkmgr.hxx> #include <swtypes.hxx> #include <undobj.hxx> -#include <unoobj.hxx> +#include <unobookmark.hxx> #include <rtl/random.h> SV_IMPL_REF( SwServerObject ) using namespace ::sw::mark; +using namespace ::com::sun::star; namespace { @@ -147,6 +148,16 @@ namespace sw { namespace mark return aResult.append(nCount++).append(sUniquePostfix).makeStringAndClear(); } + // SwClient + void MarkBase::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) + { + SwModify::Modify(pOld, pNew); + if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) + { // invalidate cached uno object + SetXBookmark(uno::Reference<text::XTextContent>(0)); + } + } + NavigatorReminder::NavigatorReminder(const SwPaM& rPaM) : MarkBase(rPaM, our_sNamePrefix) @@ -240,24 +251,13 @@ namespace sw { namespace mark return !pDoc->IsInHeaderFooter( SwNodeIndex(GetMarkPos().nNode) ); } - ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > - Bookmark::MakeUnoObject() + uno::Reference< rdf::XMetadatable > Bookmark::MakeUnoObject() { - // re-use existing SwXBookmark - SwClientIter iter( *this ); - SwClient * pClient( iter.First( TYPE( SwXBookmark ) ) ); - while (pClient) { - SwXBookmark *const pBookmark( dynamic_cast<SwXBookmark*>(pClient) ); - if (pBookmark && pBookmark->GetCoreObject() == this) { - return pBookmark; - } - pClient = iter.Next(); - } - - // create new SwXBookmark SwDoc *const pDoc( GetMarkPos().GetDoc() ); OSL_ENSURE(pDoc, "Bookmark::MakeUnoObject: no doc?"); - return new SwXBookmark(this, pDoc); + const uno::Reference< rdf::XMetadatable> xMeta( + SwXBookmark::CreateXBookmark(*pDoc, *this), uno::UNO_QUERY); + return xMeta; } diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index efb7c6bd76..bf99e590b2 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -66,7 +66,7 @@ #include <mdiexp.hxx> // ...Percent() #include <fmteiro.hxx> #include <wrong.hxx> // SMARTTAGS -#include <unoobj.hxx> // SMARTTAGS +#include <unotextrange.hxx> // SMARTTAGS #include <vcl/svapp.hxx> #include <numrule.hxx> #include <IGrammarContact.hxx> @@ -3372,8 +3372,8 @@ void lcl_FillTextRange( uno::Reference<text::XTextRange>& rRange, SwPosition aEndPos( aStartPos ); aEndPos.nContent = nBegin + nLen; - uno::Reference<text::XTextRange> xRange = - SwXTextRange::CreateTextRangeFromPosition( rNode.GetDoc(), aStartPos, &aEndPos); + const uno::Reference<text::XTextRange> xRange = + SwXTextRange::CreateXTextRange(*rNode.GetDoc(), aStartPos, &aEndPos); rRange = xRange; } diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 573702f2c9..7789021939 100755 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -932,7 +932,7 @@ SwFlyFrmFmt* SwDoc::_InsNoTxtNode( const SwPosition& rPos, SwNoTxtNode* pNode, SwFlyFrmFmt *pFmt = 0; if( pNode ) { - pFmt = _MakeFlySection( rPos, *pNode, FLY_AT_CNTNT, + pFmt = _MakeFlySection( rPos, *pNode, FLY_AT_PARA, pFlyAttrSet, pFrmFmt ); if( pGrfAttrSet ) pNode->SetAttr( *pGrfAttrSet ); diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 80973abeca..5af1944799 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1259,7 +1259,6 @@ void _SaveCntntIdx(SwDoc* pDoc, SwCntntNode *pNode = pDoc->GetNodes()[nNode]->GetCntntNode(); if( pNode ) { - const SwPosition* pAPos; SwFrm* pFrm = pNode->GetFrm(); #if OSL_DEBUG_LEVEL > 1 @@ -1277,16 +1276,18 @@ void _SaveCntntIdx(SwDoc* pDoc, SwAnchoredObject* pObj = rDObj[ --n ]; const SwFrmFmt& rFmt = pObj->GetFrmFmt(); const SwFmtAnchor& rAnchor = rFmt.GetAnchor(); - if( ( ( nSaveFly && FLY_AT_CNTNT == rAnchor.GetAnchorId() ) || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - ( 0 != ( pAPos = rAnchor.GetCntntAnchor() ) ) ) + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if ( pAPos && + ( ( nSaveFly && + FLY_AT_PARA == rAnchor.GetAnchorId() ) || + ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) ) ) { aSave.SetType( 0x2000 ); aSave.SetContent( pAPos->nContent.GetIndex() ); OSL_ENSURE( nNode == pAPos->nNode.GetIndex(), "_SaveCntntIdx: Wrong Node-Index" ); - if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) { if( nCntnt <= aSave.GetContent() ) { @@ -1321,14 +1322,14 @@ void _SaveCntntIdx(SwDoc* pDoc, continue; const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor()) && - nNode == pAPos->nNode.GetIndex() ) + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if ( pAPos && ( nNode == pAPos->nNode.GetIndex() ) && + ( FLY_AT_PARA == rAnchor.GetAnchorId() || + FLY_AT_CHAR == rAnchor.GetAnchorId() ) ) { aSave.SetType( 0x2000 ); aSave.SetContent( pAPos->nContent.GetIndex() ); - if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) { if( nCntnt <= aSave.GetContent() ) { @@ -1444,11 +1445,15 @@ void _RestoreCntntIdx(SwDoc* pDoc, SwFmtAnchor aNew( rFlyAnchor ); SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() ); aNewPos.nNode = *pCNd; - if( FLY_AUTO_CNTNT == rFlyAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() ) + { aNewPos.nContent.Assign( pCNd, aSave.GetContent() + nOffset ); + } else + { aNewPos.nContent.Assign( 0, 0 ); + } aNew.SetAnchor( &aNewPos ); pFrmFmt->SetFmtAttr( aNew ); } @@ -1608,11 +1613,15 @@ void _RestoreCntntIdx(SvULongs& rSaveArr, SwFmtAnchor aNew( rFlyAnchor ); SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() ); aNewPos.nNode = rNd; - if( FLY_AUTO_CNTNT == rFlyAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() ) + { aNewPos.nContent.Assign( pCNd, Min( aSave.GetContent(), nLen ) ); + } else + { aNewPos.nContent.Assign( 0, 0 ); + } aNew.SetAnchor( &aNewPos ); pFrmFmt->SetFmtAttr( aNew ); } diff --git a/sw/source/core/doc/docdraw.cxx b/sw/source/core/doc/docdraw.cxx index 4c797d6282..048b87904d 100644 --- a/sw/source/core/doc/docdraw.cxx +++ b/sw/source/core/doc/docdraw.cxx @@ -32,9 +32,7 @@ #include "precompiled_sw.hxx" #include <hintids.hxx> #include <rtl/logfile.hxx> -#ifndef _OUTDEV_HXX //autogen #include <vcl/outdev.hxx> -#endif #include <sfx2/printer.hxx> #include <svx/eeitem.hxx> #include <svx/flditem.hxx> @@ -46,22 +44,16 @@ #include <svx/langitem.hxx> #include <svx/unolingu.hxx> -#ifndef _SVDOMEAS_HXX #include <svx/svdfield.hxx> -#endif #include <svx/svdpool.hxx> #include <fmtanchr.hxx> #include <charatr.hxx> #include <frmfmt.hxx> #include <charfmt.hxx> #include <viewimp.hxx> -#ifndef _SWHINTS_HXX #include <swhints.hxx> -#endif #include <doc.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <rootfrm.hxx> //Damit der RootDtor gerufen wird. #include <poolfmt.hxx> #include <viewsh.hxx> // fuer MakeDrawView @@ -481,7 +473,7 @@ BOOL SwDoc::DeleteSelection( SwDrawView& rDrawView ) SwDrawContact *pC = (SwDrawContact*)GetUserCall(pObj); SwDrawFrmFmt *pFrmFmt = (SwDrawFrmFmt*)pC->GetFmt(); if( pFrmFmt && - FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId() ) + FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId() ) { rDrawView.MarkObj( pObj, rDrawView.Imp().GetPageView(), TRUE ); --i; diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index f741f2fc04..3cde597133 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -220,17 +220,15 @@ void _RestFlyInRange( _SaveFlyArr & rArr, const SwNodeIndex& rSttIdx, void _SaveFlyInRange( const SwNodeRange& rRg, _SaveFlyArr& rArr ) { - SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; SwSpzFrmFmts& rFmts = *rRg.aStart.GetNode().GetDoc()->GetSpzFrmFmts(); for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) { - pFmt = (SwFrmFmt*)rFmts[n]; - pAnchor = &pFmt->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwFrmFmt *const pFmt = static_cast<SwFrmFmt*>(rFmts[n]); + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && rRg.aStart <= pAPos->nNode && pAPos->nNode < rRg.aEnd ) { _SaveFly aSave( pAPos->nNode.GetIndex() - rRg.aStart.GetIndex(), @@ -260,7 +258,6 @@ void _SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos, pPos->nContent == rEndNdIdx.GetNode().GetCntntNode()->Len() )) ? 0 : 1; - const SwPosition* pAPos; const SwNodeIndex* pCntntIdx; for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) @@ -268,9 +265,10 @@ void _SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos, sal_Bool bInsPos = sal_False; pFmt = (SwFrmFmt*)rFmts[n]; pAnchor = &pFmt->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + const SwPosition* pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && // nicht verschieben, wenn die InsPos im CntntBereich vom Fly ist ( 0 == ( pCntntIdx = pFmt->GetCntnt().GetCntntIdx() ) || !( *pCntntIdx < rInsPos && @@ -317,14 +315,14 @@ void DelFlyInRange( const SwNodeIndex& rMkNdIdx, SwDoc* pDoc = rMkNdIdx.GetNode().GetDoc(); SwSpzFrmFmts& rTbl = *pDoc->GetSpzFrmFmts(); - const SwPosition* pAPos; for ( sal_uInt16 i = rTbl.Count(); i; ) { SwFrmFmt *pFmt = rTbl[--i]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); - if( ( rAnch.GetAnchorId() == FLY_AT_CNTNT || - rAnch.GetAnchorId() == FLY_AUTO_CNTNT ) && - 0 != ( pAPos = rAnch.GetCntntAnchor() ) && + SwPosition const*const pAPos = rAnch.GetCntntAnchor(); + if (pAPos && + ((rAnch.GetAnchorId() == FLY_AT_PARA) || + (rAnch.GetAnchorId() == FLY_AT_CHAR)) && ( bDelFwrd ? rMkNdIdx < pAPos->nNode && pAPos->nNode <= rPtNdIdx : rPtNdIdx <= pAPos->nNode && pAPos->nNode < rMkNdIdx )) @@ -2620,14 +2618,14 @@ bool SwDoc::DelFullPara( SwPaM& rPam ) // was ist mit Fly's ?? { // stehen noch FlyFrames rum, loesche auch diese - const SwPosition* pAPos; for( sal_uInt16 n = 0; n < GetSpzFrmFmts()->Count(); ++n ) { SwFrmFmt* pFly = (*GetSpzFrmFmts())[n]; const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && aRg.aStart <= pAPos->nNode && pAPos->nNode <= aRg.aEnd ) { DelLayoutFmt( pFly ); diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 3d65dfe816..50baa4b4a9 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -41,12 +41,8 @@ #define _SVSTDARR_ULONGS #include <svl/svarray.hxx> #endif -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif #include <unotools/charclass.hxx> #include <unotools/transliterationwrapper.hxx> #include <doc.hxx> @@ -69,14 +65,13 @@ #include <chpfld.hxx> #include <reffld.hxx> #include <flddropdown.hxx> -#ifndef _DBMGR_HXX #include <dbmgr.hxx> -#endif #include <section.hxx> #include <cellatr.hxx> #include <docary.hxx> #include <authfld.hxx> #include <txtinet.hxx> +#include <fmtcntnt.hxx> #ifndef _POOLFMT_HRC #include <poolfmt.hrc> // fuer InitFldTypes #endif diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index cfda405205..21fdff6df1 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -181,7 +181,7 @@ Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFmtAnchor& rAnch, if( rDoc.GetRootFrm() ) switch( rAnch.GetAnchorId() ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: if( pFlyFmt && rAnch.GetCntntAnchor() ) { const SwFrm* pOld = ((SwFlyFrmFmt*)pFlyFmt)->GetFrm( &aRet, FALSE ); @@ -190,8 +190,8 @@ Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFmtAnchor& rAnch, } break; - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: // LAYER_IMPL + case FLY_AT_PARA: + case FLY_AT_CHAR: // LAYER_IMPL if( rAnch.GetCntntAnchor() ) { const SwPosition *pPos = rAnch.GetCntntAnchor(); @@ -213,7 +213,7 @@ Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFmtAnchor& rAnch, } break; - case FLY_PAGE: + case FLY_AT_PAGE: { USHORT nPgNum = rAnch.GetPageNum(); const SwPageFrm *pPage = (SwPageFrm*)rDoc.GetRootFrm()->Lower(); @@ -249,9 +249,11 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms // ist der neue ein gueltiger Anker? if( !aNewAnch.GetCntntAnchor() && (FLY_AT_FLY == nNew || - FLY_AT_CNTNT == nNew || FLY_IN_CNTNT == nNew || - FLY_AUTO_CNTNT == nNew )) + (FLY_AT_PARA == nNew) || (FLY_AS_CHAR == nNew) || + (FLY_AT_CHAR == nNew) )) + { return IGNOREANCHOR; + } if( nOld == nNew ) return DONTMAKEFRMS; @@ -264,7 +266,7 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms //doppeltes hiden waere so eine art Show! rFmt.DelFrms(); - if( FLY_IN_CNTNT == nOld ) + if ( FLY_AS_CHAR == nOld ) { //Bei InCntnt's wird es spannend: Das TxtAttribut muss vernichtet //werden. Leider reisst dies neben den Frms auch noch das Format mit @@ -295,7 +297,7 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms const SfxPoolItem* pItem; switch( nNew ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: //Wenn keine Positionsattribute hereinkommen, dann muss dafuer //gesorgt werden, das keine unerlaubte automatische Ausrichtung //bleibt. @@ -326,10 +328,10 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms } break; - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: // LAYER_IMPL + case FLY_AT_PARA: + case FLY_AT_CHAR: // LAYER_IMPL case FLY_AT_FLY: // LAYER_IMPL - case FLY_PAGE: + case FLY_AT_PAGE: { //Wenn keine Positionsattribute hereinschneien korrigieren wir //die Position so, dass die Dokumentkoordinaten des Flys erhalten @@ -345,7 +347,7 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms if( text::HoriOrientation::NONE == aOldH.GetHoriOrient() && ( !pItem || aOldH.GetPos() == ((SwFmtHoriOrient*)pItem)->GetPos() )) { - SwTwips nPos = FLY_IN_CNTNT == nOld ? 0 : aOldH.GetPos(); + SwTwips nPos = (FLY_AS_CHAR == nOld) ? 0 : aOldH.GetPos(); nPos += aOldAnchorPos.X() - aNewAnchorPos.X(); if( pItem ) @@ -367,7 +369,7 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms if( text::VertOrientation::NONE == aOldV.GetVertOrient() && (!pItem || aOldV.GetPos() == ((SwFmtVertOrient*)pItem)->GetPos() ) ) { - SwTwips nPos = FLY_IN_CNTNT == nOld ? 0 : aOldV.GetPos(); + SwTwips nPos = (FLY_AS_CHAR == nOld) ? 0 : aOldV.GetPos(); nPos += aOldAnchorPos.Y() - aNewAnchorPos.Y(); if( pItem ) { @@ -698,7 +700,7 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, // xub_StrLen nIndx = STRING_NOTFOUND; const SwPosition* pOldAsCharAnchorPos( 0L ); const RndStdIds eOldAnchorType = pContact->GetAnchorId(); - if ( !_bSameOnly && eOldAnchorType == FLY_IN_CNTNT ) + if ( !_bSameOnly && eOldAnchorType == FLY_AS_CHAR ) { pOldAsCharAnchorPos = new SwPosition( pContact->GetCntntAnchor() ); } @@ -713,8 +715,8 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, switch ( _eAnchorType ) { - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: { const Point aNewPoint = pOldAnchorFrm && ( pOldAnchorFrm->IsVertical() || @@ -768,10 +770,10 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, break; } - aNewAnch.SetType( FLY_PAGE ); + aNewAnch.SetType( FLY_AT_PAGE ); // no break } - case FLY_PAGE: + case FLY_AT_PAGE: { pNewAnchorFrm = GetRootFrm()->Lower(); while ( pNewAnchorFrm && !pNewAnchorFrm->Frm().IsInside( aPt ) ) @@ -782,7 +784,7 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, aNewAnch.SetPageNum( ((SwPageFrm*)pNewAnchorFrm)->GetPhyPageNum()); } break; - case FLY_IN_CNTNT: + case FLY_AS_CHAR: if( _bSameOnly ) // Positions/Groessenaenderung { if( !pOldAnchorFrm ) @@ -805,7 +807,7 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, bUnmark = ( 0 != i ); Point aPoint( aPt ); aPoint.X() -= 1; // nicht im DrawObj landen!! - aNewAnch.SetType( FLY_IN_CNTNT ); + aNewAnch.SetType( FLY_AS_CHAR ); SwPosition aPos( *((SwCntntFrm*)pNewAnchorFrm)->GetNode() ); if ( pNewAnchorFrm->Frm().IsInside( aPoint ) ) { @@ -839,7 +841,7 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, ASSERT( !this, "unexpected AnchorId." ); } - if ( (FLY_IN_CNTNT != _eAnchorType) && + if ( (FLY_AS_CHAR != _eAnchorType) && pNewAnchorFrm && ( !_bSameOnly || pNewAnchorFrm != pOldAnchorFrm ) ) { @@ -949,8 +951,8 @@ int SwDoc::Chainable( const SwFrmFmt &rSource, const SwFrmFmt &rDest ) const SwFmtAnchor& rAnchor = (*GetSpzFrmFmts())[ n ]->GetAnchor(); ULONG nTstSttNd; // OD 11.12.2003 #i20622# - to-frame anchored objects are allowed. - if ( ( rAnchor.GetAnchorId() == FLY_AT_CNTNT || - rAnchor.GetAnchorId() == FLY_AUTO_CNTNT ) && + if ( ((rAnchor.GetAnchorId() == FLY_AT_PARA) || + (rAnchor.GetAnchorId() == FLY_AT_CHAR)) && 0 != rAnchor.GetCntntAnchor() && nFlySttNd <= ( nTstSttNd = rAnchor.GetCntntAnchor()->nNode.GetIndex() ) && @@ -971,9 +973,9 @@ int SwDoc::Chainable( const SwFrmFmt &rSource, const SwFrmFmt &rDest ) &rDstAnchor = rDest.GetAnchor(); ULONG nEndOfExtras = GetNodes().GetEndOfExtras().GetIndex(); BOOL bAllowed = FALSE; - if( FLY_PAGE == rSrcAnchor.GetAnchorId() ) + if ( FLY_AT_PAGE == rSrcAnchor.GetAnchorId() ) { - if( FLY_PAGE == rDstAnchor.GetAnchorId() || + if ( (FLY_AT_PAGE == rDstAnchor.GetAnchorId()) || ( rDstAnchor.GetCntntAnchor() && rDstAnchor.GetCntntAnchor()->nNode.GetIndex() > nEndOfExtras )) bAllowed = TRUE; diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index 2595a769e8..d3f3cbf535 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -49,12 +49,8 @@ #include <docary.hxx> #include <pam.hxx> #include <ndtxt.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif -#ifndef _GLOBDOC_HXX #include <globdoc.hxx> -#endif #include <shellio.hxx> #include <swundo.hxx> // fuer die UndoIds #include <section.hxx> @@ -371,14 +367,15 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, CorrAbs( aSIdx, aEIdx, *aTmp.GetPoint(), TRUE); // stehen noch FlyFrames rum, loesche auch diese - const SwPosition* pAPos; for( USHORT n = 0; n < GetSpzFrmFmts()->Count(); ++n ) { SwFrmFmt* pFly = (*GetSpzFrmFmts())[n]; const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwPosition const*const pAPos = + pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && aSIdx <= pAPos->nNode && pAPos->nNode < aEIdx ) { @@ -717,14 +714,15 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, int nOutlineLevel ) CorrAbs( aSIdx, aEIdx, *aTmp.GetPoint(), TRUE); // stehen noch FlyFrames rum, loesche auch diese - const SwPosition* pAPos; for( USHORT n = 0; n < GetSpzFrmFmts()->Count(); ++n ) { SwFrmFmt* pFly = (*GetSpzFrmFmts())[n]; const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwPosition const*const pAPos = + pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && aSIdx <= pAPos->nNode && pAPos->nNode < aEIdx ) { diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 0ab5de60a7..ed6ba6187b 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -68,9 +68,7 @@ #include <fmtfsize.hxx> #include <fmtsrnd.hxx> #include <fmtflcnt.hxx> -#ifndef _FRMCNCT_HXX //autogen #include <fmtcnct.hxx> -#endif #include <frmfmt.hxx> #include <dcontact.hxx> #include <txtflcnt.hxx> @@ -85,9 +83,7 @@ #include <cntfrm.hxx> #include <flyfrm.hxx> #include <fesh.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <dflyobj.hxx> #include <dcontact.hxx> #include <swundo.hxx> @@ -213,13 +209,12 @@ SwFrmFmt *SwDoc::MakeLayoutFmt( RndStdIds eRequest, const SfxItemSet* pSet ) break; #ifdef DBG_UTIL - case FLY_PAGE: - case FLY_AUTO_CNTNT: + case FLY_AT_PAGE: + case FLY_AT_CHAR: case FLY_AT_FLY: - case FLY_AT_CNTNT: - case FLY_IN_CNTNT: - ASSERT( !this, - "neue Schnittstelle benutzen: SwDoc::MakeFlySection!" ); + case FLY_AT_PARA: + case FLY_AS_CHAR: + ASSERT( false, "use new interface instead: SwDoc::MakeFlySection!" ); break; #endif @@ -358,7 +353,7 @@ void SwDoc::DelLayoutFmt( SwFrmFmt *pFmt ) // ggfs. bei Zeichengebundenen Flys das Zeichen loeschen const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() && rAnchor.GetCntntAnchor()) + if ((FLY_AS_CHAR == rAnchor.GetAnchorId()) && rAnchor.GetCntntAnchor()) { const SwPosition* pPos = rAnchor.GetCntntAnchor(); SwTxtNode *pTxtNd = pPos->nNode.GetNode().GetTxtNode(); @@ -422,9 +417,9 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource, static_cast<const SwDrawContact*>( rSource.FindContactObj() ); bMayNotCopy = - ( FLY_AT_CNTNT == rNewAnchor.GetAnchorId() || - FLY_AT_FLY == rNewAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rNewAnchor.GetAnchorId() ) && + ((FLY_AT_PARA == rNewAnchor.GetAnchorId()) || + (FLY_AT_FLY == rNewAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rNewAnchor.GetAnchorId())) && rNewAnchor.GetCntntAnchor() && IsInHeaderFooter( rNewAnchor.GetCntntAnchor()->nNode ) && pDrawContact != NULL && @@ -551,7 +546,7 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource, } } - if( bSetTxtFlyAtt && FLY_IN_CNTNT == rNewAnchor.GetAnchorId() ) + if (bSetTxtFlyAtt && (FLY_AS_CHAR == rNewAnchor.GetAnchorId())) { const SwPosition* pPos = rNewAnchor.GetCntntAnchor(); SwFmtFlyCnt aFmt( pDest ); @@ -660,7 +655,7 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, RndStdIds eAnchorId = pAnchor ? pAnchor->GetAnchorId() : pFmt->GetAnchor().GetAnchorId(); if( !pAnchor || - (FLY_PAGE != pAnchor->GetAnchorId() && + ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && //Nur Page und nicht: // FLY_AT_CNTNT == pAnchor->GetAnchorId() || // FLY_IN_CNTNT == pAnchor->GetAnchorId() || @@ -670,7 +665,7 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, { // dann setze ihn, wird im Undo gebraucht SwFmtAnchor aAnch( pFmt->GetAnchor() ); - if( pAnchor && FLY_AT_FLY == pAnchor->GetAnchorId() ) + if (pAnchor && (FLY_AT_FLY == pAnchor->GetAnchorId())) { SwPosition aPos( *rAnchPos.nNode.GetNode().FindFlyStartNode() ); aAnch.SetAnchor( &aPos ); @@ -683,7 +678,7 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, aAnch.SetType( eRequestId ); eAnchorId = aAnch.GetAnchorId(); - if ( FLY_PAGE != eAnchorId ) + if ( FLY_AT_PAGE != eAnchorId ) //Nur Page und nicht: // if( FLY_AT_CNTNT == eAnchorId || FLY_IN_CNTNT == eAnchorId || // FLY_AT_FLY == eAnchorId || FLY_AUTO_CNTNT == eAnchorId ) @@ -694,7 +689,7 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, else eAnchorId = pFmt->GetAnchor().GetAnchorId(); - if( FLY_IN_CNTNT == eAnchorId ) + if ( FLY_AS_CHAR == eAnchorId ) { xub_StrLen nStt = rAnchPos.nContent.GetIndex(); SwTxtNode * pTxtNode = rAnchPos.nNode.GetNode().GetTxtNode(); @@ -751,7 +746,7 @@ SwFlyFrmFmt* SwDoc::MakeFlySection( RndStdIds eAnchorType, { SwFlyFrmFmt* pFmt = 0; sal_Bool bCallMake = sal_True; - if( !pAnchorPos && FLY_PAGE != eAnchorType ) + if ( !pAnchorPos && (FLY_AT_PAGE != eAnchorType) ) { const SwFmtAnchor* pAnch; if( (pFlySet && SFX_ITEM_SET == pFlySet->GetItemState( @@ -759,9 +754,14 @@ SwFlyFrmFmt* SwDoc::MakeFlySection( RndStdIds eAnchorType, ( pFrmFmt && SFX_ITEM_SET == pFrmFmt->GetItemState( RES_ANCHOR, sal_True, (const SfxPoolItem**)&pAnch )) ) { - if( FLY_PAGE != pAnch->GetAnchorId() && - 0 == ( pAnchorPos = pAnch->GetCntntAnchor() ) ) - bCallMake = sal_False; + if ( (FLY_AT_PAGE != pAnch->GetAnchorId()) ) + { + pAnchorPos = pAnch->GetCntntAnchor(); + if (pAnchorPos) + { + bCallMake = sal_False; + } + } } } @@ -944,7 +944,7 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, // Anker noch nicht gesetzt ? // DrawObjecte duerfen niemals in Kopf-/Fusszeilen landen. - sal_Bool bIsAtCntnt = FLY_PAGE != eAnchorId; + const bool bIsAtCntnt = (FLY_AT_PAGE != eAnchorId); // FLY_AT_CNTNT == eAnchorId || FLY_IN_CNTNT == eAnchorId || // FLY_AT_FLY == eAnchorId || FLY_AUTO_CNTNT == eAnchorId; @@ -966,7 +966,7 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, ::CheckControlLayer( &rDrawObj ) && IsInHeaderFooter( *pChkIdx ) ) { - pFmt->SetFmtAttr( SwFmtAnchor( eAnchorId = FLY_PAGE ) ); + pFmt->SetFmtAttr( SwFmtAnchor( eAnchorId = FLY_AT_PAGE ) ); } else if( !pAnchor || (bIsAtCntnt && !pAnchor->GetCntntAnchor() )) { @@ -981,10 +981,10 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, else { aAnch.SetAnchor( rRg.GetPoint() ); - if( FLY_PAGE == eAnchorId ) + if ( FLY_AT_PAGE == eAnchorId ) { eAnchorId = rDrawObj.ISA( SdrUnoObj ) - ? FLY_IN_CNTNT : FLY_AT_CNTNT; + ? FLY_AS_CHAR : FLY_AT_PARA; aAnch.SetType( eAnchorId ); } } @@ -992,7 +992,7 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, } // bei als Zeichen gebundenen Draws das Attribut im Absatz setzen - if( FLY_IN_CNTNT == eAnchorId ) + if ( FLY_AS_CHAR == eAnchorId ) { xub_StrLen nStt = rRg.GetPoint()->nContent.GetIndex(); SwFmtFlyCnt aFmt( pFmt ); @@ -1063,7 +1063,7 @@ sal_Bool TstFlyRange( const SwPaM* pPam, const SwPosition* pFlyPos, const SwPosition* pPaMEnd = pTmp->End(); const sal_uInt32 nPamStartIndex = pPaMStart->nNode.GetIndex(); const sal_uInt32 nPamEndIndex = pPaMEnd->nNode.GetIndex(); - if(FLY_AT_CNTNT == nAnchorId) + if (FLY_AT_PARA == nAnchorId) bOk = (nPamStartIndex < nFlyIndex && nPamEndIndex > nFlyIndex) || (((nPamStartIndex == nFlyIndex) && (pPaMStart->nContent.GetIndex() == 0)) && (nPamEndIndex > nFlyIndex)); @@ -1091,7 +1091,6 @@ void SwDoc::GetAllFlyFmts( SwPosFlyFrms& rPosFlyFmts, const SwPaM* pCmpRange, sal_Bool bDrawAlso ) const { SwPosFlyFrm *pFPos = 0; - const SwPosition* pAPos; SwFrmFmt *pFly; // erstmal alle Absatzgebundenen einsammeln @@ -1103,10 +1102,11 @@ void SwDoc::GetAllFlyFmts( SwPosFlyFrms& rPosFlyFmts, if( bFlyFmt || bDrawFmt ) { const SwFmtAnchor& rAnchor = pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AT_FLY == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor()) ) + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_FLY == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()))) { if( pCmpRange && !TstFlyRange( pCmpRange, pAPos, rAnchor.GetAnchorId() )) @@ -1140,9 +1140,9 @@ void SwDoc::GetAllFlyFmts( SwPosFlyFrms& rPosFlyFmts, continue; const SwFmtAnchor& rAnchor = pFly->GetAnchor(); - if( FLY_AT_CNTNT != rAnchor.GetAnchorId() && - FLY_AT_FLY != rAnchor.GetAnchorId() && - FLY_AUTO_CNTNT != rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA != rAnchor.GetAnchorId()) && + (FLY_AT_FLY != rAnchor.GetAnchorId()) && + (FLY_AT_CHAR != rAnchor.GetAnchorId())) { const SwCntntFrm * pCntntFrm = pPage->FindFirstBodyCntnt(); if ( !pCntntFrm ) @@ -1387,7 +1387,7 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co //loesen wir vorher die Verbindung zwischen Attribut und Format. const SwFmtAnchor& rAnchor = pNewFmt->GetAnchor(); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR == rAnchor.GetAnchorId() ) { const SwPosition *pPos = rAnchor.GetCntntAnchor(); SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); @@ -1433,7 +1433,7 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co pNewSet->Put( SvxULSpaceItem(RES_UL_SPACE) ); //Der Alte ist absatzgebunden, und zwar am Absatz im neuen. - SwFmtAnchor aAnch( FLY_AT_CNTNT ); + SwFmtAnchor aAnch( FLY_AT_PARA ); SwNodeIndex aAnchIdx( *pNewFmt->GetCntnt().GetCntntIdx(), 1 ); pNew = aAnchIdx.GetNode().GetTxtNode(); SwPosition aPos( aAnchIdx ); @@ -1684,7 +1684,7 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, pNewFmt->SetFmtAttr( *pNewSet ); const SwFmtAnchor& rAnchor = pNewFmt->GetAnchor(); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR == rAnchor.GetAnchorId() ) { const SwPosition *pPos = rAnchor.GetCntntAnchor(); SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); @@ -1722,7 +1722,7 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, pNewSet->Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME ) ); //Der Alte ist absatzgebunden, und zwar am Absatz im neuen. - SwFmtAnchor aAnch( FLY_AT_CNTNT ); + SwFmtAnchor aAnch( FLY_AT_PARA ); SwNodeIndex aAnchIdx( *pNewFmt->GetCntnt().GetCntntIdx(), 1 ); pNew = aAnchIdx.GetNode().GetTxtNode(); SwPosition aPos( aAnchIdx ); @@ -1880,7 +1880,8 @@ IMPL_LINK( SwDoc, DoIdleJobs, Timer *, pTimer ) BOOL bIsOnlineSpell = pSh->GetViewOptions()->IsOnlineSpell(); sal_Bool bIsAutoGrammar = sal_False; - SvtLinguConfig().GetProperty( C2U( UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar; + SvtLinguConfig().GetProperty( ::rtl::OUString::createFromAscii( + UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar; if (bIsOnlineSpell && bIsAutoGrammar) StartGrammarChecking( *this ); @@ -2095,15 +2096,17 @@ void SwDoc::SetAllUniqueFlyNames() if( bLoadedFlag ) { const SwFmtAnchor& rAnchor = pFlyFmt->GetAnchor(); - if( ( FLY_PAGE == rAnchor.GetAnchorId() && - rAnchor.GetCntntAnchor() ) || + if (((FLY_AT_PAGE == rAnchor.GetAnchorId()) && + rAnchor.GetCntntAnchor()) || // oder werden DrawObjecte rel. zu irgendetwas ausgerichtet? ( RES_DRAWFRMFMT == pFlyFmt->Which() && ( SFX_ITEM_SET == pFlyFmt->GetItemState( RES_VERT_ORIENT )|| SFX_ITEM_SET == pFlyFmt->GetItemState( RES_HORI_ORIENT ))) ) + { bLoadedFlag = sal_False; + } } } @@ -2200,9 +2203,11 @@ sal_Bool SwDoc::IsInHeaderFooter( const SwNodeIndex& rIdx ) const if( pIdx && pFlyNd == &pIdx->GetNode() ) { const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_PAGE == rAnchor.GetAnchorId() || + if ((FLY_AT_PAGE == rAnchor.GetAnchorId()) || !rAnchor.GetCntntAnchor() ) + { return sal_False; + } pNd = &rAnchor.GetCntntAnchor()->nNode.GetNode(); pFlyNd = pNd->FindFlyStartNode(); @@ -2247,10 +2252,12 @@ short SwDoc::GetTextDirection( const SwPosition& rPos, { pItem = 0; const SwFmtAnchor* pAnchor = &pFlyFmt->GetAnchor(); - if( FLY_PAGE != pAnchor->GetAnchorId() && - pAnchor->GetCntntAnchor() ) + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && + pAnchor->GetCntntAnchor()) + { pFlyFmt = pAnchor->GetCntntAnchor()->nNode. GetNode().GetFlyFmt(); + } else pFlyFmt = 0; } diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index c23752f1db..4fbc5f3b7d 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -91,7 +91,6 @@ #include <viewsh.hxx> #include <doctxm.hxx> #include <shellres.hxx> -#include <unoclbck.hxx> #include <breakit.hxx> #include <laycache.hxx> #include <mvsave.hxx> @@ -278,7 +277,7 @@ SwDoc::SwDoc() : pStyleAccess( 0 ), // <-- pLayoutCache( 0 ), - pUnoCallBack(new SwUnoCallBack(0)), + pUnoCallBack(new SwModify(0)), mpGrammarContact( 0 ), aChartDataProviderImplRef(), pChartControllerHelper( 0 ), @@ -1435,7 +1434,7 @@ void SwDoc::Paste( const SwDoc& rSource ) if( bInsWithFmt ) { SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); - if( FLY_PAGE == aAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == aAnchor.GetAnchorId()) { aAnchor.SetPageNum( aAnchor.GetPageNum() /*+ nStartPageNumber - */); } diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index 752b146b9f..7ceaffdbda 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -48,9 +48,7 @@ #include <swtable.hxx> #include <swundo.hxx> #include <sortopt.hxx> -#ifndef _DOCSORT_HXX #include <docsort.hxx> -#endif #include <undobj.hxx> #include <tblsel.hxx> #include <cellatr.hxx> @@ -341,18 +339,13 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) const SwPosition *pStart = rPaM.Start(), *pEnd = rPaM.End(); // Index auf den Start der Selektion - SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; - USHORT n; - - for( n = 0; n < GetSpzFrmFmts()->Count(); ++n ) + for ( USHORT n = 0; n < GetSpzFrmFmts()->Count(); ++n ) { - pFmt = (SwFrmFmt*)(*GetSpzFrmFmts())[n]; - pAnchor = &pFmt->GetAnchor(); + SwFrmFmt *const pFmt = static_cast<SwFrmFmt*>((*GetSpzFrmFmts())[n]); + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); - if( FLY_AT_CNTNT == pAnchor->GetAnchorId() && - 0 != (pAPos = pAnchor->GetCntntAnchor() ) && + if (pAPos && (FLY_AT_PARA == pAnchor->GetAnchorId()) && pStart->nNode <= pAPos->nNode && pAPos->nNode <= pEnd->nNode ) return FALSE; } @@ -444,7 +437,7 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) DoUndo( FALSE ); - for( n = 0; n < aSortArr.Count(); ++n ) + for ( USHORT n = 0; n < aSortArr.Count(); ++n ) { SwSortTxtElement* pBox = (SwSortTxtElement*)aSortArr[n]; aStart = nBeg + n; diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx index a5419368d0..3067fc74a4 100644 --- a/sw/source/core/doc/poolfmt.cxx +++ b/sw/source/core/doc/poolfmt.cxx @@ -37,9 +37,7 @@ #include <svx/wghtitem.hxx> #include <svx/fontitem.hxx> #include <svx/fhgtitem.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/lrspitem.hxx> #include <svx/ulspitem.hxx> #include <svx/adjitem.hxx> @@ -55,9 +53,7 @@ #include <svx/langitem.hxx> #include <svx/charrotateitem.hxx> #include <svx/frmdiritem.hxx> -#ifndef _SVX_EMPHITEM_HXX #include <svx/emphitem.hxx> -#endif #include <svx/scriptspaceitem.hxx> #include <viewopt.hxx> #include <doc.hxx> @@ -1303,13 +1299,13 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) { if ( get(IDocumentSettingAccess::BROWSE_MODE) ) { - aSet.Put( SwFmtAnchor( FLY_IN_CNTNT )); + aSet.Put( SwFmtAnchor( FLY_AS_CHAR )); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::LINE_CENTER, text::RelOrientation::PRINT_AREA ) ); aSet.Put( SwFmtSurround( SURROUND_NONE ) ); } else { - aSet.Put( SwFmtAnchor( FLY_AT_CNTNT )); + aSet.Put( SwFmtAnchor( FLY_AT_PARA )); aSet.Put( SwFmtSurround( SURROUND_PARALLEL ) ); aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::PRINT_AREA ) ); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::PRINT_AREA ) ); @@ -1330,7 +1326,7 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) case RES_POOLFRM_GRAPHIC: case RES_POOLFRM_OLE: { - aSet.Put( SwFmtAnchor( FLY_AT_CNTNT )); + aSet.Put( SwFmtAnchor( FLY_AT_PARA )); aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME )); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME )); aSet.Put( SwFmtSurround( SURROUND_NONE )); @@ -1338,14 +1334,14 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) break; case RES_POOLFRM_FORMEL: { - aSet.Put( SwFmtAnchor( FLY_IN_CNTNT ) ); + aSet.Put( SwFmtAnchor( FLY_AS_CHAR ) ); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::CHAR_CENTER, text::RelOrientation::FRAME ) ); aSet.Put( SvxLRSpaceItem( 114, 114, 0, 0, RES_LR_SPACE ) ); } break; case RES_POOLFRM_MARGINAL: { - aSet.Put( SwFmtAnchor( FLY_AT_CNTNT )); + aSet.Put( SwFmtAnchor( FLY_AT_PARA )); aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME )); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME )); aSet.Put( SwFmtSurround( SURROUND_PARALLEL )); @@ -1358,7 +1354,7 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) break; case RES_POOLFRM_WATERSIGN: { - aSet.Put( SwFmtAnchor( FLY_PAGE )); + aSet.Put( SwFmtAnchor( FLY_AT_PAGE )); aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::CENTER, text::RelOrientation::FRAME )); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::CENTER, text::RelOrientation::FRAME )); aSet.Put( SvxOpaqueItem( FALSE )); @@ -1368,7 +1364,7 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) case RES_POOLFRM_LABEL: { - aSet.Put( SwFmtAnchor( FLY_IN_CNTNT ) ); + aSet.Put( SwFmtAnchor( FLY_AS_CHAR ) ); aSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ) ); aSet.Put( SvxLRSpaceItem( 114, 114, 0, 0, RES_LR_SPACE ) ); diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index 84fa3845a3..0982e9ade9 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -591,14 +591,14 @@ void lcl_CpyBox( const SwTable& rCpyTbl, const SwTableBox* pCpyBox, } // stehen noch FlyFrames rum, loesche auch diese - const SwPosition* pAPos; for( USHORT n = 0; n < pDoc->GetSpzFrmFmts()->Count(); ++n ) { - SwFrmFmt* pFly = (*pDoc->GetSpzFrmFmts())[n]; - const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); - if( ( FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor() ) && + SwFrmFmt *const pFly = (*pDoc->GetSpzFrmFmts())[n]; + SwFmtAnchor const*const pAnchor = &pFly->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && aInsIdx <= pAPos->nNode && pAPos->nNode <= aEndNdIdx ) { pDoc->DelLayoutFmt( pFly ); diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index f7897bed15..68f1559055 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -552,20 +552,18 @@ void SwTxtNode::CopyCollFmt( SwTxtNode& rDestNd ) BOOL lcl_ChkFlyFly( SwDoc* pDoc, ULONG nSttNd, ULONG nEndNd, ULONG nInsNd ) { - const SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); for( USHORT n = 0; n < rFrmFmtTbl.Count(); ++n ) { - pFmt = rFrmFmtTbl[n]; - pAnchor = &pFmt->GetAnchor(); - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - ( FLY_IN_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId() || - FLY_AT_FLY == pAnchor->GetAnchorId() || - FLY_AT_CNTNT == pAnchor->GetAnchorId() ) && + SwFrmFmt const*const pFmt = rFrmFmtTbl[n]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AS_CHAR == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId()) || + (FLY_AT_FLY == pAnchor->GetAnchorId()) || + (FLY_AT_PARA == pAnchor->GetAnchorId())) && nSttNd <= pAPos->nNode.GetIndex() && pAPos->nNode.GetIndex() < nEndNd ) { @@ -1398,18 +1396,17 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, SwDoc *const pDest = rStartIdx.GetNode().GetDoc(); _ZSortFlys aArr; USHORT nArrLen = GetSpzFrmFmts()->Count(); - USHORT n; - for( n = 0; n < nArrLen; ++n ) + for ( USHORT n = 0; n < nArrLen; ++n ) { - const SwFrmFmt* pFmt = (*GetSpzFrmFmts())[n]; - const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - const SwPosition* pAPos; - bool bAtCntnt = pAnchor->GetAnchorId() == FLY_AT_CNTNT; - if ( ( bAtCntnt || - pAnchor->GetAnchorId() == FLY_AT_FLY || - pAnchor->GetAnchorId() == FLY_AUTO_CNTNT ) && - 0 != ( pAPos = pAnchor->GetCntntAnchor()) && + SwFrmFmt const*const pFmt = (*GetSpzFrmFmts())[n]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + bool bAtCntnt = (pAnchor->GetAnchorId() == FLY_AT_PARA); + if ( pAPos && + ( bAtCntnt || + (pAnchor->GetAnchorId() == FLY_AT_FLY) || + (pAnchor->GetAnchorId() == FLY_AT_CHAR)) && (( bCopyFlyAtFly && FLY_AT_FLY == pAnchor->GetAnchorId() ) ? rRg.aStart <= pAPos->nNode.GetIndex() + 1 : ( IsRedlineMove() @@ -1470,7 +1467,7 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, //die Chains entsprechend aufgebaut werden koennen. SvPtrarr aNewArr( 10, 10 ); - for( n = 0; n < aArr.Count(); ++n ) + for ( USHORT n = 0; n < aArr.Count(); ++n ) { const _ZSortFly& rZSortFly = aArr[ n ]; @@ -1485,8 +1482,8 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, // method <SwNodes::_CopyNodes(..)>. // Thus, the new anchor position in the destination document is found // by counting the text nodes. - if ( aAnchor.GetAnchorId() == FLY_AT_CNTNT || - aAnchor.GetAnchorId() == FLY_AUTO_CNTNT ) + if ((aAnchor.GetAnchorId() == FLY_AT_PARA) || + (aAnchor.GetAnchorId() == FLY_AT_CHAR) ) { // First, determine number of anchor text node in the copied range. // Note: The anchor text node *have* to be inside the copied range. @@ -1552,7 +1549,7 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, } // <-- // die am Zeichen Flys wieder ans das vorgegebene Zeichen setzen - if ( FLY_AUTO_CNTNT == aAnchor.GetAnchorId() && + if ((FLY_AT_CHAR == aAnchor.GetAnchorId()) && pNewPos->nNode.GetNode().IsTxtNode() ) { pNewPos->nContent.Assign( (SwTxtNode*)&pNewPos->nNode.GetNode(), @@ -1592,7 +1589,7 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, ASSERT( aArr.Count() == aNewArr.Count(), "Missing new Flys" ); if ( aArr.Count() == aNewArr.Count() ) { - for ( n = 0; n < aArr.Count(); ++n ) + for ( USHORT n = 0; n < aArr.Count(); ++n ) { const SwFrmFmt *pFmt = aArr[n].GetFmt(); const SwFmtChain &rChain = pFmt->GetChain(); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 31f477752f..a98ec01f95 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -38,7 +38,6 @@ #endif #include <hintids.hxx> - #include <svx/lrspitem.hxx> #include <svx/brkitem.hxx> #include <svx/protitem.hxx> @@ -91,9 +90,7 @@ #include <comcore.hrc> #endif #include "docsh.hxx" -#ifdef LINUX #include <tabcol.hxx> -#endif #include <unochart.hxx> #include <node.hxx> @@ -104,6 +101,9 @@ // --> OD 2005-12-05 #i27138# #include <rootfrm.hxx> // <-- +#include <fldupde.hxx> + + #ifndef DBG_UTIL #define CHECK_TABLE(t) #else @@ -113,7 +113,6 @@ #define CHECK_TABLE(t) #endif #endif -#include <fldupde.hxx> using namespace ::com::sun::star; @@ -1684,17 +1683,19 @@ BOOL SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh, // #i28006# Fly frames have to be restored even if the table was // #alone in the section const SwSpzFrmFmts& rFlyArr = *GetDoc()->GetSpzFrmFmts(); - const SwPosition* pAPos; for( USHORT n = 0; n < rFlyArr.Count(); ++n ) { - SwFrmFmt* pFmt = (SwFrmFmt*)rFlyArr[n]; + SwFrmFmt *const pFmt = (SwFrmFmt*)rFlyArr[n]; const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor() ) && + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) && nStt <= pAPos->nNode.GetIndex() && pAPos->nNode.GetIndex() < nEnd ) + { pFmt->MakeFrms(); + } } return TRUE; diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 73d0124567..84d709538a 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -38,9 +38,7 @@ #include <svx/frmdiritem.hxx> // <-- #include <svx/protitem.hxx> -#ifndef _COM_SUN_STAR_I18N_CHARACTERITERATORMODE_HDL_ #include <com/sun/star/i18n/CharacterIteratorMode.hdl> -#endif #include <fmtcntnt.hxx> #include <fmtanchr.hxx> #include <frmfmt.hxx> @@ -609,7 +607,7 @@ const SwPageDesc* SwNode::FindPageDesc( BOOL bCalcLay, if( pFmt ) { const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - if( FLY_PAGE != pAnchor->GetAnchorId() && + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor() ) { pNd = &pAnchor->GetCntntAnchor()->nNode.GetNode(); @@ -631,7 +629,7 @@ const SwPageDesc* SwNode::FindPageDesc( BOOL bCalcLay, break; } pAnchor = &pFrmFmt->GetAnchor(); - if( FLY_PAGE == pAnchor->GetAnchorId() || + if ((FLY_AT_PAGE == pAnchor->GetAnchorId()) || !pAnchor->GetCntntAnchor() ) { pFlyNd = 0; diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index 489d1c4dcf..e437493f54 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -47,7 +47,8 @@ #include <ddefld.hxx> #include <swddetbl.hxx> #include <frame.hxx> -#include <fmtmeta.hxx> +#include <txtatr.hxx> +#include <tox.hxx> // InvalidateTOXMark #include <docsh.hxx> #include <svl/smplhint.hxx> @@ -341,7 +342,8 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, break; case RES_TXTATR_TOXMARK: - nDelMsg = RES_TOXMARK_DELETED; + static_cast<SwTOXMark&>(pAttr->GetAttr()) + .InvalidateTOXMark(); break; case RES_TXTATR_REFMARK: @@ -350,8 +352,13 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, case RES_TXTATR_META: case RES_TXTATR_METAFIELD: - static_cast<SwFmtMeta&>(pAttr->GetAttr()) - .NotifyRemoval(); + { + SwTxtMeta *const pTxtMeta( + static_cast<SwTxtMeta*>(pAttr)); + // force removal of UNO object + pTxtMeta->ChgTxtNode(0); + pTxtMeta->ChgTxtNode(pTxtNd); + } break; default: diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 66dbd2e7a9..0706e3d888 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -835,6 +835,11 @@ void SwSectionFmt::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) break; } SwFrmFmt::Modify( pOld, pNew ); + + if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) + { // invalidate cached uno object + SetXTextSection(uno::Reference<text::XTextSection>(0)); + } } // erfrage vom Format Informationen diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx index 01711b931d..47961a47ea 100644 --- a/sw/source/core/docnode/swbaslnk.cxx +++ b/sw/source/core/docnode/swbaslnk.cxx @@ -31,14 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <hintids.hxx> #include <vcl/svapp.hxx> #include <vcl/outdev.hxx> -#ifndef _OSL_THREAD_HXX_ #include <osl/thread.hxx> -#endif #include <salhelper/condition.hxx> #include <comphelper/mediadescriptor.hxx> #include <sfx2/docfile.hxx> @@ -492,18 +489,23 @@ void SwBaseLink::Closed() const SwNode* SwBaseLink::GetAnchor() const { - SwFrmFmt* pFmt; - if( pCntntNode && 0 != ( pFmt = pCntntNode->GetFlyFmt()) ) + if (pCntntNode) { - const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - const SwPosition* pAPos; - if( 0 != ( pAPos = rAnchor.GetCntntAnchor()) && - ( FLY_IN_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_AT_FLY == rAnchor.GetAnchorId() || - FLY_AT_CNTNT == rAnchor.GetAnchorId() )) - return &pAPos->nNode.GetNode(); - return 0; + SwFrmFmt *const pFmt = pCntntNode->GetFlyFmt(); + if (pFmt) + { + const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AS_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_FLY == rAnchor.GetAnchorId()) || + (FLY_AT_PARA == rAnchor.GetAnchorId()))) + { + return &pAPos->nNode.GetNode(); + } + return 0; + } } ASSERT( !this, "GetAnchor nicht ueberlagert" ); diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 43b29f9e33..9ee5b8305c 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -60,9 +60,7 @@ #include <dflyobj.hxx> #include <dcontact.hxx> #include <unodraw.hxx> -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include <IDocumentDrawModelAccess.hxx> -#endif #include <doc.hxx> #include <hints.hxx> #include <txtfrm.hxx> @@ -1943,7 +1941,7 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) switch ( pAnch->GetAnchorId() ) { - case FLY_PAGE: + case FLY_AT_PAGE: { USHORT nPgNum = pAnch->GetPageNum(); SwPageFrm *pPage = static_cast<SwPageFrm*>(pRoot->Lower()); @@ -1963,12 +1961,12 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) } break; - case FLY_AUTO_CNTNT: - case FLY_AT_CNTNT: + case FLY_AT_CHAR: + case FLY_AT_PARA: case FLY_AT_FLY: - case FLY_IN_CNTNT: + case FLY_AS_CHAR: { - if ( pAnch->GetAnchorId() == FLY_IN_CNTNT ) + if ( pAnch->GetAnchorId() == FLY_AS_CHAR ) { ClrContourCache( GetMaster() ); } @@ -2043,7 +2041,7 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) // OD 2004-01-20 #110582# - find correct follow for // as character anchored objects. - if ( pAnch->GetAnchorId() == FLY_IN_CNTNT && + if ((pAnch->GetAnchorId() == FLY_AS_CHAR) && pFrm->IsTxtFrm() ) { pFrm = lcl_GetFlyInCntntAnchor( @@ -2061,7 +2059,7 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) { // append 'virtual' drawing object SwDrawVirtObj* pDrawVirtObj = AddVirtObj(); - if ( pAnch->GetAnchorId() == FLY_IN_CNTNT ) + if ( pAnch->GetAnchorId() == FLY_AS_CHAR ) { ClrContourCache( pDrawVirtObj ); } @@ -2072,7 +2070,7 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) pDrawVirtObj->ActionChanged(); } - if ( pAnch->GetAnchorId() == FLY_IN_CNTNT ) + if ( pAnch->GetAnchorId() == FLY_AS_CHAR ) { pFrm->InvalidatePrt(); } diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx index 08051aa33d..eb88a28f0e 100644 --- a/sw/source/core/draw/dview.cxx +++ b/sw/source/core/draw/dview.cxx @@ -34,9 +34,7 @@ #include "hintids.hxx" #include <svx/protitem.hxx> #include <svx/svdpagv.hxx> -#ifndef _FM_FMMODEL_HXX #include <svx/fmmodel.hxx> -#endif #include "swtypes.hxx" #include "pagefrm.hxx" @@ -62,8 +60,6 @@ #include <com/sun/star/embed/EmbedMisc.hpp> -using namespace com::sun::star; - // OD 18.06.2003 #108784# //#ifndef _SVDVMARK_HXX //autogen //#include <svx/svdvmark.hxx> @@ -74,6 +70,10 @@ using namespace com::sun::star; #include <flyfrms.hxx> // <-- + +using namespace com::sun::star; + + class SwSdrHdl : public SdrHdl { public: @@ -258,7 +258,7 @@ void SwDrawView::AddCustomHdl() const SwFmtAnchor &rAnchor = pFrmFmt->GetAnchor(); // <-- - if(FLY_IN_CNTNT == rAnchor.GetAnchorId()) + if (FLY_AS_CHAR == rAnchor.GetAnchorId()) return; const SwFrm* pAnch; @@ -267,7 +267,7 @@ void SwDrawView::AddCustomHdl() Point aPos(aAnchorPoint); - if ( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) { // --> OD 2004-06-24 #i28701# - use last character rectangle saved at object // in order to avoid a format of the anchor frame @@ -1019,7 +1019,7 @@ void SwDrawView::CheckPossibilities() "<SwDrawView::CheckPossibilities()> - missing frame format" ); bProtect = TRUE; } - else if ( FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId() && + else if ((FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId()) && rMrkList.GetMarkCount() > 1 ) { bProtect = TRUE; diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 26c94709c2..48ab1530a4 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -386,7 +386,7 @@ BOOL SwAutoFormat::HasObjects( const SwNode& rNd ) for( USHORT n = 0; n < rFmts.Count(); ++n ) { const SwFmtAnchor& rAnchor = rFmts[ n ]->GetAnchor(); - if( FLY_PAGE != rAnchor.GetAnchorId() && + if ((FLY_AT_PAGE != rAnchor.GetAnchorId()) && rAnchor.GetCntntAnchor() && &rAnchor.GetCntntAnchor()->nNode.GetNode() == &rNd ) { diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index c1e368a0b8..e2bf9d439e 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -63,7 +63,7 @@ #include <extinput.hxx> #include <crsskip.hxx> #include <scriptinfo.hxx> -#include <unoobj.hxx> +#include <unocrsrhelper.hxx> #include <section.hxx> #include <unochart.hxx> #include <numrule.hxx> @@ -1111,7 +1111,7 @@ String SwEditShell::DeleteExtTextInput( SwExtTextInput* pDel, BOOL bInsText ) if( pDel ) { rtl::OUString sTmp; - SwXTextCursor::getTextFromPam(*pDel, sTmp); + SwUnoCursorHelper::GetTextFromPam(*pDel, sTmp); sRet = sTmp; SET_CURR_SHELL( this ); StartAllAction(); diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index d620ff9f5f..311ad59135 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <hintids.hxx> #include <unotools/collatorwrapper.hxx> #include <unotools/charclass.hxx> @@ -41,6 +40,7 @@ #include <svx/fontitem.hxx> #include <com/sun/star/text/SetVariableType.hpp> #include <unofield.hxx> +#include <frmfmt.hxx> #include <fmtfld.hxx> #include <txtfld.hxx> #include <fmtanchr.hxx> @@ -64,9 +64,7 @@ #include <swtable.hxx> #include <breakit.hxx> #include <SwStyleNameMapper.hxx> -#ifndef _UNOFLDMID_H #include <unofldmid.h> -#endif #include <numrule.hxx> using namespace ::com::sun::star; @@ -187,17 +185,20 @@ const SwTxtNode* GetBodyTxtNode( const SwDoc& rDoc, SwPosition& rPos, pLayout = (SwLayoutFrm*)((SwFlyFrm*)pLayout)->GetAnchorFrm(); continue; } - else if( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + else if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AS_CHAR == rAnchor.GetAnchorId())) { ASSERT( rAnchor.GetCntntAnchor(), "keine gueltige Position" ); rPos = *rAnchor.GetCntntAnchor(); pTxtNode = rPos.nNode.GetNode().GetTxtNode(); - if( FLY_AT_CNTNT == rAnchor.GetAnchorId() ) - ((SwTxtNode*)pTxtNode)->MakeStartIndex( &rPos.nContent ); + if ( FLY_AT_PARA == rAnchor.GetAnchorId() ) + { + const_cast<SwTxtNode*>(pTxtNode)->MakeStartIndex( + &rPos.nContent ); // oder doch besser das Ende vom (Anker-)TextNode nehmen ?? // ((SwTxtNode*)pTxtNode)->MakeEndIndex( &rPos.nContent ); + } // noch nicht abbrechen, kann ja auch noch im // Header/Footer/Footnote/Fly stehen !! diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index 27f93b5cf6..e606befaf2 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -151,14 +151,16 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) SwFrmFmt* pFlyFmt = pFly->GetFmt(); SwFmtAnchor aAnchor( pFlyFmt->GetAnchor() ); - if ( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_AT_FLY == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AT_FLY == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { SwPosition aPos( aSttIdx ); - if( FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR == aAnchor.GetAnchorId() ) + { aPos.nContent.Assign( pTxtNd, 0 ); + } aAnchor.SetAnchor( &aPos ); } pFlyFmt = pClpDoc->CopyLayoutFmt( *pFlyFmt, aAnchor, true, true ); @@ -175,7 +177,7 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) rSpzFrmFmts.Insert( pFlyFmt, 0 ); } - if( FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR == aAnchor.GetAnchorId() ) { // JP 13.02.99 Bug 61863: wenn eine Rahmenselektion ins Clipboard // gestellt wird, so muss beim Pasten auch wieder @@ -206,24 +208,25 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) { SfxItemSet aSet( pClpDoc->GetAttrPool(), aFrmFmtSetRange ); - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); aAnchor.SetAnchor( &aPos ); aSet.Put( aAnchor ); - SdrObject* pNew = pClpDoc->CloneSdrObj( *pObj, FALSE, TRUE ); + SdrObject *const pNew = + pClpDoc->CloneSdrObj( *pObj, FALSE, TRUE ); SwPaM aTemp(aPos); - pClpDoc->Insert(aTemp, *pNew, &aSet, NULL); + pClpDoc->Insert(aTemp, *pNew, &aSet, NULL); } else { SwDrawContact *pContact = (SwDrawContact*)GetUserCall( pObj ); SwFrmFmt *pFmt = pContact->GetFmt(); SwFmtAnchor aAnchor( pFmt->GetAnchor() ); - if ( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_AT_FLY == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AT_FLY == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { aAnchor.SetAnchor( &aPos ); } @@ -269,7 +272,9 @@ BOOL lcl_SetAnchor( const SwPosition& rPos, const SwNode& rNd, SwFlyFrm* pFly, SwCntntFrm* pTmpFrm = rNd.GetCntntNode()->GetFrm( &rInsPt, 0, FALSE ); SwFlyFrm *pTmpFly = pTmpFrm->FindFlyFrm(); if( pTmpFly && bCheckFlyRecur && pFly->IsUpperOf( *pTmpFly ) ) + { bRet = FALSE; + } else if ( FLY_AT_FLY == rAnchor.GetAnchorId() ) { if( pTmpFly ) @@ -281,7 +286,7 @@ BOOL lcl_SetAnchor( const SwPosition& rPos, const SwNode& rNd, SwFlyFrm* pFly, } else { - rAnchor.SetType( FLY_PAGE ); + rAnchor.SetType( FLY_AT_PAGE ); rAnchor.SetPageNum( rDestShell.GetPageNumber( rInsPt ) ); const SwFrm *pPg = pTmpFrm->FindPageFrm(); rNewPos = pPg->Frm().Pos(); @@ -329,7 +334,7 @@ BOOL SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt, // in die Gruppe einfuegen, wenns aus einer betretenen Gruppe // kommt oder das Object nicht zeichengebunden ist if( pSrcDrwView->IsGroupEntered() || - FLY_IN_CNTNT != rAnchor.GetAnchorId() ) + (FLY_AS_CHAR != rAnchor.GetAnchorId()) ) { SdrObject* pNew = pDestDoc->CloneSdrObj( *pObj, bIsMove && @@ -345,10 +350,10 @@ BOOL SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt, SwFmtAnchor aAnchor( rAnchor ); Point aNewAnch; - if ( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_AT_FLY == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AT_FLY == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { if ( this == pDestShell ) { @@ -378,7 +383,7 @@ BOOL SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt, aNewAnch, FALSE ); } } - else if( FLY_PAGE == aAnchor.GetAnchorId() ) + else if ( FLY_AT_PAGE == aAnchor.GetAnchorId() ) { aAnchor.SetPageNum( pDestShell->GetPageNumber( rInsPt ) ); const SwRootFrm* pTmpRoot = pDestShell->GetLayout(); @@ -406,7 +411,7 @@ BOOL SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt, if ( pFmt ) { SdrObject* pNew = pFmt->FindSdrObject(); - if( FLY_IN_CNTNT != aAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR != aAnchor.GetAnchorId() ) { Point aPos( rInsPt ); aPos -= aNewAnch; @@ -496,10 +501,10 @@ BOOL SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt, bRet = TRUE; Point aNewAnch; - if ( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_AT_FLY == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AT_FLY == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { if ( this == pDestShell ) { @@ -537,7 +542,7 @@ BOOL SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt, aNewAnch, GetDoc() == pDestShell->GetDoc()); } } - else if( FLY_PAGE == aAnchor.GetAnchorId() ) + else if ( FLY_AT_PAGE == aAnchor.GetAnchorId() ) { aAnchor.SetPageNum( pDestShell->GetPageNumber( rInsPt ) ); const SwRootFrm* pTmpRoot = pDestShell->GetLayout(); @@ -554,7 +559,7 @@ BOOL SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt, SwFrmFmt *pOldFmt = pFlyFmt; pFlyFmt = pDestShell->GetDoc()->CopyLayoutFmt( *pFlyFmt, aAnchor, true, true ); - if( FLY_IN_CNTNT != aAnchor.GetAnchorId() ) + if ( FLY_AS_CHAR != aAnchor.GetAnchorId() ) { Point aPos( rInsPt ); aPos -= aNewAnch; @@ -918,7 +923,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) if( Imp()->GetDrawView()->IsGroupEntered() && RES_DRAWFRMFMT == rCpyFmt.Which() && - FLY_IN_CNTNT != rCpyFmt.GetAnchor().GetAnchorId() ) + (FLY_AS_CHAR != rCpyFmt.GetAnchor().GetAnchorId()) ) { const SdrObject* pSdrObj = rCpyFmt.FindSdrObject(); if( pSdrObj ) @@ -966,9 +971,9 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) if( bInsWithFmt ) { SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); - if( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { SwPosition* pPos = PCURCRSR->GetPoint(); // #108784# allow shapes (no controls) in header/footer @@ -979,7 +984,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) aAnchor.SetAnchor( pPos ); } - else if( FLY_PAGE == aAnchor.GetAnchorId() ) + else if ( FLY_AT_PAGE == aAnchor.GetAnchorId() ) { aAnchor.SetPageNum( GetPhyPageNum() ); } @@ -1091,7 +1096,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) if( bInsWithFmt ) { SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); - if( FLY_PAGE == aAnchor.GetAnchorId() ) + if ( FLY_AT_PAGE == aAnchor.GetAnchorId() ) { aAnchor.SetPageNum( aAnchor.GetPageNum() + nStartPageNumber - 1 ); } @@ -1199,7 +1204,7 @@ BOOL SwFEShell::PastePages( SwFEShell& rToFill, USHORT nStartPage, USHORT nEndPa { const SwFrmFmt& rCpyFmt = *(*GetDoc()->GetSpzFrmFmts())[i]; SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); - if( FLY_PAGE == aAnchor.GetAnchorId() && + if ((FLY_AT_PAGE == aAnchor.GetAnchorId()) && aAnchor.GetPageNum() >= nStartPage && aAnchor.GetPageNum() <= nEndPage) { aAnchor.SetPageNum( aAnchor.GetPageNum() - nStartPage + 1); diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index 70ee872744..267ec0eb09 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -113,7 +113,7 @@ sal_Bool lcl_SetNewFlyPos( const SwNode& rNode, SwFmtAnchor& rAnchor, const SwPageFrm *pPg = pCFrm ? pCFrm->FindPageFrm() : 0; rAnchor.SetPageNum( pPg ? pPg->GetPhyPageNum() : 1 ); - rAnchor.SetType( FLY_PAGE ); + rAnchor.SetType( FLY_AT_PAGE ); } return bRet; } @@ -130,9 +130,9 @@ BOOL lcl_FindAnchorPos( SwDoc& rDoc, const Point& rPt, const SwFrm& rFrm, Point aTmpPnt( rPt ); switch( nNew ) { - case FLY_IN_CNTNT: // sollte der nicht auch mit hinein? - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: // LAYER_IMPL + case FLY_AS_CHAR: // sollte der nicht auch mit hinein? + case FLY_AT_PARA: + case FLY_AT_CHAR: // LAYER_IMPL { //Ausgehend von der linken oberen Ecke des Fly den //dichtesten CntntFrm suchen. @@ -146,7 +146,7 @@ BOOL lcl_FindAnchorPos( SwDoc& rDoc, const Point& rPt, const SwFrm& rFrm, } SwPosition aPos( *((SwCntntFrm*)pNewAnch)->GetNode() ); - if( FLY_AUTO_CNTNT == nNew || FLY_IN_CNTNT == nNew ) + if ((FLY_AT_CHAR == nNew) || (FLY_AS_CHAR == nNew)) { // es muss ein TextNode gefunden werden, denn nur in diesen // ist ein Inhaltsgebundene Frames zu verankern @@ -186,10 +186,10 @@ BOOL lcl_FindAnchorPos( SwDoc& rDoc, const Point& rPt, const SwFrm& rFrm, } } - aNewAnch.SetType( nNew = FLY_PAGE ); + aNewAnch.SetType( nNew = FLY_AT_PAGE ); // no break - case FLY_PAGE: + case FLY_AT_PAGE: pNewAnch = rFrm.FindPageFrm(); aNewAnch.SetPageNum( pNewAnch->GetPhyPageNum() ); break; @@ -219,8 +219,8 @@ sal_Bool lcl_ChkAndSetNewAnchor( const SwFlyFrm& rFly, SfxItemSet& rSet ) SwDoc* pDoc = (SwDoc*)rFmt.GetDoc(); #ifdef DBG_UTIL - ASSERT( !(nNew == FLY_PAGE && - (FLY_AT_CNTNT==nOld || FLY_AUTO_CNTNT==nOld || FLY_IN_CNTNT==nOld ) && + ASSERT( !(nNew == FLY_AT_PAGE && + (FLY_AT_PARA==nOld || FLY_AT_CHAR==nOld || FLY_AS_CHAR==nOld ) && pDoc->IsInHeaderFooter( rOldAnch.GetCntntAnchor()->nNode )), "Unerlaubter Ankerwechsel in Head/Foot." ); #endif @@ -441,7 +441,7 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt(); RndStdIds nAnchorId = rFmt.GetAnchor().GetAnchorId(); - if ( FLY_IN_CNTNT == nAnchorId ) + if ( FLY_AS_CHAR == nAnchorId ) return aRet; sal_Bool bFlyFrame = pObj->ISA(SwVirtFlyDrawObj); @@ -462,8 +462,10 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) pOldAnch = pFly->GetAnchorFrm(); if( !pOldAnch ) return aRet; - if( FLY_PAGE != nAnchorId ) + if ( FLY_AT_PAGE != nAnchorId ) + { pFooterOrHeader = pCntnt->FindFooterOrHeader(); + } } // OD 26.06.2003 #108784# - set <pFooterOrHeader> also for drawing // objects, but not for control objects. @@ -489,14 +491,18 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) const SwFrm *pNewAnch; if( pTxtFrm ) { - if( FLY_PAGE == nAnchorId ) + if ( FLY_AT_PAGE == nAnchorId ) + { pNewAnch = pTxtFrm->FindPageFrm(); + } else { pNewAnch = ::FindAnchor( pTxtFrm, rAbsPos ); if( FLY_AT_FLY == nAnchorId ) // LAYER_IMPL + { pNewAnch = pNewAnch->FindFlyFrm(); + } } } else @@ -522,19 +528,19 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) { aRet = pNewAnch->GetFrmAnchorPos( ::HasWrap( pObj ) ); - if( bMoveIt || nAnchorId == FLY_AUTO_CNTNT ) + if ( bMoveIt || (nAnchorId == FLY_AT_CHAR) ) { SwFmtAnchor aAnch( rFmt.GetAnchor() ); switch ( nAnchorId ) { - case FLY_AT_CNTNT: + case FLY_AT_PARA: { SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor(); pPos->nNode = *pTxtFrm->GetNode(); pPos->nContent.Assign(0,0); break; } - case FLY_PAGE: + case FLY_AT_PAGE: { aAnch.SetPageNum( ((const SwPageFrm*)pNewAnch)-> GetPhyPageNum() ); @@ -547,7 +553,7 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, sal_Bool bMoveIt ) aAnch.SetAnchor( &aPos ); break; } - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: { SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor(); Point aTmpPnt( rAbsPos ); @@ -666,21 +672,25 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali RndStdIds eRndId = rAnch.GetAnchorId(); switch( eRndId ) { - case FLY_PAGE: + case FLY_AT_PAGE: if( !rAnch.GetPageNum() ) //HotFix: Bug in UpdateByExample rAnch.SetPageNum( 1 ); break; case FLY_AT_FLY: - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: - case FLY_IN_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: + case FLY_AS_CHAR: if( !bAnchValid ) { if( FLY_AT_FLY != eRndId ) + { rAnch.SetAnchor( &rPos ); + } else if( lcl_SetNewFlyPos( rPos.nNode.GetNode(), rAnch, aPt ) ) - eRndId = FLY_PAGE; + { + eRndId = FLY_AT_PAGE; + } } break; @@ -698,7 +708,7 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali SwFmtVertOrient aOldV; SwFmtHoriOrient aOldH; - if( FLY_PAGE != eRndId ) + if ( FLY_AT_PAGE != eRndId ) { // erstmal als mit Seitenbindung, Absatz/Zeichenbindung erst wenn // alles verschoben ist. Dann ist die Position gueltig! @@ -706,7 +716,7 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali // umsetzen, damit diese beim Umanker NICHT // korrigiert wird pOldAnchor = new SwFmtAnchor( rAnch ); - ((SfxItemSet&)rSet).Put( SwFmtAnchor( FLY_PAGE, 1 ) ); + const_cast<SfxItemSet&>(rSet).Put( SwFmtAnchor( FLY_AT_PAGE, 1 ) ); const SfxPoolItem* pItem; if( SFX_ITEM_SET == rSet.GetItemState( RES_HORI_ORIENT, sal_False, &pItem ) @@ -741,8 +751,10 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali const SwFrm* pAnch = ::FindAnchor( GetLayout(), aPt, sal_False ); SwPosition aPos( *((SwCntntFrm*)pAnch)->GetNode() ); - if( FLY_IN_CNTNT == eRndId ) + if ( FLY_AS_CHAR == eRndId ) + { aPos.nContent.Assign( ((SwCntntFrm*)pAnch)->GetNode(), 0 ); + } pOldAnchor->SetAnchor( &aPos ); // das verschieben von TabelleSelektion ist noch nicht @@ -818,9 +830,9 @@ void SwFEShell::Insert( const String& rGrfName, const String& rFltName, SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem; switch( pAnchor->GetAnchorId()) { - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: // LAYER_IMPL - case FLY_IN_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: // LAYER_IMPL + case FLY_AS_CHAR: if( !pAnchor->GetCntntAnchor() ) { pAnchor->SetAnchor( pCursor->GetPoint() ); @@ -833,7 +845,7 @@ void SwFEShell::Insert( const String& rGrfName, const String& rFltName, *pAnchor, GetCrsrDocPos() ); } break; - case FLY_PAGE: + case FLY_AT_PAGE: if( !pAnchor->GetPageNum() ) { pAnchor->SetPageNum( pCursor->GetPageNum( @@ -912,10 +924,10 @@ void SwFEShell::Insert( SdrObject& rDrawObj, const SfxPoolItem* pItem; if( !pFlyAttrSet || !pFlyAttrSet->GetItemState( RES_ANCHOR, sal_False, &pItem ) || - FLY_PAGE != ((SwFmtAnchor*)pItem)->GetAnchorId() ) + (FLY_AT_PAGE != ((SwFmtAnchor*)pItem)->GetAnchorId())) { pSet = new SfxItemSet( GetDoc()->GetAttrPool(), aFrmFmtSetRange ); - pSet->Put( SwFmtAnchor( FLY_AT_CNTNT )); + pSet->Put( SwFmtAnchor( FLY_AT_PARA )); pFlyAttrSet = pSet; } @@ -978,8 +990,10 @@ void SwFEShell::GetPageObjs( SvPtrarr& rFillArr ) for( sal_uInt16 n = 0; n < pDoc->GetSpzFrmFmts()->Count(); ++n ) { pFmt = (const SwFrmFmt*)(*pDoc->GetSpzFrmFmts())[n]; - if( FLY_PAGE == pFmt->GetAnchor().GetAnchorId() ) + if (FLY_AT_PAGE == pFmt->GetAnchor().GetAnchorId()) + { rFillArr.Insert( (VoidPtr)pFmt, rFillArr.Count() ); + } } } @@ -1010,7 +1024,7 @@ void SwFEShell::SetPageObjsNewPage( SvPtrarr& rFillArr, int nOffset ) { // FlyFmt ist noch gueltig, also behandeln SwFmtAnchor aNewAnchor( pFmt->GetAnchor() ); - if( FLY_PAGE != aNewAnchor.GetAnchorId() || + if ((FLY_AT_PAGE != aNewAnchor.GetAnchorId()) || 0 >= ( nNewPage = aNewAnchor.GetPageNum() + nOffset ) ) // chaos::Anchor wurde veraendert oder ungueltige SeitenNummer, // also nicht veraendern !! @@ -1086,12 +1100,12 @@ sal_Bool SwFEShell::GetFlyFrmAttr( SfxItemSet &rSet ) const SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem; RndStdIds eType = pAnchor->GetAnchorId(); - if( FLY_PAGE != eType ) + if ( FLY_AT_PAGE != eType ) { // OD 12.11.2003 #i22341# - content anchor of anchor item is needed. // Thus, don't overwrite anchor item by default contructed anchor item. //rSet.Put( SwFmtAnchor( eType ) ); - if( FLY_IN_CNTNT == eType ) + if ( FLY_AS_CHAR == eType ) { rSet.ClearItem( RES_OPAQUE ); rSet.ClearItem( RES_SURROUND ); @@ -1828,7 +1842,7 @@ ObjCntType SwFEShell::GetObjCntType( const SdrObject& rObj ) const "<SwFEShell::GetObjCntType(..)> - missing frame format" ); eType = OBJCNT_NONE; } - else if ( FLY_IN_CNTNT != pFrmFmt->GetAnchor().GetAnchorId() ) + else if ( FLY_AS_CHAR != pFrmFmt->GetAnchor().GetAnchorId() ) { eType = OBJCNT_GROUPOBJ; } diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index e8c849cee0..d7e0e4e02e 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -326,7 +326,7 @@ sal_Bool SwFEShell::MoveAnchor( USHORT nDir ) SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt(); SwFmtAnchor aAnch( rFmt.GetAnchor() ); RndStdIds nAnchorId = aAnch.GetAnchorId(); - if ( FLY_IN_CNTNT == nAnchorId ) + if ( FLY_AS_CHAR == nAnchorId ) return sal_False; if( pOld->IsVertical() ) { @@ -348,7 +348,7 @@ sal_Bool SwFEShell::MoveAnchor( USHORT nDir ) } } switch ( nAnchorId ) { - case FLY_PAGE: + case FLY_AT_PAGE: { ASSERT( pOld->IsPageFrm(), "Wrong anchor, page exspected." ); if( SW_MOVE_UP == nDir ) @@ -362,7 +362,7 @@ sal_Bool SwFEShell::MoveAnchor( USHORT nDir ) } break; } - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: { ASSERT( pOld->IsCntntFrm(), "Wrong anchor, page exspected." ); if( SW_MOVE_LEFT == nDir || SW_MOVE_RIGHT == nDir ) @@ -396,7 +396,7 @@ sal_Bool SwFEShell::MoveAnchor( USHORT nDir ) } } } // no break! - case FLY_AT_CNTNT: + case FLY_AT_PARA: { ASSERT( pOld->IsCntntFrm(), "Wrong anchor, page exspected." ); if( SW_MOVE_UP == nDir ) @@ -1652,7 +1652,7 @@ BOOL SwFEShell::ImpEndCreate() if( bCharBound ) { - aAnch.SetType( FLY_IN_CNTNT ); + aAnch.SetType( FLY_AS_CHAR ); aAnch.SetAnchor( &aPos ); } } @@ -1719,7 +1719,7 @@ BOOL SwFEShell::ImpEndCreate() bAtPage = true; else { - aAnch.SetType( FLY_AT_CNTNT ); + aAnch.SetType( FLY_AT_PARA ); aAnch.SetAnchor( &aPos ); } } @@ -1728,7 +1728,7 @@ BOOL SwFEShell::ImpEndCreate() { pPage = pAnch->FindPageFrm(); - aAnch.SetType( FLY_PAGE ); + aAnch.SetType( FLY_AT_PAGE ); aAnch.SetPageNum( pPage->GetPhyPageNum() ); pAnch = pPage; // die Page wird jetzt zum Anker } @@ -1871,7 +1871,7 @@ BOOL SwFEShell::ImpEndCreate() // <-- if( bCharBound ) { - ASSERT( aAnch.GetAnchorId() == FLY_IN_CNTNT, "wrong AnchorType" ); + ASSERT( aAnch.GetAnchorId() == FLY_AS_CHAR, "wrong AnchorType" ); SwTxtNode *pNd = aAnch.GetCntntAnchor()->nNode.GetNode().GetTxtNode(); SwFmtFlyCnt aFmt( pFmt ); pNd->InsertItem(aFmt, @@ -2256,7 +2256,7 @@ BOOL SwFEShell::IsGroupSelected() // --> FME 2004-12-08 #i38505# No ungroup allowed for 3d objects !pObj->Is3DObj() && // <-- - FLY_IN_CNTNT != ((SwDrawContact*)GetUserCall(pObj))-> + FLY_AS_CHAR != ((SwDrawContact*)GetUserCall(pObj))-> GetFmt()->GetAnchor().GetAnchorId() ) { return TRUE; @@ -2302,7 +2302,7 @@ bool SwFEShell::IsGroupAllowed() const "<SwFEShell::IsGroupAllowed()> - missing frame format" ); bIsGroupAllowed = false; } - else if ( FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId() ) + else if ( FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId() ) { bIsGroupAllowed = false; } @@ -2619,7 +2619,7 @@ BOOL SwFEShell::IsAlignPossible() const SdrObject *pO = Imp()->GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); SwDrawContact *pC = (SwDrawContact*)GetUserCall(pO); //only as character bound drawings can be aligned - bRet = pC->GetFmt()->GetAnchor().GetAnchorId() == FLY_IN_CNTNT; + bRet = (pC->GetFmt()->GetAnchor().GetAnchorId() == FLY_AS_CHAR); } if ( bRet ) return Imp()->GetDrawView()->IsAlignPossible(); @@ -2664,7 +2664,7 @@ void SwFEShell::CheckUnboundObjects() { pAnch = ::FindAnchor( pPage, aPt, TRUE ); SwPosition aPos( *((SwCntntFrm*)pAnch)->GetNode() ); - aAnch.SetType( FLY_AT_CNTNT ); + aAnch.SetType( FLY_AT_PARA ); aAnch.SetAnchor( &aPos ); ((SwRect&)GetCharRect()).Pos() = aPt; } diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx index 4485ba99f6..fd2939fc27 100644 --- a/sw/source/core/frmedt/fews.cxx +++ b/sw/source/core/frmedt/fews.cxx @@ -31,11 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <tools/list.hxx> -//#ifndef _SVDVMARK_HXX //autogen -//#include <svx/svdvmark.hxx> -//#endif #include <svx/svdobj.hxx> #include <init.hxx> #include <fesh.hxx> @@ -71,8 +67,10 @@ // OD 2004-03-29 #i26791# #include <dcontact.hxx> + using namespace com::sun::star; + TYPEINIT1(SwFEShell,SwEditShell) /*********************************************************************** @@ -780,12 +778,12 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, BOOL bVertic = FALSE; BOOL bRTL = FALSE; - if( FLY_PAGE == _nAnchorId || FLY_AT_FLY == _nAnchorId ) // LAYER_IMPL + if ((FLY_AT_PAGE == _nAnchorId) || (FLY_AT_FLY == _nAnchorId)) // LAYER_IMPL { const SwFrm* pTmp = pFrm; // OD 06.11.2003 #i22305# - if ( FLY_PAGE == _nAnchorId || - ( FLY_AT_FLY == _nAnchorId && !_bFollowTextFlow ) ) + if ((FLY_AT_PAGE == _nAnchorId) || + ((FLY_AT_FLY == _nAnchorId) && !_bFollowTextFlow)) { pFrm = pPage; } @@ -906,7 +904,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, aPos = (pFrm->Frm().*fnRect->fnGetPos)(); // OD 08.09.2003 #i17567#, #108749#, #110354# - allow negative positions // for fly frames anchor to paragraph/to character. - if ( _nAnchorId == FLY_AT_CNTNT || _nAnchorId == FLY_AUTO_CNTNT ) + if ((_nAnchorId == FLY_AT_PARA) || (_nAnchorId == FLY_AT_CHAR)) { // The rectangle, the fly frame can be positioned in, is determined // horizontally by the frame area of the horizontal environment @@ -985,7 +983,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, // fly frame). Thus, assure this. const SwTxtFrm* pTxtFrm( dynamic_cast<const SwTxtFrm*>(pFrm) ); if ( pTxtFrm && - _nAnchorId == FLY_AUTO_CNTNT && + (_nAnchorId == FLY_AT_CHAR) && ( _eVertRelOrient == text::RelOrientation::CHAR || _eVertRelOrient == text::RelOrientation::TEXT_LINE ) ) { @@ -1032,7 +1030,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, // position (<aPos.X()> respectively <aPos.Y()>), if object is // anchored to character and horizontal aligned at character. if ( pTxtFrm && - _nAnchorId == FLY_AUTO_CNTNT && + (_nAnchorId == FLY_AT_CHAR) && _eHoriRelOrient == text::RelOrientation::CHAR ) { SwTwips nLeft = 0L; diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 26eed5bdf8..6979478c33 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> #include <svx/boxitem.hxx> #include <svx/protitem.hxx> @@ -984,11 +985,11 @@ BOOL IsEmptyBox( const SwTableBox& rBox, SwPaM& rPam ) for( USHORT n = 0; n < rFmts.Count(); ++n ) { - const SwPosition* pAPos; const SwFmtAnchor& rAnchor = rFmts[n]->GetAnchor(); - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor() ) && + const SwPosition* pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) && nSttIdx <= ( nIdx = pAPos->nNode.GetIndex() ) && nIdx < nEndIdx ) { diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx index 415deffa24..c281e69b18 100644 --- a/sw/source/core/inc/bookmrk.hxx +++ b/sw/source/core/inc/bookmrk.hxx @@ -31,12 +31,20 @@ #ifndef _BOOKMRK_HXX #define _BOOKMRK_HXX -#include <IMark.hxx> +#include <cppuhelper/weakref.hxx> + #include <sfx2/Metadatable.hxx> #include <boost/scoped_ptr.hpp> #include <boost/noncopyable.hpp> +#include <IMark.hxx> + + +namespace com { namespace sun { namespace star { + namespace text { class XTextContent; } +} } } + struct SwPosition; // fwd Decl. wg. UI class SwDoc; @@ -90,6 +98,17 @@ namespace sw { namespace mark {} virtual ~MarkBase(); + + // SwClient + virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); + + const ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextContent> & GetXBookmark() const + { return m_wXBookmark; } + void SetXBookmark(::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent> const& xBkmk) + { m_wXBookmark = xBkmk; } + protected: MarkBase(const SwPaM& rPaM, const ::rtl::OUString& rName); @@ -97,6 +116,9 @@ namespace sw { namespace mark ::boost::scoped_ptr<SwPosition> m_pPos2; ::rtl::OUString m_aName; static ::rtl::OUString GenerateNewName(const ::rtl::OUString& rPrefix); + + ::com::sun::star::uno::WeakReference< + ::com::sun::star::text::XTextContent> m_wXBookmark; }; class NavigatorReminder diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx index 6b629270e0..4de6f3d3d2 100644 --- a/sw/source/core/inc/flyfrm.hxx +++ b/sw/source/core/inc/flyfrm.hxx @@ -109,10 +109,10 @@ protected: //(CheckClip) nur das Format aufgerufen wird; //nicht aber die Breite anhand der Attribute //wieder bestimmt wird. - BOOL bInCnt :1; // FLY_IN_CNTNT, als Zeichen verankert - BOOL bAtCnt :1; // FLY_AT_CNTNT, am Absatz verankert - BOOL bLayout :1; // FLY_PAGE, FLY_AT_FLY, an Seite oder Rahmen - BOOL bAutoPosition :1; // FLY_AUTO_CNTNT, im Text verankerter Rahmen + BOOL bInCnt :1; // FLY_AS_CHAR, anchored as character + BOOL bAtCnt :1; // FLY_AT_PARA, anchored at paragraph + BOOL bLayout :1; // FLY_AT_PAGE, FLY_AT_FLY, at page or at frame + BOOL bAutoPosition :1; // FLY_AT_CHAR, anchored at character BOOL bNoShrink :1; // temporary forbud of shrinking to avoid loops BOOL bLockDeleteContent :1; // If the flag is set, the content of the // fly frame is not deleted if moved to diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index 199be26f58..1cb76b9255 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -141,7 +141,7 @@ const SwFrm * MA_FASTCALL FindPage( const SwRect &rRect, const SwFrm *pPage ); // JP 07.05.98: wird von SwCntntNode::GetFrm und von SwFlyFrm::GetFrm // gerufen -SwFrm* GetFrmOfModify( SwModify&, USHORT nFrmType, const Point* = 0, +SwFrm* GetFrmOfModify( SwModify const&, USHORT const nFrmType, const Point* = 0, const SwPosition *pPos = 0, const BOOL bCalcFrm = FALSE ); diff --git a/sw/source/core/inc/unoclbck.hxx b/sw/source/core/inc/unoclbck.hxx deleted file mode 100644 index 230b7eb503..0000000000 --- a/sw/source/core/inc/unoclbck.hxx +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: unoclbck.hxx,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _UNOCLBCK_HXX -#define _UNOCLBCK_HXX -#include <calbck.hxx> - -class SwXReferenceMark; -class SwFmtRefMark; -class SwFmtFtn; -class SwXFootnote; -class SwTOXMark; -class SwXDocumentIndexMark; - -class SwUnoCallBack : public SwModify -{ -public: - SwUnoCallBack(SwModify *pToRegisterIn); - virtual ~SwUnoCallBack(); - - // returns the API object of a reference mark if available - SwXReferenceMark* GetRefMark(const SwFmtRefMark& rMark); - SwXFootnote* GetFootnote(const SwFmtFtn& rMark); - SwXDocumentIndexMark* GetTOXMark(const SwTOXMark& rMark); -}; -#endif diff --git a/sw/source/core/inc/unometa.hxx b/sw/source/core/inc/unometa.hxx index 1dc1985f7d..39f81caa90 100755 --- a/sw/source/core/inc/unometa.hxx +++ b/sw/source/core/inc/unometa.hxx @@ -31,63 +31,99 @@ #ifndef SW_UNOMETA_HXX #define SW_UNOMETA_HXX -#include "calbck.hxx" - -#include <sfx2/Metadatable.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase5.hxx> +#include <deque> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/text/XTextContent.hpp> #include <com/sun/star/text/XTextField.hpp> -#include <deque> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase5.hxx> + +#include <sfx2/Metadatable.hxx> + +#include <unobaseclass.hxx> typedef ::std::deque< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > > TextRangeList_t; -class SwXTextRange; class SwPaM; -class SwTxtMeta; +class SwTxtNode; + namespace sw { class Meta; class MetaField; } -typedef -::cppu::ImplInheritanceHelper5 -< ::sfx2::MetadatableMixin -, ::com::sun::star::lang::XUnoTunnel -, ::com::sun::star::lang::XServiceInfo -, ::com::sun::star::text::XTextContent -, ::com::sun::star::text::XText -, ::com::sun::star::container::XEnumerationAccess -> SwXMetaBaseClass; +typedef ::cppu::ImplInheritanceHelper5 +< ::sfx2::MetadatableMixin +, ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::container::XEnumerationAccess +, ::com::sun::star::text::XTextContent +, ::com::sun::star::text::XText +> SwXMeta_Base; class SwXMeta - : public SwXMetaBaseClass - , public SwClient + : public SwXMeta_Base , private ::boost::noncopyable { -private: - struct Impl; - ::std::auto_ptr<Impl> m_pImpl; + +public: + + class Impl; protected: + + ::sw::UnoImplPtr<Impl> m_pImpl; + + virtual void SAL_CALL AttachImpl( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange, + const USHORT nWhich) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ~SwXMeta(); -public: - SwXMeta(SwDoc *const pDoc, + /// @param pDoc and pMeta != 0, but not & because of ImplInheritanceHelper + SwXMeta(SwDoc *const pDoc, ::sw::Meta *const pMeta, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> const& xParentText, - TextRangeList_t * const pPortions, SwTxtMeta * const pHint); + TextRangeList_t const*const pPortions); + +public: + SwXMeta(SwDoc *const pDoc); - TYPEINFO(); + static ::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable > + CreateXMeta( + ::sw::Meta & rMeta, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> + const& xParentText = 0, + ::std::auto_ptr<TextRangeList_t const> pPortions = + ::std::auto_ptr<TextRangeList_t const>(0)); + + /// init params with position of the attribute content (w/out CH_TXTATR) + bool SetContentRange( + SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd) const; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + GetParentText() const; + + bool CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // MetadatableMixin + virtual ::sfx2::Metadatable * GetCoreObject(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + GetModel(); static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); @@ -118,6 +154,18 @@ public: ::com::sun::star::lang::XEventListener > & xListener) 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); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + // XTextContent virtual void SAL_CALL attach( const ::com::sun::star::uno::Reference< @@ -180,72 +228,37 @@ public: throw (::com::sun::star::container::NoSuchElementException, ::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); - - // XEnumerationAccess - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::container::XEnumeration > SAL_CALL - createEnumeration() - throw (::com::sun::star::uno::RuntimeException); - - // MetadatableMixin - virtual ::sfx2::Metadatable * GetCoreObject(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > - GetModel(); - - // SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); - - /// init params with position of the attribute content (w/out CH_TXTATR) - bool SetContentRange( - SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd) const; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > - GetParentText() const; - - bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - -protected: - virtual void SAL_CALL AttachImpl( - const ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > & xTextRange, - const USHORT nWhich) - throw ( ::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException ); - -private: - inline const ::sw::Meta * GetMeta() const; - }; -typedef -::cppu::ImplInheritanceHelper2 -< SwXMeta -, ::com::sun::star::beans::XPropertySet -, ::com::sun::star::text::XTextField -> SwXMetaFieldBaseClass; +typedef ::cppu::ImplInheritanceHelper2 +< SwXMeta +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::text::XTextField +> SwXMetaField_Base; class SwXMetaField - : public SwXMetaFieldBaseClass + : public SwXMetaField_Base { + private: + virtual ~SwXMetaField(); -private: - inline const ::sw::MetaField * GetMetaField() const; + friend ::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable > + SwXMeta::CreateXMeta(::sw::Meta &, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> + const&, + ::std::auto_ptr<TextRangeList_t const> pPortions); -public: - SwXMetaField(SwDoc *const pDoc, + SwXMetaField(SwDoc *const pDoc, ::sw::Meta *const pMeta, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> const& xParentText, - TextRangeList_t * const pPortions, SwTxtMeta * const pHint); + TextRangeList_t const*const pPortions); + +public: + SwXMetaField(SwDoc *const pDoc); // XServiceInfo @@ -270,16 +283,6 @@ public: ::com::sun::star::lang::XEventListener > & xListener) 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); - // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL @@ -327,6 +330,16 @@ public: ::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() + throw (::com::sun::star::uno::RuntimeException); + // XTextField virtual rtl::OUString SAL_CALL getPresentation(sal_Bool bShowCommand) throw (::com::sun::star::uno::RuntimeException); diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index e2376f3d8e..7762216928 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -37,12 +37,8 @@ #include <pagefrm.hxx> #include <cntfrm.hxx> #include <doc.hxx> -#ifndef _TOCNTNTANCHOROBJECTPOSITION_HXX #include <tocntntanchoredobjectposition.hxx> -#endif -#ifndef _TOLAYOUTANCHOROBJECTPOSITION_HXX #include <tolayoutanchoredobjectposition.hxx> -#endif #include <frmtool.hxx> #include <fmtornt.hxx> // --> OD 2004-08-12 #i32795# @@ -357,7 +353,7 @@ void SwAnchoredDrawObject::MakeObjPos() // determine relative position of drawing object and set it switch ( pDrawContact->GetAnchorId() ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: { // indicate that position will be valid after positioning is performed mbValidPos = true; @@ -365,15 +361,15 @@ void SwAnchoredDrawObject::MakeObjPos() // during the format of its anchor frame - see <SwFlyCntPortion::SetBase(..)> } break; - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: { // --> OD 2004-08-12 #i32795# - move intrinsic positioning to // helper method <_MakeObjPosAnchoredAtPara()> _MakeObjPosAnchoredAtPara(); } break; - case FLY_PAGE: + case FLY_AT_PAGE: case FLY_AT_FLY: { // --> OD 2004-08-12 #i32795# - move intrinsic positioning to @@ -603,7 +599,7 @@ void SwAnchoredDrawObject::_InvalidatePage( SwPageFrm* _pPageFrm ) { // --> OD 2004-11-11 #i35007# - correct invalidation for as-character // anchored objects. - if ( GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + if ( GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR ) { _pPageFrm->InvalidateFlyInCnt(); } @@ -645,7 +641,7 @@ void SwAnchoredDrawObject::InvalidateObjPos() // --> OD 2005-03-09 #i44559# - assure, that text hint is already // existing in the text frame if ( GetAnchorFrm()->ISA(SwTxtFrm) && - GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + (GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR) ) { SwTxtFrm* pAnchorTxtFrm( static_cast<SwTxtFrm*>(AnchorFrm()) ); if ( pAnchorTxtFrm->GetTxtNode()->GetpSwpHints() && diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx index eed807f6f2..25aee1b555 100644 --- a/sw/source/core/layout/anchoredobject.cxx +++ b/sw/source/core/layout/anchoredobject.cxx @@ -306,7 +306,7 @@ void SwAnchoredObject::CheckCharRectAndTopOfLine( GetAnchorFrm()->IsTxtFrm() ) { const SwFmtAnchor& rAnch = GetFrmFmt().GetAnchor(); - if ( rAnch.GetAnchorId() == FLY_AUTO_CNTNT && + if ( (rAnch.GetAnchorId() == FLY_AT_CHAR) && rAnch.GetCntntAnchor() ) { // --> OD 2004-07-14 #117380# - if requested, assure that anchor frame, @@ -540,8 +540,8 @@ bool SwAnchoredObject::ConsiderObjWrapInfluenceOnObjPos() const // <-- { const SwFmtAnchor& rAnchor = rObjFmt.GetAnchor(); - if ( ( rAnchor.GetAnchorId() == FLY_AUTO_CNTNT || - rAnchor.GetAnchorId() == FLY_AT_CNTNT ) && + if ( ((rAnchor.GetAnchorId() == FLY_AT_CHAR) || + (rAnchor.GetAnchorId() == FLY_AT_PARA)) && rObjFmt.GetSurround().GetSurround() != SURROUND_THROUGHT ) { // --> OD 2004-09-23 #i34520# - text also wraps around anchored @@ -792,7 +792,7 @@ void SwAnchoredObject::UpdateObjInSortedList() AnchorFrm()->GetDrawObjs()->Update( *this ); // update its position in the sorted object list of its page frame // note: as-character anchored object aren't registered at a page frame - if ( GetFrmFmt().GetAnchor().GetAnchorId() != FLY_IN_CNTNT ) + if ( GetFrmFmt().GetAnchor().GetAnchorId() != FLY_AS_CHAR ) { GetPageFrm()->GetSortedObjs()->Update( *this ); } @@ -859,8 +859,8 @@ SwTxtFrm* SwAnchoredObject::FindAnchorCharFrm() if ( mpAnchorFrm ) { const SwFmtAnchor& rAnch = GetFrmFmt().GetAnchor(); - if ( rAnch.GetAnchorId() == FLY_AUTO_CNTNT || - rAnch.GetAnchorId() == FLY_IN_CNTNT ) + if ((rAnch.GetAnchorId() == FLY_AT_CHAR) || + (rAnch.GetAnchorId() == FLY_AS_CHAR)) { pAnchorCharFrm = &(static_cast<SwTxtFrm*>(AnchorFrm())-> GetFrmAtOfst( rAnch.GetCntntAnchor()->nContent.GetIndex() )); diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 394303d743..a8519847d2 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -51,9 +51,7 @@ #include <com/sun/star/awt/Size.hpp> #include <svtools/unoimap.hxx> #include <svtools/unoevent.hxx> -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include <basic/sbxvar.hxx> -#endif #include <svtools/imap.hxx> #include <svtools/imapobj.hxx> #include <svx/ulspitem.hxx> @@ -79,9 +77,7 @@ #include <fmtcnct.hxx> #include <node.hxx> #include <section.hxx> -#ifndef _FMTLINE_HXX #include <fmtline.hxx> -#endif #include <tgrditem.hxx> #include <hfspacingitem.hxx> #include <doc.hxx> @@ -103,6 +99,7 @@ #include <fmtclbl.hxx> #include <swunohelper.hxx> #include <unoframe.hxx> +#include <unotextbodyhf.hxx> #include <SwStyleNameMapper.hxx> /// OD 22.08.2002 #99657# /// include definition of class SvxBrushItem and GraphicObject @@ -110,18 +107,12 @@ #include <svx/brshitem.hxx> #include <goodies/grfmgr.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _UNOMID_H #include <unomid.h> -#endif #ifndef _COMCORE_HRC #include <comcore.hrc> #endif -#ifndef _SVX_SVUNDO_HXX #include <svx/svdundo.hxx> // #111827# -#endif // OD 2004-05-24 #i28701# #include <sortedobjs.hxx> // --> OD 2006-03-06 #125892# @@ -207,7 +198,8 @@ void DelHFFormat( SwClient *pToRemove, SwFrmFmt *pFmt ) SwClient *pLast = aIter.GoStart(); if( pLast ) do { - bDel = pLast->IsA( TYPE(SwFrm) )|| pLast->IsA(TYPE(SwXHeadFootText)); + bDel = pLast->IsA( TYPE(SwFrm) ) + || SwXHeadFootText::IsXHeadFootText(pLast); } while( bDel && 0 != ( pLast = aIter++ )); } @@ -1484,9 +1476,11 @@ void SwFmtAnchor::SetAnchor( const SwPosition *pPos ) delete pCntntAnchor; pCntntAnchor = pPos ? new SwPosition( *pPos ) : 0; //AM Absatz gebundene Flys sollten nie in den Absatz hineinzeigen. - if ( pCntntAnchor && ( FLY_AT_CNTNT == nAnchorId || - FLY_AT_FLY == nAnchorId )) + if (pCntntAnchor && + ((FLY_AT_PARA == nAnchorId) || (FLY_AT_FLY == nAnchorId))) + { pCntntAnchor->nContent.Assign( 0, 0 ); + } } SwFmtAnchor& SwFmtAnchor::operator=(const SwFmtAnchor& rAnchor) @@ -1543,14 +1537,23 @@ BOOL SwFmtAnchor::QueryValue( uno::Any& rVal, BYTE nMemberId ) const case MID_ANCHOR_ANCHORTYPE: text::TextContentAnchorType eRet; - switch((sal_Int16)GetAnchorId()) + switch (GetAnchorId()) { - case FLY_AUTO_CNTNT : eRet = text::TextContentAnchorType_AT_CHARACTER;break; - case FLY_PAGE : eRet = text::TextContentAnchorType_AT_PAGE; break; - case FLY_AT_FLY : eRet = text::TextContentAnchorType_AT_FRAME; break; - case FLY_IN_CNTNT : eRet = text::TextContentAnchorType_AS_CHARACTER;break; - //case FLY_AT_CNTNT : - default: eRet = text::TextContentAnchorType_AT_PARAGRAPH; + case FLY_AT_CHAR: + eRet = text::TextContentAnchorType_AT_CHARACTER; + break; + case FLY_AT_PAGE: + eRet = text::TextContentAnchorType_AT_PAGE; + break; + case FLY_AT_FLY: + eRet = text::TextContentAnchorType_AT_FRAME; + break; + case FLY_AS_CHAR: + eRet = text::TextContentAnchorType_AS_CHARACTER; + break; + //case FLY_AT_PARA: + default: + eRet = text::TextContentAnchorType_AT_PARAGRAPH; } rVal <<= eRet; break; @@ -1591,10 +1594,10 @@ BOOL SwFmtAnchor::PutValue( const uno::Any& rVal, BYTE nMemberId ) switch( SWUnoHelper::GetEnumAsInt32( rVal ) ) { case text::TextContentAnchorType_AS_CHARACTER: - eAnchor = FLY_IN_CNTNT; + eAnchor = FLY_AS_CHAR; break; case text::TextContentAnchorType_AT_PAGE: - eAnchor = FLY_PAGE; + eAnchor = FLY_AT_PAGE; if( GetPageNum() > 0 && pCntntAnchor ) { // If the anchor type is page and a valid page number @@ -1608,11 +1611,11 @@ BOOL SwFmtAnchor::PutValue( const uno::Any& rVal, BYTE nMemberId ) eAnchor = FLY_AT_FLY; break; case text::TextContentAnchorType_AT_CHARACTER: - eAnchor = FLY_AUTO_CNTNT; + eAnchor = FLY_AT_CHAR; break; //case text::TextContentAnchorType_AT_PARAGRAPH: default: - eAnchor = FLY_AT_CNTNT; + eAnchor = FLY_AT_PARA; break; } SetType( eAnchor ); @@ -1624,7 +1627,7 @@ BOOL SwFmtAnchor::PutValue( const uno::Any& rVal, BYTE nMemberId ) if((rVal >>= nVal) && nVal > 0) { SetPageNum( nVal ); - if( FLY_PAGE == GetAnchorId() && pCntntAnchor ) + if ((FLY_AT_PAGE == GetAnchorId()) && pCntntAnchor) { // If the anchor type is page and a valid page number // is set, the content paoition has to be deleted to not @@ -2478,6 +2481,11 @@ void SwFrmFmt::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) // wegen RESET_FMTWRITTEN. // if ( GetDepends() ) SwFmt::Modify( pOld, pNew ); + + if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) + { // invalidate cached uno object + SetXObject(uno::Reference<uno::XInterface>(0)); + } } //Vernichtet alle Frms, die in aDepend angemeldet sind. @@ -2597,7 +2605,7 @@ sal_Bool SwFrmFmt::IsLowerOf( const SwFrmFmt& rFmt ) const // dann mal ueber die Node-Positionen versuchen const SwFmtAnchor* pAnchor = &rFmt.GetAnchor(); - if( FLY_PAGE != pAnchor->GetAnchorId() && pAnchor->GetCntntAnchor() ) + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor()) { const SwSpzFrmFmts& rFmts = *GetDoc()->GetSpzFrmFmts(); const SwNode* pFlyNd = pAnchor->GetCntntAnchor()->nNode.GetNode(). @@ -2616,9 +2624,11 @@ sal_Bool SwFrmFmt::IsLowerOf( const SwFrmFmt& rFmt ) const return sal_True; pAnchor = &pFmt->GetAnchor(); - if( FLY_PAGE == pAnchor->GetAnchorId() || + if ((FLY_AT_PAGE == pAnchor->GetAnchorId()) || !pAnchor->GetCntntAnchor() ) + { return sal_False; + } pFlyNd = pAnchor->GetCntntAnchor()->nNode.GetNode(). FindFlyStartNode(); @@ -2702,11 +2712,13 @@ void SwFlyFrmFmt::MakeFrms() SwFmtAnchor aAnchorAttr( GetAnchor() ); switch( aAnchorAttr.GetAnchorId() ) { - case FLY_IN_CNTNT: - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_PARA: + case FLY_AT_CHAR: if( aAnchorAttr.GetCntntAnchor() ) + { pModify = aAnchorAttr.GetCntntAnchor()->nNode.GetNode().GetCntntNode(); + } break; case FLY_AT_FLY: @@ -2739,7 +2751,7 @@ void SwFlyFrmFmt::MakeFrms() } break; - case FLY_PAGE: + case FLY_AT_PAGE: { sal_uInt16 nPgNum = aAnchorAttr.GetPageNum(); SwPageFrm *pPage = (SwPageFrm*)GetDoc()->GetRootFrm()->Lower(); @@ -2822,12 +2834,12 @@ void SwFlyFrmFmt::MakeFrms() pFly = new SwFlyLayFrm( this, pFrm ); break; - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: pFly = new SwFlyAtCntFrm( this, pFrm ); break; - case FLY_IN_CNTNT: + case FLY_AS_CHAR: pFly = new SwFlyInCntFrm( this, pFrm ); break; default: @@ -3026,8 +3038,8 @@ SwHandleAnchorNodeChg::SwHandleAnchorNodeChg( SwFlyFrmFmt& _rFlyFrmFmt, mbAnchorNodeChanged( false ) { const RndStdIds nNewAnchorType( _rNewAnchorFmt.GetAnchorId() ); - if ( ( nNewAnchorType == FLY_AT_CNTNT || - nNewAnchorType == FLY_AUTO_CNTNT ) && + if ( ((nNewAnchorType == FLY_AT_PARA) || + (nNewAnchorType == FLY_AT_CHAR)) && _rNewAnchorFmt.GetCntntAnchor() && _rNewAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode() ) { diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index 91090ac630..02f901a3fc 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -46,9 +46,7 @@ #include <svx/ulspitem.hxx> #include <svx/keepitem.hxx> -#ifndef _OUTDEV_HXX //autogen #include <vcl/outdev.hxx> -#endif #include <fmtfsize.hxx> #include <fmtanchr.hxx> #include <fmtclbl.hxx> @@ -1014,10 +1012,12 @@ BOOL SwCntntFrm::MakePrtArea( const SwBorderAttrs &rAttrs ) rFmt.GetFrmSize().GetWidthPercent() ) continue; - if ( FLY_IN_CNTNT == rFmt.GetAnchor().GetAnchorId() ) + if ( FLY_AS_CHAR == rFmt.GetAnchor().GetAnchorId() ) + { nMinWidth = Max( nMinWidth, bFly ? rFmt.GetFrmSize().GetWidth() : pObj->GetObjRect().Width() ); + } // <-- } diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 4968601e7a..1073421e01 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -366,7 +366,7 @@ BYTE SwFlowFrm::BwdMoveNecessary( const SwPageFrm *pPage, const SwRect &rRect ) //denn dann weiche ich ihm nicht aus. if ( ::IsFrmInSameKontext( pAnchor, &rThis ) ) { - if ( rFmt.GetAnchor().GetAnchorId() == FLY_AT_CNTNT ) + if ( rFmt.GetAnchor().GetAnchorId() == FLY_AT_PARA ) { // Den Index des anderen erhalten wir immer ueber das Ankerattr. ULONG nTmpIndex = rFmt.GetAnchor().GetCntntAnchor()->nNode.GetIndex(); diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index c7eb4b408c..83909c17ed 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -33,9 +33,7 @@ #include "hintids.hxx" #include <svl/itemiter.hxx> #include <svtools/imap.hxx> -#ifndef _GRAPH_HXX //autogen #include <vcl/graph.hxx> -#endif #include <tools/poly.hxx> #include <svx/contdlg.hxx> #include <svx/protitem.hxx> @@ -1182,7 +1180,7 @@ void SwFlyFrm::ChgRelPos( const Point &rNewPos ) // --> OD 2004-11-12 #i34948# - handle also at-page and at-fly anchored // Writer fly frames const RndStdIds eAnchorType = GetFrmFmt().GetAnchor().GetAnchorId(); - if ( eAnchorType == FLY_PAGE ) + if ( eAnchorType == FLY_AT_PAGE ) { aVert.SetVertOrient( text::VertOrientation::NONE ); aVert.SetRelationOrient( text::RelOrientation::PAGE_FRAME ); @@ -1235,7 +1233,7 @@ void SwFlyFrm::ChgRelPos( const Point &rNewPos ) SwFmtHoriOrient aHori( pFmt->GetHoriOrient() ); // --> OD 2004-11-12 #i34948# - handle also at-page and at-fly anchored // Writer fly frames - if ( eAnchorType == FLY_PAGE ) + if ( eAnchorType == FLY_AT_PAGE ) { aHori.SetHoriOrient( text::HoriOrientation::NONE ); aHori.SetRelationOrient( text::RelOrientation::PAGE_FRAME ); @@ -1645,11 +1643,17 @@ void CalcCntnt( SwLayoutFrm *pLay, { // Bei autopositionierten hilft manchmal nur // noch, auf Durchlauf zu schalten - if( rFmt.GetAnchor().GetAnchorId() == FLY_AUTO_CNTNT && - SURROUND_PARALLEL == aAttr.GetSurround() ) + if ((rFmt.GetAnchor().GetAnchorId() == + FLY_AT_CHAR) && + (SURROUND_PARALLEL == + aAttr.GetSurround())) + { aAttr.SetSurround( SURROUND_THROUGHT ); + } else + { aAttr.SetSurround( SURROUND_PARALLEL ); + } rFmt.LockModify(); rFmt.SetFmtAttr( aAttr ); rFmt.UnlockModify(); @@ -2313,7 +2317,8 @@ void SwFrm::InvalidateObjs( const bool _bInvaPosOnly, { SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[i]; if ( _bNoInvaOfAsCharAnchoredObjs && - pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + (pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() + == FLY_AS_CHAR) ) { continue; } diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 1fadf0378f..ece6233db2 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -90,7 +90,7 @@ SwFlyAtCntFrm::SwFlyAtCntFrm( SwFlyFrmFmt *pFmt, SwFrm *pAnch ) : SwFlyFreeFrm( pFmt, pAnch ) { bAtCnt = TRUE; - bAutoPosition = FLY_AUTO_CNTNT == pFmt->GetAnchor().GetAnchorId(); + bAutoPosition = (FLY_AT_CHAR == pFmt->GetAnchor().GetAnchorId()); } // --> OD 2004-06-29 #i28701# diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx index 5e6e53b69b..61654a68c2 100644 --- a/sw/source/core/layout/flylay.cxx +++ b/sw/source/core/layout/flylay.cxx @@ -600,7 +600,7 @@ void SwFlyLayFrm::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) SwPageFrm *pOldPage = GetPageFrm(); AnchorFrm()->RemoveFly( this ); - if( FLY_PAGE == pAnch->GetAnchorId() ) + if ( FLY_AT_PAGE == pAnch->GetAnchorId() ) { USHORT nPgNum = pAnch->GetPageNum(); SwRootFrm *pRoot = FindRootFrm(); @@ -955,7 +955,7 @@ void SwPageFrm::AppendDrawObjToPage( SwAnchoredObject& _rNewObj ) _rNewObj.DrawObj()->SetOrdNum( nNewNum ); } - if ( FLY_IN_CNTNT == _rNewObj.GetFrmFmt().GetAnchor().GetAnchorId() ) + if ( FLY_AS_CHAR == _rNewObj.GetFrmFmt().GetAnchor().GetAnchorId() ) { return; } @@ -999,7 +999,8 @@ void SwPageFrm::RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj ) } if ( GetUpper() ) { - if ( FLY_IN_CNTNT != _rToRemoveObj.GetFrmFmt().GetAnchor().GetAnchorId() ) + if (FLY_AS_CHAR != + _rToRemoveObj.GetFrmFmt().GetAnchor().GetAnchorId()) { ((SwRootFrm*)GetUpper())->SetSuperfluous(); InvalidatePage(); @@ -1333,7 +1334,7 @@ BOOL CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, BOOL bMove ) const SwDrawContact *pC = (const SwDrawContact*)GetUserCall(pSdrObj); const SwFrmFmt *pFmt = (const SwFrmFmt*)pC->GetFmt(); const SwFmtAnchor &rAnch = pFmt->GetAnchor(); - if ( FLY_IN_CNTNT == rAnch.GetAnchorId() ) + if ( FLY_AS_CHAR == rAnch.GetAnchorId() ) { const SwFrm* pAnchorFrm = pC->GetAnchorFrm( pSdrObj ); if( !pAnchorFrm ) diff --git a/sw/source/core/layout/flypos.cxx b/sw/source/core/layout/flypos.cxx index 3800fcf03f..27571f6527 100644 --- a/sw/source/core/layout/flypos.cxx +++ b/sw/source/core/layout/flypos.cxx @@ -57,8 +57,10 @@ SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt, { BOOL bFnd = FALSE; const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_PAGE == rAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == rAnchor.GetAnchorId()) + { pNdIdx = new SwNodeIndex( rIdx ); + } else if( pFmt->GetDoc()->GetRootFrm() ) { SwClientIter aIter( (SwFmt&)*pFmt ); @@ -88,8 +90,10 @@ SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt, SwPosFlyFrm::~SwPosFlyFrm() { const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); - if( FLY_PAGE == rAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == rAnchor.GetAnchorId()) + { delete pNdIdx; + } } BOOL SwPosFlyFrm::operator==( const SwPosFlyFrm& ) diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 82c921750a..8593e53dee 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1033,9 +1033,11 @@ SwCntntNotify::~SwCntntNotify() SwFrmFmt *pFmt = (*pTbl)[i]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); - if ( FLY_PAGE != rAnch.GetAnchorId() && - FLY_AT_CNTNT != rAnch.GetAnchorId() ) + if ((FLY_AT_PAGE != rAnch.GetAnchorId()) && + (FLY_AT_PARA != rAnch.GetAnchorId())) + { continue; //#60878# nicht etwa zeichengebundene. + } BOOL bCheckPos = FALSE; if ( rAnch.GetCntntAnchor() ) @@ -1047,7 +1049,7 @@ SwCntntNotify::~SwCntntNotify() if ( rAnch.GetCntntAnchor()->nNode == *pIdx ) { bCheckPos = TRUE; - if ( FLY_PAGE == rAnch.GetAnchorId() ) + if (FLY_AT_PAGE == rAnch.GetAnchorId()) { ASSERT( false, "<SwCntntNotify::~SwCntntNotify()> - to page anchored object with content position. Please inform OD." ); SwFmtAnchor aAnch( rAnch ); @@ -1097,7 +1099,7 @@ SwCntntNotify::~SwCntntNotify() { SwAnchoredObject* pAnchoredObj = (*pObjs)[i]; if ( pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() - == FLY_AUTO_CNTNT ) + == FLY_AT_CHAR ) { pAnchoredObj->CheckCharRectAndTopOfLine( !pMasterFrm->IsEmpty() ); } @@ -1135,11 +1137,11 @@ void AppendObjs( const SwSpzFrmFmts *pTbl, ULONG nIndex, // OD 23.06.2003 #108784# - append also drawing objects anchored // as character. const bool bDrawObjInCntnt = bSdrObj && - rAnch.GetAnchorId() == FLY_IN_CNTNT; + (rAnch.GetAnchorId() == FLY_AS_CHAR); if( bFlyAtFly || - rAnch.GetAnchorId() == FLY_AT_CNTNT || - rAnch.GetAnchorId() == FLY_AUTO_CNTNT || + (rAnch.GetAnchorId() == FLY_AT_PARA) || + (rAnch.GetAnchorId() == FLY_AT_CHAR) || bDrawObjInCntnt ) { SdrObject* pSdrObj = 0; @@ -1227,7 +1229,7 @@ bool lcl_InHeaderOrFooter( SwFrmFmt& _rFmt ) const SwFmtAnchor& rAnch = _rFmt.GetAnchor(); - if ( rAnch.GetAnchorId() != FLY_PAGE ) + if (rAnch.GetAnchorId() != FLY_AT_PAGE) { bRetVal = _rFmt.GetDoc()->IsInHeaderFooter( rAnch.GetCntntAnchor()->nNode ); } @@ -1256,10 +1258,13 @@ void AppendAllObjs( const SwSpzFrmFmts *pTbl ) SwFrmFmt *pFmt = (SwFrmFmt*)aCpy[ USHORT(i) ]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); BOOL bRemove = FALSE; - if ( rAnch.GetAnchorId() == FLY_PAGE || rAnch.GetAnchorId() == FLY_IN_CNTNT ) + if ((rAnch.GetAnchorId() == FLY_AT_PAGE) || + (rAnch.GetAnchorId() == FLY_AS_CHAR)) + { //Seitengebunde sind bereits verankert, zeichengebundene //will ich hier nicht. bRemove = TRUE; + } else if ( FALSE == (bRemove = ::lcl_ObjConnected( pFmt )) || ::lcl_InHeaderOrFooter( *pFmt ) ) { @@ -2578,7 +2583,7 @@ void MA_FASTCALL lcl_RemoveObjsFromPage( SwFrm* _pFrm ) // --> OD 2004-11-29 #115759# - remove also drawing objects from page else if ( pObj->ISA(SwAnchoredDrawObject) ) { - if ( pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_IN_CNTNT ) + if (pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_AS_CHAR) { pObj->GetPageFrm()->RemoveDrawObjFromPage( *(static_cast<SwAnchoredDrawObject*>(pObj)) ); @@ -2746,7 +2751,7 @@ void MA_FASTCALL lcl_AddObjsToPage( SwFrm* _pFrm, SwPageFrm* _pPage ) // --> OD 2004-11-29 #115759# - remove also drawing objects from page else if ( pObj->ISA(SwAnchoredDrawObject) ) { - if ( pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_IN_CNTNT ) + if (pObj->GetFrmFmt().GetAnchor().GetAnchorId() != FLY_AS_CHAR) { pObj->InvalidateObjPos(); _pPage->AppendDrawObjToPage( @@ -3514,8 +3519,8 @@ const SwFrm* MA_FASTCALL FindPage( const SwRect &rRect, const SwFrm *pPage ) return pPage; } -SwFrm* GetFrmOfModify( SwModify& rMod, USHORT nFrmType, const Point* pPoint, - const SwPosition *pPos, const BOOL bCalcFrm ) +SwFrm* GetFrmOfModify( SwModify const& rMod, USHORT const nFrmType, + const Point* pPoint, const SwPosition *pPos, const BOOL bCalcFrm ) { SwFrm *pMinFrm = 0, *pTmpFrm; SwRect aCalcRect; diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx index 977f458863..767a16abb3 100644 --- a/sw/source/core/layout/laycache.cxx +++ b/sw/source/core/layout/laycache.cxx @@ -63,17 +63,16 @@ #include <sortedobjs.hxx> // --> OD 2006-03-22 #b6375613# #include <pam.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <com/sun/star/document/XDocumentInfoSupplier.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <set> + + using namespace ::com::sun::star; // <-- -#include <set> - SV_IMPL_PTRARR( SwPageFlyCache, SwFlyCachePtr ) /*-----------------28.5.2001 10:06------------------ @@ -696,8 +695,8 @@ bool lcl_HasTextFrmAnchoredObjs( SwTxtFrm* p_pTxtFrm ) SwFrmFmt *pFmt = (SwFrmFmt*)(*pSpzFrmFmts)[i]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); if ( rAnch.GetCntntAnchor() && - ( rAnch.GetAnchorId() == FLY_AT_CNTNT || - rAnch.GetAnchorId() == FLY_AUTO_CNTNT ) && + ((rAnch.GetAnchorId() == FLY_AT_PARA) || + (rAnch.GetAnchorId() == FLY_AT_CHAR)) && rAnch.GetCntntAnchor()->nNode.GetIndex() == p_pTxtFrm->GetTxtNode()->GetIndex() ) { diff --git a/sw/source/core/layout/objectformatter.cxx b/sw/source/core/layout/objectformatter.cxx index ded11f9796..a89e2cd07e 100644 --- a/sw/source/core/layout/objectformatter.cxx +++ b/sw/source/core/layout/objectformatter.cxx @@ -338,7 +338,7 @@ void SwObjectFormatter::_FormatObj( SwAnchoredObject& _rAnchoredObj ) // check, if only as-character anchored object have to be formatted, and // check the anchor type if ( FormatOnlyAsCharAnchored() && - !_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + !(_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR) ) { return; } diff --git a/sw/source/core/layout/objectformattertxtfrm.cxx b/sw/source/core/layout/objectformattertxtfrm.cxx index 2967d8a97a..c1956e4b22 100644 --- a/sw/source/core/layout/objectformattertxtfrm.cxx +++ b/sw/source/core/layout/objectformattertxtfrm.cxx @@ -136,7 +136,7 @@ bool SwObjectFormatterTxtFrm::DoFormatObj( SwAnchoredObject& _rAnchoredObj, // check, if only as-character anchored object have to be formatted, and // check the anchor type if ( FormatOnlyAsCharAnchored() && - !_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + !(_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR) ) { return true; } @@ -656,8 +656,8 @@ bool SwObjectFormatterTxtFrm::CheckMovedFwdCondition( // which will be on the next page. if ( !bAnchorIsMovedForward && _bAnchoredAtMasterBeforeFormatAnchor && - ( _rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AUTO_CNTNT || - _rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AT_CNTNT ) ) + ((_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AT_CHAR) || + (_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AT_PARA))) { SwFrm* pAnchorFrm = _rAnchoredObj.GetAnchorFrmContainingAnchPos(); ASSERT( pAnchorFrm->IsTxtFrm(), diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index b7079fad50..42f9208d6a 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -46,9 +46,7 @@ #include <ftninfo.hxx> #include <tgrditem.hxx> #include <viewopt.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include "viewimp.hxx" #include "pagefrm.hxx" @@ -408,7 +406,7 @@ void MA_FASTCALL lcl_MakeObjs( const SwSpzFrmFmts &rTbl, SwPageFrm *pPage ) { if( rAnch.GetCntntAnchor() ) { - if( FLY_PAGE == rAnch.GetAnchorId() ) + if (FLY_AT_PAGE == rAnch.GetAnchorId()) { SwFmtAnchor aAnch( rAnch ); aAnch.SetAnchor( 0 ); @@ -1659,7 +1657,7 @@ void SwRootFrm::AssertPageFlys( SwPageFrm *pPage ) SwFrmFmt& rFmt = (*pPage->GetSortedObjs())[i]->GetFrmFmt(); const SwFmtAnchor &rAnch = rFmt.GetAnchor(); const USHORT nPg = rAnch.GetPageNum(); - if ( rAnch.GetAnchorId() == FLY_PAGE && + if ((rAnch.GetAnchorId() == FLY_AT_PAGE) && nPg != pPage->GetPhyPageNum() ) { //Das er auf der falschen Seite steht muss noch nichts @@ -1834,11 +1832,11 @@ void SwRootFrm::ImplCalcBrowseWidth() long nWidth = 0; switch ( rFmt.GetAnchor().GetAnchorId() ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: nWidth = bFly ? rFmt.GetFrmSize().GetWidth() : pAnchoredObj->GetObjRect().Width(); break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: { // --> FME 2004-09-13 #i33170# // Reactivated old code because @@ -2007,7 +2005,7 @@ void lcl_MoveAllLowerObjs( SwFrm* pFrm, const Point& rOffset ) // all except from the as character anchored objects are moved // when processing the page frame: - const bool bAsChar = rAnchor.GetAnchorId() == FLY_IN_CNTNT; + const bool bAsChar = (rAnchor.GetAnchorId() == FLY_AS_CHAR); if ( !bPage && !bAsChar ) continue; diff --git a/sw/source/core/layout/sortedobjsimpl.cxx b/sw/source/core/layout/sortedobjsimpl.cxx index bd4e128dc4..024e35a355 100644 --- a/sw/source/core/layout/sortedobjsimpl.cxx +++ b/sw/source/core/layout/sortedobjsimpl.cxx @@ -41,17 +41,14 @@ #include <ndtxt.hxx> #include <fmtsrnd.hxx> #include <fmtwrapinfluenceonobjpos.hxx> -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include <IDocumentDrawModelAccess.hxx> -#endif + using namespace ::com::sun::star; typedef std::vector< SwAnchoredObject* >::iterator tIter; typedef std::vector< SwAnchoredObject* >::const_iterator tConstIter; -using namespace ::com::sun::star; - SwSortedObjsImpl::SwSortedObjsImpl() { @@ -96,36 +93,36 @@ struct ObjAnchorOrder const SwFmtAnchor* pAnchorNew = &(rFmtNew.GetAnchor()); // check for to-page anchored objects - if ( pAnchorListed->GetAnchorId() == FLY_PAGE && - pAnchorNew->GetAnchorId() != FLY_PAGE ) + if ((pAnchorListed->GetAnchorId() == FLY_AT_PAGE) && + (pAnchorNew ->GetAnchorId() != FLY_AT_PAGE)) { return true; } - else if ( pAnchorListed->GetAnchorId() != FLY_PAGE && - pAnchorNew->GetAnchorId() == FLY_PAGE ) + else if ((pAnchorListed->GetAnchorId() != FLY_AT_PAGE) && + (pAnchorNew ->GetAnchorId() == FLY_AT_PAGE)) { return false; } - else if ( pAnchorListed->GetAnchorId() == FLY_PAGE && - pAnchorNew->GetAnchorId() == FLY_PAGE ) + else if ((pAnchorListed->GetAnchorId() == FLY_AT_PAGE) && + (pAnchorNew ->GetAnchorId() == FLY_AT_PAGE)) { return pAnchorListed->GetOrder() < pAnchorNew->GetOrder(); } // Both objects aren't anchored to page. // Thus, check for to-fly anchored objects - if ( pAnchorListed->GetAnchorId() == FLY_AT_FLY && - pAnchorNew->GetAnchorId() != FLY_AT_FLY ) + if ((pAnchorListed->GetAnchorId() == FLY_AT_FLY) && + (pAnchorNew ->GetAnchorId() != FLY_AT_FLY)) { return true; } - else if ( pAnchorListed->GetAnchorId() != FLY_AT_FLY && - pAnchorNew->GetAnchorId() == FLY_AT_FLY ) + else if ((pAnchorListed->GetAnchorId() != FLY_AT_FLY) && + (pAnchorNew ->GetAnchorId() == FLY_AT_FLY)) { return false; } - else if ( pAnchorListed->GetAnchorId() == FLY_AT_FLY && - pAnchorNew->GetAnchorId() == FLY_AT_FLY ) + else if ((pAnchorListed->GetAnchorId() == FLY_AT_FLY) && + (pAnchorNew ->GetAnchorId() == FLY_AT_FLY)) { return pAnchorListed->GetOrder() < pAnchorNew->GetOrder(); } @@ -144,21 +141,21 @@ struct ObjAnchorOrder // --> OD 2006-11-29 #???# - objects have to be ordered by anchor node position // Thus, compare content anchor node positions and anchor type, // if not anchored at-paragraph - if ( pAnchorListed->GetAnchorId() != FLY_AT_CNTNT && - pAnchorNew->GetAnchorId() != FLY_AT_CNTNT && + if ((pAnchorListed->GetAnchorId() != FLY_AT_PARA) && + (pAnchorNew ->GetAnchorId() != FLY_AT_PARA) && pCntntAnchorListed && pCntntAnchorNew ) { if ( pCntntAnchorListed->nContent != pCntntAnchorNew->nContent ) { return pCntntAnchorListed->nContent < pCntntAnchorNew->nContent; } - else if ( pAnchorListed->GetAnchorId() == FLY_AUTO_CNTNT && - pAnchorNew->GetAnchorId() == FLY_IN_CNTNT ) + else if ((pAnchorListed->GetAnchorId() == FLY_AT_CHAR) && + (pAnchorNew ->GetAnchorId() == FLY_AS_CHAR)) { return true; } - else if ( pAnchorListed->GetAnchorId() == FLY_IN_CNTNT && - pAnchorNew->GetAnchorId() == FLY_AUTO_CNTNT ) + else if ((pAnchorListed->GetAnchorId() == FLY_AS_CHAR) && + (pAnchorNew ->GetAnchorId() == FLY_AT_CHAR)) { return false; } diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 2041797e54..ed95d13c43 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -57,9 +57,7 @@ // --> collapsing borders FME 2005-05-27 #i29550# #include <svx/boxitem.hxx> // <-- -#ifndef _OUTDEV_HXX //autogen #include <vcl/outdev.hxx> -#endif #include <fmtlsplt.hxx> #include <fmtrowsplt.hxx> #include <fmtsrnd.hxx> @@ -340,7 +338,7 @@ void lcl_InvalidateLowerObjs( SwLayoutFrm& _rLayoutFrm, pAnchoredObj->ClearCharRectAndTopOfLine(); pAnchoredObj->SetCurrRelPos( Point( 0, 0 ) ); if ( pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() - == FLY_IN_CNTNT ) + == FLY_AS_CHAR ) { pAnchoredObj->AnchorFrm() ->Prepare( PREP_FLY_ATTR_CHG, @@ -4194,7 +4192,7 @@ long MA_FASTCALL CalcHeightWidthFlys( const SwFrm *pFrm ) // the text flow have to be considered. const SwFrmFmt& rFrmFmt = pAnchoredObj->GetFrmFmt(); const bool bConsiderObj = - rFrmFmt.GetAnchor().GetAnchorId() != FLY_IN_CNTNT && + (rFrmFmt.GetAnchor().GetAnchorId() != FLY_AS_CHAR) && pAnchoredObj->GetObjRect().Top() != WEIT_WECH && rFrmFmt.GetFollowTextFlow().GetValue() && pAnchoredObj->GetPageFrm() == pTmp->FindPageFrm(); @@ -5222,7 +5220,7 @@ BOOL lcl_ArrangeLowers( SwLayoutFrm *pLay, long lYStart, BOOL bInva ) !( pTabFrm->IsFollow() && pTabFrm->FindMaster()->IsRebuildLastLine() ) && !pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() - == FLY_IN_CNTNT ) + == FLY_AS_CHAR ) { SwPageFrm* pPageFrm = pAnchoredObj->GetPageFrm(); SwPageFrm* pPageOfAnchor = pFrm->FindPageFrm(); diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index 726615f1bc..f2e0671866 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -35,9 +35,7 @@ #include <hintids.hxx> #include <hints.hxx> #include <tools/pstm.hxx> -#ifndef _OUTDEV_HXX #include <vcl/outdev.hxx> -#endif #include <svl/itemiter.hxx> #include <svx/brshitem.hxx> #include <svx/keepitem.hxx> @@ -52,9 +50,7 @@ #include <viewimp.hxx> #include <doc.hxx> #include <fesh.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <flyfrm.hxx> #include <frmtool.hxx> #include <ftninfo.hxx> @@ -81,8 +77,10 @@ // OD 2004-05-24 #i28701# #include <sortedobjs.hxx> + using namespace ::com::sun::star; + /************************************************************************* |* |* SwFrm::SwFrm() @@ -4004,8 +4002,8 @@ void SwRootFrm::InvalidateAllObjPos() { SwAnchoredObject* pAnchoredObj = rObjs[i]; const SwFmtAnchor& rAnch = pAnchoredObj->GetFrmFmt().GetAnchor(); - if ( rAnch.GetAnchorId() != FLY_AT_CNTNT && - rAnch.GetAnchorId() != FLY_AUTO_CNTNT ) + if ((rAnch.GetAnchorId() != FLY_AT_PARA) && + (rAnch.GetAnchorId() != FLY_AT_CHAR)) { // only to paragraph and to character anchored objects are considered. continue; diff --git a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx index b052e2e652..f1e317dac4 100644 --- a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx @@ -47,13 +47,9 @@ #include <fmtornt.hxx> #include <svx/lrspitem.hxx> #include <svx/ulspitem.hxx> -#ifndef _SVX_SVDOBJ_HXX #include <svx/svdobj.hxx> -#endif #include <pam.hxx> -#ifndef _ENVIRONMENTOFANCHOREDOBJECT #include <environmentofanchoredobject.hxx> -#endif #include <frmtool.hxx> #include <ndtxt.hxx> #include <dflyobj.hxx> @@ -209,7 +205,7 @@ void SwToCntntAnchoredObjectPosition::CalcPosition() { // if object is at-character anchored, determine character-rectangle // and frame, position has to be oriented at. - mbAnchorToChar = FLY_AUTO_CNTNT == rFrmFmt.GetAnchor().GetAnchorId(); + mbAnchorToChar = (FLY_AT_CHAR == rFrmFmt.GetAnchor().GetAnchorId()); if ( mbAnchorToChar ) { const SwFmtAnchor& rAnch = rFrmFmt.GetAnchor(); diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 2b67b2c1f0..67361127e8 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2064,9 +2064,11 @@ BOOL SwTable::GetInfo( SfxPoolItem& rInfo ) const return TRUE; } -SwTable* SwTable::FindTable( SwFrmFmt* pFmt ) +SwTable * SwTable::FindTable( SwFrmFmt const*const pFmt ) { - return pFmt ? (SwTable*)SwClientIter( *pFmt ).First( TYPE(SwTable) ) : 0; + return (pFmt) + ? static_cast<SwTable*>(SwClientIter(*pFmt).First( TYPE(SwTable) )) + : 0; } SwTableNode* SwTable::GetTableNode() const diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index a9715cc9ff..5dd37c429e 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -31,15 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" #include <com/sun/star/embed/XEmbeddedObject.hpp> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif #include <EnhancedPDFExportHelper.hxx> #include <hintids.hxx> -#ifndef _OUTDEV_HXX #include <vcl/outdev.hxx> -#endif #include <tools/multisel.hxx> #include <svx/adjitem.hxx> #include <svx/lrspitem.hxx> @@ -370,9 +366,9 @@ bool SwTaggedPDFHelper::CheckReopenTag() { const SwFmtAnchor& rAnchor = static_cast<const SwFlyFrm*>(&rFrm)->GetFmt()->GetAnchor(); - if ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_PAGE == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_PAGE == rAnchor.GetAnchorId())) { pKeyFrm = static_cast<const SwFlyFrm&>(rFrm).GetAnchorFrm(); bContinue = true; @@ -1814,7 +1810,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() // --> FME 2005-05-09 #i44368# Links in Header/Footer const SwFmtAnchor &rAnch = pFrmFmt->GetAnchor(); - if ( FLY_PAGE != rAnch.GetAnchorId() ) + if (FLY_AT_PAGE != rAnch.GetAnchorId()) { const SwPosition* pPosition = rAnch.GetCntntAnchor(); if ( pPosition && pDoc->IsInHeaderFooter( pPosition->nNode ) ) diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index 09be2bd798..b02f0310e4 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -461,10 +461,8 @@ sal_Bool lcl_MinMaxNode( const SwFrmFmtPtr& rpNd, void* pArgs ) const SwFmtAnchor& rFmtA = ((SwFrmFmt*)rpNd)->GetAnchor(); bool bCalculate = false; - if ( - (FLY_AT_CNTNT == rFmtA.GetAnchorId()) || - (FLY_AUTO_CNTNT == rFmtA.GetAnchorId()) - ) + if ((FLY_AT_PARA == rFmtA.GetAnchorId()) || + (FLY_AT_CHAR == rFmtA.GetAnchorId())) { bCalculate = true; } diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index f690c3064b..c8fba54dbc 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -39,9 +39,7 @@ #include "frmfmt.hxx" // SwFrmFmt #include "viewsh.hxx" -#ifndef _OUTDEV_HXX //autogen #include <vcl/outdev.hxx> -#endif #include <svx/lrspitem.hxx> #include <svx/ulspitem.hxx> #include <fmtanchr.hxx> @@ -57,6 +55,7 @@ // OD 2004-05-24 #i28701# #include <sortedobjs.hxx> + /************************************************************************* * class SwFlyPortion * @@ -178,7 +177,7 @@ void SwTxtFrm::MoveFlyInCnt( SwTxtFrm *pNew, xub_StrLen nStart, xub_StrLen nEnd // <SwSortedList> entries SwAnchoredObject* pAnchoredObj = (*pObjs)[i]; const SwFmtAnchor& rAnch = pAnchoredObj->GetFrmFmt().GetAnchor(); - if ( rAnch.GetAnchorId() == FLY_IN_CNTNT ) + if (rAnch.GetAnchorId() == FLY_AS_CHAR) { const SwPosition* pPos = rAnch.GetCntntAnchor(); xub_StrLen nIdx = pPos->nContent.GetIndex(); diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx index 38d5bb9fe1..4604129abf 100644 --- a/sw/source/core/text/txtfly.cxx +++ b/sw/source/core/text/txtfly.cxx @@ -31,12 +31,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#ifndef _OUTDEV_HXX //autogen #include <vcl/outdev.hxx> -#endif -#ifndef _VIRDEV_HXX //autogen #include <vcl/virdev.hxx> -#endif #include "viewsh.hxx" #include "pagefrm.hxx" @@ -61,14 +57,9 @@ #include "flyfrms.hxx" #include "fmtcnct.hxx" // SwFmtChain #include <pormulti.hxx> // SwMultiPortion -#ifdef VERT_DISTANCE -#include <math.h> -#endif #include <svx/obj3d.hxx> -#ifndef _TXTRANGE_HXX //autogen #include <svx/txtrange.hxx> -#endif #include <svx/lrspitem.hxx> #include <svx/ulspitem.hxx> // --> OD 2004-06-16 #i28701# @@ -83,30 +74,26 @@ #include <tgrditem.hxx> #include <sortedobjs.hxx> #include <layouter.hxx> -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include <IDocumentDrawModelAccess.hxx> -#endif #include <IDocumentLayoutAccess.hxx> #include <IDocumentSettingAccess.hxx> #include <svx/obj3d.hxx> -#ifndef _TXTRANGE_HXX //autogen #include <svx/txtrange.hxx> -#endif #include <svx/lrspitem.hxx> #include <svx/ulspitem.hxx> #include <svx/lspcitem.hxx> #include <svx/svdoedge.hxx> - +#include "doc.hxx" #ifdef DBG_UTIL #include "viewopt.hxx" // SwViewOptions, nur zum Testen (Test2) #endif -#include "doc.hxx" #ifdef VERT_DISTANCE #include <math.h> #endif + using namespace ::com::sun::star; /***************************************************************************** @@ -1006,8 +993,8 @@ sal_Bool SwTxtFly::DrawTextOpaque( SwDrawTextInfo &rInf ) // --> OD 2006-08-15 #i68520# GetMaster() == pFly->GetAnchorFrm() || // <-- - ( FLY_AT_CNTNT != rAnchor.GetAnchorId() && - FLY_AUTO_CNTNT != rAnchor.GetAnchorId() + ((FLY_AT_PARA != rAnchor.GetAnchorId()) && + (FLY_AT_CHAR != rAnchor.GetAnchorId()) ) ) && // --> OD 2006-08-15 #i68520# @@ -1176,7 +1163,7 @@ sal_Bool SwTxtFly::GetTop( const SwAnchoredObject* _pAnchoredObj, const SwFrmFmt& rFrmFmt = _pAnchoredObj->GetFrmFmt(); const SwFmtAnchor& rNewA = rFrmFmt.GetAnchor(); // <-- - if ( FLY_PAGE == rNewA.GetAnchorId() ) + if (FLY_AT_PAGE == rNewA.GetAnchorId()) { if ( bInFtn ) return sal_False; @@ -1225,23 +1212,25 @@ sal_Bool SwTxtFly::GetTop( const SwAnchoredObject* _pAnchoredObj, // If <mpCurrAnchoredObj> is anchored as character, its content // does not wrap around pNew - if( FLY_IN_CNTNT == rCurrA.GetAnchorId() ) + if (FLY_AS_CHAR == rCurrA.GetAnchorId()) return sal_False; // If pNew is anchored to page and <mpCurrAnchoredObj is not anchored // to page, the content of <mpCurrAnchoredObj> does not wrap around pNew // If both pNew and <mpCurrAnchoredObj> are anchored to page, we can do // some more checks - if( FLY_PAGE == rNewA.GetAnchorId() ) + if (FLY_AT_PAGE == rNewA.GetAnchorId()) { - if( FLY_PAGE == rCurrA.GetAnchorId() ) + if (FLY_AT_PAGE == rCurrA.GetAnchorId()) + { bEvade = sal_True; + } else return sal_False; } - else if( FLY_PAGE == rCurrA.GetAnchorId() ) + else if (FLY_AT_PAGE == rCurrA.GetAnchorId()) return sal_False; // Seitengebundene weichen nur seitengeb. aus - else if( FLY_AT_FLY == rNewA.GetAnchorId() ) + else if (FLY_AT_FLY == rNewA.GetAnchorId()) bEvade = sal_True; // Nicht seitengeb. weichen Rahmengeb. aus else if( FLY_AT_FLY == rCurrA.GetAnchorId() ) return sal_False; // Rahmengebundene weichen abs.geb. nicht aus @@ -1285,8 +1274,9 @@ sal_Bool SwTxtFly::GetTop( const SwAnchoredObject* _pAnchoredObj, // --> OD 2004-10-06 #i26945# const SwFmtAnchor& rNewA = _pAnchoredObj->GetFrmFmt().GetAnchor(); // <-- - ASSERT( FLY_IN_CNTNT != rNewA.GetAnchorId(), "Don't call GetTop with a FlyInCntFrm" ); - if( FLY_PAGE == rNewA.GetAnchorId() ) + ASSERT( FLY_AS_CHAR != rNewA.GetAnchorId(), + "Don't call GetTop with a FlyInCntFrm" ); + if (FLY_AT_PAGE == rNewA.GetAnchorId()) return sal_True; // Seitengebundenen wird immer ausgewichen. // Wenn absatzgebundene Flys in einem FlyCnt gefangen sind, so @@ -2015,8 +2005,8 @@ sal_Bool SwTxtFly::ForEach( const SwRect &rRect, SwRect* pRect, sal_Bool bAvoid // --> OD 2006-08-15 #i68520# GetMaster() == pAnchoredObj->GetAnchorFrm() || // <-- - ( FLY_AT_CNTNT != rAnchor.GetAnchorId() && - FLY_AUTO_CNTNT != rAnchor.GetAnchorId() ) ) ) + ((FLY_AT_PARA != rAnchor.GetAnchorId()) && + (FLY_AT_CHAR != rAnchor.GetAnchorId())) ) ) || aRect.Top() == WEIT_WECH ) continue; } @@ -2442,9 +2432,11 @@ SwSurround SwTxtFly::_GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredO if( rFlyFmt.IsAnchorOnly() && pAnchoredObj->GetAnchorFrm() != GetMaster() ) { const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) + { return SURROUND_NONE; + } } // Beim Durchlauf und Nowrap wird smart ignoriert. diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 0efd87ef72..d7a82edd16 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -65,9 +65,7 @@ #include <txtftn.hxx> #include <charatr.hxx> #include <ftninfo.hxx> -#ifndef _FMTLINE_HXX #include <fmtline.hxx> -#endif #include <txtfrm.hxx> // SwTxtFrm #include <sectfrm.hxx> // SwSectFrm #include <txtcfg.hxx> // DBG_LOOP @@ -76,9 +74,7 @@ #include <txtcache.hxx> #include <fntcache.hxx> // GetLineSpace benutzt pLastFont #include <SwGrammarMarkUp.hxx> -#ifndef _LINEINFO_HXX #include <lineinfo.hxx> -#endif #include <SwPortionHandler.hxx> // OD 2004-01-15 #110582# #include <dcontact.hxx> @@ -101,6 +97,7 @@ extern const sal_Char *GetPrepName( const enum PrepareHint ePrep ); #endif + TYPEINIT1( SwTxtFrm, SwCntntFrm ); // Switches width and height of the text frame @@ -487,7 +484,7 @@ bool lcl_HideObj( const SwTxtFrm& _rFrm, { bool bRet( true ); - if ( _eAnchorType == FLY_AUTO_CNTNT ) + if (_eAnchorType == FLY_AT_CHAR) { const IDocumentSettingAccess* pIDSA = _rFrm.GetTxtNode()->getIDocumentSettingAccess(); if ( !pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) && @@ -560,8 +557,9 @@ void SwTxtFrm::HideAndShowObjects() // under certain conditions const RndStdIds eAnchorType( pContact->GetAnchorId() ); const xub_StrLen nObjAnchorPos = pContact->GetCntntAnchorIndex().GetIndex(); - if ( eAnchorType != FLY_AUTO_CNTNT || - lcl_HideObj( *this, eAnchorType, nObjAnchorPos, (*GetDrawObjs())[i] ) ) + if ((eAnchorType != FLY_AT_CHAR) || + lcl_HideObj( *this, eAnchorType, nObjAnchorPos, + (*GetDrawObjs())[i] )) { pContact->MoveObjToInvisibleLayer( pObj ); } @@ -588,12 +586,12 @@ void SwTxtFrm::HideAndShowObjects() const RndStdIds eAnchorType( pContact->GetAnchorId() ); // <-- - if ( eAnchorType == FLY_AT_CNTNT ) + if (eAnchorType == FLY_AT_PARA) { pContact->MoveObjToVisibleLayer( pObj ); } - else if ( eAnchorType == FLY_AUTO_CNTNT || - eAnchorType == FLY_IN_CNTNT ) + else if ((eAnchorType == FLY_AT_CHAR) || + (eAnchorType == FLY_AS_CHAR)) { xub_StrLen nHiddenStart; xub_StrLen nHiddenEnd; @@ -1693,7 +1691,7 @@ void SwTxtFrm::Prepare( const PrepareHint ePrep, const void* pVoid, // --> OD 2004-07-16 #i28701# - consider all // to-character anchored objects if ( pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId() - == FLY_AUTO_CNTNT ) + == FLY_AT_CHAR ) { bFormat = sal_True; break; diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index 5a1795a237..268d6a3aaa 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -50,6 +50,7 @@ #include <paratr.hxx> #include <svx/tstpitem.hxx> #include <SwStyleNameMapper.hxx> +#include <hints.hxx> // SwPtrMsgPoolItem // -> #i21237# #include <algorithm> @@ -176,10 +177,11 @@ SwFormTokens lcl_GetAuthPattern(USHORT nTypeId) --------------------------------------------------------------------*/ - // Konstruktor fuers Default vom Attribut-Pool +/// pool default constructor SwTOXMark::SwTOXMark() - : SfxPoolItem( RES_TXTATR_TOXMARK ), - SwClient( 0 ), + : SfxPoolItem( RES_TXTATR_TOXMARK ) + , SwModify( 0 ) + , pTxtAttr( 0 ), bAutoGenerated(FALSE), bMainEntry(FALSE) @@ -188,8 +190,9 @@ SwTOXMark::SwTOXMark() SwTOXMark::SwTOXMark( const SwTOXType* pTyp ) - : SfxPoolItem( RES_TXTATR_TOXMARK ), - SwClient( (SwModify*)pTyp ), + : SfxPoolItem( RES_TXTATR_TOXMARK ) + , SwModify( const_cast<SwTOXType*>(pTyp) ) + , pTxtAttr( 0 ), nLevel( 0 ), bAutoGenerated(FALSE), bMainEntry(FALSE) @@ -198,8 +201,9 @@ SwTOXMark::SwTOXMark( const SwTOXType* pTyp ) SwTOXMark::SwTOXMark( const SwTOXMark& rCopy ) - : SfxPoolItem( RES_TXTATR_TOXMARK ), - SwClient((SwModify*)rCopy.GetRegisteredIn()), + : SfxPoolItem( RES_TXTATR_TOXMARK ) + , SwModify(rCopy.pRegisteredIn) + , aPrimaryKey( rCopy.aPrimaryKey ), aSecondaryKey( rCopy.aSecondaryKey ), aTextReading( rCopy.aTextReading ), aPrimaryKeyReading( rCopy.aPrimaryKeyReading ), @@ -230,6 +234,22 @@ SfxPoolItem* SwTOXMark::Clone( SfxItemPool* ) const return new SwTOXMark( *this ); } +void SwTOXMark::Modify(SfxPoolItem* pOld, SfxPoolItem* pNew) +{ + SwModify::Modify(pOld, pNew); + if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) + { // invalidate cached uno object + SetXTOXMark(::com::sun::star::uno::Reference< + ::com::sun::star::text::XDocumentIndexMark>(0)); + } +} + +void SwTOXMark::InvalidateTOXMark() +{ + SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, + &static_cast<SwModify&>(*this) ); // cast to base class! + Modify(&aMsgHint, &aMsgHint); +} String SwTOXMark::GetText() const { diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx index 92cbc614d6..e4c5d0f10a 100644 --- a/sw/source/core/txtnode/atrflyin.cxx +++ b/sw/source/core/txtnode/atrflyin.cxx @@ -124,8 +124,8 @@ void SwTxtFlyCnt::CopyFlyFmt( SwDoc* pDoc ) BOOL bUndo = pDoc->DoesUndo(); pDoc->DoUndo( FALSE ); SwFmtAnchor aAnchor( pFmt->GetAnchor() ); - if( FLY_PAGE != aAnchor.GetAnchorId() && - pDoc != pFmt->GetDoc() ) // Unterschiedliche Docs? + if ((FLY_AT_PAGE != aAnchor.GetAnchorId()) && + (pDoc != pFmt->GetDoc())) // different documents? { // JP 03.06.96: dann sorge dafuer, das der koperierte Anker auf // gueltigen Content zeigt! Die Umsetzung auf die @@ -137,8 +137,10 @@ void SwTxtFlyCnt::CopyFlyFmt( SwDoc* pDoc ) SwPosition* pPos = (SwPosition*)aAnchor.GetCntntAnchor(); pPos->nNode = aIdx; - if( FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == aAnchor.GetAnchorId()) + { pPos->nContent.Assign( pCNd, 0 ); + } else { pPos->nContent.Assign( 0, 0 ); @@ -181,7 +183,7 @@ void SwTxtFlyCnt::SetAnchor( const SwTxtNode *pNode ) else aPos.nNode = aAnchor.GetCntntAnchor()->nNode; - aAnchor.SetType( FLY_IN_CNTNT ); // defaulten !! + aAnchor.SetType( FLY_AS_CHAR ); // default! aAnchor.SetAnchor( &aPos ); // beim Ankerwechsel werden immer alle FlyFrms vom Attribut geloescht diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 99e0810da5..54e73302aa 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -57,7 +57,6 @@ #include <ndtxt.hxx> // for meta #include <doc.hxx> // for meta #include <unometa.hxx> -#include <unoobj.hxx> // SwXTextRange #include <docsh.hxx> #include <svl/zforlist.hxx> // GetNumberFormat @@ -650,19 +649,28 @@ void SwFmtMeta::SetTxtAttr(SwTxtMeta * const i_pTxtAttr) } } -void SwFmtMeta::NotifyRemoval() +void SwFmtMeta::NotifyChangeTxtNode(SwTxtNode *const pTxtNode) { // N.B.: do not reset m_pTxtAttr here: see call in nodes.cxx, // where the hint is not deleted! ASSERT(m_pMeta, "NotifyRemoval: no meta ?"); if (m_pMeta) { - SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, - &static_cast<SwModify&>(*m_pMeta) ); // cast to proper base class! - m_pMeta->Modify(&aMsgHint, &aMsgHint); + if (!pTxtNode) + { + SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, + &static_cast<SwModify&>(*m_pMeta) ); // cast to base class! + m_pMeta->Modify(&aMsgHint, &aMsgHint); + } + else + { // do not call Modify, that would call SwXMeta::Modify! + m_pMeta->NotifyChangeTxtNode(); + } } } +// UGLY: this really awful method fixes up an inconsistent state, +// and if it is not called when copying, total chaos will undoubtedly ensue void SwFmtMeta::DoCopy(SwFmtMeta & rOriginalMeta) { ASSERT(m_pMeta, "DoCopy called for SwFmtMeta with no sw::Meta?"); @@ -673,6 +681,8 @@ void SwFmtMeta::DoCopy(SwFmtMeta & rOriginalMeta) // inserted via MakeTxtAttr! so fix it up to point at the original item // (maybe would be better to tell MakeTxtAttr that it creates a copy?) pOriginal->SetFmtMeta(&rOriginalMeta); + // force pOriginal to register in original text node! + pOriginal->NotifyChangeTxtNode(); if (RES_TXTATR_META == Which()) { m_pMeta.reset( new ::sw::Meta(this) ); @@ -685,7 +695,10 @@ void SwFmtMeta::DoCopy(SwFmtMeta & rOriginalMeta) m_pMeta = pTargetDoc->GetMetaFieldManager().makeMetaField( this, pMetaField->m_nNumberFormat, pMetaField->IsFixedLanguage() ); } + // this cannot be done in Clone: a Clone is not necessarily a copy! m_pMeta->RegisterAsCopyOf(*pOriginal); + // force copy Meta to register in target text node! + m_pMeta->NotifyChangeTxtNode(); } } @@ -718,15 +731,28 @@ SwTxtNode * Meta::GetTxtNode() const return (pTxtAttr) ? pTxtAttr->GetTxtNode() : 0; } -// SwClient -void Meta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) +void Meta::NotifyChangeTxtNode() { SwTxtNode * const pTxtNode( GetTxtNode() ); if (pTxtNode && (GetRegisteredIn() != pTxtNode)) { pTxtNode->Add(this); } + else if (!pTxtNode && GetRegisteredIn()) + { + const_cast<SwModify *>(GetRegisteredIn())->Remove(this); + } +} + +// SwClient +void Meta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) +{ + NotifyChangeTxtNode(); SwModify::Modify(pOld, pNew); + if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) + { // invalidate cached uno object + SetXMeta(uno::Reference<rdf::XMetadatable>(0)); + } } // sw::Metadatable @@ -765,31 +791,7 @@ bool Meta::IsInContent() const ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > Meta::MakeUnoObject() { - // re-use existing SwXMeta - SwClientIter iter( *this ); - SwClient * pClient( iter.First( TYPE( SwXMeta ) ) ); - while (pClient) { - SwXMeta *const pMeta( dynamic_cast<SwXMeta*>(pClient) ); - if (pMeta && pMeta->GetCoreObject() == this) { - return pMeta; - } - pClient = iter.Next(); - } - - // create new SwXMeta - SwTxtMeta * const pTxtAttr( GetTxtAttr() ); - OSL_ENSURE(pTxtAttr, "MakeUnoObject: no text attr?"); - if (!pTxtAttr) return 0; - SwTxtNode * const pTxtNode( pTxtAttr->GetTxtNode() ); - OSL_ENSURE(pTxtNode, "MakeUnoObject: no text node?"); - if (!pTxtNode) return 0; - const SwPosition aPos(*pTxtNode, *pTxtAttr->GetStart()); - const uno::Reference<text::XText> xParentText( - SwXTextRange::CreateParentXText(pTxtNode->GetDoc(), aPos) ); - if (!xParentText.is()) return 0; - return (RES_TXTATR_META == m_pFmt->Which()) - ? new SwXMeta (pTxtNode->GetDoc(), xParentText, 0, pTxtAttr) - : new SwXMetaField(pTxtNode->GetDoc(), xParentText, 0, pTxtAttr); + return SwXMeta::CreateXMeta(*this); } /************************************************************************* diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 218cdfb9a8..ee663716f0 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -3623,6 +3623,12 @@ void SwTxtNode::Modify( SfxPoolItem* pOldValue, SfxPoolItem* pNewValue ) } m_bNotifiable = bWasNotifiable; + + if (pOldValue && (RES_REMOVE_UNO_OBJECT == pOldValue->Which())) + { // invalidate cached uno object + SetXParagraph(::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent>(0)); + } } SwFmtColl* SwTxtNode::ChgFmtColl( SwFmtColl *pNewColl ) @@ -4972,27 +4978,15 @@ bool SwTxtNode::IsInContent() const return !GetDoc()->IsInHeaderFooter( SwNodeIndex(*this) ); } -#include <unoobj.hxx> +#include <unoparagraph.hxx> + +using namespace ::com::sun::star; -::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > +uno::Reference< rdf::XMetadatable > SwTxtNode::MakeUnoObject() { - // re-use existing SwXParagraph - SwClientIter iter( *this ); - SwClient * pClient( iter.First( TYPE( SwXParagraph ) ) ); - while (pClient) { - SwXParagraph *pPara( dynamic_cast<SwXParagraph*>(pClient) ); - if (pPara && pPara->GetCoreObject() == this ) { - return pPara; - } - pClient = iter.Next(); - } - - // create new SwXParagraph - SwPosition Pos( *this ); - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent( - SwXTextRange::CreateParentXText( GetDoc(), Pos ) ); - SwXParagraph * pXPara( new SwXParagraph( xParent, this ) ); - return pXPara; + const uno::Reference<rdf::XMetadatable> xMeta( + SwXParagraph::CreateXParagraph(*GetDoc(), *this), uno::UNO_QUERY); + return xMeta; } diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 47d1cb01bd..5384f4f73b 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -114,6 +114,11 @@ struct TxtAttrDeleter TxtAttrDeleter( SwDoc & rDoc ) : m_rPool( rDoc.GetAttrPool() ) { } void operator() (SwTxtAttr * const pAttr) { + if (RES_TXTATR_META == pAttr->Which() || + RES_TXTATR_METAFIELD == pAttr->Which()) + { + static_cast<SwTxtMeta *>(pAttr)->ChgTxtNode(0); // prevents ASSERT + } SwTxtAttr::Destroy( pAttr, m_rPool ); } }; @@ -159,7 +164,8 @@ bool isNestedAny(const xub_StrLen nStart1, const xub_StrLen nEnd1, const xub_StrLen nStart2, const xub_StrLen nEnd2) { return ((nStart1 == nStart2) || (nEnd1 == nEnd2)) - ? (nStart1 != nEnd1) // same start/end: nested except if hint1 empty + // same start/end: nested except if hint1 empty and hint2 not empty + ? (nStart1 != nEnd1) || (nStart2 == nEnd2) : ((nStart1 < nStart2) ? (nEnd1 >= nEnd2) : (nEnd1 <= nEnd2)); } @@ -1168,7 +1174,7 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) break; case RES_TXTATR_TOXMARK: - nDelMsg = RES_TOXMARK_DELETED; + static_cast<SwTOXMark&>(pAttr->GetAttr()).InvalidateTOXMark(); break; case RES_TXTATR_REFMARK: @@ -1177,7 +1183,7 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) case RES_TXTATR_META: case RES_TXTATR_METAFIELD: - static_cast<SwFmtMeta&>(pAttr->GetAttr()).NotifyRemoval(); + static_cast<SwTxtMeta*>(pAttr)->ChgTxtNode(0); break; default: @@ -1269,11 +1275,15 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) InsertText( c, aIdx, nInsertFlags ); nInsMode |= nsSetAttrMode::SETATTR_NOTXTATRCHR; - if( pAnchor && FLY_IN_CNTNT == pAnchor->GetAnchorId() && + if (pAnchor && + (FLY_AS_CHAR == pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor() && pAnchor->GetCntntAnchor()->nNode == *this && pAnchor->GetCntntAnchor()->nContent == aIdx ) - ((SwIndex&)pAnchor->GetCntntAnchor()->nContent)--; + { + const_cast<SwIndex&>( + pAnchor->GetCntntAnchor()->nContent)--; + } } pFly->SetAnchor( this ); diff --git a/sw/source/core/txtnode/txtatr2.cxx b/sw/source/core/txtnode/txtatr2.cxx index 23900ed60b..104d6d457f 100644 --- a/sw/source/core/txtnode/txtatr2.cxx +++ b/sw/source/core/txtnode/txtatr2.cxx @@ -329,3 +329,13 @@ SwTxtMeta::~SwTxtMeta() } } +void SwTxtMeta::ChgTxtNode(SwTxtNode * const pNode) +{ + m_pTxtNode = pNode; // before Notify! + SwFmtMeta & rFmtMeta( static_cast<SwFmtMeta &>(GetAttr()) ); + if (rFmtMeta.GetTxtAttr() == this) + { + rFmtMeta.NotifyChangeTxtNode(pNode); + } +} + diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 1d8d7b3cf7..4540a7dcd0 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -922,7 +922,7 @@ SwHistoryChangeFlyAnchor::SwHistoryChangeFlyAnchor( SwFrmFmt& rFmt ) : SwHistoryHint( HSTRY_CHGFLYANCHOR ) , m_rFmt( rFmt ) , m_nOldNodeIndex( rFmt.GetAnchor().GetCntntAnchor()->nNode.GetIndex() ) - , m_nOldContentIndex( ( FLY_AUTO_CNTNT == rFmt.GetAnchor().GetAnchorId() ) + , m_nOldContentIndex( (FLY_AT_CHAR == rFmt.GetAnchor().GetAnchorId()) ? rFmt.GetAnchor().GetCntntAnchor()->nContent.GetIndex() : STRING_MAXLEN ) { diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index 422a02f0b2..de590d974d 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -462,10 +462,10 @@ void SwUndoFmtAttr::SaveFlyAnchor( bool bSvDrwPt ) xub_StrLen nCntnt = 0; switch( rAnchor.GetAnchorId() ) { - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: nCntnt = rAnchor.GetCntntAnchor()->nContent.GetIndex(); - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: m_nNodeIndex = rAnchor.GetCntntAnchor()->nNode.GetIndex(); break; @@ -489,7 +489,7 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) static_cast<const SwFmtAnchor&>( m_pOldSet->Get( RES_ANCHOR, FALSE ) ); SwFmtAnchor aNewAnchor( rAnchor.GetAnchorId() ); - if( FLY_PAGE != rAnchor.GetAnchorId() ) + if (FLY_AT_PAGE != rAnchor.GetAnchorId()) { SwNode* pNd = pDoc->GetNodes()[ m_nNodeIndex ]; @@ -505,8 +505,8 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) } SwPosition aPos( *pNd ); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AS_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) { aPos.nContent.Assign( (SwTxtNode*)pNd, rAnchor.GetPageNum() ); if ( aPos.nContent.GetIndex() > @@ -549,7 +549,7 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) const SwFmtAnchor &rOldAnch = pFrmFmt->GetAnchor(); // --> OD 2006-03-13 #i54336# // Consider case, that as-character anchored object has moved its anchor position. - if ( FLY_IN_CNTNT == rOldAnch.GetAnchorId() ) + if (FLY_AS_CHAR == rOldAnch.GetAnchorId()) // <-- { //Bei InCntnt's wird es spannend: Das TxtAttribut muss vernichtet @@ -613,7 +613,7 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) SwFmtFrmSize( ATT_VAR_SIZE, aDrawOldPt.X(), aDrawOldPt.Y() ) ); } - if( FLY_IN_CNTNT == aNewAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == aNewAnchor.GetAnchorId()) { const SwPosition* pPos = aNewAnchor.GetCntntAnchor(); SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 1ebc3a084f..df8eaf2a0a 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -81,7 +81,7 @@ void lcl_MakeAutoFrms( const SwSpzFrmFmts& rSpzArr, ULONG nMovedIndex ) { pFmt = (SwFlyFrmFmt*)rSpzArr[n]; pAnchor = &pFmt->GetAnchor(); - if( pAnchor->GetAnchorId() == FLY_AUTO_CNTNT ) + if (pAnchor->GetAnchorId() == FLY_AT_CHAR) { const SwPosition* pAPos = pAnchor->GetCntntAnchor(); if( pAPos && nMovedIndex == pAPos->nNode.GetIndex() ) @@ -632,7 +632,7 @@ void lcl_ReAnchorAtCntntFlyFrames( const SwSpzFrmFmts& rSpzArr, SwPosition &rPos { pFmt = (SwFlyFrmFmt*)rSpzArr[n]; pAnchor = &pFmt->GetAnchor(); - if( pAnchor->GetAnchorId() == FLY_AT_CNTNT ) + if (pAnchor->GetAnchorId() == FLY_AT_PARA) { pAPos = pAnchor->GetCntntAnchor(); if( pAPos && nOldIdx == pAPos->nNode.GetIndex() ) diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index ba175e42a8..83c4713e84 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -593,7 +593,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, pAnchor = &pFmt->GetAnchor(); switch( pAnchor->GetAnchorId() ) { - case FLY_IN_CNTNT: + case FLY_AS_CHAR: if( 0 != (pAPos = pAnchor->GetCntntAnchor() ) && (( nsDelCntntType::DELCNT_CHKNOCNTNT & nDelCntntType ) ? ( pStt->nNode <= pAPos->nNode && @@ -611,7 +611,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, n = n >= rSpzArr.Count() ? rSpzArr.Count() : n+1; } break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: { pAPos = pAnchor->GetCntntAnchor(); if( pAPos ) @@ -660,7 +660,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, } } break; - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: if( 0 != (pAPos = pAnchor->GetCntntAnchor() ) && ( pStt->nNode <= pAPos->nNode && pAPos->nNode <= pEnd->nNode ) ) { diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index 58383f9415..dc2fc49eae 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -93,15 +93,19 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) SwFmtAnchor aAnchor( (RndStdIds)nRndId ); - if( FLY_PAGE == nRndId ) + if (FLY_AT_PAGE == nRndId) + { aAnchor.SetPageNum( (USHORT)nNdPgPos ); + } else { SwPosition aNewPos( *rUndoIter.pAktPam->GetPoint() ); aNewPos.nNode = nNdPgPos; - if( FLY_IN_CNTNT == nRndId || FLY_AUTO_CNTNT == nRndId ) + if ((FLY_AS_CHAR == nRndId) || (FLY_AT_CHAR == nRndId)) + { aNewPos.nContent.Assign( aNewPos.nNode.GetNode().GetCntntNode(), nCntPos ); + } aAnchor.SetAnchor( &aNewPos ); } @@ -119,7 +123,7 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) // vorhanden ist! Sonst wuerde das Layout den Fly vorher // formatieren, aber keine Inhalt finden; so geschene bei // Grafiken aus dem Internet - if( FLY_IN_CNTNT == nRndId ) + if (FLY_AS_CHAR == nRndId) { // es muss mindestens das Attribut im TextNode stehen SwCntntNode* pCNd = aAnchor.GetCntntAnchor()->nNode.GetNode().GetCntntNode(); @@ -138,22 +142,22 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) switch( nRndId ) { - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: { const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); nCntPos = rAnchor.GetCntntAnchor()->nContent.GetIndex(); } break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: { const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); } break; - case FLY_PAGE: + case FLY_AT_PAGE: break; } bDelFmt = FALSE; @@ -193,7 +197,8 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc ) const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); const SwPosition* pPos = rAnchor.GetCntntAnchor(); // die Positionen im Nodes-Array haben sich verschoben - if( FLY_IN_CNTNT == ( nRndId = static_cast<USHORT>(rAnchor.GetAnchorId()) ) ) + nRndId = static_cast<USHORT>(rAnchor.GetAnchorId()); + if (FLY_AS_CHAR == nRndId) { nNdPgPos = pPos->nNode.GetIndex(); nCntPos = pPos->nContent.GetIndex(); @@ -210,15 +215,19 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc ) pTxtNd->EraseText( aIdx, 1 ); } } - else if( FLY_AUTO_CNTNT == nRndId ) + else if (FLY_AT_CHAR == nRndId) { nNdPgPos = pPos->nNode.GetIndex(); nCntPos = pPos->nContent.GetIndex(); } - else if( FLY_AT_CNTNT == nRndId || FLY_AT_FLY == nRndId ) + else if ((FLY_AT_PARA == nRndId) || (FLY_AT_FLY == nRndId)) + { nNdPgPos = pPos->nNode.GetIndex(); + } else + { nNdPgPos = rAnchor.GetPageNum(); + } pFrmFmt->ResetFmtAttr( RES_ANCHOR ); // Anchor loeschen @@ -240,15 +249,15 @@ SwUndoInsLayFmt::SwUndoInsLayFmt( SwFrmFmt* pFormat, ULONG nNodeIdx, xub_StrLen bDelFmt = FALSE; switch( nRndId ) { - case FLY_PAGE: + case FLY_AT_PAGE: nNdPgPos = rAnchor.GetPageNum(); break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); break; - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: { const SwPosition* pPos = rAnchor.GetCntntAnchor(); nCntPos = pPos->nContent.GetIndex(); @@ -305,13 +314,15 @@ void SwUndoInsLayFmt::Repeat( SwUndoIter& rUndoIter ) SwDoc* pDoc = &rUndoIter.GetDoc(); // erfrage und setze den Anker neu SwFmtAnchor aAnchor( pFrmFmt->GetAnchor() ); - if( FLY_AT_CNTNT == aAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == aAnchor.GetAnchorId() || - FLY_IN_CNTNT == aAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || + (FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (FLY_AS_CHAR == aAnchor.GetAnchorId())) { SwPosition aPos( *rUndoIter.pAktPam->GetPoint() ); - if( FLY_AT_CNTNT == aAnchor.GetAnchorId() ) + if (FLY_AT_PARA == aAnchor.GetAnchorId()) + { aPos.nContent.Assign( 0, 0 ); + } aAnchor.SetAnchor( &aPos ); } else if( FLY_AT_FLY == aAnchor.GetAnchorId() ) @@ -328,7 +339,7 @@ void SwUndoInsLayFmt::Repeat( SwUndoIter& rUndoIter ) return ; } } - else if( FLY_PAGE == aAnchor.GetAnchorId() ) + else if (FLY_AT_PAGE == aAnchor.GetAnchorId()) { aAnchor.SetPageNum( pDoc->GetRootFrm()->GetCurrPage( rUndoIter.pAktPam )); @@ -482,7 +493,7 @@ void SwUndoSetFlyFmt::GetAnchor( SwFmtAnchor& rAnchor, ULONG nNode, xub_StrLen nCntnt ) { RndStdIds nAnchorTyp = rAnchor.GetAnchorId(); - if( FLY_PAGE != nAnchorTyp ) + if (FLY_AT_PAGE != nAnchorTyp) { SwNode* pNd = pFrmFmt->GetDoc()->GetNodes()[ nNode ]; @@ -490,26 +501,34 @@ void SwUndoSetFlyFmt::GetAnchor( SwFmtAnchor& rAnchor, ? ( !pNd->IsStartNode() || SwFlyStartNode != ((SwStartNode*)pNd)->GetStartNodeType() ) : !pNd->IsTxtNode() ) - pNd = 0; // ungueltige Position + { + pNd = 0; // invalid position + } else { SwPosition aPos( *pNd ); - if( FLY_IN_CNTNT == nAnchorTyp || - FLY_AUTO_CNTNT == nAnchorTyp ) + if ((FLY_AS_CHAR == nAnchorTyp) || + (FLY_AT_CHAR == nAnchorTyp)) { - if( nCntnt > ((SwTxtNode*)pNd)->GetTxt().Len() ) - pNd = 0; // ungueltige Position + if ( nCntnt > static_cast<SwTxtNode*>(pNd)->GetTxt().Len() ) + { + pNd = 0; // invalid position + } else - aPos.nContent.Assign( (SwTxtNode*)pNd, nCntnt ); + { + aPos.nContent.Assign(static_cast<SwTxtNode*>(pNd), nCntnt); + } } - if( pNd ) + if ( pNd ) + { rAnchor.SetAnchor( &aPos ); + } } if( !pNd ) { // ungueltige Position - setze auf 1. Seite - rAnchor.SetType( FLY_PAGE ); + rAnchor.SetType( FLY_AT_PAGE ); rAnchor.SetPageNum( 1 ); } } @@ -548,7 +567,7 @@ void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter ) if( bAnchorChgd ) { const SwFmtAnchor& rOldAnch = pFrmFmt->GetAnchor(); - if( FLY_IN_CNTNT == rOldAnch.GetAnchorId() ) + if (FLY_AS_CHAR == rOldAnch.GetAnchorId()) { // Bei InCntnt's wird es spannend: Das TxtAttribut muss // vernichtet werden. Leider reisst dies neben den Frms @@ -577,7 +596,7 @@ void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter ) GetAnchor( aNewAnchor, nOldNode, nOldCntnt ); pFrmFmt->SetFmtAttr( aNewAnchor ); - if( FLY_IN_CNTNT == aNewAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == aNewAnchor.GetAnchorId()) { SwPosition* pPos = (SwPosition*)aNewAnchor.GetCntntAnchor(); SwFmtFlyCnt aFmt( pFrmFmt ); @@ -629,10 +648,10 @@ void SwUndoSetFlyFmt::PutAttr( USHORT nWhich, const SfxPoolItem* pItem ) const SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem; switch( nOldAnchorTyp = static_cast<USHORT>(pAnchor->GetAnchorId()) ) { - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: nOldCntnt = pAnchor->GetCntntAnchor()->nContent.GetIndex(); - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: nOldNode = pAnchor->GetCntntAnchor()->nNode.GetIndex(); break; @@ -644,10 +663,10 @@ void SwUndoSetFlyFmt::PutAttr( USHORT nWhich, const SfxPoolItem* pItem ) pAnchor = (SwFmtAnchor*)&pFrmFmt->GetAnchor(); switch( nNewAnchorTyp = static_cast<USHORT>(pAnchor->GetAnchorId()) ) { - case FLY_IN_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AS_CHAR: + case FLY_AT_CHAR: nNewCntnt = pAnchor->GetCntntAnchor()->nContent.GetIndex(); - case FLY_AT_CNTNT: + case FLY_AT_PARA: case FLY_AT_FLY: nNewNode = pAnchor->GetCntntAnchor()->nNode.GetIndex(); break; diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index 2b89cb1e7c..475c6dc6df 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -32,15 +32,9 @@ #include "precompiled_sw.hxx" #include <rtl/string.h> - -#ifndef _RTL_MEMORY_H #include <rtl/memory.h> -#endif #include <hintids.hxx> -#ifndef _RTL_STRING_H -#include <rtl/string.h> -#endif #include <svx/svdogrp.hxx> #include <svx/svdundo.hxx> #include <svx/svdpage.hxx> @@ -61,6 +55,7 @@ #include <rootfrm.hxx> #include <viewsh.hxx> + struct SwUndoGroupObjImpl { SwDrawFrmFmt* pFmt; @@ -142,15 +137,15 @@ void lcl_SendRemoveToUno( SwFmt& rFmt ) void lcl_SaveAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) { const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_AT_FLY == rAnchor.GetAnchorId() || - FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_FLY == rAnchor.GetAnchorId()) || + (FLY_AS_CHAR == rAnchor.GetAnchorId())) { rNodePos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); xub_StrLen nCntntPos = 0; - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == rAnchor.GetAnchorId()) { nCntntPos = rAnchor.GetCntntAnchor()->nContent.GetIndex(); @@ -168,8 +163,10 @@ void lcl_SaveAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) pTxtNd->EraseText( aIdx, 1 ); } } - else if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + else if (FLY_AT_CHAR == rAnchor.GetAnchorId()) + { nCntntPos = rAnchor.GetCntntAnchor()->nContent.GetIndex(); + } pFmt->SetFmtAttr( SwFmtAnchor( rAnchor.GetAnchorId(), nCntntPos ) ); } @@ -178,10 +175,10 @@ void lcl_SaveAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) void lcl_RestoreAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) { const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() || - FLY_AT_FLY == rAnchor.GetAnchorId() || - FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_FLY == rAnchor.GetAnchorId()) || + (FLY_AS_CHAR == rAnchor.GetAnchorId())) { xub_StrLen nCntntPos = rAnchor.GetPageNum(); SwNodes& rNds = pFmt->GetDoc()->GetNodes(); @@ -190,13 +187,15 @@ void lcl_RestoreAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) SwPosition aPos( aIdx ); SwFmtAnchor aTmp( rAnchor.GetAnchorId() ); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AS_CHAR == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) + { aPos.nContent.Assign( aIdx.GetNode().GetCntntNode(), nCntntPos ); + } aTmp.SetAnchor( &aPos ); pFmt->SetFmtAttr( aTmp ); - if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) + if (FLY_AS_CHAR == rAnchor.GetAnchorId()) { SwTxtNode *pTxtNd = aIdx.GetNode().GetTxtNode(); ASSERT( pTxtNd, "no Text Node" ); diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 2782a408ac..b6249bd0c6 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -448,12 +448,12 @@ SwUndoTblToTxt::SwUndoTblToTxt( const SwTable& rTbl, sal_Unicode cCh ) const SwSpzFrmFmts& rFrmFmtTbl = *pTblNd->GetDoc()->GetSpzFrmFmts(); for( USHORT n = 0; n < rFrmFmtTbl.Count(); ++n ) { - const SwPosition* pAPos; SwFrmFmt* pFmt = rFrmFmtTbl[ n ]; - const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - ( FLY_AUTO_CNTNT == pAnchor->GetAnchorId() || - FLY_AT_CNTNT == pAnchor->GetAnchorId() ) && + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_CHAR == pAnchor->GetAnchorId()) || + (FLY_AT_PARA == pAnchor->GetAnchorId())) && nTblStt <= pAPos->nNode.GetIndex() && pAPos->nNode.GetIndex() < nTblEnd ) { diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index e6aad03906..fdbc7b74cf 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -69,10 +69,10 @@ SwUndoInserts::SwUndoInserts( SwUndoId nUndoId, const SwPaM& rPam ) for( USHORT n = 0; n < nArrLen; ++n ) { SwFrmFmt* pFmt = (*pDoc->GetSpzFrmFmts())[n]; - const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - const SwPosition* pAPos; - if ( pAnchor->GetAnchorId() == FLY_AT_CNTNT && - 0 != ( pAPos = pAnchor->GetCntntAnchor()) && + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + const SwPosition* pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + (pAnchor->GetAnchorId() == FLY_AT_PARA) && nSttNode == pAPos->nNode.GetIndex() ) { if( !pFrmFmts ) @@ -124,10 +124,10 @@ void SwUndoInserts::SetInsertRange( const SwPaM& rPam, BOOL bScanFlys, for( USHORT n = 0; n < nArrLen; ++n ) { SwFrmFmt* pFmt = (*pDoc->GetSpzFrmFmts())[n]; - const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); - const SwPosition* pAPos; - if( pAnchor->GetAnchorId() == FLY_AT_CNTNT && - 0 != ( pAPos = pAnchor->GetCntntAnchor()) && + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + (pAnchor->GetAnchorId() == FLY_AT_PARA) && nSttNode == pAPos->nNode.GetIndex() ) { if( !pFrmFmts || diff --git a/sw/source/core/unocore/SwXTextDefaults.cxx b/sw/source/core/unocore/SwXTextDefaults.cxx index 2218129443..7d1c1cb43d 100644 --- a/sw/source/core/unocore/SwXTextDefaults.cxx +++ b/sw/source/core/unocore/SwXTextDefaults.cxx @@ -30,9 +30,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + +#include <com/sun/star/beans/PropertyAttribute.hpp> + #include <vos/mutex.hxx> #include <vcl/svapp.hxx> -#include <com/sun/star/beans/PropertyAttribute.hpp> + #include <SwXTextDefaults.hxx> #include <SwStyleNameMapper.hxx> #include <fchrfmt.hxx> @@ -44,6 +47,7 @@ #include <unomid.h> #include <paratr.hxx> #include <unoprnms.hxx> +#include <unocrsrhelper.hxx> #include <hintids.hxx> #include <unomid.h> @@ -56,9 +60,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; -// declarations -void lcl_setPageDesc(SwDoc*, const uno::Any&, SfxItemSet& ); // from unoobj.cxx - SwXTextDefaults::SwXTextDefaults ( SwDoc * pNewDoc ) : m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_DEFAULT ) ), @@ -97,7 +98,7 @@ void SAL_CALL SwXTextDefaults::setPropertyValue( const OUString& rPropertyName, { SfxItemSet aSet( m_pDoc->GetAttrPool(), RES_PAGEDESC, RES_PAGEDESC ); aSet.Put(rItem); - lcl_setPageDesc( m_pDoc, aValue, aSet ); + SwUnoCursorHelper::SetPageDesc( aValue, *m_pDoc, aSet ); m_pDoc->SetDefault(aSet.Get(RES_PAGEDESC)); } else if ((RES_PARATR_DROP == pMap->nWID && MID_DROPCAP_CHAR_STYLE_NAME == pMap->nMemberId) || diff --git a/sw/source/core/unocore/TextCursorHelper.cxx b/sw/source/core/unocore/TextCursorHelper.cxx index b21587a155..6e8fb9efe4 100644 --- a/sw/source/core/unocore/TextCursorHelper.cxx +++ b/sw/source/core/unocore/TextCursorHelper.cxx @@ -30,8 +30,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include "TextCursorHelper.hxx" -#include "unoobj.hxx" +#include "unobaseclass.hxx" + using namespace ::com::sun::star; /* -----------------------------03.03.03 11:07-------------------------------- diff --git a/sw/source/core/unocore/makefile.mk b/sw/source/core/unocore/makefile.mk index b364956a3d..31c6f4f726 100644 --- a/sw/source/core/unocore/makefile.mk +++ b/sw/source/core/unocore/makefile.mk @@ -115,7 +115,6 @@ SLOFILES = \ $(SLO)$/unotextmarkup.obj\ $(SLO)$/TextCursorHelper.obj \ $(SLO)$/unotext.obj\ - $(SLO)$/unoclbck.obj\ $(SLO)$/unomap.obj\ $(SLO)$/unoprnms.obj\ $(SLO)$/XMLRangeHelper.obj diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 11ea44de5f..b0cb38b78f 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -31,12 +31,15 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - +#include <unobookmark.hxx> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> -#include <unoobj.hxx> + +#include <TextCursorHelper.hxx> +#include <unotextrange.hxx> #include <unomap.hxx> #include <unoprnms.hxx> +#include <unoevtlstnr.hxx> #include <IMark.hxx> #include <crossrefbookmark.hxx> #include <doc.hxx> @@ -50,13 +53,8 @@ using namespace ::com::sun::star; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::text; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; using ::rtl::OUString; -using ::rtl::OUStringBuffer; + namespace { @@ -64,7 +62,7 @@ namespace { static const OUString sStart = OUString(String(SW_RES(STR_START_QUOTE))); static const OUString sEnd = OUString(String(SW_RES(STR_END_QUOTE))); - OUStringBuffer sBuf(64); + ::rtl::OUStringBuffer sBuf(64); return sBuf.append(sStart).append(rName).append(sEnd).makeStringAndClear(); } } @@ -72,170 +70,307 @@ namespace /****************************************************************** * SwXBookmark ******************************************************************/ -TYPEINIT1(SwXBookmark, SwClient) -const uno::Sequence< sal_Int8 > & SwXBookmark::getUnoTunnelId() +class SwXBookmark::Impl + : public SwClient { - static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; + +public: + SwEventListenerContainer m_ListenerContainer; + SwDoc * m_pDoc; + ::sw::mark::IMark * m_pRegisteredBookmark; + ::rtl::OUString m_sMarkName; + + + Impl( SwXBookmark & rThis, + SwDoc *const pDoc, ::sw::mark::IMark *const /*pBookmark*/) + : SwClient() + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_pDoc(pDoc) + , m_pRegisteredBookmark(0) + { + // DO NOT regiserInMark here! (because SetXBookmark would delete rThis) + } + + void registerInMark(SwXBookmark & rThis, ::sw::mark::IMark *const pBkmk); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +void SwXBookmark::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + if (!GetRegisteredIn()) + { + m_pRegisteredBookmark = NULL; + m_pDoc = NULL; + m_ListenerContainer.Disposing(); + } } -sal_Int64 SAL_CALL SwXBookmark::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +void SwXBookmark::Impl::registerInMark(SwXBookmark & rThis, + ::sw::mark::IMark *const pBkmk) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) + if (pBkmk) { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); + pBkmk->Add(this); + ::sw::mark::MarkBase *const pMarkBase( + dynamic_cast< ::sw::mark::MarkBase * >(pBkmk)); + OSL_ENSURE(pMarkBase, "registerInMark: no MarkBase?"); + if (pMarkBase) + { + const uno::Reference<text::XTextContent> xBookmark(& rThis); + pMarkBase->SetXBookmark(xBookmark); + } } - return 0; + else if (m_pRegisteredBookmark) + { + m_sMarkName = m_pRegisteredBookmark->GetName(); + m_pRegisteredBookmark->Remove(this); + } + m_pRegisteredBookmark = pBkmk; +} + + +const ::sw::mark::IMark* SwXBookmark::GetBookmark() const +{ + return m_pImpl->m_pRegisteredBookmark; } -SwXBookmark::SwXBookmark(::sw::mark::IMark* pBkmk, SwDoc* pDoc) - : m_aLstnrCntnr((text::XTextContent*)this) - , m_pDoc(pDoc) - , m_pRegisteredBookmark(NULL) +SwXBookmark::SwXBookmark(::sw::mark::IMark *const pBkmk, SwDoc *const pDoc) + : m_pImpl( new SwXBookmark::Impl(*this, pDoc, pBkmk) ) +{ +} + +SwXBookmark::SwXBookmark() + : m_pImpl( new SwXBookmark::Impl(*this, 0, 0) ) { - registerInMark(pBkmk); } SwXBookmark::~SwXBookmark() -{ } +{ +} + +uno::Reference<text::XTextContent> +SwXBookmark::CreateXBookmark(SwDoc & rDoc, ::sw::mark::IMark & rBookmark) +{ + // #i105557#: do not iterate over the registered clients: race condition + ::sw::mark::MarkBase *const pMarkBase( + dynamic_cast< ::sw::mark::MarkBase * >(&rBookmark)); + OSL_ENSURE(pMarkBase, "CreateXBookmark: no MarkBase?"); + if (!pMarkBase) { return 0; } + uno::Reference<text::XTextContent> xBookmark(pMarkBase->GetXBookmark()); + if (!xBookmark.is()) + { + // FIXME: These belong in XTextFieldsSupplier + //if (dynamic_cast< ::sw::mark::TextFieldmark* >(&rBkmk)) + // pXBkmk = new SwXFieldmark(false, &rBkmk, pDoc); + //else if (dynamic_cast< ::sw::mark::CheckboxFieldmark* >(&rBkmk)) + // pXBkmk = new SwXFieldmark(true, &rBkmk, pDoc); + //else + OSL_ENSURE( + dynamic_cast< ::sw::mark::IBookmark* >(&rBookmark), + "<SwXBookmark::GetObject(..)>" + "SwXBookmark requested for non-bookmark mark."); + SwXBookmark *const pXBookmark = new SwXBookmark(&rBookmark, &rDoc); + xBookmark.set(pXBookmark); + pXBookmark->m_pImpl->registerInMark(*pXBookmark, pMarkBase); + } + return xBookmark; +} + +::sw::mark::IMark const* SwXBookmark::GetBookmarkInDoc(SwDoc const*const pDoc, + const uno::Reference< lang::XUnoTunnel> & xUT) +{ + SwXBookmark *const pXBkm( + ::sw::UnoTunnelGetImplementation<SwXBookmark>(xUT)); + if (pXBkm && (pDoc == pXBkm->m_pImpl->m_pDoc)) + { + return pXBkm->m_pImpl->m_pRegisteredBookmark; + } + return 0; +} + +const uno::Sequence< sal_Int8 > & SwXBookmark::getUnoTunnelId() +{ + static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); + return aSeq; +} + +sal_Int64 SAL_CALL +SwXBookmark::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) +{ + return ::sw::UnoTunnelImpl<SwXBookmark>(rId, this); +} void SwXBookmark::attachToRangeEx( const uno::Reference< text::XTextRange > & xTextRange, IDocumentMarkAccess::MarkType eType) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - if(m_pRegisteredBookmark) + if (m_pImpl->m_pRegisteredBookmark) + { throw uno::RuntimeException(); + } - uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); + const uno::Reference<lang::XUnoTunnel> xRangeTunnel( + xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; OTextCursorHelper* pCursor = 0; if(xRangeTunnel.is()) { + pRange = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel); + } - 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() ))); + SwDoc *const pDoc = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pDoc) + { + throw lang::IllegalArgumentException(); } - SwDoc* pDc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? - (SwDoc*)pCursor->GetDoc() : 0; - if(pDc) + m_pImpl->m_pDoc = pDoc; + SwUnoInternalPaM aPam(*m_pImpl->m_pDoc); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); + UnoActionContext aCont(m_pImpl->m_pDoc); + if (!m_pImpl->m_sMarkName.getLength()) { - m_pDoc = pDc; - SwUnoInternalPaM aPam(*m_pDoc); - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); - UnoActionContext aCont(m_pDoc); - if(!m_aName.Len()) - m_aName = OUString::createFromAscii("Bookmark"); - if(eType == IDocumentMarkAccess::BOOKMARK && ::sw::mark::CrossRefNumItemBookmark::IsLegalName(m_aName)) - eType = IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK; - else if(eType == IDocumentMarkAccess::BOOKMARK && ::sw::mark::CrossRefHeadingBookmark::IsLegalName(m_aName)) - eType = IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK; - registerInMark(m_pDoc->getIDocumentMarkAccess()->makeMark(aPam, m_aName, eType)); - // --> OD 2007-10-23 #i81002# - // Check, if bookmark has been created. - // E.g., the creation of a cross-reference bookmark is suppress, - // if the PaM isn't a valid one for cross-reference bookmarks. - if(!m_pRegisteredBookmark) - { - OSL_ENSURE(false, - "<SwXBookmark::attachToRange(..)>" - " - could not create Mark."); - throw lang::IllegalArgumentException(); - } - // <-- + m_pImpl->m_sMarkName = OUString::createFromAscii("Bookmark"); } - else + if ((eType == IDocumentMarkAccess::BOOKMARK) && + ::sw::mark::CrossRefNumItemBookmark::IsLegalName(m_pImpl->m_sMarkName)) + { + eType = IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK; + } + else if ((eType == IDocumentMarkAccess::BOOKMARK) && + ::sw::mark::CrossRefHeadingBookmark::IsLegalName(m_pImpl->m_sMarkName)) + { + eType = IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK; + } + m_pImpl->registerInMark(*this, + m_pImpl->m_pDoc->getIDocumentMarkAccess()->makeMark( + aPam, m_pImpl->m_sMarkName, eType)); + // --> OD 2007-10-23 #i81002# + // Check, if bookmark has been created. + // E.g., the creation of a cross-reference bookmark is suppress, + // if the PaM isn't a valid one for cross-reference bookmarks. + if (!m_pImpl->m_pRegisteredBookmark) + { + OSL_ENSURE(false, + "<SwXBookmark::attachToRange(..)>" + " - could not create Mark."); throw lang::IllegalArgumentException(); + } + // <-- } -void SwXBookmark::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SwXBookmark::attachToRange( + const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { attachToRangeEx(xTextRange, IDocumentMarkAccess::BOOKMARK); } -void SwXBookmark::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXBookmark::attach(const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); attachToRange( xTextRange ); } -uno::Reference< text::XTextRange > SwXBookmark::getAnchor(void) - throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXBookmark::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > aRet; - if(m_pRegisteredBookmark) - aRet = SwXTextRange::CreateTextRangeFromPosition( - m_pDoc, - m_pRegisteredBookmark->GetMarkPos(), - m_pRegisteredBookmark->IsExpanded() ? &m_pRegisteredBookmark->GetOtherMarkPos() : NULL); - else + + if (!m_pImpl->m_pRegisteredBookmark) + { throw uno::RuntimeException(); - return aRet; + } + return SwXTextRange::CreateXTextRange( + *m_pImpl->m_pDoc, + m_pImpl->m_pRegisteredBookmark->GetMarkPos(), + (m_pImpl->m_pRegisteredBookmark->IsExpanded()) + ? &m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos() : NULL); } -void SwXBookmark::dispose(void) - throw( uno::RuntimeException ) +void SAL_CALL SwXBookmark::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(m_pRegisteredBookmark) - GetDoc()->getIDocumentMarkAccess()->deleteMark(m_pRegisteredBookmark); - else - throw uno::RuntimeException(); + if (m_pImpl->m_pRegisteredBookmark) + { + m_pImpl->m_pDoc->getIDocumentMarkAccess()->deleteMark( + m_pImpl->m_pRegisteredBookmark); + } } -void SwXBookmark::addEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL SwXBookmark::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!m_pRegisteredBookmark) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->m_pRegisteredBookmark) + { throw uno::RuntimeException(); - m_aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } -void SwXBookmark::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL SwXBookmark::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!m_pRegisteredBookmark || !m_aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->m_pRegisteredBookmark || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } -OUString SwXBookmark::getName(void) - throw(uno::RuntimeException) +OUString SAL_CALL SwXBookmark::getName() +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - OUString sRet; - if(m_pRegisteredBookmark) - sRet = m_pRegisteredBookmark->GetName(); - else - sRet = m_aName; - return sRet; + + return (m_pImpl->m_pRegisteredBookmark) + ? m_pImpl->m_pRegisteredBookmark->GetName() + : m_pImpl->m_sMarkName; } -void SwXBookmark::setName(const OUString& rName) - throw(uno::RuntimeException) +void SAL_CALL SwXBookmark::setName(const OUString& rName) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!m_pRegisteredBookmark) - m_aName = rName; - if(!m_pRegisteredBookmark || getName() == rName) + + if (!m_pImpl->m_pRegisteredBookmark) + { + m_pImpl->m_sMarkName = rName; + } + if (!m_pImpl->m_pRegisteredBookmark || (getName() == rName)) + { return; - IDocumentMarkAccess* const pMarkAccess = m_pDoc->getIDocumentMarkAccess(); + } + IDocumentMarkAccess *const pMarkAccess = + m_pImpl->m_pDoc->getIDocumentMarkAccess(); if(pMarkAccess->findMark(rName) != pMarkAccess->getMarksEnd()) + { throw uno::RuntimeException(); + } - SwPaM aPam(m_pRegisteredBookmark->GetMarkPos()); - if(m_pRegisteredBookmark->IsExpanded()) + SwPaM aPam(m_pImpl->m_pRegisteredBookmark->GetMarkPos()); + if (m_pImpl->m_pRegisteredBookmark->IsExpanded()) { aPam.SetMark(); - *aPam.GetMark() = m_pRegisteredBookmark->GetOtherMarkPos(); + *aPam.GetMark() = m_pImpl->m_pRegisteredBookmark->GetOtherMarkPos(); } SwRewriter aRewriter; @@ -243,117 +378,148 @@ void SwXBookmark::setName(const OUString& rName) aRewriter.AddRule(UNDO_ARG2, SW_RES(STR_YIELDS)); aRewriter.AddRule(UNDO_ARG3, lcl_QuoteName(rName)); - m_pDoc->StartUndo(UNDO_BOOKMARK_RENAME, &aRewriter); - pMarkAccess->renameMark(m_pRegisteredBookmark, rName); - m_pDoc->EndUndo(UNDO_BOOKMARK_RENAME, NULL); + m_pImpl->m_pDoc->StartUndo(UNDO_BOOKMARK_RENAME, &aRewriter); + pMarkAccess->renameMark(m_pImpl->m_pRegisteredBookmark, rName); + m_pImpl->m_pDoc->EndUndo(UNDO_BOOKMARK_RENAME, NULL); } -OUString SwXBookmark::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXBookmark::getImplementationName() throw (uno::RuntimeException) { return OUString::createFromAscii("SwXBookmark"); } -sal_Bool SwXBookmark::supportsService(const OUString& rServiceName) - throw( uno::RuntimeException ) +static char const*const g_ServicesBookmark[] = { - return !rServiceName.compareToAscii("com.sun.star.text.Bookmark") || - !rServiceName.compareToAscii("com.sun.star.document.LinkTarget") || - !rServiceName.compareToAscii("com.sun.star.text.TextContent"); -} - -uno::Sequence< OUString > SwXBookmark::getSupportedServiceNames(void) - throw( uno::RuntimeException ) + "com.sun.star.text.TextContent", + "com.sun.star.text.Bookmark", + "com.sun.star.document.LinkTarget", +}; +static const size_t g_nServicesBookmark( + sizeof(g_ServicesBookmark)/sizeof(g_ServicesBookmark[0])); + +sal_Bool SAL_CALL SwXBookmark::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(3); - aRet[0] = OUString::createFromAscii("com.sun.star.text.Bookmark"); - aRet[1] = OUString::createFromAscii("com.sun.star.document.LinkTarget"); - aRet[2] = OUString::createFromAscii("com.sun.star.text.TextContent"); - return aRet; + return ::sw::SupportsServiceImpl( + g_nServicesBookmark, g_ServicesBookmark, rServiceName); } -void SwXBookmark::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +uno::Sequence< OUString > SAL_CALL +SwXBookmark::getSupportedServiceNames() throw (uno::RuntimeException) { - ClientModify(this, pOld, pNew); - if(!GetRegisteredIn()) - { - m_pRegisteredBookmark = NULL; - m_pDoc = NULL; - m_aLstnrCntnr.Disposing(); - } + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesBookmark, g_ServicesBookmark); } // MetadatableMixin ::sfx2::Metadatable* SwXBookmark::GetCoreObject() { - return dynamic_cast< ::sfx2::Metadatable* >( GetBookmark() ); + return dynamic_cast< ::sfx2::Metadatable* >(m_pImpl->m_pRegisteredBookmark); } uno::Reference<frame::XModel> SwXBookmark::GetModel() { - if (GetDoc()) + if (m_pImpl->m_pDoc) { - SwDocShell const * const pShell( GetDoc()->GetDocShell() ); + SwDocShell const * const pShell( m_pImpl->m_pDoc->GetDocShell() ); return (pShell) ? pShell->GetModel() : 0; } return 0; } -uno::Reference< beans::XPropertySetInfo > SwXBookmark::getPropertySetInfo(void) - throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXBookmark::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > aRef; - if(!aRef.is()) - { - aRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_BOOKMARK)->getPropertySetInfo(); - } - return aRef; + vos::OGuard g(Application::GetSolarMutex()); + + static uno::Reference< beans::XPropertySetInfo > xRef( + aSwMapProvider.GetPropertySet(PROPERTY_MAP_BOOKMARK) + ->getPropertySetInfo() ); + return xRef; } -void SwXBookmark::setPropertyValue(const OUString& PropertyName, const uno::Any& /*aValue*/) - throw( beans::UnknownPropertyException, - beans::PropertyVetoException, - lang::IllegalArgumentException, - lang::WrappedTargetException, - uno::RuntimeException ) +void SAL_CALL +SwXBookmark::setPropertyValue(const OUString& PropertyName, + const uno::Any& /*rValue*/) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { // nothing to set here - throw IllegalArgumentException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + PropertyName, static_cast < cppu::OWeakObject * > ( this ), 0 ); + throw lang::IllegalArgumentException( ::rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + PropertyName, static_cast< cppu::OWeakObject * >(this), 0 ); } -uno::Any SwXBookmark::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL SwXBookmark::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + uno::Any aRet; - if(!SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) + if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName)) { if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME))) + { aRet <<= getName(); + } } return aRet; } -void SwXBookmark::addPropertyChangeListener(const OUString& /*PropertyName*/, - const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ } +void SAL_CALL +SwXBookmark::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXBookmark::addPropertyChangeListener(): not implemented"); +} -void SwXBookmark::removePropertyChangeListener(const OUString& /*PropertyName*/, - const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ } +void SAL_CALL +SwXBookmark::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXBookmark::removePropertyChangeListener(): not implemented"); +} -void SwXBookmark::addVetoableChangeListener(const OUString& /*PropertyName*/, - const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ } +void SAL_CALL +SwXBookmark::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXBookmark::addVetoableChangeListener(): not implemented"); +} -void SwXBookmark::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) -{ } +void SAL_CALL +SwXBookmark::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXBookmark::removeVetoableChangeListener(): not implemented"); +} + +/****************************************************************** + * SwXFieldmark + ******************************************************************/ SwXFieldmark::SwXFieldmark(bool _isReplacementObject, ::sw::mark::IMark* pBkm, SwDoc* pDc) - : SwXFieldmark_BASE(pBkm, pDc) + : SwXFieldmark_Base(pBkm, pDc) , isReplacementObject(_isReplacementObject) { } @@ -420,3 +586,4 @@ void SAL_CALL SwXFieldmark::setDescription( const ::rtl::OUString& description ) else throw uno::RuntimeException(); } + diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index 167add1e58..218d7e1e63 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -34,7 +34,6 @@ #include <memory> #include <algorithm> - #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart2/data/LabelOrigin.hpp> #include <cppuhelper/interfacecontainer.hxx> @@ -51,7 +50,7 @@ #include <swtable.hxx> #include <unoprnms.hxx> #include <unomap.hxx> -#include <unoobj.hxx> +#include <unomid.h> #include <unocrsr.hxx> #include <unotbl.hxx> #include <doc.hxx> diff --git a/sw/source/core/unocore/unoclbck.cxx b/sw/source/core/unocore/unoclbck.cxx deleted file mode 100644 index 5936365594..0000000000 --- a/sw/source/core/unocore/unoclbck.cxx +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: unoclbck.cxx,v $ - * $Revision: 1.10 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sw.hxx" - - -#include <hintids.hxx> -#include <tools/debug.hxx> -#include <swtypes.hxx> -#include <unoobj.hxx> -#include <unoidx.hxx> -#include <tox.hxx> -#include <unoclbck.hxx> -#include <txtftn.hxx> -#include <fmtftn.hxx> -#include <doc.hxx> -#include <fmtrfmrk.hxx> -#include <txtrfmrk.hxx> - -/* -----------------------------06.01.00 13:51-------------------------------- - - ---------------------------------------------------------------------------*/ -SwUnoCallBack::SwUnoCallBack(SwModify *pToRegisterIn) : - SwModify(pToRegisterIn) -{ -} -/* -----------------------------06.01.00 13:51-------------------------------- - - ---------------------------------------------------------------------------*/ -SwUnoCallBack::~SwUnoCallBack() -{ -} -/* -----------------------------01.09.00 12:03-------------------------------- - - ---------------------------------------------------------------------------*/ -SwXReferenceMark* SwUnoCallBack::GetRefMark(const SwFmtRefMark& rMark) -{ - SwClientIter aIter( *this ); - SwXReferenceMark* pxRefMark = (SwXReferenceMark*)aIter.First( TYPE( SwXReferenceMark )); - while(pxRefMark) - { - SwDoc* pDoc = pxRefMark->GetDoc(); - if(pDoc) - { - const SwFmtRefMark* pFmt = pDoc->GetRefMark(pxRefMark->GetMarkName()); - if(pFmt == &rMark) - return pxRefMark; - } - pxRefMark = (SwXReferenceMark*)aIter.Next( ); - } - return 0; -} -/* -----------------------------05.09.00 12:38-------------------------------- - - ---------------------------------------------------------------------------*/ -SwXFootnote* SwUnoCallBack::GetFootnote(const SwFmtFtn& rMark) -{ - SwClientIter aIter( *this ); - SwXFootnote* pxFootnote = (SwXFootnote*)aIter.First( TYPE( SwXFootnote )); - while(pxFootnote) - { - SwDoc* pDoc = pxFootnote->GetDoc(); - if(pDoc) - { - const SwFmtFtn* pFtn = pxFootnote->FindFmt(); - if(pFtn == &rMark) - return pxFootnote; - } - pxFootnote = (SwXFootnote*)aIter.Next( ); - } - return 0; -} - -/* -----------------------------27.11.00 17:15-------------------------------- - - ---------------------------------------------------------------------------*/ -SwXDocumentIndexMark* SwUnoCallBack::GetTOXMark(const SwTOXMark& rMark) -{ - SwClientIter aIter( *this ); - SwXDocumentIndexMark* pxIndexMark = (SwXDocumentIndexMark*)aIter.First( TYPE( SwXDocumentIndexMark )); - while(pxIndexMark) - { - const SwTOXMark* pMark = pxIndexMark->GetTOXMark(); - if(pMark == &rMark) - return pxIndexMark; - - pxIndexMark = (SwXDocumentIndexMark*)aIter.Next( ); - } - return 0; -} - diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 78799c8a96..8bb33a4fdb 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <swtypes.hxx> #include <cmdid.h> #include <hintids.hxx> @@ -44,7 +43,6 @@ #include <poolfmt.hxx> #include <unocoll.hxx> #include <unosett.hxx> -#include <unoclbck.hxx> #include <fmtanchr.hxx> #include <ndtxt.hxx> #include <section.hxx> @@ -67,7 +65,9 @@ #include <unofield.hxx> #include <unoidx.hxx> #include <unoframe.hxx> +#include <unofootnote.hxx> #include <vcl/svapp.hxx> +#include <fmtcntnt.hxx> #include <authfld.hxx> #include <SwXTextDefaults.hxx> #include <unochart.hxx> @@ -76,7 +76,11 @@ #include <slist> #include <iterator> -#include "unometa.hxx" +#include <unosection.hxx> +#include <unoparagraph.hxx> +#include <unobookmark.hxx> +#include <unorefmark.hxx> +#include <unometa.hxx> #include "docsh.hxx" @@ -442,7 +446,8 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 break; case SW_SERVICE_INDEX_HEADER_SECTION : case SW_SERVICE_TEXT_SECTION : - xRet = SwXTextSectionClient::CreateXTextSection( 0, SW_SERVICE_INDEX_HEADER_SECTION == nObjectType); + xRet = SwXTextSection::CreateXTextSection(0, + (SW_SERVICE_INDEX_HEADER_SECTION == nObjectType)); break; case SW_SERVICE_REFERENCE_MARK : @@ -869,7 +874,8 @@ namespace } template<FlyCntType T> - class SwXFrameEnumeration : public SwSimpleEnumerationBaseClass + class SwXFrameEnumeration + : public SwSimpleEnumeration_Base { private: typedef ::std::slist< Any > frmcontainer_t; @@ -1467,15 +1473,7 @@ sal_Bool SwXTextSections::hasElements(void) throw( uno::RuntimeException ) -----------------------------------------------------------------------*/ uno::Reference< XTextSection > SwXTextSections::GetObject( SwSectionFmt& rFmt ) { - SwXTextSectionClient* pClient = (SwXTextSectionClient*)SwClientIter( rFmt ). - First( TYPE( SwXTextSectionClient )); - uno::Reference< XTextSection > xRet; - if( pClient ) - xRet = pClient->GetXTextSection(); - // it is possible that the client is still registered but the reference is already invalid - if( !xRet.is() ) - xRet = SwXTextSectionClient::CreateXTextSection(&rFmt); - return xRet; + return SwXTextSection::CreateXTextSection(&rFmt); } OUString SwXBookmarks::getImplementationName(void) throw( RuntimeException ) @@ -1523,8 +1521,9 @@ uno::Any SwXBookmarks::getByIndex(sal_Int32 nIndex) uno::Any aRet; ::sw::mark::IMark* pBkmk = pMarkAccess->getBookmarksBegin()[nIndex].get(); - uno::Reference< XTextContent > xRef = GetObject(*pBkmk, GetDoc()); - aRet.setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0)); + const uno::Reference< text::XTextContent > xRef = + SwXBookmark::CreateXBookmark(*GetDoc(), *pBkmk); + aRet <<= xRef; return aRet; } @@ -1541,8 +1540,9 @@ uno::Any SwXBookmarks::getByName(const rtl::OUString& rName) throw NoSuchElementException(); uno::Any aRet; - uno::Reference< XTextContent > xRef = SwXBookmarks::GetObject(*(ppBkmk->get()), GetDoc()); - aRet.setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0)); + const uno::Reference< text::XTextContent > xRef = + SwXBookmark::CreateXBookmark(*GetDoc(), *(ppBkmk->get())); + aRet <<= xRef; return aRet; } @@ -1588,27 +1588,6 @@ sal_Bool SwXBookmarks::hasElements(void) return GetDoc()->getIDocumentMarkAccess()->getBookmarksCount() != 0; } -SwXBookmark* SwXBookmarks::GetObject( ::sw::mark::IMark& rBkmk, SwDoc* pDoc) -{ - SwModify* const pModify = static_cast<SwModify*>(&rBkmk); - SwXBookmark* pXBkmk = (SwXBookmark*)SwClientIter(*pModify).First(TYPE(SwXBookmark)); - if(!pXBkmk) - { - // FIXME: These belong in XTextFieldsSupplier - //if (dynamic_cast< ::sw::mark::TextFieldmark* >(&rBkmk)) - // pXBkmk = new SwXFieldmark(false, &rBkmk, pDoc); - //else if (dynamic_cast< ::sw::mark::CheckboxFieldmark* >(&rBkmk)) - // pXBkmk = new SwXFieldmark(true, &rBkmk, pDoc); - //else - OSL_ENSURE( - dynamic_cast< ::sw::mark::IBookmark* >(&rBkmk), - "<SwXBookmark::GetObject(..)>" - "SwXBookmark requested for non-bookmark mark."); - pXBkmk = new SwXBookmark(&rBkmk, pDoc); - } - return pXBkmk; -} - /****************************************************************** * ******************************************************************/ @@ -1747,8 +1726,8 @@ uno::Any SwXFootnotes::getByIndex(sal_Int32 nIndex) if(nCount == nIndex) { - xRef = new SwXFootnote(GetDoc(), rFtn); - aRet.setValue(&xRef, ::getCppuType((uno::Reference<XFootnote>*)0)); + xRef = SwXFootnote::CreateXFootnote(*GetDoc(), rFtn); + aRet <<= xRef; break; } nCount++; @@ -1782,12 +1761,7 @@ sal_Bool SwXFootnotes::hasElements(void) throw( uno::RuntimeException ) ---------------------------------------------------------------------------*/ Reference<XFootnote> SwXFootnotes::GetObject( SwDoc& rDoc, const SwFmtFtn& rFmt ) { - Reference<XTextContent> xContent = ((SwUnoCallBack*)rDoc.GetUnoCallBack())-> - GetFootnote(rFmt); - if(!xContent.is()) - xContent = new SwXFootnote(&rDoc, rFmt); - Reference<XFootnote> xRet(xContent, UNO_QUERY); - return xRet; + return SwXFootnote::CreateXFootnote(rDoc, rFmt); } /****************************************************************** @@ -1940,18 +1914,10 @@ sal_Bool SwXReferenceMarks::hasElements(void) throw( uno::RuntimeException ) SwXReferenceMark* SwXReferenceMarks::GetObject( SwDoc* pDoc, const SwFmtRefMark* pMark ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwClientIter aIter( *pDoc->GetUnoCallBack() ); - SwXReferenceMark* pxMark = (SwXReferenceMark*)aIter.First( TYPE( SwXReferenceMark )); - while(pxMark) - { - if(pxMark->GetMark() == pMark) - break; - pxMark = (SwXReferenceMark*)aIter.Next(); - } - if( !pxMark ) - pxMark = new SwXReferenceMark(pDoc, pMark); - return pxMark; + + return SwXReferenceMark::CreateXReferenceMark(*pDoc, *pMark); } + /****************************************************************** * ******************************************************************/ diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 1ac40712b4..a48e37a8f5 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -32,16 +32,21 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <map> + +#include <com/sun/star/text/XTextSection.hpp> #include <cmdid.h> #include <unocrsrhelper.hxx> -#include <unoobj.hxx> +#include <unofootnote.hxx> +#include <unorefmark.hxx> #include <unostyle.hxx> #include <unoidx.hxx> #include <unofield.hxx> #include <unotbl.hxx> #include <unosett.hxx> #include <unoframe.hxx> +#include <unocrsr.hxx> #include <doc.hxx> #include <IDocumentRedlineAccess.hxx> #include <fmtftn.hxx> @@ -64,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> @@ -100,8 +106,9 @@ using ::rtl::OUString; namespace SwUnoCursorHelper { + /* -----------------16.09.98 12:27------------------- - * Lesen spezieller Properties am Cursor +* Lesen spezieller Properties am Cursor * --------------------------------------------------*/ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry , SwPaM& rPam @@ -193,7 +200,10 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry pFmt = FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID ? pNode->GetFmtColl() : &pNode->GetAnyFmtColl(); else - pFmt = SwXTextCursor::GetCurTxtFmtColl(rPam, FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID); + { + pFmt = SwUnoCursorHelper::GetCurTxtFmtColl(rPam, + FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID); + } if(pFmt) { if( pAny ) @@ -303,10 +313,13 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry { if( pAny ) { - const SwTOXMark& rMark = pTxtAttr->GetTOXMark(); - uno::Reference< XDocumentIndexMark > xRef = SwXDocumentIndexMark::GetObject( - (SwTOXType*)rMark.GetTOXType(), &rMark, rPam.GetDoc()); - pAny->setValue(&xRef, ::getCppuType((uno::Reference<XDocumentIndex>*)0)); + SwTOXMark & rMark = + static_cast<SwTOXMark&>(pTxtAttr->GetAttr()); + const uno::Reference< text::XDocumentIndexMark > xRef = + SwXDocumentIndexMark::CreateXDocumentIndexMark( + *rPam.GetDoc(), + *const_cast<SwTOXType*>(rMark.GetTOXType()), rMark); + (*pAny) <<= xRef; } } else @@ -322,9 +335,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 @@ -436,8 +450,9 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry { if( pAny ) { - uno::Reference< XFootnote > xFoot = new SwXFootnote(rPam.GetDoc(), rFtn); - pAny->setValue(&xFoot, ::getCppuType((uno::Reference<XFootnote>*)0)); + const uno::Reference< text::XFootnote > xFootnote = + SwXFootnote::CreateXFootnote(*rPam.GetDoc(), rFtn); + *pAny <<= xFootnote; } } else diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 65b0ad2dca..7d685b6e9c 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -38,16 +38,20 @@ #include <unodraw.hxx> #include <unocoll.hxx> #include <unoframe.hxx> +#include <unoparagraph.hxx> +#include <unotextrange.hxx> #include <unoprnms.hxx> #include <svx/unoprnms.hxx> #include <swunohelper.hxx> #include <doc.hxx> +#include <fmtcntnt.hxx> #include <fmtflcnt.hxx> #include <txtatr.hxx> #include <docsh.hxx> #include <unomap.hxx> #include <unoport.hxx> #include <unocrsr.hxx> +#include <TextCursorHelper.hxx> #include <swundo.hxx> #include <dflyobj.hxx> #include <ndtxt.hxx> @@ -156,7 +160,9 @@ public: SwFmtAnchor* GetAnchor(sal_Bool bCreate = sal_False) { if(bCreate && !pAnchor) - pAnchor = new SwFmtAnchor(FLY_IN_CNTNT); + { + pAnchor = new SwFmtAnchor(FLY_AS_CHAR); + } return pAnchor; } SwFmtHoriOrient* GetHOrient(sal_Bool bCreate = sal_False) @@ -429,7 +435,8 @@ uno::Reference< drawing::XShape > SwFmDrawPage::_CreateShape( SdrObject *pObj ) ****************************************************************************/ namespace { - class SwXShapesEnumeration : public SwSimpleEnumerationBaseClass + class SwXShapesEnumeration + : public SwSimpleEnumeration_Base { private: typedef ::std::slist< ::com::sun::star::uno::Any > shapescontainer_t; @@ -693,7 +700,7 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 ); - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); sal_Bool bOpaque = sal_False; if( pDesc ) { @@ -770,18 +777,22 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) if( pDesc && (xRg = pDesc->GetTextRange()).is() ) { pInternalPam = new SwUnoInternalPaM(*pDoc); - if(SwXTextRange::XTextRangeToSwPaM(*pInternalPam, xRg)) + if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg)) { if(FLY_AT_FLY == aAnchor.GetAnchorId() && !pInternalPam->GetNode()->FindFlyStartNode()) - aAnchor.SetType(FLY_IN_CNTNT); - else if(FLY_PAGE == aAnchor.GetAnchorId()) + { + aAnchor.SetType(FLY_AS_CHAR); + } + else if (FLY_AT_PAGE == aAnchor.GetAnchorId()) + { aAnchor.SetAnchor(pInternalPam->Start()); + } } else throw uno::RuntimeException(); } - else if( aAnchor.GetAnchorId() != FLY_PAGE && pDoc->GetRootFrm() ) + else if ((aAnchor.GetAnchorId() != FLY_AT_PAGE) && pDoc->GetRootFrm()) { SwCrsrMoveState aState( MV_SETONLYTEXT ); Point aTmp(MM100_TO_TWIP(aMM100Pos.X), MM100_TO_TWIP(aMM100Pos.Y)); @@ -793,7 +804,7 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) } else { - aAnchor.SetType(FLY_PAGE); + aAnchor.SetType(FLY_AT_PAGE); // --> OD 2004-08-18 #i32349# - adjustment of vertical positioning // attributes no longer needed, because its already got a default. @@ -846,8 +857,11 @@ uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference< for ( sal_uInt16 i = 0; !bFlyInCnt && i < rMarkList.GetMarkCount(); ++i ) { const SdrObject *pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); - if ( FLY_IN_CNTNT == ::FindFrmFmt( (SdrObject*)pObj )->GetAnchor().GetAnchorId() ) + if (FLY_AS_CHAR == ::FindFrmFmt(const_cast<SdrObject*>( + pObj))->GetAnchor().GetAnchorId()) + { bFlyInCnt = sal_True; + } } if( bFlyInCnt ) throw uno::RuntimeException(); @@ -857,7 +871,9 @@ uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference< pDoc->StartUndo( UNDO_START, NULL ); SwDrawContact* pContact = pDoc->GroupSelection( *pPage->GetDrawView() ); - pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(), FLY_AT_CNTNT/*int eAnchorId*/, + pDoc->ChgAnchor( + pPage->GetDrawView()->GetMarkedObjectList(), + FLY_AT_PARA/*int eAnchorId*/, sal_True, sal_False ); pPage->GetDrawView()->UnmarkAll(); @@ -892,7 +908,8 @@ void SwXDrawPage::ungroup(const uno::Reference< drawing::XShapeGroup > & xShapeG pDoc->StartUndo( UNDO_START, NULL ); pDoc->UnGroupSelection( *pPage->GetDrawView() ); - pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(), FLY_AT_CNTNT/*int eAnchorId*/, + pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(), + FLY_AT_PARA/*int eAnchorId*/, sal_True, sal_False ); pDoc->EndUndo( UNDO_END, NULL ); } @@ -1267,7 +1284,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A else if ( FN_TEXT_RANGE == pEntry->nWID ) { SwFmtAnchor aAnchor( static_cast<const SwFmtAnchor&>(aSet.Get( RES_ANCHOR )) ); - if ( aAnchor.GetAnchorId() == FLY_PAGE ) + if (aAnchor.GetAnchorId() == FLY_AT_PAGE) { // set property <TextRange> not valid for to-page anchored shapes throw lang::IllegalArgumentException(); @@ -1278,9 +1295,9 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A new SwUnoInternalPaM( *(pFmt->GetDoc()) ); uno::Reference< text::XTextRange > xRg; aValue >>= xRg; - if ( SwXTextRange::XTextRangeToSwPaM(*pInternalPam, xRg) ) + if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg) ) { - if(aAnchor.GetAnchorId() == FLY_IN_CNTNT) + if (aAnchor.GetAnchorId() == FLY_AS_CHAR) { //delete old SwFmtFlyCnt //With AnchorAsCharacter the current TxtAttribute has to be deleted. @@ -1368,7 +1385,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A SwFrmFmt *pFlyFmt = FindFrmFmt( pObj ); pFlyFmt->DelFrms(); if( text::TextContentAnchorType_AS_CHARACTER != eNewAnchor && - FLY_IN_CNTNT == eOldAnchorId ) + (FLY_AS_CHAR == eOldAnchorId)) { //With AnchorAsCharacter the current TxtAttribute has to be deleted. //Tbis removes the frame format too. @@ -1391,7 +1408,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A pTxtNode->DeleteAttributes(RES_TXTATR_FLYCNT, nIdx); } else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor && - FLY_PAGE == eOldAnchorId ) + (FLY_AT_PAGE == eOldAnchorId)) { SwFmtAnchor aNewAnchor( dynamic_cast< const SwFmtAnchor& >( aSet.Get( RES_ANCHOR ) ) ); //if the fly has been anchored at page then it needs to be connected @@ -1414,7 +1431,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A pFmt->SetFmtAttr(aSet); bSetAttr = false; if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor && - FLY_IN_CNTNT != eOldAnchorId ) + (FLY_AS_CHAR != eOldAnchorId)) { //the RES_TXTATR_FLYCNT needs to be added now SwTxtNode *pNd = aPam.GetNode()->GetTxtNode(); @@ -1599,7 +1616,7 @@ uno::Any SwXShape::getPropertyValue(const rtl::OUString& rPropertyName) else if ( FN_TEXT_RANGE == pEntry->nWID ) { const SwFmtAnchor aAnchor = pFmt->GetAnchor(); - if ( aAnchor.GetAnchorId() == FLY_PAGE ) + if (aAnchor.GetAnchorId() == FLY_AT_PAGE) { // return nothing, because property <TextRange> isn't // valid for to-page anchored shapes @@ -1610,9 +1627,9 @@ uno::Any SwXShape::getPropertyValue(const rtl::OUString& rPropertyName) { if ( aAnchor.GetCntntAnchor() ) { - uno::Reference< text::XTextRange > xTextRange = - SwXTextRange::CreateTextRangeFromPosition( - pFmt->GetDoc(), + const uno::Reference< text::XTextRange > xTextRange + = SwXTextRange::CreateXTextRange( + *pFmt->GetDoc(), *aAnchor.GetCntntAnchor(), 0L ); aRet.setValue(&xTextRange, ::getCppuType((uno::Reference<text::XTextRange>*)0)); @@ -2134,7 +2151,9 @@ void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange) pDoc = pPortion->GetCursor()->GetDoc(); } else if ( !pDoc && pParagraph && pParagraph->GetTxtNode( ) ) - pDoc = pParagraph->GetTxtNode( )->GetDoc( ); + { + pDoc = const_cast<SwDoc*>(pParagraph->GetTxtNode()->GetDoc()); + } } @@ -2173,11 +2192,11 @@ uno::Reference< text::XTextRange > SwXShape::getAnchor(void) throw( uno::Runtim const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); // return an anchor for non-page bound frames // and for page bound frames that have a page no == NULL and a content position - if( rAnchor.GetAnchorId() != FLY_PAGE || + if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) || (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum())) { const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); - aRef = SwXTextRange::CreateTextRangeFromPosition(pFmt->GetDoc(), rPos, 0); + aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0); } } else @@ -2217,7 +2236,7 @@ void SwXShape::dispose(void) throw( uno::RuntimeException ) pObj->IsInserted() ) // <-- { - if( pFmt->GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR) { const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode(); diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 2167a0c918..8105d65bff 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -41,7 +41,8 @@ #include <ndtxt.hxx> #include <unomap.hxx> #include <unoprnms.hxx> -#include <unoobj.hxx> +#include <unotextrange.hxx> +#include <unotextcursor.hxx> #include <unocoll.hxx> #include <svx/linkmgr.hxx> #include <docstat.hxx> @@ -1304,7 +1305,7 @@ void SwXTextField::attachToRange( { SwUnoInternalPaM aPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); SwField* pFld = 0; switch(m_nServiceId) { @@ -1879,8 +1880,8 @@ uno::Reference< text::XTextRange > SwXTextField::getAnchor(void) throw( uno::Ru SwPaM aPam(rTxtNode, *pTxtFld->GetStart() + 1, rTxtNode, *pTxtFld->GetStart()); - aRef = SwXTextRange::CreateTextRangeFromPosition(m_pDoc, - *aPam.GetPoint(), aPam.GetMark()); + aRef = SwXTextRange::CreateXTextRange( + *m_pDoc, *aPam.GetPoint(), aPam.GetMark()); } return aRef; diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index 68015384da..d45125c2d2 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -46,7 +46,8 @@ #include <viewimp.hxx> #include <breakit.hxx> #include <pam.hxx> -#include <unoobj.hxx> +#include <unobaseclass.hxx> +#include <unotextrange.hxx> #include <pagefrm.hxx> #include <cntfrm.hxx> #include <rootfrm.hxx> @@ -217,7 +218,9 @@ void SAL_CALL SwXFlatParagraph::changeText(::sal_Int32 nPos, ::sal_Int32 nLen, c UnoActionContext aAction( mpTxtNode->GetDoc() ); - uno::Reference< text::XTextRange > xRange = SwXTextRange::CreateTextRangeFromPosition( mpTxtNode->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); + const uno::Reference< text::XTextRange > xRange = + SwXTextRange::CreateXTextRange( + *mpTxtNode->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); uno::Reference< beans::XPropertySet > xPropSet( xRange, uno::UNO_QUERY ); if ( xPropSet.is() ) { @@ -245,7 +248,9 @@ void SAL_CALL SwXFlatParagraph::changeAttributes(::sal_Int32 nPos, ::sal_Int32 n UnoActionContext aAction( mpTxtNode->GetDoc() ); - uno::Reference< text::XTextRange > xRange = SwXTextRange::CreateTextRangeFromPosition( mpTxtNode->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); + const uno::Reference< text::XTextRange > xRange = + SwXTextRange::CreateXTextRange( + *mpTxtNode->GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); uno::Reference< beans::XPropertySet > xPropSet( xRange, uno::UNO_QUERY ); if ( xPropSet.is() ) { diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 37f53ade45..afea552fd2 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <com/sun/star/embed/NoVisualAreaSizeException.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/embed/XClassifiedObject.hpp> @@ -45,9 +46,7 @@ #include <memory> #include <hints.hxx> #include <doc.hxx> -#ifndef _DOCSH_HXX //autogen #include <docsh.hxx> -#endif #include <editsh.hxx> #include <swcli.hxx> #include <ndindex.hxx> @@ -62,7 +61,9 @@ #include <ndole.hxx> #include <frmfmt.hxx> #include <frame.hxx> -#include <unoobj.hxx> +#include <unotextrange.hxx> +#include <unotextcursor.hxx> +#include <unoparagraph.hxx> #include <unomap.hxx> #include <unoprnms.hxx> #include <unoevent.hxx> @@ -99,6 +100,7 @@ #include <unoframe.hxx> #include <fmtanchr.hxx> #include <fmtclds.hxx> +#include <fmtcntnt.hxx> #include <frmatr.hxx> #include <ndtxt.hxx> #include <ndgrf.hxx> @@ -1402,7 +1404,8 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: aSet.Put(aAnchor); } } - else if(aAnchor.GetAnchorId() != FLY_PAGE && !aAnchor.GetCntntAnchor()) + else if ((aAnchor.GetAnchorId() != FLY_AT_PAGE) && + !aAnchor.GetCntntAnchor()) { SwNode& rNode = pDoc->GetNodes().GetEndOfContent(); SwPaM aPam(rNode); @@ -2023,7 +2026,7 @@ void SwXFrame::dispose(void) throw( uno::RuntimeException ) ( pObj->GetUserCall() && !static_cast<SwContact*>(pObj->GetUserCall())->IsInDTOR() ) ) ) { - if( pFmt->GetAnchor().GetAnchorId() == FLY_IN_CNTNT ) + if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR) { const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode(); @@ -2049,11 +2052,11 @@ uno::Reference< text::XTextRange > SwXFrame::getAnchor(void) throw( uno::Runtim const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); // return an anchor for non-page bound frames // and for page bound frames that have a page no == NULL and a content position - if( rAnchor.GetAnchorId() != FLY_PAGE || + if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) || (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum())) { const SwPosition &rPos = *(rAnchor.GetCntntAnchor()); - aRef = SwXTextRange::CreateTextRangeFromPosition(pFmt->GetDoc(), rPos, 0); + aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0); } } else @@ -2095,7 +2098,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan { SwUnoInternalPaM aIntPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aIntPam, xTextRange); + ::sw::XTextRangeToSwPaM(aIntPam, xTextRange); SwNode& rNode = pDoc->GetNodes().GetEndOfContent(); SwPaM aPam(rNode); @@ -2128,7 +2131,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan } const SfxPoolItem* pItem; - RndStdIds eAnchorId = FLY_AT_CNTNT; + RndStdIds eAnchorId = FLY_AT_PARA; if(SFX_ITEM_SET == aFrmSet.GetItemState(RES_ANCHOR, sal_False, &pItem) ) { eAnchorId = ((const SwFmtAnchor*)pItem)->GetAnchorId(); @@ -2136,10 +2139,10 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan !aPam.GetNode()->FindFlyStartNode()) { //rahmengebunden geht nur dort, wo ein Rahmen ist! - SwFmtAnchor aAnchor(FLY_AT_CNTNT); + SwFmtAnchor aAnchor(FLY_AT_PARA); aFrmSet.Put(aAnchor); } - else if( FLY_PAGE == eAnchorId && + else if ((FLY_AT_PAGE == eAnchorId) && 0 == ((const SwFmtAnchor*)pItem)->GetPageNum() ) { SwFmtAnchor aAnchor( *((const SwFmtAnchor*)pItem) ); @@ -2162,10 +2165,10 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan SwFmtAnchor* pAnchorItem = 0; // the frame is inserted bound to page // to prevent conflicts if the to-be-anchored position is part of the to-be-copied text - if(eAnchorId != FLY_PAGE) + if (eAnchorId != FLY_AT_PAGE) { pAnchorItem = static_cast<SwFmtAnchor*>(aFrmSet.Get(RES_ANCHOR).Clone()); - aFrmSet.Put( SwFmtAnchor( FLY_PAGE, 1 )); + aFrmSet.Put( SwFmtAnchor( FLY_AT_PAGE, 1 )); } pFmt = pDoc->MakeFlyAndMove( *m_pCopySource, aFrmSet, @@ -2183,8 +2186,10 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan DELETEZ( m_pCopySource ); } else - pFmt = pDoc->MakeFlySection( FLY_AT_CNTNT, aPam.GetPoint(), + { + pFmt = pDoc->MakeFlySection( FLY_AT_PARA, aPam.GetPoint(), &aFrmSet, pParentFrmFmt ); + } if(pFmt) { pFmt->Add(this); @@ -2425,7 +2430,7 @@ void SwXFrame::attach(const uno::Reference< text::XTextRange > & xTextRange) } SwDoc* pDoc = pFmt->GetDoc(); SwUnoInternalPaM aIntPam(*pDoc); - if(SwXTextRange::XTextRangeToSwPaM(aIntPam, xTextRange)) + if (::sw::XTextRangeToSwPaM(aIntPam, xTextRange)) { SfxItemSet aSet( pDoc->GetAttrPool(), RES_ANCHOR, RES_ANCHOR ); @@ -2606,7 +2611,8 @@ const SwStartNode *SwXTextFrame::GetStartNode() const return pSttNd; } -uno::Reference< text::XTextCursor > SwXTextFrame::createCursor() throw ( uno::RuntimeException) +uno::Reference< text::XTextCursor > +SwXTextFrame::CreateCursor() throw (uno::RuntimeException) { return createTextCursor(); } @@ -2647,10 +2653,11 @@ uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursor(void) throw( throw aExcept; } - SwXTextCursor* pXCrsr = new SwXTextCursor(this, *aPam.GetPoint(), CURSOR_FRAME, pFmt->GetDoc()); - aRef = (text::XWordCursor*)pXCrsr; + SwXTextCursor *const pXCursor = new SwXTextCursor( + *pFmt->GetDoc(), this, CURSOR_FRAME, *aPam.GetPoint()); + aRef = static_cast<text::XWordCursor*>(pXCursor); #if OSL_DEBUG_LEVEL > 1 - SwUnoCrsr* pUnoCrsr = pXCrsr->GetCrsr(); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); (void) pUnoCrsr; #endif } @@ -2667,7 +2674,7 @@ uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursorByRange(const uno::Reference< text::XTextCursor > aRef; SwFrmFmt* pFmt = GetFrmFmt(); SwUnoInternalPaM aPam(*GetDoc()); - if(pFmt && SwXTextRange::XTextRangeToSwPaM(aPam, aTextPosition)) + if (pFmt && ::sw::XTextRangeToSwPaM(aPam, aTextPosition)) { SwNode& rNode = pFmt->GetCntnt().GetCntntIdx()->GetNode(); #if OSL_DEBUG_LEVEL > 1 @@ -2677,8 +2684,11 @@ uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursorByRange(const (void)p2; #endif if(aPam.GetNode()->FindFlyStartNode() == rNode.FindFlyStartNode()) - aRef = (text::XWordCursor*)new SwXTextCursor(this , - *aPam.GetPoint(), CURSOR_FRAME, pFmt->GetDoc(), aPam.GetMark()); + { + aRef = static_cast<text::XWordCursor*>( + new SwXTextCursor(*pFmt->GetDoc(), this, CURSOR_FRAME, + *aPam.GetPoint(), aPam.GetMark())); + } } else throw uno::RuntimeException(); @@ -2695,14 +2705,15 @@ uno::Reference< container::XEnumeration > SwXTextFrame::createEnumeration(void) if(pFmt) { SwPosition aPos(pFmt->GetCntnt().GetCntntIdx()->GetNode()); - SwUnoCrsr* pUnoCrsr = GetDoc()->CreateUnoCrsr(aPos, sal_False); - pUnoCrsr->Move( fnMoveForward, fnGoNode ); + ::std::auto_ptr<SwUnoCrsr> pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); // // no Cursor in protected sections // SwCrsrSaveState aSave( *pUnoCrsr ); // if(pUnoCrsr->IsInProtectTable( sal_True ) || // pUnoCrsr->IsSelOvr( SELOVER_TOGGLE | SELOVER_CHANGEPOS )) // throw uno::RuntimeException() ); - aRef = new SwXParagraphEnumeration(this, pUnoCrsr, CURSOR_FRAME); + aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FRAME); } return aRef; } diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index d7a974bfb1..3a1509a276 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -31,13 +31,20 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <rtl/uuid.h> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> -#include <rtl/uuid.h> -#include <unoobj.hxx> +#include <comphelper/sequence.hxx> + +#include <unomid.h> +#include <unofootnote.hxx> +#include <unotextrange.hxx> +#include <unotextcursor.hxx> +#include <unoparagraph.hxx> #include <unomap.hxx> #include <unoprnms.hxx> +#include <unoevtlstnr.hxx> #include <doc.hxx> #include <ftnidx.hxx> #include <fmtftn.hxx> @@ -46,122 +53,238 @@ #include <unocrsr.hxx> #include <hints.hxx> + using namespace ::com::sun::star; using ::rtl::OUString; /****************************************************************** - * + * SwXFootnote ******************************************************************/ -/* -----------------------------13.03.00 12:15-------------------------------- - ---------------------------------------------------------------------------*/ -const uno::Sequence< sal_Int8 > & SwXFootnote::getUnoTunnelId() +class SwXFootnote::Impl + : public SwClient { - static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; -} -/* -----------------------------10.03.00 18:04-------------------------------- - ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXFootnote::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) -{ - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) +public: + + SwXFootnote & m_rThis; + const bool m_bIsEndnote; + SwEventListenerContainer m_ListenerContainer; + bool m_bIsDescriptor; + const SwFmtFtn * m_pFmtFtn; + ::rtl::OUString m_sLabel; + + Impl( SwXFootnote & rThis, + SwDoc *const pDoc, SwFmtFtn const*const pFootnote, + const bool bIsEndnote) + : SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0) + , m_rThis(rThis) + , m_bIsEndnote(bIsEndnote) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIsDescriptor(0 == pFootnote) + , m_pFmtFtn(pFootnote) { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); } - return SwXText::getSomething( rId ); -} -/* -----------------------------06.04.00 16:36-------------------------------- + + const SwFmtFtn* GetFootnoteFormat() const { + return m_rThis.GetDoc() ? m_pFmtFtn : 0; + } + + SwFmtFtn const& GetFootnoteFormatOrThrow() { + SwFmtFtn const*const pFootnote( GetFootnoteFormat() ); + if (!pFootnote) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXFootnote: disposed or invalid")), 0); + } + return *pFootnote; + } + + void Invalidate(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/* -----------------------------07.01.00 12:39-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXFootnote::getImplementationName(void) throw( uno::RuntimeException ) +void SwXFootnote::Impl::Invalidate() { - return C2U("SwXFootnote"); + if (GetRegisteredIn()) + { + const_cast<SwModify*>(GetRegisteredIn())->Remove(this); + } + m_ListenerContainer.Disposing(); + m_pFmtFtn = 0; + m_rThis.SetDoc(0); } -/* -----------------------------06.04.00 16:36-------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXFootnote::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +/* -----------------18.01.99 09:12------------------- + * + * --------------------------------------------------*/ +void SwXFootnote::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { - return !rServiceName.compareToAscii("com.sun.star.text.Footnote") || - !rServiceName.compareToAscii("com.sun.star.text.TextContent") || - !rServiceName.compareToAscii("com.sun.star.text.Text") || - (m_bIsEndnote && !rServiceName.compareToAscii("com.sun.star.text.Endnote")); -; -} -/* -----------------------------06.04.00 16:36-------------------------------- + ClientModify(this, pOld, pNew); - ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXFootnote::getSupportedServiceNames(void) throw( uno::RuntimeException ) -{ - uno::Sequence< OUString > aRet(m_bIsEndnote ? 4 : 3); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.Footnote"); - pArray[1] = C2U("com.sun.star.text.TextContent"); - pArray[2] = C2U("com.sun.star.text.Text"); - if(m_bIsEndnote) - pArray[3] = C2U("com.sun.star.text.Endnote"); - return aRet; + if (!GetRegisteredIn()) // removed => dispose + { + Invalidate(); + } + else if (pOld) + { + switch (pOld->Which()) + { + case RES_FOOTNOTE_DELETED: + if (static_cast<const void*>(m_pFmtFtn) == + static_cast<SwPtrMsgPoolItem *>(pOld)->pObject) + { + Invalidate(); + } + break; + } + } } + /*-- 10.12.98 15:31:44--------------------------------------------------- -----------------------------------------------------------------------*/ -TYPEINIT1(SwXFootnote, SwClient); - -SwXFootnote::SwXFootnote(sal_Bool bEndnote) : - SwXText(0, CURSOR_FOOTNOTE), - aLstnrCntnr( (text::XTextContent*)this), - pFmtFtn(0), - m_bIsDescriptor(sal_True), - m_bIsEndnote(bEndnote) +SwXFootnote::SwXFootnote(const bool bEndnote) + : SwXText(0, CURSOR_FOOTNOTE) + , m_pImpl( new SwXFootnote::Impl(*this, 0, 0, bEndnote) ) { - } /*-- 10.12.98 15:31:45--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXFootnote::SwXFootnote(SwDoc* _pDoc, const SwFmtFtn& rFmt) : - SwXText(_pDoc, CURSOR_FOOTNOTE), - aLstnrCntnr( (text::XTextContent*)this), - pFmtFtn(&rFmt), - m_bIsDescriptor(sal_False), - m_bIsEndnote(rFmt.IsEndNote()) +SwXFootnote::SwXFootnote(SwDoc & rDoc, const SwFmtFtn& rFmt) + : SwXText(& rDoc, CURSOR_FOOTNOTE) + , m_pImpl( new SwXFootnote::Impl(*this, &rDoc, &rFmt, rFmt.IsEndNote()) ) { - GetDoc()->GetUnoCallBack()->Add(this); } /*-- 10.12.98 15:31:45--------------------------------------------------- -----------------------------------------------------------------------*/ SwXFootnote::~SwXFootnote() { +} + +SwXFootnote * +SwXFootnote::GetXFootnote( + SwModify const& /*rUnoCB*/, SwFmtFtn const& /*rFootnoteFmt*/) +{ + // re-use existing SwXFootnote + // #i105557#: do not iterate over the registered clients: race condition + // to do this properly requires the SwXFootnote to register at the + // SwFmtFtn directly, not at the unocallback + // also this function must return a uno Reference! +#if 0 + SwClientIter aIter( rUnoCB ); + SwXFootnote::Impl * pXFootnote = static_cast<SwXFootnote::Impl*>( + aIter.First( TYPE( SwXFootnote::Impl ))); + while (pXFootnote) + { + SwDoc *const pDoc = pXFootnote->m_rThis.GetDoc(); + if (pDoc) + { + SwFmtFtn const*const pFtn = pXFootnote->GetFootnoteFormat(); + if (pFtn == &rFootnoteFmt) + { + return & pXFootnote->m_rThis; + } + } + pXFootnote = static_cast<SwXFootnote::Impl*>(aIter.Next()); + } +#endif + return 0; +} + +SwXFootnote * +SwXFootnote::CreateXFootnote(SwDoc & rDoc, SwFmtFtn const& rFootnoteFmt) +{ + SwXFootnote *const pXFootnote( + GetXFootnote(*rDoc.GetUnoCallBack(), rFootnoteFmt)); + return (pXFootnote) + ? pXFootnote + : new SwXFootnote(rDoc, rFootnoteFmt); +} + +/* -----------------------------13.03.00 12:15-------------------------------- + ---------------------------------------------------------------------------*/ +const uno::Sequence< sal_Int8 > & SwXFootnote::getUnoTunnelId() +{ + static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); + return aSeq; } -/* -----------------------------21.03.00 15:39-------------------------------- +/* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Type > SAL_CALL SwXFootnote::getTypes( ) throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXFootnote::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - uno::Sequence< uno::Type > aFtnTypes = SwXFootnoteBaseClass::getTypes(); - uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); + const sal_Int64 nRet( ::sw::UnoTunnelImpl<SwXFootnote>(rId, this) ); + return (nRet) ? nRet : SwXText::getSomething(rId); +} - long nIndex = aFtnTypes.getLength(); - aFtnTypes.realloc( aFtnTypes.getLength() + aTextTypes.getLength()); +/* -----------------------------06.04.00 16:36-------------------------------- - uno::Type* pFtnTypes = aFtnTypes.getArray(); - const uno::Type* pTextTypes = aTextTypes.getConstArray(); - for(long nPos = 0; nPos < aTextTypes.getLength(); nPos++) - pFtnTypes[nIndex++] = pTextTypes[nPos]; + ---------------------------------------------------------------------------*/ +OUString SAL_CALL +SwXFootnote::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXFootnote"); +} - return aFtnTypes; +/* -----------------------------06.04.00 16:36-------------------------------- + + ---------------------------------------------------------------------------*/ +static char const*const g_ServicesFootnote[] = +{ + "com.sun.star.text.TextContent", + "com.sun.star.text.Footnote", + "com.sun.star.text.Text", + "com.sun.star.text.Endnote", // NB: only supported for endnotes! +}; +static const size_t g_nServicesEndnote( + sizeof(g_ServicesFootnote)/sizeof(g_ServicesFootnote[0])); +static const size_t g_nServicesFootnote( g_nServicesEndnote - 1 ); // NB: omit! + +sal_Bool SAL_CALL SwXFootnote::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return ::sw::SupportsServiceImpl( + (m_pImpl->m_bIsEndnote) ? g_nServicesEndnote : g_nServicesFootnote, + g_ServicesFootnote, rServiceName); +} + +uno::Sequence< OUString > SAL_CALL +SwXFootnote::getSupportedServiceNames() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return ::sw::GetSupportedServiceNamesImpl( + (m_pImpl->m_bIsEndnote) ? g_nServicesEndnote : g_nServicesFootnote, + g_ServicesFootnote); } /* -----------------------------21.03.00 15:39-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< sal_Int8 > SAL_CALL SwXFootnote::getImplementationId( ) throw(uno::RuntimeException) +uno::Sequence< uno::Type > SAL_CALL +SwXFootnote::getTypes() throw (uno::RuntimeException) +{ + const uno::Sequence< uno::Type > aTypes = SwXFootnote_Base::getTypes(); + const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); + return ::comphelper::concatSequences(aTypes, aTextTypes); +} + +/* -----------------------------21.03.00 15:39-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< sal_Int8 > SAL_CALL +SwXFootnote::getImplementationId() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); static uno::Sequence< sal_Int8 > aId( 16 ); @@ -176,37 +299,49 @@ uno::Sequence< sal_Int8 > SAL_CALL SwXFootnote::getImplementationId( ) throw(un /* -----------------------------21.03.00 15:46-------------------------------- ---------------------------------------------------------------------------*/ -uno::Any SAL_CALL SwXFootnote::queryInterface( const uno::Type& aType ) throw(uno::RuntimeException) +uno::Any SAL_CALL +SwXFootnote::queryInterface(const uno::Type& rType) +throw (uno::RuntimeException) { - uno::Any aRet = SwXFootnoteBaseClass::queryInterface(aType); - if(aRet.getValueType() == ::getCppuVoidType() ) - aRet = SwXText::queryInterface(aType); - return aRet; + const uno::Any ret = SwXFootnote_Base::queryInterface(rType); + return (ret.getValueType() == ::getCppuVoidType()) + ? SwXText::queryInterface(rType) + : ret; } /*-- 10.12.98 15:31:47--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXFootnote::getLabel(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXFootnote::getLabel() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - String sRet; - const SwFmtFtn* pFmt = SwXFootnote::FindFmt(); + + ::rtl::OUString sRet; + SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat(); if(pFmt) + { sRet = pFmt->GetNumStr(); - else if(m_bIsDescriptor) - return m_sLabel; + } + else if (m_pImpl->m_bIsDescriptor) + { + sRet = m_pImpl->m_sLabel; + } else + { throw uno::RuntimeException(); + } return sRet; } + /*-- 10.12.98 15:31:48--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::setLabel(const OUString& aLabel) throw( uno::RuntimeException ) +void SAL_CALL +SwXFootnote::setLabel(const OUString& aLabel) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwFmtFtn* pFmt = FindFmt(); + + SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat(); if(pFmt) { const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); @@ -216,297 +351,292 @@ void SwXFootnote::setLabel(const OUString& aLabel) throw( uno::RuntimeException SwPaM aPam(rTxtNode, *pTxtFtn->GetStart()); GetDoc()->SetCurFtn(aPam, aLabel, pFmt->GetNumber(), pFmt->IsEndNote()); } - else if(m_bIsDescriptor) - m_sLabel = String(aLabel); + else if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_sLabel = String(aLabel); + } else + { throw uno::RuntimeException(); - + } } + /* -----------------18.02.99 13:32------------------- * * --------------------------------------------------*/ -void SwXFootnote::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXFootnote::attach(const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - if(!m_bIsDescriptor) + vos::OGuard aGuard(Application::GetSolarMutex()); + + if (!m_pImpl->m_bIsDescriptor) + { throw uno::RuntimeException(); - uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) + } + const uno::Reference<lang::XUnoTunnel> xRangeTunnel( + xTextRange, uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel); + SwDoc *const pNewDoc = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pNewDoc) { - 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* pNewDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; - if(pNewDoc) + + SwUnoInternalPaM aPam(*pNewDoc); + //das muss jetzt sal_True liefern + ::sw::XTextRangeToSwPaM(aPam, xTextRange); + + UnoActionContext aCont(pNewDoc); + pNewDoc->DeleteAndJoin(aPam); + aPam.DeleteMark(); + SwFmtFtn aFootNote(m_pImpl->m_bIsEndnote); + if (m_pImpl->m_sLabel.getLength()) { - SwUnoInternalPaM aPam(*pNewDoc); - //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); - - UnoActionContext aCont(pNewDoc); - SwTxtAttr* pTxtAttr = 0; - pNewDoc->DeleteAndJoin(aPam); - aPam.DeleteMark(); - SwFmtFtn aFootNote(m_bIsEndnote); - if(m_sLabel.Len()) - aFootNote.SetNumStr(m_sLabel); - - SwXTextCursor const*const pTextCursor( - dynamic_cast<SwXTextCursor*>(pCursor)); - const bool bForceExpandHints( (pTextCursor) - ? pTextCursor->IsAtEndOfMeta() : false ); - const SetAttrMode nInsertFlags = (bForceExpandHints) - ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND - : nsSetAttrMode::SETATTR_DEFAULT; - - pNewDoc->InsertPoolItem(aPam, aFootNote, nInsertFlags); - - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( - aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FTN ); - - if(pTxtAttr) + aFootNote.SetNumStr(m_pImpl->m_sLabel); + } + + SwXTextCursor const*const pTextCursor( + dynamic_cast<SwXTextCursor*>(pCursor)); + const bool bForceExpandHints( (pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND + : nsSetAttrMode::SETATTR_DEFAULT; + + pNewDoc->InsertPoolItem(aPam, aFootNote, nInsertFlags); + + SwTxtFtn *const pTxtAttr = static_cast<SwTxtFtn*>( + aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( + aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FTN )); + + if (pTxtAttr) + { + const SwFmtFtn& rFtn = pTxtAttr->GetFtn(); + m_pImpl->m_pFmtFtn = &rFtn; + pNewDoc->GetUnoCallBack()->Add(m_pImpl.get()); + // force creation of sequence id - is used for references + if (pNewDoc->IsInReading()) + { + pTxtAttr->SetSeqNo(pNewDoc->GetFtnIdxs().Count()); + } + else { - const SwFmtFtn& rFtn = pTxtAttr->GetFtn(); - pFmtFtn = &rFtn; - pNewDoc->GetUnoCallBack()->Add(this); - //force creation of sequence id - is used for references - if(pNewDoc->IsInReading()) - ((SwTxtFtn*)pTxtAttr)->SetSeqNo(pNewDoc->GetFtnIdxs().Count()); - else - ((SwTxtFtn*)pTxtAttr)->SetSeqRefNo(); + pTxtAttr->SetSeqRefNo(); } - m_bIsDescriptor = sal_False; - SetDoc(pNewDoc); } - else - throw lang::IllegalArgumentException(); + m_pImpl->m_bIsDescriptor = sal_False; + SetDoc(pNewDoc); } -/*-- 10.12.98 15:31:48--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXFootnote::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - attachToRange( xTextRange ); -} /*-- 10.12.98 15:31:48--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXFootnote::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXFootnote::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > aRef; - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) - { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - SwPaM aPam( pTxtFtn->GetTxtNode(), *pTxtFtn->GetStart() ); - SwPosition aMark( *aPam.Start() ); - aPam.SetMark(); - aPam.GetMark()->nContent++; - aRef = SwXTextRange::CreateTextRangeFromPosition((SwDoc*)GetDoc(), *aPam.Start(), aPam.End()); - } - else - throw uno::RuntimeException(); - return aRef; + + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + SwPaM aPam( pTxtFtn->GetTxtNode(), *pTxtFtn->GetStart() ); + SwPosition aMark( *aPam.Start() ); + aPam.SetMark(); + aPam.GetMark()->nContent++; + const uno::Reference< text::XTextRange > xRet = + SwXTextRange::CreateXTextRange(*GetDoc(), *aPam.Start(), aPam.End()); + return xRet; } /*-- 10.12.98 15:31:49--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL SwXFootnote::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) - { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - DBG_ASSERT(pTxtFtn, "kein TextNode?"); - SwTxtNode& rTxtNode = (SwTxtNode&)pTxtFtn->GetTxtNode(); - xub_StrLen nPos = *pTxtFtn->GetStart(); - SwPaM aPam(rTxtNode, nPos, rTxtNode, nPos+1 ); - GetDoc()->DeleteAndJoin( aPam ); - } - else - throw uno::RuntimeException(); + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + DBG_ASSERT(pTxtFtn, "no TextNode?"); + SwTxtNode& rTxtNode = const_cast<SwTxtNode&>(pTxtFtn->GetTxtNode()); + const xub_StrLen nPos = *pTxtFtn->GetStart(); + SwPaM aPam(rTxtNode, nPos, rTxtNode, nPos+1); + GetDoc()->DeleteAndJoin( aPam ); } + /*-- 10.12.98 15:31:49--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL +SwXFootnote::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetFootnoteFormat()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 10.12.98 15:31:50--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL +SwXFootnote::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetFootnoteFormat() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } + /* -----------------06.05.99 15:31------------------- * * --------------------------------------------------*/ const SwStartNode *SwXFootnote::GetStartNode() const { - const SwStartNode *pSttNd = 0; - const SwFmtFtn* pFmt = FindFmt(); + SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat(); if(pFmt) { const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); if( pTxtFtn ) - pSttNd = pTxtFtn->GetStartNode()->GetNode().GetStartNode(); + { + return pTxtFtn->GetStartNode()->GetNode().GetStartNode(); + } } - return pSttNd; + return 0; } -uno::Reference< text::XTextCursor > SwXFootnote::createCursor() throw ( uno::RuntimeException) +uno::Reference< text::XTextCursor > +SwXFootnote::CreateCursor() throw (uno::RuntimeException) { return createTextCursor(); } + /*-- 10.12.98 15:31:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXFootnote::createTextCursor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXFootnote::createTextCursor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > aRef; - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) - { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - SwPosition aPos( *pTxtFtn->GetStartNode() ); - SwXTextCursor* pXCrsr = new SwXTextCursor(this, aPos, CURSOR_FOOTNOTE, GetDoc()); - aRef = (text::XWordCursor*)pXCrsr; - SwUnoCrsr* pUnoCrsr = pXCrsr->GetCrsr(); - pUnoCrsr->Move(fnMoveForward, fnGoNode); - } - else - throw uno::RuntimeException(); - return aRef; + + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + SwPosition aPos( *pTxtFtn->GetStartNode() ); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE, aPos); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); + pUnoCrsr->Move(fnMoveForward, fnGoNode); + const uno::Reference< text::XTextCursor > xRet = + static_cast<text::XWordCursor*>(pXCursor); + return xRet; } + /*-- 10.12.98 15:31:51--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXFootnote::createTextCursorByRange( - const uno::Reference< text::XTextRange > & aTextPosition) - throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXFootnote::createTextCursorByRange( + const uno::Reference< text::XTextRange > & xTextPosition) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwFmtFtn* pFmt = FindFmt(); - if( !pFmt ) - throw uno::RuntimeException(); - uno::Reference< text::XTextCursor > aRef; + + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + SwUnoInternalPaM aPam(*GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, aTextPosition)) + if (!::sw::XTextRangeToSwPaM(aPam, xTextPosition)) { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - const SwNode* pFtnStartNode = &pTxtFtn->GetStartNode()->GetNode(); - - const SwNode* pStart = aPam.GetNode()->FindFootnoteStartNode(); - if( pStart != pFtnStartNode ) - throw uno::RuntimeException(); - - aRef = (text::XWordCursor*)new SwXTextCursor(this , *aPam.GetPoint(), CURSOR_FOOTNOTE, GetDoc(), aPam.GetMark()); + throw uno::RuntimeException(); } - else + + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + SwNode const*const pFtnStartNode = &pTxtFtn->GetStartNode()->GetNode(); + + const SwNode* pStart = aPam.GetNode()->FindFootnoteStartNode(); + if (pStart != pFtnStartNode) + { throw uno::RuntimeException(); - return aRef; + } + + const uno::Reference< text::XTextCursor > xRet = + static_cast<text::XWordCursor*>( + new SwXTextCursor(*GetDoc(), this, CURSOR_FOOTNOTE, + *aPam.GetPoint(), aPam.GetMark())); + return xRet; } + /*-- 13.06.00 14:28:23--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXFootnote::createEnumeration() throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXFootnote::createEnumeration() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< container::XEnumeration > aRef; - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) - { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); - SwPosition aPos( *pTxtFtn->GetStartNode() ); - SwXTextCursor* pXCrsr = new SwXTextCursor(this, aPos, CURSOR_FOOTNOTE, GetDoc()); - SwUnoCrsr* pUnoCrsr = pXCrsr->GetCrsr(); - pUnoCrsr->Move(fnMoveForward, fnGoNode); - aRef = new SwXParagraphEnumeration(this, pUnoCrsr, CURSOR_FOOTNOTE); - } - return aRef; + + SwFmtFtn const& rFmt( m_pImpl->GetFootnoteFormatOrThrow() ); + + SwTxtFtn const*const pTxtFtn = rFmt.GetTxtFtn(); + SwPosition aPos( *pTxtFtn->GetStartNode() ); + ::std::auto_ptr<SwUnoCrsr> pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); + const uno::Reference< container::XEnumeration > xRet = + new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FOOTNOTE); + return xRet; } + /*-- 13.06.00 14:28:24--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXFootnote::getElementType( ) throw(uno::RuntimeException) +uno::Type SAL_CALL SwXFootnote::getElementType() throw (uno::RuntimeException) { - return ::getCppuType(static_cast<uno::Reference<XTextRange>*>(0)); + return text::XTextRange::static_type(); } /*-- 13.06.00 14:28:24--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXFootnote::hasElements( ) throw(uno::RuntimeException) +sal_Bool SAL_CALL SwXFootnote::hasElements() throw (uno::RuntimeException) { return sal_True; } -/* -----------------------------07.01.00 12:39-------------------------------- - ---------------------------------------------------------------------------*/ -void SwXFootnote::Invalidate() -{ - if(GetRegisteredIn()) - { - ((SwModify*)GetRegisteredIn())->Remove(this); - pFmtFtn = 0; - aLstnrCntnr.Disposing(); - SetDoc(0); - } -} -/* -----------------18.01.99 09:12------------------- - * - * --------------------------------------------------*/ -void SwXFootnote::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - switch( pOld ? pOld->Which() : 0 ) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - case RES_FMT_CHG: - // wurden wir an das neue umgehaengt und wird das alte geloscht? - if( ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() && - ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR() ) - Invalidate(); - break; - case RES_FOOTNOTE_DELETED: - if( (void*)pFmtFtn == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - } -} /*-- 11.09.00 13:12:03--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXFootnote::getPropertySetInfo( ) - throw(uno::RuntimeException) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXFootnote::getPropertySetInfo() +throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_FOOTNOTE)->getPropertySetInfo(); - return xRef; + vos::OGuard g(Application::GetSolarMutex()); + static uno::Reference< beans::XPropertySetInfo > xRet = + aSwMapProvider.GetPropertySet(PROPERTY_MAP_FOOTNOTE) + ->getPropertySetInfo(); + return xRet; } + /*-- 11.09.00 13:12:04--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::setPropertyValue( const ::rtl::OUString&, - const uno::Any& ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::setPropertyValue(const ::rtl::OUString&, const uno::Any&) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { //no values to be set throw lang::IllegalArgumentException(); @@ -514,28 +644,34 @@ void SwXFootnote::setPropertyValue( const ::rtl::OUString&, /*-- 11.09.00 13:12:04--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXFootnote::getPropertyValue( const OUString& rPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +uno::Any SAL_CALL +SwXFootnote::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + uno::Any aRet; - if(!SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) + if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName)) { - if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_START_REDLINE))|| - rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_END_REDLINE))) + if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_START_REDLINE)) || + rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_END_REDLINE))) { //redline can only be returned if it's a living object - if(!m_bIsDescriptor) + if (!m_pImpl->m_bIsDescriptor) + { aRet = SwXText::getPropertyValue(rPropertyName); + } } - else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_REFERENCE_ID))) + else if (rPropertyName.equalsAsciiL( + SW_PROP_NAME(UNO_NAME_REFERENCE_ID))) { - const SwFmtFtn* pFmt = FindFmt(); - if(pFmt) + SwFmtFtn const*const pFmt = m_pImpl->GetFootnoteFormat(); + if (pFmt) { - const SwTxtFtn* pTxtFtn = pFmt->GetTxtFtn(); + SwTxtFtn const*const pTxtFtn = pFmt->GetTxtFtn(); DBG_ASSERT(pTxtFtn, "no TextNode?"); - aRet <<= (sal_Int16)pTxtFtn->GetSeqRefNo(); + aRet <<= static_cast<sal_Int16>(pTxtFtn->GetSeqRefNo()); } } else @@ -547,37 +683,51 @@ uno::Any SwXFootnote::getPropertyValue( const OUString& rPropertyName ) } return aRet; } + /*-- 11.09.00 13:12:04--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXFootnote::addPropertyChangeListener( const OUString& /*aPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXFootnote::addPropertyChangeListener(): not implemented"); } -/*-- 11.09.00 13:12:04--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXFootnote::removePropertyChangeListener( const OUString& /*aPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXFootnote::removePropertyChangeListener(): not implemented"); } -/*-- 11.09.00 13:12:04--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXFootnote::addVetoableChangeListener( const OUString& /*PropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXFootnote::addVetoableChangeListener(): not implemented"); } -/*-- 11.09.00 13:12:05--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXFootnote::removeVetoableChangeListener( const OUString& /*PropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXFootnote::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXFootnote::removeVetoableChangeListener(): not implemented"); } - diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 41643101c1..19dda1dd91 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -31,21 +31,21 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/container/XIndexReplace.hpp> +#include <com/sun/star/frame/XModel.hpp> +#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/text/XTextDocument.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> -#ifndef _CMDID_H + +#include <hints.hxx> #include <cmdid.h> -#endif #include <swtypes.hxx> #include <shellres.hxx> #include <viewsh.hxx> @@ -56,54 +56,82 @@ #include <poolfmt.hrc> #endif #include <pagedesc.hxx> +#include <fmtcntnt.hxx> #include <unomap.hxx> -#include <unoobj.hxx> +#include <unotextrange.hxx> +#include <unotextcursor.hxx> +#include <unosection.hxx> #include <doctxm.hxx> #include <txttxmrk.hxx> #include <unocrsr.hxx> #include <unostyle.hxx> #include <ndtxt.hxx> #include <unoidx.hxx> -#ifndef _DOCSH_HXX //autogen #include <docsh.hxx> -#endif #include <chpfld.hxx> #include <SwStyleNameMapper.hxx> +#include <unoevtlstnr.hxx> + using namespace ::com::sun::star; using ::rtl::OUString; //----------------------------------------------------------------------------- -String lcl_AnyToString(uno::Any rVal) throw(lang::IllegalArgumentException) +static OUString +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 +161,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 +183,287 @@ 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); + } } } +/* -----------------13.09.99 16:39------------------- + + --------------------------------------------------*/ +typedef ::cppu::WeakImplHelper2 +< lang::XServiceInfo +, container::XIndexReplace +> SwXDocumentIndexStyleAccess_Base; + +class SwXDocumentIndex::StyleAccess_Impl + : public SwXDocumentIndexStyleAccess_Base +{ + +private: + /// can be destroyed threadsafely, so no UnoImplPtr here + ::rtl::Reference<SwXDocumentIndex> m_xParent; + + virtual ~StyleAccess_Impl(); + +public: + StyleAccess_Impl(SwXDocumentIndex& rParentIdx); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL + supportsService(const ::rtl::OUString& rServiceName) + throw (uno::RuntimeException); + virtual uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (uno::RuntimeException); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException); + virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) + throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException); + + // XIndexReplace + virtual void SAL_CALL + replaceByIndex(sal_Int32 Index, const uno::Any& rElement) + throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, + lang::WrappedTargetException, uno::RuntimeException); + +}; + +/* -----------------13.09.99 16:39------------------- + + --------------------------------------------------*/ +typedef ::cppu::WeakImplHelper2 +< lang::XServiceInfo +, container::XIndexReplace +> SwXDocumentIndexTokenAccess_Base; + +class SwXDocumentIndex::TokenAccess_Impl + : public SwXDocumentIndexTokenAccess_Base +{ + +private: + /// can be destroyed threadsafely, so no UnoImplPtr here + ::rtl::Reference<SwXDocumentIndex> m_xParent; + + virtual ~TokenAccess_Impl(); + +public: + + TokenAccess_Impl(SwXDocumentIndex& rParentIdx); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL + supportsService(const ::rtl::OUString& rServiceName) + throw (uno::RuntimeException); + virtual uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (uno::RuntimeException); + + // XElementAccess + virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException); + virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) + throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException); + + // XIndexReplace + virtual void SAL_CALL + replaceByIndex(sal_Int32 Index, const uno::Any& rElement) + throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, + lang::WrappedTargetException, uno::RuntimeException); + +}; + + /****************************************************************** * 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_Index(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_Index(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 +475,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 +1006,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 +1103,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 TokenAccess_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 StyleAccess_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 +1164,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 +1213,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,287 +1235,468 @@ 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::CreateXDocumentIndexMark( + *m_pImpl->m_pDoc, + *const_cast<SwTOXType*>(pType), *pMark); } - 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 - SwXTextRange::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::CreateTextRangeFromPosition(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(); + } } /****************************************************************** * SwXDocumentIndexMark ******************************************************************/ +/* -----------------21.04.99 09:36------------------- + * + * --------------------------------------------------*/ +static sal_uInt16 +lcl_TypeToPropertyMap_Mark(const TOXTypes eType) +{ + switch (eType) + { + case TOX_INDEX: return PROPERTY_MAP_INDEX_MARK; + case TOX_CONTENT: return PROPERTY_MAP_CNTIDX_MARK; + //case TOX_USER: + default: + return PROPERTY_MAP_USER_MARK; + } +} + +class SwXDocumentIndexMark::Impl + : public SwClient +{ + +public: + + SfxItemPropertySet const& m_rPropSet; + const TOXTypes m_eTOXType; + SwEventListenerContainer m_ListenerContainer; + bool m_bIsDescriptor; + SwDepend m_TypeDepend; + const SwTOXMark * m_pTOXMark; + SwDoc * m_pDoc; + + sal_Bool m_bMainEntry; + sal_uInt16 m_nLevel; + OUString m_sAltText; + OUString m_sPrimaryKey; + OUString m_sSecondaryKey; + OUString m_sTextReading; + OUString m_sPrimaryKeyReading; + OUString m_sSecondaryKeyReading; + OUString m_sUserIndexName; + + Impl( SwXDocumentIndexMark & rThis, + SwDoc *const pDoc, + const enum TOXTypes eType, + SwTOXType *const pType, SwTOXMark const*const pMark) + : SwClient(const_cast<SwTOXMark*>(pMark)) + , m_rPropSet( + *aSwMapProvider.GetPropertySet(lcl_TypeToPropertyMap_Mark(eType))) + , m_eTOXType(eType) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIsDescriptor(0 == pMark) + , m_TypeDepend(this, pType) + , m_pTOXMark(pMark) + , m_pDoc(pDoc) + , m_bMainEntry(sal_False) + , m_nLevel(0) + { + } + + SwTOXType * GetTOXType() const { + return static_cast<SwTOXType*>( + const_cast<SwModify *>(m_TypeDepend.GetRegisteredIn())); + } + + void Invalidate(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/* -----------------------------16.10.00 11:24-------------------------------- + + ---------------------------------------------------------------------------*/ +void SwXDocumentIndexMark::Impl::Invalidate() +{ + if (GetRegisteredIn()) + { + const_cast<SwModify*>(GetRegisteredIn())->Remove(this); + if (m_TypeDepend.GetRegisteredIn()) + { + const_cast<SwModify*>(m_TypeDepend.GetRegisteredIn())->Remove( + &m_TypeDepend); + } + } + m_ListenerContainer.Disposing(); + m_pDoc = 0; + m_pTOXMark = 0; +} + +/*-- 14.12.98 10:25:47--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXDocumentIndexMark::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn()) // removed => dispose + { + Invalidate(); + } +} + +/*-- 14.12.98 10:25:43--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndexMark::SwXDocumentIndexMark(const TOXTypes eToxType) + : m_pImpl( new SwXDocumentIndexMark::Impl(*this, 0, eToxType, 0, 0) ) +{ +} +/*-- 14.12.98 10:25:44--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndexMark::SwXDocumentIndexMark(SwDoc & rDoc, + SwTOXType & rType, SwTOXMark & rMark) + : m_pImpl( new SwXDocumentIndexMark::Impl(*this, &rDoc, rType.GetType(), + &rType, &rMark) ) +{ +} +/*-- 14.12.98 10:25:44--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXDocumentIndexMark::~SwXDocumentIndexMark() +{ +} + +uno::Reference<text::XDocumentIndexMark> +SwXDocumentIndexMark::CreateXDocumentIndexMark( + SwDoc & rDoc, SwTOXType & rType, SwTOXMark & rMark) +{ + // re-use existing SwXDocumentIndexMark + // NB: xmloff depends on this caching to generate ID from the address! + // #i105557#: do not iterate over the registered clients: race condition + uno::Reference< text::XDocumentIndexMark > xTOXMark(rMark.GetXTOXMark()); + if (!xTOXMark.is()) + { + SwXDocumentIndexMark *const pNew = + new SwXDocumentIndexMark(rDoc, rType, rMark); + xTOXMark.set(pNew); + rMark.SetXTOXMark(xTOXMark); + } + return xTOXMark; +} + /* -----------------------------10.03.00 18:02-------------------------------- ---------------------------------------------------------------------------*/ @@ -1202,55 +1708,62 @@ const uno::Sequence< sal_Int8 > & SwXDocumentIndexMark::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXDocumentIndexMark::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXDocumentIndexMark::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<SwXDocumentIndexMark>(rId, this); } -TYPEINIT1(SwXDocumentIndexMark, SwClient) -const sal_Char cBaseMark[] = "com.sun.star.text.BaseIndexMark"; -const sal_Char cContentMark[] = "com.sun.star.text.ContentIndexMark"; -const sal_Char cIdxMark[] = "com.sun.star.text.DocumentIndexMark"; -const sal_Char cIdxMarkAsian[] = "com.sun.star.text.DocumentIndexMarkAsian"; -const sal_Char cUserMark[] = "com.sun.star.text.UserIndexMark"; -const sal_Char cTextContent[] = "com.sun.star.text.TextContent"; +static const sal_Char cBaseMark[] = "com.sun.star.text.BaseIndexMark"; +static const sal_Char cContentMark[] = "com.sun.star.text.ContentIndexMark"; +static const sal_Char cIdxMark[] = "com.sun.star.text.DocumentIndexMark"; +static const sal_Char cIdxMarkAsian[] = "com.sun.star.text.DocumentIndexMarkAsian"; +static const sal_Char cUserMark[] = "com.sun.star.text.UserIndexMark"; +static const sal_Char cTextContent[] = "com.sun.star.text.TextContent"; + /* -----------------------------06.04.00 15:07-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXDocumentIndexMark::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndexMark::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXDocumentIndexMark"); } /* -----------------------------06.04.00 15:07-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXDocumentIndexMark::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) -{ - return !rServiceName.compareToAscii(cBaseMark)|| - !rServiceName.compareToAscii(cTextContent) || - (eType == TOX_USER && !rServiceName.compareToAscii(cUserMark)) || - (eType == TOX_CONTENT && !rServiceName.compareToAscii(cContentMark)) || - (eType == TOX_INDEX && !rServiceName.compareToAscii(cIdxMark)) || - (eType == TOX_INDEX && !rServiceName.compareToAscii(cIdxMarkAsian)); +sal_Bool SAL_CALL +SwXDocumentIndexMark::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + return rServiceName.equalsAscii(cBaseMark) + || rServiceName.equalsAscii(cTextContent) + || ((m_pImpl->m_eTOXType == TOX_USER) + && rServiceName.equalsAscii(cUserMark)) + || ((m_pImpl->m_eTOXType == TOX_CONTENT) + && rServiceName.equalsAscii(cContentMark)) + || ((m_pImpl->m_eTOXType == TOX_INDEX) + && rServiceName.equalsAscii(cIdxMark)) + || ((m_pImpl->m_eTOXType == TOX_INDEX) + && rServiceName.equalsAscii(cIdxMarkAsian)); } /* -----------------------------06.04.00 15:07-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXDocumentIndexMark::getSupportedServiceNames(void) throw( uno::RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndexMark::getSupportedServiceNames() throw (uno::RuntimeException) { - INT32 nCnt = (eType == TOX_INDEX) ? 4 : 3; + vos::OGuard g(Application::GetSolarMutex()); + + const sal_Int32 nCnt = (m_pImpl->m_eTOXType == TOX_INDEX) ? 4 : 3; uno::Sequence< OUString > aRet(nCnt); OUString* pArray = aRet.getArray(); pArray[0] = C2U(cBaseMark); pArray[1] = C2U(cTextContent); - switch(eType) + switch (m_pImpl->m_eTOXType) { case TOX_USER: pArray[2] = C2U(cUserMark); @@ -1268,97 +1781,47 @@ uno::Sequence< OUString > SwXDocumentIndexMark::getSupportedServiceNames(void) t } return aRet; } -/*-- 14.12.98 10:25:43--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXDocumentIndexMark::SwXDocumentIndexMark(TOXTypes eToxType) : - aLstnrCntnr( (text::XTextContent*)this), - aTypeDepend(this, 0), - m_pDoc(0), - m_pTOXMark(0), - bIsDescriptor(sal_True), - bMainEntry(sal_False), - eType(eToxType), - nLevel(0) -{ - InitMap(eToxType); -} -/*-- 14.12.98 10:25:44--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXDocumentIndexMark::SwXDocumentIndexMark(const SwTOXType* pType, - const SwTOXMark* pMark, - SwDoc* pDc) : - aLstnrCntnr( (text::XTextContent*)this), - aTypeDepend(this, (SwTOXType*)pType), - m_pDoc(pDc), - m_pTOXMark(pMark), - bIsDescriptor(sal_False), - bMainEntry(sal_False), - eType(pType->GetType()), - nLevel(0) -{ - m_pDoc->GetUnoCallBack()->Add(this); - InitMap(eType); -} -/*-- 14.12.98 10:25:44--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXDocumentIndexMark::~SwXDocumentIndexMark() -{ - -} -/* -----------------21.04.99 09:36------------------- - * - * --------------------------------------------------*/ -void SwXDocumentIndexMark::InitMap(TOXTypes eToxType) -{ - sal_uInt16 nMapId = PROPERTY_MAP_USER_MARK; //case TOX_USER: - switch( eToxType ) - { - case TOX_INDEX: - nMapId = PROPERTY_MAP_INDEX_MARK ; - break; - case TOX_CONTENT: - nMapId = PROPERTY_MAP_CNTIDX_MARK; - break; - //case TOX_USER: - default: - ; - } - m_pPropSet = aSwMapProvider.GetPropertySet(nMapId); -} /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXDocumentIndexMark::getMarkEntry(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndexMark::getMarkEntry() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); + OUString sRet; - if(pType && m_pTOXMark) + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) + { + sRet = OUString(m_pImpl->m_pTOXMark->GetAlternativeText()); + } + else if (m_pImpl->m_bIsDescriptor) { - sRet = OUString(m_pTOXMark->GetAlternativeText()); + sRet = m_pImpl->m_sAltText; } - else if(bIsDescriptor) - sRet = sAltText; else + { throw uno::RuntimeException(); + } return sRet; } /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - if(pType && m_pTOXMark) + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) { - SwTOXMark aMark(*m_pTOXMark); + SwTOXMark aMark(*m_pImpl->m_pTOXMark); aMark.SetAlternativeText(rIndexEntry); - const SwTxtTOXMark* pTxtMark = m_pTOXMark->GetTxtTOXMark(); + SwTxtTOXMark const*const pTxtMark = + m_pImpl->m_pTOXMark->GetTxtTOXMark(); SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); aPam.SetMark(); if(pTxtMark->GetEnd()) @@ -1368,9 +1831,9 @@ void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno: else aPam.GetPoint()->nContent++; - //die alte Marke loeschen - m_pDoc->DeleteTOXMark(m_pTOXMark); - m_pTOXMark = 0; + // delete old mark + m_pImpl->m_pDoc->DeleteTOXMark(m_pImpl->m_pTOXMark); + m_pImpl->m_pTOXMark = 0; SwTxtAttr* pTxtAttr = 0; sal_Bool bInsAtPos = aMark.IsAlternativeText(); @@ -1379,311 +1842,378 @@ void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno: if( bInsAtPos ) { SwPaM aTmp( *pStt ); - m_pDoc->InsertPoolItem( aTmp, aMark, 0 ); + m_pImpl->m_pDoc->InsertPoolItem( aTmp, aMark, 0 ); pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttrForCharAt( pStt->nContent.GetIndex()-1, RES_TXTATR_TOXMARK); } else if( *pEnd != *pStt ) { - m_pDoc->InsertPoolItem( aPam, aMark, + m_pImpl->m_pDoc->InsertPoolItem( aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND ); pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( pStt->nContent, RES_TXTATR_TOXMARK); } - //und sonst - Marke geloescht? if(pTxtAttr) - m_pTOXMark = &pTxtAttr->GetTOXMark(); + { + m_pImpl->m_pTOXMark = &pTxtAttr->GetTOXMark(); + } } - else if(bIsDescriptor) + else if (m_pImpl->m_bIsDescriptor) { - sAltText = rIndexEntry; + m_pImpl->m_sAltText = rIndexEntry; } else + { throw uno::RuntimeException(); + } } + /* -----------------18.02.99 13:40------------------- * * --------------------------------------------------*/ -void SwXDocumentIndexMark::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::attach( + const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!bIsDescriptor) - throw uno::RuntimeException(); - uno::Reference<XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) + if (!m_pImpl->m_bIsDescriptor) { - 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 uno::RuntimeException(); } - SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; + 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) + { + throw lang::IllegalArgumentException(); + } - if(pDoc ) + const SwTOXType* pTOXType = 0; + switch (m_pImpl->m_eTOXType) { - const SwTOXType* pTOXType = 0; - switch(eType) + case TOX_INDEX: + case TOX_CONTENT: + pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 ); + break; + case TOX_USER: { - case TOX_INDEX: - case TOX_CONTENT: - pTOXType = pDoc->GetTOXType( eType, 0 ); - break; - case TOX_USER: + if (!m_pImpl->m_sUserIndexName.getLength()) { - if(!sUserIndexName.Len()) - pTOXType = pDoc->GetTOXType( eType, 0 ); - else + pTOXType = pDoc->GetTOXType( m_pImpl->m_eTOXType, 0 ); + } + else + { + const sal_uInt16 nCount = + pDoc->GetTOXTypeCount(m_pImpl->m_eTOXType); + for (sal_uInt16 i = 0; i < nCount; i++) { - sal_uInt16 nCount = pDoc->GetTOXTypeCount( eType); - for(sal_uInt16 i = 0; i < nCount; i++) + SwTOXType const*const pTemp = + pDoc->GetTOXType( m_pImpl->m_eTOXType, i ); + if (m_pImpl->m_sUserIndexName == + OUString(pTemp->GetTypeName())) { - const SwTOXType* pTemp = pDoc->GetTOXType( eType, i ); - if(sUserIndexName == pTemp->GetTypeName()) - { - pTOXType = pTemp; - break; - } - } - if(!pTOXType) - { - SwTOXType aUserType(TOX_USER, sUserIndexName); - pTOXType = pDoc->InsertTOXType(aUserType); + pTOXType = pTemp; + break; } } + if (!pTOXType) + { + SwTOXType aUserType(TOX_USER, m_pImpl->m_sUserIndexName); + pTOXType = pDoc->InsertTOXType(aUserType); + } } - break; - - default: - ; } - if(!pTOXType) - throw lang::IllegalArgumentException(); - pDoc->GetUnoCallBack()->Add(this); - ((SwTOXType*)pTOXType)->Add(&aTypeDepend); - - SwUnoInternalPaM aPam(*pDoc); - //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); - SwTOXMark aMark (pTOXType); - if(sAltText.Len()) - aMark.SetAlternativeText(sAltText); - switch(eType) - { - case TOX_INDEX: - if(sPrimaryKey.Len()) - aMark.SetPrimaryKey(sPrimaryKey); - if(sSecondaryKey.Len()) - aMark.SetSecondaryKey(sSecondaryKey); - if(sTextReading.Len()) - aMark.SetTextReading(sTextReading); - if(sPrimaryKeyReading.Len()) - aMark.SetPrimaryKeyReading(sPrimaryKeyReading); - if(sSecondaryKeyReading.Len()) - aMark.SetSecondaryKeyReading(sSecondaryKeyReading); - aMark.SetMainEntry(bMainEntry); - break; - case TOX_USER: - case TOX_CONTENT: - if(USHRT_MAX != nLevel) - aMark.SetLevel(nLevel+1); - break; + break; - default: - ; - } - UnoActionContext aAction(pDoc); - sal_Bool bMark = *aPam.GetPoint() != *aPam.GetMark(); - // Marks ohne Alternativtext ohne selektierten Text koennen nicht eingefuegt werden, - // deshalb hier ein Leerzeichen - ob das die ideale Loesung ist? - if(!bMark && !aMark.GetAlternativeText().Len()) - aMark.SetAlternativeText( String(' ') ); - - SwXTextCursor const*const pTextCursor( - dynamic_cast<SwXTextCursor*>(pCursor)); - const bool bForceExpandHints( (!bMark && pTextCursor) - ? pTextCursor->IsAtEndOfMeta() : false ); - const SetAttrMode nInsertFlags = (bForceExpandHints) - ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND - | nsSetAttrMode::SETATTR_DONTEXPAND) - : nsSetAttrMode::SETATTR_DONTEXPAND; - - pDoc->InsertPoolItem(aPam, aMark, nInsertFlags); - if( bMark && *aPam.GetPoint() > *aPam.GetMark()) - aPam.Exchange(); + default: + break; + } + if (!pTOXType) + { + throw lang::IllegalArgumentException(); + } - SwTxtAttr* pTxtAttr = 0; - if( bMark ) - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( - aPam.GetPoint()->nContent, RES_TXTATR_TOXMARK ); - else - { - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( - aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_TOXMARK ); - } + SwUnoInternalPaM aPam(*pDoc); + //das muss jetzt sal_True liefern + ::sw::XTextRangeToSwPaM(aPam, xTextRange); + SwTOXMark aMark (pTOXType); + if (m_pImpl->m_sAltText.getLength()) + { + aMark.SetAlternativeText(m_pImpl->m_sAltText); + } + switch (m_pImpl->m_eTOXType) + { + case TOX_INDEX: + if (m_pImpl->m_sPrimaryKey.getLength()) + { + aMark.SetPrimaryKey(m_pImpl->m_sPrimaryKey); + } + if (m_pImpl->m_sSecondaryKey.getLength()) + { + aMark.SetSecondaryKey(m_pImpl->m_sSecondaryKey); + } + if (m_pImpl->m_sTextReading.getLength()) + { + aMark.SetTextReading(m_pImpl->m_sTextReading); + } + if (m_pImpl->m_sPrimaryKeyReading.getLength()) + { + aMark.SetPrimaryKeyReading(m_pImpl->m_sPrimaryKeyReading); + } + if (m_pImpl->m_sSecondaryKeyReading.getLength()) + { + aMark.SetSecondaryKeyReading(m_pImpl->m_sSecondaryKeyReading); + } + aMark.SetMainEntry(m_pImpl->m_bMainEntry); + break; + case TOX_USER: + case TOX_CONTENT: + if (USHRT_MAX != m_pImpl->m_nLevel) + { + aMark.SetLevel(m_pImpl->m_nLevel+1); + } + break; - if(pTxtAttr) - { - m_pTOXMark = &pTxtAttr->GetTOXMark(); - m_pDoc = pDoc; - bIsDescriptor = sal_False; - } - else - throw uno::RuntimeException(); + default: + break; + } + UnoActionContext aAction(pDoc); + const sal_Bool bMark = *aPam.GetPoint() != *aPam.GetMark(); + // Marks ohne Alternativtext ohne selektierten Text koennen nicht eingefuegt werden, + // deshalb hier ein Leerzeichen - ob das die ideale Loesung ist? + if (!bMark && !aMark.GetAlternativeText().Len()) + { + aMark.SetAlternativeText( String(' ') ); } -} -/*-- 14.12.98 10:25:45--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - attachToRange( xTextRange ); + SwXTextCursor const*const pTextCursor( + dynamic_cast<SwXTextCursor*>(pCursor)); + const bool bForceExpandHints( (!bMark && pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND + | nsSetAttrMode::SETATTR_DONTEXPAND) + : nsSetAttrMode::SETATTR_DONTEXPAND; + + pDoc->InsertPoolItem(aPam, aMark, nInsertFlags); + if (bMark && *aPam.GetPoint() > *aPam.GetMark()) + { + aPam.Exchange(); + } + + SwTxtAttr* pTxtAttr = 0; + if (bMark) + { + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( + aPam.GetPoint()->nContent, RES_TXTATR_TOXMARK ); + } + else + { + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( + aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_TOXMARK ); + } + + if (!pTxtAttr) + { + throw uno::RuntimeException(); + } + + m_pImpl->m_pTOXMark = &pTxtAttr->GetTOXMark(); + m_pImpl->m_pDoc = pDoc; + m_pImpl->m_bIsDescriptor = sal_False; + + const_cast<SwTOXMark*>(m_pImpl->m_pTOXMark)->Add(m_pImpl.get()); + const_cast<SwTOXType*>(pTOXType)->Add(&m_pImpl->m_TypeDepend); } + /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXDocumentIndexMark::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXDocumentIndexMark::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > aRet; - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - if(pType && m_pTOXMark) + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (!pType || !m_pImpl->m_pTOXMark) { - if( m_pTOXMark->GetTxtTOXMark() ) - { - const SwTxtTOXMark* pTxtMark = m_pTOXMark->GetTxtTOXMark(); - SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); - aPam.SetMark(); - if(pTxtMark->GetEnd()) - { - aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); - } - else - aPam.GetPoint()->nContent++; - uno::Reference< frame::XModel > xModel = m_pDoc->GetDocShell()->GetBaseModel(); - uno::Reference< text::XTextDocument > xTDoc(xModel, uno::UNO_QUERY); - aRet = new SwXTextRange(aPam, xTDoc->getText()); - } + throw uno::RuntimeException(); } - if(!aRet.is()) + if (!m_pImpl->m_pTOXMark->GetTxtTOXMark()) + { throw uno::RuntimeException(); - return aRet; + } + const SwTxtTOXMark* pTxtMark = m_pImpl->m_pTOXMark->GetTxtTOXMark(); + SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); + aPam.SetMark(); + if(pTxtMark->GetEnd()) + { + aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); + } + else + { + aPam.GetPoint()->nContent++; + } + const uno::Reference< frame::XModel > xModel = + m_pImpl->m_pDoc->GetDocShell()->GetBaseModel(); + const uno::Reference< text::XTextDocument > xTDoc(xModel, uno::UNO_QUERY); + const uno::Reference< text::XTextRange > xRet = + new SwXTextRange(aPam, xTDoc->getText()); + + return xRet; } + /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - if(pType && m_pTOXMark) + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) { - m_pDoc->DeleteTOXMark(m_pTOXMark); + m_pImpl->m_pDoc->DeleteTOXMark(m_pImpl->m_pTOXMark); } - else - throw uno::RuntimeException(); } /*-- 14.12.98 10:25:45--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::addEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::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); } /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::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(); + } } + /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXDocumentIndexMark::getPropertySetInfo(void) - throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXDocumentIndexMark::getPropertySetInfo() throw (uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + static uno::Reference< beans::XPropertySetInfo > xInfos[3]; int nPos = 0; - switch(eType) + switch (m_pImpl->m_eTOXType) { - case TOX_INDEX: nPos = 0; break; - case TOX_CONTENT: nPos = 1; break; - case TOX_USER: nPos = 2; break; + case TOX_INDEX: nPos = 0; break; + case TOX_CONTENT: nPos = 1; break; + case TOX_USER: nPos = 2; break; default: ; } if(!xInfos[nPos].is()) { - uno::Reference< beans::XPropertySetInfo > xInfo = m_pPropSet->getPropertySetInfo(); + const uno::Reference< beans::XPropertySetInfo > xInfo = + m_pImpl->m_rPropSet.getPropertySetInfo(); // extend PropertySetInfo! const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties(); xInfos[nPos] = new SfxExtItemPropertySetInfo( - aSwMapProvider.GetPropertyMapEntries(PROPERTY_MAP_PARAGRAPH_EXTENSIONS), + aSwMapProvider.GetPropertyMapEntries( + PROPERTY_MAP_PARAGRAPH_EXTENSIONS), aPropSeq ); } return xInfos[nPos]; } + /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, - const uno::Any& aValue) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::setPropertyValue( + const OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - 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 ) ); - if(pType && m_pTOXMark) { - SwDoc* pLocalDoc = m_pDoc; + 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)); + } + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) + { + SwDoc* pLocalDoc = m_pImpl->m_pDoc; - SwTOXMark aMark(*m_pTOXMark); + SwTOXMark aMark(*m_pImpl->m_pTOXMark); switch(pEntry->nWID) { case WID_ALT_TEXT: - aMark.SetAlternativeText(lcl_AnyToString(aValue)); + aMark.SetAlternativeText(lcl_AnyToString(rValue)); break; case WID_LEVEL: - aMark.SetLevel(Min( (sal_Int8) ( MAXLEVEL ), - (sal_Int8)(lcl_AnyToInt16(aValue)+1))); + aMark.SetLevel(Min( static_cast<sal_Int8>( MAXLEVEL ), + static_cast<sal_Int8>(lcl_AnyToInt16(rValue)+1))); break; case WID_PRIMARY_KEY : - aMark.SetPrimaryKey(lcl_AnyToString(aValue)); + aMark.SetPrimaryKey(lcl_AnyToString(rValue)); break; case WID_SECONDARY_KEY: - aMark.SetSecondaryKey(lcl_AnyToString(aValue)); + aMark.SetSecondaryKey(lcl_AnyToString(rValue)); break; case WID_MAIN_ENTRY: - aMark.SetMainEntry(lcl_AnyToBool(aValue)); + aMark.SetMainEntry(lcl_AnyToBool(rValue)); break; case WID_TEXT_READING: - aMark.SetTextReading(lcl_AnyToString(aValue)); + aMark.SetTextReading(lcl_AnyToString(rValue)); break; case WID_PRIMARY_KEY_READING: - aMark.SetPrimaryKeyReading(lcl_AnyToString(aValue)); + aMark.SetPrimaryKeyReading(lcl_AnyToString(rValue)); break; case WID_SECONDARY_KEY_READING: - aMark.SetSecondaryKeyReading(lcl_AnyToString(aValue)); + aMark.SetSecondaryKeyReading(lcl_AnyToString(rValue)); break; } - const SwTxtTOXMark* pTxtMark = m_pTOXMark->GetTxtTOXMark(); + SwTxtTOXMark const*const pTxtMark = + m_pImpl->m_pTOXMark->GetTxtTOXMark(); SwPaM aPam(pTxtMark->GetTxtNode(), *pTxtMark->GetStart()); aPam.SetMark(); if(pTxtMark->GetEnd()) @@ -1691,15 +2221,17 @@ void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, aPam.GetPoint()->nContent = *pTxtMark->GetEnd(); } else + { aPam.GetPoint()->nContent++; + } //delete the old mark - pLocalDoc->DeleteTOXMark(m_pTOXMark); - m_pTOXMark = 0; + pLocalDoc->DeleteTOXMark(m_pImpl->m_pTOXMark); + m_pImpl->m_pTOXMark = 0; sal_Bool bInsAtPos = aMark.IsAlternativeText(); - const SwPosition *pStt = aPam.Start(), - *pEnd = aPam.End(); + const SwPosition *pStt = aPam.Start(); + const SwPosition *pEnd = aPam.End(); SwTxtAttr* pTxtAttr = 0; if( bInsAtPos ) @@ -1716,99 +2248,120 @@ void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( pStt->nContent, RES_TXTATR_TOXMARK ); } - m_pDoc = pLocalDoc; + m_pImpl->m_pDoc = pLocalDoc; if(pTxtAttr) { - m_pTOXMark = &pTxtAttr->GetTOXMark(); - m_pDoc->GetUnoCallBack()->Add(this); - pType->Add(&aTypeDepend); + m_pImpl->m_pTOXMark = &pTxtAttr->GetTOXMark(); + const_cast<SwTOXMark*>(m_pImpl->m_pTOXMark)->Add(m_pImpl.get()); + pType->Add(&m_pImpl->m_TypeDepend); } } - else if(bIsDescriptor) + else if (m_pImpl->m_bIsDescriptor) { switch(pEntry->nWID) { case WID_ALT_TEXT: - sAltText = lcl_AnyToString(aValue); + m_pImpl->m_sAltText = lcl_AnyToString(rValue); break; case WID_LEVEL: { - sal_Int16 nVal = lcl_AnyToInt16(aValue); + const sal_Int16 nVal = lcl_AnyToInt16(rValue); if(nVal >= 0 && nVal < MAXLEVEL) - nLevel = nVal; + { + m_pImpl->m_nLevel = nVal; + } else + { throw lang::IllegalArgumentException(); + } } break; - case WID_PRIMARY_KEY : - sPrimaryKey = lcl_AnyToString(aValue); + case WID_PRIMARY_KEY: + m_pImpl->m_sPrimaryKey = lcl_AnyToString(rValue); break; case WID_SECONDARY_KEY: - sSecondaryKey = lcl_AnyToString(aValue); + m_pImpl->m_sSecondaryKey = lcl_AnyToString(rValue); break; case WID_TEXT_READING: - sTextReading = lcl_AnyToString(aValue); + m_pImpl->m_sTextReading = lcl_AnyToString(rValue); break; case WID_PRIMARY_KEY_READING: - sPrimaryKeyReading = lcl_AnyToString(aValue); + m_pImpl->m_sPrimaryKeyReading = lcl_AnyToString(rValue); break; case WID_SECONDARY_KEY_READING: - sSecondaryKeyReading = lcl_AnyToString(aValue); + m_pImpl->m_sSecondaryKeyReading = lcl_AnyToString(rValue); break; - case WID_USER_IDX_NAME : + case WID_USER_IDX_NAME: { - OUString sTmp(lcl_AnyToString(aValue)); + OUString sTmp(lcl_AnyToString(rValue)); lcl_ConvertTOUNameToUserName(sTmp); - sUserIndexName = sTmp; + m_pImpl->m_sUserIndexName = sTmp; } break; case WID_MAIN_ENTRY: - bMainEntry = lcl_AnyToBool(aValue); + m_pImpl->m_bMainEntry = lcl_AnyToBool(rValue); break; } } else + { throw uno::RuntimeException(); + } } + /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + uno::Any aRet; - SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); - 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(SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName, pEntry->nWID)) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast<cppu::OWeakObject *>(this)); + } + if (::sw::GetDefaultTextContentValue(aRet, rPropertyName, pEntry->nWID)) + { return aRet; - if(pType && m_pTOXMark) + } + + SwTOXType *const pType = m_pImpl->GetTOXType(); + if (pType && m_pImpl->m_pTOXMark) { switch(pEntry->nWID) { case WID_ALT_TEXT: - aRet <<= OUString(m_pTOXMark->GetAlternativeText()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetAlternativeText()); break; case WID_LEVEL: - aRet <<= (sal_Int16)(m_pTOXMark->GetLevel() - 1); + aRet <<= static_cast<sal_Int16>( + m_pImpl->m_pTOXMark->GetLevel() - 1); break; case WID_PRIMARY_KEY : - aRet <<= OUString(m_pTOXMark->GetPrimaryKey()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetPrimaryKey()); break; case WID_SECONDARY_KEY: - aRet <<= OUString(m_pTOXMark->GetSecondaryKey()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetSecondaryKey()); break; case WID_TEXT_READING: - aRet <<= OUString(m_pTOXMark->GetTextReading()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetTextReading()); break; case WID_PRIMARY_KEY_READING: - aRet <<= OUString(m_pTOXMark->GetPrimaryKeyReading()); + aRet <<= OUString(m_pImpl->m_pTOXMark->GetPrimaryKeyReading()); break; case WID_SECONDARY_KEY_READING: - aRet <<= OUString(m_pTOXMark->GetSecondaryKeyReading()); + aRet <<= OUString( + m_pImpl->m_pTOXMark->GetSecondaryKeyReading()); break; case WID_USER_IDX_NAME : { @@ -1819,179 +2372,158 @@ uno::Any SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName) break; case WID_MAIN_ENTRY: { - sal_Bool bTemp = m_pTOXMark->IsMainEntry(); - aRet.setValue(&bTemp, ::getBooleanCppuType()); + const sal_Bool bTemp = m_pImpl->m_pTOXMark->IsMainEntry(); + aRet <<= bTemp; } break; } } - else if(bIsDescriptor) + else if (m_pImpl->m_bIsDescriptor) { switch(pEntry->nWID) { case WID_ALT_TEXT: - aRet <<= OUString(sAltText); + aRet <<= m_pImpl->m_sAltText; break; case WID_LEVEL: - aRet <<= (sal_Int16)nLevel; + aRet <<= static_cast<sal_Int16>(m_pImpl->m_nLevel); break; - case WID_PRIMARY_KEY : - aRet <<= OUString(sPrimaryKey); + case WID_PRIMARY_KEY: + aRet <<= m_pImpl->m_sPrimaryKey; break; case WID_SECONDARY_KEY: - aRet <<= OUString(sSecondaryKey); + aRet <<= m_pImpl->m_sSecondaryKey; break; case WID_TEXT_READING: - aRet <<= OUString(sTextReading); + aRet <<= m_pImpl->m_sTextReading; break; case WID_PRIMARY_KEY_READING: - aRet <<= OUString(sPrimaryKeyReading); + aRet <<= m_pImpl->m_sPrimaryKeyReading; break; case WID_SECONDARY_KEY_READING: - aRet <<= OUString(sSecondaryKeyReading); + aRet <<= m_pImpl->m_sSecondaryKeyReading; break; case WID_USER_IDX_NAME : - aRet <<= OUString(sUserIndexName); + aRet <<= m_pImpl->m_sUserIndexName; break; case WID_MAIN_ENTRY: { - aRet.setValue(&bMainEntry, ::getBooleanCppuType()); + aRet <<= static_cast<sal_Bool>(m_pImpl->m_bMainEntry); } break; } } else + { throw uno::RuntimeException(); + } return aRet; } + /*-- 14.12.98 10:25:46--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::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, + "SwXDocumentIndexMark::addPropertyChangeListener(): not implemented"); } -/*-- 14.12.98 10:25:46--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::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, + "SwXDocumentIndexMark::removePropertyChangeListener(): not implemented"); } -/*-- 14.12.98 10:25:47--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::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, + "SwXDocumentIndexMark::addVetoableChangeListener(): not implemented"); } -/*-- 14.12.98 10:25:47--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXDocumentIndexMark::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXDocumentIndexMark::removeVetoableChangeListener(): not implemented"); } -/*-- 14.12.98 10:25:47--------------------------------------------------- + + +/****************************************************************** + * SwXDocumentIndexes + ******************************************************************/ +/*-- 05.05.99 13:14:59--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXDocumentIndexMark* SwXDocumentIndexMark::GetObject(SwTOXType* pType, - const SwTOXMark* pMark, SwDoc* pDoc) +SwXDocumentIndexes::SwXDocumentIndexes(SwDoc *const _pDoc) + : SwUnoCollection(_pDoc) { - SwClientIter aIter(*pType); - SwXDocumentIndexMark* pxMark = (SwXDocumentIndexMark*) - aIter.First(TYPE(SwXDocumentIndexMark)); - while( pxMark ) - { - if(pxMark->m_pTOXMark == pMark) - return pxMark; - pxMark = (SwXDocumentIndexMark*)aIter.Next(); - } - return new SwXDocumentIndexMark(pType, pMark, pDoc); } -/*-- 14.12.98 10:25:47--------------------------------------------------- +/*-- 05.05.99 13:15:00--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXDocumentIndexMark::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) +SwXDocumentIndexes::~SwXDocumentIndexes() { - switch( pOld ? pOld->Which() : 0 ) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - - case RES_FMT_CHG: - // wurden wir an das neue umgehaengt und wird das alte geloscht? - if( ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() && - ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR() ) - Invalidate(); - break; - case RES_TOXMARK_DELETED: - if( (void*)m_pTOXMark == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - } } -/* -----------------------------16.10.00 11:24-------------------------------- - ---------------------------------------------------------------------------*/ -void SwXDocumentIndexMark::Invalidate() -{ - if(GetRegisteredIn()) - { - ((SwModify*)GetRegisteredIn())->Remove(this); - if(aTypeDepend.GetRegisteredIn()) - ((SwModify*)aTypeDepend.GetRegisteredIn())->Remove(&aTypeDepend); - aLstnrCntnr.Disposing(); - m_pTOXMark = 0; - m_pDoc = 0; - } -} /* -----------------------------06.04.00 15:08-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXDocumentIndexes::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndexes::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXDocumentIndexes"); } -/* -----------------------------06.04.00 15:08-------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXDocumentIndexes::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +static char const*const g_ServicesDocumentIndexes[] = { - return C2U("com.sun.star.text.DocumentIndexes") == rServiceName; -} -/* -----------------------------06.04.00 15:08-------------------------------- + "com.sun.star.text.DocumentIndexes", +}; +static const size_t g_nServicesDocumentIndexes( + sizeof(g_ServicesDocumentIndexes)/sizeof(g_ServicesDocumentIndexes[0])); - ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXDocumentIndexes::getSupportedServiceNames(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXDocumentIndexes::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.DocumentIndexes"); - return aRet; + return ::sw::SupportsServiceImpl( + g_nServicesDocumentIndexes, g_ServicesDocumentIndexes, rServiceName); } -/*-- 05.05.99 13:14:59--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXDocumentIndexes::SwXDocumentIndexes(SwDoc* _pDoc) : - SwUnoCollection(_pDoc) +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndexes::getSupportedServiceNames() throw (uno::RuntimeException) { + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesDocumentIndexes, g_ServicesDocumentIndexes); } -/*-- 05.05.99 13:15:00--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXDocumentIndexes::~SwXDocumentIndexes() -{ -} /*-- 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(); @@ -2002,21 +2534,26 @@ 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(); - uno::Any aRet; sal_Int32 nIdx = 0; const SwSectionFmts& rFmts = GetDoc()->GetSections(); @@ -2026,12 +2563,14 @@ uno::Any SwXDocumentIndexes::getByIndex(sal_Int32 nIndex) if( TOX_CONTENT_SECTION == pSect->GetType() && pSect->GetFmt()->GetSectionNode() && nIdx++ == nIndex ) - { - uno::Reference< text::XDocumentIndex > xTmp = new SwXDocumentIndex( - (SwTOXBaseSection*)pSect, GetDoc() ); - aRet.setValue(&xTmp, ::getCppuType((uno::Reference<text::XDocumentIndex>*)0)); - 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(); @@ -2040,15 +2579,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(); - uno::Any aRet; - String sToFind(rName); const SwSectionFmts& rFmts = GetDoc()->GetSections(); for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) @@ -2056,23 +2596,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) - { - uno::Reference< text::XDocumentIndex > xTmp = new SwXDocumentIndex( - (SwTOXBaseSection*)pSect, GetDoc() ); - aRet.setValue(&xTmp, ::getCppuType((uno::Reference<text::XDocumentIndex>*)0)); - 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(); @@ -2081,10 +2626,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); @@ -2092,22 +2639,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(); @@ -2115,147 +2666,158 @@ 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(); } -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()); -} +/****************************************************************** + * SwXDocumentIndex::StyleAccess_Impl + ******************************************************************/ -/* -----------------------------06.04.00 15:08-------------------------------- +/*-- 13.09.99 16:52:28--------------------------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXIndexStyleAccess_Impl::getImplementationName(void) throw( uno::RuntimeException ) + -----------------------------------------------------------------------*/ +SwXDocumentIndex::StyleAccess_Impl::StyleAccess_Impl( + SwXDocumentIndex& rParentIdx) + : m_xParent(&rParentIdx) { - return C2U("SwXIndexStyleAccess_Impl"); } -/* -----------------------------06.04.00 15:08-------------------------------- +/*-- 13.09.99 16:52:29--------------------------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXIndexStyleAccess_Impl::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) + -----------------------------------------------------------------------*/ +SwXDocumentIndex::StyleAccess_Impl::~StyleAccess_Impl() { - return C2U("com.sun.star.text.DocumentIndexParagraphStyles") == rServiceName; } + /* -----------------------------06.04.00 15:08-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXIndexStyleAccess_Impl::getSupportedServiceNames(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getImplementationName() +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.DocumentIndexParagraphStyles"); - return aRet; + return C2U("SwXDocumentIndex::StyleAccess_Impl"); } -/*-- 13.09.99 16:52:28--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXIndexStyleAccess_Impl::SwXIndexStyleAccess_Impl(SwXDocumentIndex& rParentIdx) : - rParent(rParentIdx), - xParent(&rParentIdx) +static char const*const g_ServicesIndexStyleAccess[] = { - vos::OGuard aGuard(Application::GetSolarMutex()); - rParent.SetStyleAccess(this); + "com.sun.star.text.DocumentIndexParagraphStyles", +}; +static const size_t g_nServicesIndexStyleAccess( + sizeof(g_ServicesIndexStyleAccess)/sizeof(g_ServicesIndexStyleAccess[0])); + +sal_Bool SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::supportsService( + const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesIndexStyleAccess, g_ServicesIndexStyleAccess, rServiceName); } -/*-- 13.09.99 16:52:29--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXIndexStyleAccess_Impl::~SwXIndexStyleAccess_Impl() +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getSupportedServiceNames() +throw (uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); - rParent.SetStyleAccess(0); + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesIndexStyleAccess, g_ServicesIndexStyleAccess); } + /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXIndexStyleAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& rElement) - throw( lang::IllegalArgumentException, lang::IndexOutOfBoundsException, +void SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::replaceByIndex( + sal_Int32 nIndex, const uno::Any& rElement) +throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, 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 & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); uno::Sequence<OUString> aSeq; if(!(rElement >>= aSeq)) + { throw lang::IllegalArgumentException(); + } - sal_Int32 nStyles = aSeq.getLength(); + const sal_Int32 nStyles = aSeq.getLength(); const OUString* pStyles = aSeq.getConstArray(); String sSetStyles; String aString; for(sal_Int32 i = 0; i < nStyles; i++) { if(i) + { sSetStyles += TOX_STYLE_DELIMITER; - SwStyleNameMapper::FillUIName(pStyles[i], aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); + } + SwStyleNameMapper::FillUIName(pStyles[i], aString, + nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True); sSetStyles += aString; } - pTOXBase->SetStyleNames(sSetStyles, (sal_uInt16) nIndex); + rTOXBase.SetStyleNames(sSetStyles, static_cast<sal_uInt16>(nIndex)); } /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int32 SwXIndexStyleAccess_Impl::getCount(void) throw( uno::RuntimeException ) +sal_Int32 SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getCount() throw (uno::RuntimeException) { return MAXLEVEL; } /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXIndexStyleAccess_Impl::getByIndex(sal_Int32 nIndex) - throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, - uno::RuntimeException) +uno::Any SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getByIndex(sal_Int32 nIndex) +throw (lang::IndexOutOfBoundsException, 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 & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); - const String& rStyles = pTOXBase->GetStyleNames((sal_uInt16) nIndex); - sal_uInt16 nStyles = rStyles.GetTokenCount(TOX_STYLE_DELIMITER); + const String& rStyles = + rTOXBase.GetStyleNames(static_cast<sal_uInt16>(nIndex)); + const sal_uInt16 nStyles = rStyles.GetTokenCount(TOX_STYLE_DELIMITER); uno::Sequence<OUString> aStyles(nStyles); OUString* pStyles = aStyles.getArray(); String aString; @@ -2274,123 +2836,143 @@ uno::Any SwXIndexStyleAccess_Impl::getByIndex(sal_Int32 nIndex) /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXIndexStyleAccess_Impl::getElementType(void) - throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::getElementType() +throw (uno::RuntimeException) { return ::getCppuType((uno::Sequence<OUString>*)0); } /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXIndexStyleAccess_Impl::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXDocumentIndex::StyleAccess_Impl::hasElements() throw (uno::RuntimeException) { return sal_True; } -/* -----------------13.09.99 16:51------------------- - - --------------------------------------------------*/ -/* -----------------------------06.04.00 15:08-------------------------------- +/****************************************************************** + * SwXDocumentIndex::TokenAccess_Impl + ******************************************************************/ +/*-- 13.09.99 16:52:28--------------------------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXIndexTokenAccess_Impl::getImplementationName(void) throw( uno::RuntimeException ) + -----------------------------------------------------------------------*/ +SwXDocumentIndex::TokenAccess_Impl::TokenAccess_Impl( + SwXDocumentIndex& rParentIdx) + : m_xParent(&rParentIdx) { - return C2U("SwXIndexTokenAccess_Impl"); } -/* -----------------------------06.04.00 15:08-------------------------------- +/*-- 13.09.99 16:52:29--------------------------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXIndexTokenAccess_Impl::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) + -----------------------------------------------------------------------*/ +SwXDocumentIndex::TokenAccess_Impl::~TokenAccess_Impl() { - return C2U("com.sun.star.text.DocumentIndexLevelFormat") == rServiceName; } + /* -----------------------------06.04.00 15:08-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXIndexTokenAccess_Impl::getSupportedServiceNames(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getImplementationName() +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.DocumentIndexLevelFormat"); - return aRet; + return C2U("SwXDocumentIndex::TokenAccess_Impl"); } -/*-- 13.09.99 16:52:28--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXIndexTokenAccess_Impl::SwXIndexTokenAccess_Impl(SwXDocumentIndex& rParentIdx) : - rParent(rParentIdx), - xParent(&rParentIdx), - nCount(SwForm::GetFormMaxLevel(rParent.GetTOXType())) +static char const*const g_ServicesIndexTokenAccess[] = { - vos::OGuard aGuard(Application::GetSolarMutex()); - rParent.SetTokenAccess(this); + "com.sun.star.text.DocumentIndexLevelFormat", +}; +static const size_t g_nServicesIndexTokenAccess( + sizeof(g_ServicesIndexTokenAccess)/sizeof(g_ServicesIndexTokenAccess[0])); + +sal_Bool SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::supportsService( + const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesIndexTokenAccess, g_ServicesIndexTokenAccess, rServiceName); } -/*-- 13.09.99 16:52:29--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXIndexTokenAccess_Impl::~SwXIndexTokenAccess_Impl() +uno::Sequence< OUString > SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getSupportedServiceNames() +throw (uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); - rParent.SetTokenAccess(0); + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesIndexTokenAccess, g_ServicesIndexTokenAccess); } + +struct TokenType { + const char *pName; + const enum FormTokenType eTokenType; +}; + +static const struct TokenType g_TokenTypes[] = +{ + { "TokenEntryNumber", TOKEN_ENTRY_NO }, + { "TokenEntryText", TOKEN_ENTRY_TEXT }, + { "TokenTabStop", TOKEN_TAB_STOP }, + { "TokenText", TOKEN_TEXT }, + { "TokenPageNumber", TOKEN_PAGE_NUMS }, + { "TokenChapterInfo", TOKEN_CHAPTER_INFO }, + { "TokenHyperlinkStart", TOKEN_LINK_START }, + { "TokenHyperlinkEnd", TOKEN_LINK_END }, + { "TokenBibliographyDataField", TOKEN_AUTHORITY }, + { 0, static_cast<enum FormTokenType>(0) } +}; + /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& rElement) - throw( lang::IllegalArgumentException, lang::IndexOutOfBoundsException, - lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::replaceByIndex( + sal_Int32 nIndex, const uno::Any& rElement) +throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, + 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(); - if(nIndex < 0 || - (nIndex > pTOXBase->GetTOXForm().GetFormMax())) - throw lang::IndexOutOfBoundsException(); + SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); + + if ((nIndex < 0) || (nIndex > rTOXBase.GetTOXForm().GetFormMax())) + { + throw lang::IndexOutOfBoundsException(); + } uno::Sequence<beans::PropertyValues> aSeq; if(!(rElement >>= aSeq)) + { throw lang::IllegalArgumentException(); + } String sPattern; - sal_Int32 nTokens = aSeq.getLength(); + const sal_Int32 nTokens = aSeq.getLength(); const beans::PropertyValues* pTokens = aSeq.getConstArray(); for(sal_Int32 i = 0; i < nTokens; i++) { const beans::PropertyValue* pProperties = pTokens[i].getConstArray(); - sal_Int32 nProperties = pTokens[i].getLength(); + const sal_Int32 nProperties = pTokens[i].getLength(); //create an invalid token SwFormToken aToken(TOKEN_END); for(sal_Int32 j = 0; j < nProperties; j++) { - if( COMPARE_EQUAL == pProperties[j].Name.compareToAscii("TokenType")) + if (pProperties[j].Name.equalsAscii("TokenType")) { - const String sTokenType = + const OUString sTokenType = lcl_AnyToString(pProperties[j].Value); - if(sTokenType.EqualsAscii("TokenEntryNumber")) - aToken.eTokenType = TOKEN_ENTRY_NO; - else if(sTokenType.EqualsAscii("TokenEntryText" )) - aToken.eTokenType = TOKEN_ENTRY_TEXT; - else if(sTokenType.EqualsAscii("TokenTabStop" )) - aToken.eTokenType = TOKEN_TAB_STOP; - else if(sTokenType.EqualsAscii("TokenText" )) - aToken.eTokenType = TOKEN_TEXT; - else if(sTokenType.EqualsAscii("TokenPageNumber")) - aToken.eTokenType = TOKEN_PAGE_NUMS; - else if(sTokenType.EqualsAscii("TokenChapterInfo" )) - aToken.eTokenType = TOKEN_CHAPTER_INFO; - else if(sTokenType.EqualsAscii("TokenHyperlinkStart" )) - aToken.eTokenType = TOKEN_LINK_START; - else if(sTokenType.EqualsAscii("TokenHyperlinkEnd")) - aToken.eTokenType = TOKEN_LINK_END; - else if(sTokenType.EqualsAscii("TokenBibliographyDataField" )) - aToken.eTokenType = TOKEN_AUTHORITY; + for (TokenType const* pTokenType = g_TokenTypes; + pTokenType->pName; ++pTokenType) + { + if (sTokenType.equalsAscii(pTokenType->pName)) + { + aToken.eTokenType = pTokenType->eTokenType; + break; + } + } } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("CharacterStyleName" ) )) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("CharacterStyleName"))) { String sCharStyleName; SwStyleNameMapper::FillUIName( @@ -2400,54 +2982,68 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& sal_True); aToken.sCharStyleName = sCharStyleName; aToken.nPoolId = SwStyleNameMapper::GetPoolIdFromUIName ( - sCharStyleName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); + sCharStyleName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopRightAligned") )) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("TabStopRightAligned"))) { - sal_Bool bRight = lcl_AnyToBool(pProperties[j].Value); + const sal_Bool bRight = lcl_AnyToBool(pProperties[j].Value); aToken.eTabAlign = bRight ? SVX_TAB_ADJUST_END : SVX_TAB_ADJUST_LEFT; } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopPosition" ))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("TabStopPosition"))) { sal_Int32 nPosition = 0; - if(pProperties[j].Value.getValueType() != ::getCppuType((sal_Int32*)0)) + if (!(pProperties[j].Value >>= nPosition)) + { throw lang::IllegalArgumentException(); - pProperties[j].Value >>= nPosition; + } nPosition = MM100_TO_TWIP(nPosition); if(nPosition < 0) + { throw lang::IllegalArgumentException(); + } aToken.nTabStopPosition = nPosition; } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabStopFillCharacter" ))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("TabStopFillCharacter"))) { - const String sFillChar = + const OUString sFillChar = lcl_AnyToString(pProperties[j].Value); - if(sFillChar.Len() > 1) + if (sFillChar.getLength() > 1) + { throw lang::IllegalArgumentException(); - aToken.cTabFillChar = sFillChar.Len() ? - sFillChar.GetChar(0) : ' '; + } + aToken.cTabFillChar = + (sFillChar.getLength()) ? sFillChar[0] : ' '; } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Text" ))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("Text"))) { - const String sText = - lcl_AnyToString(pProperties[j].Value); + const OUString sText = lcl_AnyToString(pProperties[j].Value); aToken.sText = sText; } - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ChapterFormat" ))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ChapterFormat"))) { sal_Int16 nFormat = lcl_AnyToInt16(pProperties[j].Value); switch(nFormat) { - case text::ChapterFormat::NUMBER: nFormat = CF_NUMBER; + case text::ChapterFormat::NUMBER: + nFormat = CF_NUMBER; break; - case text::ChapterFormat::NAME: nFormat = CF_TITLE; + case text::ChapterFormat::NAME: + nFormat = CF_TITLE; break; - case text::ChapterFormat::NAME_NUMBER: nFormat = CF_NUM_TITLE; + case text::ChapterFormat::NAME_NUMBER: + nFormat = CF_NUM_TITLE; break; - case text::ChapterFormat::NO_PREFIX_SUFFIX:nFormat = CF_NUMBER_NOPREPST; + case text::ChapterFormat::NO_PREFIX_SUFFIX: + nFormat = CF_NUMBER_NOPREPST; break; - case text::ChapterFormat::DIGIT: nFormat = CF_NUM_NOPREPST_TITLE; + case text::ChapterFormat::DIGIT: + nFormat = CF_NUM_NOPREPST_TITLE; break; default: throw lang::IllegalArgumentException(); @@ -2455,15 +3051,19 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& aToken.nChapterFormat = nFormat; } //--->i53420 - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ChapterLevel")) ) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("ChapterLevel"))) { const sal_Int16 nLevel = lcl_AnyToInt16(pProperties[j].Value); if( nLevel < 1 || nLevel > MAXLEVEL ) + { throw lang::IllegalArgumentException(); + } aToken.nOutlineLevel = nLevel; } //<--- - else if( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("BibliographyDataField"))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("BibliographyDataField"))) { sal_Int16 nType = 0; pProperties[j].Value >>= nType; @@ -2477,7 +3077,8 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& aToken.nAuthorityField = nType; } // #i21237# - else if ( pProperties[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("WithTab"))) + else if (pProperties[j].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("WithTab"))) { aToken.bWithTab = lcl_AnyToBool(pProperties[j].Value); } @@ -2485,17 +3086,22 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& } //exception if wrong TokenType if(TOKEN_END <= aToken.eTokenType ) + { throw lang::IllegalArgumentException(); + } // set TokenType from TOKEN_ENTRY_TEXT to TOKEN_ENTRY if it is // not a content index if(TOKEN_ENTRY_TEXT == aToken.eTokenType && - TOX_CONTENT != pTOXBase->GetType()) + (TOX_CONTENT != rTOXBase.GetType())) + { aToken.eTokenType = TOKEN_ENTRY; + } //---> i53420 // check for chapter format allowed values if it was TOKEN_ENTRY_NO type // only allowed value are CF_NUMBER and CF_NUM_NOPREPST_TITLE // reading from file if( TOKEN_ENTRY_NO == aToken.eTokenType ) + { switch(aToken.nChapterFormat) { case CF_NUMBER: @@ -2504,50 +3110,47 @@ void SwXIndexTokenAccess_Impl::replaceByIndex(sal_Int32 nIndex, const uno::Any& default: throw lang::IllegalArgumentException(); } + } //<--- sPattern += aToken.GetString(); } - SwForm aForm(pTOXBase->GetTOXForm()); - aForm.SetPattern((sal_uInt16) nIndex, sPattern); - pTOXBase->SetTOXForm(aForm); + SwForm aForm(rTOXBase.GetTOXForm()); + aForm.SetPattern(static_cast<sal_uInt16>(nIndex), sPattern); + rTOXBase.SetTOXForm(aForm); } + /*-- 13.09.99 16:52:29--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int32 SwXIndexTokenAccess_Impl::getCount(void) throw( uno::RuntimeException ) +sal_Int32 SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getCount() 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 = m_xParent->m_pImpl->GetFormMax(); return nRet; } + /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) - throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, - uno::RuntimeException) +uno::Any SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex) +throw (lang::IndexOutOfBoundsException, 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(); - if(nIndex < 0 || - (nIndex > pTOXBase->GetTOXForm().GetFormMax())) + + SwTOXBase & rTOXBase( m_xParent->m_pImpl->GetTOXSectionOrThrow() ); + + if ((nIndex < 0) || (nIndex > rTOXBase.GetTOXForm().GetFormMax())) + { throw lang::IndexOutOfBoundsException(); + } // #i21237# - SwFormTokens aPattern = pTOXBase->GetTOXForm(). - GetPattern((sal_uInt16) nIndex); + SwFormTokens aPattern = rTOXBase.GetTOXForm(). + GetPattern(static_cast<sal_uInt16>(nIndex)); SwFormTokens::iterator aIt = aPattern.begin(); sal_uInt16 nTokenCount = 0; @@ -2560,7 +3163,8 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) beans::PropertyValues* pTokenProps = aRetSeq.getArray(); SwFormToken aToken = *aIt; // #i21237# - uno::Sequence< beans::PropertyValue >& rCurTokenSeq = pTokenProps[nTokenCount-1]; + uno::Sequence< beans::PropertyValue >& rCurTokenSeq = + pTokenProps[nTokenCount-1]; SwStyleNameMapper::FillProgName( aToken.sCharStyleName, aString, @@ -2569,25 +3173,30 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) const OUString aProgCharStyle( aString ); switch(aToken.eTokenType) { - case TOKEN_ENTRY_NO : + case TOKEN_ENTRY_NO: { //--->i53420 // writing to file (from doc to properties) sal_Int32 nElements = 2; sal_Int32 nCurrentElement = 0; - if( aToken.nChapterFormat != CF_NUMBER )//check for default value + // check for default value + if (aToken.nChapterFormat != CF_NUMBER) + { nElements++;//we need the element + } if( aToken.nOutlineLevel != MAXLEVEL ) + { nElements++; + } rCurTokenSeq.realloc( nElements ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); pArr[nCurrentElement].Name = C2U("TokenType"); - pArr[nCurrentElement++].Value <<= OUString::createFromAscii("TokenEntryNumber"); -// pArr[0].Value <<= C2U("TokenEntryNumber"); + pArr[nCurrentElement++].Value <<= + OUString::createFromAscii("TokenEntryNumber"); pArr[nCurrentElement].Name = C2U("CharacterStyleName"); pArr[nCurrentElement++].Value <<= aProgCharStyle; @@ -2595,18 +3204,24 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) { pArr[nCurrentElement].Name = C2U("ChapterFormat"); sal_Int16 nVal; -//! the allowed values for chapter format, when used as entry number, are CF_NUMBER and CF_NUM_NOPREPST_TITLE only, all else forced to +// the allowed values for chapter format, when used as entry number, +// are CF_NUMBER and CF_NUM_NOPREPST_TITLE only, all else forced to //CF_NUMBER switch(aToken.nChapterFormat) { default: - case CF_NUMBER: nVal = text::ChapterFormat::NUMBER; break; - case CF_NUM_NOPREPST_TITLE: nVal = text::ChapterFormat::DIGIT; break; + case CF_NUMBER: + nVal = text::ChapterFormat::NUMBER; + break; + case CF_NUM_NOPREPST_TITLE: + nVal = text::ChapterFormat::DIGIT; + break; } - pArr[nCurrentElement++].Value <<= (sal_Int16)nVal; + pArr[nCurrentElement++].Value <<= nVal; } - if( aToken.nOutlineLevel != MAXLEVEL ) //only a ChapterLevel != MAXLEVEL is registered + // only a ChapterLevel != MAXLEVEL is registered + if (aToken.nOutlineLevel != MAXLEVEL) { pArr[nCurrentElement].Name = C2U("ChapterLevel"); pArr[nCurrentElement].Value <<= aToken.nOutlineLevel; @@ -2614,8 +3229,8 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) //<--- } break; - case TOKEN_ENTRY : // no difference between Entry and Entry Text - case TOKEN_ENTRY_TEXT : + case TOKEN_ENTRY: // no difference between Entry and Entry Text + case TOKEN_ENTRY_TEXT: { rCurTokenSeq.realloc( 2 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2627,7 +3242,7 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[1].Value <<= aProgCharStyle; } break; - case TOKEN_TAB_STOP : + case TOKEN_TAB_STOP: { rCurTokenSeq.realloc(5); // #i21237# beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2635,7 +3250,6 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[0].Name = C2U("TokenType"); pArr[0].Value <<= OUString::createFromAscii("TokenTabStop"); - if(SVX_TAB_ADJUST_END == aToken.eTabAlign) { pArr[1].Name = C2U("TabStopRightAligned"); @@ -2656,10 +3270,10 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[3].Value <<= aProgCharStyle; // #i21237# pArr[4].Name = C2U("WithTab"); - pArr[4].Value.setValue(&aToken.bWithTab, ::getCppuBooleanType()); + pArr[4].Value <<= static_cast<sal_Bool>(aToken.bWithTab); } break; - case TOKEN_TEXT : + case TOKEN_TEXT: { rCurTokenSeq.realloc( 3 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2674,7 +3288,7 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[2].Value <<= OUString(aToken.sText); } break; - case TOKEN_PAGE_NUMS : + case TOKEN_PAGE_NUMS: { rCurTokenSeq.realloc( 2 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2686,7 +3300,7 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) pArr[1].Value <<= aProgCharStyle; } break; - case TOKEN_CHAPTER_INFO : + case TOKEN_CHAPTER_INFO: { rCurTokenSeq.realloc( 4 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); @@ -2701,13 +3315,23 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) sal_Int16 nVal = text::ChapterFormat::NUMBER; switch(aToken.nChapterFormat) { - case CF_NUMBER: nVal = text::ChapterFormat::NUMBER; break; - case CF_TITLE: nVal = text::ChapterFormat::NAME; break; - case CF_NUM_TITLE: nVal = text::ChapterFormat::NAME_NUMBER; break; - case CF_NUMBER_NOPREPST: nVal = text::ChapterFormat::NO_PREFIX_SUFFIX; break; - case CF_NUM_NOPREPST_TITLE: nVal = text::ChapterFormat::DIGIT; break; + case CF_NUMBER: + nVal = text::ChapterFormat::NUMBER; + break; + case CF_TITLE: + nVal = text::ChapterFormat::NAME; + break; + case CF_NUM_TITLE: + nVal = text::ChapterFormat::NAME_NUMBER; + break; + case CF_NUMBER_NOPREPST: + nVal = text::ChapterFormat::NO_PREFIX_SUFFIX; + break; + case CF_NUM_NOPREPST_TITLE: + nVal = text::ChapterFormat::DIGIT; + break; } - pArr[2].Value <<= (sal_Int16)nVal; + pArr[2].Value <<= nVal; //--->i53420 pArr[3].Name = C2U("ChapterLevel"); // @@ -2715,33 +3339,36 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) //<--- } break; - case TOKEN_LINK_START : + case TOKEN_LINK_START: { rCurTokenSeq.realloc( 2 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); pArr[0].Name = C2U("TokenType"); - pArr[0].Value <<= OUString::createFromAscii("TokenHyperlinkStart"); + pArr[0].Value <<= + OUString::createFromAscii("TokenHyperlinkStart"); pArr[1].Name = C2U("CharacterStyleName"); pArr[1].Value <<= aProgCharStyle; } break; - case TOKEN_LINK_END : + case TOKEN_LINK_END: { rCurTokenSeq.realloc( 1 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); pArr[0].Name = C2U("TokenType"); - pArr[0].Value <<= OUString::createFromAscii("TokenHyperlinkEnd"); + pArr[0].Value <<= + OUString::createFromAscii("TokenHyperlinkEnd"); } break; - case TOKEN_AUTHORITY : + case TOKEN_AUTHORITY: { rCurTokenSeq.realloc( 3 ); beans::PropertyValue* pArr = rCurTokenSeq.getArray(); pArr[0].Name = C2U("TokenType"); - pArr[0].Value <<= OUString::createFromAscii("TokenBibliographyDataField"); + pArr[0].Value <<= + OUString::createFromAscii("TokenBibliographyDataField"); pArr[1].Name = C2U("CharacterStyleName"); pArr[1].Value <<= aProgCharStyle; @@ -2758,22 +3385,26 @@ uno::Any SwXIndexTokenAccess_Impl::getByIndex(sal_Int32 nIndex) aIt++; // #i21237# } - uno::Any aRet(&aRetSeq, ::getCppuType((uno::Sequence< beans::PropertyValues >*)0)); - + uno::Any aRet; + aRet <<= aRetSeq; return aRet; } + /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXIndexTokenAccess_Impl::getElementType(void) - throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::getElementType() +throw (uno::RuntimeException) { return ::getCppuType((uno::Sequence< beans::PropertyValues >*)0); } /*-- 13.09.99 16:52:30--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXIndexTokenAccess_Impl::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXDocumentIndex::TokenAccess_Impl::hasElements() +throw (uno::RuntimeException) { return sal_True; } diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 30f57c7df8..f046719f85 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -31,9 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <com/sun/star/table/TableSortField.hpp> #include <osl/endian.h> #include <rtl/ustrbuf.hxx> +#include <unotools/collatorwrapper.hxx> #include <swtypes.hxx> #include <hintids.hxx> #include <cmdid.h> @@ -44,6 +46,7 @@ #include <istyleaccess.hxx> #include <ndtxt.hxx> #include <ndnotxt.hxx> +#include <unocrsr.hxx> #include <unocrsrhelper.hxx> #include <swundo.hxx> #include <rootfrm.hxx> @@ -81,8 +84,8 @@ #include <sfx2/fcontnr.hxx> #include <fmtrfmrk.hxx> #include <txtrfmrk.hxx> -#include <unoclbck.hxx> -#include <unoobj.hxx> +#include <unotextrange.hxx> +#include <unotextcursor.hxx> #include <unomap.hxx> #include <unosett.hxx> #include <unoprnms.hxx> @@ -114,26 +117,23 @@ #define _SVSTDARR_USHORTSSORT #include <svl/svstdarr.hxx> #include <svx/brshitem.hxx> +#include <svx/unolingu.hxx> #include <fmtclds.hxx> #include <dcontact.hxx> #include <SwStyleNameMapper.hxx> #include <crsskip.hxx> +#include <sortopt.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <memory> +#include <unoparaframeenum.hxx> +#include <unoparagraph.hxx> using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::text; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::drawing; -using std::auto_ptr; using ::rtl::OUString; using ::rtl::OUStringBuffer; + /**************************************************************************** static methods ****************************************************************************/ @@ -184,73 +184,34 @@ SwUnoInternalPaM& SwUnoInternalPaM::operator=(const SwPaM& rPaM) } return *this; } -/**************************************************************************** - ActionContext -****************************************************************************/ -UnoActionContext::UnoActionContext(SwDoc* pDc) : - pDoc(pDc) -{ - SwRootFrm* pRootFrm = pDoc->GetRootFrm(); - if(pRootFrm) - pRootFrm->StartAllAction(); -} -/*-----------------04.03.98 11:56------------------- - ---------------------------------------------------*/ -UnoActionContext::~UnoActionContext() -{ - //das Doc kann hier schon entfernt worden sein - if(pDoc) - { - SwRootFrm* pRootFrm = pDoc->GetRootFrm(); - if(pRootFrm) - pRootFrm->EndAllAction(); - } -} - -/**************************************************************************** - ActionRemoveContext -****************************************************************************/ -UnoActionRemoveContext::UnoActionRemoveContext(SwDoc* pDc) : - pDoc(pDc) -{ - SwRootFrm* pRootFrm = pDoc->GetRootFrm(); - if(pRootFrm) - pRootFrm->UnoRemoveAllActions(); -} -/* -----------------07.07.98 12:05------------------- - * - * --------------------------------------------------*/ -UnoActionRemoveContext::~UnoActionRemoveContext() -{ - SwRootFrm* pRootFrm = pDoc->GetRootFrm(); - if(pRootFrm) - pRootFrm->UnoRestoreAllActions(); - -} /*-----------------09.03.98 08:29------------------- --------------------------------------------------*/ -void SwXTextCursor::SelectPam(SwPaM& rCrsr, sal_Bool bExpand) +void SwUnoCursorHelper::SelectPam(SwPaM & rPam, const bool bExpand) { - if(bExpand) + if (bExpand) { - if(!rCrsr.HasMark()) - rCrsr.SetMark(); + if (!rPam.HasMark()) + { + rPam.SetMark(); + } + } + else if (rPam.HasMark()) + { + rPam.DeleteMark(); } - else if(rCrsr.HasMark()) - rCrsr.DeleteMark(); - } /* -----------------20.05.98 14:59------------------- * * --------------------------------------------------*/ -void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer) +void SwUnoCursorHelper::GetTextFromPam(SwPaM & rPam, OUString & rBuffer) { - if(!aCrsr.HasMark()) + if (!rPam.HasMark()) + { return; + } SvCacheStream aStream( 20480 ); #ifdef OSL_BIGENDIAN aStream.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN ); @@ -262,7 +223,7 @@ void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer) SwReaderWriter::GetWriter( C2S(FILTER_TEXT_DLG), String(), xWrt ); if( xWrt.Is() ) { - SwWriter aWriter( aStream, aCrsr ); + SwWriter aWriter( aStream, rPam ); xWrt->bASCII_NoLastLineEnd = sal_True; xWrt->bExportPargraphNumbering = sal_False; SwAsciiOptions aOpt = xWrt->GetAsciiOptions(); @@ -290,10 +251,15 @@ void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer) String sBuf; sal_Int32 nLocalLen = 0; if( lUniLen >= STRING_MAXLEN ) + { nLocalLen = STRING_MAXLEN - 1; + } else + { nLocalLen = lUniLen; - sal_Unicode* pStrBuf = sBuf.AllocBuffer( xub_StrLen( nLocalLen + 1)); + } + sal_Unicode *const pStrBuf = + sBuf.AllocBuffer( xub_StrLen( nLocalLen + 1)); aStream.Read( pStrBuf, 2 * nLocalLen ); pStrBuf[ nLocalLen ] = '\0'; aStrBuffer.append( pStrBuf, nLocalLen ); @@ -308,46 +274,52 @@ void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer) /* -----------------06.07.98 07:33------------------- * * --------------------------------------------------*/ -void lcl_setCharStyle(SwDoc* pDoc, const uno::Any aValue, SfxItemSet& rSet) - throw (lang::IllegalArgumentException) +static void +lcl_setCharStyle(SwDoc *const pDoc, const uno::Any & rValue, SfxItemSet & rSet) +throw (lang::IllegalArgumentException) { - SwDocShell* pDocSh = pDoc->GetDocShell(); + SwDocShell *const pDocSh = pDoc->GetDocShell(); if(pDocSh) { OUString uStyle; - aValue >>= uStyle; - String sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); - SwDocStyleSheet* pStyle = - (SwDocStyleSheet*)pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR); - if(pStyle) + if (!(rValue >>= uStyle)) { - SwFmtCharFmt aFmt(pStyle->GetCharFmt()); - rSet.Put(aFmt); + throw lang::IllegalArgumentException(); } - else + String sStyle; + SwStyleNameMapper::FillUIName(uStyle, sStyle, + nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True); + SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>( + pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR)); + if (!pStyle) { - throw lang::IllegalArgumentException(); + throw lang::IllegalArgumentException(); } - + const SwFmtCharFmt aFmt(pStyle->GetCharFmt()); + rSet.Put(aFmt); } }; /* -----------------08.06.06 10:43------------------- * * --------------------------------------------------*/ -void lcl_setAutoStyle(IStyleAccess& rStyleAccess, const uno::Any aValue, SfxItemSet& rSet, bool bPara ) - throw (lang::IllegalArgumentException) +static void +lcl_setAutoStyle(IStyleAccess & rStyleAccess, const uno::Any & rValue, + SfxItemSet & rSet, const bool bPara) +throw (lang::IllegalArgumentException) { OUString uStyle; - aValue >>= uStyle; - String sStyle; + if (!(rValue >>= uStyle)) + { + throw lang::IllegalArgumentException(); + } StylePool::SfxItemSet_Pointer_t pStyle = bPara ? rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_PARA ): rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_CHAR ); if(pStyle.get()) { - SwFmtAutoFmt aFmt( bPara ? sal::static_int_cast< USHORT >(RES_AUTO_STYLE) - : sal::static_int_cast< USHORT >(RES_TXTATR_AUTOFMT) ); + SwFmtAutoFmt aFmt( (bPara) + ? sal::static_int_cast< USHORT >(RES_AUTO_STYLE) + : sal::static_int_cast< USHORT >(RES_TXTATR_AUTOFMT) ); aFmt.SetStyleHandle( pStyle ); rSet.Put(aFmt); } @@ -359,71 +331,77 @@ void lcl_setAutoStyle(IStyleAccess& rStyleAccess, const uno::Any aValue, SfxItem /* -----------------30.06.98 08:46------------------- * * --------------------------------------------------*/ -void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) - throw (lang::IllegalArgumentException) +void +SwUnoCursorHelper::SetTxtFmtColl(const uno::Any & rAny, SwPaM & rPaM) +throw (lang::IllegalArgumentException) { - SwDoc* pDoc = rPaM.GetDoc(); - SwDocShell* pDocSh = pDoc->GetDocShell(); + SwDoc *const pDoc = rPaM.GetDoc(); + SwDocShell *const pDocSh = pDoc->GetDocShell(); if(!pDocSh) return; OUString uStyle; rAny >>= uStyle; String sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True ); - SwDocStyleSheet* pStyle = - (SwDocStyleSheet*)pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_PARA); - if(pStyle) - { - SwTxtFmtColl *pLocal = pStyle->GetCollection(); - UnoActionContext aAction(pDoc); - pDoc->StartUndo( UNDO_START, NULL ); - SwPaM *pTmpCrsr = &rPaM; - do { - pDoc->SetTxtFmtColl(*pTmpCrsr, pLocal); - pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); - } while ( pTmpCrsr != &rPaM ); - pDoc->EndUndo( UNDO_END, NULL ); - } - else + SwStyleNameMapper::FillUIName(uStyle, sStyle, + nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True ); + SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>( + pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_PARA)); + if (!pStyle) { throw lang::IllegalArgumentException(); } + SwTxtFmtColl *const pLocal = pStyle->GetCollection(); + UnoActionContext aAction(pDoc); + pDoc->StartUndo( UNDO_START, NULL ); + SwPaM *pTmpCrsr = &rPaM; + do { + pDoc->SetTxtFmtColl(*pTmpCrsr, pLocal); + pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != &rPaM ); + pDoc->EndUndo( UNDO_END, NULL ); } + /* -----------------06.07.98 07:38------------------- * * --------------------------------------------------*/ - void lcl_setPageDesc(SwDoc* pDoc, const uno::Any& aValue, SfxItemSet& rSet) - { - if(aValue.getValueType() != ::getCppuType((const OUString*)0)) - return; - SwFmtPageDesc *pNewDesc = 0 ; +bool +SwUnoCursorHelper::SetPageDesc( + const uno::Any& rValue, SwDoc & rDoc, SfxItemSet & rSet) +{ + OUString uDescName; + if (!(rValue >>= uDescName)) + { + return false; + } + ::std::auto_ptr<SwFmtPageDesc> pNewDesc; const SfxPoolItem* pItem; if(SFX_ITEM_SET == rSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) ) { - pNewDesc = new SwFmtPageDesc(*((SwFmtPageDesc*)pItem)); + pNewDesc.reset(new SwFmtPageDesc( + *static_cast<const SwFmtPageDesc*>(pItem))); + } + if (!pNewDesc.get()) + { + pNewDesc.reset(new SwFmtPageDesc()); } - if(!pNewDesc) - pNewDesc = new SwFmtPageDesc(); - OUString uDescName; - aValue >>= uDescName; String sDescName; - SwStyleNameMapper::FillUIName(uDescName, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True ); - if(!pNewDesc->GetPageDesc() || pNewDesc->GetPageDesc()->GetName() != sDescName) + SwStyleNameMapper::FillUIName(uDescName, sDescName, + nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True); + if (!pNewDesc->GetPageDesc() || + (pNewDesc->GetPageDesc()->GetName() != sDescName)) { sal_Bool bPut = sal_False; if(sDescName.Len()) { - SwPageDesc* pPageDesc = ::GetPageDescByName_Impl(*pDoc, sDescName); - if(pPageDesc) - { - pPageDesc->Add( pNewDesc ); - bPut = sal_True; - } - else + SwPageDesc *const pPageDesc = + ::GetPageDescByName_Impl(rDoc, sDescName); + if (!pPageDesc) { throw lang::IllegalArgumentException(); } + pPageDesc->Add( pNewDesc.get() ); + bPut = sal_True; } if(!bPut) { @@ -431,17 +409,21 @@ void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) rSet.Put(SwFmtPageDesc()); } else + { rSet.Put(*pNewDesc); + } } - delete pNewDesc; + return true; } + /* -----------------30.06.98 10:29------------------- * * --------------------------------------------------*/ -void lcl_SetNodeNumStart( SwPaM& rCrsr, uno::Any aValue ) +static void +lcl_SetNodeNumStart(SwPaM & rCrsr, uno::Any const& rValue) { sal_Int16 nTmp = 1; - aValue >>= nTmp; + rValue >>= nTmp; sal_uInt16 nStt = (nTmp < 0 ? USHRT_MAX : (sal_uInt16)nTmp); SwDoc* pDoc = rCrsr.GetDoc(); UnoActionContext aAction(pDoc); @@ -466,215 +448,264 @@ void lcl_SetNodeNumStart( SwPaM& rCrsr, uno::Any aValue ) } } +static bool +lcl_setCharFmtSequence(SwPaM & rPam, uno::Any const& rValue) +{ + uno::Sequence<OUString> aCharStyles; + if (!(rValue >>= aCharStyles)) + { + return false; + } + + for (sal_Int32 nStyle = 0; nStyle < aCharStyles.getLength(); nStyle++) + { + uno::Any aStyle; + rPam.GetDoc()->StartUndo(UNDO_START, NULL); + aStyle <<= aCharStyles.getConstArray()[nStyle]; + // create a local set and apply each format directly + SfxItemSet aSet(rPam.GetDoc()->GetAttrPool(), + RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT); + lcl_setCharStyle(rPam.GetDoc(), aStyle, aSet); + // the first style should replace the current attributes, + // all other have to be added + SwUnoCursorHelper::SetCrsrAttr(rPam, aSet, (nStyle) + ? nsSetAttrMode::SETATTR_DONTREPLACE + : nsSetAttrMode::SETATTR_DEFAULT); + rPam.GetDoc()->EndUndo(UNDO_START, NULL); + } + return true; +} + +static void +lcl_setDropcapCharStyle(SwPaM & rPam, SfxItemSet & rItemSet, + uno::Any const& rValue) +{ + OUString uStyle; + if (!(rValue >>= uStyle)) + { + throw lang::IllegalArgumentException(); + } + String sStyle; + SwStyleNameMapper::FillUIName(uStyle, sStyle, + nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True); + SwDoc *const pDoc = rPam.GetDoc(); + //default character style must not be set as default format + SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>( + pDoc->GetDocShell() + ->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR)); + if (!pStyle || + (static_cast<SwDocStyleSheet*>(pStyle)->GetCharFmt() == + pDoc->GetDfltCharFmt())) + { + throw lang::IllegalArgumentException(); + } + ::std::auto_ptr<SwFmtDrop> pDrop; + SfxPoolItem const* pItem(0); + if (SFX_ITEM_SET == + rItemSet.GetItemState(RES_PARATR_DROP, sal_True, &pItem)) + { + pDrop.reset(new SwFmtDrop(*static_cast<const SwFmtDrop*>(pItem))); + } + if (!pDrop.get()) + { + pDrop.reset(new SwFmtDrop); + } + const rtl::Reference<SwDocStyleSheet> xStyle(new SwDocStyleSheet(*pStyle)); + pDrop->SetCharFmt(xStyle->GetCharFmt()); + rItemSet.Put(*pDrop); +} + +static void +lcl_setRubyCharstyle(SfxItemSet & rItemSet, uno::Any const& rValue) +{ + OUString sTmp; + if (!(rValue >>= sTmp)) + { + throw lang::IllegalArgumentException(); + } + + ::std::auto_ptr<SwFmtRuby> pRuby; + const SfxPoolItem* pItem; + if (SFX_ITEM_SET == + rItemSet.GetItemState(RES_TXTATR_CJK_RUBY, sal_True, &pItem)) + { + pRuby.reset(new SwFmtRuby(*static_cast<const SwFmtRuby*>(pItem))); + } + if (!pRuby.get()) + { + pRuby.reset(new SwFmtRuby(aEmptyStr)); + } + String sStyle; + SwStyleNameMapper::FillUIName(sTmp, sStyle, + nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); + pRuby->SetCharFmtName(sStyle); + pRuby->SetCharFmtId(0); + if (sStyle.Len() > 0) + { + const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( + sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT); + pRuby->SetCharFmtId(nId); + } + rItemSet.Put(*pRuby); +} + /* -----------------17.09.98 09:44------------------- * * --------------------------------------------------*/ -sal_Bool lcl_setCrsrPropertyValue(const SfxItemPropertySimpleEntry* pEntry, - SwPaM& rPam, - SfxItemSet& rItemSet, - const uno::Any& aValue ) throw (lang::IllegalArgumentException) -{ - sal_Bool bRet = sal_True; - if(0 == ( pEntry->nFlags&PropertyAttribute::MAYBEVOID ) && - aValue.getValueType() == ::getCppuVoidType()) - bRet = sal_False; - else - { - switch(pEntry->nWID) +bool +SwUnoCursorHelper::SetCursorPropertyValue( + SfxItemPropertySimpleEntry const& rEntry, const uno::Any& rValue, + SwPaM & rPam, SfxItemSet & rItemSet) +throw (lang::IllegalArgumentException) +{ + if (!(rEntry.nFlags & beans::PropertyAttribute::MAYBEVOID) && + (rValue.getValueType() == ::getCppuVoidType())) + { + return false; + } + bool bRet = true; + switch (rEntry.nWID) + { + case RES_TXTATR_CHARFMT: + lcl_setCharStyle(rPam.GetDoc(), rValue, rItemSet); + break; + case RES_TXTATR_AUTOFMT: + lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(), + rValue, rItemSet, false); + break; + case FN_UNO_CHARFMT_SEQUENCE: + lcl_setCharFmtSequence(rPam, rValue); + break; + case FN_UNO_PARA_STYLE : + SwUnoCursorHelper::SetTxtFmtColl(rValue, rPam); + break; + case RES_AUTO_STYLE: + lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(), + rValue, rItemSet, true); + break; + case FN_UNO_PAGE_STYLE: + //FIXME nothing here? + break; + case FN_UNO_NUM_START_VALUE: + lcl_SetNodeNumStart( rPam, rValue ); + break; + case FN_UNO_NUM_LEVEL: + // --> OD 2008-07-14 #i91601# + case FN_UNO_LIST_ID: + // <-- + case FN_UNO_IS_NUMBER: { - case RES_TXTATR_CHARFMT: - lcl_setCharStyle(rPam.GetDoc(), aValue, rItemSet ); - break; - case RES_TXTATR_AUTOFMT: - lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(), aValue, rItemSet, false ); - break; - case FN_UNO_CHARFMT_SEQUENCE: + // multi selection is not considered + SwTxtNode *const pTxtNd = rPam.GetNode()->GetTxtNode(); + // --> OD 2008-05-14 #refactorlists# - check on list style not needed +// const SwNumRule* pRule = pTxtNd->GetNumRule(); +// if( FN_UNO_NUM_LEVEL == rEntry.nWID && pRule != NULL ) + if (FN_UNO_NUM_LEVEL == rEntry.nWID) + // <-- { - Sequence<OUString> aCharStyles; - if(aValue >>= aCharStyles) + sal_Int16 nLevel = 0; + if (rValue >>= nLevel) { - for(sal_Int32 nStyle = 0; nStyle < aCharStyles.getLength(); nStyle++) - { - Any aStyle; - rPam.GetDoc()->StartUndo( UNDO_START, NULL); - aStyle <<= aCharStyles.getConstArray()[nStyle]; - //create a local set and apply each format directly - SfxItemSet aSet(rPam.GetDoc()->GetAttrPool(), RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT ); - lcl_setCharStyle(rPam.GetDoc(), aStyle, aSet ); - //the first style should replace the current attributes, all other have to be added - SwXTextCursor::SetCrsrAttr(rPam, aSet, nStyle ? CRSR_ATTR_MODE_DONTREPLACE : 0); - rPam.GetDoc()->EndUndo( UNDO_START, NULL ); - } + pTxtNd->SetAttrListLevel(nLevel); } - else - bRet = sal_False; } - break; - case FN_UNO_PARA_STYLE : - lcl_SetTxtFmtColl(aValue, rPam); - break; - case RES_AUTO_STYLE: - lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(), aValue, rItemSet, true ); - break; - case FN_UNO_PAGE_STYLE : - break; - case FN_UNO_NUM_START_VALUE : - lcl_SetNodeNumStart( rPam, aValue ); - break; - case FN_UNO_NUM_LEVEL : // --> OD 2008-07-14 #i91601# - case FN_UNO_LIST_ID: - // <-- - case FN_UNO_IS_NUMBER : + else if (FN_UNO_LIST_ID == rEntry.nWID) { - // multi selection is not considered - SwTxtNode* pTxtNd = rPam.GetNode()->GetTxtNode(); - // --> OD 2008-05-14 #refactorlists# - check on list style not needed -// const SwNumRule* pRule = pTxtNd->GetNumRule(); -// if( FN_UNO_NUM_LEVEL == pEntry->nWID && pRule != NULL ) - if ( FN_UNO_NUM_LEVEL == pEntry->nWID ) - // <-- + ::rtl::OUString sListId; + if (rValue >>= sListId) { - sal_Int16 nLevel = 0; - aValue >>= nLevel; - - pTxtNd->SetAttrListLevel(nLevel); - - } - // --> OD 2008-07-14 #i91601# - else if( FN_UNO_LIST_ID == pEntry->nWID ) - { - ::rtl::OUString sListId; - aValue >>= sListId; pTxtNd->SetListId( sListId ); } - // <-- - else if( FN_UNO_IS_NUMBER == pEntry->nWID ) + } + // <-- + else if (FN_UNO_IS_NUMBER == rEntry.nWID) + { + sal_Bool bIsNumber(sal_False); + if (rValue >>= bIsNumber) { - BOOL bIsNumber = *(sal_Bool*) aValue.getValue(); - if(!bIsNumber) + if (!bIsNumber) + { pTxtNd->SetCountedInList( false ); + } } - //PROPERTY_MAYBEVOID! } - break; - case FN_NUMBER_NEWSTART : + //PROPERTY_MAYBEVOID! + } + break; + case FN_NUMBER_NEWSTART: + { + sal_Bool bVal = sal_False; + if (!(rValue >>= bVal)) { - sal_Bool bVal = sal_False; - if (aValue >>= bVal) - rPam.GetDoc()->SetNumRuleStart(*rPam.GetPoint(), bVal); - else - throw lang::IllegalArgumentException(); + throw lang::IllegalArgumentException(); } - break; - case FN_UNO_NUM_RULES: - SwUnoCursorHelper::setNumberingProperty(aValue, rPam); - break; - case RES_PARATR_DROP: + rPam.GetDoc()->SetNumRuleStart(*rPam.GetPoint(), bVal); + } + break; + case FN_UNO_NUM_RULES: + SwUnoCursorHelper::setNumberingProperty(rValue, rPam); + break; + case RES_PARATR_DROP: + { + if (MID_DROPCAP_CHAR_STYLE_NAME == rEntry.nMemberId) { - if( MID_DROPCAP_CHAR_STYLE_NAME == pEntry->nMemberId) - { - OUString uStyle; - if(aValue >>= uStyle) - { - String sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); - SwDoc* pDoc = rPam.GetDoc(); - //default character style mustn't be set as default format - SwDocStyleSheet* pStyle = - (SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR); - SwFmtDrop* pDrop = 0; - if(pStyle && - ((SwDocStyleSheet*)pStyle)->GetCharFmt() != pDoc->GetDfltCharFmt()) - { - const SfxPoolItem* pItem; - if(SFX_ITEM_SET == rItemSet.GetItemState( RES_PARATR_DROP, sal_True, &pItem ) ) - pDrop = new SwFmtDrop(*((SwFmtDrop*)pItem)); - if(!pDrop) - pDrop = new SwFmtDrop(); - rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pStyle ) ); - pDrop->SetCharFmt(xStyle->GetCharFmt()); - } - else - throw lang::IllegalArgumentException(); - rItemSet.Put(*pDrop); - delete pDrop; - } - else - throw lang::IllegalArgumentException(); - } - else - bRet = sal_False; + lcl_setDropcapCharStyle(rPam, rItemSet, rValue); } - break; - case RES_TXTATR_CJK_RUBY: - if(MID_RUBY_CHARSTYLE == pEntry->nMemberId ) - { - OUString sTmp; - if(aValue >>= sTmp) - { - SwFmtRuby* pRuby = 0; - const SfxPoolItem* pItem; - if(SFX_ITEM_SET == rItemSet.GetItemState( RES_TXTATR_CJK_RUBY, sal_True, &pItem ) ) - pRuby = new SwFmtRuby(*((SwFmtRuby*)pItem)); - if(!pRuby) - pRuby = new SwFmtRuby(aEmptyStr); - String sStyle; - SwStyleNameMapper::FillUIName(sTmp, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True ); - pRuby->SetCharFmtName( sStyle ); - pRuby->SetCharFmtId( 0 ); - if(sStyle.Len() > 0) - { - sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); - pRuby->SetCharFmtId(nId); - } - rItemSet.Put(*pRuby); - delete pRuby; - } - else - throw lang::IllegalArgumentException(); - bRet = sal_True; - } - else - bRet = sal_False; - break; - case RES_PAGEDESC : - if(MID_PAGEDESC_PAGEDESCNAME == pEntry->nMemberId ) + else { - lcl_setPageDesc(rPam.GetDoc(), aValue, rItemSet); - break; + bRet = false; + } + } + break; + case RES_TXTATR_CJK_RUBY: + { + if (MID_RUBY_CHARSTYLE == rEntry.nMemberId) + { + lcl_setRubyCharstyle(rItemSet, rValue); + } + else + { + bRet = false; } - //hier kein break - default: bRet = sal_False; } + break; + case RES_PAGEDESC: + { + if (MID_PAGEDESC_PAGEDESCNAME == rEntry.nMemberId) + { + SwUnoCursorHelper::SetPageDesc( + rValue, *rPam.GetDoc(), rItemSet); + } + else + { + bRet = false; + } + } + break; + default: + bRet = false; } -return bRet; + return bRet; } /* -----------------30.06.98 08:39------------------- * * --------------------------------------------------*/ -SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) +SwFmtColl * +SwUnoCursorHelper::GetCurTxtFmtColl(SwPaM & rPaM, const bool bConditional) { static const sal_uInt16 nMaxLookup = 1000; SwFmtColl *pFmt = 0; // if ( GetCrsrCnt() > nMaxLookup ) // return 0; - sal_Bool bError = sal_False; + bool bError = false; SwPaM *pTmpCrsr = &rPaM; - do { - - ULONG nSttNd = pTmpCrsr->GetMark()->nNode.GetIndex(); - ULONG nEndNd = pTmpCrsr->GetPoint()->nNode.GetIndex(); - xub_StrLen nSttCnt = pTmpCrsr->GetMark()->nContent.GetIndex(); - xub_StrLen nEndCnt = pTmpCrsr->GetPoint()->nContent.GetIndex(); - - if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt )) - { - sal_uInt32 nTmp = nSttNd; nSttNd = nEndNd; nEndNd = nTmp; - nTmp = nSttCnt; nSttCnt = nEndCnt; nEndCnt = (sal_uInt16)nTmp; - } + do + { + const ULONG nSttNd = pTmpCrsr->Start()->nNode.GetIndex(); + const ULONG nEndNd = pTmpCrsr->End()->nNode.GetIndex(); if( nEndNd - nSttNd >= nMaxLookup ) { @@ -685,33 +716,33 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) const SwNodes& rNds = rPaM.GetDoc()->GetNodes(); for( ULONG n = nSttNd; n <= nEndNd; ++n ) { - const SwTxtNode* pNd = rNds[ n ]->GetTxtNode(); + SwTxtNode const*const pNd = rNds[ n ]->GetTxtNode(); if( pNd ) { - SwFmtColl* pNdFmt = bConditional ? pNd->GetFmtColl() - : &pNd->GetAnyFmtColl(); + SwFmtColl *const pNdFmt = (bConditional) + ? pNd->GetFmtColl() : &pNd->GetAnyFmtColl(); if( !pFmt ) + { pFmt = pNdFmt; + } else if( pFmt != pNdFmt ) { - bError = sal_True; + bError = true; break; } } } - if(bError) - break; pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); } while ( pTmpCrsr != &rPaM ); - return bError ? 0 : pFmt; + return (bError) ? 0 : pFmt; } /* -----------------26.06.98 16:20------------------- * Hilfsfunktion fuer PageDesc * --------------------------------------------------*/ - SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName) - { +SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName) +{ SwPageDesc* pRet = 0; sal_uInt16 nDCount = rDoc.GetPageDescCnt(); sal_uInt16 i; @@ -732,7 +763,8 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) const String aFmtName(SW_RES(i)); if(aFmtName == rName) { - pRet = rDoc.GetPageDescFromPool( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) ); + pRet = rDoc.GetPageDescFromPool( static_cast< sal_uInt16 >( + RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) ); break; } } @@ -740,95 +772,146 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) return pRet; } -/****************************************************************************** - ****************************************************************************** - ****************************************************************************** - * Taskforce ONE51 - ******************************************************************************/ /****************************************************************** * SwXTextCursor ******************************************************************/ -/*-- 09.12.98 14:19:19--------------------------------------------------- +class SwXTextCursor::Impl + : public SwClient +{ - -----------------------------------------------------------------------*/ -OUString SwXTextCursor::getImplementationName(void) throw( RuntimeException ) +public: + + const SfxItemPropertySet & m_rPropSet; + const enum CursorType m_eType; + const uno::Reference< text::XText > m_xParentText; + SwEventListenerContainer m_ListenerContainer; + bool m_bIsDisposed; + + Impl( SwXTextCursor & rThis, + SwDoc & rDoc, + const enum CursorType eType, + uno::Reference<text::XText> xParent, + SwPosition const& rPoint, SwPosition const*const pMark) + : SwClient(rDoc.CreateUnoCrsr(rPoint, sal_False)) + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)) + , m_eType(eType) + , m_xParentText(xParent) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIsDisposed(false) + { + if (pMark) + { + GetCursor()->SetMark(); + *GetCursor()->GetMark() = *pMark; + } + } + + ~Impl() { + // Impl owns the cursor; delete it here: SolarMutex is locked + delete GetRegisteredIn(); + } + + SwUnoCrsr * GetCursor() { + return (m_bIsDisposed) ? 0 : + static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn())); + } + + SwUnoCrsr & GetCursorOrThrow() { + SwUnoCrsr *const pUnoCursor( GetCursor() ); + if (!pUnoCursor) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXTextCursor: disposed or invalid")), 0); + } + return *pUnoCursor; + } + + void Invalidate() { + m_bIsDisposed = true; + m_ListenerContainer.Disposing(); + } + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +void SwXTextCursor::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { - return C2U("SwXTextCursor"); + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn() || + // if the cursor leaves its designated section, it becomes invalid + (pOld != NULL) && (pOld->Which() == RES_UNOCURSOR_LEAVES_SECTION)) + { + Invalidate(); + } +} + + +SwUnoCrsr const* SwXTextCursor::GetCursor() const +{ + return m_pImpl->GetCursor(); } -/*-- 09.12.98 14:19:19--------------------------------------------------- + +SwUnoCrsr * SwXTextCursor::GetCursor() +{ + return m_pImpl->GetCursor(); +} + +/*-- 09.12.98 14:19:01--------------------------------------------------- -----------------------------------------------------------------------*/ -BOOL SwXTextCursor::supportsService(const OUString& rServiceName) throw( RuntimeException ) -{ - String sServiceName(rServiceName); - return sServiceName.EqualsAscii("com.sun.star.text.TextCursor") || - sServiceName.EqualsAscii("com.sun.star.style.CharacterProperties")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesAsian")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesComplex")|| - sServiceName.EqualsAscii("com.sun.star.style.ParagraphProperties") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesAsian") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesComplex") || - sServiceName.EqualsAscii("com.sun.star.text.TextSortable"); +SwPaM const* SwXTextCursor::GetPaM() const +{ + return m_pImpl->GetCursor(); +} + +SwPaM * SwXTextCursor::GetPaM() +{ + return m_pImpl->GetCursor(); } -/*-- 09.12.98 14:19:19--------------------------------------------------- + +/*-- 09.12.98 14:19:02--------------------------------------------------- -----------------------------------------------------------------------*/ -Sequence< OUString > SwXTextCursor::getSupportedServiceNames(void) throw( RuntimeException ) +SwDoc const* SwXTextCursor::GetDoc() const { - Sequence< OUString > aRet(8); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.TextCursor"); - pArray[1] = C2U("com.sun.star.style.CharacterProperties"); - pArray[2] = C2U("com.sun.star.style.CharacterPropertiesAsian"); - pArray[3] = C2U("com.sun.star.style.CharacterPropertiesComplex"); - pArray[4] = C2U("com.sun.star.style.ParagraphProperties"); - pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian"); - pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex"); - pArray[7] = C2U("com.sun.star.text.TextSortable"); - return aRet; + return m_pImpl->GetCursor() ? m_pImpl->GetCursor()->GetDoc() : 0; } +/* -----------------22.07.99 13:52------------------- + + --------------------------------------------------*/ +SwDoc * SwXTextCursor::GetDoc() +{ + return m_pImpl->GetCursor() ? m_pImpl->GetCursor()->GetDoc() : 0; +} + + /*-- 09.12.98 14:19:19--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXTextCursor::SwXTextCursor(uno::Reference< XText > xParent, const SwPosition& rPos, - CursorType eSet, SwDoc* pDoc, const SwPosition* pMark) : - aLstnrCntnr(( util::XSortable*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - xParentText(xParent), - pLastSortOptions(0), - eType(eSet), - mbRemoveUserEvent( false ) +SwXTextCursor::SwXTextCursor( + SwDoc & rDoc, + uno::Reference< text::XText > const& xParent, + const enum CursorType eType, + const SwPosition& rPos, + SwPosition const*const pMark) + : m_pImpl( new SwXTextCursor::Impl(*this, rDoc, eType, xParent, + rPos, pMark ) ) { - SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(rPos, sal_False); - if(pMark) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pMark; - } - pUnoCrsr->Add(this); } /* -----------------04.03.99 09:02------------------- * * --------------------------------------------------*/ -SwXTextCursor::SwXTextCursor(uno::Reference< XText > xParent, - SwUnoCrsr* pSourceCrsr, CursorType eSet) : - aLstnrCntnr( (util::XSortable*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - xParentText(xParent), - pLastSortOptions(0), - eType(eSet), - mbRemoveUserEvent( false ) +SwXTextCursor::SwXTextCursor(uno::Reference< text::XText > const& xParent, + SwPaM const& rSourceCursor, const enum CursorType eType) + : m_pImpl( new SwXTextCursor::Impl(*this, *rSourceCursor.GetDoc(), eType, + xParent, *rSourceCursor.GetPoint(), + rSourceCursor.HasMark() ? rSourceCursor.GetMark() : 0) ) { - SwUnoCrsr* pUnoCrsr = pSourceCrsr->GetDoc()->CreateUnoCrsr(*pSourceCrsr->GetPoint(), sal_False); - if(pSourceCrsr->HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pSourceCrsr->GetMark(); - } - pUnoCrsr->Add(this); } /*-- 09.12.98 14:19:20--------------------------------------------------- @@ -836,55 +919,43 @@ SwXTextCursor::SwXTextCursor(uno::Reference< XText > xParent, -----------------------------------------------------------------------*/ SwXTextCursor::~SwXTextCursor() { - vos::OGuard aGuard(Application::GetSolarMutex()); - - // --> FME 2006-03-07 #126177# A user event has been posted in order - // to delete the SwUnoCursor. Remove the user event if the SwXTextCursor - // is destroyed before the user event could be handled. - if ( mbRemoveUserEvent ) - { - mbRemoveUserEvent = false; - Application::RemoveUserEvent( mnUserEventId ); - } - // <-- - - SwUnoCrsr* pUnoCrsr = GetCrsr(); - delete pUnoCrsr; - delete pLastSortOptions; } + /*-- 09.12.98 14:19:18--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::DeleteAndInsert(const String& rText, +void SwXTextCursor::DeleteAndInsert(const ::rtl::OUString& rText, const bool bForceExpandHints) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr *const pUnoCrsr = m_pImpl->GetCursor(); if(pUnoCrsr) { // Start/EndAction SwDoc* pDoc = pUnoCrsr->GetDoc(); UnoActionContext aAction(pDoc); - xub_StrLen nTxtLen = rText.Len(); + const xub_StrLen nTxtLen = rText.getLength(); pDoc->StartUndo(UNDO_INSERT, NULL); - SwCursor *_pStartCrsr = pUnoCrsr; + SwCursor * pCurrent = pUnoCrsr; do { - if(_pStartCrsr->HasMark()) + if (pCurrent->HasMark()) { - pDoc->DeleteAndJoin(*_pStartCrsr); + pDoc->DeleteAndJoin(*pCurrent); } if(nTxtLen) { const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR( - *pDoc, *_pStartCrsr, rText, bForceExpandHints ) ); + *pDoc, *pCurrent, rText, bForceExpandHints ) ); DBG_ASSERT( bSuccess, "Doc->Insert(Str) failed." ); (void) bSuccess; - SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); - _pStartCrsr->Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); + SwUnoCursorHelper::SelectPam(*pUnoCrsr, true); + pCurrent->Left(rText.getLength(), + CRSR_SKIP_CHARS, FALSE, FALSE); } - } while( (_pStartCrsr=(SwCursor*)_pStartCrsr->GetNext()) != pUnoCrsr ); + pCurrent = static_cast<SwCursor *>(pCurrent->GetNext()); + } while (pCurrent != pUnoCrsr); pDoc->EndUndo(UNDO_INSERT, NULL); } } @@ -892,7 +963,8 @@ void SwXTextCursor::DeleteAndInsert(const String& rText, enum ForceIntoMetaMode { META_CHECK_BOTH, META_INIT_START, META_INIT_END }; -sal_Bool lcl_ForceIntoMeta(SwPaM & rCursor, +static sal_Bool +lcl_ForceIntoMeta(SwPaM & rCursor, uno::Reference<text::XText> const & xParentText, const enum ForceIntoMetaMode eMode) { @@ -937,10 +1009,11 @@ sal_Bool lcl_ForceIntoMeta(SwPaM & rCursor, bool SwXTextCursor::IsAtEndOfMeta() const { - if (CURSOR_META == eType) + if (CURSOR_META == m_pImpl->m_eType) { - SwUnoCrsr const * const pCursor( GetCrsr() ); - SwXMeta const*const pXMeta( dynamic_cast<SwXMeta*>(xParentText.get()) ); + SwUnoCrsr const * const pCursor( m_pImpl->GetCursor() ); + SwXMeta const*const pXMeta( + dynamic_cast<SwXMeta*>(m_pImpl->m_xParentText.get()) ); ASSERT(pXMeta, "no meta?"); if (pCursor && pXMeta) { @@ -964,6 +1037,45 @@ bool SwXTextCursor::IsAtEndOfMeta() const return false; } +/*-- 09.12.98 14:19:19--------------------------------------------------- + + -----------------------------------------------------------------------*/ +OUString SwXTextCursor::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXTextCursor"); +} + +/*-- 09.12.98 14:19:19--------------------------------------------------- + + -----------------------------------------------------------------------*/ +static char const*const g_ServicesTextCursor[] = +{ + "com.sun.star.text.TextCursor", + "com.sun.star.style.CharacterProperties", + "com.sun.star.style.CharacterPropertiesAsian", + "com.sun.star.style.CharacterPropertiesComplex", + "com.sun.star.style.ParagraphProperties", + "com.sun.star.style.ParagraphPropertiesAsian", + "com.sun.star.style.ParagraphPropertiesComplex", + "com.sun.star.text.TextSortable", +}; +static const size_t g_nServicesTextCursor( + sizeof(g_ServicesTextCursor)/sizeof(g_ServicesTextCursor[0])); + +sal_Bool SAL_CALL SwXTextCursor::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesTextCursor, g_ServicesTextCursor, rServiceName); +} + +uno::Sequence< OUString > SAL_CALL +SwXTextCursor::getSupportedServiceNames() throw (uno::RuntimeException) +{ + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesTextCursor, g_ServicesTextCursor); +} + /* -----------------------------10.03.00 18:02-------------------------------- ---------------------------------------------------------------------------*/ @@ -975,231 +1087,219 @@ const uno::Sequence< sal_Int8 > & SwXTextCursor::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXTextCursor::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXTextCursor::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 OTextCursorHelper::getSomething(rId); + const sal_Int64 nRet( ::sw::UnoTunnelImpl<SwXTextCursor>(rId, this) ); + return (nRet) ? nRet : OTextCursorHelper::getSomething(rId); } /*-- 09.12.98 14:18:12--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::collapseToStart(void) throw( uno::RuntimeException ) +void SAL_CALL SwXTextCursor::collapseToStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (rUnoCursor.HasMark()) { - if(pUnoCrsr->HasMark()) + if (*rUnoCursor.GetPoint() > *rUnoCursor.GetMark()) { - if(*pUnoCrsr->GetPoint() > *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); - pUnoCrsr->DeleteMark(); + rUnoCursor.Exchange(); } - } - else - { - throw uno::RuntimeException(); + rUnoCursor.DeleteMark(); } } /*-- 09.12.98 14:18:14--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::collapseToEnd(void) throw( uno::RuntimeException ) +void SAL_CALL SwXTextCursor::collapseToEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (rUnoCursor.HasMark()) { - if(pUnoCrsr->HasMark()) + if (*rUnoCursor.GetPoint() < *rUnoCursor.GetMark()) { - if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); - pUnoCrsr->DeleteMark(); + rUnoCursor.Exchange(); } - } - else - { - throw uno::RuntimeException(); + rUnoCursor.DeleteMark(); } } /*-- 09.12.98 14:18:41--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isCollapsed(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextCursor::isCollapsed() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + sal_Bool bRet = sal_True; - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr *const pUnoCrsr = m_pImpl->GetCursor(); if(pUnoCrsr && pUnoCrsr->GetMark()) { bRet = (*pUnoCrsr->GetPoint() == *pUnoCrsr->GetMark()); } return bRet; } + /*-- 09.12.98 14:18:42--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->Left( nCount, CRSR_SKIP_CHARS, FALSE, FALSE); - if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; - } - } - else + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = rUnoCursor.Left( nCount, CRSR_SKIP_CHARS, FALSE, FALSE); + if (CURSOR_META == m_pImpl->m_eType) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; } return bRet; } /*-- 09.12.98 14:18:42--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->Right(nCount, CRSR_SKIP_CHARS, FALSE, FALSE); - if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; - } - } - else + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = rUnoCursor.Right(nCount, CRSR_SKIP_CHARS, FALSE, FALSE); + if (CURSOR_META == m_pImpl->m_eType) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; } return bRet; } + /*-- 09.12.98 14:18:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::gotoStart(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + if (CURSOR_BODY == m_pImpl->m_eType) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - if(eType == CURSOR_BODY) + rUnoCursor.Move( fnMoveBackward, fnGoDoc ); + //check, that the cursor is not in a table + SwTableNode * pTblNode = rUnoCursor.GetNode()->FindTableNode(); + SwCntntNode * pCNode = 0; + while (pTblNode) { - pUnoCrsr->Move( fnMoveBackward, fnGoDoc ); - //check, that the cursor is not in a table - SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); - SwCntntNode* pCont = 0; - while( pTblNode ) - { - pUnoCrsr->GetPoint()->nNode = *pTblNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&pUnoCrsr->GetPoint()->nNode); - pTblNode = pCont ? pCont->FindTableNode() : 0; - } - if(pCont) - pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); - const SwStartNode* pTmp = pUnoCrsr->GetNode()->StartOfSectionNode(); - if(pTmp->IsSectionNode()) - { - SwSectionNode* pSectionStartNode = (SwSectionNode*)pTmp; - if(pSectionStartNode->GetSection().IsHiddenFlag()) - { - pCont = GetDoc()->GetNodes().GoNextSection( - &pUnoCrsr->GetPoint()->nNode, sal_True, sal_False); - if(pCont) - pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); - } - } + rUnoCursor.GetPoint()->nNode = *pTblNode->EndOfSectionNode(); + pCNode = GetDoc()->GetNodes().GoNext(&rUnoCursor.GetPoint()->nNode); + pTblNode = (pCNode) ? pCNode->FindTableNode() : 0; } - else if(eType == CURSOR_FRAME || - eType == CURSOR_TBLTEXT || - eType == CURSOR_HEADER || - eType == CURSOR_FOOTER || - eType == CURSOR_FOOTNOTE|| - eType == CURSOR_REDLINE) + if (pCNode) { - pUnoCrsr->MoveSection( fnSectionCurr, fnSectionStart); + rUnoCursor.GetPoint()->nContent.Assign(pCNode, 0); } - else if (CURSOR_META == eType) + SwStartNode const*const pTmp = + rUnoCursor.GetNode()->StartOfSectionNode(); + if (pTmp->IsSectionNode()) { - lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_INIT_START); + SwSectionNode const*const pSectionStartNode = + static_cast<SwSectionNode const*>(pTmp); + if (pSectionStartNode->GetSection().IsHiddenFlag()) + { + pCNode = GetDoc()->GetNodes().GoNextSection( + &rUnoCursor.GetPoint()->nNode, sal_True, sal_False); + if (pCNode) + { + rUnoCursor.GetPoint()->nContent.Assign(pCNode, 0); + } + } } } - else + else if ( (CURSOR_FRAME == m_pImpl->m_eType) + || (CURSOR_TBLTEXT == m_pImpl->m_eType) + || (CURSOR_HEADER == m_pImpl->m_eType) + || (CURSOR_FOOTER == m_pImpl->m_eType) + || (CURSOR_FOOTNOTE== m_pImpl->m_eType) + || (CURSOR_REDLINE == m_pImpl->m_eType)) { - throw uno::RuntimeException(); + rUnoCursor.MoveSection(fnSectionCurr, fnSectionStart); + } + else if (CURSOR_META == m_pImpl->m_eType) + { + lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, META_INIT_START); } } /*-- 09.12.98 14:18:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::gotoEnd(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + if (CURSOR_BODY == m_pImpl->m_eType) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - if(eType == CURSOR_BODY) - { - pUnoCrsr->Move( fnMoveForward, fnGoDoc ); - } - else if(eType == CURSOR_FRAME || - eType == CURSOR_TBLTEXT || - eType == CURSOR_HEADER || - eType == CURSOR_FOOTER || - eType == CURSOR_FOOTNOTE|| - eType == CURSOR_REDLINE) - { - pUnoCrsr->MoveSection( fnSectionCurr, fnSectionEnd); - } - else if (CURSOR_META == eType) - { - lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_INIT_END); - } + rUnoCursor.Move( fnMoveForward, fnGoDoc ); } - else + else if ( (CURSOR_FRAME == m_pImpl->m_eType) + || (CURSOR_TBLTEXT == m_pImpl->m_eType) + || (CURSOR_HEADER == m_pImpl->m_eType) + || (CURSOR_FOOTER == m_pImpl->m_eType) + || (CURSOR_FOOTNOTE== m_pImpl->m_eType) + || (CURSOR_REDLINE == m_pImpl->m_eType)) { - throw uno::RuntimeException(); + rUnoCursor.MoveSection( fnSectionCurr, fnSectionEnd); + } + else if (CURSOR_META == m_pImpl->m_eType) + { + lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, META_INIT_END); } } -void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_Bool bExpand ) - throw( uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::gotoRange( + const uno::Reference< text::XTextRange > & xRange, sal_Bool bExpand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pOwnCursor = GetCrsr(); - if(!pOwnCursor || !xRange.is()) + + if (!xRange.is()) { throw uno::RuntimeException(); } + SwUnoCrsr & rOwnCursor( m_pImpl->GetCursorOrThrow() ); + uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; OTextCursorHelper* pCursor = 0; if(xRangeTunnel.is()) { - 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()) )); + pRange = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel); } if (!pRange && !pCursor) @@ -1208,7 +1308,7 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B } SwStartNodeType eSearchNodeType = SwNormalStartNode; - switch(eType) + switch (m_pImpl->m_eType) { case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break; case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break; @@ -1220,20 +1320,29 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B default: ; } - const SwStartNode* pOwnStartNode = pOwnCursor->GetNode()-> - FindSttNodeByType(eSearchNodeType); + const SwStartNode* pOwnStartNode = + rOwnCursor.GetNode()->FindSttNodeByType(eSearchNodeType); - const SwNode* pSrcNode = 0; - if(pCursor && pCursor->GetPaM()) + SwPaM aPam(GetDoc()->GetNodes()); + const SwPaM * pPam(0); + if (pCursor) { - pSrcNode = pCursor->GetPaM()->GetNode(); + pPam = pCursor->GetPaM(); } - else if(pRange && pRange->GetBookmark()) + else if (pRange) { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - pSrcNode = &pBkmk->GetMarkPos().nNode.GetNode(); + if (pRange->GetPositions(aPam)) + { + pPam = & aPam; + } } - const SwStartNode* pTmp = pSrcNode ? pSrcNode->FindSttNodeByType(eSearchNodeType) : 0; + + if (!pPam) + { + throw uno::RuntimeException(); + } + const SwStartNode* pTmp = + pPam->GetNode()->FindSttNodeByType(eSearchNodeType); //SectionNodes ueberspringen while(pTmp && pTmp->IsSectionNode()) @@ -1249,18 +1358,11 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B throw uno::RuntimeException(); } - if (CURSOR_META == eType) + if (CURSOR_META == m_pImpl->m_eType) { - const SwPosition & rPoint( (pRange) - ? pRange->GetBookmark()->GetMarkPos() - : *pCursor->GetPaM()->GetPoint() ); - const SwPosition & rMark ( (pRange) - ? ((pRange->GetBookmark()->IsExpanded()) - ? pRange->GetBookmark()->GetOtherMarkPos() : rPoint) - : *pCursor->GetPaM()->GetMark() ); - SwPaM aPam(rPoint, rMark); - const bool bNotForced( - lcl_ForceIntoMeta(aPam, xParentText, META_CHECK_BOTH) ); + SwPaM CopyPam(*pPam->GetMark(), *pPam->GetPoint()); + const bool bNotForced( lcl_ForceIntoMeta( + CopyPam, m_pImpl->m_xParentText, META_CHECK_BOTH) ); if (!bNotForced) { throw uno::RuntimeException( @@ -1275,73 +1377,30 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B { // der Cursor soll alles einschliessen, was bisher von ihm und dem uebergebenen // Range eingeschlossen wurde - SwPosition aOwnLeft(*pOwnCursor->GetPoint()); - SwPosition aOwnRight(pOwnCursor->HasMark() ? *pOwnCursor->GetMark() : aOwnLeft); - if(aOwnRight < aOwnLeft) - { - SwPosition aTmp = aOwnLeft; - aOwnLeft = aOwnRight; - aOwnRight = aTmp; - } - SwPosition* pParamLeft; - SwPosition* pParamRight; - if(pCursor) - { - const SwPaM* pTmp2 = pCursor->GetPaM(); - pParamLeft = new SwPosition(*pTmp2->GetPoint()); - pParamRight = new SwPosition(pTmp2->HasMark() ? *pTmp2->GetMark() : *pParamLeft); - } - else - { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - pParamLeft = new SwPosition(pBkmk->GetMarkPos()); - pParamRight = new SwPosition(pBkmk->IsExpanded() ? pBkmk->GetOtherMarkPos() : *pParamLeft); - } - if(*pParamRight < *pParamLeft) - { - SwPosition* pTmp2 = pParamLeft; - pParamLeft = pParamRight; - pParamRight = pTmp2; - } + const SwPosition aOwnLeft(*rOwnCursor.Start()); + const SwPosition aOwnRight(*rOwnCursor.End()); + SwPosition const& rParamLeft = *pPam->Start(); + SwPosition const& rParamRight = *pPam->End(); + // jetzt sind vier SwPositions da, zwei davon werden gebraucht, also welche? - if(aOwnRight > *pParamRight) - *pOwnCursor->GetPoint() = aOwnRight; - else - *pOwnCursor->GetPoint() = *pParamRight; - pOwnCursor->SetMark(); - if(aOwnLeft < *pParamLeft) - *pOwnCursor->GetMark() = aOwnLeft; - else - *pOwnCursor->GetMark() = *pParamLeft; - delete pParamLeft; - delete pParamRight; + *rOwnCursor.GetPoint() = (aOwnRight > rParamRight) + ? aOwnRight : *rOwnCursor.GetPoint() = rParamRight; + rOwnCursor.SetMark(); + *rOwnCursor.GetMark() = (aOwnLeft < rParamLeft) + ? aOwnLeft : *rOwnCursor.GetMark() = rParamLeft; } else { - //der Cursor soll dem uebergebenen Range entsprechen - if(pCursor) + // cursor should be the given range + *rOwnCursor.GetPoint() = *pPam->GetPoint(); + if (pPam->HasMark()) { - const SwPaM* pTmp2 = pCursor->GetPaM(); - *pOwnCursor->GetPoint() = *pTmp2->GetPoint(); - if(pTmp2->HasMark()) - { - pOwnCursor->SetMark(); - *pOwnCursor->GetMark() = *pTmp2->GetMark(); - } - else - pOwnCursor->DeleteMark(); + rOwnCursor.SetMark(); + *rOwnCursor.GetMark() = *pPam->GetMark(); } else { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - *pOwnCursor->GetPoint() = pBkmk->GetMarkPos(); - if(pBkmk->IsExpanded()) - { - pOwnCursor->SetMark(); - *pOwnCursor->GetMark() = pBkmk->GetOtherMarkPos(); - } - else - pOwnCursor->DeleteMark(); + rOwnCursor.DeleteMark(); } } } @@ -1349,169 +1408,157 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B /*-- 09.12.98 14:18:44--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isStartOfWord(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextCursor::isStartOfWord() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - bRet = pUnoCrsr->IsStartWordWT( i18n::WordType::DICTIONARY_WORD ); - } - else - { - throw uno::RuntimeException(); - } + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Bool bRet = + rUnoCursor.IsStartWordWT( i18n::WordType::DICTIONARY_WORD ); return bRet; } /*-- 09.12.98 14:18:44--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isEndOfWord(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextCursor::isEndOfWord() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - bRet = pUnoCrsr->IsEndWordWT( i18n::WordType::DICTIONARY_WORD ); - } - else - { - throw uno::RuntimeException(); - } + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Bool bRet = + rUnoCursor.IsEndWordWT( i18n::WordType::DICTIONARY_WORD ); return bRet; } + /*-- 09.12.98 14:18:44--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoNextWord(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoNextWord(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - //Probleme gibt's noch mit einem Absatzanfang, an dem kein Wort beginnt. - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + //Probleme gibt's noch mit einem Absatzanfang, an dem kein Wort beginnt. sal_Bool bRet = sal_False; - if(pUnoCrsr) - { - // remember old position to check if cursor has moved - // since the called functions are sometimes a bit unreliable - // in specific cases... - SwPosition *pPoint = pUnoCrsr->GetPoint(); - SwNode *pOldNode = &pPoint->nNode.GetNode(); - xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); - - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - //Absatzende? - if(pUnoCrsr->GetCntntNode() && - pPoint->nContent == pUnoCrsr->GetCntntNode()->Len()) - { - pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); - } - else - { - sal_Bool bTmp = pUnoCrsr->GoNextWordWT( i18n::WordType::DICTIONARY_WORD ); - //if there is no next word within the current paragraph try to go to the start of the next paragraph - if(!bTmp) - pUnoCrsr->MovePara(fnParaNext, fnParaStart); - } + // remember old position to check if cursor has moved + // since the called functions are sometimes a bit unreliable + // in specific cases... + SwPosition *const pPoint = rUnoCursor.GetPoint(); + SwNode *const pOldNode = &pPoint->nNode.GetNode(); + xub_StrLen const nOldIndex = pPoint->nContent.GetIndex(); - // return true if cursor has moved - bRet = &pPoint->nNode.GetNode() != pOldNode || - pPoint->nContent.GetIndex() != nOldIndex; - if (bRet && (CURSOR_META == eType)) + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + // end of paragraph + if (rUnoCursor.GetCntntNode() && + (pPoint->nContent == rUnoCursor.GetCntntNode()->Len())) + { + rUnoCursor.Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); + } + else + { + const bool bTmp = + rUnoCursor.GoNextWordWT( i18n::WordType::DICTIONARY_WORD ); + // if there is no next word within the current paragraph + // try to go to the start of the next paragraph + if (!bTmp) { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + rUnoCursor.MovePara(fnParaNext, fnParaStart); } } - else + + // return true if cursor has moved + bRet = (&pPoint->nNode.GetNode() != pOldNode) || + (pPoint->nContent.GetIndex() != nOldIndex); + if (bRet && (CURSOR_META == m_pImpl->m_eType)) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH); } return bRet; } + /*-- 09.12.98 14:18:45--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - // hier machen Leerzeichen am Absatzanfang Probleme - SwUnoCrsr* pUnoCrsr = GetCrsr(); - sal_Bool bRet = sal_False; - if(pUnoCrsr) - { - SwPosition *pPoint = pUnoCrsr->GetPoint(); - SwNode *pOldNode = &pPoint->nNode.GetNode(); - xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - //Absatzanfang ? - if(pPoint->nContent == 0) - { - pUnoCrsr->Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); - } - else - { - pUnoCrsr->GoPrevWordWT( i18n::WordType::DICTIONARY_WORD ); - if(pPoint->nContent == 0) - pUnoCrsr->Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); - } + // hier machen Leerzeichen am Absatzanfang Probleme + sal_Bool bRet = sal_False; + SwPosition *const pPoint = rUnoCursor.GetPoint(); + SwNode *const pOldNode = &pPoint->nNode.GetNode(); + xub_StrLen const nOldIndex = pPoint->nContent.GetIndex(); - // return true if cursor has moved - bRet = &pPoint->nNode.GetNode() != pOldNode || - pPoint->nContent.GetIndex() != nOldIndex; - if (bRet && (CURSOR_META == eType)) + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + // start of paragraph? + if (pPoint->nContent == 0) + { + rUnoCursor.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); + } + else + { + rUnoCursor.GoPrevWordWT( i18n::WordType::DICTIONARY_WORD ); + if (pPoint->nContent == 0) { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + rUnoCursor.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); } } - else + + // return true if cursor has moved + bRet = (&pPoint->nNode.GetNode() != pOldNode) || + (pPoint->nContent.GetIndex() != nOldIndex); + if (bRet && (CURSOR_META == m_pImpl->m_eType)) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH); } return bRet; } + /*-- 09.12.98 14:18:45--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); sal_Bool bRet = sal_False; - if(pUnoCrsr) - { - SwPosition *pPoint = pUnoCrsr->GetPoint(); - SwNode &rOldNode = pPoint->nNode.GetNode(); - xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); + SwPosition *const pPoint = rUnoCursor.GetPoint(); + SwNode & rOldNode = pPoint->nNode.GetNode(); + xub_StrLen const nOldIndex = pPoint->nContent.GetIndex(); - sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - if(!pUnoCrsr->IsEndWordWT( nWordType )) - pUnoCrsr->GoEndWordWT( nWordType ); + const sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + if (!rUnoCursor.IsEndWordWT( nWordType )) + { + rUnoCursor.GoEndWordWT( nWordType ); + } - // restore old cursor if we are not at the end of a word by now - // otherwise use current one - bRet = pUnoCrsr->IsEndWordWT( nWordType ); - if (!bRet) - { - pPoint->nNode = rOldNode; - pPoint->nContent = nOldIndex; - } - else if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); - } + // restore old cursor if we are not at the end of a word by now + // otherwise use current one + bRet = rUnoCursor.IsEndWordWT( nWordType ); + if (!bRet) + { + pPoint->nNode = rOldNode; + pPoint->nContent = nOldIndex; } - else + else if (CURSOR_META == m_pImpl->m_eType) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH); } return bRet; @@ -1519,270 +1566,266 @@ sal_Bool SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw( uno::RuntimeExcept /*-- 09.12.98 14:18:46--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoStartOfWord(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoStartOfWord(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); sal_Bool bRet = sal_False; - if(pUnoCrsr) - { - SwPosition *pPoint = pUnoCrsr->GetPoint(); - SwNode &rOldNode = pPoint->nNode.GetNode(); - xub_StrLen nOldIndex = pPoint->nContent.GetIndex(); + SwPosition *const pPoint = rUnoCursor.GetPoint(); + SwNode & rOldNode = pPoint->nNode.GetNode(); + xub_StrLen const nOldIndex = pPoint->nContent.GetIndex(); - sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - if(!pUnoCrsr->IsStartWordWT( nWordType )) - pUnoCrsr->GoStartWordWT( nWordType ); + const sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD; + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + if (!rUnoCursor.IsStartWordWT( nWordType )) + { + rUnoCursor.GoStartWordWT( nWordType ); + } - // restore old cursor if we are not at the start of a word by now - // otherwise use current one - bRet = pUnoCrsr->IsStartWordWT( nWordType ); - if (!bRet) - { - pPoint->nNode = rOldNode; - pPoint->nContent = nOldIndex; - } - else if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); - } + // restore old cursor if we are not at the start of a word by now + // otherwise use current one + bRet = rUnoCursor.IsStartWordWT( nWordType ); + if (!bRet) + { + pPoint->nNode = rOldNode; + pPoint->nContent = nOldIndex; } - else + else if (CURSOR_META == m_pImpl->m_eType) { - throw uno::RuntimeException(); + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH); } return bRet; } + /*-- 09.12.98 14:18:46--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isStartOfSentence(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::isStartOfSentence() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + // start of paragraph? + sal_Bool bRet = rUnoCursor.GetPoint()->nContent == 0; + // with mark ->no sentence start + // (check if cursor is no selection, i.e. it does not have + // a mark or else point and mark are identical) + if (!bRet && (!rUnoCursor.HasMark() || + *rUnoCursor.GetPoint() == *rUnoCursor.GetMark())) { - // start of paragraph? - bRet = pUnoCrsr->GetPoint()->nContent == 0; - // with mark ->no sentence start - // (check if cursor is no selection, i.e. it does not have - // a mark or else point and mark are identical) - if(!bRet && (!pUnoCrsr->HasMark() || - *pUnoCrsr->GetPoint() == *pUnoCrsr->GetMark())) - { - SwCursor aCrsr(*pUnoCrsr->GetPoint(),0,false); - SwPosition aOrigPos = *aCrsr.GetPoint(); - aCrsr.GoSentence(SwCursor::START_SENT ); - bRet = aOrigPos == *aCrsr.GetPoint(); - } + SwCursor aCrsr(*rUnoCursor.GetPoint(),0,false); + SwPosition aOrigPos = *aCrsr.GetPoint(); + aCrsr.GoSentence(SwCursor::START_SENT ); + bRet = aOrigPos == *aCrsr.GetPoint(); } - else - throw uno::RuntimeException(); return bRet; } /*-- 09.12.98 14:18:47--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isEndOfSentence(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::isEndOfSentence() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + // end of paragraph? + sal_Bool bRet = rUnoCursor.GetCntntNode() && + (rUnoCursor.GetPoint()->nContent == rUnoCursor.GetCntntNode()->Len()); + // with mark->no sentence end + // (check if cursor is no selection, i.e. it does not have + // a mark or else point and mark are identical) + if (!bRet && (!rUnoCursor.HasMark() || + *rUnoCursor.GetPoint() == *rUnoCursor.GetMark())) { - //end of paragraph? - bRet = pUnoCrsr->GetCntntNode() && - pUnoCrsr->GetPoint()->nContent == pUnoCrsr->GetCntntNode()->Len(); - // with mark->no sentence end - // (check if cursor is no selection, i.e. it does not have - // a mark or else point and mark are identical) - if(!bRet && (!pUnoCrsr->HasMark() || - *pUnoCrsr->GetPoint() == *pUnoCrsr->GetMark())) - { - SwCursor aCrsr(*pUnoCrsr->GetPoint(),0,false); - SwPosition aOrigPos = *aCrsr.GetPoint(); - aCrsr.GoSentence(SwCursor::END_SENT ); - bRet = aOrigPos == *aCrsr.GetPoint(); - } + SwCursor aCrsr(*rUnoCursor.GetPoint(), 0, false); + SwPosition aOrigPos = *aCrsr.GetPoint(); + aCrsr.GoSentence(SwCursor::END_SENT); + bRet = aOrigPos == *aCrsr.GetPoint(); } - else - throw uno::RuntimeException(); return bRet; } + /*-- 09.12.98 14:18:47--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoNextSentence(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoNextSentence(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const bool bWasEOS = isEndOfSentence(); + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = rUnoCursor.GoSentence(SwCursor::NEXT_SENT); + if (!bRet) { - BOOL bWasEOS = isEndOfSentence(); - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->GoSentence(SwCursor::NEXT_SENT); - if(!bRet) - bRet = pUnoCrsr->MovePara(fnParaNext, fnParaStart); + bRet = rUnoCursor.MovePara(fnParaNext, fnParaStart); + } - // if at the end of the sentence (i.e. at the space after the '.') - // advance to next word in order for GoSentence to work properly - // next time and have isStartOfSentence return true after this call - if (!pUnoCrsr->IsStartWord()) - { - BOOL bNextWord = pUnoCrsr->GoNextWord(); - if (bWasEOS && !bNextWord) - bRet = sal_False; - } - if (CURSOR_META == eType) + // if at the end of the sentence (i.e. at the space after the '.') + // advance to next word in order for GoSentence to work properly + // next time and have isStartOfSentence return true after this call + if (!rUnoCursor.IsStartWord()) + { + const bool bNextWord = rUnoCursor.GoNextWord(); + if (bWasEOS && !bNextWord) { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; + bRet = sal_False; } } - else - throw uno::RuntimeException(); + if (CURSOR_META == m_pImpl->m_eType) + { + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; + } return bRet; } /*-- 09.12.98 14:18:47--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoPreviousSentence(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoPreviousSentence(sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = rUnoCursor.GoSentence(SwCursor::PREV_SENT); + if (!bRet) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->GoSentence(SwCursor::PREV_SENT); - if(!bRet) - { - if(0 != (bRet = pUnoCrsr->MovePara(fnParaPrev, fnParaStart))) - { - pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); - //at the end of a paragraph move to the sentence end again - // - pUnoCrsr->GoSentence(SwCursor::PREV_SENT); - } - } - if (CURSOR_META == eType) + bRet = rUnoCursor.MovePara(fnParaPrev, fnParaStart); + if (bRet) { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; + rUnoCursor.MovePara(fnParaCurr, fnParaEnd); + // at the end of a paragraph move to the sentence end again + rUnoCursor.GoSentence(SwCursor::PREV_SENT); } } - else - throw uno::RuntimeException(); + if (CURSOR_META == m_pImpl->m_eType) + { + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; + } return bRet; } + /* -----------------15.10.99 08:24------------------- --------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoStartOfSentence(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoStartOfSentence(sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - // if we're at the para start then we wont move - // but bRet is also true if GoSentence failed but - // the start of the sentence is reached - bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr) - || pUnoCrsr->GoSentence(SwCursor::START_SENT) || - SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr); - if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; - } + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + // if we're at the para start then we wont move + // but bRet is also true if GoSentence failed but + // the start of the sentence is reached + bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor) + || rUnoCursor.GoSentence(SwCursor::START_SENT) + || SwUnoCursorHelper::IsStartOfPara(rUnoCursor); + if (CURSOR_META == m_pImpl->m_eType) + { + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; } - else - throw uno::RuntimeException(); return bRet; } /* -----------------15.10.99 08:24------------------- --------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoEndOfSentence(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoEndOfSentence(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - // bRet is true if GoSentence() succeeded or if the - // MovePara() succeeded while the end of the para is - // not reached already - sal_Bool bAlreadyParaEnd = SwUnoCursorHelper::IsEndOfPara(*pUnoCrsr); - bRet = !bAlreadyParaEnd && - (pUnoCrsr->GoSentence(SwCursor::END_SENT) || - pUnoCrsr->MovePara(fnParaCurr, fnParaEnd)); - if (CURSOR_META == eType) - { - bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) - && bRet; - } + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + // bRet is true if GoSentence() succeeded or if the + // MovePara() succeeded while the end of the para is + // not reached already + sal_Bool bAlreadyParaEnd = SwUnoCursorHelper::IsEndOfPara(rUnoCursor); + bRet = !bAlreadyParaEnd + && (rUnoCursor.GoSentence(SwCursor::END_SENT) + || rUnoCursor.MovePara(fnParaCurr, fnParaEnd)); + if (CURSOR_META == m_pImpl->m_eType) + { + bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, + META_CHECK_BOTH) + && bRet; } - else - throw uno::RuntimeException(); return bRet; } /*-- 09.12.98 14:18:48--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isStartOfParagraph(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::isStartOfParagraph() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr); - else - throw uno::RuntimeException(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor); return bRet; } /*-- 09.12.98 14:18:48--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::isEndOfParagraph(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::isEndOfParagraph() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - bRet = SwUnoCursorHelper::IsEndOfPara(*pUnoCrsr); - else - throw uno::RuntimeException(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Bool bRet = SwUnoCursorHelper::IsEndOfPara(rUnoCursor); return bRet; } + /*-- 09.12.98 14:18:49--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - if (CURSOR_META == eType) - return bRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr ) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (CURSOR_META == m_pImpl->m_eType) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr); - if(!bRet) - bRet = pUnoCrsr->MovePara(fnParaCurr, fnParaStart); + return sal_False; + } + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor); + if (!bRet) + { + bRet = rUnoCursor.MovePara(fnParaCurr, fnParaStart); } - else - throw uno::RuntimeException(); // since MovePara(fnParaCurr, fnParaStart) only returns false // if we were already at the start of the paragraph this function @@ -1793,22 +1836,23 @@ sal_Bool SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) throw( uno::Runtim /*-- 09.12.98 14:18:49--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - if (CURSOR_META == eType) - return bRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (CURSOR_META == m_pImpl->m_eType) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - bRet = SwUnoCursorHelper::IsEndOfPara(*pUnoCrsr); - if(!bRet) - bRet = pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); + return sal_False; + } + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + sal_Bool bRet = SwUnoCursorHelper::IsEndOfPara(rUnoCursor); + if (!bRet) + { + bRet = rUnoCursor.MovePara(fnParaCurr, fnParaEnd); } - else - throw uno::RuntimeException(); // since MovePara(fnParaCurr, fnParaEnd) only returns false // if we were already at the end of the paragraph this function @@ -1816,404 +1860,459 @@ sal_Bool SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw( uno::RuntimeE DBG_ASSERT( bRet, "gotoEndOfParagraph failed" ); return bRet; } + /*-- 09.12.98 14:18:50--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoNextParagraph(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoNextParagraph(sal_Bool Expand) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - if (CURSOR_META == eType) - return bRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (CURSOR_META == m_pImpl->m_eType) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->MovePara(fnParaNext, fnParaStart); + return sal_False; } - else - throw uno::RuntimeException(); + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + const sal_Bool bRet = rUnoCursor.MovePara(fnParaNext, fnParaStart); return bRet; } /*-- 09.12.98 14:18:50--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::gotoPreviousParagraph(sal_Bool Expand) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXTextCursor::gotoPreviousParagraph(sal_Bool Expand) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Bool bRet = sal_False; - if (CURSOR_META == eType) - return bRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (CURSOR_META == m_pImpl->m_eType) { - SwXTextCursor::SelectPam(*pUnoCrsr, Expand); - bRet = pUnoCrsr->MovePara(fnParaPrev, fnParaStart); + return sal_False; } - else - throw uno::RuntimeException(); + SwUnoCursorHelper::SelectPam(rUnoCursor, Expand); + const sal_Bool bRet = rUnoCursor.MovePara(fnParaPrev, fnParaStart); return bRet; } + /*-- 09.12.98 14:18:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< XText > SwXTextCursor::getText(void) throw( uno::RuntimeException ) +uno::Reference< text::XText > SAL_CALL +SwXTextCursor::getText() throw (uno::RuntimeException) { - return xParentText; + vos::OGuard g(Application::GetSolarMutex()); + + return m_pImpl->m_xParentText; } + /*-- 09.12.98 14:18:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< XTextRange > SwXTextCursor::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextCursor::getStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextCursor*)this)->GetCrsr(); - if( pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + uno::Reference< text::XTextRange > xRet; + SwPaM aPam(*rUnoCursor.Start()); + const uno::Reference< text::XText > xParent = getText(); + if (CURSOR_META == m_pImpl->m_eType) { - SwPaM aPam(*pUnoCrsr->Start()); - uno::Reference< XText > xParent = getText(); - if (CURSOR_META == eType) - { - // return cursor to prevent modifying SwXTextRange for META - SwXTextCursor * const pCursor( - new SwXTextCursor(xParent, *pUnoCrsr->GetPoint(), - CURSOR_META, pUnoCrsr->GetDoc()) ); - pCursor->gotoStart(sal_False); - xRet = static_cast<text::XWordCursor*>(pCursor); - } - else - { - xRet = new SwXTextRange(aPam, xParent); - } + // return cursor to prevent modifying SwXTextRange for META + SwXTextCursor * const pXCursor( + new SwXTextCursor(*rUnoCursor.GetDoc(), xParent, CURSOR_META, + *rUnoCursor.GetPoint()) ); + pXCursor->gotoStart(sal_False); + xRet = static_cast<text::XWordCursor*>(pXCursor); } else - throw uno::RuntimeException(); + { + xRet = new SwXTextRange(aPam, xParent); + } return xRet; } /*-- 09.12.98 14:18:51--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< XTextRange > SwXTextCursor::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextCursor::getEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextCursor*)this)->GetCrsr(); - if( pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + uno::Reference< text::XTextRange > xRet; + SwPaM aPam(*rUnoCursor.End()); + const uno::Reference< text::XText > xParent = getText(); + if (CURSOR_META == m_pImpl->m_eType) { - SwPaM aPam(*pUnoCrsr->End()); - uno::Reference< XText > xParent = getText(); - if (CURSOR_META == eType) - { - // return cursor to prevent modifying SwXTextRange for META - SwXTextCursor * const pCursor( - new SwXTextCursor(xParent, *pUnoCrsr->GetPoint(), - CURSOR_META, pUnoCrsr->GetDoc()) ); - pCursor->gotoEnd(sal_False); - xRet = static_cast<text::XWordCursor*>(pCursor); - } - else - { - xRet = new SwXTextRange(aPam, xParent); - } + // return cursor to prevent modifying SwXTextRange for META + SwXTextCursor * const pXCursor( + new SwXTextCursor(*rUnoCursor.GetDoc(), xParent, CURSOR_META, + *rUnoCursor.GetPoint()) ); + pXCursor->gotoEnd(sal_False); + xRet = static_cast<text::XWordCursor*>(pXCursor); } else - throw uno::RuntimeException(); + { + xRet = new SwXTextRange(aPam, xParent); + } return xRet; } + /*-- 09.12.98 14:18:51--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXTextCursor::getString(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXTextCursor::getString() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + OUString aTxt; - SwUnoCrsr* pUnoCrsr = ((SwXTextCursor*)this)->GetCrsr(); - if( pUnoCrsr) - { -/* if( pUnoCrsr->GetPoint()->nNode.GetIndex() == - pUnoCrsr->GetMark()->nNode.GetIndex() ) - { - SwTxtNode* pTxtNd = pUnoCrsr->GetNode()->GetTxtNode(); - if( pTxtNd ) - { - sal_uInt16 nStt = pUnoCrsr->Start()->nContent.GetIndex(); - aTxt = pTxtNd->GetExpandTxt( nStt, - pUnoCrsr->End()->nContent.GetIndex() - nStt ); - } - } - else -*/ { - //Text ueber mehrere Absaetze - SwXTextCursor::getTextFromPam(*pUnoCrsr, aTxt); - } - } - else - throw uno::RuntimeException(); + SwUnoCursorHelper::GetTextFromPam(rUnoCursor, aTxt); return aTxt; } /*-- 09.12.98 14:18:52--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::setString(const OUString& aString) throw( uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::setString(const OUString& aString) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(!pUnoCrsr) - throw uno::RuntimeException(); - const bool bForceExpandHints( (CURSOR_META != eType) + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + (void) rUnoCursor; // just to check if valid + + const bool bForceExpandHints( (CURSOR_META != m_pImpl->m_eType) ? false - : dynamic_cast<SwXMeta*>(xParentText.get())->CheckForOwnMemberMeta( - 0, GetPaM(), true) ); + : dynamic_cast<SwXMeta*>(m_pImpl->m_xParentText.get()) + ->CheckForOwnMemberMeta(*GetPaM(), true) ); DeleteAndInsert(aString, bForceExpandHints); } + /* -----------------------------03.05.00 12:56-------------------------------- ---------------------------------------------------------------------------*/ -Any SwXTextCursor::GetPropertyValue( +uno::Any SwUnoCursorHelper::GetPropertyValue( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - Any aAny; - const SfxItemPropertySimpleEntry* pEntry = rPropSet.getPropertyMap()->getByName( - rPropertyName); - if(pEntry) + uno::Any aAny; + SfxItemPropertySimpleEntry const*const pEntry = + rPropSet.getPropertyMap()->getByName(rPropertyName); + + if (!pEntry) { - PropertyState eTemp; - BOOL bDone = SwUnoCursorHelper::getCrsrPropertyValue( *pEntry, rPaM, &aAny, eTemp ); - if(!bDone) - { - SfxItemSet aSet(rPaM.GetDoc()->GetAttrPool(), - RES_CHRATR_BEGIN, RES_FRMATR_END -1, - RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, - RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, - 0L); - SwXTextCursor::GetCrsrAttr(rPaM, aSet); - - rPropSet.getPropertyValue(*pEntry, aSet, aAny); - } + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, static_cast<cppu::OWeakObject *>(0)); + } + + beans::PropertyState eTemp; + const sal_Bool bDone = SwUnoCursorHelper::getCrsrPropertyValue( + *pEntry, rPaM, &aAny, eTemp ); + + if (!bDone) + { + SfxItemSet aSet(rPaM.GetDoc()->GetAttrPool(), + RES_CHRATR_BEGIN, RES_FRMATR_END - 1, + RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, + RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, + 0L); + SwUnoCursorHelper::GetCrsrAttr(rPaM, aSet); + + rPropSet.getPropertyValue(*pEntry, aSet, aAny); } - else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); return aAny; } /* -----------------------------03.05.00 12:57-------------------------------- ---------------------------------------------------------------------------*/ -void SwXTextCursor::SetPropertyValue( - SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName, - const Any& aValue, USHORT nAttrMode) - throw (UnknownPropertyException, PropertyVetoException, - IllegalArgumentException, WrappedTargetException, RuntimeException) +void SwUnoCursorHelper::SetPropertyValue( + SwPaM& rPaM, const SfxItemPropertySet& rPropSet, + const OUString& rPropertyName, + const uno::Any& rValue, + const SetAttrMode nAttrMode, const bool bTableMode) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { - SwDoc* pDoc = rPaM.GetDoc(); - const SfxItemPropertySimpleEntry* pEntry = rPropSet.getPropertyMap()->getByName(rPropertyName); - if(pEntry) + SwDoc *const pDoc = rPaM.GetDoc(); + SfxItemPropertySimpleEntry const*const pEntry = + rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) { - if( pEntry->nFlags & PropertyAttribute::READONLY) - throw PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast<cppu::OWeakObject *>(0)); + } - SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID ); - SwXTextCursor::GetCrsrAttr( rPaM, aItemSet ); + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw beans::PropertyVetoException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + rPropertyName, + static_cast<cppu::OWeakObject *>(0)); + } - if(!lcl_setCrsrPropertyValue( pEntry, rPaM, aItemSet, aValue )) - rPropSet.setPropertyValue(*pEntry, aValue, aItemSet ); - SwXTextCursor::SetCrsrAttr(rPaM, aItemSet, nAttrMode ); + SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID ); + SwUnoCursorHelper::GetCrsrAttr( rPaM, aItemSet ); + + if (!SwUnoCursorHelper::SetCursorPropertyValue( + *pEntry, rValue, rPaM, aItemSet)) + { + rPropSet.setPropertyValue(*pEntry, rValue, aItemSet ); } - else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); + SwUnoCursorHelper::SetCrsrAttr(rPaM, aItemSet, nAttrMode, bTableMode); } + /* -----------------------------03.05.00 13:16-------------------------------- ---------------------------------------------------------------------------*/ -Sequence< PropertyState > SwXTextCursor::GetPropertyStates( +uno::Sequence< beans::PropertyState > +SwUnoCursorHelper::GetPropertyStates( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, - const Sequence< OUString >& PropertyNames, - SwGetPropertyStatesCaller eCaller ) - throw(UnknownPropertyException, RuntimeException) + const uno::Sequence< OUString >& rPropertyNames, + const SwGetPropertyStatesCaller eCaller) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - const OUString* pNames = PropertyNames.getConstArray(); - Sequence< PropertyState > aRet ( PropertyNames.getLength() ); - PropertyState* pStates = aRet.getArray(); + const OUString* pNames = rPropertyNames.getConstArray(); + uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength()); + beans::PropertyState* pStates = aRet.getArray(); + SfxItemPropertyMap const*const pMap = rPropSet.getPropertyMap(); + ::std::auto_ptr<SfxItemSet> pSet; + ::std::auto_ptr<SfxItemSet> pSetParent; - SfxItemSet *pSet = 0, *pSetParent = 0; - const SfxItemPropertyMap *pMap = rPropSet.getPropertyMap(); - for( INT32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd; i++ ) + for (sal_Int32 i = 0, nEnd = rPropertyNames.getLength(); i < nEnd; i++) { - const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[i] ); + SfxItemPropertySimpleEntry const*const pEntry = + pMap->getByName( pNames[i] ); if(!pEntry) { - if(pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || - pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) + if (pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || + pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) { pStates[i] = beans::PropertyState_DEFAULT_VALUE; continue; } - else if( SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT == eCaller ) + else if (SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT == + eCaller) { //this values marks the element as unknown property pStates[i] = beans::PropertyState_MAKE_FIXED_SIZE; continue; } else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( 0 ) ); + { + throw beans::UnknownPropertyException( + OUString( RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pNames[i], + static_cast<cppu::OWeakObject *>(0)); + } } - if ((eCaller == SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION || eCaller == SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT) && + if (((SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION == eCaller) || + (SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT == eCaller)) && pEntry->nWID < FN_UNO_RANGE_BEGIN && pEntry->nWID > FN_UNO_RANGE_END && pEntry->nWID < RES_CHRATR_BEGIN && pEntry->nWID > RES_TXTATR_END ) + { pStates[i] = beans::PropertyState_DEFAULT_VALUE; + } else { if ( pEntry->nWID >= FN_UNO_RANGE_BEGIN && pEntry->nWID <= FN_UNO_RANGE_END ) - SwUnoCursorHelper::getCrsrPropertyValue(*pEntry, rPaM, 0, pStates[i] ); + { + SwUnoCursorHelper::getCrsrPropertyValue( + *pEntry, rPaM, 0, pStates[i] ); + } else { - if( !pSet ) + if (!pSet.get()) { switch ( eCaller ) { case SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT: case SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION: - pSet = new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), - RES_CHRATR_BEGIN, RES_TXTATR_END ); + pSet.reset( + new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), + RES_CHRATR_BEGIN, RES_TXTATR_END )); break; case SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY: - pSet = new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), - pEntry->nWID, pEntry->nWID ); + pSet.reset( + new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), + pEntry->nWID, pEntry->nWID )); break; default: - pSet = new SfxItemSet( rPaM.GetDoc()->GetAttrPool(), + pSet.reset( new SfxItemSet( + rPaM.GetDoc()->GetAttrPool(), RES_CHRATR_BEGIN, RES_FRMATR_END - 1, RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, - 0L ); + 0L )); } // --> OD 2006-07-12 #i63870# - SwXTextCursor::GetCrsrAttr( rPaM, *pSet ); + SwUnoCursorHelper::GetCrsrAttr( rPaM, *pSet ); // <-- } - if( pSet->Count() ) - pStates[i] = rPropSet.getPropertyState( *pEntry, *pSet ); - else - pStates[i] = PropertyState_DEFAULT_VALUE; + pStates[i] = ( pSet->Count() ) + ? rPropSet.getPropertyState( *pEntry, *pSet ) + : beans::PropertyState_DEFAULT_VALUE; //try again to find out if a value has been inherited if( beans::PropertyState_DIRECT_VALUE == pStates[i] ) { - if( !pSetParent ) + if (!pSetParent.get()) { - pSetParent = pSet->Clone( FALSE ); + pSetParent.reset( pSet->Clone( FALSE ) ); // --> OD 2006-07-12 #i63870# - SwXTextCursor::GetCrsrAttr( rPaM, *pSetParent, TRUE, FALSE ); + SwUnoCursorHelper::GetCrsrAttr( + rPaM, *pSetParent, TRUE, FALSE ); // <-- } - if( (pSetParent)->Count() ) - pStates[i] = rPropSet.getPropertyState( *pEntry, *pSetParent ); - else - pStates[i] = PropertyState_DEFAULT_VALUE; + pStates[i] = ( (pSetParent)->Count() ) + ? rPropSet.getPropertyState( *pEntry, *pSetParent ) + : beans::PropertyState_DEFAULT_VALUE; } } } } - delete pSet; - delete pSetParent; return aRet; } /* -----------------------------03.05.00 13:17-------------------------------- ---------------------------------------------------------------------------*/ -PropertyState SwXTextCursor::GetPropertyState( - SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName) - throw(UnknownPropertyException, RuntimeException) +beans::PropertyState SwUnoCursorHelper::GetPropertyState( + SwPaM& rPaM, const SfxItemPropertySet& rPropSet, + const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - Sequence < OUString > aStrings ( 1 ); + uno::Sequence< OUString > aStrings ( 1 ); aStrings[0] = rPropertyName; - Sequence < PropertyState > aSeq = GetPropertyStates( rPaM, rPropSet, aStrings, SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY ); + uno::Sequence< beans::PropertyState > aSeq = + GetPropertyStates(rPaM, rPropSet, aStrings, + SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY ); return aSeq[0]; } /* -----------------------------03.05.00 13:20-------------------------------- ---------------------------------------------------------------------------*/ -void lcl_SelectParaAndReset ( SwPaM &rPaM, SwDoc* pDoc, const SvUShortsSort* pWhichIds = 0 ) +static void +lcl_SelectParaAndReset( SwPaM &rPaM, SwDoc & rDoc, + SvUShortsSort const*const pWhichIds = 0 ) { // if we are reseting paragraph attributes, we need to select the full paragraph first SwPosition aStart = *rPaM.Start(); SwPosition aEnd = *rPaM.End(); - auto_ptr < SwUnoCrsr > pTemp ( pDoc->CreateUnoCrsr(aStart, FALSE) ); + ::std::auto_ptr< SwUnoCrsr > pTemp ( rDoc.CreateUnoCrsr(aStart, FALSE) ); if(!SwUnoCursorHelper::IsStartOfPara(*pTemp)) + { pTemp->MovePara(fnParaCurr, fnParaStart); + } pTemp->SetMark(); *pTemp->GetPoint() = aEnd; - SwXTextCursor::SelectPam(*pTemp, sal_True); + SwUnoCursorHelper::SelectPam(*pTemp, true); if(!SwUnoCursorHelper::IsEndOfPara(*pTemp)) + { pTemp->MovePara(fnParaCurr, fnParaEnd); - pDoc->ResetAttrs(*pTemp, sal_True, pWhichIds); + } + rDoc.ResetAttrs(*pTemp, sal_True, pWhichIds); } -void SwXTextCursor::SetPropertyToDefault( +void SwUnoCursorHelper::SetPropertyToDefault( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName) - throw(UnknownPropertyException, RuntimeException) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); - SwDoc* pDoc = rPaM.GetDoc(); - const SfxItemPropertySimpleEntry* pEntry = rPropSet.getPropertyMap()->getByName( rPropertyName); - if(pEntry) + SwDoc & rDoc = *rPaM.GetDoc(); + SfxItemPropertySimpleEntry const*const pEntry = + rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, static_cast<cppu::OWeakObject *>(0)); + } + + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) { - if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertyToDefault: property is read-only: " ) ) + rPropertyName, 0 ); - if(pEntry->nWID < RES_FRMATR_END) + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "setPropertyToDefault: property is read-only: ")) + + rPropertyName, 0); + } + + if (pEntry->nWID < RES_FRMATR_END) + { + SvUShortsSort aWhichIds; + aWhichIds.Insert(pEntry->nWID); + if (pEntry->nWID < RES_PARATR_BEGIN) { - SvUShortsSort aWhichIds; - aWhichIds.Insert(pEntry->nWID); - if(pEntry->nWID < RES_PARATR_BEGIN) - pDoc->ResetAttrs(rPaM, sal_True, &aWhichIds); - else - lcl_SelectParaAndReset ( rPaM, pDoc, &aWhichIds ); + rDoc.ResetAttrs(rPaM, sal_True, &aWhichIds); } else - SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, rPaM); + { + lcl_SelectParaAndReset ( rPaM, rDoc, &aWhichIds ); + } } else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); + { + SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, rPaM); + } } + /* -----------------------------03.05.00 13:19-------------------------------- ---------------------------------------------------------------------------*/ -Any SwXTextCursor::GetPropertyDefault( +uno::Any SwUnoCursorHelper::GetPropertyDefault( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - Any aRet; - SwDoc* pDoc = rPaM.GetDoc(); - const SfxItemPropertySimpleEntry* pEntry = rPropSet.getPropertyMap()->getByName( rPropertyName); - if(pEntry) + SfxItemPropertySimpleEntry const*const pEntry = + rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) { - if(pEntry->nWID < RES_FRMATR_END) - { - const SfxPoolItem& rDefItem = pDoc->GetAttrPool().GetDefaultItem(pEntry->nWID); - rDefItem.QueryValue(aRet, pEntry->nMemberId); - } + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, static_cast<cppu::OWeakObject *>(0)); + } + + uno::Any aRet; + if (pEntry->nWID < RES_FRMATR_END) + { + SwDoc & rDoc = *rPaM.GetDoc(); + const SfxPoolItem& rDefItem = + rDoc.GetAttrPool().GetDefaultItem(pEntry->nWID); + rDefItem.QueryValue(aRet, pEntry->nMemberId); } - else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) ); return aRet; } + /*-- 09.12.98 14:18:54--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXTextCursor::getPropertySetInfo(void) throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXTextCursor::getPropertySetInfo() throw (uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + static uno::Reference< beans::XPropertySetInfo > xRef; if(!xRef.is()) { @@ -2223,7 +2322,8 @@ uno::Reference< beans::XPropertySetInfo > SwXTextCursor::getPropertySetInfo(voi { SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT), FN_SKIP_PROTECTED_TEXT, &::getBooleanCppuType(), PROPERTY_NONE, 0}, {0,0,0,0,0,0} }; - uno::Reference< beans::XPropertySetInfo > xInfo = m_pPropSet->getPropertySetInfo(); + const uno::Reference< beans::XPropertySetInfo > xInfo = + m_pImpl->m_rPropSet.getPropertySetInfo(); // PropertySetInfo verlaengern! const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties(); xRef = new SfxExtItemPropertySetInfo( @@ -2232,291 +2332,881 @@ uno::Reference< beans::XPropertySetInfo > SwXTextCursor::getPropertySetInfo(voi } return xRef; } + /*-- 09.12.98 14:18:54--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextCursor::setPropertyValue( + const OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT))) { - if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT))) + sal_Bool bSet(sal_False); + if (!(rValue >>= bSet)) { - sal_Bool bSet = *(sal_Bool*)aValue.getValue(); - pUnoCrsr->SetSkipOverHiddenSections(bSet); + throw lang::IllegalArgumentException(); } - else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) + rUnoCursor.SetSkipOverHiddenSections(bSet); + } + else if (rPropertyName.equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) + { + sal_Bool bSet(sal_False); + if (!(rValue >>= bSet)) { - sal_Bool bSet = *(sal_Bool*)aValue.getValue(); - pUnoCrsr->SetSkipOverProtectSections(bSet); + throw lang::IllegalArgumentException(); } - else - SetPropertyValue(*pUnoCrsr, *m_pPropSet, rPropertyName, aValue); + rUnoCursor.SetSkipOverProtectSections(bSet); } else - throw uno::RuntimeException(); - + { + SwUnoCursorHelper::SetPropertyValue(rUnoCursor, + m_pImpl->m_rPropSet, rPropertyName, rValue); + } } + /*-- 09.12.98 14:18:55--------------------------------------------------- -----------------------------------------------------------------------*/ -Any SwXTextCursor::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXTextCursor::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + uno::Any aAny; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT))) { - if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT))) - { - BOOL bSet = pUnoCrsr->IsSkipOverHiddenSections(); - aAny.setValue(&bSet, ::getBooleanCppuType()); - } - else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) - { - BOOL bSet = pUnoCrsr->IsSkipOverProtectSections(); - aAny.setValue(&bSet, ::getBooleanCppuType()); - } - else - aAny = GetPropertyValue(*pUnoCrsr, *m_pPropSet, rPropertyName); + const sal_Bool bSet = rUnoCursor.IsSkipOverHiddenSections(); + aAny <<= bSet; + } + else if (rPropertyName.equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) + { + const sal_Bool bSet = rUnoCursor.IsSkipOverProtectSections(); + aAny <<= bSet; } else - throw uno::RuntimeException(); + { + aAny = SwUnoCursorHelper::GetPropertyValue(rUnoCursor, + m_pImpl->m_rPropSet, rPropertyName); + } return aAny; - } + /*-- 09.12.98 14:18:55--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::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, + "SwXTextCursor::addPropertyChangeListener(): not implemented"); } + /*-- 09.12.98 14:18:57--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::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, + "SwXTextCursor::removePropertyChangeListener(): not implemented"); } + /*-- 09.12.98 14:18:57--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::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, + "SwXTextCursor::addVetoableChangeListener(): not implemented"); } + /*-- 09.12.98 14:18:58--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextCursor::removeVetoableChangeListener(): not implemented"); } + /*-- 05.03.99 11:36:11--------------------------------------------------- -----------------------------------------------------------------------*/ -beans::PropertyState SwXTextCursor::getPropertyState(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +beans::PropertyState SAL_CALL +SwXTextCursor::getPropertyState(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - eRet = GetPropertyState(*pUnoCrsr, *m_pPropSet, rPropertyName); - } - else - throw RuntimeException(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const beans::PropertyState eRet = SwUnoCursorHelper::GetPropertyState( + rUnoCursor, m_pImpl->m_rPropSet, rPropertyName); return eRet; } /*-- 05.03.99 11:36:11--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Sequence< beans::PropertyState > SwXTextCursor::getPropertyStates( - const uno::Sequence< OUString >& PropertyNames) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +uno::Sequence< beans::PropertyState > SAL_CALL +SwXTextCursor::getPropertyStates( + const uno::Sequence< OUString >& rPropertyNames) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(!pUnoCrsr) - throw RuntimeException(); - return GetPropertyStates(*pUnoCrsr, *m_pPropSet, PropertyNames); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + return SwUnoCursorHelper::GetPropertyStates( + rUnoCursor, m_pImpl->m_rPropSet, rPropertyNames); } + /*-- 05.03.99 11:36:12--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::setPropertyToDefault(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +void SAL_CALL +SwXTextCursor::setPropertyToDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - Sequence < OUString > aSequence ( &rPropertyName, 1 ); + // forward: need no solar mutex here + uno::Sequence < OUString > aSequence ( &rPropertyName, 1 ); setPropertiesToDefault ( aSequence ); } /*-- 05.03.99 11:36:12--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXTextCursor::getPropertyDefault(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXTextCursor::getPropertyDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - const Sequence < OUString > aSequence ( &rPropertyName, 1 ); + // forward: need no solar mutex here + const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 ); return getPropertyDefaults ( aSequence ).getConstArray()[0]; } -void SAL_CALL SwXTextCursor::setAllPropertiesToDefault() - throw (RuntimeException) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); +// para specific attribut ranges +static USHORT g_ParaResetableSetRange[] = { + RES_FRMATR_BEGIN, RES_FRMATR_END-1, + RES_PARATR_BEGIN, RES_PARATR_END-1, + // --> OD 2008-02-25 #refactorlists# + RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1, + // <-- + RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, + 0 +}; + +// selection specific attribut ranges +static USHORT g_ResetableSetRange[] = { + RES_CHRATR_BEGIN, RES_CHRATR_END-1, + RES_TXTATR_INETFMT, RES_TXTATR_INETFMT, + RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT, + RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY, + RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, + 0 +}; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if (pUnoCrsr) +static void +lcl_EnumerateIds(USHORT const* pIdRange, SvUShortsSort & rWhichIds) +{ + while (*pIdRange) { - // para specific attribut ranges - USHORT aParaResetableSetRange[] = { - RES_FRMATR_BEGIN, RES_FRMATR_END-1, - RES_PARATR_BEGIN, RES_PARATR_END-1, - // --> OD 2008-02-25 #refactorlists# - RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1, - // <-- - RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, - 0 - }; - // selection specific attribut ranges - USHORT aResetableSetRange[] = { - RES_CHRATR_BEGIN, RES_CHRATR_END-1, - RES_TXTATR_INETFMT, RES_TXTATR_INETFMT, - RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT, - RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY, - RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, - 0 - }; - SvUShortsSort aParaWhichIds; - SvUShortsSort aWhichIds; - for (USHORT k = 0; k < 2; ++k) + const USHORT nStart = sal::static_int_cast<USHORT>(*pIdRange++); + const USHORT nEnd = sal::static_int_cast<USHORT>(*pIdRange++); + for (USHORT nId = nStart + 1; nId <= nEnd; ++nId) { - SvUShortsSort &rWhichIds = k == 0? aParaWhichIds : aWhichIds; - USHORT *pResetableSetRange = k == 0? aParaResetableSetRange : aResetableSetRange; - while (*pResetableSetRange) - { - USHORT nStart = sal::static_int_cast< USHORT >(*pResetableSetRange++); - USHORT nEnd = sal::static_int_cast< USHORT >(*pResetableSetRange++); - for (USHORT nId = nStart + 1; nId <= nEnd; ++nId) - rWhichIds.Insert( nId ); - } + rWhichIds.Insert( nId ); } - if (aParaWhichIds.Count()) - lcl_SelectParaAndReset( *pUnoCrsr, pUnoCrsr->GetDoc(), &aParaWhichIds ); - if (aWhichIds.Count() ) - pUnoCrsr->GetDoc()->ResetAttrs( *pUnoCrsr, sal_True, &aWhichIds ); } - else - throw uno::RuntimeException(); } -void SAL_CALL SwXTextCursor::setPropertiesToDefault( const Sequence< OUString >& aPropertyNames ) - throw (UnknownPropertyException, RuntimeException) +void SAL_CALL +SwXTextCursor::setAllPropertiesToDefault() +throw (uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SvUShortsSort aParaWhichIds; + SvUShortsSort aWhichIds; + lcl_EnumerateIds(g_ParaResetableSetRange, aParaWhichIds); + lcl_EnumerateIds(g_ResetableSetRange, aWhichIds); + if (aParaWhichIds.Count()) + { + lcl_SelectParaAndReset(rUnoCursor, *rUnoCursor.GetDoc(), + &aParaWhichIds); + } + if (aWhichIds.Count()) + { + rUnoCursor.GetDoc()->ResetAttrs(rUnoCursor, sal_True, &aWhichIds); + } +} + +void SAL_CALL +SwXTextCursor::setPropertiesToDefault( + const uno::Sequence< OUString >& rPropertyNames) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Int32 nCount = aPropertyNames.getLength(); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Int32 nCount = rPropertyNames.getLength(); if ( nCount ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + SwDoc & rDoc = *rUnoCursor.GetDoc(); + const OUString * pNames = rPropertyNames.getConstArray(); + SvUShortsSort aWhichIds; + SvUShortsSort aParaWhichIds; + for (sal_Int32 i = 0; i < nCount; i++) { - SwDoc* pDoc = pUnoCrsr->GetDoc(); - const OUString * pNames = aPropertyNames.getConstArray(); - SvUShortsSort aWhichIds, aParaWhichIds; - for ( sal_Int32 i = 0; i < nCount; i++ ) + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName( pNames[i] ); + if (!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( pNames[i] ); - if(!pEntry) + if (pNames[i].equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || + pNames[i].equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) { - if(pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || - pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) - { - continue; - } - else - throw UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( 0 ) ); + continue; } - if( pEntry->nFlags & PropertyAttribute::READONLY) - throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertiesToDefault: property is read-only: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) ); + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pNames[i], + static_cast<cppu::OWeakObject *>(this)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw uno::RuntimeException( + OUString(RTL_CONSTASCII_USTRINGPARAM( + "setPropertiesToDefault: property is read-only: ")) + + pNames[i], + static_cast<cppu::OWeakObject *>(this)); + } - if( pEntry->nWID < RES_FRMATR_END) + if (pEntry->nWID < RES_FRMATR_END) + { + if (pEntry->nWID < RES_PARATR_BEGIN) + { + aWhichIds.Insert(pEntry->nWID); + } + else { - if(pEntry->nWID < RES_PARATR_BEGIN) - aWhichIds.Insert(pEntry->nWID); - else - aParaWhichIds.Insert (pEntry->nWID); + aParaWhichIds.Insert(pEntry->nWID); } - else if ( pEntry->nWID == FN_UNO_NUM_START_VALUE ) - SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, *pUnoCrsr); } + else if (pEntry->nWID == FN_UNO_NUM_START_VALUE) + { + SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, rUnoCursor); + } + } - if ( aParaWhichIds.Count() ) - lcl_SelectParaAndReset ( *pUnoCrsr, pDoc, &aParaWhichIds ); - if (aWhichIds.Count() ) - pDoc->ResetAttrs(*pUnoCrsr, sal_True, &aWhichIds); + if (aParaWhichIds.Count()) + { + lcl_SelectParaAndReset(rUnoCursor, rDoc, &aParaWhichIds); + } + if (aWhichIds.Count()) + { + rDoc.ResetAttrs(rUnoCursor, sal_True, &aWhichIds); } - else - throw uno::RuntimeException(); } } -Sequence< Any > SAL_CALL SwXTextCursor::getPropertyDefaults( const Sequence< OUString >& aPropertyNames ) - throw (UnknownPropertyException, WrappedTargetException, RuntimeException) + +uno::Sequence< uno::Any > SAL_CALL +SwXTextCursor::getPropertyDefaults( + const uno::Sequence< OUString >& rPropertyNames) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Int32 nCount = aPropertyNames.getLength(); - Sequence < Any > aRet ( nCount ); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const sal_Int32 nCount = rPropertyNames.getLength(); + uno::Sequence< uno::Any > aRet(nCount); if ( nCount ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if (pUnoCrsr) + SwDoc & rDoc = *rUnoCursor.GetDoc(); + const OUString *pNames = rPropertyNames.getConstArray(); + uno::Any *pAny = aRet.getArray(); + for (sal_Int32 i = 0; i < nCount; i++) + { + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName( pNames[i] ); + if (!pEntry) + { + if (pNames[i].equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || + pNames[i].equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) + { + continue; + } + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pNames[i], + static_cast<cppu::OWeakObject *>(0)); + } + if (pEntry->nWID < RES_FRMATR_END) + { + const SfxPoolItem& rDefItem = + rDoc.GetAttrPool().GetDefaultItem(pEntry->nWID); + rDefItem.QueryValue(pAny[i], pEntry->nMemberId); + } + } + } + return aRet; +} + +/*-- 10.03.2008 09:58:47--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SAL_CALL +SwXTextCursor::makeRedline( + const ::rtl::OUString& rRedlineType, + const uno::Sequence< beans::PropertyValue >& rRedlineProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::makeRedline(rUnoCursor, rRedlineType, rRedlineProperties); +} + +/*-- 09.12.98 14:18:58--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SAL_CALL SwXTextCursor::insertDocumentFromURL(const OUString& rURL, + const uno::Sequence< beans::PropertyValue >& rOptions) +throw (lang::IllegalArgumentException, io::IOException, + uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + SwUnoCursorHelper::InsertFile(&rUnoCursor, rURL, rOptions); +} + +/* -----------------------------15.12.00 14:01-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< beans::PropertyValue > +SwUnoCursorHelper::CreateSortDescriptor(const bool bFromTable) +{ + uno::Sequence< beans::PropertyValue > aRet(5); + beans::PropertyValue* pArray = aRet.getArray(); + + uno::Any aVal; + aVal.setValue( &bFromTable, ::getCppuBooleanType()); + pArray[0] = beans::PropertyValue(C2U("IsSortInTable"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + aVal <<= sal_Unicode(' '); + pArray[1] = beans::PropertyValue(C2U("Delimiter"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + aVal <<= (sal_Bool) sal_False; + pArray[2] = beans::PropertyValue(C2U("IsSortColumns"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + aVal <<= (sal_Int32) 3; + pArray[3] = beans::PropertyValue(C2U("MaxSortFieldsCount"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + uno::Sequence< table::TableSortField > aFields(3); + table::TableSortField* pFields = aFields.getArray(); + + lang::Locale aLang( SvxCreateLocale( LANGUAGE_SYSTEM ) ); + // get collator algorithm to be used for the locale + uno::Sequence< OUString > aSeq( + GetAppCollator().listCollatorAlgorithms( aLang ) ); + const sal_Int32 nLen = aSeq.getLength(); + DBG_ASSERT( nLen > 0, "list of collator algorithms is empty!"); + OUString aCollAlg; + if (nLen > 0) + { + aCollAlg = aSeq.getConstArray()[0]; + } + +#if OSL_DEBUG_LEVEL > 1 + const OUString *pTxt = aSeq.getConstArray(); + (void)pTxt; +#endif + + pFields[0].Field = 1; + pFields[0].IsAscending = sal_True; + pFields[0].IsCaseSensitive = sal_False; + pFields[0].FieldType = table::TableSortFieldType_ALPHANUMERIC; + pFields[0].CollatorLocale = aLang; + pFields[0].CollatorAlgorithm = aCollAlg; + + pFields[1].Field = 1; + pFields[1].IsAscending = sal_True; + pFields[1].IsCaseSensitive = sal_False; + pFields[1].FieldType = table::TableSortFieldType_ALPHANUMERIC; + pFields[1].CollatorLocale = aLang; + pFields[1].CollatorAlgorithm = aCollAlg; + + pFields[2].Field = 1; + pFields[2].IsAscending = sal_True; + pFields[2].IsCaseSensitive = sal_False; + pFields[2].FieldType = table::TableSortFieldType_ALPHANUMERIC; + pFields[2].CollatorLocale = aLang; + pFields[2].CollatorAlgorithm = aCollAlg; + + aVal <<= aFields; + pArray[4] = beans::PropertyValue(C2U("SortFields"), -1, aVal, + beans::PropertyState_DIRECT_VALUE); + + return aRet; +} + +/*-- 09.12.98 14:18:58--------------------------------------------------- + + -----------------------------------------------------------------------*/ +uno::Sequence< beans::PropertyValue > SAL_CALL +SwXTextCursor::createSortDescriptor() throw (uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + return SwUnoCursorHelper::CreateSortDescriptor(false); +} + +/* -----------------------------15.12.00 14:06-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_Bool SwUnoCursorHelper::ConvertSortProperties( + const uno::Sequence< beans::PropertyValue >& rDescriptor, + SwSortOptions& rSortOpt) +{ + sal_Bool bRet = sal_True; + const beans::PropertyValue* pProperties = rDescriptor.getConstArray(); + + rSortOpt.bTable = sal_False; + rSortOpt.cDeli = ' '; + rSortOpt.eDirection = SRT_COLUMNS; //!! UI text may be contrary though !! + + SwSortKey* pKey1 = new SwSortKey; + pKey1->nColumnId = USHRT_MAX; + pKey1->bIsNumeric = TRUE; + pKey1->eSortOrder = SRT_ASCENDING; + + SwSortKey* pKey2 = new SwSortKey; + pKey2->nColumnId = USHRT_MAX; + pKey2->bIsNumeric = TRUE; + pKey2->eSortOrder = SRT_ASCENDING; + + SwSortKey* pKey3 = new SwSortKey; + pKey3->nColumnId = USHRT_MAX; + pKey3->bIsNumeric = TRUE; + pKey3->eSortOrder = SRT_ASCENDING; + SwSortKey* aKeys[3] = {pKey1, pKey2, pKey3}; + + sal_Bool bOldSortdescriptor(sal_False); + sal_Bool bNewSortdescriptor(sal_False); + + for (sal_Int32 n = 0; n < rDescriptor.getLength(); ++n) + { + uno::Any aValue( pProperties[n].Value ); +// String sPropName = pProperties[n].Name; + const OUString& rPropName = pProperties[n].Name; + + // old and new sortdescriptor + if (rPropName.equalsAscii("IsSortInTable")) + { + if (aValue.getValueType() == ::getBooleanCppuType()) + { + rSortOpt.bTable = *(sal_Bool*)aValue.getValue(); + } + else + { + bRet = sal_False; + } + } + else if (rPropName.equalsAscii("Delimiter")) + { + sal_Unicode uChar = sal_Unicode(); + if (aValue >>= uChar) + { + rSortOpt.cDeli = uChar; + } + else + { + bRet = sal_False; + } + } + // old sortdescriptor + else if (rPropName.equalsAscii("SortColumns")) + { + bOldSortdescriptor = sal_True; + sal_Bool bTemp(sal_False); + if (aValue >>= bTemp) + { + rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; + } + else + { + bRet = sal_False; + } + } + else if ( rPropName.equalsAscii("IsCaseSensitive")) + { + bOldSortdescriptor = sal_True; + sal_Bool bTemp(sal_False); + if (aValue >>= bTemp) + { + rSortOpt.bIgnoreCase = !bTemp; + } + else + { + bRet = sal_False; + } + } + else if (rPropName.equalsAscii("CollatorLocale")) + { + bOldSortdescriptor = sal_True; + lang::Locale aLocale; + if (aValue >>= aLocale) + { + rSortOpt.nLanguage = SvxLocaleToLanguage( aLocale ); + } + else + { + bRet = sal_False; + } + } + else if (rPropName.matchAsciiL("CollatorAlgorithm", 17) && + rPropName.getLength() == 18 && + (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) + { + bOldSortdescriptor = sal_True; + sal_uInt16 nIndex = rPropName.getStr()[17]; + nIndex -= '0'; + OUString aTxt; + if ((aValue >>= aTxt) && nIndex < 3) + { + aKeys[nIndex]->sSortType = aTxt; + } + else + { + bRet = sal_False; + } + } + else if (rPropName.matchAsciiL("SortRowOrColumnNo", 17) && + rPropName.getLength() == 18 && + (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) + { + bOldSortdescriptor = sal_True; + sal_uInt16 nIndex = rPropName.getStr()[17]; + nIndex -= '0'; + sal_Int16 nCol = -1; + if (aValue.getValueType() == ::getCppuType((const sal_Int16*)0) + && nIndex < 3) + { + aValue >>= nCol; + } + if (nCol >= 0) + { + aKeys[nIndex]->nColumnId = nCol; + } + else + { + bRet = sal_False; + } + } + else if (0 == rPropName.indexOf(C2U("IsSortNumeric")) && + rPropName.getLength() == 14 && + (rPropName.getStr()[13] >= '0' && rPropName.getStr()[13] <= '9')) + { + bOldSortdescriptor = sal_True; + sal_uInt16 nIndex = rPropName.getStr()[13]; + nIndex = nIndex - '0'; + if (aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3) + { + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); + aKeys[nIndex]->bIsNumeric = bTemp; + } + else + { + bRet = sal_False; + } + } + else if (0 == rPropName.indexOf(C2U("IsSortAscending")) && + rPropName.getLength() == 16 && + (rPropName.getStr()[15] >= '0' && rPropName.getStr()[15] <= '9')) + { + bOldSortdescriptor = sal_True; + sal_uInt16 nIndex = rPropName.getStr()[15]; + nIndex -= '0'; + if (aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3) + { + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); + aKeys[nIndex]->eSortOrder = (bTemp) + ? SRT_ASCENDING : SRT_DESCENDING; + } + else + { + bRet = sal_False; + } + } + // new sortdescriptor + else if (rPropName.equalsAscii("IsSortColumns")) + { + bNewSortdescriptor = sal_True; + if (aValue.getValueType() == ::getBooleanCppuType()) + { + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); + rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; + } + else + { + bRet = sal_False; + } + } + else if (rPropName.equalsAscii("SortFields")) { - SwDoc* pDoc = pUnoCrsr->GetDoc(); - const OUString *pNames = aPropertyNames.getConstArray(); - Any *pAny = aRet.getArray(); - for ( sal_Int32 i = 0; i < nCount; i++) + bNewSortdescriptor = sal_True; + uno::Sequence < table::TableSortField > aFields; + if (aValue >>= aFields) { - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( pNames[i] ); - if(!pEntry) + sal_Int32 nCount(aFields.getLength()); + if (nCount <= 3) { - if(pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || - pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT))) + table::TableSortField* pFields = aFields.getArray(); + for (sal_Int32 i = 0; i < nCount; ++i) { - continue; + rSortOpt.bIgnoreCase = !pFields[i].IsCaseSensitive; + rSortOpt.nLanguage = + SvxLocaleToLanguage( pFields[i].CollatorLocale ); + aKeys[i]->sSortType = pFields[i].CollatorAlgorithm; + aKeys[i]->nColumnId = + static_cast<USHORT>(pFields[i].Field); + aKeys[i]->bIsNumeric = (pFields[i].FieldType == + table::TableSortFieldType_NUMERIC); + aKeys[i]->eSortOrder = (pFields[i].IsAscending) + ? SRT_ASCENDING : SRT_DESCENDING; } - else - throw UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( 0 ) ); } - if(pEntry->nWID < RES_FRMATR_END) + else { - const SfxPoolItem& rDefItem = pDoc->GetAttrPool().GetDefaultItem(pEntry->nWID); - rDefItem.QueryValue(pAny[i], pEntry->nMemberId); + bRet = sal_False; } } + else + { + bRet = sal_False; + } } - else - throw UnknownPropertyException(); } - return aRet; + + if (bNewSortdescriptor && bOldSortdescriptor) + { + DBG_ERROR("someone tried to set the old deprecated and " + "the new sortdescriptor"); + bRet = sal_False; + } + + if (pKey1->nColumnId != USHRT_MAX) + { + rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey1, rSortOpt.aKeys.Count()); + } + if (pKey2->nColumnId != USHRT_MAX) + { + rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey2, rSortOpt.aKeys.Count()); + } + if (pKey3->nColumnId != USHRT_MAX) + { + rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey3, rSortOpt.aKeys.Count()); + } + + return bRet && rSortOpt.aKeys.Count() > 0; } -/*-- 10.03.2008 09:58:47--------------------------------------------------- +/*-- 09.12.98 14:19:00--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::makeRedline( - const ::rtl::OUString& rRedlineType, - const uno::Sequence< beans::PropertyValue >& rRedlineProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) +void SAL_CALL +SwXTextCursor::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - SwUnoCursorHelper::makeRedline( *pUnoCrsr, rRedlineType, rRedlineProperties ); - else + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + if (rUnoCursor.HasMark()) + { + SwSortOptions aSortOpt; + if (!SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)) + { + throw uno::RuntimeException(); + } + UnoActionContext aContext( rUnoCursor.GetDoc() ); + + SwPosition & rStart = *rUnoCursor.Start(); + SwPosition & rEnd = *rUnoCursor.End(); + + SwNodeIndex aPrevIdx( rStart.nNode, -1 ); + const ULONG nOffset = rEnd.nNode.GetIndex() - rStart.nNode.GetIndex(); + const xub_StrLen nCntStt = rStart.nContent.GetIndex(); + + rUnoCursor.GetDoc()->SortText(rUnoCursor, aSortOpt); + + // Selektion wieder setzen + rUnoCursor.DeleteMark(); + rUnoCursor.GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); + SwCntntNode *const pCNd = rUnoCursor.GetCntntNode(); + xub_StrLen nLen = pCNd->Len(); + if (nLen > nCntStt) + { + nLen = nCntStt; + } + rUnoCursor.GetPoint()->nContent.Assign(pCNd, nLen ); + rUnoCursor.SetMark(); + + rUnoCursor.GetPoint()->nNode += nOffset; + SwCntntNode *const pCNd2 = rUnoCursor.GetCntntNode(); + rUnoCursor.GetPoint()->nContent.Assign( pCNd2, pCNd2->Len() ); + } +} + +/* -----------------------------03.04.00 09:11-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Reference< container::XEnumeration > SAL_CALL +SwXTextCursor::createContentEnumeration(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (!rServiceName.equalsAscii("com.sun.star.text.TextContent")) + { + throw uno::RuntimeException(); + } + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + uno::Reference< container::XEnumeration > xRet = + new SwXParaFrameEnumeration(rUnoCursor, PARAFRAME_PORTION_TEXTRANGE); + return xRet; +} + +/* -----------------------------07.03.01 14:53-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Reference< container::XEnumeration > SAL_CALL +SwXTextCursor::createEnumeration() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + const uno::Reference<lang::XUnoTunnel> xTunnel( + m_pImpl->m_xParentText, uno::UNO_QUERY); + SwXText* pParentText = 0; + if (xTunnel.is()) + { + pParentText = ::sw::UnoTunnelGetImplementation<SwXText>(xTunnel); + } + DBG_ASSERT(pParentText, "parent is not a SwXText"); + if (!pParentText) + { throw uno::RuntimeException(); + } + + ::std::auto_ptr<SwUnoCrsr> pNewCrsr( + rUnoCursor.GetDoc()->CreateUnoCrsr(*rUnoCursor.GetPoint()) ); + if (rUnoCursor.HasMark()) + { + pNewCrsr->SetMark(); + *pNewCrsr->GetMark() = *rUnoCursor.GetMark(); + } + const CursorType eSetType = (CURSOR_TBLTEXT == m_pImpl->m_eType) + ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; + SwTableNode const*const pStartNode( (CURSOR_TBLTEXT == m_pImpl->m_eType) + ? rUnoCursor.GetPoint()->nNode.GetNode().FindTableNode() + : 0); + SwTable const*const pTable( + (pStartNode) ? & pStartNode->GetTable() : 0 ); + const uno::Reference< container::XEnumeration > xRet = + new SwXParagraphEnumeration( + pParentText, pNewCrsr, eSetType, pStartNode, pTable); + + return xRet; +} + +/* -----------------------------07.03.01 15:43-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Type SAL_CALL +SwXTextCursor::getElementType() throw (uno::RuntimeException) +{ + return text::XTextRange::static_type(); +} + +/* -----------------------------07.03.01 15:43-------------------------------- + + ---------------------------------------------------------------------------*/ +sal_Bool SAL_CALL SwXTextCursor::hasElements() throw (uno::RuntimeException) +{ + return sal_True; } + +/* -----------------------------03.04.00 09:11-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXTextCursor::getAvailableServiceNames() throw (uno::RuntimeException) +{ + uno::Sequence< OUString > aRet(1); + OUString* pArray = aRet.getArray(); + pArray[0] = OUString::createFromAscii("com.sun.star.text.TextContent"); + return aRet; +} + +// --------------------------------------------------------------------------- +IMPLEMENT_FORWARD_REFCOUNT( SwXTextCursor,SwXTextCursor_Base ) + +uno::Any SAL_CALL +SwXTextCursor::queryInterface(const uno::Type& rType) +throw (uno::RuntimeException) +{ + return (rType == lang::XUnoTunnel::static_type()) + ? OTextCursorHelper::queryInterface(rType) + : SwXTextCursor_Base::queryInterface(rType); +} + diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 5b09353555..accb3c2991 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <rtl/ustrbuf.hxx> #include <swtypes.hxx> #include <hintids.hxx> @@ -76,8 +75,11 @@ #include <sfx2/fcontnr.hxx> #include <fmtrfmrk.hxx> #include <txtrfmrk.hxx> -#include <unoclbck.hxx> -#include <unoobj.hxx> +#include <unoparaframeenum.hxx> +#include <unofootnote.hxx> +#include <unotextbodyhf.hxx> +#include <unotextrange.hxx> +#include <unoparagraph.hxx> #include <unomap.hxx> #include <unoport.hxx> #include <unocrsrhelper.hxx> @@ -90,19 +92,17 @@ #include <unofield.hxx> #include <fmtanchr.hxx> #include <svx/flstitem.hxx> -#include <svx/unolingu.hxx> #include <svtools/ctrltool.hxx> #include <flypos.hxx> #include <txtftn.hxx> #include <fmtftn.hxx> +#include <fmtcntnt.hxx> #include <com/sun/star/text/WrapTextMode.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> #include <com/sun/star/style/PageStyleLayout.hpp> #include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> -#include <unotools/collatorwrapper.hxx> -#include <com/sun/star/table/TableSortField.hpp> #include <unoidx.hxx> #include <unoframe.hxx> #include <fmthdft.hxx> @@ -122,6 +122,7 @@ #include <vector> // OD 2004-05-24 #i28701# #include <sortedobjs.hxx> +#include <sortopt.hxx> #include <algorithm> #include <iterator> @@ -129,17 +130,63 @@ using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::text; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::drawing; - using ::rtl::OUString; +namespace sw { + +sal_Bool SupportsServiceImpl( + size_t const nServices, char const*const pServices[], + ::rtl::OUString const & rServiceName) +{ + for (size_t i = 0; i < nServices; ++i) + { + if (rServiceName.equalsAscii(pServices[i])) + { + return sal_True; + } + } + return sal_False; +} + +uno::Sequence< ::rtl::OUString > +GetSupportedServiceNamesImpl( + size_t const nServices, char const*const pServices[]) +{ + uno::Sequence< ::rtl::OUString > ret(nServices); + for (size_t i = 0; i < nServices; ++i) + { + ret[i] = C2U(pServices[i]); + } + return ret; +} + +} // namespace sw + + +namespace sw { + +void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget) +{ + rTarget = rSource; + + if (rSource.GetNext() != &rSource) + { + SwPaM *pPam = static_cast<SwPaM *>(rSource.GetNext()); + do + { + // create new PaM + SwPaM *const pNew = new SwPaM(*pPam); + // insert into ring + pNew->MoveTo(&rTarget); + pPam = static_cast<SwPaM *>(pPam->GetNext()); + } + while (pPam != &rSource); + } +} + +} // namespace sw + struct FrameDependSortListLess { bool operator() (FrameDependSortListEntry const& r1, @@ -163,7 +210,8 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, // gebunden sind SwDoc* pDoc = rIdx.GetNode().GetDoc(); - USHORT nChkType = static_cast< USHORT >(_bAtCharAnchoredObjs ? FLY_AUTO_CNTNT : FLY_AT_CNTNT); + USHORT nChkType = static_cast< USHORT >((_bAtCharAnchoredObjs) + ? FLY_AT_CHAR : FLY_AT_PARA); const SwCntntFrm* pCFrm; const SwCntntNode* pCNd; if( pDoc->GetRootFrm() && @@ -220,343 +268,61 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, } } - -/*-- 09.12.98 14:18:58--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXTextCursor::insertDocumentFromURL(const OUString& rURL, - const uno::Sequence< beans::PropertyValue >& rOptions) - throw( lang::IllegalArgumentException, io::IOException, uno::RuntimeException ) +/**************************************************************************** + ActionContext +****************************************************************************/ +UnoActionContext::UnoActionContext(SwDoc *const pDoc) + : m_pDoc(pDoc) { - vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + SwRootFrm *const pRootFrm = m_pDoc->GetRootFrm(); + if (pRootFrm) { - SwUnoCursorHelper::InsertFile(pUnoCrsr, rURL, rOptions); + pRootFrm->StartAllAction(); } - else - throw uno::RuntimeException(); -} -/* -----------------------------15.12.00 14:01-------------------------------- - - ---------------------------------------------------------------------------*/ -uno::Sequence< beans::PropertyValue > SwXTextCursor::createSortDescriptor(sal_Bool bFromTable) -{ - uno::Sequence< beans::PropertyValue > aRet(5); - beans::PropertyValue* pArray = aRet.getArray(); - - uno::Any aVal; - aVal.setValue( &bFromTable, ::getCppuBooleanType()); - pArray[0] = beans::PropertyValue(C2U("IsSortInTable"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - String sSpace(String::CreateFromAscii(" ")); - sal_Unicode uSpace = sSpace.GetChar(0); - - aVal <<= uSpace; - pArray[1] = beans::PropertyValue(C2U("Delimiter"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - aVal <<= (sal_Bool) sal_False; - pArray[2] = beans::PropertyValue(C2U("IsSortColumns"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - aVal <<= (sal_Int32) 3; - pArray[3] = beans::PropertyValue(C2U("MaxSortFieldsCount"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - uno::Sequence< table::TableSortField > aFields(3); - table::TableSortField* pFields = aFields.getArray(); - - Locale aLang( SvxCreateLocale( LANGUAGE_SYSTEM ) ); - // get collator algorithm to be used for the locale - Sequence < OUString > aSeq( GetAppCollator().listCollatorAlgorithms( aLang ) ); - INT32 nLen = aSeq.getLength(); - DBG_ASSERT( nLen > 0, "list of collator algorithms is empty!"); - OUString aCollAlg; - if (nLen > 0) - aCollAlg = aSeq.getConstArray()[0]; - -#if OSL_DEBUG_LEVEL > 1 - const OUString *pTxt = aSeq.getConstArray(); - (void)pTxt; -#endif - - pFields[0].Field = 1; - pFields[0].IsAscending = sal_True; - pFields[0].IsCaseSensitive = sal_False; - pFields[0].FieldType = table::TableSortFieldType_ALPHANUMERIC; - pFields[0].CollatorLocale = aLang; - pFields[0].CollatorAlgorithm = aCollAlg; - - pFields[1].Field = 1; - pFields[1].IsAscending = sal_True; - pFields[1].IsCaseSensitive = sal_False; - pFields[1].FieldType = table::TableSortFieldType_ALPHANUMERIC; - pFields[1].CollatorLocale = aLang; - pFields[1].CollatorAlgorithm = aCollAlg; - - pFields[2].Field = 1; - pFields[2].IsAscending = sal_True; - pFields[2].IsCaseSensitive = sal_False; - pFields[2].FieldType = table::TableSortFieldType_ALPHANUMERIC; - pFields[2].CollatorLocale = aLang; - pFields[2].CollatorAlgorithm = aCollAlg; - - aVal <<= aFields; - pArray[4] = beans::PropertyValue(C2U("SortFields"), -1, aVal, beans::PropertyState_DIRECT_VALUE); - - return aRet; } -/*-- 09.12.98 14:18:58--------------------------------------------------- +/*-----------------04.03.98 11:56------------------- - -----------------------------------------------------------------------*/ -uno::Sequence< beans::PropertyValue > SwXTextCursor::createSortDescriptor(void) throw( uno::RuntimeException ) +--------------------------------------------------*/ +UnoActionContext::~UnoActionContext() { - vos::OGuard aGuard(Application::GetSolarMutex()); - return SwXTextCursor::createSortDescriptor(sal_False); -} -/* -----------------------------15.12.00 14:06-------------------------------- - - ---------------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::convertSortProperties( - const uno::Sequence< beans::PropertyValue >& rDescriptor, SwSortOptions& rSortOpt) -{ - sal_Bool bRet = sal_True; - const beans::PropertyValue* pProperties = rDescriptor.getConstArray(); - - rSortOpt.bTable = sal_False; - rSortOpt.cDeli = ' '; - rSortOpt.eDirection = SRT_COLUMNS; //!! UI text may be contrary though !! - - SwSortKey* pKey1 = new SwSortKey; - pKey1->nColumnId = USHRT_MAX; - pKey1->bIsNumeric = TRUE; - pKey1->eSortOrder = SRT_ASCENDING; - - SwSortKey* pKey2 = new SwSortKey; - pKey2->nColumnId = USHRT_MAX; - pKey2->bIsNumeric = TRUE; - pKey2->eSortOrder = SRT_ASCENDING; - - SwSortKey* pKey3 = new SwSortKey; - pKey3->nColumnId = USHRT_MAX; - pKey3->bIsNumeric = TRUE; - pKey3->eSortOrder = SRT_ASCENDING; - SwSortKey* aKeys[3] = {pKey1, pKey2, pKey3}; - - sal_Bool bOldSortdescriptor(sal_False); - sal_Bool bNewSortdescriptor(sal_False); - - for( int n = 0; n < rDescriptor.getLength(); ++n ) + // Doc may already have been removed here + if (m_pDoc) { - uno::Any aValue( pProperties[n].Value ); -// String sPropName = pProperties[n].Name; - const OUString& rPropName = pProperties[n].Name; - - // old and new sortdescriptor - if( COMPARE_EQUAL == rPropName.compareToAscii("IsSortInTable")) - { - if ( aValue.getValueType() == ::getBooleanCppuType() ) - rSortOpt.bTable = *(sal_Bool*)aValue.getValue(); - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("Delimiter")) + SwRootFrm *const pRootFrm = m_pDoc->GetRootFrm(); + if (pRootFrm) { - sal_Unicode uChar = sal_Unicode(); - if( aValue >>= uChar ) - rSortOpt.cDeli = uChar; - else - bRet = sal_False; - } - // old sortdescriptor - else if(COMPARE_EQUAL == rPropName.compareToAscii("SortColumns")) - { - bOldSortdescriptor = sal_True; - if ( aValue.getValueType() == ::getBooleanCppuType() ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; - } - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("IsCaseSensitive")) - { - bOldSortdescriptor = sal_True; - if ( aValue.getValueType() == ::getBooleanCppuType() ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - rSortOpt.bIgnoreCase = !bTemp; - } - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("CollatorLocale")) - { - bOldSortdescriptor = sal_True; - Locale aLocale; - if (aValue >>= aLocale) - rSortOpt.nLanguage = SvxLocaleToLanguage( aLocale ); - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("CollatorAlgorithm", 17) && - rPropName.getLength() == 18 && - (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) - { - bOldSortdescriptor = sal_True; - sal_uInt16 nIndex = rPropName.getStr()[17]; - nIndex -= '0'; - OUString aTxt; - if ((aValue >>= aTxt) && nIndex < 3) - aKeys[nIndex]->sSortType = aTxt; - else - bRet = sal_False; - } - else if(COMPARE_EQUAL == rPropName.compareToAscii("SortRowOrColumnNo", 17) && - rPropName.getLength() == 18 && - (rPropName.getStr()[17] >= '0' && rPropName.getStr()[17] <= '9')) - { - bOldSortdescriptor = sal_True; - sal_uInt16 nIndex = rPropName.getStr()[17]; - nIndex -= '0'; - sal_Int16 nCol = -1; - if( aValue.getValueType() == ::getCppuType((const sal_Int16*)0) && nIndex < 3) - aValue >>= nCol; - if( nCol >= 0 ) - aKeys[nIndex]->nColumnId = nCol; - else - bRet = sal_False; - } - else if(0 == rPropName.indexOf(C2U("IsSortNumeric")) && - rPropName.getLength() == 14 && - (rPropName.getStr()[13] >= '0' && rPropName.getStr()[13] <= '9')) - { - bOldSortdescriptor = sal_True; - sal_uInt16 nIndex = rPropName.getStr()[13]; - nIndex = nIndex - '0'; - if ( aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3 ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - aKeys[nIndex]->bIsNumeric = bTemp; - } - else - bRet = sal_False; - } - else if(0 == rPropName.indexOf(C2U("IsSortAscending")) && - rPropName.getLength() == 16 && - (rPropName.getStr()[15] >= '0' && rPropName.getStr()[15] <= '9')) - { - bOldSortdescriptor = sal_True; - sal_uInt16 nIndex = rPropName.getStr()[15]; - nIndex -= '0'; - if ( aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3 ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - aKeys[nIndex]->eSortOrder = bTemp ? SRT_ASCENDING : SRT_DESCENDING; - } - else - bRet = sal_False; - } - // new sortdescriptor - else if(COMPARE_EQUAL == rPropName.compareToAscii("IsSortColumns")) - { - bNewSortdescriptor = sal_True; - if ( aValue.getValueType() == ::getBooleanCppuType() ) - { - sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); - rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; - } - else - bRet = sal_False; - } - else if (COMPARE_EQUAL == rPropName.compareToAscii("SortFields")) - { - bNewSortdescriptor = sal_True; - uno::Sequence < table::TableSortField > aFields; - if ( aValue >>= aFields ) - { - sal_Int32 nCount(aFields.getLength()); - if (nCount <= 3) - { - table::TableSortField* pFields = aFields.getArray(); - for (sal_Int32 i = 0; i < nCount; ++i) - { - rSortOpt.bIgnoreCase = !pFields[i].IsCaseSensitive; - rSortOpt.nLanguage = SvxLocaleToLanguage( pFields[i].CollatorLocale ); - aKeys[i]->sSortType = pFields[i].CollatorAlgorithm; - aKeys[i]->nColumnId = static_cast< USHORT >(pFields[i].Field); - aKeys[i]->bIsNumeric = (pFields[i].FieldType == table::TableSortFieldType_NUMERIC); - aKeys[i]->eSortOrder = pFields[i].IsAscending ? SRT_ASCENDING : SRT_DESCENDING; - } - } - else - bRet = sal_False; - } - else - bRet = sal_False; + pRootFrm->EndAllAction(); } } +} - if (bNewSortdescriptor && bOldSortdescriptor) +/**************************************************************************** + ActionRemoveContext +****************************************************************************/ +UnoActionRemoveContext::UnoActionRemoveContext(SwDoc *const pDoc) + : m_pDoc(pDoc) +{ + SwRootFrm *const pRootFrm = m_pDoc->GetRootFrm(); + if (pRootFrm) { - DBG_ERROR("someone tried to set the old deprecated and the new sortdescriptor"); - bRet = sal_False; + pRootFrm->UnoRemoveAllActions(); } - - if(pKey1->nColumnId != USHRT_MAX) - rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey1, rSortOpt.aKeys.Count()); - if(pKey2->nColumnId != USHRT_MAX) - rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey2, rSortOpt.aKeys.Count()); - if(pKey3->nColumnId != USHRT_MAX) - rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey3, rSortOpt.aKeys.Count()); - - return bRet && rSortOpt.aKeys.Count() > 0; } -/*-- 09.12.98 14:19:00--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXTextCursor::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor) - throw( uno::RuntimeException ) +/* -----------------07.07.98 12:05------------------- + * + * --------------------------------------------------*/ +UnoActionRemoveContext::~UnoActionRemoveContext() { - vos::OGuard aGuard(Application::GetSolarMutex()); - SwSortOptions aSortOpt; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - - if(pUnoCrsr) + SwRootFrm *const pRootFrm = m_pDoc->GetRootFrm(); + if (pRootFrm) { - if(pUnoCrsr->HasMark()) - { - if(!SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) - throw uno::RuntimeException(); - UnoActionContext aContext( pUnoCrsr->GetDoc() ); - - SwPosition* pStart = pUnoCrsr->Start(); - SwPosition* pEnd = pUnoCrsr->End(); - - SwNodeIndex aPrevIdx( pStart->nNode, -1 ); - ULONG nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex(); - xub_StrLen nCntStt = pStart->nContent.GetIndex(); - - pUnoCrsr->GetDoc()->SortText(*pUnoCrsr, aSortOpt); - - // Selektion wieder setzen - pUnoCrsr->DeleteMark(); - pUnoCrsr->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); - SwCntntNode* pCNd = pUnoCrsr->GetCntntNode(); - xub_StrLen nLen = pCNd->Len(); - if( nLen > nCntStt ) - nLen = nCntStt; - pUnoCrsr->GetPoint()->nContent.Assign(pCNd, nLen ); - pUnoCrsr->SetMark(); - - pUnoCrsr->GetPoint()->nNode += nOffset; - pCNd = pUnoCrsr->GetCntntNode(); - pUnoCrsr->GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); - } + pRootFrm->UnoRestoreAllActions(); } - else - throw uno::RuntimeException(); } + + /*-- 10.12.98 11:52:15--------------------------------------------------- -----------------------------------------------------------------------*/ @@ -579,197 +345,33 @@ void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew) } } -/* -----------------------------03.04.00 09:11-------------------------------- - - ---------------------------------------------------------------------------*/ -uno::Reference< XEnumeration > SAL_CALL SwXTextCursor::createContentEnumeration(const OUString& rServiceName) throw( RuntimeException ) -{ - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if( !pUnoCrsr || 0 != rServiceName.compareToAscii("com.sun.star.text.TextContent") ) - throw RuntimeException(); - - uno::Reference< XEnumeration > xRet = new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_TEXTRANGE); - return xRet; -} -/* -----------------------------07.03.01 14:53-------------------------------- - - ---------------------------------------------------------------------------*/ -uno::Reference< XEnumeration > SwXTextCursor::createEnumeration(void) throw( RuntimeException ) -{ - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if( !pUnoCrsr ) - throw RuntimeException(); - uno::Reference<XUnoTunnel> xTunnel(xParentText, UNO_QUERY); - SwXText* pParentText = 0; - if(xTunnel.is()) - { - pParentText = reinterpret_cast< SwXText *>( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXText::getUnoTunnelId()) )); - } - DBG_ASSERT(pParentText, "parent is not a SwXText"); - - SwUnoCrsr* pNewCrsr = pUnoCrsr->GetDoc()->CreateUnoCrsr(*pUnoCrsr->GetPoint()); - if(pUnoCrsr->HasMark()) - { - pNewCrsr->SetMark(); - *pNewCrsr->GetMark() = *pUnoCrsr->GetMark(); - } - CursorType eSetType = eType == CURSOR_TBLTEXT ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - SwXParagraphEnumeration *pEnum = - new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); - uno::Reference< XEnumeration > xRet = pEnum; - if (eType == CURSOR_TBLTEXT) - { - // for import of tables in tables we have to remember the actual - // table and start node of the current position in the enumeration. - SwTableNode *pStartN = pUnoCrsr->GetPoint()->nNode.GetNode().FindTableNode(); - if (pStartN) - { - pEnum->SetOwnTable( &pStartN->GetTable() ); - pEnum->SetOwnStartNode( pStartN ); - } - } - - return xRet; -} -/* -----------------------------07.03.01 15:43-------------------------------- - - ---------------------------------------------------------------------------*/ -uno::Type SwXTextCursor::getElementType(void) throw( RuntimeException ) -{ - return ::getCppuType((uno::Reference<XTextRange>*)0); -} -/* -----------------------------07.03.01 15:43-------------------------------- - - ---------------------------------------------------------------------------*/ -sal_Bool SwXTextCursor::hasElements(void) throw( RuntimeException ) -{ - return sal_True; -} -/* -----------------------------03.04.00 09:11-------------------------------- - - ---------------------------------------------------------------------------*/ -Sequence< OUString > SAL_CALL SwXTextCursor::getAvailableServiceNames(void) throw( RuntimeException ) -{ - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = OUString::createFromAscii("com.sun.star.text.TextContent"); - return aRet; -} -/*-- 09.12.98 14:19:00--------------------------------------------------- - - -----------------------------------------------------------------------*/ - -IMPL_STATIC_LINK( SwXTextCursor, RemoveCursor_Impl, - uno::Reference< XInterface >*, EMPTYARG ) -{ - ASSERT( pThis != NULL, "no reference?" ); - //ASSERT( pArg != NULL, "no reference?" ); - - // --> FME 2006-03-07 #126177# Tell the SwXTextCursor that the user event - // has been executed. It is not necessary to remove the user event in - // ~SwXTextCursor - pThis->DoNotRemoveUserEvent(); - // <-- - - SwUnoCrsr* pCursor = pThis->GetCrsr(); - if( pCursor != NULL ) - { - pCursor->Remove( pThis ); - delete pCursor; - } - - // --> FME 2006-03-07 #126177# - //delete pArg; - // <-- - - return 0; -} - -void SwXTextCursor::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); - - // if the cursor leaves its designated section, it becomes invalid - if( !mbRemoveUserEvent && ( pOld != NULL ) && ( pOld->Which() == RES_UNOCURSOR_LEAVES_SECTION ) ) - { - // --> FME 2006-03-07 #126177# We don't need to create a reference - // to the SwXTextCursor to prevent its deletion. If the destructor - // of the SwXTextCursor is called before the user event is executed, - // the user event will be removed. This is necessary, because an other - // thread might be currently waiting in ~SwXTextCursor. In this case - // the pRef = new ... stuff did not work! - - // create reference to this object to prevent deletion before - // the STATIC_LINK is executed. The link will delete the - // reference. - //uno::Reference<XInterface>* pRef = - //new uno::Reference<XInterface>( static_cast<XServiceInfo*>( this ) ); - - mbRemoveUserEvent = true; - // <-- - - mnUserEventId = Application::PostUserEvent( - STATIC_LINK( this, SwXTextCursor, RemoveCursor_Impl ), this ); - } - - if(!GetRegisteredIn()) - aLstnrCntnr.Disposing(); - -} -/*-- 09.12.98 14:19:01--------------------------------------------------- - - -----------------------------------------------------------------------*/ -const SwPaM* SwXTextCursor::GetPaM() const -{ - return GetCrsr() ? GetCrsr() : 0; -} -// ----------------------------------------------------------------------------- -SwPaM* SwXTextCursor::GetPaM() -{ - return GetCrsr() ? GetCrsr() : 0; -} - -/*-- 09.12.98 14:19:02--------------------------------------------------- - - -----------------------------------------------------------------------*/ -const SwDoc* SwXTextCursor::GetDoc()const -{ - return GetCrsr() ? GetCrsr()->GetDoc() : 0; -} -/* -----------------22.07.99 13:52------------------- - - --------------------------------------------------*/ -SwDoc* SwXTextCursor::GetDoc() -{ - return GetCrsr() ? GetCrsr()->GetDoc() : 0; -} /*-- 09.12.98 14:19:03--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAttrMode) +void SwUnoCursorHelper::SetCrsrAttr(SwPaM & rPam, + const SfxItemSet& rSet, + const SetAttrMode nAttrMode, const bool bTableMode) { - sal_uInt16 nFlags = nsSetAttrMode::SETATTR_APICALL | (nAttrMode & nsSetAttrMode::SETATTR_NOFORMATATTR); - if(nAttrMode & CRSR_ATTR_MODE_DONTREPLACE) - nFlags |= nsSetAttrMode::SETATTR_DONTREPLACE; + const SetAttrMode nFlags = nAttrMode | nsSetAttrMode::SETATTR_APICALL; SwDoc* pDoc = rPam.GetDoc(); //StartEndAction UnoActionContext aAction(pDoc); - SwPaM* pCrsr = &rPam; - if( pCrsr->GetNext() != pCrsr ) // Ring von Cursorn + if (rPam.GetNext() != &rPam) // Ring of Cursors { pDoc->StartUndo(UNDO_INSATTR, NULL); - SwPaM *_pStartCrsr = &rPam; + SwPaM *pCurrent = &rPam; do { - if( _pStartCrsr->HasMark() && ( (CRSR_ATTR_MODE_TABLE & nAttrMode) || - *_pStartCrsr->GetPoint() != *_pStartCrsr->GetMark() )) + if (pCurrent->HasMark() && + ( (bTableMode) || + (*pCurrent->GetPoint() != *pCurrent->GetMark()) )) { - pDoc->InsertItemSet(*_pStartCrsr, rSet, nFlags); + pDoc->InsertItemSet(*pCurrent, rSet, nFlags); } - } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != &rPam ); + pCurrent= static_cast<SwPaM *>(pCurrent->GetNext()); + } while (pCurrent != &rPam); pDoc->EndUndo(UNDO_INSATTR, NULL); } @@ -777,7 +379,7 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt { // if( !HasSelection() ) // UpdateAttr(); - pDoc->InsertItemSet( *pCrsr, rSet, nFlags ); + pDoc->InsertItemSet( rPam, rSet, nFlags ); } //#outline level,add by zhaojianwei if( rSet.GetItemState( RES_PARATR_OUTLINELEVEL, false ) >= SFX_ITEM_AVAILABLE ) @@ -787,7 +389,6 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt { rPam.GetDoc()->GetNodes().UpdateOutlineNode( *pTmpNode ); } - } //<-end,zhaojianwei } @@ -797,172 +398,228 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt // --> OD 2006-07-12 #i63870# // split third parameter <bCurrentAttrOnly> into new parameters <bOnlyTxtAttr> // and <bGetFromChrFmt> to get better control about resulting <SfxItemSet> -void SwXTextCursor::GetCrsrAttr( SwPaM& rPam, - SfxItemSet& rSet, - BOOL bOnlyTxtAttr, - BOOL bGetFromChrFmt ) +void SwUnoCursorHelper::GetCrsrAttr(SwPaM & rPam, + SfxItemSet & rSet, const bool bOnlyTxtAttr, const bool bGetFromChrFmt) { static const sal_uInt16 nMaxLookup = 1000; SfxItemSet aSet( *rSet.GetPool(), rSet.GetRanges() ); SfxItemSet *pSet = &rSet; - SwPaM *_pStartCrsr = &rPam; + SwPaM *pCurrent = & rPam; do { - ULONG nSttNd = _pStartCrsr->GetMark()->nNode.GetIndex(), - nEndNd = _pStartCrsr->GetPoint()->nNode.GetIndex(); - xub_StrLen nSttCnt = _pStartCrsr->GetMark()->nContent.GetIndex(), - nEndCnt = _pStartCrsr->GetPoint()->nContent.GetIndex(); - - if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt )) - { - sal_uInt32 nTmp = nSttNd; nSttNd = nEndNd; nEndNd = nTmp; - nTmp = nSttCnt; nSttCnt = nEndCnt; nEndCnt = (sal_uInt16)nTmp; - } + SwPosition const & rStart( *pCurrent->Start() ); + SwPosition const & rEnd( *pCurrent->End() ); + const ULONG nSttNd = rStart.nNode.GetIndex(); + const ULONG nEndNd = rEnd .nNode.GetIndex(); - if( nEndNd - nSttNd >= nMaxLookup ) - { - rSet.ClearItem(); - rSet.InvalidateAllItems(); - return;// uno::Any(); - } + if (nEndNd - nSttNd >= nMaxLookup) + { + rSet.ClearItem(); + rSet.InvalidateAllItems(); + return;// uno::Any(); + } - // beim 1.Node traegt der Node die Werte in den GetSet ein (Initial) - // alle weiteren Nodes werden zum GetSet zu gemergt - for( ULONG n = nSttNd; n <= nEndNd; ++n ) + // the first node inserts the values into the get set + // all other nodes merge their values into the get set + for (ULONG n = nSttNd; n <= nEndNd; ++n) + { + SwNode *const pNd = rPam.GetDoc()->GetNodes()[ n ]; + switch (pNd->GetNodeType()) { - SwNode* pNd = rPam.GetDoc()->GetNodes()[ n ]; - switch( pNd->GetNodeType() ) - { case ND_TEXTNODE: - { - xub_StrLen nStt = n == nSttNd ? nSttCnt : 0, - nEnd = n == nEndNd ? nEndCnt - : ((SwTxtNode*)pNd)->GetTxt().Len(); - ((SwTxtNode*)pNd)->GetAttr( *pSet, nStt, nEnd, bOnlyTxtAttr, bGetFromChrFmt ); - } - break; + { + const xub_StrLen nStart = (n == nSttNd) + ? rStart.nContent.GetIndex() : 0; + const xub_StrLen nEnd = (n == nEndNd) + ? rEnd.nContent.GetIndex() + : static_cast<SwTxtNode*>(pNd)->GetTxt().Len(); + static_cast<SwTxtNode*>(pNd)->GetAttr( + *pSet, nStart, nEnd, bOnlyTxtAttr, bGetFromChrFmt); + } + break; case ND_GRFNODE: case ND_OLENODE: - ((SwCntntNode*)pNd)->GetAttr( *pSet ); - break; + static_cast<SwCntntNode*>(pNd)->GetAttr( *pSet ); + break; default: - pNd = 0; - } - - if( pNd ) - { - if( pSet != &rSet ) - rSet.MergeValues( aSet ); - - if( aSet.Count() ) - aSet.ClearItem(); + continue; // skip this node + } - } + if (pSet != &rSet) + { + rSet.MergeValues( aSet ); + } + else + { pSet = &aSet; } - } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != &rPam ); + + if (aSet.Count()) + { + aSet.ClearItem(); + } + } + pCurrent= static_cast<SwPaM *>(pCurrent->GetNext()); + } while ( pCurrent != &rPam ); } + /****************************************************************** * SwXParagraphEnumeration ******************************************************************/ -/* -----------------------------06.04.00 16:33-------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXParagraphEnumeration::getImplementationName(void) throw( RuntimeException ) -{ - return C2U("SwXParagraphEnumeration"); -} -/* -----------------------------06.04.00 16:33-------------------------------- +class SwXParagraphEnumeration::Impl + : public SwClient +{ + +public: + + uno::Reference< text::XText > const m_xParentText; + const CursorType m_eCursorType; + /// Start node of the cell _or_ table the enumeration belongs to. + /// Used to restrict the movement of the UNO cursor to the cell and its + /// embedded tables. + SwStartNode const*const m_pOwnStartNode; + SwTable const*const m_pOwnTable; + const ULONG m_nEndIndex; + sal_Int32 m_nFirstParaStart; + sal_Int32 m_nLastParaEnd; + bool m_bFirstParagraph; + uno::Reference< text::XTextContent > m_xNextPara; + + Impl( uno::Reference< text::XText > const& xParent, + ::std::auto_ptr<SwUnoCrsr> pCursor, + const CursorType eType, + SwStartNode const*const pStartNode, SwTable const*const pTable) + : SwClient( pCursor.release() ) + , m_xParentText( xParent ) + , m_eCursorType( eType ) + // remember table and start node for later travelling + // (used in export of tables in tables) + , m_pOwnStartNode( pStartNode ) + // for import of tables in tables we have to remember the actual + // table and start node of the current position in the enumeration. + , m_pOwnTable( pTable ) + , m_nEndIndex( GetCursor()->End()->nNode.GetIndex() ) + , m_nFirstParaStart( -1 ) + , m_nLastParaEnd( -1 ) + , m_bFirstParagraph( true ) + { + OSL_ENSURE(m_xParentText.is(), "SwXParagraphEnumeration: no parent?"); + OSL_ENSURE(GetRegisteredIn(), "SwXParagraphEnumeration: no cursor?"); + OSL_ENSURE( !((CURSOR_SELECTION_IN_TABLE == eType) || + (CURSOR_TBLTEXT == eType)) + || (m_pOwnTable && m_pOwnStartNode), + "SwXParagraphEnumeration: table type but no start node or table?"); + + if ((CURSOR_SELECTION == m_eCursorType) || + (CURSOR_SELECTION_IN_TABLE == m_eCursorType)) + { + SwUnoCrsr & rCursor = *GetCursor(); + rCursor.Normalize(); + m_nFirstParaStart = rCursor.GetPoint()->nContent.GetIndex(); + m_nLastParaEnd = rCursor.GetMark()->nContent.GetIndex(); + rCursor.DeleteMark(); + } + } - ---------------------------------------------------------------------------*/ -BOOL SwXParagraphEnumeration::supportsService(const OUString& rServiceName) throw( RuntimeException ) + ~Impl() { + // Impl owns the cursor; delete it here: SolarMutex is locked + delete GetRegisteredIn(); + } + + SwUnoCrsr * GetCursor() { + return static_cast<SwUnoCrsr*>( + const_cast<SwModify*>(GetRegisteredIn())); + } + + uno::Reference< text::XTextContent > NextElement_Impl() + throw (container::NoSuchElementException, lang::WrappedTargetException, + uno::RuntimeException); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +void SwXParagraphEnumeration::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { - return C2U("com.sun.star.text.ParagraphEnumeration") == rServiceName; + ClientModify(this, pOld, pNew); } -/* -----------------------------06.04.00 16:33-------------------------------- - ---------------------------------------------------------------------------*/ -Sequence< OUString > SwXParagraphEnumeration::getSupportedServiceNames(void) throw( RuntimeException ) +/*-- 10.12.98 11:52:12--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXParagraphEnumeration::SwXParagraphEnumeration( + uno::Reference< text::XText > const& xParent, + ::std::auto_ptr<SwUnoCrsr> pCursor, + const CursorType eType, + SwStartNode const*const pStartNode, SwTable const*const pTable) + : m_pImpl( new SwXParagraphEnumeration::Impl(xParent, pCursor, eType, + pStartNode, pTable) ) { - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.ParagraphEnumeration"); - return aRet; } /*-- 10.12.98 11:52:12--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXParagraphEnumeration::SwXParagraphEnumeration(SwXText* pParent, - SwPosition& rPos, - CursorType eType) : - xParentText(pParent), - nFirstParaStart(-1), - nLastParaEnd(-1), - nEndIndex(rPos.nNode.GetIndex()), - eCursorType(eType), - bFirstParagraph(sal_True) -{ - pOwnTable = 0; - pOwnStartNode = 0; - SwUnoCrsr* pUnoCrsr = pParent->GetDoc()->CreateUnoCrsr(rPos, sal_False); - pUnoCrsr->Add(this); +SwXParagraphEnumeration::~SwXParagraphEnumeration() +{ } -/*-- 10.12.98 11:52:12--------------------------------------------------- +/* -----------------------------06.04.00 16:33-------------------------------- - -----------------------------------------------------------------------*/ -SwXParagraphEnumeration::SwXParagraphEnumeration(SwXText* pParent, - SwUnoCrsr* pCrsr, - CursorType eType) : - SwClient(pCrsr), - xParentText(pParent), - nFirstParaStart(-1), - nLastParaEnd(-1), - nEndIndex(pCrsr->End()->nNode.GetIndex()), - eCursorType(eType), - bFirstParagraph(sal_True) -{ - pOwnTable = 0; - pOwnStartNode = 0; - if(CURSOR_SELECTION == eCursorType || CURSOR_SELECTION_IN_TABLE == eCursorType) - { - if(*pCrsr->GetPoint() > *pCrsr->GetMark()) - pCrsr->Exchange(); - nFirstParaStart = pCrsr->GetPoint()->nContent.GetIndex(); - nLastParaEnd = pCrsr->GetMark()->nContent.GetIndex(); - if(pCrsr->HasMark()) - pCrsr->DeleteMark(); - } + ---------------------------------------------------------------------------*/ +OUString SAL_CALL +SwXParagraphEnumeration::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXParagraphEnumeration"); } -/*-- 10.12.98 11:52:12--------------------------------------------------- +/* -----------------------------06.04.00 16:33-------------------------------- - -----------------------------------------------------------------------*/ -SwXParagraphEnumeration::~SwXParagraphEnumeration() + ---------------------------------------------------------------------------*/ +static char const*const g_ServicesParagraphEnum[] = { - vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - delete pUnoCrsr; + "com.sun.star.text.ParagraphEnumeration", +}; +static const size_t g_nServicesParagraphEnum( + sizeof(g_ServicesParagraphEnum)/sizeof(g_ServicesParagraphEnum[0])); +sal_Bool SAL_CALL +SwXParagraphEnumeration::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesParagraphEnum, g_ServicesParagraphEnum, rServiceName); } +/* -----------------------------06.04.00 16:33-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXParagraphEnumeration::getSupportedServiceNames() +throw (uno::RuntimeException) +{ + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesParagraphEnum, g_ServicesParagraphEnum); +} + /*-- 10.12.98 11:52:13--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXParagraphEnumeration::hasMoreElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXParagraphEnumeration::hasMoreElements() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - return bFirstParagraph ? sal_True : xNextPara.is(); + + return (m_pImpl->m_bFirstParagraph) ? sal_True : m_pImpl->m_xNextPara.is(); } /*-- 14.08.03 13:10:14--------------------------------------------------- -----------------------------------------------------------------------*/ //!! compare to SwShellTableCrsr::FillRects() in viscrs.cxx -SwTableNode * lcl_FindTopLevelTable( - /*SwUnoCrsr* pUnoCrsr ,*/ - SwTableNode *pTblNode, - const SwTable *pOwnTable ) +static SwTableNode * +lcl_FindTopLevelTable( + SwTableNode *const pTblNode, SwTable const*const pOwnTable) { // find top-most table in current context (section) level @@ -977,14 +634,14 @@ SwTableNode * lcl_FindTopLevelTable( } -BOOL lcl_CursorIsInSection( - const SwUnoCrsr *pUnoCrsr, - const SwStartNode *pOwnStartNode ) +static bool +lcl_CursorIsInSection( + SwUnoCrsr const*const pUnoCrsr, SwStartNode const*const pOwnStartNode) { // returns true if the cursor is in the section (or in a sub section!) // represented by pOwnStartNode - BOOL bRes = TRUE; + bool bRes = true; if (pUnoCrsr && pOwnStartNode) { const SwEndNode * pOwnEndNode = pOwnStartNode->EndOfSectionNode(); @@ -995,388 +652,450 @@ BOOL lcl_CursorIsInSection( } -uno::Reference< XTextContent > SAL_CALL SwXParagraphEnumeration::NextElement_Impl(void) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Reference< text::XTextContent > +SwXParagraphEnumeration::Impl::NextElement_Impl() +throw (container::NoSuchElementException, lang::WrappedTargetException, + uno::RuntimeException) { - uno::Reference< XTextContent > aRef; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + SwUnoCrsr *const pUnoCrsr = GetCursor(); + if (!pUnoCrsr) { - // check for exceeding selections - if(!bFirstParagraph && - (CURSOR_SELECTION == eCursorType || CURSOR_SELECTION_IN_TABLE == eCursorType)) + throw uno::RuntimeException(); + } + + // check for exceeding selections + if (!m_bFirstParagraph && + ((CURSOR_SELECTION == m_eCursorType) || + (CURSOR_SELECTION_IN_TABLE == m_eCursorType))) + { + SwPosition* pStart = pUnoCrsr->Start(); + const ::std::auto_ptr<SwUnoCrsr> aNewCrsr( + pUnoCrsr->GetDoc()->CreateUnoCrsr(*pStart, sal_False) ); + // one may also go into tables here + if ((CURSOR_TBLTEXT != m_eCursorType) && + (CURSOR_SELECTION_IN_TABLE != m_eCursorType)) { - SwPosition* pStart = pUnoCrsr->Start(); - ::std::auto_ptr<SwUnoCrsr> aNewCrsr( pUnoCrsr->GetDoc()->CreateUnoCrsr(*pStart, sal_False) ); - //man soll hier auch in Tabellen landen duerfen - if(CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType) - aNewCrsr->SetRemainInSection( sal_False ); - - // os 2005-01-14: This part is only necessary to detect movements out of a selection - // if there is no selection we don't have to care - SwTableNode* pTblNode = aNewCrsr->GetNode()->FindTableNode(); - if((CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType) && pTblNode) - { - aNewCrsr->GetPoint()->nNode = pTblNode->EndOfSectionIndex(); - aNewCrsr->Move(fnMoveForward, fnGoNode); - } - else - aNewCrsr->MovePara(fnParaNext, fnParaStart); - if(nEndIndex < aNewCrsr->Start()->nNode.GetIndex()) - return aRef; // empty reference + aNewCrsr->SetRemainInSection( sal_False ); } - XText* pText = xParentText.get(); - sal_Bool bInTable = sal_False; - if(!bFirstParagraph) + // os 2005-01-14: This part is only necessary to detect movements out + // of a selection; if there is no selection we don't have to care + SwTableNode *const pTblNode = aNewCrsr->GetNode()->FindTableNode(); + if (((CURSOR_TBLTEXT != m_eCursorType) && + (CURSOR_SELECTION_IN_TABLE != m_eCursorType)) && pTblNode) { - //man soll hier auch in Tabellen landen duerfen - //if(CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType) - { - //BOOL bRemain = sal_False; - //pUnoCrsr->SetRemainInSection( bRemain ); - pUnoCrsr->SetRemainInSection( sal_False ); - //was mache ich, wenn ich schon in einer Tabelle stehe? - SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); - pTblNode = lcl_FindTopLevelTable( /*pUnoCrsr,*/ pTblNode, pOwnTable ); - if(pTblNode && &pTblNode->GetTable() != pOwnTable) - { - // wir haben es mit einer fremden Tabelle zu tun - also ans Ende - pUnoCrsr->GetPoint()->nNode = pTblNode->EndOfSectionIndex(); - if(!pUnoCrsr->Move(fnMoveForward, fnGoNode)) - return aRef; - else - bInTable = sal_True; - - } - } + aNewCrsr->GetPoint()->nNode = pTblNode->EndOfSectionIndex(); + aNewCrsr->Move(fnMoveForward, fnGoNode); + } + else + { + aNewCrsr->MovePara(fnParaNext, fnParaStart); + } + if (m_nEndIndex < aNewCrsr->Start()->nNode.GetIndex()) + { + return 0; } + } - // the cursor must remain in the current section or a subsection - // before AND after the movement... - if( lcl_CursorIsInSection( pUnoCrsr, pOwnStartNode ) && - (bFirstParagraph || bInTable || - (pUnoCrsr->MovePara(fnParaNext, fnParaStart) && - lcl_CursorIsInSection( pUnoCrsr, pOwnStartNode ) ) ) ) + sal_Bool bInTable = sal_False; + if (!m_bFirstParagraph) + { + pUnoCrsr->SetRemainInSection( sal_False ); + // what to do if already in a table? + SwTableNode * pTblNode = pUnoCrsr->GetNode()->FindTableNode(); + pTblNode = lcl_FindTopLevelTable( pTblNode, m_pOwnTable ); + if (pTblNode && (&pTblNode->GetTable() != m_pOwnTable)) { - SwPosition* pStart = pUnoCrsr->Start(); - sal_Int32 nFirstContent = bFirstParagraph ? nFirstParaStart : -1; - sal_Int32 nLastContent = nEndIndex == pStart->nNode.GetIndex() ? nLastParaEnd : -1; - //steht man nun in einer Tabelle, oder in einem einfachen Absatz? - - SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); - pTblNode = lcl_FindTopLevelTable( /*pUnoCrsr,*/ pTblNode, pOwnTable ); - if(/*CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType && */ - pTblNode && &pTblNode->GetTable() != pOwnTable) + // this is a foreign table: go to end + pUnoCrsr->GetPoint()->nNode = pTblNode->EndOfSectionIndex(); + if (!pUnoCrsr->Move(fnMoveForward, fnGoNode)) { - // wir haben es mit einer fremden Tabelle zu tun - SwFrmFmt* pTableFmt = (SwFrmFmt*)pTblNode->GetTable().GetFrmFmt(); - XTextTable* pTable = SwXTextTables::GetObject( *pTableFmt ); - aRef = (XTextContent*)(SwXTextTable*)pTable; - } - else - { - aRef = new SwXParagraph(static_cast<SwXText*>(pText), - pStart->nNode.GetNode().GetTxtNode(), - nFirstContent, nLastContent); + return 0; } + bInTable = sal_True; } } - else - throw uno::RuntimeException(); - return aRef; + uno::Reference< text::XTextContent > xRef; + // the cursor must remain in the current section or a subsection + // before AND after the movement... + if (lcl_CursorIsInSection( pUnoCrsr, m_pOwnStartNode ) && + (m_bFirstParagraph || bInTable || + (pUnoCrsr->MovePara(fnParaNext, fnParaStart) && + lcl_CursorIsInSection( pUnoCrsr, m_pOwnStartNode )))) + { + SwPosition* pStart = pUnoCrsr->Start(); + const sal_Int32 nFirstContent = + (m_bFirstParagraph) ? m_nFirstParaStart : -1; + const sal_Int32 nLastContent = + (m_nEndIndex == pStart->nNode.GetIndex()) ? m_nLastParaEnd : -1; + + // position in a table, or in a simple paragraph? + SwTableNode * pTblNode = pUnoCrsr->GetNode()->FindTableNode(); + pTblNode = lcl_FindTopLevelTable( pTblNode, m_pOwnTable ); + if (/*CURSOR_TBLTEXT != eCursorType && CURSOR_SELECTION_IN_TABLE != eCursorType && */ + pTblNode && (&pTblNode->GetTable() != m_pOwnTable)) + { + // this is a foreign table + SwFrmFmt* pTableFmt = + static_cast<SwFrmFmt*>(pTblNode->GetTable().GetFrmFmt()); + text::XTextTable *const pTable = + SwXTextTables::GetObject( *pTableFmt ); + xRef = static_cast<text::XTextContent*>( + static_cast<SwXTextTable*>(pTable)); + } + else + { + text::XText *const pText = m_xParentText.get(); + xRef = SwXParagraph::CreateXParagraph(*pUnoCrsr->GetDoc(), + *pStart->nNode.GetNode().GetTxtNode(), + static_cast<SwXText*>(pText), nFirstContent, nLastContent); + } + } + + return xRef; } /*-- 10.12.98 11:52:14--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParagraphEnumeration::nextElement(void) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL SwXParagraphEnumeration::nextElement() +throw (container::NoSuchElementException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextContent > aRef; - if (bFirstParagraph) + if (m_pImpl->m_bFirstParagraph) { - xNextPara = NextElement_Impl(); - bFirstParagraph = sal_False; + m_pImpl->m_xNextPara = m_pImpl->NextElement_Impl(); + m_pImpl->m_bFirstParagraph = false; } - aRef = xNextPara; - if (!aRef.is()) + const uno::Reference< text::XTextContent > xRef = m_pImpl->m_xNextPara; + if (!xRef.is()) + { throw container::NoSuchElementException(); - xNextPara = NextElement_Impl(); + } + m_pImpl->m_xNextPara = m_pImpl->NextElement_Impl(); - uno::Any aRet(&aRef, ::getCppuType((uno::Reference<XTextContent>*)0)); + uno::Any aRet; + aRet <<= xRef; return aRet; } -void SwXParagraphEnumeration::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); -} /****************************************************************** * SwXTextRange ******************************************************************/ -TYPEINIT1(SwXTextRange, SwClient); -const uno::Sequence< sal_Int8 > & SwXTextRange::getUnoTunnelId() -{ - static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; -} +class SwXTextRange::Impl + : public SwClient +{ + +public: + + const SfxItemPropertySet & m_rPropSet; + const enum RangePosition m_eRangePosition; + SwDoc & m_rDoc; + uno::Reference<text::XText> m_xParentText; + SwDepend m_ObjectDepend; // register at format of table or frame + ::sw::mark::IMark * m_pMark; + + Impl( SwDoc & rDoc, const enum RangePosition eRange, + SwFrmFmt *const pTblFmt = 0, + const uno::Reference< text::XText > & xParent = 0) + : SwClient() + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)) + , m_eRangePosition(eRange) + , m_rDoc(rDoc) + , m_xParentText(xParent) + , m_ObjectDepend(this, pTblFmt) + , m_pMark(0) + { + } -//XUnoTunnel -sal_Int64 SAL_CALL SwXTextRange::getSomething( - const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) -{ - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) + ~Impl() + { + // Impl owns the bookmark; delete it here: SolarMutex is locked + Invalidate(); + } + + void Invalidate() + { + if (m_pMark) { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast <sal_IntPtr >(this) ); + m_rDoc.getIDocumentMarkAccess()->deleteMark(m_pMark); + m_pMark = 0; } - return 0; -} + } -OUString SwXTextRange::getImplementationName(void) throw( RuntimeException ) -{ - return OUString::createFromAscii("SwXTextRange"); -} + const ::sw::mark::IMark * GetBookmark() const { return m_pMark; } + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; -BOOL SwXTextRange::supportsService(const OUString& rServiceName) throw( RuntimeException ) +void SwXTextRange::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { - String sServiceName(rServiceName); - return sServiceName.EqualsAscii("com.sun.star.text.TextRange") || - sServiceName.EqualsAscii("com.sun.star.style.CharacterProperties")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesAsian")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesComplex")|| - sServiceName.EqualsAscii("com.sun.star.style.ParagraphProperties") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesAsian") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesComplex"); + const bool bAlreadyRegistered = 0 != GetRegisteredIn(); + ClientModify(this, pOld, pNew); + if (m_ObjectDepend.GetRegisteredIn()) + { + ClientModify(&m_ObjectDepend, pOld, pNew); + // if the depend was removed then the range must be removed too + if (!m_ObjectDepend.GetRegisteredIn() && GetRegisteredIn()) + { + const_cast<SwModify*>(GetRegisteredIn())->Remove(this); + } + // or if the range has been removed but the depend ist still + // connected then the depend must be removed + else if (bAlreadyRegistered && !GetRegisteredIn() && + m_ObjectDepend.GetRegisteredIn()) + { + const_cast<SwModify*>(m_ObjectDepend.GetRegisteredIn()) + ->Remove(& m_ObjectDepend); + } + } + if (!GetRegisteredIn()) + { + m_pMark = 0; + } } -Sequence< OUString > SwXTextRange::getSupportedServiceNames(void) throw( RuntimeException ) + +SwXTextRange::SwXTextRange(SwPaM& rPam, + const uno::Reference< text::XText > & xParent, + const enum RangePosition eRange) + : m_pImpl( new SwXTextRange::Impl(*rPam.GetDoc(), eRange, 0, xParent) ) { - Sequence< OUString > aRet(7); - aRet[0] = OUString::createFromAscii("com.sun.star.text.TextRange"); - aRet[1] = OUString::createFromAscii("com.sun.star.style.CharacterProperties"); - aRet[2] = OUString::createFromAscii("com.sun.star.style.CharacterPropertiesAsian"); - aRet[3] = OUString::createFromAscii("com.sun.star.style.CharacterPropertiesComplex"); - aRet[4] = OUString::createFromAscii("com.sun.star.style.ParagraphProperties"); - aRet[5] = OUString::createFromAscii("com.sun.star.style.ParagraphPropertiesAsian"); - aRet[6] = OUString::createFromAscii("com.sun.star.style.ParagraphPropertiesComplex"); - return aRet; + SetPositions(rPam); } -SwXTextRange::SwXTextRange(SwPaM& rPam, - const uno::Reference< XText > & rxParent, enum RangePosition eRange) : - eRangePosition(eRange), - pDoc(rPam.GetDoc()), - pBox(0), - pBoxStartNode(0), - aObjectDepend(this, 0), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - xParentText(rxParent), - pMark(NULL) -{ - _CreateNewBookmark(rPam); -} - -SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt) : - eRangePosition(RANGE_IS_TABLE), - pDoc(rTblFmt.GetDoc()), - pBox(0), - pBoxStartNode(0), - aObjectDepend(this, &rTblFmt), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - pMark(NULL) -{ - SwTable* pTable = SwTable::FindTable( &rTblFmt ); - SwTableNode* pTblNode = pTable->GetTableNode( ); +SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt) + : m_pImpl( + new SwXTextRange::Impl(*rTblFmt.GetDoc(), RANGE_IS_TABLE, &rTblFmt) ) +{ + SwTable *const pTable = SwTable::FindTable( &rTblFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); SwPosition aPosition( *pTblNode ); SwPaM aPam( aPosition ); - _CreateNewBookmark( aPam ); + SetPositions( aPam ); } SwXTextRange::~SwXTextRange() { - vos::OGuard aGuard(Application::GetSolarMutex()); - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(pBkmk) - pDoc->getIDocumentMarkAccess()->deleteMark(pBkmk); } -void SwXTextRange::_CreateNewBookmark(SwPaM& rPam) +const SwDoc * SwXTextRange::GetDoc() const { - IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); + return & m_pImpl->m_rDoc; +} - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(pBkmk) - pMarkAccess->deleteMark(pBkmk); - pMark = pMarkAccess->makeMark(rPam, ::rtl::OUString(), IDocumentMarkAccess::UNO_BOOKMARK); - pMark->Add(this); +SwDoc * SwXTextRange::GetDoc() +{ + return & m_pImpl->m_rDoc; +} + + +void SwXTextRange::Invalidate() +{ + m_pImpl->Invalidate(); +} + +void SwXTextRange::SetPositions(const SwPaM& rPam) +{ + m_pImpl->Invalidate(); + IDocumentMarkAccess* const pMA = m_pImpl->m_rDoc.getIDocumentMarkAccess(); + m_pImpl->m_pMark = pMA->makeMark(rPam, ::rtl::OUString(), + IDocumentMarkAccess::UNO_BOOKMARK); + m_pImpl->m_pMark->Add(m_pImpl.get()); } void SwXTextRange::DeleteAndInsert( - const String& rText, const bool bForceExpandHints) - throw(uno::RuntimeException) + const ::rtl::OUString& rText, const bool bForceExpandHints) +throw (uno::RuntimeException) { - if (RANGE_IS_TABLE == eRangePosition) + if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition) { // setString on table not allowed throw uno::RuntimeException(); } - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(pBkmk) + const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent()); + SwCursor aCursor(aPos, 0, false); + if (GetPositions(aCursor)) { - const SwPosition& rPoint = pBkmk->GetMarkStart(); - SwCursor aNewCrsr(rPoint, 0, false); - if(pBkmk->IsExpanded()) - { - aNewCrsr.SetMark(); - const SwPosition& rMark = pBkmk->GetMarkEnd(); - *aNewCrsr.GetMark() = rMark; - } - UnoActionContext aAction(pDoc); - pDoc->StartUndo(UNDO_INSERT, NULL); - if(aNewCrsr.HasMark()) + UnoActionContext aAction(& m_pImpl->m_rDoc); + m_pImpl->m_rDoc.StartUndo(UNDO_INSERT, NULL); + if (aCursor.HasMark()) { - pDoc->DeleteAndJoin(aNewCrsr); + m_pImpl->m_rDoc.DeleteAndJoin(aCursor); } - if(rText.Len()) + if (rText.getLength()) { SwUnoCursorHelper::DocInsertStringSplitCR( - *pDoc, aNewCrsr, rText, bForceExpandHints); + m_pImpl->m_rDoc, aCursor, rText, bForceExpandHints); - SwXTextCursor::SelectPam(aNewCrsr, sal_True); - aNewCrsr.Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); + SwUnoCursorHelper::SelectPam(aCursor, true); + aCursor.Left(rText.getLength(), CRSR_SKIP_CHARS, FALSE, FALSE); } - _CreateNewBookmark(aNewCrsr); - pDoc->EndUndo(UNDO_INSERT, NULL); + SetPositions(aCursor); + m_pImpl->m_rDoc.EndUndo(UNDO_INSERT, NULL); } } -uno::Reference< XText > SwXTextRange::getText(void) throw( uno::RuntimeException ) +const uno::Sequence< sal_Int8 > & SwXTextRange::getUnoTunnelId() +{ + static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); + return aSeq; +} + +// XUnoTunnel +sal_Int64 SAL_CALL +SwXTextRange::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) +{ + return ::sw::UnoTunnelImpl<SwXTextRange>(rId, this); +} + +OUString SAL_CALL +SwXTextRange::getImplementationName() throw (uno::RuntimeException) +{ + return OUString::createFromAscii("SwXTextRange"); +} + +static char const*const g_ServicesTextRange[] = +{ + "com.sun.star.text.TextRange", + "com.sun.star.style.CharacterProperties", + "com.sun.star.style.CharacterPropertiesAsian", + "com.sun.star.style.CharacterPropertiesComplex", + "com.sun.star.style.ParagraphProperties", + "com.sun.star.style.ParagraphPropertiesAsian", + "com.sun.star.style.ParagraphPropertiesComplex", +}; +static const size_t g_nServicesTextRange( + sizeof(g_ServicesTextRange)/sizeof(g_ServicesTextRange[0])); + +sal_Bool SAL_CALL SwXTextRange::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesTextRange, g_ServicesTextRange, rServiceName); +} + +uno::Sequence< OUString > SAL_CALL +SwXTextRange::getSupportedServiceNames() throw (uno::RuntimeException) +{ + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesTextRange, g_ServicesTextRange); +} + +uno::Reference< text::XText > SAL_CALL +SwXTextRange::getText() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if (!xParentText.is()) + + if (!m_pImpl->m_xParentText.is()) { - if (eRangePosition == RANGE_IS_TABLE && - aObjectDepend.GetRegisteredIn() ) - { - SwFrmFmt* pTblFmt = (SwFrmFmt*)aObjectDepend.GetRegisteredIn(); - SwTable* pTable = SwTable::FindTable( pTblFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); - SwPosition aPosition( *pTblNode ); - uno::Reference< XTextRange > xRange = - SwXTextRange::CreateTextRangeFromPosition(pDoc, aPosition, 0); - xParentText = xRange->getText(); - } - else + if (m_pImpl->m_eRangePosition == RANGE_IS_TABLE && + m_pImpl->m_ObjectDepend.GetRegisteredIn()) { - OSL_ENSURE(false, "SwXTextRange::getText: no text"); + SwFrmFmt const*const pTblFmt = static_cast<SwFrmFmt const*>( + m_pImpl->m_ObjectDepend.GetRegisteredIn()); + SwTable const*const pTable = SwTable::FindTable( pTblFmt ); + SwTableNode const*const pTblNode = pTable->GetTableNode(); + const SwPosition aPosition( *pTblNode ); + m_pImpl->m_xParentText = + ::sw::CreateParentXText(m_pImpl->m_rDoc, aPosition); } } - return xParentText; + OSL_ENSURE(m_pImpl->m_xParentText.is(), "SwXTextRange::getText: no text"); + return m_pImpl->m_xParentText; } -uno::Reference< XTextRange > SwXTextRange::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextRange::getStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > xRet; - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(!xParentText.is()) + uno::Reference< text::XTextRange > xRet; + ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark(); + if (!m_pImpl->m_xParentText.is()) + { getText(); + } if(pBkmk) { SwPaM aPam(pBkmk->GetMarkStart()); - xRet = new SwXTextRange(aPam, xParentText); + xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText); } - else if(eRangePosition == RANGE_IS_TABLE) + else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition) { - //start and end are this, if its a table + // start and end are this, if its a table xRet = this; } else + { throw uno::RuntimeException(); + } return xRet; } -uno::Reference< XTextRange > SwXTextRange::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextRange::getEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > xRet; - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(!xParentText.is()) + + uno::Reference< text::XTextRange > xRet; + ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark(); + if (!m_pImpl->m_xParentText.is()) + { getText(); + } if(pBkmk) { SwPaM aPam(pBkmk->GetMarkEnd()); - xRet = new SwXTextRange(aPam, xParentText); + xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText); } - else if(eRangePosition == RANGE_IS_TABLE) + else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition) { - //start and end are this, if its a table + // start and end are this, if its a table xRet = this; } else + { throw uno::RuntimeException(); + } return xRet; } -OUString SwXTextRange::getString(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXTextRange::getString() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + OUString sRet; - ::sw::mark::IMark const * const pBkmk = GetBookmark(); // for tables there is no bookmark, thus also no text // one could export the table as ASCII here maybe? - if(pBkmk && pBkmk->IsExpanded()) + SwPaM aPaM(GetDoc()->GetNodes()); + if (GetPositions(aPaM) && aPaM.HasMark()) { - const SwPosition& rPoint = pBkmk->GetMarkPos(); - const SwPosition& rMark = pBkmk->GetOtherMarkPos(); - SwPaM aCrsr(rMark, rPoint); - SwXTextCursor::getTextFromPam(aCrsr, sRet); + SwUnoCursorHelper::GetTextFromPam(aPaM, sRet); } return sRet; } -void SwXTextRange::setString(const OUString& aString) - throw( uno::RuntimeException ) +void SAL_CALL SwXTextRange::setString(const OUString& rString) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - DeleteAndInsert(aString, false); -} -void SwXTextRange::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - sal_Bool bAlreadyRegisterred = 0 != GetRegisteredIn(); - ClientModify(this, pOld, pNew); - if(aObjectDepend.GetRegisteredIn()) - { - ClientModify(&aObjectDepend, pOld, pNew); - // if the depend was removed then the range must be removed too - if(!aObjectDepend.GetRegisteredIn() && GetRegisteredIn()) - ((SwModify*)GetRegisteredIn())->Remove(this); - // or if the range has been removed but the depend ist still - // connected then the depend must be removed - else if(bAlreadyRegisterred && !GetRegisteredIn() && - aObjectDepend.GetRegisteredIn()) - ((SwModify*)aObjectDepend.GetRegisteredIn())->Remove(&aObjectDepend); - } - if(!GetRegisteredIn()) - pMark = NULL; + DeleteAndInsert(rString, false); } -sal_Bool SwXTextRange::GetPositions(SwPaM& rToFill) const +bool SwXTextRange::GetPositions(SwPaM& rToFill) const { - sal_Bool bRet = sal_False; - ::sw::mark::IMark const * const pBkmk = GetBookmark(); + ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark(); if(pBkmk) { *rToFill.GetPoint() = pBkmk->GetMarkPos(); @@ -1386,16 +1105,20 @@ sal_Bool SwXTextRange::GetPositions(SwPaM& rToFill) const *rToFill.GetMark() = pBkmk->GetOtherMarkPos(); } else + { rToFill.DeleteMark(); - bRet = sal_True; + } + return true; } - return bRet; + return false; } -sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, - const uno::Reference< XTextRange > & xTextRange) +namespace sw { + +bool XTextRangeToSwPaM( SwUnoInternalPaM & rToFill, + const uno::Reference< text::XTextRange > & xTextRange) { - sal_Bool bRet = sal_False; + bool bRet = false; uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; @@ -1405,27 +1128,27 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, SwXParagraph* pPara = 0; if(xRangeTunnel.is()) { - 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()) )); - pPortion = reinterpret_cast< SwXTextPortion * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextPortion::getUnoTunnelId()) )); - pText = reinterpret_cast< SwXText * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXText::getUnoTunnelId()) )); - pPara = reinterpret_cast< SwXParagraph * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXParagraph::getUnoTunnelId()) )); + pRange = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel); + pPortion= + ::sw::UnoTunnelGetImplementation<SwXTextPortion>(xRangeTunnel); + pText = ::sw::UnoTunnelGetImplementation<SwXText>(xRangeTunnel); + pPara = ::sw::UnoTunnelGetImplementation<SwXParagraph>(xRangeTunnel); } - //if it's a text cursor then create a temporary cursor there and re-use the pCursor variable - uno::Reference< XTextCursor > xTextCursor; - if(pText) + // if it's a text then create a temporary cursor there and re-use + // the pCursor variable + // #i108489#: Reference in outside scope to keep cursor alive + uno::Reference< text::XTextCursor > xTextCursor; + if (pText) { - xTextCursor = pText->createCursor(); + xTextCursor.set( pText->CreateCursor() ); xTextCursor->gotoEnd(sal_True); - uno::Reference<XUnoTunnel> xCrsrTunnel( xTextCursor, UNO_QUERY); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + const uno::Reference<lang::XUnoTunnel> xCrsrTunnel( + xTextCursor, uno::UNO_QUERY); + pCursor = + ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xCrsrTunnel); } if(pRange && pRange->GetDoc() == rToFill.GetDoc()) { @@ -1435,15 +1158,7 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, { if (pPara) { - const SwTxtNode * pTxtNode( pPara->GetTxtNode() ); - - if (pTxtNode) { - bRet = sal_True; - *rToFill.GetPoint() = SwPosition( *pTxtNode ); - // set selection to the whole paragraph - rToFill.SetMark(); - rToFill.GetMark()->nContent = pTxtNode->GetTxt().Len(); - } + bRet = pPara->SelectPaM(rToFill); } else { @@ -1453,8 +1168,9 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, : ((pPortion) ? pPortion->GetCursor() : 0); if (pUnoCrsr && pDoc == rToFill.GetDoc()) { - DBG_ASSERT((SwPaM*)pUnoCrsr->GetNext() == pUnoCrsr, "was machen wir mit Ringen?" ); - bRet = sal_True; + DBG_ASSERT((SwPaM*)pUnoCrsr->GetNext() == pUnoCrsr, + "what to do about rings?"); + bRet = true; *rToFill.GetPoint() = *pUnoCrsr->GetPoint(); if (pUnoCrsr->HasMark()) { @@ -1469,53 +1185,65 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, return bRet; } -sal_Bool lcl_IsStartNodeInFormat(sal_Bool bHeader, SwStartNode* pSttNode, - const SwFrmFmt* pFrmFmt, SwFrmFmt*& rpFormat) +static bool +lcl_IsStartNodeInFormat(const bool bHeader, SwStartNode *const pSttNode, + SwFrmFmt const*const pFrmFmt, SwFrmFmt*& rpFormat) { - sal_Bool bRet = sal_False; + bool bRet = false; const SfxItemSet& rSet = pFrmFmt->GetAttrSet(); const SfxPoolItem* pItem; - SwFrmFmt* pHeadFootFmt; - if(SFX_ITEM_SET == rSet.GetItemState( static_cast< USHORT >(bHeader ? RES_HEADER : RES_FOOTER), sal_True, &pItem) && - 0 != (pHeadFootFmt = bHeader ? - ((SwFmtHeader*)pItem)->GetHeaderFmt() : - ((SwFmtFooter*)pItem)->GetFooterFmt())) - { - const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); - const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); - const SwStartNode* pCurSttNode = rNode.FindSttNodeByType( - bHeader ? SwHeaderStartNode : SwFooterStartNode); - if(pCurSttNode && pCurSttNode == pSttNode) + if (SFX_ITEM_SET == rSet.GetItemState( + static_cast<USHORT>(bHeader ? RES_HEADER : RES_FOOTER), + sal_True, &pItem)) + { + SfxPoolItem *const pItemNonConst(const_cast<SfxPoolItem *>(pItem)); + SwFrmFmt *const pHeadFootFmt = (bHeader) ? + static_cast<SwFmtHeader*>(pItemNonConst)->GetHeaderFmt() : + static_cast<SwFmtFooter*>(pItemNonConst)->GetFooterFmt(); + if (pHeadFootFmt) { - bRet = sal_True; - rpFormat = pHeadFootFmt; + const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); + const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); + SwStartNode const*const pCurSttNode = rNode.FindSttNodeByType( + (bHeader) ? SwHeaderStartNode : SwFooterStartNode); + if (pCurSttNode && (pCurSttNode == pSttNode)) + { + rpFormat = pHeadFootFmt; + bRet = true; + } } } return bRet; } -uno::Reference< XTextRange > SwXTextRange::CreateTextRangeFromPosition( - SwDoc* pDoc, const SwPosition& rPos, const SwPosition* pMark) +} // namespace sw + +uno::Reference< text::XTextRange > +SwXTextRange::CreateXTextRange( + SwDoc & rDoc, const SwPosition& rPos, const SwPosition *const pMark) { - uno::Reference< XText > xParentText( CreateParentXText(pDoc, rPos) ); - std::auto_ptr<SwUnoCrsr> pNewCrsr( pDoc->CreateUnoCrsr(rPos, sal_False) ); + const uno::Reference<text::XText> xParentText( + ::sw::CreateParentXText(rDoc, rPos)); + const ::std::auto_ptr<SwUnoCrsr> pNewCrsr( + rDoc.CreateUnoCrsr(rPos, sal_False)); if(pMark) { pNewCrsr->SetMark(); *pNewCrsr->GetMark() = *pMark; } - bool isCell( dynamic_cast<SwXCell*>(xParentText.get()) ); - uno::Reference< XTextRange > xRet( + const bool isCell( dynamic_cast<SwXCell*>(xParentText.get()) ); + const uno::Reference< text::XTextRange > xRet( new SwXTextRange(*pNewCrsr, xParentText, isCell ? RANGE_IN_CELL : RANGE_IN_TEXT) ); return xRet; - } -uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, - const SwPosition& rPos) +namespace sw { + +uno::Reference< text::XText > +CreateParentXText(SwDoc & rDoc, const SwPosition& rPos) { - uno::Reference< XText > xParentText; + uno::Reference< text::XText > xParentText; SwStartNode* pSttNode = rPos.nNode.GetNode().StartOfSectionNode(); while(pSttNode && pSttNode->IsSectionNode()) { @@ -1526,18 +1254,19 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, { case SwTableBoxStartNode: { - const SwTableNode* pTblNode = pSttNode->FindTableNode(); - SwFrmFmt* pTableFmt = (SwFrmFmt*)pTblNode->GetTable().GetFrmFmt(); - SwTableBox* pBox = pSttNode->GetTblBox(); + SwTableNode const*const pTblNode = pSttNode->FindTableNode(); + SwFrmFmt *const pTableFmt = + static_cast<SwFrmFmt*>(pTblNode->GetTable().GetFrmFmt()); + SwTableBox *const pBox = pSttNode->GetTblBox(); - xParentText = pBox + xParentText = (pBox) ? SwXCell::CreateXCell( pTableFmt, pBox ) : new SwXCell( pTableFmt, *pSttNode ); } break; case SwFlyStartNode: { - SwFrmFmt* pFmt = pSttNode->GetFlyFmt(); + SwFrmFmt *const pFmt = pSttNode->GetFlyFmt(); if (0 != pFmt) { SwXTextFrame* pFrame( static_cast<SwXTextFrame*>( @@ -1549,42 +1278,44 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, case SwHeaderStartNode: case SwFooterStartNode: { - sal_Bool bHeader = SwHeaderStartNode == eType; - sal_uInt16 nPDescCount = pDoc->GetPageDescCnt(); + const bool bHeader = (SwHeaderStartNode == eType); + const sal_uInt16 nPDescCount = rDoc.GetPageDescCnt(); for(sal_uInt16 i = 0; i < nPDescCount; i++) { - const SwPageDesc& rDesc = const_cast<const SwDoc*>(pDoc) - ->GetPageDesc( i ); + const SwPageDesc& rDesc = + // C++ is retarded + const_cast<SwDoc const&>(rDoc).GetPageDesc( i ); const SwFrmFmt* pFrmFmtMaster = &rDesc.GetMaster(); const SwFrmFmt* pFrmFmtLeft = &rDesc.GetLeft(); SwFrmFmt* pHeadFootFmt = 0; - if(!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrmFmtMaster, pHeadFootFmt)) - lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrmFmtLeft, pHeadFootFmt); + if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrmFmtMaster, + pHeadFootFmt)) + { + lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrmFmtLeft, + pHeadFootFmt); + } - if(pHeadFootFmt) + if (pHeadFootFmt) { - SwXHeadFootText* pxHdFt = (SwXHeadFootText*)SwClientIter( *pHeadFootFmt ). - First( TYPE( SwXHeadFootText )); - xParentText = pxHdFt; - if(!pxHdFt) - xParentText = new SwXHeadFootText(*pHeadFootFmt, bHeader); - break; + xParentText = SwXHeadFootText::CreateXHeadFootText( + *pHeadFootFmt, bHeader); } } } break; case SwFootnoteStartNode: { - sal_uInt16 n, nFtnCnt = pDoc->GetFtnIdxs().Count(); - uno::Reference< XFootnote > xRef; - for( n = 0; n < nFtnCnt; ++n ) + const sal_uInt16 nFtnCnt = rDoc.GetFtnIdxs().Count(); + uno::Reference< text::XFootnote > xRef; + for (sal_uInt16 n = 0; n < nFtnCnt; ++n ) { - const SwTxtFtn* pTxtFtn = pDoc->GetFtnIdxs()[ n ]; + const SwTxtFtn* pTxtFtn = rDoc.GetFtnIdxs()[ n ]; const SwFmtFtn& rFtn = pTxtFtn->GetFtn(); pTxtFtn = rFtn.GetTxtFtn(); #if OSL_DEBUG_LEVEL > 1 - const SwStartNode* pTmpSttNode = pTxtFtn->GetStartNode()->GetNode(). + const SwStartNode* pTmpSttNode = + pTxtFtn->GetStartNode()->GetNode(). FindSttNodeByType(SwFootnoteStartNode); (void)pTmpSttNode; #endif @@ -1592,12 +1323,7 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, if (pSttNode == pTxtFtn->GetStartNode()->GetNode(). FindSttNodeByType(SwFootnoteStartNode)) { - xParentText = ((SwUnoCallBack*)pDoc->GetUnoCallBack())-> - GetFootnote(rFtn); - if (!xParentText.is()) - { - xParentText = new SwXFootnote(pDoc, rFtn); - } + xParentText = SwXFootnote::CreateXFootnote(rDoc, rFtn); break; } } @@ -1606,9 +1332,9 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, default: { // then it is the body text - uno::Reference<frame::XModel> xModel = - pDoc->GetDocShell()->GetBaseModel(); - uno::Reference< XTextDocument > xDoc( + const uno::Reference<frame::XModel> xModel = + rDoc.GetDocShell()->GetBaseModel(); + const uno::Reference< text::XTextDocument > xDoc( xModel, uno::UNO_QUERY); xParentText = xDoc->getText(); } @@ -1617,181 +1343,250 @@ uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, return xParentText; } -uno::Reference< XEnumeration > SAL_CALL SwXTextRange::createContentEnumeration( - const OUString& rServiceName) - throw(RuntimeException) +} // namespace sw + +uno::Reference< container::XEnumeration > SAL_CALL +SwXTextRange::createContentEnumeration(const OUString& rServiceName) +throw (uno::RuntimeException) { - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if( !pBkmk || COMPARE_EQUAL != rServiceName.compareToAscii("com.sun.star.text.TextContent") ) - throw RuntimeException(); + vos::OGuard g(Application::GetSolarMutex()); - const SwPosition& rPoint = pBkmk->GetMarkPos(); - SwUnoCrsr* pNewCrsr = pDoc->CreateUnoCrsr(rPoint, FALSE); - if(pBkmk->IsExpanded() && pBkmk->GetOtherMarkPos() != rPoint) + if (!rServiceName.equalsAscii("com.sun.star.text.TextContent")) { - pNewCrsr->SetMark(); - *pNewCrsr->GetMark() = pBkmk->GetOtherMarkPos(); + throw uno::RuntimeException(); + } + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent()); + const ::std::auto_ptr<SwUnoCrsr> pNewCrsr( + m_pImpl->m_rDoc.CreateUnoCrsr(aPos, FALSE)); + if (!GetPositions(*pNewCrsr)) + { + throw uno::RuntimeException(); } - uno::Reference< XEnumeration > xRet = new SwXParaFrameEnumeration(*pNewCrsr, PARAFRAME_PORTION_TEXTRANGE); - delete pNewCrsr; + + const uno::Reference< container::XEnumeration > xRet = + new SwXParaFrameEnumeration(*pNewCrsr, PARAFRAME_PORTION_TEXTRANGE); return xRet; } -uno::Reference< XEnumeration > SwXTextRange::createEnumeration(void) throw( RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXTextRange::createEnumeration() throw (uno::RuntimeException) { - ::sw::mark::IMark const * const pBkmk = GetBookmark(); - if(!pBkmk) throw RuntimeException(); - const SwPosition& rPoint = pBkmk->GetMarkPos(); - SwUnoCrsr* pNewCrsr = pDoc->CreateUnoCrsr(rPoint, FALSE); - if(pBkmk->IsExpanded() && pBkmk->GetOtherMarkPos() != rPoint) + vos::OGuard g(Application::GetSolarMutex()); + + if (!GetDoc() || !m_pImpl->GetBookmark()) { - pNewCrsr->SetMark(); - *pNewCrsr->GetMark() = pBkmk->GetOtherMarkPos(); + throw uno::RuntimeException(); + } + const SwPosition aPos(GetDoc()->GetNodes().GetEndOfContent()); + ::std::auto_ptr<SwUnoCrsr> pNewCrsr( + m_pImpl->m_rDoc.CreateUnoCrsr(aPos, FALSE)); + if (!GetPositions(*pNewCrsr)) + { + throw uno::RuntimeException(); } - uno::Reference<XUnoTunnel> xTunnel(xParentText, UNO_QUERY); - SwXText* pParentText = 0; - if(xTunnel.is()) + if (!m_pImpl->m_xParentText.is()) { - pParentText = reinterpret_cast< SwXText * >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXText::getUnoTunnelId()) )); + getText(); } - DBG_ASSERT(pParentText, "parent is not a SwXText"); - CursorType eSetType = RANGE_IN_CELL == eRangePosition ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - uno::Reference< XEnumeration > xRet = - new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); + + const CursorType eSetType = (RANGE_IN_CELL == m_pImpl->m_eRangePosition) + ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; + const uno::Reference< container::XEnumeration > xRet = + new SwXParagraphEnumeration(m_pImpl->m_xParentText, pNewCrsr, eSetType); return xRet; } -uno::Type SwXTextRange::getElementType(void) throw( RuntimeException ) +uno::Type SAL_CALL SwXTextRange::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference<XTextRange>*)0); + return text::XTextRange::static_type(); } -sal_Bool SwXTextRange::hasElements(void) throw( RuntimeException ) +sal_Bool SAL_CALL SwXTextRange::hasElements() throw (uno::RuntimeException) { return sal_True; } -Sequence< OUString > SAL_CALL SwXTextRange::getAvailableServiceNames(void) throw( RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXTextRange::getAvailableServiceNames() throw (uno::RuntimeException) { - Sequence< OUString > aRet(1); + uno::Sequence< OUString > aRet(1); OUString* pArray = aRet.getArray(); pArray[0] = OUString::createFromAscii("com.sun.star.text.TextContent"); return aRet; } -uno::Reference< XPropertySetInfo > SAL_CALL SwXTextRange::getPropertySetInfo( ) throw(RuntimeException) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXTextRange::getPropertySetInfo() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - static uno::Reference< XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo(); + + static uno::Reference< beans::XPropertySetInfo > xRef = + m_pImpl->m_rPropSet.getPropertySetInfo(); return xRef; } -void SAL_CALL SwXTextRange::setPropertyValue( - const OUString& rPropertyName, const Any& rValue ) - throw(UnknownPropertyException, PropertyVetoException, - IllegalArgumentException, WrappedTargetException, RuntimeException) +void SAL_CALL +SwXTextRange::setPropertyValue( + const OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } SwPaM aPaM(GetDoc()->GetNodes()); - SwXTextRange::GetPositions(aPaM); - SwXTextCursor::SetPropertyValue(aPaM, *m_pPropSet, rPropertyName, rValue); + GetPositions(aPaM); + SwUnoCursorHelper::SetPropertyValue(aPaM, m_pImpl->m_rPropSet, + rPropertyName, rValue); } -Any SAL_CALL SwXTextRange::getPropertyValue( const OUString& rPropertyName ) - throw(UnknownPropertyException, WrappedTargetException, RuntimeException) +uno::Any SAL_CALL +SwXTextRange::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - return SwXTextCursor::GetPropertyValue(aPaM, *m_pPropSet, rPropertyName); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + return SwUnoCursorHelper::GetPropertyValue(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -void SAL_CALL SwXTextRange::addPropertyChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextRange::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, + "SwXTextRange::addPropertyChangeListener(): not implemented"); } -void SAL_CALL SwXTextRange::removePropertyChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextRange::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, + "SwXTextRange::removePropertyChangeListener(): not implemented"); } -void SAL_CALL SwXTextRange::addVetoableChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextRange::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, + "SwXTextRange::addVetoableChangeListener(): not implemented"); } -void SAL_CALL SwXTextRange::removeVetoableChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL +SwXTextRange::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextRange::removeVetoableChangeListener(): not implemented"); } -PropertyState SAL_CALL SwXTextRange::getPropertyState( const OUString& rPropertyName ) - throw(UnknownPropertyException, RuntimeException) +beans::PropertyState SAL_CALL +SwXTextRange::getPropertyState(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - return SwXTextCursor::GetPropertyState(aPaM, *m_pPropSet, rPropertyName); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + return SwUnoCursorHelper::GetPropertyState(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -Sequence< PropertyState > SAL_CALL SwXTextRange::getPropertyStates( - const Sequence< OUString >& rPropertyName ) throw(UnknownPropertyException, RuntimeException) +uno::Sequence< beans::PropertyState > SAL_CALL +SwXTextRange::getPropertyStates(const uno::Sequence< OUString >& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - return SwXTextCursor::GetPropertyStates(aPaM, *m_pPropSet, rPropertyName); + vos::OGuard g(Application::GetSolarMutex()); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + return SwUnoCursorHelper::GetPropertyStates(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -void SAL_CALL SwXTextRange::setPropertyToDefault( const OUString& rPropertyName ) - throw(UnknownPropertyException, RuntimeException) +void SAL_CALL SwXTextRange::setPropertyToDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - SwXTextCursor::SetPropertyToDefault(aPaM, *m_pPropSet, rPropertyName); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + SwUnoCursorHelper::SetPropertyToDefault(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -Any SAL_CALL SwXTextRange::getPropertyDefault( const OUString& rPropertyName ) - throw(UnknownPropertyException, WrappedTargetException, RuntimeException) +uno::Any SAL_CALL +SwXTextRange::getPropertyDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); - SwXTextRange::GetPositions(aPaM); - return SwXTextCursor::GetPropertyDefault(aPaM, *m_pPropSet, rPropertyName); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); + GetPositions(aPaM); + return SwUnoCursorHelper::GetPropertyDefault(aPaM, m_pImpl->m_rPropSet, + rPropertyName); } -void SwXTextRange::makeRedline( - const ::rtl::OUString& rRedlineType, - const uno::Sequence< beans::PropertyValue >& rRedlineProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) +void SAL_CALL +SwXTextRange::makeRedline( + const ::rtl::OUString& rRedlineType, + const uno::Sequence< beans::PropertyValue >& rRedlineProperties ) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetDoc() || !GetBookmark()) - throw RuntimeException(); - SwPaM aPaM(((SwDoc*)GetDoc())->GetNodes()); + + if (!GetDoc() || !m_pImpl->GetBookmark()) + { + throw uno::RuntimeException(); + } + SwPaM aPaM(GetDoc()->GetNodes()); SwXTextRange::GetPositions(aPaM); SwUnoCursorHelper::makeRedline( aPaM, rRedlineType, rRedlineProperties ); } @@ -1799,6 +1594,96 @@ void SwXTextRange::makeRedline( /****************************************************************** * SwXTextRanges ******************************************************************/ + +class SwXTextRanges::Impl + : public SwClient +{ + +public: + + ::std::vector< uno::Reference< text::XTextRange > > m_Ranges; + + Impl(SwPaM *const pPaM) + : SwClient( (pPaM) + ? pPaM->GetDoc()->CreateUnoCrsr(*pPaM->GetPoint()) + : 0 ) + { + if (pPaM) + { + ::sw::DeepCopyPaM(*pPaM, *GetCursor()); + } + MakeRanges(); + } + + ~Impl() { + // Impl owns the cursor; delete it here: SolarMutex is locked + delete GetRegisteredIn(); + } + + SwUnoCrsr * GetCursor() { + return static_cast<SwUnoCrsr*>( + const_cast<SwModify*>(GetRegisteredIn())); + } + + void MakeRanges(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/*-- 10.12.98 13:57:02--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXTextRanges::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); +} + +/* -----------------10.12.98 14:25------------------- + * + * --------------------------------------------------*/ +void SwXTextRanges::Impl::MakeRanges() +{ + SwUnoCrsr *const pCursor = GetCursor(); + if (pCursor) + { + SwPaM *pTmpCursor = pCursor; + do { + const uno::Reference< text::XTextRange > xRange( + SwXTextRange::CreateXTextRange( + *pTmpCursor->GetDoc(), + *pTmpCursor->GetPoint(), pTmpCursor->GetMark())); + if (xRange.is()) + { + m_Ranges.push_back(xRange); + } + pTmpCursor = static_cast<SwPaM*>(pTmpCursor->GetNext()); + } + while (pTmpCursor != pCursor); + } +} + +const SwUnoCrsr* SwXTextRanges::GetCursor() const +{ + return m_pImpl->GetCursor(); +} + +/*-- 10.12.98 13:57:22--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXTextRanges::SwXTextRanges(SwPaM *const pPaM) + : m_pImpl( new SwXTextRanges::Impl(pPaM) ) +{ +} + +/*-- 10.12.98 13:57:22--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXTextRanges::~SwXTextRanges() +{ +} + /* -----------------------------13.03.00 12:15-------------------------------- ---------------------------------------------------------------------------*/ @@ -1810,210 +1695,121 @@ const uno::Sequence< sal_Int8 > & SwXTextRanges::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXTextRanges::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXTextRanges::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<SwXTextRanges>(rId, this); } + /**************************************************************************** * Text positions * Bis zum ersten Zugriff auf eine TextPosition wird ein SwCursor gehalten, * danach wird ein Array mit uno::Reference< XTextPosition > angelegt * ****************************************************************************/ -SV_IMPL_PTRARR(XTextRangeArr, XTextRangeRefPtr); /* -----------------------------06.04.00 16:36-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXTextRanges::getImplementationName(void) throw( RuntimeException ) +OUString SAL_CALL +SwXTextRanges::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXTextRanges"); } /* -----------------------------06.04.00 16:36-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXTextRanges::supportsService(const OUString& rServiceName) throw( RuntimeException ) +static char const*const g_ServicesTextRanges[] = { - return C2U("com.sun.star.text.TextRanges") == rServiceName; -} -/* -----------------------------06.04.00 16:36-------------------------------- - - ---------------------------------------------------------------------------*/ -Sequence< OUString > SwXTextRanges::getSupportedServiceNames(void) throw( RuntimeException ) -{ - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.TextRanges"); - return aRet; -} -/*-- 10.12.98 13:57:20--------------------------------------------------- + "com.sun.star.text.TextRanges", +}; +static const size_t g_nServicesTextRanges( + sizeof(g_ServicesTextRanges)/sizeof(g_ServicesTextRanges[0])); - -----------------------------------------------------------------------*/ -SwXTextRanges::SwXTextRanges() : - pRangeArr(0) +sal_Bool SAL_CALL SwXTextRanges::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - + return ::sw::SupportsServiceImpl( + g_nServicesTextRanges, g_ServicesTextRanges, rServiceName); } -/*-- 10.12.98 13:57:22--------------------------------------------------- +/* -----------------------------06.04.00 16:36-------------------------------- - -----------------------------------------------------------------------*/ -SwXTextRanges::SwXTextRanges(SwPaM* pCrsr) : - pRangeArr(0) + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXTextRanges::getSupportedServiceNames() throw (uno::RuntimeException) { - SwUnoCrsr* pUnoCrsr = pCrsr->GetDoc()->CreateUnoCrsr(*pCrsr->GetPoint()); - if(pCrsr->HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pCrsr->GetMark(); - } - if(pCrsr->GetNext() != pCrsr) - { - SwPaM *_pStartCrsr = (SwPaM *)pCrsr->GetNext(); - do - { - //neuen PaM erzeugen - SwPaM* pPaM = _pStartCrsr->HasMark() ? - new SwPaM(*_pStartCrsr->GetMark(), *_pStartCrsr->GetPoint()) : - new SwPaM(*_pStartCrsr->GetPoint()); - //und in den Ring einfuegen - pPaM->MoveTo(pUnoCrsr); - - } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != pCrsr ); - } - - pUnoCrsr->Add(this); + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesTextRanges, g_ServicesTextRanges); } -/*-- 10.12.98 13:57:22--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXTextRanges::~SwXTextRanges() -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pCrsr = GetCrsr(); - delete pCrsr; - if(pRangeArr) - { - pRangeArr->DeleteAndDestroy(0, pRangeArr->Count()); - delete pRangeArr; - } -} /*-- 10.12.98 13:57:24--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int32 SwXTextRanges::getCount(void) throw( uno::RuntimeException ) +sal_Int32 SAL_CALL SwXTextRanges::getCount() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - sal_Int32 nRet = 0; - SwUnoCrsr* pCrsr = GetCrsr(); - if(pCrsr) - { - SwPaM *pTmpCrsr = pCrsr; - do { - nRet++; - pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); - } while ( pTmpCrsr != pCrsr ); - } - else if(pRangeArr) - nRet = pRangeArr->Count(); - return nRet; + + return static_cast<sal_Int32>(m_pImpl->m_Ranges.size()); } /*-- 10.12.98 13:57:25--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXTextRanges::getByIndex(sal_Int32 nIndex) - throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL SwXTextRanges::getByIndex(sal_Int32 nIndex) +throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< XTextRange > aRef; - XTextRangeArr* pArr = ((SwXTextRanges*)this)->GetRangesArray(); - if(pArr && 0 <= nIndex && nIndex < pArr->Count()) + + if ((nIndex < 0) || + (static_cast<size_t>(nIndex) >= m_pImpl->m_Ranges.size())) { - XTextRangeRefPtr pRef = pArr->GetObject( USHORT( nIndex )); - aRef = *pRef; - } - else throw lang::IndexOutOfBoundsException(); - uno::Any aRet(&aRef, ::getCppuType((uno::Reference<XTextRange>*)0)); - return aRet; + } + uno::Any ret; + ret <<= (m_pImpl->m_Ranges.at(nIndex)); + return ret; } + /*-- 10.12.98 13:57:25--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXTextRanges::getElementType(void) throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXTextRanges::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference<XTextRange>*)0); + return text::XTextRange::static_type(); } /*-- 10.12.98 13:57:26--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextRanges::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextRanges::hasElements() throw (uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); + // no mutex necessary: getCount() does locking return getCount() > 0; } -/* -----------------10.12.98 14:25------------------- - * - * --------------------------------------------------*/ -XTextRangeArr* SwXTextRanges::GetRangesArray() -{ - SwUnoCrsr* pCrsr = GetCrsr(); - if(!pRangeArr && pCrsr) - { - pRangeArr = new XTextRangeArr(); - SwPaM *pTmpCrsr = pCrsr; - do { - - uno::Reference< XTextRange >* pPtr = - new uno::Reference<XTextRange>( - SwXTextRange::CreateTextRangeFromPosition( - pTmpCrsr->GetDoc(), - *pTmpCrsr->GetPoint(), pTmpCrsr->GetMark())); -// new uno::Reference<XTextRange>( SwXTextRange::createTextRangeFromPaM(*pTmpCrsr, xParentText)); - if(pPtr->is()) - pRangeArr->Insert(pPtr, pRangeArr->Count()); - - pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); - } while ( pTmpCrsr != pCrsr ); - pCrsr->Remove( this ); - } - return pRangeArr; -} -/*-- 10.12.98 13:57:02--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXTextRanges::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); -} /* -----------------11.12.98 10:07------------------- * * --------------------------------------------------*/ -void SwXTextCursor::SetString(SwCursor& rCrsr, const OUString& rString) +void SwUnoCursorHelper::SetString(SwCursor & rCursor, const OUString& rString) { // Start/EndAction - SwDoc* pDoc = rCrsr.GetDoc(); + SwDoc *const pDoc = rCursor.GetDoc(); UnoActionContext aAction(pDoc); - String aText(rString); - xub_StrLen nTxtLen = aText.Len(); pDoc->StartUndo(UNDO_INSERT, NULL); - if(rCrsr.HasMark()) - pDoc->DeleteAndJoin(rCrsr); - if(nTxtLen) + if (rCursor.HasMark()) { + pDoc->DeleteAndJoin(rCursor); + } + if (rString.getLength()) + { + String aText(rString); const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR( - *pDoc, rCrsr, aText, false ) ); + *pDoc, rCursor, aText, false ) ); DBG_ASSERT( bSuccess, "DocInsertStringSplitCR" ); (void) bSuccess; - SwXTextCursor::SelectPam(rCrsr, sal_True); - rCrsr.Left(nTxtLen, CRSR_SKIP_CHARS, FALSE, FALSE); + SwUnoCursorHelper::SelectPam(rCursor, true); + rCursor.Left(rString.getLength(), CRSR_SKIP_CHARS, FALSE, FALSE); } pDoc->EndUndo(UNDO_INSERT, NULL); } @@ -2022,6 +1818,68 @@ void SwXTextCursor::SetString(SwCursor& rCrsr, const OUString& rString) * SwXParaFrameEnumeration ******************************************************************/ +class SwXParaFrameEnumeration::Impl + : public SwClient +{ + +public: + + // created by hasMoreElements + uno::Reference< text::XTextContent > m_xNextObject; + FrameDependList_t m_Frames; + + Impl(SwPaM const & rPaM) + : SwClient(rPaM.GetDoc()->CreateUnoCrsr(*rPaM.GetPoint(), sal_False)) + { + if (rPaM.HasMark()) + { + GetCursor()->SetMark(); + *GetCursor()->GetMark() = *rPaM.GetMark(); + } + } + + ~Impl() { + // Impl owns the cursor; delete it here: SolarMutex is locked + delete GetRegisteredIn(); + } + + SwUnoCrsr * GetCursor() { + return static_cast<SwUnoCrsr*>( + const_cast<SwModify*>(GetRegisteredIn())); + } + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/*-- 23.03.99 13:22:37--------------------------------------------------- + + -----------------------------------------------------------------------*/ + +struct InvalidFrameDepend { + bool operator() (::boost::shared_ptr<SwDepend> const & rEntry) + { return !rEntry->GetRegisteredIn(); } +}; + +void SwXParaFrameEnumeration::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); + if(!GetRegisteredIn()) + { + m_Frames.clear(); + m_xNextObject = 0; + } + else + { + // check if any frame went away... + FrameDependList_t::iterator const iter = + ::std::remove_if(m_Frames.begin(), m_Frames.end(), + InvalidFrameDepend()); + m_Frames.erase(iter, m_Frames.end()); + } +} + /* -----------------23.03.99 13:38------------------- * * --------------------------------------------------*/ @@ -2033,7 +1891,7 @@ lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr, if (!i_rFrames.size()) return sal_False; - SwFrmFmt* pFormat = static_cast<SwFrmFmt*>(const_cast<SwModify*>( + SwFrmFmt *const pFormat = static_cast<SwFrmFmt*>(const_cast<SwModify*>( i_rFrames.front()->GetRegisteredIn())); i_rFrames.pop_front(); // the format should be valid here, otherwise the client @@ -2054,7 +1912,7 @@ lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr, { const SwNodeIndex* pIdx = pFormat->GetCntnt().GetCntntIdx(); DBG_ASSERT(pIdx, "where is the index?"); - const SwNode* pNd = + SwNode const*const pNd = i_rUnoCrsr.GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ]; const FlyCntType eType = (!pNd->IsNoTxtNode()) ? FLYCNTTYPE_FRM @@ -2073,11 +1931,12 @@ lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr, and fill the frame into the array ---------------------------------------------------------------------------*/ static void -lcl_FillFrame(SwXParaFrameEnumeration & rEnum, SwUnoCrsr& rUnoCrsr, +lcl_FillFrame(SwClient & rEnum, SwUnoCrsr& rUnoCrsr, FrameDependList_t & rFrames) { // search for objects at the cursor - anchored at/as char - const SwTxtAttr * pTxtAttr = rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttr( + SwTxtAttr const*const pTxtAttr = + rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttr( rUnoCrsr.GetPoint()->nContent, RES_TXTATR_FLYCNT); if (pTxtAttr) { @@ -2088,93 +1947,64 @@ lcl_FillFrame(SwXParaFrameEnumeration & rEnum, SwUnoCrsr& rUnoCrsr, } } -/* -----------------------------06.04.00 16:39-------------------------------- - - ---------------------------------------------------------------------------*/ -OUString SwXParaFrameEnumeration::getImplementationName() -throw( RuntimeException ) -{ - return C2U("SwXParaFrameEnumeration"); -} -/* -----------------------------06.04.00 16:39-------------------------------- - - ---------------------------------------------------------------------------*/ -sal_Bool SwXParaFrameEnumeration::supportsService(const OUString& rServiceName) -throw( RuntimeException ) -{ - return C2U("com.sun.star.util.ContentEnumeration") == rServiceName; -} -/* -----------------------------06.04.00 16:39-------------------------------- - - ---------------------------------------------------------------------------*/ -Sequence< OUString > SwXParaFrameEnumeration::getSupportedServiceNames() -throw( RuntimeException ) -{ - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.util.ContentEnumeration"); - return aRet; -} /*-- 23.03.99 13:22:29--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, - sal_uInt8 nParaFrameMode, - SwFrmFmt* pFmt) +SwXParaFrameEnumeration::SwXParaFrameEnumeration( + const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode, + SwFrmFmt *const pFmt) + : m_pImpl( new SwXParaFrameEnumeration::Impl(rPaM) ) { - SwDoc* pDoc = rPaM.GetDoc(); - SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(*rPaM.GetPoint(), sal_False); - if (rPaM.HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *rPaM.GetMark(); - } - pUnoCrsr->Add(this); - - if (PARAFRAME_PORTION_PARAGRAPH == nParaFrameMode) + if (PARAFRAME_PORTION_PARAGRAPH == eParaFrameMode) { FrameDependSortList_t frames; - ::CollectFrameAtNode( *this, rPaM.GetPoint()->nNode, frames, false ); + ::CollectFrameAtNode(*m_pImpl.get(), rPaM.GetPoint()->nNode, + frames, false); ::std::transform(frames.begin(), frames.end(), - ::std::back_inserter(m_Frames), + ::std::back_inserter(m_pImpl->m_Frames), ::boost::bind(&FrameDependSortListEntry::pFrameDepend, _1)); } else if (pFmt) { - //jetzt einen SwDepend anlegen und in das Array einfuegen - SwDepend* pNewDepend = new SwDepend(this, pFmt); - m_Frames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) ); + // create SwDepend for frame and insert into array + SwDepend *const pNewDepend = new SwDepend(m_pImpl.get(), pFmt); + m_pImpl->m_Frames.push_back(::boost::shared_ptr<SwDepend>(pNewDepend)); } - else if((PARAFRAME_PORTION_CHAR == nParaFrameMode) || - (PARAFRAME_PORTION_TEXTRANGE == nParaFrameMode)) + else if ((PARAFRAME_PORTION_CHAR == eParaFrameMode) || + (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode)) { - if(PARAFRAME_PORTION_TEXTRANGE == nParaFrameMode) + if (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode) { SwPosFlyFrms aFlyFrms; //get all frames that are bound at paragraph or at character - pDoc->GetAllFlyFmts(aFlyFrms, pUnoCrsr);//, bDraw); + rPaM.GetDoc()->GetAllFlyFmts(aFlyFrms, m_pImpl->GetCursor()); for(USHORT i = 0; i < aFlyFrms.Count(); i++) { SwPosFlyFrm* pPosFly = aFlyFrms[i]; - SwFrmFmt* pFrmFmt = (SwFrmFmt*)&pPosFly->GetFmt(); - //jetzt einen SwDepend anlegen und in das Array einfuegen - SwDepend* pNewDepend = new SwDepend(this, pFrmFmt); - m_Frames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) ); + SwFrmFmt *const pFrmFmt = + const_cast<SwFrmFmt*>(&pPosFly->GetFmt()); + // create SwDepend for frame and insert into array + SwDepend *const pNewDepend = + new SwDepend(m_pImpl.get(), pFrmFmt); + m_pImpl->m_Frames.push_back( + ::boost::shared_ptr<SwDepend>(pNewDepend) ); } //created from any text range - if(pUnoCrsr->HasMark()) + if (m_pImpl->GetCursor()->HasMark()) { - if(pUnoCrsr->Start() != pUnoCrsr->GetPoint()) - pUnoCrsr->Exchange(); + m_pImpl->GetCursor()->Normalize(); do { - lcl_FillFrame(*this, *pUnoCrsr, m_Frames); - pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); + lcl_FillFrame(*m_pImpl.get(), *m_pImpl->GetCursor(), + m_pImpl->m_Frames); + m_pImpl->GetCursor()->Right( + 1, CRSR_SKIP_CHARS, FALSE, FALSE); } - while(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()); + while (*m_pImpl->GetCursor()->GetPoint() < + *m_pImpl->GetCursor()->GetMark()); } } - lcl_FillFrame(*this, *pUnoCrsr, m_Frames); + lcl_FillFrame(*m_pImpl.get(), *m_pImpl->GetCursor(), m_pImpl->m_Frames); } } /*-- 23.03.99 13:22:30--------------------------------------------------- @@ -2182,98 +2012,88 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, -----------------------------------------------------------------------*/ SwXParaFrameEnumeration::~SwXParaFrameEnumeration() { - vos::OGuard aGuard(Application::GetSolarMutex()); - - SwUnoCrsr* pUnoCrsr = GetCursor(); - delete pUnoCrsr; } /*-- 23.03.99 13:22:32--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXParaFrameEnumeration::hasMoreElements() -throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXParaFrameEnumeration::hasMoreElements() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if (!GetCursor()) + if (!m_pImpl->GetCursor()) throw uno::RuntimeException(); - return m_xNextObject.is() ? sal_True : - lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames); + return (m_pImpl->m_xNextObject.is()) + ? sal_True + : lcl_CreateNextObject(*m_pImpl->GetCursor(), + m_pImpl->m_xNextObject, m_pImpl->m_Frames); } /*-- 23.03.99 13:22:33--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParaFrameEnumeration::nextElement() - throw( container::NoSuchElementException, - lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL SwXParaFrameEnumeration::nextElement() +throw (container::NoSuchElementException, + lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if (!GetCursor()) + if (!m_pImpl->GetCursor()) + { throw uno::RuntimeException(); + } - if (!m_xNextObject.is() && m_Frames.size()) + if (!m_pImpl->m_xNextObject.is() && m_pImpl->m_Frames.size()) { - lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames); + lcl_CreateNextObject(*m_pImpl->GetCursor(), + m_pImpl->m_xNextObject, m_pImpl->m_Frames); } - if(!m_xNextObject.is()) + if (!m_pImpl->m_xNextObject.is()) + { throw container::NoSuchElementException(); - uno::Any aRet(&m_xNextObject, - ::getCppuType((uno::Reference<XTextContent>*)0)); - m_xNextObject = 0; + } + uno::Any aRet; + aRet <<= m_pImpl->m_xNextObject; + m_pImpl->m_xNextObject = 0; return aRet; } -struct InvalidFrameDepend { - bool operator() (::boost::shared_ptr<SwDepend> const & rEntry) - { return !rEntry->GetRegisteredIn(); } -}; +/* -----------------------------06.04.00 16:39-------------------------------- -/*-- 23.03.99 13:22:37--------------------------------------------------- + ---------------------------------------------------------------------------*/ +OUString SAL_CALL +SwXParaFrameEnumeration::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXParaFrameEnumeration"); +} - -----------------------------------------------------------------------*/ -void SwXParaFrameEnumeration::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) +/* -----------------------------06.04.00 16:39-------------------------------- + + ---------------------------------------------------------------------------*/ +static char const*const g_ServicesParaFrameEnum[] = { - switch( pOld ? pOld->Which() : 0 ) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - ((SwModify*)GetRegisteredIn())->Remove(this); - break; + "com.sun.star.util.ContentEnumeration", +}; +static const size_t g_nServicesParaFrameEnum( + sizeof(g_ServicesParaFrameEnum)/sizeof(g_ServicesParaFrameEnum[0])); - case RES_FMT_CHG: - // wurden wir an das neue umgehaengt und wird das alte geloscht? - if( ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() && - ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR() ) - ((SwModify*)GetRegisteredIn())->Remove(this); - break; - } - if(!GetRegisteredIn()) - { - m_Frames.clear(); - m_xNextObject = 0; - } - else - { - // check if any frame went away... - FrameDependList_t::iterator iter = - ::std::remove_if(m_Frames.begin(), m_Frames.end(), - InvalidFrameDepend()); - m_Frames.erase(iter, m_Frames.end()); - } +sal_Bool SAL_CALL +SwXParaFrameEnumeration::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesParaFrameEnum, g_ServicesParaFrameEnum, rServiceName); } -// ----------------------------------------------------------------------------- -IMPLEMENT_FORWARD_REFCOUNT( SwXTextCursor,SwXTextCursor_Base ) -uno::Any SAL_CALL SwXTextCursor::queryInterface( const uno::Type& _rType ) throw (uno::RuntimeException) +/* -----------------------------06.04.00 16:39-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXParaFrameEnumeration::getSupportedServiceNames() +throw (uno::RuntimeException) { - if( _rType == ::getCppuType( (uno::Reference<XUnoTunnel>*)0) ) - return OTextCursorHelper::queryInterface( _rType ); - else - return SwXTextCursor_Base::queryInterface( _rType ); + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesParaFrameEnum, g_ServicesParaFrameEnum); } - diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 732e777eaa..93051e05f0 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -31,10 +31,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - +#include <unoparagraph.hxx> #include <cmdid.h> #include <unomid.h> -#include <unoobj.hxx> +#include <unoparaframeenum.hxx> +#include <unotext.hxx> +#include <unotextrange.hxx> #include <unoport.hxx> #include <unomap.hxx> #include <unocrsr.hxx> @@ -57,6 +59,7 @@ #include <com/sun/star/text/WrapTextMode.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> + using namespace ::com::sun::star; using ::rtl::OUString; @@ -66,38 +69,38 @@ using ::rtl::OUString; ---------------------------------------------------------------------------*/ class SwParaSelection { - SwCursor* m_pCursor; + SwCursor & m_rCursor; public: - SwParaSelection(SwCursor* pPam); + SwParaSelection(SwCursor & rCursor); ~SwParaSelection(); }; -SwParaSelection::SwParaSelection(SwCursor* pCursor) - : m_pCursor(pCursor) +SwParaSelection::SwParaSelection(SwCursor & rCursor) + : m_rCursor(rCursor) { - if (m_pCursor->HasMark()) + if (m_rCursor.HasMark()) { - m_pCursor->DeleteMark(); + m_rCursor.DeleteMark(); } // is it at the start? - if (m_pCursor->GetPoint()->nContent != 0) + if (m_rCursor.GetPoint()->nContent != 0) { - m_pCursor->MovePara(fnParaCurr, fnParaStart); + m_rCursor.MovePara(fnParaCurr, fnParaStart); } // or at the end already? - if (m_pCursor->GetPoint()->nContent != m_pCursor->GetCntntNode()->Len()) + if (m_rCursor.GetPoint()->nContent != m_rCursor.GetCntntNode()->Len()) { - m_pCursor->SetMark(); - m_pCursor->MovePara(fnParaCurr, fnParaEnd); + m_rCursor.SetMark(); + m_rCursor.MovePara(fnParaCurr, fnParaEnd); } } SwParaSelection::~SwParaSelection() { - if (m_pCursor->GetPoint()->nContent != 0) + if (m_rCursor.GetPoint()->nContent != 0) { - m_pCursor->DeleteMark(); - m_pCursor->MovePara(fnParaCurr, fnParaStart); + m_rCursor.DeleteMark(); + m_rCursor.MovePara(fnParaCurr, fnParaStart); } } @@ -111,25 +114,184 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( const SwAttrSet** ppSet, const SfxItemPropertySimpleEntry& rEntry, sal_Bool &rAttrSetFetched ) - throw( beans::UnknownPropertyException); + throw (beans::UnknownPropertyException); /****************************************************************** * SwXParagraph ******************************************************************/ -TYPEINIT1(SwXParagraph, SwClient); +class SwXParagraph::Impl + : public SwClient +{ -/* -----------------------------11.07.00 12:10-------------------------------- +public: + SwXParagraph & m_rThis; + SwEventListenerContainer m_ListenerContainer; + SfxItemPropertySet const& m_rPropSet; + bool m_bIsDescriptor; + sal_Int32 m_nSelectionStartPos; + sal_Int32 m_nSelectionEndPos; + ::rtl::OUString m_sText; + uno::Reference<text::XText> m_xParentText; + + Impl( SwXParagraph & rThis, + SwTxtNode *const pTxtNode = 0, + uno::Reference< text::XText > const & xParent = 0, + const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = -1) + : SwClient(pTxtNode) + , m_rThis(rThis) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH)) + , m_bIsDescriptor(0 == pTxtNode) + , m_nSelectionStartPos(nSelStart) + , m_nSelectionEndPos(nSelEnd) + , m_xParentText(xParent) + { + } - ---------------------------------------------------------------------------*/ -SwXParagraph* SwXParagraph::GetImplementation(uno::Reference< XInterface> xRef ) + const SwTxtNode * GetTxtNode() const { + return static_cast<const SwTxtNode*>(GetRegisteredIn()); + } + SwTxtNode * GetTxtNode() { + return static_cast<SwTxtNode*>(pRegisteredIn); + } + + SwTxtNode & GetTxtNodeOrThrow() { + SwTxtNode *const pTxtNode( GetTxtNode() ); + if (!pTxtNode) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXParagraph: disposed or invalid")), 0); + } + return *pTxtNode; + } + + bool IsDescriptor() const { return m_bIsDescriptor; } + + void SetPropertyValues_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames, + const uno::Sequence< uno::Any >& rValues) + throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException); + + uno::Sequence< uno::Any > + GetPropertyValues_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException); + + uno::Sequence< beans::GetDirectPropertyTolerantResult > + GetPropertyValuesTolerant_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames, + bool bDirectValuesOnly) + throw (uno::RuntimeException); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/*-- 11.12.98 08:12:58--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXParagraph::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { - uno::Reference<lang::XUnoTunnel> xParaTunnel( xRef, uno::UNO_QUERY); - if(xParaTunnel.is()) - return reinterpret_cast< SwXParagraph * >( - sal::static_int_cast< sal_IntPtr >( xParaTunnel->getSomething(SwXParagraph::getUnoTunnelId()) )); - return 0; + ClientModify(this, pOld, pNew); + if (!GetRegisteredIn()) + { + m_ListenerContainer.Disposing(); + } } + +/*-- 11.12.98 08:12:47--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXParagraph::SwXParagraph() + : m_pImpl( new SwXParagraph::Impl(*this) ) +{ +} + +/*-- 11.12.98 08:12:47--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXParagraph::SwXParagraph( + uno::Reference< text::XText > const & xParent, + SwTxtNode & rTxtNode, + const sal_Int32 nSelStart, const sal_Int32 nSelEnd) + : m_pImpl( + new SwXParagraph::Impl(*this, &rTxtNode, xParent, nSelStart, nSelEnd)) +{ +} + +/*-- 11.12.98 08:12:48--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXParagraph::~SwXParagraph() +{ +} + +const SwTxtNode * SwXParagraph::GetTxtNode() const +{ + return m_pImpl->GetTxtNode(); +} + +bool SwXParagraph::IsDescriptor() const +{ + return m_pImpl->IsDescriptor(); +} + +uno::Reference<text::XTextContent> +SwXParagraph::CreateXParagraph(SwDoc & rDoc, SwTxtNode& rTxtNode, + uno::Reference< text::XText> const& i_xParent, + const sal_Int32 nSelStart, const sal_Int32 nSelEnd) +{ + // re-use existing SwXParagraph + // #i105557#: do not iterate over the registered clients: race condition + uno::Reference<text::XTextContent> xParagraph; + if ((-1 == nSelStart) && (-1 == nSelEnd)) // only use cache if no selection! + { + xParagraph.set(rTxtNode.GetXParagraph()); + } + if (xParagraph.is()) + { + return xParagraph; + } + + // create new SwXParagraph + uno::Reference<text::XText> xParentText(i_xParent); + if (!xParentText.is()) + { + SwPosition Pos( rTxtNode ); + xParentText.set(::sw::CreateParentXText( rDoc, Pos )); + } + SwXParagraph *const pXPara( + new SwXParagraph(xParentText, rTxtNode, nSelStart, nSelEnd) ); + // this is why the constructor is private: need to acquire pXPara here + xParagraph.set(pXPara); + // in order to initialize the weak pointer cache in the core object + if ((-1 == nSelStart) && (-1 == nSelEnd)) + { + rTxtNode.SetXParagraph(xParagraph); + } + return xParagraph; +} + +bool SwXParagraph::SelectPaM(SwPaM & rPaM) +{ + SwTxtNode const*const pTxtNode( GetTxtNode() ); + + if (!pTxtNode) + { + return false; + } + + *rPaM.GetPoint() = SwPosition( *pTxtNode ); + // set selection to the whole paragraph + rPaM.SetMark(); + rPaM.GetMark()->nContent = pTxtNode->GetTxt().Len(); + return true; +} + /* -----------------------------13.03.00 12:15-------------------------------- ---------------------------------------------------------------------------*/ @@ -141,190 +303,176 @@ const uno::Sequence< sal_Int8 > & SwXParagraph::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXParagraph::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXParagraph::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<SwXParagraph>(rId, this); } -/* -----------------------------06.04.00 16:37-------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXParagraph::getImplementationName(void) throw( uno::RuntimeException ) -{ - return C2U("SwXParagraph"); -} /* -----------------------------06.04.00 16:37-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXParagraph::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXParagraph::getImplementationName() throw (uno::RuntimeException) { - String sServiceName(rServiceName); - return sServiceName.EqualsAscii("com.sun.star.text.TextContent") || - sServiceName.EqualsAscii("com.sun.star.text.Paragraph") || - sServiceName.EqualsAscii("com.sun.star.style.CharacterProperties")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesAsian")|| - sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesComplex")|| - sServiceName.EqualsAscii("com.sun.star.style.ParagraphProperties") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesAsian") || - sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesComplex"); + return C2U("SwXParagraph"); } /* -----------------------------06.04.00 16:37-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXParagraph::getSupportedServiceNames(void) throw( uno::RuntimeException ) +static char const*const g_ServicesParagraph[] = { - uno::Sequence< OUString > aRet(8); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.Paragraph"); - pArray[1] = C2U("com.sun.star.style.CharacterProperties"); - pArray[2] = C2U("com.sun.star.style.CharacterPropertiesAsian"); - pArray[3] = C2U("com.sun.star.style.CharacterPropertiesComplex"); - pArray[4] = C2U("com.sun.star.style.ParagraphProperties"); - pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian"); - pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex"); - pArray[7] = C2U("com.sun.star.text.TextContent"); - return aRet; -} -/*-- 11.12.98 08:12:47--------------------------------------------------- + "com.sun.star.text.TextContent", + "com.sun.star.text.Paragraph", + "com.sun.star.style.CharacterProperties", + "com.sun.star.style.CharacterPropertiesAsian", + "com.sun.star.style.CharacterPropertiesComplex", + "com.sun.star.style.ParagraphProperties", + "com.sun.star.style.ParagraphPropertiesAsian", + "com.sun.star.style.ParagraphPropertiesComplex", +}; +static const size_t g_nServicesParagraph( + sizeof(g_ServicesParagraph)/sizeof(g_ServicesParagraph[0])); - -----------------------------------------------------------------------*/ -SwXParagraph::SwXParagraph() : - xParentText(0), - aLstnrCntnr( (text::XTextRange*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH)), - nSelectionStartPos(-1), - nSelectionEndPos(-1), - m_bIsDescriptor(TRUE) +sal_Bool SAL_CALL +SwXParagraph::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { + return ::sw::SupportsServiceImpl( + g_nServicesParagraph, g_ServicesParagraph, rServiceName); } +/* -----------------------------06.04.00 16:37-------------------------------- -/*-- 11.12.98 08:12:47--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXParagraph::SwXParagraph(uno::Reference< text::XText > const & i_xParent, SwTxtNode * i_pTxtNode, sal_Int32 nSelStart, sal_Int32 nSelEnd) : - SwClient(i_pTxtNode), - xParentText(i_xParent), - aLstnrCntnr( (text::XTextRange*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH)), - nSelectionStartPos(nSelStart), - nSelectionEndPos(nSelEnd), - m_bIsDescriptor(FALSE) + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXParagraph::getSupportedServiceNames() throw (uno::RuntimeException) { + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesParagraph, g_ServicesParagraph); } -/*-- 11.12.98 08:12:48--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXParagraph::~SwXParagraph() -{ -} /* -----------------------------11.07.00 14:48-------------------------------- ---------------------------------------------------------------------------*/ -void SwXParagraph::attachToText(SwXText* pParent, SwUnoCrsr* pCrsr) +void +SwXParagraph::attachToText(SwXText & rParent, SwTxtNode & rTxtNode) { - DBG_ASSERT(m_bIsDescriptor, "Paragraph is not a descriptor"); - if(m_bIsDescriptor) + DBG_ASSERT(m_pImpl->m_bIsDescriptor, "Paragraph is not a descriptor"); + if (m_pImpl->m_bIsDescriptor) { - m_bIsDescriptor = FALSE; - pCrsr->Add(this); - xParentText = pParent; - if(m_sText.getLength()) + m_pImpl->m_bIsDescriptor = false; + rTxtNode.Add(m_pImpl.get()); + rTxtNode.SetXParagraph(uno::Reference<text::XTextContent>(this)); + m_pImpl->m_xParentText = &rParent; + if (m_pImpl->m_sText.getLength()) { - try { setString(m_sText); } + try { setString(m_pImpl->m_sText); } catch(...){} - m_sText = OUString(); + m_pImpl->m_sText = OUString(); } } } + /*-- 11.12.98 08:12:49--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXParagraph::getPropertySetInfo(void) - throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXParagraph::getPropertySetInfo() +throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo(); + vos::OGuard g(Application::GetSolarMutex()); + + static uno::Reference< beans::XPropertySetInfo > xRef = + m_pImpl->m_rPropSet.getPropertySetInfo(); return xRef; } /*-- 11.12.98 08:12:49--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::setPropertyValue(const OUString& rPropertyName, + const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Sequence<OUString> aPropertyNames(1); aPropertyNames.getArray()[0] = rPropertyName; uno::Sequence<uno::Any> aValues(1); - aValues.getArray()[0] = aValue; - SetPropertyValues_Impl( aPropertyNames, aValues ); + aValues.getArray()[0] = rValue; + m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues ); } + /*-- 11.12.98 08:12:49--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParagraph::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any +SwXParagraph::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Sequence<OUString> aPropertyNames(1); aPropertyNames.getArray()[0] = rPropertyName; - uno::Sequence< uno::Any > aRet = GetPropertyValues_Impl(aPropertyNames ); + const uno::Sequence< uno::Any > aRet = + m_pImpl->GetPropertyValues_Impl(aPropertyNames); return aRet.getConstArray()[0]; } /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -void SAL_CALL SwXParagraph::SetPropertyValues_Impl( +void SwXParagraph::Impl::SetPropertyValues_Impl( const uno::Sequence< OUString >& rPropertyNames, const uno::Sequence< uno::Any >& rValues ) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { - if (GetTxtNode()) + SwTxtNode & rTxtNode(GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + const OUString* pPropertyNames = rPropertyNames.getConstArray(); + const uno::Any* pValues = rValues.getConstArray(); + SfxItemPropertyMap const*const pMap = m_rPropSet.getPropertyMap(); + SwParaSelection aParaSel( aCursor ); + for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) { - SwPosition aPos( *GetTxtNode() ); - SwCursor aCursor( aPos, 0, false ); - const OUString* pPropertyNames = rPropertyNames.getConstArray(); - const uno::Any* pValues = rValues.getConstArray(); - const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); - SwParaSelection aParaSel( & aCursor ); - for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) + SfxItemPropertySimpleEntry const*const pEntry = + pMap->getByName( pPropertyNames[nProp] ); + if (!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pPropertyNames[nProp] ); - if(!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - else - { - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - - SwXTextCursor::SetPropertyValue(aCursor, *m_pPropSet, - pPropertyNames[nProp], pValues[nProp]); - } + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pPropertyNames[nProp], + static_cast< cppu::OWeakObject * >(&m_rThis)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw beans::PropertyVetoException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + pPropertyNames[nProp], + static_cast< cppu::OWeakObject * >(&m_rThis)); } + SwUnoCursorHelper::SetPropertyValue(aCursor, m_rPropSet, + pPropertyNames[nProp], pValues[nProp]); } - else - throw uno::RuntimeException(); } -void SwXParagraph::setPropertyValues( +void SAL_CALL SwXParagraph::setPropertyValues( const uno::Sequence< OUString >& rPropertyNames, const uno::Sequence< uno::Any >& rValues ) - throw(beans::PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, uno::RuntimeException) +throw (beans::PropertyVetoException, lang::IllegalArgumentException, + lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); // workaround for bad designed API try { - SetPropertyValues_Impl( rPropertyNames, rValues ); + m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues ); } catch (beans::UnknownPropertyException &rException) { @@ -335,53 +483,57 @@ void SwXParagraph::setPropertyValues( throw aWExc; } } + /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Any > SAL_CALL SwXParagraph::GetPropertyValues_Impl( +uno::Sequence< uno::Any > SwXParagraph::Impl::GetPropertyValues_Impl( const uno::Sequence< OUString > & rPropertyNames ) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + SwTxtNode & rTxtNode(GetTxtNodeOrThrow()); + uno::Sequence< uno::Any > aValues(rPropertyNames.getLength()); - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) + SwPosition aPos( rTxtNode ); + SwPaM aPam( aPos ); + uno::Any* pValues = aValues.getArray(); + const OUString* pPropertyNames = rPropertyNames.getConstArray(); + SfxItemPropertyMap const*const pMap = m_rPropSet.getPropertyMap(); + const SwAttrSet& rAttrSet( rTxtNode.GetSwAttrSet() ); + for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) { - SwPosition aPos( *pTxtNode ); - SwPaM aPam( aPos ); - uno::Any* pValues = aValues.getArray(); - const OUString* pPropertyNames = rPropertyNames.getConstArray(); - const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); - const SwAttrSet& rAttrSet( pTxtNode->GetSwAttrSet() ); - for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) + SfxItemPropertySimpleEntry const*const pEntry = + pMap->getByName( pPropertyNames[nProp] ); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pPropertyNames[nProp], + static_cast< cppu::OWeakObject * >(&m_rThis)); + } + if (! ::sw::GetDefaultTextContentValue( + pValues[nProp], pPropertyNames[nProp], pEntry->nWID)) { - const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pPropertyNames[nProp] ); - if(pEntry) + beans::PropertyState eTemp; + const bool bDone = SwUnoCursorHelper::getCrsrPropertyValue( + *pEntry, aPam, &(pValues[nProp]), eTemp, &rTxtNode ); + if (!bDone) { - if(!SwXParagraph::getDefaultTextContentValue( - pValues[nProp], pPropertyNames[nProp], pEntry->nWID)) - { - BOOL bDone = FALSE; - beans::PropertyState eTemp; - bDone = SwUnoCursorHelper::getCrsrPropertyValue( - *pEntry, aPam, &(pValues[nProp]), eTemp, pTxtNode ); - if(!bDone) - m_pPropSet->getPropertyValue(*pEntry, rAttrSet, pValues[nProp]); - } + m_rPropSet.getPropertyValue( + *pEntry, rAttrSet, pValues[nProp]); } - else - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); } } - else - throw uno::RuntimeException(); return aValues; } + /* -----------------------------04.11.03 11:43-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Any > SwXParagraph::getPropertyValues( - const uno::Sequence< OUString >& rPropertyNames ) - throw(uno::RuntimeException) +uno::Sequence< uno::Any > SAL_CALL +SwXParagraph::getPropertyValues(const uno::Sequence< OUString >& rPropertyNames) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Sequence< uno::Any > aValues; @@ -389,67 +541,82 @@ uno::Sequence< uno::Any > SwXParagraph::getPropertyValues( // workaround for bad designed API try { - aValues = GetPropertyValues_Impl( rPropertyNames ); + aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames ); } catch (beans::UnknownPropertyException &) { - throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "Unknown property exception caught")), + static_cast<cppu::OWeakObject *>(this)); } catch (lang::WrappedTargetException &) { - throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "WrappedTargetException caught")), + static_cast<cppu::OWeakObject *>(this)); } return aValues; } + /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -void SwXParagraph::addPropertiesChangeListener( +void SAL_CALL SwXParagraph::addPropertiesChangeListener( const uno::Sequence< OUString >& /*aPropertyNames*/, const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(uno::RuntimeException) -{} +throw (uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXParagraph::addPropertiesChangeListener(): not implemented"); +} /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -void SwXParagraph::removePropertiesChangeListener( +void SAL_CALL SwXParagraph::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(uno::RuntimeException) -{} +throw (uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXParagraph::removePropertiesChangeListener(): not implemented"); +} /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ -void SwXParagraph::firePropertiesChangeEvent( +void SAL_CALL SwXParagraph::firePropertiesChangeEvent( const uno::Sequence< OUString >& /*aPropertyNames*/, const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) throw(uno::RuntimeException) -{} +{ + OSL_ENSURE(false, + "SwXParagraph::firePropertiesChangeEvent(): not implemented"); +} /* -----------------------------25.09.03 11:09-------------------------------- ---------------------------------------------------------------------------*/ /* disabled for #i46921# */ -uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setPropertyValuesTolerant( +uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL +SwXParagraph::setPropertyValuesTolerant( const uno::Sequence< OUString >& rPropertyNames, const uno::Sequence< uno::Any >& rValues ) - throw (lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard( Application::GetSolarMutex() ); if (rPropertyNames.getLength() != rValues.getLength()) + { throw lang::IllegalArgumentException(); + } - const SwTxtNode * const pTxtNode( GetTxtNode() ); - if (!pTxtNode) - throw uno::RuntimeException(); + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); //SwNode& rTxtNode = pUnoCrsr->GetPoint()->nNode.GetNode(); //const SwAttrSet& rAttrSet = ((SwTxtNode&)rTxtNode).GetSwAttrSet(); //USHORT nAttrCount = rAttrSet.Count(); - sal_Int32 nProps = rPropertyNames.getLength(); + const sal_Int32 nProps = rPropertyNames.getLength(); const OUString *pProp = rPropertyNames.getConstArray(); //sal_Int32 nVals = rValues.getLength(); @@ -460,31 +627,39 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setProp beans::SetPropertyTolerantFailed *pFailed = aFailed.getArray(); // get entry to start with - const SfxItemPropertyMap* pPropMap = m_pPropSet->getPropertyMap(); + SfxItemPropertyMap const*const pPropMap = + m_pImpl->m_rPropSet.getPropertyMap(); OUString sTmp; - SwPosition aPos( *pTxtNode ); + SwPosition aPos( rTxtNode ); SwCursor aCursor( aPos, 0, false ); - SwParaSelection aParaSel( & aCursor ); + SwParaSelection aParaSel( aCursor ); for (sal_Int32 i = 0; i < nProps; ++i) { try { pFailed[ nFailed ].Name = pProp[i]; - const SfxItemPropertySimpleEntry* pEntry = pPropMap->getByName( pProp[i] ); + SfxItemPropertySimpleEntry const*const pEntry = + pPropMap->getByName( pProp[i] ); if (!pEntry) - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + { + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + } else { // set property value // (compare to SwXParagraph::setPropertyValues) if (pEntry->nFlags & beans::PropertyAttribute::READONLY) - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO; + { + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::PROPERTY_VETO; + } else { - SwXTextCursor::SetPropertyValue( - aCursor, *m_pPropSet, pProp[i], pValue[i] ); + SwUnoCursorHelper::SetPropertyValue( + aCursor, m_pImpl->m_rPropSet, pProp[i], pValue[i]); } } } @@ -492,19 +667,23 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setProp { // should not occur because property was searched for before DBG_ERROR( "unexpected exception catched" ); - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; } catch (lang::IllegalArgumentException &) { - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT; + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT; } catch (beans::PropertyVetoException &) { - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO; + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::PROPERTY_VETO; } catch (lang::WrappedTargetException &) { - pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET; + pFailed[ nFailed++ ].Result = + beans::TolerantPropertySetResultType::WRAPPED_TARGET; } } @@ -513,52 +692,56 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setProp } -uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL SwXParagraph::getPropertyValuesTolerant( +uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL +SwXParagraph::getPropertyValuesTolerant( const uno::Sequence< OUString >& rPropertyNames ) - throw (uno::RuntimeException) +throw (uno::RuntimeException) { vos::OGuard aGuard( Application::GetSolarMutex() ); uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes( - GetPropertyValuesTolerant_Impl( rPropertyNames, sal_False ) ); - const beans::GetDirectPropertyTolerantResult *pTmpRes = aTmpRes.getConstArray(); + m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, false ) ); + const beans::GetDirectPropertyTolerantResult *pTmpRes = + aTmpRes.getConstArray(); // copy temporary result to final result type - sal_Int32 nLen = aTmpRes.getLength(); + const sal_Int32 nLen = aTmpRes.getLength(); uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen ); beans::GetPropertyTolerantResult *pRes = aRes.getArray(); for (sal_Int32 i = 0; i < nLen; i++) + { *pRes++ = *pTmpRes++; + } return aRes; } -uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::getDirectPropertyValuesTolerant( +uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL +SwXParagraph::getDirectPropertyValuesTolerant( const uno::Sequence< OUString >& rPropertyNames ) - throw (uno::RuntimeException) +throw (uno::RuntimeException) { vos::OGuard aGuard( Application::GetSolarMutex() ); - return GetPropertyValuesTolerant_Impl( rPropertyNames, sal_True ); + + return m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, true ); } -uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::GetPropertyValuesTolerant_Impl( +uno::Sequence< beans::GetDirectPropertyTolerantResult > +SwXParagraph::Impl::GetPropertyValuesTolerant_Impl( const uno::Sequence< OUString >& rPropertyNames, - sal_Bool bDirectValuesOnly ) - throw (uno::RuntimeException) + bool bDirectValuesOnly ) +throw (uno::RuntimeException) { vos::OGuard aGuard( Application::GetSolarMutex() ); - const SwTxtNode * const pTxtNode( GetTxtNode() ); - DBG_ASSERT( pTxtNode != NULL, "need text node" ); - if (!pTxtNode) - throw uno::RuntimeException(); + SwTxtNode & rTxtNode(GetTxtNodeOrThrow()); // #i46786# Use SwAttrSet pointer for determining the state. // Use the value SwAttrSet (from the paragraph OR the style) // for determining the actual value(s). - const SwAttrSet* pAttrSet = pTxtNode->GetpSwAttrSet(); - const SwAttrSet& rValueAttrSet = pTxtNode->GetSwAttrSet(); + const SwAttrSet* pAttrSet = rTxtNode.GetpSwAttrSet(); + const SwAttrSet& rValueAttrSet = rTxtNode.GetSwAttrSet(); sal_Int32 nProps = rPropertyNames.getLength(); const OUString *pProp = rPropertyNames.getConstArray(); @@ -568,7 +751,7 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::G sal_Int32 nIdx = 0; // get entry to start with - const SfxItemPropertyMap *pPropMap = m_pPropSet->getPropertyMap(); + SfxItemPropertyMap const*const pPropMap = m_rPropSet.getPropertyMap(); for (sal_Int32 i = 0; i < nProps; ++i) { @@ -579,42 +762,50 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::G { rResult.Name = pProp[i]; - const SfxItemPropertySimpleEntry* pEntry = pPropMap->getByName( pProp[i] ); + SfxItemPropertySimpleEntry const*const pEntry = + pPropMap->getByName( pProp[i] ); if (!pEntry) // property available? - rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + { + rResult.Result = + beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY; + } else { // get property state // (compare to SwXParagraph::getPropertyState) sal_Bool bAttrSetFetched = sal_True; beans::PropertyState eState = lcl_SwXParagraph_getPropertyState( - *pTxtNode, &pAttrSet, *pEntry, bAttrSetFetched ); + rTxtNode, &pAttrSet, *pEntry, bAttrSetFetched ); rResult.State = eState; // if (bDirectValuesOnly && PropertyState_DIRECT_VALUE != eState) // rResult.Result = beans::TolerantPropertySetResultType::NO_DIRECT_VALUE; // else rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE; - if (!bDirectValuesOnly || beans::PropertyState_DIRECT_VALUE == eState) + if (!bDirectValuesOnly || + (beans::PropertyState_DIRECT_VALUE == eState)) { // get property value // (compare to SwXParagraph::getPropertyValue(s)) uno::Any aValue; - if (!SwXParagraph::getDefaultTextContentValue( + if (! ::sw::GetDefaultTextContentValue( aValue, pProp[i], pEntry->nWID ) ) { - SwPosition aPos( *pTxtNode ); + SwPosition aPos( rTxtNode ); SwPaM aPam( aPos ); // handle properties that are not part of the attribute // and thus only pretendend to be paragraph attributes - BOOL bDone = FALSE; beans::PropertyState eTemp; - bDone = SwUnoCursorHelper::getCrsrPropertyValue( - *pEntry, aPam, &aValue, eTemp, pTxtNode ); + const bool bDone = + SwUnoCursorHelper::getCrsrPropertyValue( + *pEntry, aPam, &aValue, eTemp, &rTxtNode ); // if not found try the real paragraph attributes... if (!bDone) - m_pPropSet->getPropertyValue( *pEntry, rValueAttrSet, aValue ); + { + m_rPropSet.getPropertyValue( + *pEntry, rValueAttrSet, aValue ); + } } rResult.Value = aValue; @@ -657,7 +848,8 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::G /* -----------------------------12.09.00 11:09-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXParagraph::getDefaultTextContentValue(uno::Any& rAny, const OUString& rPropertyName, USHORT nWID) +bool ::sw::GetDefaultTextContentValue( + uno::Any& rAny, const OUString& rPropertyName, USHORT nWID) { if(!nWID) { @@ -690,35 +882,59 @@ BOOL SwXParagraph::getDefaultTextContentValue(uno::Any& rAny, const OUString& rP /*-- 11.12.98 08:12:50--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::addPropertyChangeListener( - const OUString& /*PropertyName*/, - const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::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, + "SwXParagraph::addPropertyChangeListener(): not implemented"); } + /*-- 11.12.98 08:12:50--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::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, + "SwXParagraph::removePropertyChangeListener(): not implemented"); } + /*-- 11.12.98 08:12:50--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::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, + "SwXParagraph::addVetoableChangeListener(): not implemented"); } + /*-- 11.12.98 08:12:51--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXParagraph::removeVetoableChangeListener(): not implemented"); } + //----------------------------------------------------------------------------- beans::PropertyState lcl_SwXParagraph_getPropertyState( // SwUnoCrsr& rUnoCrsr, @@ -726,7 +942,7 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( const SwAttrSet** ppSet, const SfxItemPropertySimpleEntry& rEntry, sal_Bool &rAttrSetFetched ) - throw( beans::UnknownPropertyException) +throw (beans::UnknownPropertyException) { beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; @@ -756,7 +972,7 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( case FN_UNO_PARA_STYLE: case FN_UNO_PARA_CONDITIONAL_STYLE_NAME: { - SwFmtColl* pFmt = SwXTextCursor::GetCurTxtFmtColl( + SwFmtColl* pFmt = SwUnoCursorHelper::GetCurTxtFmtColl( aPam, rEntry.nWID == FN_UNO_PARA_CONDITIONAL_STYLE_NAME); eRet = pFmt ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE; @@ -782,348 +998,393 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( /*-- 05.03.99 11:37:30--------------------------------------------------- -----------------------------------------------------------------------*/ -beans::PropertyState SwXParagraph::getPropertyState(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +beans::PropertyState SAL_CALL +SwXParagraph::getPropertyState(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; - const SwTxtNode * const pTxtNode( GetTxtNode() ); - if (pTxtNode) + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + const SwAttrSet* pSet = 0; + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) { - const SwAttrSet* pSet = 0; - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); - if(!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - sal_Bool bDummy = sal_False; - eRet = lcl_SwXParagraph_getPropertyState( *pTxtNode, &pSet, *pEntry, - bDummy ); + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + rPropertyName, + static_cast<cppu::OWeakObject *>(this)); } - else - throw uno::RuntimeException(); + sal_Bool bDummy = sal_False; + const beans::PropertyState eRet = + lcl_SwXParagraph_getPropertyState(rTxtNode, &pSet, *pEntry, bDummy); return eRet; } /*-- 05.03.99 11:37:32--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Sequence< beans::PropertyState > SwXParagraph::getPropertyStates( +uno::Sequence< beans::PropertyState > SAL_CALL +SwXParagraph::getPropertyStates( const uno::Sequence< OUString >& PropertyNames) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + const OUString* pNames = PropertyNames.getConstArray(); uno::Sequence< beans::PropertyState > aRet(PropertyNames.getLength()); beans::PropertyState* pStates = aRet.getArray(); + SfxItemPropertyMap const*const pMap = m_pImpl->m_rPropSet.getPropertyMap(); + const SwAttrSet* pSet = 0; + sal_Bool bAttrSetFetched = sal_False; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) + for (sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd; + ++i, ++pStates, ++pNames) { - const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); - const SwAttrSet* pSet = 0; - sal_Bool bAttrSetFetched = sal_False; - for(sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd; i++,++pStates,++pNames ) + SfxItemPropertySimpleEntry const*const pEntry = + pMap->getByName( *pNames ); + if (!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( *pNames ); - if(!pEntry) - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + *pNames, static_cast < cppu::OWeakObject * > ( this ) ); + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + *pNames, + static_cast<cppu::OWeakObject *>(this)); + } - if (bAttrSetFetched && !pSet && isATR(pEntry->nWID)) - { - *pStates = beans::PropertyState_DEFAULT_VALUE; - } - else - { - *pStates = lcl_SwXParagraph_getPropertyState( - *pTxtNode, &pSet, *pEntry, bAttrSetFetched ); - } + if (bAttrSetFetched && !pSet && isATR(pEntry->nWID)) + { + *pStates = beans::PropertyState_DEFAULT_VALUE; + } + else + { + *pStates = lcl_SwXParagraph_getPropertyState( + rTxtNode, &pSet, *pEntry, bAttrSetFetched ); } } - else - throw uno::RuntimeException(); return aRet; } + /*-- 05.03.99 11:37:33--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::setPropertyToDefault(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::setPropertyToDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)) || + rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_ANCHOR_TYPES)) || + rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_TEXT_WRAP))) { - SwPosition aPos( *pTxtNode ); - SwCursor aCursor( aPos, 0, false ); - if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)) || - rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPES)) || - rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_TEXT_WRAP))) - return; + return; + } - // select paragraph - SwParaSelection aParaSel( & aCursor ); - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); - if(pEntry) - { - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - throw uno::RuntimeException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only:" ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + // select paragraph + SwParaSelection aParaSel( aCursor ); + 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->nWID < RES_FRMATR_END) + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw uno::RuntimeException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + rPropertyName, + static_cast<cppu::OWeakObject *>(this)); + } + + if (pEntry->nWID < RES_FRMATR_END) + { + SvUShortsSort aWhichIds; + aWhichIds.Insert(pEntry->nWID); + if (pEntry->nWID < RES_PARATR_BEGIN) + { + aCursor.GetDoc()->ResetAttrs(aCursor, sal_True, &aWhichIds); + } + else + { + // for paragraph attributes the selection must be extended + // to paragraph boundaries + SwPosition aStart( *aCursor.Start() ); + SwPosition aEnd ( *aCursor.End() ); + ::std::auto_ptr<SwUnoCrsr> pTemp( + aCursor.GetDoc()->CreateUnoCrsr(aStart, sal_False) ); + if(!SwUnoCursorHelper::IsStartOfPara(*pTemp)) { - SvUShortsSort aWhichIds; - aWhichIds.Insert(pEntry->nWID); - if(pEntry->nWID < RES_PARATR_BEGIN) - { - aCursor.GetDoc()->ResetAttrs(aCursor, sal_True, &aWhichIds); - } - else - { - // for paragraph attributes the selection must be extended - // to paragraph boundaries - SwPosition aStart( *aCursor.Start() ); - SwPosition aEnd ( *aCursor.End() ); - std::auto_ptr<SwUnoCrsr> pTemp( - aCursor.GetDoc()->CreateUnoCrsr(aStart, sal_False) ); - if(!SwUnoCursorHelper::IsStartOfPara(*pTemp)) - { - pTemp->MovePara(fnParaCurr, fnParaStart); - } - pTemp->SetMark(); - *pTemp->GetPoint() = aEnd; - //pTemp->Exchange(); - SwXTextCursor::SelectPam(*pTemp, sal_True); - if(!SwUnoCursorHelper::IsEndOfPara(*pTemp)) - { - pTemp->MovePara(fnParaCurr, fnParaEnd); - } - pTemp->GetDoc()->ResetAttrs(*pTemp, sal_True, &aWhichIds); - } + pTemp->MovePara(fnParaCurr, fnParaStart); } - else + pTemp->SetMark(); + *pTemp->GetPoint() = aEnd; + //pTemp->Exchange(); + SwUnoCursorHelper::SelectPam(*pTemp, true); + if (!SwUnoCursorHelper::IsEndOfPara(*pTemp)) { - SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, aCursor); + pTemp->MovePara(fnParaCurr, fnParaEnd); } + pTemp->GetDoc()->ResetAttrs(*pTemp, sal_True, &aWhichIds); } - else - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); } else - throw uno::RuntimeException(); + { + SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, aCursor); + } } + /*-- 05.03.99 11:37:33--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParagraph::getPropertyDefault(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXParagraph::getPropertyDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + uno::Any aRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) + if (::sw::GetDefaultTextContentValue(aRet, rPropertyName)) { - if(SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) - return aRet; + return aRet; + } - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); - if(pEntry) - { - if(pEntry->nWID < RES_FRMATR_END) - { - const SfxPoolItem& rDefItem = - pTxtNode->GetDoc()->GetAttrPool().GetDefaultItem( - pEntry->nWID); - rDefItem.QueryValue(aRet, pEntry->nMemberId); - } - } - else - throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + 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->nWID < RES_FRMATR_END) + { + const SfxPoolItem& rDefItem = + rTxtNode.GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); + rDefItem.QueryValue(aRet, pEntry->nMemberId); } - else - throw uno::RuntimeException(); return aRet; } + /*-- 11.12.98 08:12:51--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::attach(const uno::Reference< text::XTextRange > & /*xTextRange*/) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXParagraph::attach(const uno::Reference< text::XTextRange > & /*xTextRange*/) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - // SwXParagraph will only created in order to be inserteb by + // SwXParagraph will only created in order to be inserted by // 'insertTextContentBefore' or 'insertTextContentAfter' therefore // they cannot be attached throw uno::RuntimeException(); } + /*-- 11.12.98 08:12:51--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXParagraph::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXParagraph::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > aRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) - { - SwPosition aPos( *pTxtNode ); - SwCursor aCursor( aPos, 0, false ); - // select paragraph - SwParaSelection aParaSel( & aCursor ); - aRet = new SwXTextRange(aCursor, xParentText); - } - else - throw uno::RuntimeException(); - return aRet; + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + // select paragraph + SwParaSelection aParaSel( aCursor ); + const uno::Reference< text::XTextRange > xRet = + new SwXTextRange(aCursor, m_pImpl->m_xParentText); + return xRet; } + /*-- 11.12.98 08:12:52--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL SwXParagraph::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwTxtNode * pTxtNode( GetTxtNode() ); + + SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() ); if (pTxtNode) { SwCursor aCursor( SwPosition( *pTxtNode ), 0, false ); // select paragraph { - SwParaSelection aParaSel( & aCursor ); + SwParaSelection aParaSel( aCursor ); pTxtNode->GetDoc()->DelFullPara(aCursor); } - aLstnrCntnr.Disposing(); + m_pImpl->m_ListenerContainer.Disposing(); } - else - throw uno::RuntimeException(); } + /*-- 11.12.98 08:12:52--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXParagraph::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetTxtNode()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 11.12.98 08:12:53--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXParagraph::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetTxtNode() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } + /*-- 11.12.98 08:12:53--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXParagraph::createEnumeration(void) throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXParagraph::createEnumeration() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< container::XEnumeration > aRef; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) - { - SwPosition aPos( *pTxtNode ); - SwPaM aPam ( aPos ); - aRef = new SwXTextPortionEnumeration(aPam, xParentText, - nSelectionStartPos, nSelectionEndPos); - } - else - throw uno::RuntimeException(); - return aRef; + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwPaM aPam ( aPos ); + const uno::Reference< container::XEnumeration > xRef = + new SwXTextPortionEnumeration(aPam, m_pImpl->m_xParentText, + m_pImpl->m_nSelectionStartPos, m_pImpl->m_nSelectionEndPos); + return xRef; } + /*-- 11.12.98 08:12:54--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Type SwXParagraph::getElementType(void) throw( uno::RuntimeException ) +uno::Type SAL_CALL SwXParagraph::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference<text::XTextRange>*)0); + return text::XTextRange::static_type(); } /*-- 11.12.98 08:12:54--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXParagraph::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXParagraph::hasElements() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); return (GetTxtNode()) ? sal_True : sal_False; } + /*-- 11.12.98 08:12:55--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XText > SwXParagraph::getText(void) throw( uno::RuntimeException ) +uno::Reference< text::XText > SAL_CALL +SwXParagraph::getText() throw (uno::RuntimeException) { - return xParentText; + vos::OGuard g(Application::GetSolarMutex()); + + return m_pImpl->m_xParentText; } + /*-- 11.12.98 08:12:55--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXParagraph::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXParagraph::getStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > xRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) - { - SwPosition aPos( *pTxtNode ); - SwCursor aCursor( aPos, 0, false ); - SwParaSelection aParaSel( &aCursor ); - SwPaM aPam( *aCursor.Start() ); - uno::Reference< text::XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); - } - else - throw uno::RuntimeException(); + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + SwParaSelection aParaSel( aCursor ); + SwPaM aPam( *aCursor.Start() ); + uno::Reference< text::XText > xParent = getText(); + const uno::Reference< text::XTextRange > xRet = + new SwXTextRange(aPam, xParent); return xRet; } /*-- 11.12.98 08:12:56--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXParagraph::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXParagraph::getEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > xRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); - if (pTxtNode) - { - SwPosition aPos( *pTxtNode ); - SwCursor aCursor( aPos, 0, false ); - SwParaSelection aParaSel( &aCursor ); - SwPaM aPam( *aCursor.End() ); - uno::Reference< text::XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); - } - else - throw uno::RuntimeException(); + + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); + SwCursor aCursor( aPos, 0, false ); + SwParaSelection aParaSel( aCursor ); + SwPaM aPam( *aCursor.End() ); + uno::Reference< text::XText > xParent = getText(); + const uno::Reference< text::XTextRange > xRet = + new SwXTextRange(aPam, xParent); return xRet; } + /*-- 11.12.98 08:12:56--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXParagraph::getString(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXParagraph::getString() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); OUString aRet; - const SwTxtNode * pTxtNode( GetTxtNode() ); + SwTxtNode const*const pTxtNode( GetTxtNode() ); if (pTxtNode) { SwPosition aPos( *pTxtNode ); SwCursor aCursor( aPos, 0, false ); - SwParaSelection aParaSel( & aCursor ); - SwXTextCursor::getTextFromPam(aCursor, aRet); + SwParaSelection aParaSel( aCursor ); + SwUnoCursorHelper::GetTextFromPam(aCursor, aRet); + } + else if (m_pImpl->IsDescriptor()) + { + aRet = m_pImpl->m_sText; } - else if(IsDescriptor()) - aRet = m_sText; else + { throw uno::RuntimeException(); + } return aRet; } /*-- 11.12.98 08:12:57--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXParagraph::setString(const OUString& aString) throw( uno::RuntimeException ) +void SAL_CALL SwXParagraph::setString(const OUString& aString) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwTxtNode * pTxtNode( GetTxtNode() ); + SwTxtNode const*const pTxtNode( GetTxtNode() ); if (pTxtNode) { SwPosition aPos( *pTxtNode ); @@ -1131,30 +1392,40 @@ void SwXParagraph::setString(const OUString& aString) throw( uno::RuntimeExcepti if (!SwUnoCursorHelper::IsStartOfPara(aCursor)) { aCursor.MovePara(fnParaCurr, fnParaStart); } - SwXTextCursor::SelectPam(aCursor, sal_True); + SwUnoCursorHelper::SelectPam(aCursor, true); if (pTxtNode->GetTxt().Len()) { aCursor.MovePara(fnParaCurr, fnParaEnd); } - SwXTextCursor::SetString(aCursor, aString); - SwXTextCursor::SelectPam(aCursor, sal_False); + SwUnoCursorHelper::SetString(aCursor, aString); + SwUnoCursorHelper::SelectPam(aCursor, false); + } + else if (m_pImpl->IsDescriptor()) + { + m_pImpl->m_sText = aString; } - else if(IsDescriptor()) - m_sText = aString; else + { throw uno::RuntimeException(); - + } } + /* -----------------23.03.99 12:49------------------- * * --------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXParagraph::createContentEnumeration(const OUString& rServiceName) - throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXParagraph::createContentEnumeration(const OUString& rServiceName) +throw (uno::RuntimeException) { - const SwTxtNode * pTxtNode( GetTxtNode() ); - if(!pTxtNode || !rServiceName.equalsAscii("com.sun.star.text.TextContent")) + vos::OGuard g(Application::GetSolarMutex()); + + if (!rServiceName.equalsAscii("com.sun.star.text.TextContent")) + { throw uno::RuntimeException(); + } - SwPosition aPos( *pTxtNode ); + SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow()); + + SwPosition aPos( rTxtNode ); SwPaM aPam( aPos ); uno::Reference< container::XEnumeration > xRet = new SwXParaFrameEnumeration(aPam, PARAFRAME_PORTION_PARAGRAPH); @@ -1163,50 +1434,31 @@ uno::Reference< container::XEnumeration > SwXParagraph::createContentEnumeratio /* -----------------23.03.99 12:49------------------- * * --------------------------------------------------*/ -uno::Sequence< OUString > SwXParagraph::getAvailableServiceNames(void) throw( uno::RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXParagraph::getAvailableServiceNames() throw (uno::RuntimeException) { uno::Sequence< OUString > aRet(1); OUString* pArray = aRet.getArray(); pArray[0] = C2U("com.sun.star.text.TextContent"); return aRet; } -/*-- 11.12.98 08:12:58--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXParagraph::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); - if(!GetRegisteredIn()) - aLstnrCntnr.Disposing(); -} - -const SwTxtNode * SwXParagraph::GetTxtNode() const -{ - return static_cast<const SwTxtNode*>(GetRegisteredIn()); -} -SwTxtNode * SwXParagraph::GetTxtNode() -{ - return static_cast<SwTxtNode*>(pRegisteredIn); -} +// MetadatableMixin ::sfx2::Metadatable* SwXParagraph::GetCoreObject() { - SwTxtNode * pTxtNode( GetTxtNode() ); + SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() ); return pTxtNode; } uno::Reference<frame::XModel> SwXParagraph::GetModel() { - SwTxtNode * pTxtNode( GetTxtNode() ); + SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() ); if (pTxtNode) { - const SwDocShell * pShell( pTxtNode->GetDoc()->GetDocShell() ); + SwDocShell const*const pShell( pTxtNode->GetDoc()->GetDocShell() ); return (pShell) ? pShell->GetModel() : 0; } - else - { - return 0; - } + return 0; } diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index ceb9b4885e..c2094ffae7 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -36,9 +36,11 @@ #include <vos/mutex.hxx> #include <vcl/svapp.hxx> #include <svl/itemprop.hxx> + #include <unocrsrhelper.hxx> #include <unoport.hxx> -#include <unoobj.hxx> +#include <unoparaframeenum.hxx> +#include <unotextrange.hxx> #include <unomap.hxx> #include <unoprnms.hxx> #include <unomid.h> @@ -48,6 +50,7 @@ #include <doc.hxx> #include <fmtflcnt.hxx> #include <fmtfld.hxx> +#include <frmfmt.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp> @@ -237,7 +240,7 @@ void SwXTextPortion::setString(const OUString& aString) throw( uno::RuntimeExcep if (!pUnoCrsr) throw uno::RuntimeException(); - SwXTextCursor::SetString(*pUnoCrsr, aString); + SwUnoCursorHelper::SetString(*pUnoCrsr, aString); } /*-- 11.12.98 09:56:57--------------------------------------------------- @@ -271,7 +274,7 @@ void SwXTextPortion::setPropertyValue(const OUString& rPropertyName, if (!pUnoCrsr) throw uno::RuntimeException(); - SwXTextCursor::SetPropertyValue(*pUnoCrsr, *m_pPropSet, + SwUnoCursorHelper::SetPropertyValue(*pUnoCrsr, *m_pPropSet, rPropertyName, aValue); } /*-- 04.11.03 09:56:58--------------------------------------------------- @@ -422,7 +425,7 @@ void SwXTextPortion::GetPropertyValue( RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER, 0L); - SwXTextCursor::GetCrsrAttr(*pUnoCrsr, *pSet); + SwUnoCursorHelper::GetCrsrAttr(*pUnoCrsr, *pSet); } m_pPropSet->getPropertyValue(rEntry, *pSet, rVal); } @@ -499,7 +502,7 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl( if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - SwXTextCursor::SetPropertyValue( *pUnoCrsr, *m_pPropSet, + SwUnoCursorHelper::SetPropertyValue( *pUnoCrsr, *m_pPropSet, pPropertyNames[nProp], pValues[nProp]); } } @@ -602,7 +605,7 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXTextPortion::setPr pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO; else { - SwXTextCursor::SetPropertyValue( + SwUnoCursorHelper::SetPropertyValue( *pUnoCrsr, *m_pPropSet, pProp[i], pValue[i] ); } } @@ -679,7 +682,8 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion: const SfxItemPropertyMap* pPropMap = m_pPropSet->getPropertyMap(); - uno::Sequence< beans::PropertyState > aPropertyStates = SwXTextCursor::GetPropertyStates( + uno::Sequence< beans::PropertyState > aPropertyStates = + SwUnoCursorHelper::GetPropertyStates( *pUnoCrsr, *m_pPropSet, rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT ); @@ -828,7 +832,7 @@ beans::PropertyState SwXTextPortion::getPropertyState(const OUString& rPropertyN } else { - eRet = SwXTextCursor::GetPropertyState(*pUnoCrsr, *m_pPropSet, + eRet = SwUnoCursorHelper::GetPropertyState(*pUnoCrsr, *m_pPropSet, rPropertyName); } return eRet; @@ -846,7 +850,7 @@ uno::Sequence< beans::PropertyState > SwXTextPortion::getPropertyStates( throw uno::RuntimeException(); uno::Sequence< beans::PropertyState > aRet = - SwXTextCursor::GetPropertyStates(*pUnoCrsr, *m_pPropSet, + SwUnoCursorHelper::GetPropertyStates(*pUnoCrsr, *m_pPropSet, rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION); if(GetTextPortionType() == PORTION_RUBY_START) @@ -872,7 +876,8 @@ void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName) if (!pUnoCrsr) throw uno::RuntimeException(); - SwXTextCursor::SetPropertyToDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); + SwUnoCursorHelper::SetPropertyToDefault( + *pUnoCrsr, *m_pPropSet, rPropertyName); } /*-- 08.03.99 09:41:48--------------------------------------------------- @@ -886,7 +891,7 @@ uno::Any SwXTextPortion::getPropertyDefault(const OUString& rPropertyName) if (!pUnoCrsr) throw uno::RuntimeException(); - aRet = SwXTextCursor::GetPropertyDefault(*pUnoCrsr, *m_pPropSet, + aRet = SwUnoCursorHelper::GetPropertyDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); return aRet; } diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 6809c389d1..be4befde2f 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -45,13 +45,18 @@ #include <unocrsr.hxx> #include <docary.hxx> #include <tox.hxx> -#include <unoclbck.hxx> -#include <unoobj.hxx> +#include <unomid.h> +#include <unoparaframeenum.hxx> +#include <unocrsrhelper.hxx> +#include <unorefmark.hxx> +#include <unobookmark.hxx> #include <unoredline.hxx> #include <unofield.hxx> #include <unometa.hxx> +#include <fmtmeta.hxx> #include <fmtanchr.hxx> #include <fmtrfmrk.hxx> +#include <frmfmt.hxx> #include <unoidx.hxx> #include <redline.hxx> #include <crsskip.hxx> @@ -94,8 +99,9 @@ namespace BYTE nBkmType; const SwPosition aPosition; - SwXBookmarkPortion_Impl( SwXBookmark* pXMark, BYTE nType, const SwPosition &rPosition ) - : xBookmark ( pXMark ) + SwXBookmarkPortion_Impl(uno::Reference<text::XTextContent> const& xMark, + const BYTE nType, SwPosition const& rPosition) + : xBookmark ( xMark ) , nBkmType ( nType ) , aPosition ( rPosition ) { @@ -159,7 +165,9 @@ namespace { const BYTE nType = hasOther ? BKM_TYPE_START : BKM_TYPE_START_END; rBkmArr.insert(SwXBookmarkPortion_ImplSharedPtr( - new SwXBookmarkPortion_Impl ( SwXBookmarks::GetObject(*pBkmk, &rDoc ), nType, rStartPos))); + new SwXBookmarkPortion_Impl( + SwXBookmark::CreateXBookmark(rDoc, *pBkmk), + nType, rStartPos))); } const SwPosition& rEndPos = pBkmk->GetMarkEnd(); @@ -177,8 +185,12 @@ namespace pEndPos = pCrossRefEndPos.get(); } if(pEndPos) + { rBkmArr.insert(SwXBookmarkPortion_ImplSharedPtr( - new SwXBookmarkPortion_Impl ( SwXBookmarks::GetObject(*pBkmk, &rDoc ), BKM_TYPE_END, *pEndPos))); + new SwXBookmarkPortion_Impl( + SwXBookmark::CreateXBookmark(rDoc, *pBkmk), + BKM_TYPE_END, *pEndPos))); + } } } } @@ -416,9 +428,7 @@ lcl_CreateRefMarkPortion( SwDoc* pDoc = pUnoCrsr->GetDoc(); const SwFmtRefMark& rRefMark = static_cast<const SwFmtRefMark&>(rAttr.GetAttr()); - Reference<XTextContent> xContent = - static_cast<SwUnoCallBack*>(pDoc->GetUnoCallBack()) - ->GetRefMark(rRefMark); + Reference<XTextContent> xContent; if (!xContent.is()) { xContent = new SwXReferenceMark(pDoc, &rRefMark); @@ -458,19 +468,15 @@ static Reference<XTextRange> lcl_CreateTOXMarkPortion( Reference<XText> const& xParent, const SwUnoCrsr * const pUnoCrsr, - const SwTxtAttr & rAttr, const bool bEnd) + SwTxtAttr & rAttr, const bool bEnd) { SwDoc* pDoc = pUnoCrsr->GetDoc(); - const SwTOXMark& rTOXMark = static_cast<const SwTOXMark&>(rAttr.GetAttr()); + SwTOXMark & rTOXMark = static_cast<SwTOXMark&>(rAttr.GetAttr()); - Reference<XTextContent> xContent = - static_cast<SwUnoCallBack*>(pDoc->GetUnoCallBack()) - ->GetTOXMark(rTOXMark); - if (!xContent.is()) - { - xContent = new SwXDocumentIndexMark(rTOXMark.GetTOXType(), - &rTOXMark, pDoc); - } + const Reference<XTextContent> xContent( + SwXDocumentIndexMark::CreateXDocumentIndexMark(*pDoc, + *const_cast<SwTOXType*>(rTOXMark.GetTOXType()), rTOXMark), + uno::UNO_QUERY); SwXTextPortion* pPortion = 0; if (!bEnd) @@ -488,6 +494,33 @@ lcl_CreateTOXMarkPortion( } //----------------------------------------------------------------------------- +static uno::Reference<text::XTextRange> +lcl_CreateMetaPortion( + uno::Reference<text::XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + SwTxtAttr & rAttr, ::std::auto_ptr<TextRangeList_t const> & pPortions) +{ + const uno::Reference<rdf::XMetadatable> xMeta( SwXMeta::CreateXMeta( + *static_cast<SwFmtMeta &>(rAttr.GetAttr()).GetMeta(), + xParent, pPortions)); + SwXTextPortion * pPortion(0); + if (RES_TXTATR_META == rAttr.Which()) + { + const uno::Reference<text::XTextContent> xContent(xMeta, + uno::UNO_QUERY); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_META); + pPortion->SetMeta(xContent); + } + else + { + const uno::Reference<text::XTextField> xField(xMeta, uno::UNO_QUERY); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD); + pPortion->SetTextField(xField); + } + return pPortion; +} + +//----------------------------------------------------------------------------- static void lcl_ExportBookmark( TextRangeList_t & rPortions, @@ -687,30 +720,13 @@ lcl_ExportHints( } else { - TextRangeList_t *const pCurrentPortions(Top.first); + ::std::auto_ptr<const TextRangeList_t> + pCurrentPortions(Top.first); rPortionStack.pop(); - SwXTextPortion * pPortion; - if (RES_TXTATR_META == nWhich) - { - SwXMeta * const pMeta = - new SwXMeta(pDoc, xParent, - pCurrentPortions, - static_cast<SwTxtMeta * const>(pAttr)); - pPortion = new SwXTextPortion( - pUnoCrsr, xParent, PORTION_META); - pPortion->SetMeta(pMeta); - } - else - { - SwXMetaField * const pMeta = - new SwXMetaField(pDoc, xParent, - pCurrentPortions, - static_cast<SwTxtMeta * const>(pAttr)); - pPortion = new SwXTextPortion( - pUnoCrsr, xParent, PORTION_FIELD); - pPortion->SetTextField(pMeta); - } - rPortionStack.top().first->push_back(pPortion); + const uno::Reference<text::XTextRange> xPortion( + lcl_CreateMetaPortion(xParent, pUnoCrsr, + *pAttr, pCurrentPortions)); + rPortionStack.top().first->push_back(xPortion); } } break; @@ -726,7 +742,7 @@ lcl_ExportHints( while(nStartIndex < pHints->GetStartCount() && nCurrentIndex >= (nNextStart = (*pHints->GetStart(nStartIndex)->GetStart()))) { - const SwTxtAttr * const pAttr = pHints->GetStart(nStartIndex); + SwTxtAttr * const pAttr = pHints->GetStart(nStartIndex); USHORT nAttrWhich = pAttr->Which(); if (nNextStart == nCurrentIndex) { @@ -1127,7 +1143,7 @@ lcl_CreatePortions( // text at nCurrentIndex; i.e. it must be set _once_ per iteration uno::Reference< XTextRange > xRef; - SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); // set mark + SwUnoCursorHelper::SelectPam(*pUnoCrsr, true); // set mark const sal_Int32 nFirstFrameIndex = lcl_ExportFrames( *PortionStack.top().first, diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index d3b85ff340..4e7122560f 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -31,24 +31,29 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <com/sun/star/util/DateTime.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <rtl/ustrbuf.hxx> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> + #include <pagedesc.hxx> #include "poolfmt.hxx" #include <redline.hxx> #include <section.hxx> #include <unoprnms.hxx> -#include <unoobj.hxx> +#include <unomid.h> +#include <unotextrange.hxx> +#include <unotextcursor.hxx> +#include <unoparagraph.hxx> #include <unocoll.hxx> #include <unomap.hxx> #include <unocrsr.hxx> #include <unoredline.hxx> #include <doc.hxx> #include <docary.hxx> -#include <rtl/ustrbuf.hxx> -#include <com/sun/star/util/DateTime.hpp> -#include <com/sun/star/text/XTextTable.hpp> + using namespace ::com::sun::star; using ::rtl::OUString; @@ -136,9 +141,9 @@ uno::Reference<text::XTextCursor> SwXRedlineText::createTextCursor(void) vos::OGuard aGuard(Application::GetSolarMutex()); SwPosition aPos(aNodeIndex); - SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, CURSOR_REDLINE, - GetDoc()); - SwUnoCrsr* pUnoCursor = pCrsr->GetCrsr(); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*GetDoc(), this, CURSOR_REDLINE, aPos); + SwUnoCrsr *const pUnoCursor = pXCursor->GetCursor(); pUnoCursor->Move(fnMoveForward, fnGoNode); // #101929# prevent a newly created text cursor from running inside a table @@ -170,7 +175,7 @@ uno::Reference<text::XTextCursor> SwXRedlineText::createTextCursor(void) throw aExcept; } - return (text::XWordCursor*)pCrsr; + return static_cast<text::XWordCursor*>(pXCursor); } /* --------------------------------------------------------------------------- @@ -193,7 +198,9 @@ uno::Reference<container::XEnumeration> SwXRedlineText::createEnumeration(void) vos::OGuard aGuard(Application::GetSolarMutex()); SwPaM aPam(aNodeIndex); aPam.Move(fnMoveForward, fnGoNode); - return new SwXParagraphEnumeration(this, *aPam.Start(), CURSOR_REDLINE); + ::std::auto_ptr<SwUnoCrsr> pUnoCursor( + GetDoc()->CreateUnoCrsr(*aPam.Start(), sal_False)); + return new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_REDLINE); } /* --------------------------------------------------------------------------- @@ -584,11 +591,8 @@ uno::Any SwXRedline::getPropertyValue( const OUString& rPropertyName ) pPoint = pRedline->GetPoint(); else pPoint = pRedline->GetMark(); - SwPaM aTmp(*pPoint); - uno::Reference<text::XText> xTmpParent; -// uno::Reference< text::XTextRange > xRange = SwXTextRange::createTextRangeFromPaM(aTmp); - uno::Reference<text::XTextRange>xRange = - SwXTextRange::CreateTextRangeFromPosition( pDoc, *pPoint, 0 ); + const uno::Reference<text::XTextRange> xRange = + SwXTextRange::CreateXTextRange(*pDoc, *pPoint, 0); xRet = xRange.get(); } break; @@ -676,7 +680,9 @@ uno::Reference< container::XEnumeration > SwXRedline::createEnumeration(void) t { SwPaM aPam(*pNodeIndex); aPam.Move(fnMoveForward, fnGoNode); - xRet = new SwXParagraphEnumeration(this, *aPam.Start(), CURSOR_REDLINE); + ::std::auto_ptr<SwUnoCrsr> pUnoCursor( + GetDoc()->CreateUnoCrsr(*aPam.Start(), sal_False)); + xRet = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_REDLINE); } return xRet; } @@ -710,8 +716,9 @@ uno::Reference< text::XTextCursor > SwXRedline::createTextCursor(void) throw( u if(pNodeIndex) { SwPosition aPos(*pNodeIndex); - SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, CURSOR_REDLINE, pDoc); - SwUnoCrsr* pUnoCrsr = pCrsr->GetCrsr(); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*pDoc, this, CURSOR_REDLINE, aPos); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); pUnoCrsr->Move(fnMoveForward, fnGoNode); //steht hier eine Tabelle? @@ -725,7 +732,7 @@ uno::Reference< text::XTextCursor > SwXRedline::createTextCursor(void) throw( u } if(pCont) pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); - xRet = (text::XWordCursor*)pCrsr; + xRet = static_cast<text::XWordCursor*>(pXCursor); } else { diff --git a/sw/source/core/unocore/unoredlines.cxx b/sw/source/core/unocore/unoredlines.cxx index e70935b55b..05c70eb723 100644 --- a/sw/source/core/unocore/unoredlines.cxx +++ b/sw/source/core/unocore/unoredlines.cxx @@ -31,18 +31,21 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <com/sun/star/beans/XPropertySet.hpp> +#include <tools/debug.hxx> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> + #include <unoredlines.hxx> #include <unoredline.hxx> -#include <tools/debug.hxx> +#include <unomid.h> #include <pagedesc.hxx> #include "poolfmt.hxx" #include <doc.hxx> #include <docary.hxx> #include <redline.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> + using namespace ::com::sun::star; using ::rtl::OUString; diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 752022c763..b3fe08f3a3 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -31,18 +31,23 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <vos/mutex.hxx> #include <vcl/svapp.hxx> -#include <unoobj.hxx> + +#include <unomid.h> +#include <unotextrange.hxx> +#include <unorefmark.hxx> +#include <unotextcursor.hxx> #include <unomap.hxx> #include <unocrsr.hxx> +#include <unoevtlstnr.hxx> #include <doc.hxx> #include <ndtxt.hxx> #include <fmtrfmrk.hxx> #include <txtrfmrk.hxx> #include <hints.hxx> + using namespace ::com::sun::star; using ::rtl::OUString; @@ -50,81 +55,191 @@ using ::rtl::OUString; * SwXReferenceMark ******************************************************************/ -/* -----------------------------13.03.00 12:15-------------------------------- +class SwXReferenceMark::Impl + : public SwClient +{ + +public: + SwEventListenerContainer m_ListenerContainer; + bool m_bIsDescriptor; + SwDoc * m_pDoc; + const SwFmtRefMark * m_pMarkFmt; + ::rtl::OUString m_sMarkName; + + Impl( SwXReferenceMark & rThis, + SwDoc *const pDoc, SwFmtRefMark const*const pRefMark) + : SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIsDescriptor(0 == pRefMark) + , m_pDoc(pDoc) + , m_pMarkFmt(pRefMark) + { + if (pRefMark) + { + m_sMarkName = pRefMark->GetRefName(); + } + } + + bool IsValid() const { return 0 != GetRegisteredIn(); } + void InsertRefMark( SwPaM & rPam, SwXTextCursor const*const pCursor ); + void Invalidate(); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/* -----------------------------07.01.00 12:51-------------------------------- ---------------------------------------------------------------------------*/ -const uno::Sequence< sal_Int8 > & SwXReferenceMark::getUnoTunnelId() +void SwXReferenceMark::Impl::Invalidate() { - static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); - return aSeq; + if (IsValid()) + { + const_cast<SwModify*>(GetRegisteredIn())->Remove(this); + } + m_ListenerContainer.Disposing(); + m_pDoc = 0; + m_pMarkFmt = 0; } -/* -----------------------------10.03.00 18:04-------------------------------- - ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXReferenceMark::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +/*-- 11.12.98 10:28:37--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXReferenceMark::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { - if( rId.getLength() == 16 - && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn()) // removed => dispose { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); + Invalidate(); } + else if (pOld) + { + switch (pOld->Which()) + { + case RES_REFMARK_DELETED: + if (static_cast<const void*>(m_pMarkFmt) == + static_cast<SwPtrMsgPoolItem *>(pOld)->pObject) + { + Invalidate(); + } + break; + } + } +} + + +/*-- 11.12.98 10:28:32--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXReferenceMark::SwXReferenceMark( + SwDoc *const pDoc, SwFmtRefMark const*const pRefMark) + : m_pImpl( new SwXReferenceMark::Impl(*this, pDoc, pRefMark) ) +{ +} + +/*-- 11.12.98 10:28:33--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXReferenceMark::~SwXReferenceMark() +{ +} + +SwXReferenceMark * +SwXReferenceMark::GetReferenceMark( + SwModify const& /*rUnoCB*/, SwFmtRefMark const& /*rMarkFmt*/) +{ + // #i105557#: do not iterate over the registered clients: race condition + // to do this properly requires the SwXReferenceMark to register at the + // SwFmtRefMark directly, not at the unocallback +#if 0 + SwClientIter aIter( rUnoCB ); + SwXReferenceMark::Impl * pXMark = + static_cast<SwXReferenceMark::Impl*>( + aIter.First( TYPE( SwXReferenceMark::Impl ) )); + while (pXMark) + { + if (pXMark->m_pMarkFmt == &rMarkFmt) + { + return &pXMark->m_rThis; + } + pXMark = static_cast<SwXReferenceMark::Impl*>(aIter.Next()); + } +#endif return 0; } -/* -----------------------------06.04.00 16:41-------------------------------- + +SwXReferenceMark * +SwXReferenceMark::CreateXReferenceMark( + SwDoc & rDoc, SwFmtRefMark const& rMarkFmt) +{ + SwXReferenceMark *const pXMark( + GetReferenceMark(*rDoc.GetUnoCallBack(), rMarkFmt) ); + return (pXMark) + ? pXMark + : new SwXReferenceMark(&rDoc, &rMarkFmt); +} + +/* -----------------------------13.03.00 12:15-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXReferenceMark::getImplementationName(void) throw( uno::RuntimeException ) +const uno::Sequence< sal_Int8 > & SwXReferenceMark::getUnoTunnelId() { - return C2U("SwXReferenceMark"); + static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); + return aSeq; } -/* -----------------------------06.04.00 16:41-------------------------------- +/* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXReferenceMark::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +sal_Int64 SAL_CALL +SwXReferenceMark::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - return !rServiceName.compareToAscii("com.sun.star.text.ReferenceMark")|| - !rServiceName.compareToAscii("com.sun.star.text.TextContent"); + return ::sw::UnoTunnelImpl<SwXReferenceMark>(rId, this); } /* -----------------------------06.04.00 16:41-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXReferenceMark::getSupportedServiceNames(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXReferenceMark::getImplementationName() +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(2); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.ReferenceMark"); - pArray[1] = C2U("com.sun.star.text.TextContent"); - return aRet; + return C2U("SwXReferenceMark"); } -/*-- 11.12.98 10:28:32--------------------------------------------------- +/* -----------------------------06.04.00 16:41-------------------------------- - -----------------------------------------------------------------------*/ -TYPEINIT1(SwXReferenceMark, SwClient); + ---------------------------------------------------------------------------*/ +static char const*const g_ServicesReferenceMark[] = +{ + "com.sun.star.text.TextContent", + "com.sun.star.text.ReferenceMark", +}; +static const size_t g_nServicesReferenceMark( + sizeof(g_ServicesReferenceMark)/sizeof(g_ServicesReferenceMark[0])); -SwXReferenceMark::SwXReferenceMark(SwDoc* pDc, const SwFmtRefMark* pRefMark) : - aLstnrCntnr( (text::XTextContent*)this), - pDoc(pDc), - pMark(pRefMark), - m_bIsDescriptor(0 == pRefMark) +sal_Bool SAL_CALL +SwXReferenceMark::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - if(pRefMark) - sMarkName = pRefMark->GetRefName(); - if(pDoc) - pDoc->GetUnoCallBack()->Add(this); + return ::sw::SupportsServiceImpl( + g_nServicesReferenceMark, g_ServicesReferenceMark, rServiceName); } -/*-- 11.12.98 10:28:33--------------------------------------------------- +/* -----------------------------06.04.00 16:41-------------------------------- - -----------------------------------------------------------------------*/ -SwXReferenceMark::~SwXReferenceMark() + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXReferenceMark::getSupportedServiceNames() +throw (uno::RuntimeException) { - + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesReferenceMark, g_ServicesReferenceMark); } + /* -----------------03.11.99 14:14------------------- --------------------------------------------------*/ -void SwXReferenceMark::InsertRefMark(SwPaM& rPam, SwXTextCursor * pCursor) +void SwXReferenceMark::Impl::InsertRefMark(SwPaM& rPam, + SwXTextCursor const*const pCursor) { //! in some cases when this function is called the pDoc pointer member may have become //! invalid/deleted thus we obtain the document pointer from rPaM where it should always @@ -132,12 +247,8 @@ void SwXReferenceMark::InsertRefMark(SwPaM& rPam, SwXTextCursor * pCursor) SwDoc *pDoc2 = rPam.GetDoc(); UnoActionContext aCont(pDoc2); - SwTxtAttr* pTxtAttr = 0; - SwFmtRefMark aRefMark(sMarkName); -// SfxItemSet aSet(pDoc2->GetAttrPool(), RES_TXTATR_REFMARK, RES_TXTATR_REFMARK, 0L); -// aSet.Put(aRefMark); + SwFmtRefMark aRefMark(m_sMarkName); sal_Bool bMark = *rPam.GetPoint() != *rPam.GetMark(); -// SwXTextCursor::SetCrsrAttr(rPam, aSet, 0); const bool bForceExpandHints( (!bMark && pCursor) ? pCursor->IsAtEndOfMeta() : false ); @@ -149,294 +260,314 @@ void SwXReferenceMark::InsertRefMark(SwPaM& rPam, SwXTextCursor * pCursor) pDoc2->InsertPoolItem( rPam, aRefMark, nInsertFlags ); if( bMark && *rPam.GetPoint() > *rPam.GetMark()) - rPam.Exchange(); - - if( bMark ) - pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttr( - rPam.GetPoint()->nContent, RES_TXTATR_REFMARK ); - else { - pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( - rPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_REFMARK ); + rPam.Exchange(); } + SwTxtAttr *const pTxtAttr = (bMark) + ? rPam.GetNode()->GetTxtNode()->GetTxtAttr( + rPam.GetPoint()->nContent, RES_TXTATR_REFMARK) + : rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( + rPam.GetPoint()->nContent.GetIndex() - 1, RES_TXTATR_REFMARK); + if(pTxtAttr) - pMark = &pTxtAttr->GetRefMark(); + { + m_pMarkFmt = &pTxtAttr->GetRefMark(); + } pDoc2->GetUnoCallBack()->Add(this); } -/* -----------------18.02.99 13:33------------------- - * - * --------------------------------------------------*/ -void SwXReferenceMark::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +/*-- 11.12.98 10:28:34--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SAL_CALL +SwXReferenceMark::attach(const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - if(!m_bIsDescriptor) + vos::OGuard aGuard(Application::GetSolarMutex()); + + if (!m_pImpl->m_bIsDescriptor) + { throw uno::RuntimeException(); + } uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; OTextCursorHelper* pCursor = 0; if(xRangeTunnel.is()) { - 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()) )); + pRange = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel); } - SwDoc* pDocument = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; - if(pDocument) + SwDoc *const pDocument = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pDocument) { - SwUnoInternalPaM aPam(*pDocument); - //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); - InsertRefMark(aPam, dynamic_cast<SwXTextCursor*>(pCursor)); - m_bIsDescriptor = sal_False; - pDoc = pDocument; - pDoc->GetUnoCallBack()->Add(this); - } - else throw lang::IllegalArgumentException(); -} -/*-- 11.12.98 10:28:34--------------------------------------------------- + } - -----------------------------------------------------------------------*/ -void SwXReferenceMark::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - attachToRange( xTextRange ); + SwUnoInternalPaM aPam(*pDocument); + //das muss jetzt sal_True liefern + ::sw::XTextRangeToSwPaM(aPam, xTextRange); + m_pImpl->InsertRefMark(aPam, dynamic_cast<SwXTextCursor*>(pCursor)); + m_pImpl->m_bIsDescriptor = sal_False; + m_pImpl->m_pDoc = pDocument; + m_pImpl->m_pDoc->GetUnoCallBack()->Add(m_pImpl.get()); } + /*-- 11.12.98 10:28:34--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXReferenceMark::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXReferenceMark::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextRange > xRet; - if(IsValid()) + + if (m_pImpl->IsValid()) { - const SwFmtRefMark* pNewMark = pDoc->GetRefMark(sMarkName); - if(pNewMark && pNewMark == pMark) + SwFmtRefMark const*const pNewMark = + m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName); + if (pNewMark && (pNewMark == m_pImpl->m_pMarkFmt)) { - const SwTxtRefMark* pTxtMark = pMark->GetTxtRefMark(); - if(pTxtMark && - &pTxtMark->GetTxtNode().GetNodes() == &pDoc->GetNodes()) + SwTxtRefMark const*const pTxtMark = + m_pImpl->m_pMarkFmt->GetTxtRefMark(); + if (pTxtMark && + (&pTxtMark->GetTxtNode().GetNodes() == + &m_pImpl->m_pDoc->GetNodes())) { - SwTxtNode& rTxtNode = (SwTxtNode&)pTxtMark->GetTxtNode(); - SwPaM* pPam = pTxtMark->GetEnd() ? - new SwPaM( rTxtNode, *pTxtMark->GetEnd(), - rTxtNode, *pTxtMark->GetStart()) : - new SwPaM( rTxtNode, *pTxtMark->GetStart()); - - - xRet = SwXTextRange::CreateTextRangeFromPosition(pDoc, - *pPam->Start(), pPam->End()); - delete pPam; + SwTxtNode const& rTxtNode = pTxtMark->GetTxtNode(); + const ::std::auto_ptr<SwPaM> pPam( (pTxtMark->GetEnd()) + ? new SwPaM( rTxtNode, *pTxtMark->GetEnd(), + rTxtNode, *pTxtMark->GetStart()) + : new SwPaM( rTxtNode, *pTxtMark->GetStart()) ); + + return SwXTextRange::CreateXTextRange( + *m_pImpl->m_pDoc, *pPam->Start(), pPam->End()); } } } - return xRet; + return 0; } /*-- 11.12.98 10:28:35--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL SwXReferenceMark::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(IsValid()) + if (m_pImpl->IsValid()) { - const SwFmtRefMark* pNewMark = pDoc->GetRefMark(sMarkName); - if(pNewMark && pNewMark == pMark) + SwFmtRefMark const*const pNewMark = + m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName); + if (pNewMark && (pNewMark == m_pImpl->m_pMarkFmt)) { - const SwTxtRefMark* pTxtMark = pMark->GetTxtRefMark(); - if(pTxtMark && - &pTxtMark->GetTxtNode().GetNodes() == &pDoc->GetNodes()) + SwTxtRefMark const*const pTxtMark = + m_pImpl->m_pMarkFmt->GetTxtRefMark(); + if (pTxtMark && + (&pTxtMark->GetTxtNode().GetNodes() == + &m_pImpl->m_pDoc->GetNodes())) { - SwTxtNode& rTxtNode = (SwTxtNode&)pTxtMark->GetTxtNode(); + SwTxtNode const& rTxtNode = pTxtMark->GetTxtNode(); xub_StrLen nStt = *pTxtMark->GetStart(), nEnd = pTxtMark->GetEnd() ? *pTxtMark->GetEnd() : nStt + 1; SwPaM aPam( rTxtNode, nStt, rTxtNode, nEnd ); - pDoc->DeleteAndJoin( aPam ); + m_pImpl->m_pDoc->DeleteAndJoin( aPam ); } } } - else - throw uno::RuntimeException(); + else if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->Invalidate(); + } } /*-- 11.12.98 10:28:35--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXReferenceMark::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->IsValid()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 11.12.98 10:28:35--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) +void SAL_CALL SwXReferenceMark::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->IsValid() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } /*-- 11.12.98 10:28:36--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXReferenceMark::getName(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXReferenceMark::getName() +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid() || !pDoc->GetRefMark(sMarkName)) + if (!m_pImpl->IsValid() || + !m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName)) { throw uno::RuntimeException(); } - return sMarkName; + return m_pImpl->m_sMarkName; } /*-- 11.12.98 10:28:36--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::setName(const OUString& Name_) throw( uno::RuntimeException ) +void SAL_CALL SwXReferenceMark::setName(const OUString& rName) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(m_bIsDescriptor) - sMarkName = String(Name_); + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_sMarkName = rName; + } else { - String sNewName(Name_); - if(!IsValid() || !pDoc->GetRefMark(sMarkName) || pDoc->GetRefMark(sNewName)) + if (!m_pImpl->IsValid() + || !m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName) + || m_pImpl->m_pDoc->GetRefMark(rName)) { throw uno::RuntimeException(); } - const SwFmtRefMark* pCurMark = pDoc->GetRefMark(sMarkName); - if(sNewName != sMarkName && pCurMark && pCurMark == pMark) + SwFmtRefMark const*const pCurMark = + m_pImpl->m_pDoc->GetRefMark(m_pImpl->m_sMarkName); + if ((rName != m_pImpl->m_sMarkName) + && pCurMark && (pCurMark == m_pImpl->m_pMarkFmt)) { - UnoActionContext aCont(pDoc); - const SwTxtRefMark* pTxtMark = pMark->GetTxtRefMark(); - if(pTxtMark && - &pTxtMark->GetTxtNode().GetNodes() == &pDoc->GetNodes()) + const UnoActionContext aCont(m_pImpl->m_pDoc); + SwTxtRefMark const*const pTxtMark = + m_pImpl->m_pMarkFmt->GetTxtRefMark(); + if (pTxtMark && + (&pTxtMark->GetTxtNode().GetNodes() == + &m_pImpl->m_pDoc->GetNodes())) { - SwTxtNode& rTxtNode = (SwTxtNode&)pTxtMark->GetTxtNode(); + SwTxtNode const& rTxtNode = pTxtMark->GetTxtNode(); xub_StrLen nStt = *pTxtMark->GetStart(), nEnd = pTxtMark->GetEnd() ? *pTxtMark->GetEnd() : nStt + 1; SwPaM aPam( rTxtNode, nStt, rTxtNode, nEnd ); - pDoc->DeleteAndJoin( aPam ); //! deletes the pDoc member in the SwXReferenceMark - //! The aPam will keep the correct and functional doc though + // deletes the m_pImpl->m_pDoc member in the SwXReferenceMark! + m_pImpl->m_pDoc->DeleteAndJoin( aPam ); + // The aPam will keep the correct and functional doc though - sMarkName = sNewName; + m_pImpl->m_sMarkName = rName; //create a new one - InsertRefMark( aPam, 0 ); - pDoc = aPam.GetDoc(); + m_pImpl->InsertRefMark( aPam, 0 ); + m_pImpl->m_pDoc = aPam.GetDoc(); } } } } -/* -----------------------------07.01.00 12:51-------------------------------- - - ---------------------------------------------------------------------------*/ -void SwXReferenceMark::Invalidate() -{ - if(GetRegisteredIn()) - { - ((SwModify*)GetRegisteredIn())->Remove(this); - aLstnrCntnr.Disposing(); - pDoc = 0; - pMark = 0; - } -} -/*-- 11.12.98 10:28:37--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXReferenceMark::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - switch( pOld ? pOld->Which() : 0 ) - { - case RES_REMOVE_UNO_OBJECT: - case RES_OBJECTDYING: - if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - case RES_FMT_CHG: - // wurden wir an das neue umgehaengt und wird das alte geloscht? - if( ((SwFmtChg*)pNew)->pChangedFmt == GetRegisteredIn() && - ((SwFmtChg*)pOld)->pChangedFmt->IsFmtInDTOR() ) - Invalidate(); - break; - case RES_REFMARK_DELETED: - if( (void*)pMark == ((SwPtrMsgPoolItem *)pOld)->pObject ) - Invalidate(); - break; - } -} /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXReferenceMark::getPropertySetInfo( ) throw(uno::RuntimeException) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXReferenceMark::getPropertySetInfo() throw (uno::RuntimeException) { + vos::OGuard g(Application::GetSolarMutex()); + static uno::Reference< beans::XPropertySetInfo > xRef = - aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH_EXTENSIONS)->getPropertySetInfo(); + aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH_EXTENSIONS) + ->getPropertySetInfo(); return xRef; } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::setPropertyValue( +void SAL_CALL SwXReferenceMark::setPropertyValue( const OUString& /*rPropertyName*/, const uno::Any& /*rValue*/ ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { throw lang::IllegalArgumentException(); } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXReferenceMark::getPropertyValue( const OUString& rPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +uno::Any SAL_CALL +SwXReferenceMark::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + // does not seem to need SolarMutex uno::Any aRet; - if(!SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) + if (! ::sw::GetDefaultTextContentValue(aRet, rPropertyName)) + { throw beans::UnknownPropertyException(); + } return aRet; } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::addPropertyChangeListener( - const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL SwXReferenceMark::addPropertyChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXReferenceMark::addPropertyChangeListener(): not implemented"); } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::removePropertyChangeListener( - const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL SwXReferenceMark::removePropertyChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXReferenceMark::removePropertyChangeListener(): not implemented"); } /*-- 12.09.00 12:58:20--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::addVetoableChangeListener( const OUString& /*rPropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL SwXReferenceMark::addVetoableChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXReferenceMark::addVetoableChangeListener(): not implemented"); } /*-- 12.09.00 12:58:21--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXReferenceMark::removeVetoableChangeListener( - const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +void SAL_CALL SwXReferenceMark::removeVetoableChangeListener( + const OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { + OSL_ENSURE(false, + "SwXReferenceMark::removeVetoableChangeListener(): not implemented"); } #include <com/sun/star/lang/DisposedException.hpp> #include <unometa.hxx> +#include <unotext.hxx> #include <unoport.hxx> #include <txtatr.hxx> #include <fmtmeta.hxx> @@ -455,21 +586,22 @@ private: SwXMeta & m_rMeta; virtual void PrepareForAttach(uno::Reference< text::XTextRange > & xRange, - const SwXTextRange* const pRange, const SwPaM * const pPam); + const SwPaM & rPam); - virtual bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); + virtual bool CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) + throw (lang::IllegalArgumentException, uno::RuntimeException); protected: virtual const SwStartNode *GetStartNode() const; virtual uno::Reference< text::XTextCursor > - createCursor() throw (uno::RuntimeException); + CreateCursor() throw (uno::RuntimeException); public: SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta); + /// make available for SwXMeta + void Invalidate() { SwXText::Invalidate(); }; + // XInterface virtual void SAL_CALL acquire() throw() { OSL_ENSURE(false, "ERROR: SwXMetaText::acquire"); } @@ -488,6 +620,8 @@ public: const uno::Reference< text::XTextRange > & xTextPosition) throw (uno::RuntimeException); + SwXMeta & GetXMeta() { return m_rMeta; } + }; SwXMetaText::SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta) @@ -504,44 +638,21 @@ const SwStartNode *SwXMetaText::GetStartNode() const } void SwXMetaText::PrepareForAttach( uno::Reference<text::XTextRange> & xRange, - const SwXTextRange* const pRange, const SwPaM * const pPam) + const SwPaM & rPam) { - SwPosition const* pPoint(0); - SwPosition const* pMark (0); - if (pRange) - { - ::sw::mark::IMark const& rIMark(*pRange->GetBookmark()); - pMark = &rIMark.GetMarkPos(); - if (rIMark.IsExpanded()) - { - pMark = &rIMark.GetOtherMarkPos(); - } - } - else if (pPam) - { - pPoint = pPam->GetPoint(); - if (pPam->HasMark()) - { - pMark = pPam->GetMark(); - } - } // create a new cursor to prevent modifying SwXTextRange - if (pPoint) - { - xRange = static_cast<text::XWordCursor*>( - new SwXTextCursor(&m_rMeta, *pPoint, CURSOR_META, GetDoc(), pMark)); - } + xRange = static_cast<text::XWordCursor*>( + new SwXTextCursor(*GetDoc(), &m_rMeta, CURSOR_META, *rPam.GetPoint(), + (rPam.HasMark()) ? rPam.GetMark() : 0)); } -bool SwXMetaText::CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) +bool SwXMetaText::CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) + throw (lang::IllegalArgumentException, uno::RuntimeException) { - return m_rMeta.CheckForOwnMemberMeta(pRange, pPam, bAbsorb); + return m_rMeta.CheckForOwnMemberMeta(rPam, bAbsorb); } -uno::Reference< text::XTextCursor > SwXMetaText::createCursor() +uno::Reference< text::XTextCursor > SwXMetaText::CreateCursor() throw (uno::RuntimeException) { uno::Reference< text::XTextCursor > xRet; @@ -556,7 +667,7 @@ throw (uno::RuntimeException) { SwPosition aPos(*pTxtNode, nMetaStart); xRet = static_cast<text::XWordCursor*>( - new SwXTextCursor(&m_rMeta, aPos, CURSOR_META, GetDoc())); + new SwXTextCursor(*GetDoc(), &m_rMeta, CURSOR_META, aPos)); } } return xRet; @@ -572,7 +683,7 @@ SwXMetaText::getImplementationId() throw (uno::RuntimeException) uno::Reference< text::XTextCursor > SAL_CALL SwXMetaText::createTextCursor() throw (uno::RuntimeException) { - return createCursor(); + return CreateCursor(); } uno::Reference< text::XTextCursor > SAL_CALL @@ -580,7 +691,7 @@ SwXMetaText::createTextCursorByRange( const uno::Reference<text::XTextRange> & xTextPosition) throw (uno::RuntimeException) { - const uno::Reference<text::XTextCursor> xCursor( createCursor() ); + const uno::Reference<text::XTextCursor> xCursor( CreateCursor() ); xCursor->gotoRange(xTextPosition, sal_False); return xCursor; } @@ -593,8 +704,12 @@ SwXMetaText::createTextCursorByRange( // this list is created by SwXTextPortionEnumeration // the Meta listens at the SwTxtNode and throws away the cache when it changes -struct SwXMeta::Impl +class SwXMeta::Impl + : public SwClient { + +public: + SwEventListenerContainer m_ListenerContainer; ::std::auto_ptr<const TextRangeList_t> m_pTextPortions; // 3 possible states: not attached, attached, disposed @@ -603,37 +718,131 @@ struct SwXMeta::Impl uno::Reference<text::XText> m_xParentText; SwXMetaText m_Text; - Impl(SwXMeta & rThis, SwDoc & rDoc, + Impl( SwXMeta & rThis, SwDoc & rDoc, + ::sw::Meta * const pMeta, uno::Reference<text::XText> const& xParentText, - TextRangeList_t const * const pPortions, - SwTxtMeta const * const pHint) - : m_ListenerContainer( - static_cast< ::cppu::OWeakObject* >(&rThis)) + TextRangeList_t const * const pPortions) + : SwClient(pMeta) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) , m_pTextPortions( pPortions ) , m_bIsDisposed( false ) - , m_bIsDescriptor( 0 == pHint ) + , m_bIsDescriptor(0 == pMeta) , m_xParentText(xParentText) , m_Text(rDoc, rThis) { } -}; -TYPEINIT1(SwXMeta, SwClient); + inline const ::sw::Meta * GetMeta() const; + // only for SwXMetaField! + inline const ::sw::MetaField * GetMetaField() const; -inline const ::sw::Meta * SwXMeta::GetMeta() const + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +inline const ::sw::Meta * SwXMeta::Impl::GetMeta() const { return static_cast< const ::sw::Meta * >(GetRegisteredIn()); } +// SwModify +void SwXMeta::Impl::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) +{ + m_pTextPortions.reset(); // throw away cache (SwTxtNode changed) + + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn()) // removed => dispose + { + m_ListenerContainer.Disposing(); + m_bIsDisposed = true; + m_Text.Invalidate(); + } +} + uno::Reference<text::XText> SwXMeta::GetParentText() const { return m_pImpl->m_xParentText; } +SwXMeta::SwXMeta(SwDoc *const pDoc, ::sw::Meta *const pMeta, + uno::Reference<text::XText> const& xParentText, + TextRangeList_t const*const pPortions) + : m_pImpl( new SwXMeta::Impl(*this, *pDoc, pMeta, xParentText, pPortions) ) +{ +} + +SwXMeta::SwXMeta(SwDoc *const pDoc) + : m_pImpl( new SwXMeta::Impl(*this, *pDoc, 0, 0, 0) ) +{ +} + +SwXMeta::~SwXMeta() +{ +} + +uno::Reference<rdf::XMetadatable> +SwXMeta::CreateXMeta(::sw::Meta & rMeta, + uno::Reference<text::XText> const& i_xParent, + ::std::auto_ptr<TextRangeList_t const> pPortions) +{ + // re-use existing SwXMeta + // #i105557#: do not iterate over the registered clients: race condition + uno::Reference<rdf::XMetadatable> xMeta(rMeta.GetXMeta()); + if (xMeta.is()) + { + if (pPortions.get()) // set cache in the XMeta to the given portions + { + const uno::Reference<lang::XUnoTunnel> xUT(xMeta, uno::UNO_QUERY); + SwXMeta *const pXMeta( + ::sw::UnoTunnelGetImplementation<SwXMeta>(xUT)); + OSL_ENSURE(pXMeta, "no pXMeta?"); + // NB: the meta must always be created with the complete content + // if SwXTextPortionEnumeration is created for a selection, + // it must be checked that the Meta is contained in the selection! + pXMeta->m_pImpl->m_pTextPortions = pPortions; + // ??? is this necessary? + if (pXMeta->m_pImpl->m_xParentText.get() != i_xParent.get()) + { + OSL_ENSURE(false, "SwXMeta with different parent?"); + pXMeta->m_pImpl->m_xParentText.set(i_xParent); + } + } + return xMeta; + } + + // create new SwXMeta + SwTxtNode * const pTxtNode( rMeta.GetTxtNode() ); + OSL_ENSURE(pTxtNode, "CreateXMeta: no text node?"); + if (!pTxtNode) { return 0; } + uno::Reference<text::XText> xParentText(i_xParent); + if (!xParentText.is()) + { + SwTxtMeta * const pTxtAttr( rMeta.GetTxtAttr() ); + OSL_ENSURE(pTxtAttr, "CreateXMeta: no text attr?"); + if (!pTxtAttr) { return 0; } + const SwPosition aPos(*pTxtNode, *pTxtAttr->GetStart()); + xParentText.set( ::sw::CreateParentXText(*pTxtNode->GetDoc(), aPos) ); + } + if (!xParentText.is()) { return 0; } + SwXMeta *const pXMeta( (RES_TXTATR_META == rMeta.GetFmtMeta()->Which()) + ? new SwXMeta (pTxtNode->GetDoc(), &rMeta, xParentText, + pPortions.release()) // temporarily un-auto_ptr :-( + : new SwXMetaField(pTxtNode->GetDoc(), &rMeta, xParentText, + pPortions.release())); + // this is why the constructor is private: need to acquire pXMeta here + xMeta.set(pXMeta); + // in order to initialize the weak pointer cache in the core object + rMeta.SetXMeta(xMeta); + return xMeta; +} + + bool SwXMeta::SetContentRange( SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd ) const { - ::sw::Meta const * const pMeta( GetMeta() ); + ::sw::Meta const * const pMeta( m_pImpl->GetMeta() ); if (pMeta) { SwTxtMeta const * const pTxtAttr( pMeta->GetTxtAttr() ); @@ -652,28 +861,9 @@ bool SwXMeta::SetContentRange( return false; } -SwXMeta::SwXMeta(SwDoc *const pDoc, - uno::Reference<text::XText> const& xParentText, - TextRangeList_t * const pPortions, SwTxtMeta * const pHint) - : m_pImpl( new SwXMeta::Impl(*this, *pDoc, xParentText, pPortions, pHint) ) -{ - if (pHint) - { - ::sw::Meta * const pMeta( - static_cast<SwFmtMeta&>(pHint->GetAttr()).GetMeta() ); - ASSERT(pMeta, "SwXMeta: no meta?") - if (pMeta) - { - pMeta->Add(this); - } - } -} - -bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, - const SwPaM* const pPam, bool bAbsorb) +bool SwXMeta::CheckForOwnMemberMeta(const SwPaM & rPam, const bool bAbsorb) throw (lang::IllegalArgumentException, uno::RuntimeException) { - ASSERT((pPam && !pRange) || (!pPam && pRange), "ERROR: pam xor range"); SwTxtNode * pTxtNode; xub_StrLen nMetaStart; xub_StrLen nMetaEnd; @@ -681,9 +871,8 @@ bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, ASSERT(bSuccess, "no pam?"); if (!bSuccess) throw lang::DisposedException(); - SwPosition const * const pStartPos( (pPam) - ? pPam->Start() - : &pRange->GetBookmark()->GetMarkStart() ); + + SwPosition const * const pStartPos( rPam.Start() ); if (&pStartPos->nNode.GetNode() != pTxtNode) { throw lang::IllegalArgumentException( @@ -706,14 +895,9 @@ bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, { bForceExpandHints = true; } - const bool bHasEnd( (pPam) - ? pPam->HasMark() - : pRange->GetBookmark()->IsExpanded()); - if (bHasEnd && bAbsorb) + if (rPam.HasMark() && bAbsorb) { - SwPosition const * const pEndPos( (pPam) - ? pPam->End() - : &pRange->GetBookmark()->GetMarkEnd() ); + SwPosition const * const pEndPos( rPam.End() ); if (&pEndPos->nNode.GetNode() != pTxtNode) { throw lang::IllegalArgumentException( @@ -739,16 +923,6 @@ bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, return bForceExpandHints; } - -SwXMeta::SwXMeta(SwDoc *const pDoc) - : m_pImpl( new SwXMeta::Impl(*this, *pDoc, 0, 0, 0) ) -{ -} - -SwXMeta::~SwXMeta() -{ -} - const uno::Sequence< sal_Int8 > & SwXMeta::getUnoTunnelId() { static uno::Sequence< sal_Int8 > aSeq( ::CreateUnoTunnelId() ); @@ -760,14 +934,7 @@ sal_Int64 SAL_CALL SwXMeta::getSomething( const uno::Sequence< sal_Int8 > & i_rId ) throw (uno::RuntimeException) { - if ( i_rId.getLength() == 16 && - 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - i_rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( - reinterpret_cast< sal_IntPtr >(this) ); - } - return 0; + return ::sw::UnoTunnelImpl<SwXMeta>(i_rId, this); } // XServiceInfo @@ -777,21 +944,26 @@ SwXMeta::getImplementationName() throw (uno::RuntimeException) return C2U("SwXMeta"); } +static char const*const g_ServicesMeta[] = +{ + "com.sun.star.text.TextContent", + "com.sun.star.text.InContentMetadata", +}; +static const size_t g_nServicesMeta( + sizeof(g_ServicesMeta)/sizeof(g_ServicesMeta[0])); + sal_Bool SAL_CALL SwXMeta::supportsService(const ::rtl::OUString& rServiceName) throw (uno::RuntimeException) { - return rServiceName.equalsAscii("com.sun.star.text.TextContent") - || rServiceName.equalsAscii("com.sun.star.text.InContentMetadata"); + return ::sw::SupportsServiceImpl( + g_nServicesMeta, g_ServicesMeta, rServiceName); } uno::Sequence< ::rtl::OUString > SAL_CALL SwXMeta::getSupportedServiceNames() throw (uno::RuntimeException) { - uno::Sequence< ::rtl::OUString > aRet(2); - aRet[0] = C2U("com.sun.star.text.TextContent"); - aRet[1] = C2U("com.sun.star.text.InContentMetadata"); - return aRet; + return ::sw::GetSupportedServiceNamesImpl(g_nServicesMeta, g_ServicesMeta); } @@ -881,14 +1053,10 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) C2S("SwXMeta::attach(): argument is no XUnoTunnel"), static_cast< ::cppu::OWeakObject* >(this), 0); } - SwXTextRange * const pRange( - reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( - SwXTextRange::getUnoTunnelId() ))) ); - OTextCursorHelper * const pCursor( pRange ? 0 : - reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( - OTextCursorHelper::getUnoTunnelId() ))) ); + SwXTextRange *const pRange( + ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel)); + OTextCursorHelper *const pCursor( (pRange) ? 0 : + ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel)); if (!pRange && !pCursor) { throw lang::IllegalArgumentException( @@ -906,7 +1074,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) } SwUnoInternalPaM aPam(*pDoc); - SwXTextRange::XTextRangeToSwPaM(aPam, i_xTextRange); + ::sw::XTextRangeToSwPaM(aPam, i_xTextRange); UnoActionContext aContext(pDoc); @@ -940,10 +1108,10 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) static_cast< ::cppu::OWeakObject* >(this)); } - pMeta->Add(this); + pMeta->Add(m_pImpl.get()); + pMeta->SetXMeta(uno::Reference<rdf::XMetadatable>(this)); - m_pImpl->m_xParentText = - SwXTextRange::CreateParentXText(pDoc, *aPam.GetPoint()); + m_pImpl->m_xParentText = ::sw::CreateParentXText(*pDoc, *aPam.GetPoint()); m_pImpl->m_bIsDescriptor = false; } @@ -986,8 +1154,7 @@ SwXMeta::getAnchor() throw (uno::RuntimeException) const SwPosition start(*pTxtNode, nMetaStart - 1); // -1 due to CH_TXTATR const SwPosition end(*pTxtNode, nMetaEnd); - return SwXTextRange::CreateTextRangeFromPosition( - pTxtNode->GetDoc(), start, &end); + return SwXTextRange::CreateXTextRange(*pTxtNode->GetDoc(), start, &end); } // XTextRange @@ -1097,7 +1264,7 @@ SwXMeta::hasElements() throw (uno::RuntimeException) { vos::OGuard g(Application::GetSolarMutex()); - return GetRegisteredIn() ? sal_True : sal_False; + return m_pImpl->GetRegisteredIn() ? sal_True : sal_False; } // XEnumerationAccess @@ -1113,7 +1280,7 @@ SwXMeta::createEnumeration() throw (uno::RuntimeException) if (m_pImpl->m_bIsDescriptor) { throw uno::RuntimeException( - C2S("getAnchor(): not inserted"), + C2S("createEnumeration(): not inserted"), static_cast< ::cppu::OWeakObject* >(this)); } @@ -1142,12 +1309,12 @@ SwXMeta::createEnumeration() throw (uno::RuntimeException) // MetadatableMixin ::sfx2::Metadatable* SwXMeta::GetCoreObject() { - return const_cast< ::sw::Meta * >(GetMeta()); + return const_cast< ::sw::Meta * >(m_pImpl->GetMeta()); } uno::Reference<frame::XModel> SwXMeta::GetModel() { - ::sw::Meta const * const pMeta( GetMeta() ); + ::sw::Meta const * const pMeta( m_pImpl->GetMeta() ); if (pMeta) { SwTxtNode const * const pTxtNode( pMeta->GetTxtNode() ); @@ -1160,42 +1327,27 @@ uno::Reference<frame::XModel> SwXMeta::GetModel() return 0; } -// SwModify -void SwXMeta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) -{ - m_pImpl->m_pTextPortions.reset(); // throw away cache (SwTxtNode changed) - - ClientModify(this, pOld, pNew); - - if (!GetRegisteredIn()) // removed => dispose - { - m_pImpl->m_ListenerContainer.Disposing(); - m_pImpl->m_bIsDisposed = true; - m_pImpl->m_Text.Invalidate(); - } -} - /****************************************************************** * SwXMetaField ******************************************************************/ -inline const ::sw::MetaField * SwXMetaField::GetMetaField() const +inline const ::sw::MetaField * SwXMeta::Impl::GetMetaField() const { return static_cast< const ::sw::MetaField * >(GetRegisteredIn()); } -SwXMetaField::SwXMetaField(SwDoc *const pDoc, +SwXMetaField::SwXMetaField(SwDoc *const pDoc, ::sw::Meta *const pMeta, uno::Reference<text::XText> const& xParentText, - TextRangeList_t * const pPortions, SwTxtMeta * const pHint) - : SwXMetaFieldBaseClass(pDoc, xParentText, pPortions, pHint) + TextRangeList_t const*const pPortions) + : SwXMetaField_Base(pDoc, pMeta, xParentText, pPortions) { - ASSERT(!pHint || RES_TXTATR_METAFIELD == pHint->Which(), + ASSERT(pMeta && dynamic_cast< ::sw::MetaField* >(pMeta), "SwXMetaField created for wrong hint!"); } SwXMetaField::SwXMetaField(SwDoc *const pDoc) - : SwXMetaFieldBaseClass(pDoc) + : SwXMetaField_Base(pDoc) { } @@ -1210,23 +1362,28 @@ SwXMetaField::getImplementationName() throw (uno::RuntimeException) return C2U("SwXMetaField"); } +static char const*const g_ServicesMetaField[] = +{ + "com.sun.star.text.TextContent", + "com.sun.star.text.TextField", + "com.sun.star.text.textfield.MetadataField", +}; +static const size_t g_nServicesMetaField( + sizeof(g_ServicesMetaField)/sizeof(g_ServicesMetaField[0])); + sal_Bool SAL_CALL SwXMetaField::supportsService(const ::rtl::OUString& rServiceName) throw (uno::RuntimeException) { - return rServiceName.equalsAscii("com.sun.star.text.TextContent") - || rServiceName.equalsAscii("com.sun.star.text.TextField") - || rServiceName.equalsAscii("com.sun.star.text.textfield.MetadataField"); + return ::sw::SupportsServiceImpl( + g_nServicesMetaField, g_ServicesMetaField, rServiceName); } uno::Sequence< ::rtl::OUString > SAL_CALL SwXMetaField::getSupportedServiceNames() throw (uno::RuntimeException) { - uno::Sequence< ::rtl::OUString > aRet(3); - aRet[0] = C2U("com.sun.star.text.TextContent"); - aRet[1] = C2U("com.sun.star.text.TextField"); - aRet[2] = C2U("com.sun.star.text.textfield.MetadataField"); - return aRet; + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesMetaField, g_ServicesMetaField); } // XComponent @@ -1288,7 +1445,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, vos::OGuard g(Application::GetSolarMutex()); ::sw::MetaField * const pMeta( - const_cast< ::sw::MetaField * >(GetMetaField()) ); + const_cast< ::sw::MetaField * >(m_pImpl->GetMetaField()) ); if (!pMeta) throw lang::DisposedException(); @@ -1321,7 +1478,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, { vos::OGuard g(Application::GetSolarMutex()); - ::sw::MetaField const * const pMeta( GetMetaField() ); + ::sw::MetaField const * const pMeta( m_pImpl->GetMetaField() ); if (!pMeta) throw lang::DisposedException(); diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index a78d27225a..d4ab7f0813 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -31,31 +31,29 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/text/SectionFileLink.hpp> #include <cmdid.h> #include <hintids.hxx> #include <svl/urihelper.hxx> #include <svx/brshitem.hxx> -#ifndef _SVX_XMLCNITEM_HXX #include <svx/xmlcnitm.hxx> -#endif #include <sfx2/linkmgr.hxx> #include <sfx2/lnkbase.hxx> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> #include <fmtclds.hxx> -#include <unoobj.hxx> +#include <unotextrange.hxx> +#include <unosection.hxx> +#include <TextCursorHelper.hxx> #include <unoredline.hxx> #include <redline.hxx> #include <unomap.hxx> #include <unocrsr.hxx> #include <section.hxx> #include <doc.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <sfx2/docfile.hxx> #include <docary.hxx> #include <swundo.hxx> @@ -65,189 +63,178 @@ #include <doctxm.hxx> #include <fmtftntx.hxx> #include <fmtclbl.hxx> -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_ -#include <com/sun/star/beans/PropertyAttribute.hpp> -#endif +#include <fmtcntnt.hxx> #include <svx/frmdiritem.hxx> /* #109700# */ #include <svx/lrspitem.hxx> + using namespace ::com::sun::star; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::text; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; using ::rtl::OUString; -TYPEINIT1(SwXTextSectionClient, SwClient); -/*-- 20.12.2005 09:56:33--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXTextSectionClient::SwXTextSectionClient( - SwSectionFmt& rFmt, - SwXTextSection& rTextSection, - uno::Reference< text::XTextSection > xSection ) : - SwClient(&rFmt), - m_pSection( &rTextSection ), - m_xReference( xSection ) +/****************************************************************** + * + ******************************************************************/ +struct SwTextSectionProperties_Impl { - m_pSection->SetClient( this ); -} -/*-- 20.12.2005 09:56:33--------------------------------------------------- + uno::Sequence<sal_Int8> m_Password; + ::rtl::OUString m_sCondition; + ::rtl::OUString m_sLinkFileName; + ::rtl::OUString m_sSectionFilter; + ::rtl::OUString m_sSectionRegion; + + ::std::auto_ptr<SwFmtCol> m_pColItem; + ::std::auto_ptr<SvxBrushItem> m_pBrushItem; + ::std::auto_ptr<SwFmtFtnAtTxtEnd> m_pFtnItem; + ::std::auto_ptr<SwFmtEndAtTxtEnd> m_pEndItem; + ::std::auto_ptr<SvXMLAttrContainerItem> m_pXMLAttr; + ::std::auto_ptr<SwFmtNoBalancedColumns> m_pNoBalanceItem; + ::std::auto_ptr<SvxFrameDirectionItem> m_pFrameDirItem; + ::std::auto_ptr<SvxLRSpaceItem> m_pLRSpaceItem; // #109700# + + bool m_bDDE; + bool m_bHidden; + bool m_bCondHidden; + bool m_bProtect; + // --> FME 2004-06-22 #114856# edit in readonly sections + bool m_bEditInReadonly; + // <-- + bool m_bUpdateType; - -----------------------------------------------------------------------*/ -SwXTextSectionClient::~SwXTextSectionClient() -{ - uno::Reference< text::XTextSection > xSection( m_xReference ); - if(xSection.is()) + SwTextSectionProperties_Impl() + : m_bDDE(false) + , m_bHidden(false) + , m_bCondHidden(false) + , m_bProtect(false) + // --> FME 2004-06-22 #114856# edit in readonly sections + , m_bEditInReadonly(false) + // <-- + , m_bUpdateType(true) { - m_pSection->SetClient( 0 ); } -} -/*-- 20.12.2005 09:56:35--------------------------------------------------- - -----------------------------------------------------------------------*/ -uno::Reference< text::XTextSection > SwXTextSectionClient::GetXTextSection() -{ - return uno::Reference< text::XTextSection >( m_xReference ); -} +}; -/*-- 29.12.2005 11:29:30--------------------------------------------------- - -----------------------------------------------------------------------*/ -/*SwXTextSection* SwXTextSectionClient::GetSwTextSection() +class SwXTextSection::Impl + : public SwClient { - if( m_xReference.is() ) - return m_pSection;; -} */ + +public: + + SwXTextSection & m_rThis; + const SfxItemPropertySet & m_rPropSet; + SwEventListenerContainer m_ListenerContainer; + const bool m_bIndexHeader; + bool m_bIsDescriptor; + ::rtl::OUString m_sName; + ::std::auto_ptr<SwTextSectionProperties_Impl> m_pProps; + + Impl( SwXTextSection & rThis, + SwSectionFmt *const pFmt, const bool bIndexHeader) + : SwClient(pFmt) + , m_rThis(rThis) + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_SECTION)) + , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_bIndexHeader(bIndexHeader) + , m_bIsDescriptor(0 == pFmt) + , m_pProps((pFmt) ? 0 : new SwTextSectionProperties_Impl()) + { + } + + SwSectionFmt * GetSectionFmt() const + { + return static_cast<SwSectionFmt*>(const_cast<SwModify*>( + GetRegisteredIn())); + } + + SwSectionFmt & GetSectionFmtOrThrow() const { + SwSectionFmt *const pFmt( GetSectionFmt() ); + if (!pFmt) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXTextSection: disposed or invalid")), 0); + } + return *pFmt; + } + + void SAL_CALL SetPropertyValues_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames, + const uno::Sequence< uno::Any >& aValues) + throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException); + uno::Sequence< uno::Any > SAL_CALL + GetPropertyValues_Impl( + const uno::Sequence< ::rtl::OUString >& rPropertyNames) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException); + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; /*-- 10.12.98 14:42:52--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSectionClient::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) +void SwXTextSection::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) { - if(pOld && pOld->Which() == RES_REMOVE_UNO_OBJECT && - (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject ) - ((SwModify*)GetRegisteredIn())->Remove(this); - else - ClientModify(this, pOld, pNew); - if(!GetRegisteredIn()) + ClientModify(this, pOld, pNew); + if (!GetRegisteredIn()) { - uno::Reference< text::XTextSection > xSection( m_xReference ); - if(xSection.is()) - { - m_pSection->SetClient( 0 ); - m_pSection->aLstnrCntnr.Disposing(); - m_xReference = uno::Reference< text::XTextSection >(); - - Application::PostUserEvent( - STATIC_LINK( this, SwXTextSectionClient, RemoveSectionClient_Impl ), this ); - } + m_ListenerContainer.Disposing(); } } -/*-- 29.12.2005 13:04:57--------------------------------------------------- +/*-- 20.12.2005 10:27:33--------------------------------------------------- -----------------------------------------------------------------------*/ -IMPL_STATIC_LINK_NOINSTANCE( SwXTextSectionClient, RemoveSectionClient_Impl, - SwXTextSectionClient*, pClient ) +SwSectionFmt * SwXTextSection::GetFmt() const { - delete pClient; - return 0; + return m_pImpl->GetSectionFmt(); } /*-- 20.12.2005 09:56:36--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextSection > SwXTextSectionClient::CreateXTextSection( - SwSectionFmt* pFmt, BOOL bIndexHeader ) +uno::Reference< text::XTextSection > +SwXTextSection::CreateXTextSection( + SwSectionFmt *const pFmt, const bool bIndexHeader) { - SwXTextSection* pNew; - uno::Reference< text::XTextSection > xSection = pNew = new SwXTextSection( pFmt != 0, bIndexHeader ); - if(pFmt) - new SwXTextSectionClient( *pFmt, *pNew, xSection ); + // re-use existing SwXTextSection + // #i105557#: do not iterate over the registered clients: race condition + uno::Reference< text::XTextSection > xSection; + if (pFmt) + { + xSection.set(pFmt->GetXTextSection()); + } + if ( !xSection.is() ) + { + SwXTextSection *const pNew = new SwXTextSection(pFmt, bIndexHeader); + xSection.set(pNew); + if (pFmt) + { + pFmt->SetXTextSection(xSection); + } + } return xSection; } -/*-- 29.12.2005 10:23:37--------------------------------------------------- +/*-- 10.12.98 14:47:05--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXTextSectionClient* SwXTextSectionClient::Create(SwXTextSection& rSection, - uno::Reference< text::XTextSection >xSection, SwSectionFmt& rFmt ) +SwXTextSection::SwXTextSection( + SwSectionFmt *const pFmt, const bool bIndexHeader) + : m_pImpl( new SwXTextSection::Impl(*this, pFmt, bIndexHeader) ) { - return new SwXTextSectionClient( rFmt, rSection, xSection ); } -/****************************************************************** - * - ******************************************************************/ -struct SwTextSectionProperties_Impl -{ - - String sCondition; - String sLinkFileName; - String sSectionFilter; - String sSectionRegion; - uno::Sequence<sal_Int8> aPassword; - - SwFmtCol* pColItem; - SvxBrushItem* pBrushItem; - SwFmtFtnAtTxtEnd* pFtnItem; - SwFmtEndAtTxtEnd* pEndItem; - SvXMLAttrContainerItem *pXMLAttr; - SwFmtNoBalancedColumns *pNoBalanceItem; - SvxFrameDirectionItem *pFrameDirItem; - SvxLRSpaceItem *pLRSpaceItem; // #109700# - sal_Bool bDDE; - sal_Bool bHidden; - sal_Bool bCondHidden; - sal_Bool bProtect; - // --> FME 2004-06-22 #114856# edit in readonly sections - sal_Bool bEditInReadonly; - // <-- - sal_Bool bUpdateType; - - SwTextSectionProperties_Impl() : - pColItem(0), - pBrushItem(0), - pFtnItem(0), - pEndItem(0), - pXMLAttr(0), - pNoBalanceItem(0), - pFrameDirItem(0), - pLRSpaceItem(0), // #109700# - bDDE(0), - bHidden(0), - bCondHidden(0), - bProtect(0), - // --> FME 2004-06-22 #114856# edit in readonly sections - bEditInReadonly(0), - // <-- - bUpdateType(sal_True){} - ~SwTextSectionProperties_Impl() - { - delete pColItem; - delete pBrushItem; - delete pFtnItem; - delete pEndItem; - delete pXMLAttr; - delete pNoBalanceItem; - delete pFrameDirItem; - delete pLRSpaceItem; // #109700# - } -}; -/* -----------------------------11.07.00 12:10-------------------------------- +/*-- 10.12.98 14:47:07--------------------------------------------------- - ---------------------------------------------------------------------------*/ -SwXTextSection* SwXTextSection::GetImplementation(uno::Reference< XInterface> xRef ) + -----------------------------------------------------------------------*/ +SwXTextSection::~SwXTextSection() { - uno::Reference<lang::XUnoTunnel> xTunnel( xRef, uno::UNO_QUERY); - if(xTunnel.is()) - return reinterpret_cast< SwXTextSection * >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXTextSection::getUnoTunnelId()) )); - return 0; } /* -----------------------------13.03.00 12:15-------------------------------- @@ -261,258 +248,230 @@ const uno::Sequence< sal_Int8 > & SwXTextSection::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXTextSection::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; -} -/*-- 10.12.98 14:47:05--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXTextSection::SwXTextSection(sal_Bool bWithFormat, sal_Bool bIndexHeader) : -// SwClient(pFmt), - aLstnrCntnr( (text::XTextContent*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_SECTION)), - m_bIsDescriptor(!bWithFormat), - m_bIndexHeader(bIndexHeader), - pProps(bWithFormat ? 0 : new SwTextSectionProperties_Impl()), - m_pClient( 0 ) +sal_Int64 SAL_CALL +SwXTextSection::getSomething(const uno::Sequence< sal_Int8 >& rId) +throw (uno::RuntimeException) { - + return ::sw::UnoTunnelImpl<SwXTextSection>(rId, this); } -/*-- 10.12.98 14:47:07--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwXTextSection::~SwXTextSection() -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - delete m_pClient; - delete pProps; -} /*-- 10.12.98 14:47:08--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextSection > SwXTextSection::getParentSection(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextSection > SAL_CALL +SwXTextSection::getParentSection() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextSection > aRef; - SwSectionFmt* pSectFmt = GetFmt(); - if(pSectFmt) - { - SwSectionFmt* pParentFmt = pSectFmt->GetParent(); - if(pParentFmt) - { - SwXTextSectionClient* pClient = (SwXTextSectionClient*)SwClientIter(*pParentFmt). - First(TYPE(SwXTextSectionClient)); - if(pClient) - aRef = pClient->GetXTextSection(); - else - aRef = SwXTextSectionClient::CreateXTextSection(pParentFmt); - } - } - else - throw uno::RuntimeException(); - return aRef; + + SwSectionFmt & rSectionFmt( m_pImpl->GetSectionFmtOrThrow() ); + + SwSectionFmt *const pParentFmt = rSectionFmt.GetParent(); + const uno::Reference< text::XTextSection > xRet = + (pParentFmt) ? CreateXTextSection(pParentFmt) : 0; + return xRet; } + /*-- 10.12.98 14:47:08--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Sequence< uno::Reference< text::XTextSection > > SwXTextSection::getChildSections(void) - throw( uno::RuntimeException ) +uno::Sequence< uno::Reference< text::XTextSection > > SAL_CALL +SwXTextSection::getChildSections() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Sequence<uno::Reference< text::XTextSection > > aSeq; - SwSectionFmt* pSectFmt = GetFmt(); - if(pSectFmt) - { - SwSections aChildren; - pSectFmt->GetChildSections(aChildren, SORTSECT_NOT, sal_False); - aSeq.realloc(aChildren.Count()); - uno::Reference< text::XTextSection > * pArray = aSeq.getArray(); - for(sal_uInt16 i = 0; i < aChildren.Count(); i++) - { - SwSectionFmt* pChild = aChildren.GetObject(i)->GetFmt(); - SwXTextSectionClient* pClient = (SwXTextSectionClient*)SwClientIter(*pChild). - First(TYPE(SwXTextSectionClient)); - if(pClient) - pArray[i] = pClient->GetXTextSection(); - else - pArray[i] = SwXTextSectionClient::CreateXTextSection(pChild); - } + SwSectionFmt & rSectionFmt( m_pImpl->GetSectionFmtOrThrow() ); + + SwSections aChildren; + rSectionFmt.GetChildSections(aChildren, SORTSECT_NOT, sal_False); + uno::Sequence<uno::Reference<text::XTextSection> > aSeq(aChildren.Count()); + uno::Reference< text::XTextSection > * pArray = aSeq.getArray(); + for (sal_uInt16 i = 0; i < aChildren.Count(); i++) + { + SwSectionFmt *const pChild = aChildren.GetObject(i)->GetFmt(); + pArray[i] = CreateXTextSection(pChild); } return aSeq; - } + /* -----------------18.02.99 13:31------------------- * * --------------------------------------------------*/ -void SwXTextSection::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::attach(const uno::Reference< text::XTextRange > & xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - if(!m_bIsDescriptor) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->m_bIsDescriptor) + { throw uno::RuntimeException(); + } uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); SwXTextRange* pRange = 0; OTextCursorHelper* pCursor = 0; if(xRangeTunnel.is()) { - 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()) )); + pRange = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel); + pCursor = + ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel); + } + + SwDoc *const pDoc = + (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0); + if (!pDoc) + { + 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); + UnoActionContext aCont(pDoc); + pDoc->StartUndo( UNDO_INSSECTION, NULL ); + + if (!m_pImpl->m_sName.getLength()) { - SwUnoInternalPaM aPam(*pDoc); - //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); - UnoActionContext aCont(pDoc); - pDoc->StartUndo( UNDO_INSSECTION, NULL ); - - SwSection* pRet = 0; - if(!m_sName.Len()) - m_sName = C2S("TextSection"); - SectionType eType = pProps->bDDE ? DDE_LINK_SECTION : - pProps->sLinkFileName.Len() || pProps->sSectionRegion.Len() ? FILE_LINK_SECTION : - CONTENT_SECTION; - // index header section? - if(m_bIndexHeader) + m_pImpl->m_sName = C2U("TextSection"); + } + SectionType eType = (m_pImpl->m_pProps->m_bDDE) + ? DDE_LINK_SECTION + : ((m_pImpl->m_pProps->m_sLinkFileName.getLength() || + m_pImpl->m_pProps->m_sSectionRegion.getLength()) + ? FILE_LINK_SECTION : CONTENT_SECTION); + // index header section? + if (m_pImpl->m_bIndexHeader) + { + // caller wants an index header section, but will only + // give him one if a) we are inside an index, and b) said + // index doesn't yet have a header section. + const SwTOXBase* pBase = aPam.GetDoc()->GetCurTOX(*aPam.Start()); + + // are we inside an index? + if (pBase) { - // caller wants an index header section, but will only - // give him one if a) we are inside an index, and b) said - // index doesn't yet have a header section. - const SwTOXBase* pBase = aPam.GetDoc()->GetCurTOX( - *aPam.Start() ); - - // are we inside an index? - if (pBase) + // get all child sections + SwSections aSectionsArr; + static_cast<const SwTOXBaseSection*>(pBase)->GetFmt()-> + GetChildSections(aSectionsArr); + + // and search for current header section + const sal_uInt16 nCount = aSectionsArr.Count(); + sal_Bool bHeaderPresent = sal_False; + for(sal_uInt16 i = 0; i < nCount; i++) { - // get all child sections - SwSections aSectionsArr; - ((SwTOXBaseSection*)pBase)->GetFmt()-> - GetChildSections(aSectionsArr); - - // and search for current header section - sal_uInt16 nCount = aSectionsArr.Count(); - sal_Bool bHeaderPresent = sal_False; - for(sal_uInt16 i = 0; i < nCount; i++) - { - bHeaderPresent |= - (aSectionsArr[i]->GetType() == TOX_HEADER_SECTION); - } - if (! bHeaderPresent) - { - eType = TOX_HEADER_SECTION; - } + bHeaderPresent |= + (aSectionsArr[i]->GetType() == TOX_HEADER_SECTION); + } + if (! bHeaderPresent) + { + eType = TOX_HEADER_SECTION; } } + } - SwSection aSect(eType, pDoc->GetUniqueSectionName(&m_sName)); - aSect.SetCondition(pProps->sCondition); - String sLinkName(pProps->sLinkFileName); - sLinkName += sfx2::cTokenSeperator; - sLinkName += pProps->sSectionFilter; - sLinkName += sfx2::cTokenSeperator; - sLinkName += pProps->sSectionRegion; - aSect.SetLinkFileName(sLinkName); - - aSect.SetHidden(pProps->bHidden); - aSect.SetProtect(pProps->bProtect); - // --> FME 2004-06-22 #114856# edit in readonly sections - aSect.SetEditInReadonly(pProps->bEditInReadonly); - // <-- + String tmp(m_pImpl->m_sName); + SwSection aSect(eType, pDoc->GetUniqueSectionName(&tmp)); + aSect.SetCondition(m_pImpl->m_pProps->m_sCondition); + ::rtl::OUStringBuffer sLinkNameBuf(m_pImpl->m_pProps->m_sLinkFileName); + sLinkNameBuf.append(sfx2::cTokenSeperator); + sLinkNameBuf.append(m_pImpl->m_pProps->m_sSectionFilter); + sLinkNameBuf.append(sfx2::cTokenSeperator); + sLinkNameBuf.append(m_pImpl->m_pProps->m_sSectionRegion); + aSect.SetLinkFileName(sLinkNameBuf.makeStringAndClear()); + + aSect.SetHidden(m_pImpl->m_pProps->m_bHidden); + aSect.SetProtect(m_pImpl->m_pProps->m_bProtect); + // --> FME 2004-06-22 #114856# edit in readonly sections + aSect.SetEditInReadonly(m_pImpl->m_pProps->m_bEditInReadonly); + // <-- - SfxItemSet aSet(pDoc->GetAttrPool(), - RES_COL, RES_COL, - RES_BACKGROUND, RES_BACKGROUND, - RES_FTN_AT_TXTEND, RES_FRAMEDIR, - RES_LR_SPACE, RES_LR_SPACE, // #109700# - RES_UNKNOWNATR_CONTAINER,RES_UNKNOWNATR_CONTAINER, - 0); - if(pProps->pBrushItem) - aSet.Put(*pProps->pBrushItem); - if(pProps->pColItem) - aSet.Put(*pProps->pColItem); - if(pProps->pFtnItem) - aSet.Put(*pProps->pFtnItem); - if(pProps->pEndItem) - aSet.Put(*pProps->pEndItem); - if(pProps->pXMLAttr) - aSet.Put(*pProps->pXMLAttr); - if(pProps->pNoBalanceItem) - aSet.Put(*pProps->pNoBalanceItem); - if(pProps->pFrameDirItem) - aSet.Put(*pProps->pFrameDirItem); - /* #109700# */ - if(pProps->pLRSpaceItem) - aSet.Put(*pProps->pLRSpaceItem); - - // section password - if (pProps->aPassword.getLength() > 0) - aSect.SetPasswd(pProps->aPassword); - - pRet = pDoc->InsertSwSection( aPam, aSect, aSet.Count() ? &aSet : 0 ); - // now create the client - m_refCount++; - // keep block to remove Reference before the refcount is decremented - { - uno::Reference< text::XTextSection> xSection( this ); - m_pClient = SwXTextSectionClient::Create(*this, xSection, *pRet->GetFmt()); - } - m_refCount--; + SfxItemSet aSet(pDoc->GetAttrPool(), + RES_COL, RES_COL, + RES_BACKGROUND, RES_BACKGROUND, + RES_FTN_AT_TXTEND, RES_FRAMEDIR, + RES_LR_SPACE, RES_LR_SPACE, // #109700# + RES_UNKNOWNATR_CONTAINER,RES_UNKNOWNATR_CONTAINER, + 0); + if (m_pImpl->m_pProps->m_pBrushItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pBrushItem); + } + if (m_pImpl->m_pProps->m_pColItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pColItem); + } + if (m_pImpl->m_pProps->m_pFtnItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pFtnItem); + } + if (m_pImpl->m_pProps->m_pEndItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pEndItem); + } + if (m_pImpl->m_pProps->m_pXMLAttr.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pXMLAttr); + } + if (m_pImpl->m_pProps->m_pNoBalanceItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pNoBalanceItem); + } + if (m_pImpl->m_pProps->m_pFrameDirItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pFrameDirItem); + } + /* #109700# */ + if (m_pImpl->m_pProps->m_pLRSpaceItem.get()) + { + aSet.Put(*m_pImpl->m_pProps->m_pLRSpaceItem); + } + // section password + if (m_pImpl->m_pProps->m_Password.getLength() > 0) + { + aSect.SetPasswd(m_pImpl->m_pProps->m_Password); + } - // #97450# XML import must hide sections depending on their old - // condition status - if( pProps->sCondition.Len() != 0 ) - pRet->SetCondHidden(pProps->bCondHidden); + SwSection *const pRet = + pDoc->InsertSwSection( aPam, aSect, aSet.Count() ? &aSet : 0 ); + pRet->GetFmt()->Add(m_pImpl.get()); + pRet->GetFmt()->SetXObject(static_cast< ::cppu::OWeakObject*>(this)); - // set update type if DDE link (and connect, if necessary) - if (pProps->bDDE) + // #97450# XML import must hide sections depending on their old + // condition status + if (m_pImpl->m_pProps->m_sCondition.getLength() != 0) + { + pRet->SetCondHidden(m_pImpl->m_pProps->m_bCondHidden); + } + + // set update type if DDE link (and connect, if necessary) + if (m_pImpl->m_pProps->m_bDDE) + { + if (! pRet->IsConnected()) { - if (! pRet->IsConnected()) - { - pRet->CreateLink(CREATE_CONNECT); - } - pRet->SetUpdateType( static_cast< USHORT >(pProps->bUpdateType ? - sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) ); + pRet->CreateLink(CREATE_CONNECT); } - - // Undo-Klammerung hier beenden - pDoc->EndUndo( UNDO_INSSECTION, NULL ); - DELETEZ(pProps); - m_bIsDescriptor = sal_False; + pRet->SetUpdateType( static_cast< USHORT >( + (m_pImpl->m_pProps->m_bUpdateType) ? + sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) ); } - else - throw lang::IllegalArgumentException(); -} -/*-- 10.12.98 14:47:09--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXTextSection::attach(const uno::Reference< text::XTextRange > & xTextRange) - throw( lang::IllegalArgumentException, uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - attachToRange( xTextRange ); + // Undo-Klammerung hier beenden + pDoc->EndUndo( UNDO_INSSECTION, NULL ); + m_pImpl->m_pProps.reset(); + m_pImpl->m_bIsDescriptor = false; } /*-- 10.12.98 14:47:09--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXTextSection::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXTextSection::getAnchor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + uno::Reference< text::XTextRange > xRet; - SwSectionFmt* pSectFmt = GetFmt(); + SwSectionFmt *const pSectFmt = m_pImpl->GetSectionFmt(); if(pSectFmt) { const SwSection* pSect; @@ -527,7 +486,7 @@ uno::Reference< text::XTextRange > SwXTextSection::getAnchor(void) throw( uno:: const SwEndNode* pEndNode = pIdx->GetNode().EndOfSectionNode(); SwPaM aEnd(*pEndNode); aEnd.Move( fnMoveBackward, fnGoCntnt ); - xRet = SwXTextRange::CreateTextRangeFromPosition(pSectFmt->GetDoc(), + xRet = SwXTextRange::CreateXTextRange(*pSectFmt->GetDoc(), *aPaM.Start(), aEnd.Start()); } } @@ -536,380 +495,491 @@ uno::Reference< text::XTextRange > SwXTextSection::getAnchor(void) throw( uno:: /*-- 10.12.98 14:47:09--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::dispose(void) throw( uno::RuntimeException ) +void SAL_CALL SwXTextSection::dispose() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwSectionFmt* pSectFmt = GetFmt(); - if(pSectFmt) + + SwSectionFmt *const pSectFmt = m_pImpl->GetSectionFmt(); + if (pSectFmt) + { pSectFmt->GetDoc()->DelSectionFmt( pSectFmt ); - else - throw uno::RuntimeException(); + } } /*-- 10.12.98 14:47:10--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::addEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL SwXTextSection::addEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetFmt()) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetSectionFmt()) + { throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + } + m_pImpl->m_ListenerContainer.AddListener(xListener); } /*-- 10.12.98 14:47:10--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) - throw( uno::RuntimeException ) +void SAL_CALL SwXTextSection::removeEventListener( + const uno::Reference< lang::XEventListener > & xListener) +throw (uno::RuntimeException) { - if(!GetFmt() || !aLstnrCntnr.RemoveListener(aListener)) + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->GetSectionFmt() || + !m_pImpl->m_ListenerContainer.RemoveListener(xListener)) + { throw uno::RuntimeException(); + } } /*-- 10.12.98 14:47:11--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXTextSection::getPropertySetInfo(void) throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXTextSection::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo(); + vos::OGuard g(Application::GetSolarMutex()); + + static const uno::Reference< beans::XPropertySetInfo > aRef = + m_pImpl->m_rPropSet.getPropertySetInfo(); return aRef; } -/* -----------------------------12.02.01 10:29-------------------------------- - ---------------------------------------------------------------------------*/ -struct SwSectItemSet_Impl -{ - - SfxItemSet* pItemSet; - SwSectItemSet_Impl() : - pItemSet(0){} - ~SwSectItemSet_Impl() - {delete pItemSet;} -}; /* -----------------------------12.02.01 10:45-------------------------------- ---------------------------------------------------------------------------*/ -void SAL_CALL SwXTextSection::SetPropertyValues_Impl( +void SwXTextSection::Impl::SetPropertyValues_Impl( const uno::Sequence< OUString >& rPropertyNames, - const uno::Sequence< Any >& rValues ) - throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, - WrappedTargetException, RuntimeException) + const uno::Sequence< uno::Any >& rValues) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) { - SwSectionFmt* pFmt = GetFmt(); if(rPropertyNames.getLength() != rValues.getLength()) - throw IllegalArgumentException(); - if(pFmt || m_bIsDescriptor) { - SwSection aSection(CONTENT_SECTION, aEmptyStr); - SwSection* pSect = pFmt ? pFmt->GetSection() : 0; - if(pFmt) - aSection = *pSect; - const OUString* pPropertyNames = rPropertyNames.getConstArray(); - const Any* pValues = rValues.getConstArray(); - SwSectItemSet_Impl aItemSet; - - sal_Bool bLinkModeChanged = sal_False; - sal_Bool bLinkMode = sal_False; - for(sal_Int16 nProperty = 0; nProperty < rPropertyNames.getLength(); nProperty++) + throw lang::IllegalArgumentException(); + } + SwSectionFmt *const pFmt = GetSectionFmt(); + if (!pFmt && !m_bIsDescriptor) + { + throw uno::RuntimeException(); + } + + SwSection aSection(CONTENT_SECTION, aEmptyStr); + SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0; + if (pFmt) + { + aSection = *pSect; + } + OUString const*const pPropertyNames = rPropertyNames.getConstArray(); + uno::Any const*const pValues = rValues.getConstArray(); + ::std::auto_ptr<SfxItemSet> pItemSet; + sal_Bool bLinkModeChanged = sal_False; + sal_Bool bLinkMode = sal_False; + + for (sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength(); + nProperty++) + { + SfxItemPropertySimpleEntry const*const pEntry = + m_rPropSet.getPropertyMap()->getByName(pPropertyNames[nProperty]); + if (!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( pPropertyNames[nProperty] ); - if(!pEntry) - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames[nProperty], static_cast < cppu::OWeakObject * > ( this ) ); - else + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pPropertyNames[nProperty], + static_cast<cppu::OWeakObject *>(& m_rThis)); + } + if (pEntry->nFlags & beans::PropertyAttribute::READONLY) + { + throw beans::PropertyVetoException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: ")) + + pPropertyNames[nProperty], + static_cast<cppu::OWeakObject *>(& m_rThis)); + } + switch (pEntry->nWID) + { + case WID_SECT_CONDITION: + { + OUString uTmp; + pValues[nProperty] >>= uTmp; + if (m_bIsDescriptor) + { + m_pProps->m_sCondition = uTmp; + } + else + { + aSection.SetCondition(uTmp); + } + } + break; + case WID_SECT_DDE_TYPE: + case WID_SECT_DDE_FILE: + case WID_SECT_DDE_ELEMENT: { - if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames[nProperty], static_cast < cppu::OWeakObject * > ( this ) ); - switch(pEntry->nWID) + OUString uTmp; + pValues[nProperty] >>= uTmp; + String sTmp(uTmp); + if (m_bIsDescriptor) { - case WID_SECT_CONDITION: + if (!m_pProps->m_bDDE) { - OUString uTmp; - pValues[nProperty] >>= uTmp; - if(m_bIsDescriptor) - pProps->sCondition = String(uTmp); - else - aSection.SetCondition(uTmp); + ::rtl::OUStringBuffer buf; + buf.append(sfx2::cTokenSeperator); + buf.append(sfx2::cTokenSeperator); + m_pProps->m_sLinkFileName = buf.makeStringAndClear(); + m_pProps->m_bDDE = true; } - break; - case WID_SECT_DDE_TYPE : - case WID_SECT_DDE_FILE : - case WID_SECT_DDE_ELEMENT : + String sLinkFileName(m_pProps->m_sLinkFileName); + sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE, + sfx2::cTokenSeperator, sTmp); + m_pProps->m_sLinkFileName = sLinkFileName; + } + else + { + String sLinkFileName(aSection.GetLinkFileName()); + if (aSection.GetType() != DDE_LINK_SECTION) { - OUString uTmp; - pValues[nProperty] >>= uTmp; - String sTmp(uTmp); - if(m_bIsDescriptor) - { - if(!pProps->bDDE) - { - pProps->sLinkFileName = sfx2::cTokenSeperator; - pProps->sLinkFileName += sfx2::cTokenSeperator; - pProps->bDDE = sal_True; - } - pProps->sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE,sfx2::cTokenSeperator,sTmp); - } - else - { - String sLinkFileName(aSection.GetLinkFileName()); - if(aSection.GetType() != DDE_LINK_SECTION) - { - sLinkFileName = sfx2::cTokenSeperator; - sLinkFileName += sfx2::cTokenSeperator; - aSection.SetType(DDE_LINK_SECTION); - } - sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE,sfx2::cTokenSeperator, sTmp); - aSection.SetLinkFileName(sLinkFileName); - } + sLinkFileName = sfx2::cTokenSeperator; + sLinkFileName += sfx2::cTokenSeperator; + aSection.SetType(DDE_LINK_SECTION); + } + sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE, + sfx2::cTokenSeperator, sTmp); + aSection.SetLinkFileName(sLinkFileName); + } + } + break; + case WID_SECT_DDE_AUTOUPDATE: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bUpdateType = bVal; + } + else + { + bLinkModeChanged = sal_True; + bLinkMode = bVal; + } + } + break; + case WID_SECT_LINK: + { + text::SectionFileLink aLink; + if (!(pValues[nProperty] >>= aLink)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bDDE = sal_False; + m_pProps->m_sLinkFileName = aLink.FileURL; + m_pProps->m_sSectionFilter = aLink.FilterName; + } + else + { + if (aSection.GetType() != FILE_LINK_SECTION && + aLink.FileURL.getLength()) + { + aSection.SetType(FILE_LINK_SECTION); } - break; - case WID_SECT_DDE_AUTOUPDATE: + ::rtl::OUStringBuffer sFileNameBuf; + if (aLink.FileURL.getLength()) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) - { - pProps->bUpdateType = bVal; - } - else + sFileNameBuf.append( URIHelper::SmartRel2Abs( + pFmt->GetDoc()->GetDocShell()->GetMedium() + ->GetURLObject(), + aLink.FileURL, URIHelper::GetMaybeFileHdl())); + } + sFileNameBuf.append(sfx2::cTokenSeperator); + sFileNameBuf.append(aLink.FilterName); + sFileNameBuf.append(sfx2::cTokenSeperator); + sFileNameBuf.append( + aSection.GetLinkFileName().GetToken(2, + sfx2::cTokenSeperator)); + const ::rtl::OUString sFileName( + sFileNameBuf.makeStringAndClear()); + aSection.SetLinkFileName(sFileName); + if (sFileName.getLength() < 3) + { + aSection.SetType(CONTENT_SECTION); + } + } + } + break; + case WID_SECT_REGION: + { + OUString sLink; + pValues[nProperty] >>= sLink; + if (m_bIsDescriptor) + { + m_pProps->m_bDDE = sal_False; + m_pProps->m_sSectionRegion = sLink; + } + else + { + if (aSection.GetType() != FILE_LINK_SECTION && + sLink.getLength()) + { + aSection.SetType(FILE_LINK_SECTION); + } + String sSectLink(aSection.GetLinkFileName()); + while (3 < sSectLink.GetTokenCount(sfx2::cTokenSeperator)) + { + sSectLink += sfx2::cTokenSeperator; + } + sSectLink.SetToken(2, sfx2::cTokenSeperator, sLink); + aSection.SetLinkFileName(sSectLink); + if (sSectLink.Len() < 3) + { + aSection.SetType(CONTENT_SECTION); + } + } + } + break; + case WID_SECT_VISIBLE: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bHidden = !bVal; + } + else + { + aSection.SetHidden(!bVal); + } + } + break; + case WID_SECT_CURRENTLY_VISIBLE: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bCondHidden = !bVal; + } + else + { + if (aSection.GetCondition().Len() != 0) + { + aSection.SetCondHidden(!bVal); + } + } + } + break; + case WID_SECT_PROTECTED: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bProtect = bVal; + } + else + { + aSection.SetProtect(bVal); + } + } + break; + // --> FME 2004-06-22 #114856# edit in readonly sections + case WID_SECT_EDIT_IN_READONLY: + { + sal_Bool bVal(sal_False); + if (!(pValues[nProperty] >>= bVal)) + { + throw lang::IllegalArgumentException(); + } + if (m_bIsDescriptor) + { + m_pProps->m_bEditInReadonly = bVal; + } + else + { + aSection.SetEditInReadonly(bVal); + } + } + // <-- + break; + case WID_SECT_PASSWORD: + { + uno::Sequence<sal_Int8> aSeq; + pValues[nProperty] >>= aSeq; + if (m_bIsDescriptor) + { + m_pProps->m_Password = aSeq; + } + else + { + aSection.SetPasswd(aSeq); + } + } + break; + default: + { + if (pFmt) + { + const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet(); + pItemSet.reset( new SfxItemSet(*rOldAttrSet.GetPool(), + pEntry->nWID, pEntry->nWID, 0)); + pItemSet->Put(rOldAttrSet); + m_rPropSet.setPropertyValue(*pEntry, + pValues[nProperty], *pItemSet); + } + else + { + SfxPoolItem* pPutItem = 0; + if (RES_COL == pEntry->nWID) + { + if (!m_pProps->m_pColItem.get()) { - bLinkModeChanged = sal_True; - bLinkMode = bVal; + m_pProps->m_pColItem.reset(new SwFmtCol); } + pPutItem = m_pProps->m_pColItem.get(); } - break; - case WID_SECT_LINK : + else if (RES_BACKGROUND == pEntry->nWID) { - text::SectionFileLink aLink; - if(pValues[nProperty] >>= aLink) + if (!m_pProps->m_pBrushItem.get()) { - if(m_bIsDescriptor) - { - pProps->bDDE = sal_False; - pProps->sLinkFileName = String(aLink.FileURL); - pProps->sSectionFilter = String(aLink.FilterName); - } - else - { - if(aSection.GetType() != FILE_LINK_SECTION && - aLink.FileURL.getLength()) - aSection.SetType(FILE_LINK_SECTION); - String sFileName; - if(aLink.FileURL.getLength()) - { - sFileName += URIHelper::SmartRel2Abs( - pFmt->GetDoc()->GetDocShell()->GetMedium()->GetURLObject(), - aLink.FileURL, - URIHelper::GetMaybeFileHdl()); - } - sFileName += sfx2::cTokenSeperator; - sFileName += String(aLink.FilterName); - sFileName += sfx2::cTokenSeperator; - sFileName += aSection.GetLinkFileName().GetToken( 2, sfx2::cTokenSeperator ); - aSection.SetLinkFileName(sFileName); - if(sFileName.Len() < 3) - aSection.SetType(CONTENT_SECTION); - } + m_pProps->m_pBrushItem.reset( + new SvxBrushItem(RES_BACKGROUND)); } - else - throw lang::IllegalArgumentException(); + pPutItem = m_pProps->m_pBrushItem.get(); } - break; - case WID_SECT_REGION : + else if (RES_FTN_AT_TXTEND == pEntry->nWID) { - OUString uTmp; - pValues[nProperty] >>= uTmp; - String sLink(uTmp); - if(m_bIsDescriptor) + if (!m_pProps->m_pFtnItem.get()) { - pProps->bDDE = sal_False; - pProps->sSectionRegion = sLink; + m_pProps->m_pFtnItem.reset(new SwFmtFtnAtTxtEnd); } - else + pPutItem = m_pProps->m_pFtnItem.get(); + } + else if (RES_END_AT_TXTEND == pEntry->nWID) + { + if (!m_pProps->m_pEndItem.get()) { - if(aSection.GetType() != FILE_LINK_SECTION && - sLink.Len()) - aSection.SetType(FILE_LINK_SECTION); - String sSectLink(aSection.GetLinkFileName()); - while( 3 < sSectLink.GetTokenCount( sfx2::cTokenSeperator )) - { - sSectLink += sfx2::cTokenSeperator; - } - sSectLink.SetToken(2, sfx2::cTokenSeperator, sLink); - aSection.SetLinkFileName(sSectLink); - if(sSectLink.Len() < 3) - aSection.SetType(CONTENT_SECTION); + m_pProps->m_pEndItem.reset(new SwFmtEndAtTxtEnd); } + pPutItem = m_pProps->m_pEndItem.get(); } - break; - case WID_SECT_VISIBLE : + else if (RES_UNKNOWNATR_CONTAINER== pEntry->nWID) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) - pProps->bHidden = !bVal; - else - aSection.SetHidden(!bVal); + if (!m_pProps->m_pXMLAttr.get()) + { + m_pProps->m_pXMLAttr.reset( + new SvXMLAttrContainerItem( + RES_UNKNOWNATR_CONTAINER)); + } + pPutItem = m_pProps->m_pXMLAttr.get(); } - break; - case WID_SECT_CURRENTLY_VISIBLE: + else if (RES_COLUMNBALANCE== pEntry->nWID) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) - pProps->bCondHidden = !bVal; - else - if( aSection.GetCondition().Len() != 0 ) - aSection.SetCondHidden(!bVal); + if (!m_pProps->m_pNoBalanceItem.get()) + { + m_pProps->m_pNoBalanceItem.reset( + new SwFmtNoBalancedColumns(RES_COLUMNBALANCE)); + } + pPutItem = m_pProps->m_pNoBalanceItem.get(); } - break; - case WID_SECT_PROTECTED: + else if (RES_FRAMEDIR == pEntry->nWID) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) - pProps->bProtect = bVal; - else - aSection.SetProtect(bVal); + if (!m_pProps->m_pFrameDirItem.get()) + { + m_pProps->m_pFrameDirItem.reset( + new SvxFrameDirectionItem( + FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR)); + } + pPutItem = m_pProps->m_pFrameDirItem.get(); } - break; - // --> FME 2004-06-22 #114856# edit in readonly sections - case WID_SECT_EDIT_IN_READONLY: + else if (RES_LR_SPACE == pEntry->nWID) { - sal_Bool bVal = *(sal_Bool*)pValues[nProperty].getValue(); - if(m_bIsDescriptor) - pProps->bEditInReadonly = bVal; - else - aSection.SetEditInReadonly(bVal); + // #109700# + if (!m_pProps->m_pLRSpaceItem.get()) + { + m_pProps->m_pLRSpaceItem.reset( + new SvxLRSpaceItem( RES_LR_SPACE )); + } + pPutItem = m_pProps->m_pLRSpaceItem.get(); } - // <-- - break; - case WID_SECT_PASSWORD: + if (pPutItem) { - uno::Sequence<sal_Int8> aSeq; - pValues[nProperty] >>= aSeq; - if (m_bIsDescriptor) - pProps->aPassword = aSeq; - else - aSection.SetPasswd(aSeq); + pPutItem->PutValue(pValues[nProperty], + pEntry->nMemberId); } - break; - default: - if(pFmt) - { - const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet(); - aItemSet.pItemSet = new SfxItemSet(*rOldAttrSet.GetPool(), - pEntry->nWID, pEntry->nWID, 0); - aItemSet.pItemSet->Put(rOldAttrSet); - m_pPropSet->setPropertyValue(*pEntry, pValues[nProperty], *aItemSet.pItemSet); - } - else - { - SfxPoolItem* pPutItem = 0; - if(RES_COL == pEntry->nWID) - { - if(!pProps->pColItem) - pProps->pColItem = new SwFmtCol; - pPutItem = pProps->pColItem; - } - else if(RES_BACKGROUND == pEntry->nWID) - { - if(!pProps->pBrushItem) - pProps->pBrushItem = new SvxBrushItem(RES_BACKGROUND); - pPutItem = pProps->pBrushItem; - } - else if(RES_FTN_AT_TXTEND == pEntry->nWID) - { - if(!pProps->pFtnItem) - pProps->pFtnItem = new SwFmtFtnAtTxtEnd; - pPutItem = pProps->pFtnItem; - } - else if(RES_END_AT_TXTEND == pEntry->nWID) - { - if(!pProps->pEndItem) - pProps->pEndItem = new SwFmtEndAtTxtEnd; - pPutItem = pProps->pEndItem; - } - else if(RES_UNKNOWNATR_CONTAINER== pEntry->nWID) - { - if(!pProps->pXMLAttr) - pProps->pXMLAttr= new SvXMLAttrContainerItem( RES_UNKNOWNATR_CONTAINER ); - pPutItem = pProps->pXMLAttr; - } - else if(RES_COLUMNBALANCE== pEntry->nWID) - { - if(!pProps->pNoBalanceItem) - pProps->pNoBalanceItem= new SwFmtNoBalancedColumns( RES_COLUMNBALANCE ); - pPutItem = pProps->pNoBalanceItem; - } - else if(RES_FRAMEDIR == pEntry->nWID) - { - if(!pProps->pFrameDirItem) - pProps->pFrameDirItem = new SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR ); - pPutItem = pProps->pFrameDirItem; - } - else if(RES_LR_SPACE == pEntry->nWID) - { - // #109700# - if(!pProps->pLRSpaceItem) - pProps->pLRSpaceItem = new SvxLRSpaceItem( RES_LR_SPACE ); - pPutItem = pProps->pLRSpaceItem; - } - if(pPutItem) - pPutItem->PutValue(pValues[nProperty], pEntry->nMemberId); - } } } } - if(pFmt) + } + + if (pFmt) + { + SwDoc* pDoc = pFmt->GetDoc(); + const SwSectionFmts& rFmts = pDoc->GetSections(); + UnoActionContext aContext(pDoc); + for (sal_uInt16 i = 0; i < rFmts.Count(); i++) { - SwDoc* pDoc = pFmt->GetDoc(); - const SwSectionFmts& rFmts = pDoc->GetSections(); - UnoActionContext aContext(pDoc); - for( sal_uInt16 i = 0; i < rFmts.Count(); i++ ) + if (rFmts[i]->GetSection()->GetName() == pSect->GetName()) { - if(rFmts[i]->GetSection()->GetName() == pSect->GetName()) + pDoc->ChgSection(i, aSection, pItemSet.get(), + pDoc->IsInReading()); { - pDoc->ChgSection( i, aSection, aItemSet.pItemSet, pDoc->IsInReading()); - - { - // temporarily remove actions to allow cursor update - UnoActionRemoveContext aRemoveContext( pDoc ); - } + // temporarily remove actions to allow cursor update + UnoActionRemoveContext aRemoveContext( pDoc ); + } - //SwSection* pSect = pFmt->GetSection(); - if( bLinkModeChanged && pSect->GetType() == DDE_LINK_SECTION) + //SwSection* pSect = pFmt->GetSection(); + if (bLinkModeChanged && pSect->GetType() == DDE_LINK_SECTION) + { + // set update type; needs an established link + if (!pSect->IsConnected()) { - // set update type; needs an established link - if(!pSect->IsConnected()) - { - pSect->CreateLink(CREATE_CONNECT); - } - pSect->SetUpdateType( static_cast< USHORT >(bLinkMode ? - sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) ); + pSect->CreateLink(CREATE_CONNECT); } - // section found and processed: break from loop - break; + pSect->SetUpdateType( static_cast< USHORT >((bLinkMode) ? + sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) ); } + // section found and processed: break from loop + break; } } } - else - throw uno::RuntimeException(); } -void SwXTextSection::setPropertyValues( - const Sequence< ::rtl::OUString >& rPropertyNames, - const Sequence< Any >& rValues ) - throw(PropertyVetoException, lang::IllegalArgumentException, - lang::WrappedTargetException, RuntimeException) +void SAL_CALL +SwXTextSection::setPropertyValues( + const uno::Sequence< ::rtl::OUString >& rPropertyNames, + const uno::Sequence< uno::Any >& rValues) +throw (beans::PropertyVetoException, lang::IllegalArgumentException, + lang::WrappedTargetException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); // workaround for bad designed API try { - SetPropertyValues_Impl( rPropertyNames, rValues ); + m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues ); } - catch (UnknownPropertyException &rException) + catch (beans::UnknownPropertyException &rException) { // wrap the original (here not allowed) exception in // a WrappedTargetException that gets thrown instead. - WrappedTargetException aWExc; + lang::WrappedTargetException aWExc; aWExc.TargetException <<= rException; throw aWExc; } @@ -918,295 +988,366 @@ void SwXTextSection::setPropertyValues( -----------------------------------------------------------------------*/ void SwXTextSection::setPropertyValue( - const OUString& rPropertyName, const uno::Any& aValue) - throw( beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, + const OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< ::rtl::OUString > aPropertyNames(1); + + uno::Sequence< ::rtl::OUString > aPropertyNames(1); aPropertyNames.getArray()[0] = rPropertyName; - Sequence< Any > aValues(1); - aValues.getArray()[0] = aValue; - SetPropertyValues_Impl( aPropertyNames, aValues ); + uno::Sequence< uno::Any > aValues(1); + aValues.getArray()[0] = rValue; + m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues ); } + /* -----------------------------12.02.01 10:43-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< Any > SAL_CALL SwXTextSection::GetPropertyValues_Impl( +uno::Sequence< uno::Any > +SwXTextSection::Impl::GetPropertyValues_Impl( const uno::Sequence< OUString > & rPropertyNames ) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - Sequence< Any > aRet(rPropertyNames.getLength()); - Any* pRet = aRet.getArray(); - SwSectionFmt* pFmt = GetFmt(); - if(pFmt||m_bIsDescriptor) + SwSectionFmt *const pFmt = GetSectionFmt(); + if (!pFmt && !m_bIsDescriptor) + { + throw uno::RuntimeException(); + } + + uno::Sequence< uno::Any > aRet(rPropertyNames.getLength()); + uno::Any* pRet = aRet.getArray(); + SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0; + const OUString* pPropertyNames = rPropertyNames.getConstArray(); + + for (sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength(); + nProperty++) { - SwSection* pSect = pFmt ? pFmt->GetSection() : 0; - const OUString* pPropertyNames = rPropertyNames.getConstArray(); - for(sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength(); nProperty++) + SfxItemPropertySimpleEntry const*const pEntry = + m_rPropSet.getPropertyMap()->getByName(pPropertyNames[nProperty]); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pPropertyNames[nProperty], + static_cast<cppu::OWeakObject *>(& m_rThis)); + } + switch(pEntry->nWID) { - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( pPropertyNames[nProperty]); - if(pEntry) + case WID_SECT_CONDITION: + { + OUString uTmp( (m_bIsDescriptor) + ? m_pProps->m_sCondition + : ::rtl::OUString(pSect->GetCondition())); + pRet[nProperty] <<= uTmp; + } + break; + case WID_SECT_DDE_TYPE: + case WID_SECT_DDE_FILE: + case WID_SECT_DDE_ELEMENT: { - switch(pEntry->nWID) + ::rtl::OUString sRet; + if (m_bIsDescriptor) { - case WID_SECT_CONDITION: + if (m_pProps->m_bDDE) { - OUString uTmp( - m_bIsDescriptor ? pProps->sCondition : pSect->GetCondition()); - pRet[nProperty] <<= uTmp; + sRet = m_pProps->m_sLinkFileName; } - break; - case WID_SECT_DDE_TYPE : - case WID_SECT_DDE_FILE : - case WID_SECT_DDE_ELEMENT : + } + else if (DDE_LINK_SECTION == pSect->GetType()) + { + sRet = pSect->GetLinkFileName(); + } + sal_Int32 nDummy(0); + sRet = sRet.getToken(pEntry->nWID - WID_SECT_DDE_TYPE, + sfx2::cTokenSeperator, nDummy); + pRet[nProperty] <<= sRet; + } + break; + case WID_SECT_DDE_AUTOUPDATE: + { + // GetUpdateType() returns .._ALWAYS or .._ONCALL + if (pSect && pSect->IsLinkType() && pSect->IsConnected()) // lijian i73247 + { + const sal_Bool bTemp = + (pSect->GetUpdateType() == sfx2::LINKUPDATE_ALWAYS); + pRet[nProperty] <<= bTemp; + } + } + break; + case WID_SECT_LINK : + { + text::SectionFileLink aLink; + if (m_bIsDescriptor) + { + if (!m_pProps->m_bDDE) { - String sRet; - if(m_bIsDescriptor) - { - if(pProps->bDDE) - sRet = pProps->sLinkFileName; - } - else if( DDE_LINK_SECTION == pSect->GetType() ) - { - sRet = pSect->GetLinkFileName(); - } - sRet = sRet.GetToken(pEntry->nWID - WID_SECT_DDE_TYPE, sfx2::cTokenSeperator); - pRet[nProperty] <<= OUString(sRet); + aLink.FileURL = m_pProps->m_sLinkFileName; + aLink.FilterName = m_pProps->m_sSectionFilter; + } + } + else if (FILE_LINK_SECTION == pSect->GetType()) + { + ::rtl::OUString sRet( pSect->GetLinkFileName() ); + sal_Int32 nIndex(0); + aLink.FileURL = + sRet.getToken(0, sfx2::cTokenSeperator, nIndex); + aLink.FilterName = + sRet.getToken(0, sfx2::cTokenSeperator, nIndex); + } + pRet[nProperty] <<= aLink; + } + break; + case WID_SECT_REGION : + { + ::rtl::OUString sRet; + if (m_bIsDescriptor) + { + sRet = m_pProps->m_sSectionRegion; + } + else if (FILE_LINK_SECTION == pSect->GetType()) + { + sRet = pSect->GetLinkFileName().GetToken(2, + sfx2::cTokenSeperator); + } + pRet[nProperty] <<= sRet; + } + break; + case WID_SECT_VISIBLE : + { + const sal_Bool bTemp = (m_bIsDescriptor) + ? !m_pProps->m_bHidden : !pSect->IsHidden(); + pRet[nProperty] <<= bTemp; + } + break; + case WID_SECT_CURRENTLY_VISIBLE: + { + const sal_Bool bTemp = (m_bIsDescriptor) + ? !m_pProps->m_bCondHidden : !pSect->IsCondHidden(); + pRet[nProperty] <<= bTemp; + } + break; + case WID_SECT_PROTECTED: + { + const sal_Bool bTemp = (m_bIsDescriptor) + ? m_pProps->m_bProtect : pSect->IsProtect(); + pRet[nProperty] <<= bTemp; + } + break; + // --> FME 2004-06-22 #114856# edit in readonly sections + case WID_SECT_EDIT_IN_READONLY: + { + const sal_Bool bTemp = (m_bIsDescriptor) + ? m_pProps->m_bEditInReadonly : pSect->IsEditInReadonly(); + pRet[nProperty] <<= bTemp; + } + break; + // <-- + case FN_PARAM_LINK_DISPLAY_NAME: + { + if (pFmt) + { + pRet[nProperty] <<= OUString(pFmt->GetSection()->GetName()); + } + } + break; + case WID_SECT_DOCUMENT_INDEX: + { + // search enclosing index + SwSection* pEnclosingSection = pSect; + while ((pEnclosingSection != NULL) && + (TOX_CONTENT_SECTION != pEnclosingSection->GetType())) + { + pEnclosingSection = pEnclosingSection->GetParent(); + } + if (pEnclosingSection) + { + // convert section to TOXBase and get SwXDocumentIndex + SwTOXBaseSection *const pTOXBaseSect = + PTR_CAST(SwTOXBaseSection, pEnclosingSection); + const uno::Reference<text::XDocumentIndex> xIndex = + SwXDocumentIndex::CreateXDocumentIndex( + *pTOXBaseSect->GetFmt()->GetDoc(), *pTOXBaseSect); + pRet[nProperty] <<= xIndex; + } + // else: no enclosing index found -> empty return value + } + break; + case WID_SECT_IS_GLOBAL_DOC_SECTION: + { + const sal_Bool bRet = (NULL == pFmt) ? sal_False : + static_cast<sal_Bool>(NULL != pFmt->GetGlobalDocSection()); + pRet[nProperty] <<= bRet; + } + break; + case FN_UNO_ANCHOR_TYPES: + case FN_UNO_TEXT_WRAP: + case FN_UNO_ANCHOR_TYPE: + ::sw::GetDefaultTextContentValue( + pRet[nProperty], OUString(), pEntry->nWID); + break; + case FN_UNO_REDLINE_NODE_START: + case FN_UNO_REDLINE_NODE_END: + { + if (!pFmt) + break; // lijian i73247 + SwNode* pSectNode = pFmt->GetSectionNode(); + if (FN_UNO_REDLINE_NODE_END == pEntry->nWID) + { + pSectNode = pSectNode->EndOfSectionNode(); + } + const SwRedlineTbl& rRedTbl = + pFmt->GetDoc()->GetRedlineTbl(); + for (USHORT nRed = 0; nRed < rRedTbl.Count(); nRed++) + { + const SwRedline* pRedline = rRedTbl[nRed]; + SwNode const*const pRedPointNode = pRedline->GetNode(TRUE); + SwNode const*const pRedMarkNode = pRedline->GetNode(FALSE); + if ((pRedPointNode == pSectNode) || + (pRedMarkNode == pSectNode)) + { + SwNode const*const pStartOfRedline = + (SwNodeIndex(*pRedPointNode) <= + SwNodeIndex(*pRedMarkNode)) + ? pRedPointNode : pRedMarkNode; + const bool bIsStart = (pStartOfRedline == pSectNode); + pRet[nProperty] <<= + SwXRedlinePortion::CreateRedlineProperties( + *pRedline, bIsStart); + break; } - break; - case WID_SECT_DDE_AUTOUPDATE: + } + } + break; + case WID_SECT_PASSWORD: + { + pRet[nProperty] <<= (m_bIsDescriptor) + ? m_pProps->m_Password : pSect->GetPasswd(); + } + break; + default: + { + if (pFmt) + { + m_rPropSet.getPropertyValue(*pEntry, + pFmt->GetAttrSet(), pRet[nProperty]); + } + else + { + const SfxPoolItem* pQueryItem = 0; + if (RES_COL == pEntry->nWID) { - // GetUpdateType() returns .._ALWAYS or .._ONCALL - if ( pSect && pSect->IsLinkType() && pSect->IsConnected() ) // lijian i73247 + if (!m_pProps->m_pColItem.get()) { - sal_Bool bTemp = - (pSect->GetUpdateType() == sfx2::LINKUPDATE_ALWAYS); - pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType()); + m_pProps->m_pColItem.reset(new SwFmtCol); } + pQueryItem = m_pProps->m_pColItem.get(); } - break; - case WID_SECT_LINK : + else if (RES_BACKGROUND == pEntry->nWID) { - text::SectionFileLink aLink; - if(m_bIsDescriptor) - { - if(!pProps->bDDE) - { - aLink.FileURL = pProps->sLinkFileName; - aLink.FilterName = pProps->sSectionFilter; - } - } - else if( FILE_LINK_SECTION == pSect->GetType() ) + if (!m_pProps->m_pBrushItem.get()) { - String sRet( pSect->GetLinkFileName() ); - aLink.FileURL = sRet.GetToken(0, sfx2::cTokenSeperator ); - aLink.FilterName = sRet.GetToken(1, sfx2::cTokenSeperator ); + m_pProps->m_pBrushItem.reset( + new SvxBrushItem(RES_BACKGROUND)); } - pRet[nProperty].setValue(&aLink, ::getCppuType((text::SectionFileLink*)0)); + pQueryItem = m_pProps->m_pBrushItem.get(); } - break; - case WID_SECT_REGION : + else if (RES_FTN_AT_TXTEND == pEntry->nWID) { - String sRet; - if(m_bIsDescriptor) + if (!m_pProps->m_pFtnItem.get()) { - sRet = pProps->sSectionRegion; + m_pProps->m_pFtnItem.reset(new SwFmtFtnAtTxtEnd); } - else if( FILE_LINK_SECTION == pSect->GetType() ) - sRet = pSect->GetLinkFileName().GetToken(2, sfx2::cTokenSeperator); - pRet[nProperty] <<= OUString(sRet); - } - break; - case WID_SECT_VISIBLE : - { - sal_Bool bTemp = m_bIsDescriptor ? !pProps->bHidden : !pSect->IsHidden(); - pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType()); - } - break; - case WID_SECT_CURRENTLY_VISIBLE: - { - sal_Bool bTmp = m_bIsDescriptor ? !pProps->bCondHidden : !pSect->IsCondHidden(); - pRet[nProperty].setValue( &bTmp, ::getCppuBooleanType()); + pQueryItem = m_pProps->m_pFtnItem.get(); } - break; - case WID_SECT_PROTECTED: + else if (RES_END_AT_TXTEND == pEntry->nWID) { - sal_Bool bTemp = m_bIsDescriptor ? pProps->bProtect : pSect->IsProtect(); - pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType()); - } - break; - // --> FME 2004-06-22 #114856# edit in readonly sections - case WID_SECT_EDIT_IN_READONLY: - { - sal_Bool bTemp = m_bIsDescriptor ? pProps->bEditInReadonly : pSect->IsEditInReadonly(); - pRet[nProperty].setValue( &bTemp, ::getCppuBooleanType()); - } - break; - // <-- - case FN_PARAM_LINK_DISPLAY_NAME: - { - if(pFmt) - pRet[nProperty] <<= OUString(pFmt->GetSection()->GetName()); + if (!m_pProps->m_pEndItem.get()) + { + m_pProps->m_pEndItem.reset(new SwFmtEndAtTxtEnd); + } + pQueryItem = m_pProps->m_pEndItem.get(); } - break; - case WID_SECT_DOCUMENT_INDEX: + else if (RES_UNKNOWNATR_CONTAINER== pEntry->nWID) { - // search enclosing index - SwSection* pEnclosingSection = pSect; - while ( (pEnclosingSection != NULL) && - (TOX_CONTENT_SECTION != - pEnclosingSection->GetType()) ) + if (!m_pProps->m_pXMLAttr.get()) { - pEnclosingSection = pEnclosingSection->GetParent(); + m_pProps->m_pXMLAttr.reset( + new SvXMLAttrContainerItem); } - if (pEnclosingSection) + pQueryItem = m_pProps->m_pXMLAttr.get(); + } + else if (RES_COLUMNBALANCE== pEntry->nWID) + { + if (!m_pProps->m_pNoBalanceItem.get()) { - // convert section to TOXBase and get SwXDocumentIndex - SwTOXBaseSection* pTOXBaseSect = - PTR_CAST(SwTOXBaseSection, pEnclosingSection); - uno::Reference<XDocumentIndex> xIndex = - SwXDocumentIndexes::GetObject(pTOXBaseSect); - pRet[nProperty] <<= xIndex; + m_pProps->m_pNoBalanceItem.reset( + new SwFmtNoBalancedColumns); } - // else: no enclosing index found -> empty return value + pQueryItem = m_pProps->m_pNoBalanceItem.get(); } - break; - case WID_SECT_IS_GLOBAL_DOC_SECTION: + else if (RES_FRAMEDIR == pEntry->nWID) { - sal_Bool bRet = (NULL == pFmt) ? sal_False : - static_cast< sal_Bool >(NULL != pFmt->GetGlobalDocSection()); - pRet[nProperty].setValue( &bRet, ::getCppuBooleanType()); + if (!m_pProps->m_pFrameDirItem.get()) + { + m_pProps->m_pFrameDirItem.reset( + new SvxFrameDirectionItem( + FRMDIR_ENVIRONMENT, RES_FRAMEDIR)); + } + pQueryItem = m_pProps->m_pFrameDirItem.get(); } - break; - case FN_UNO_ANCHOR_TYPES: - case FN_UNO_TEXT_WRAP: - case FN_UNO_ANCHOR_TYPE: - SwXParagraph::getDefaultTextContentValue(pRet[nProperty], OUString(), pEntry->nWID); - break; - case FN_UNO_REDLINE_NODE_START: - case FN_UNO_REDLINE_NODE_END: + /* -> #109700# */ + else if (RES_LR_SPACE == pEntry->nWID) { - if(!pFmt) - break; // lijian i73247 - SwNode* pSectNode = pFmt->GetSectionNode(); - if(FN_UNO_REDLINE_NODE_END == pEntry->nWID) - pSectNode = pSectNode->EndOfSectionNode(); - const SwRedlineTbl& rRedTbl = pFmt->GetDoc()->GetRedlineTbl(); - for(USHORT nRed = 0; nRed < rRedTbl.Count(); nRed++) + if (!m_pProps->m_pLRSpaceItem.get()) { - const SwRedline* pRedline = rRedTbl[nRed]; - const SwNode* pRedPointNode = pRedline->GetNode(TRUE); - const SwNode* pRedMarkNode = pRedline->GetNode(FALSE); - if(pRedPointNode == pSectNode || pRedMarkNode == pSectNode) - { - const SwNode* pStartOfRedline = SwNodeIndex(*pRedPointNode) <= SwNodeIndex(*pRedMarkNode) ? - pRedPointNode : pRedMarkNode; - BOOL bIsStart = pStartOfRedline == pSectNode; - pRet[nProperty] <<= SwXRedlinePortion::CreateRedlineProperties(*pRedline, bIsStart); - break; - } + m_pProps->m_pLRSpaceItem.reset( + new SvxLRSpaceItem( RES_LR_SPACE )); } + pQueryItem = m_pProps->m_pLRSpaceItem.get(); } - break; - case WID_SECT_PASSWORD: + /* <- #109700# */ + if (pQueryItem) { - pRet[nProperty] <<= m_bIsDescriptor ? pProps->aPassword : pSect->GetPasswd(); + pQueryItem->QueryValue(pRet[nProperty], + pEntry->nMemberId); } - break; - default: - if(pFmt) - m_pPropSet->getPropertyValue(*pEntry, pFmt->GetAttrSet(), pRet[nProperty]); - else - { - const SfxPoolItem* pQueryItem = 0; - if(RES_COL == pEntry->nWID) - { - if(!pProps->pColItem) - pProps->pColItem = new SwFmtCol; - pQueryItem = pProps->pColItem; - } - else if(RES_BACKGROUND == pEntry->nWID) - { - if(!pProps->pBrushItem) - pProps->pBrushItem = new SvxBrushItem(RES_BACKGROUND); - pQueryItem = pProps->pBrushItem; - } - else if(RES_FTN_AT_TXTEND == pEntry->nWID) - { - if(!pProps->pFtnItem) - pProps->pFtnItem = new SwFmtFtnAtTxtEnd; - pQueryItem = pProps->pFtnItem; - } - else if(RES_END_AT_TXTEND == pEntry->nWID) - { - if(!pProps->pEndItem) - pProps->pEndItem = new SwFmtEndAtTxtEnd; - pQueryItem = pProps->pEndItem; - } - else if(RES_UNKNOWNATR_CONTAINER== pEntry->nWID) - { - if(!pProps->pXMLAttr) - pProps->pXMLAttr= new SvXMLAttrContainerItem ; - pQueryItem = pProps->pXMLAttr; - } - else if(RES_COLUMNBALANCE== pEntry->nWID) - { - if(!pProps->pNoBalanceItem) - pProps->pNoBalanceItem= new SwFmtNoBalancedColumns; - pQueryItem = pProps->pNoBalanceItem; - } - else if(RES_FRAMEDIR == pEntry->nWID) - { - if(!pProps->pFrameDirItem) - pProps->pFrameDirItem = new SvxFrameDirectionItem(FRMDIR_ENVIRONMENT, RES_FRAMEDIR); - pQueryItem = pProps->pFrameDirItem; - } - /* -> #109700# */ - else if(RES_LR_SPACE == pEntry->nWID) - { - if(!pProps->pLRSpaceItem) - pProps->pLRSpaceItem = new SvxLRSpaceItem( RES_LR_SPACE ); - pQueryItem = pProps->pLRSpaceItem; - } - /* <- #109700# */ - if(pQueryItem) - pQueryItem->QueryValue(pRet[nProperty], pEntry->nMemberId); - } } } - else - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames[nProperty], static_cast < cppu::OWeakObject * > ( this ) ); } } - else - throw uno::RuntimeException(); return aRet; } + /* -----------------------------04.11.03 10:43-------------------------------- ---------------------------------------------------------------------------*/ -Sequence< Any > SwXTextSection::getPropertyValues( - const Sequence< ::rtl::OUString >& rPropertyNames ) - throw(RuntimeException) +uno::Sequence< uno::Any > SAL_CALL +SwXTextSection::getPropertyValues( + const uno::Sequence< ::rtl::OUString >& rPropertyNames) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< Any > aValues; + uno::Sequence< uno::Any > aValues; // workaround for bad designed API try { - aValues = GetPropertyValues_Impl( rPropertyNames ); + aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames ); } - catch (UnknownPropertyException &) + catch (beans::UnknownPropertyException &) { - throw RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException(OUString( + RTL_CONSTASCII_USTRINGPARAM("Unknown property exception caught")), + static_cast<cppu::OWeakObject *>(this)); } - catch (WrappedTargetException &) + catch (lang::WrappedTargetException &) { - throw RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException(OUString( + RTL_CONSTASCII_USTRINGPARAM("WrappedTargetException caught")), + static_cast<cppu::OWeakObject *>(this)); } return aValues; @@ -1214,279 +1355,373 @@ Sequence< Any > SwXTextSection::getPropertyValues( /*-- 10.12.98 14:47:12--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXTextSection::getPropertyValue(const OUString& rPropertyName) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SAL_CALL +SwXTextSection::getPropertyValue(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< ::rtl::OUString > aPropertyNames(1); + + uno::Sequence< ::rtl::OUString > aPropertyNames(1); aPropertyNames.getArray()[0] = rPropertyName; - return GetPropertyValues_Impl(aPropertyNames).getConstArray()[0]; + return m_pImpl->GetPropertyValues_Impl(aPropertyNames).getConstArray()[0]; } /* -----------------------------12.02.01 10:30-------------------------------- ---------------------------------------------------------------------------*/ -void SwXTextSection::addPropertiesChangeListener( - const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, - const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) throw(RuntimeException) +void SAL_CALL SwXTextSection::addPropertiesChangeListener( + const uno::Sequence< OUString >& /*aPropertyNames*/, + const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) +throw (uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::addPropertiesChangeListener(): not implemented"); } + /* -----------------------------12.02.01 10:30-------------------------------- ---------------------------------------------------------------------------*/ -void SwXTextSection::removePropertiesChangeListener( +void SAL_CALL SwXTextSection::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(RuntimeException) +throw (uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::removePropertiesChangeListener(): not implemented"); } + /* -----------------------------12.02.01 10:30-------------------------------- ---------------------------------------------------------------------------*/ -void SwXTextSection::firePropertiesChangeEvent( - const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/, +void SAL_CALL SwXTextSection::firePropertiesChangeEvent( + const uno::Sequence< OUString >& /*aPropertyNames*/, const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ ) - throw(RuntimeException) + throw(uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::firePropertiesChangeEvent(): not implemented"); } + /*-- 10.12.98 14:47:13--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::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, + "SwXTextSection::addPropertyChangeListener(): not implemented"); } -/*-- 10.12.98 14:47:13--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXTextSection::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::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, + "SwXTextSection::removePropertyChangeListener(): not implemented"); } -/*-- 10.12.98 14:47:14--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXTextSection::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::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, + "SwXTextSection::addVetoableChangeListener(): not implemented"); } -/*-- 10.12.98 14:47:14--------------------------------------------------- - -----------------------------------------------------------------------*/ -void SwXTextSection::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) +void SAL_CALL +SwXTextSection::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - DBG_WARNING("not implemented"); + OSL_ENSURE(false, + "SwXTextSection::removeVetoableChangeListener(): not implemented"); } /*-- 08.11.00 10:47:55--------------------------------------------------- -----------------------------------------------------------------------*/ -PropertyState SwXTextSection::getPropertyState( const OUString& rPropertyName ) - throw(UnknownPropertyException, RuntimeException) +beans::PropertyState SAL_CALL +SwXTextSection::getPropertyState(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< OUString > aNames(1); + + uno::Sequence< OUString > aNames(1); aNames.getArray()[0] = rPropertyName; return getPropertyStates(aNames).getConstArray()[0]; } /*-- 08.11.00 10:47:55--------------------------------------------------- -----------------------------------------------------------------------*/ -Sequence< PropertyState > SwXTextSection::getPropertyStates( - const Sequence< OUString >& rPropertyNames ) - throw(UnknownPropertyException, RuntimeException) +uno::Sequence< beans::PropertyState > SAL_CALL +SwXTextSection::getPropertyStates( + const uno::Sequence< OUString >& rPropertyNames) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - Sequence< PropertyState > aStates(rPropertyNames.getLength()); - SwSectionFmt* pFmt = GetFmt(); - if(pFmt||m_bIsDescriptor) + + SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); + if (!pFmt && !m_pImpl->m_bIsDescriptor) { - PropertyState* pStates = aStates.getArray(); - const OUString* pNames = rPropertyNames.getConstArray(); - for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) + throw uno::RuntimeException(); + } + + uno::Sequence< beans::PropertyState > aStates(rPropertyNames.getLength()); + beans::PropertyState *const pStates = aStates.getArray(); + const OUString* pNames = rPropertyNames.getConstArray(); + for (sal_Int32 i = 0; i < rPropertyNames.getLength(); i++) + { + pStates[i] = beans::PropertyState_DEFAULT_VALUE; + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName( pNames[i]); + if (!pEntry) + { + throw beans::UnknownPropertyException( + OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: ")) + + pNames[i], static_cast< cppu::OWeakObject* >(this)); + } + switch (pEntry->nWID) { - pStates[i] = PropertyState_DEFAULT_VALUE; - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( pNames[i]); - if(!pEntry) - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) ); - switch(pEntry->nWID) + case WID_SECT_CONDITION: + case WID_SECT_DDE_TYPE: + case WID_SECT_DDE_FILE: + case WID_SECT_DDE_ELEMENT: + case WID_SECT_DDE_AUTOUPDATE: + case WID_SECT_LINK: + case WID_SECT_REGION : + case WID_SECT_VISIBLE: + case WID_SECT_PROTECTED: + // --> FME 2004-06-22 #114856# edit in readonly sections + case WID_SECT_EDIT_IN_READONLY: + // <-- + case FN_PARAM_LINK_DISPLAY_NAME: + case FN_UNO_ANCHOR_TYPES: + case FN_UNO_TEXT_WRAP: + case FN_UNO_ANCHOR_TYPE: + pStates[i] = beans::PropertyState_DIRECT_VALUE; + break; + default: { - case WID_SECT_CONDITION: - case WID_SECT_DDE_TYPE : - case WID_SECT_DDE_FILE : - case WID_SECT_DDE_ELEMENT : - case WID_SECT_DDE_AUTOUPDATE: - case WID_SECT_LINK : - case WID_SECT_REGION : - case WID_SECT_VISIBLE : - case WID_SECT_PROTECTED: - // --> FME 2004-06-22 #114856# edit in readonly sections - case WID_SECT_EDIT_IN_READONLY: - // <-- - case FN_PARAM_LINK_DISPLAY_NAME: - case FN_UNO_ANCHOR_TYPES: - case FN_UNO_TEXT_WRAP: - case FN_UNO_ANCHOR_TYPE: - pStates[i] = PropertyState_DIRECT_VALUE; - break; - default: - if(pFmt) - pStates[i] = m_pPropSet->getPropertyState(pNames[i], pFmt->GetAttrSet()); - else + if (pFmt) + { + pStates[i] = m_pImpl->m_rPropSet.getPropertyState( + pNames[i], pFmt->GetAttrSet()); + } + else + { + if (RES_COL == pEntry->nWID) { - if(RES_COL == pEntry->nWID) + if (!m_pImpl->m_pProps->m_pColItem.get()) { - if(!pProps->pColItem) - pStates[i] = PropertyState_DEFAULT_VALUE; - else - pStates[i] = PropertyState_DIRECT_VALUE; + pStates[i] = beans::PropertyState_DEFAULT_VALUE; } - else //if(RES_BACKGROUND == pEntry->nWID) + else + { + pStates[i] = beans::PropertyState_DIRECT_VALUE; + } + } + else //if(RES_BACKGROUND == pEntry->nWID) + { + if (!m_pImpl->m_pProps->m_pBrushItem.get()) { - if(!pProps->pBrushItem) - pStates[i] = PropertyState_DEFAULT_VALUE; - else - pStates[i] = PropertyState_DIRECT_VALUE; + pStates[i] = beans::PropertyState_DEFAULT_VALUE; + } + else + { + pStates[i] = beans::PropertyState_DIRECT_VALUE; } } + } } } } - else - throw RuntimeException(); return aStates; } + /*-- 08.11.00 10:47:55--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::setPropertyToDefault( const OUString& rPropertyName ) - throw(UnknownPropertyException, RuntimeException) +void SAL_CALL +SwXTextSection::setPropertyToDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwSectionFmt* pFmt = GetFmt(); - if(pFmt||m_bIsDescriptor) + + SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); + if (!pFmt && !m_pImpl->m_bIsDescriptor) { - SwSection aSection(CONTENT_SECTION, aEmptyStr); - SwSection* pSect = pFmt ? pFmt->GetSection() : 0; - if(pFmt) - aSection = *pSect; - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( rPropertyName ); - if(!pEntry) - throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertyToDefault: property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - SfxItemSet* pNewAttrSet = 0; - switch(pEntry->nWID) + throw uno::RuntimeException(); + } + + SwSection aSection(CONTENT_SECTION, aEmptyStr); + SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0; + if (pFmt) + { + aSection = *pSect; + } + 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 uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "setPropertyToDefault: property is read-only: ")) + + rPropertyName, + static_cast<cppu::OWeakObject *>(this)); + } + + ::std::auto_ptr<SfxItemSet> pNewAttrSet; + switch (pEntry->nWID) + { + case WID_SECT_CONDITION: { - case WID_SECT_CONDITION: + if (m_pImpl->m_bIsDescriptor) { - if(m_bIsDescriptor) - pProps->sCondition = aEmptyStr; - else - aSection.SetCondition(aEmptyStr); + m_pImpl->m_pProps->m_sCondition = aEmptyStr; } - break; - case WID_SECT_DDE_TYPE : - case WID_SECT_DDE_FILE : - case WID_SECT_DDE_ELEMENT : - case WID_SECT_LINK : - case WID_SECT_REGION : - aSection.SetType(CONTENT_SECTION); - break; - case WID_SECT_DDE_AUTOUPDATE: - aSection.SetUpdateType(sfx2::LINKUPDATE_ALWAYS); - break; - case WID_SECT_VISIBLE : + else { - if(m_bIsDescriptor) - pProps->bHidden = FALSE; - else - aSection.SetHidden(FALSE); + aSection.SetCondition(aEmptyStr); } - break; - case WID_SECT_PROTECTED: + } + break; + case WID_SECT_DDE_TYPE : + case WID_SECT_DDE_FILE : + case WID_SECT_DDE_ELEMENT : + case WID_SECT_LINK : + case WID_SECT_REGION : + aSection.SetType(CONTENT_SECTION); + break; + case WID_SECT_DDE_AUTOUPDATE: + aSection.SetUpdateType(sfx2::LINKUPDATE_ALWAYS); + break; + case WID_SECT_VISIBLE : + { + if (m_pImpl->m_bIsDescriptor) { - if(m_bIsDescriptor) - pProps->bProtect = FALSE; - else - aSection.SetProtect(FALSE); + m_pImpl->m_pProps->m_bHidden = false; } - break; - // --> FME 2004-06-22 #114856# edit in readonly sections - case WID_SECT_EDIT_IN_READONLY: + else { - if(m_bIsDescriptor) - pProps->bEditInReadonly = FALSE; - else - aSection.SetEditInReadonly(FALSE); + aSection.SetHidden(FALSE); } - break; - // <-- + } + break; + case WID_SECT_PROTECTED: + { + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_pProps->m_bProtect = false; + } + else + { + aSection.SetProtect(FALSE); + } + } + break; + // --> FME 2004-06-22 #114856# edit in readonly sections + case WID_SECT_EDIT_IN_READONLY: + { + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_pProps->m_bEditInReadonly = false; + } + else + { + aSection.SetEditInReadonly(FALSE); + } + } + break; + // <-- - case FN_UNO_ANCHOR_TYPES: - case FN_UNO_TEXT_WRAP: - case FN_UNO_ANCHOR_TYPE: - break; - default: - if(pEntry->nWID <= SFX_WHICH_MAX) + case FN_UNO_ANCHOR_TYPES: + case FN_UNO_TEXT_WRAP: + case FN_UNO_ANCHOR_TYPE: + break; + default: + { + if (pEntry->nWID <= SFX_WHICH_MAX) + { + if (pFmt) { - if(pFmt) + const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet(); + pNewAttrSet.reset( new SfxItemSet(*rOldAttrSet.GetPool(), + pEntry->nWID, pEntry->nWID, 0)); + pNewAttrSet->ClearItem(pEntry->nWID); + } + else + { + if (RES_COL == pEntry->nWID) { - const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet(); - pNewAttrSet = new SfxItemSet(*rOldAttrSet.GetPool(), - pEntry->nWID, pEntry->nWID, 0); - pNewAttrSet->ClearItem(pEntry->nWID); + m_pImpl->m_pProps->m_pColItem.reset(); } - else + else if (RES_BACKGROUND == pEntry->nWID) { - if(RES_COL == pEntry->nWID) - DELETEZ(pProps->pColItem); - else if(RES_BACKGROUND == pEntry->nWID) - DELETEZ(pProps->pBrushItem); + m_pImpl->m_pProps->m_pBrushItem.reset(); } } + } } - if(pFmt) + } + + if (pFmt) + { + SwDoc *const pDoc = pFmt->GetDoc(); + const SwSectionFmts& rFmts = pDoc->GetSections(); + UnoActionContext aContext(pDoc); + for (sal_uInt16 i = 0; i < rFmts.Count(); i++) { - SwDoc* pDoc = pFmt->GetDoc(); - const SwSectionFmts& rFmts = pDoc->GetSections(); - UnoActionContext aContext(pDoc); - for( sal_uInt16 i = 0; i < rFmts.Count(); i++ ) + if (rFmts[i]->GetSection()->GetName() == pSect->GetName()) { - if(rFmts[i]->GetSection()->GetName() == pSect->GetName()) + pDoc->ChgSection(i, aSection, pNewAttrSet.get(), + pDoc->IsInReading()); { - pDoc->ChgSection( i, aSection, pNewAttrSet, pDoc->IsInReading()); - - { - // temporarily remove actions to allow cursor update - UnoActionRemoveContext aRemoveContext( pDoc ); - } - - break; + // temporarily remove actions to allow cursor update + UnoActionRemoveContext aRemoveContext( pDoc ); } + break; } - delete pNewAttrSet; } } - else - throw RuntimeException(); } + /*-- 08.11.00 10:47:56--------------------------------------------------- -----------------------------------------------------------------------*/ -Any SwXTextSection::getPropertyDefault( const OUString& rPropertyName ) - throw(UnknownPropertyException, WrappedTargetException, RuntimeException) +uno::Any SAL_CALL +SwXTextSection::getPropertyDefault(const OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + uno::Any aRet; - SwSectionFmt* pFmt = GetFmt(); - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap()->getByName( rPropertyName ); + SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); if (!pEntry) - throw 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)); + } switch(pEntry->nWID) { @@ -1499,7 +1734,7 @@ Any SwXTextSection::getPropertyDefault( const OUString& rPropertyName ) aRet <<= OUString(); break; case WID_SECT_LINK : - aRet <<= SectionFileLink(); + aRet <<= text::SectionFileLink(); break; case WID_SECT_DDE_AUTOUPDATE: case WID_SECT_VISIBLE : @@ -1520,12 +1755,12 @@ Any SwXTextSection::getPropertyDefault( const OUString& rPropertyName ) case FN_UNO_ANCHOR_TYPES: case FN_UNO_TEXT_WRAP: case FN_UNO_ANCHOR_TYPE: - SwXParagraph::getDefaultTextContentValue(aRet, OUString(), pEntry->nWID); + ::sw::GetDefaultTextContentValue(aRet, OUString(), pEntry->nWID); break; default: if(pFmt && pEntry->nWID <= SFX_WHICH_MAX) { - SwDoc* pDoc = pFmt->GetDoc(); + SwDoc *const pDoc = pFmt->GetDoc(); const SfxPoolItem& rDefItem = pDoc->GetAttrPool().GetDefaultItem(pEntry->nWID); rDefItem.QueryValue(aRet, pEntry->nMemberId); @@ -1533,33 +1768,43 @@ Any SwXTextSection::getPropertyDefault( const OUString& rPropertyName ) } return aRet; } + /*-- 10.12.98 14:47:15--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXTextSection::getName(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXTextSection::getName() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - String sRet; - const SwSectionFmt* pFmt = GetFmt(); + + ::rtl::OUString sRet; + SwSectionFmt const*const pFmt = m_pImpl->GetSectionFmt(); if(pFmt) + { sRet = pFmt->GetSection()->GetName(); - else if(m_bIsDescriptor) - sRet = m_sName; + } + else if (m_pImpl->m_bIsDescriptor) + { + sRet = m_pImpl->m_sName; + } else + { throw uno::RuntimeException(); + } return sRet; } /*-- 10.12.98 14:47:16--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextSection::setName(const OUString& rName) throw( uno::RuntimeException ) +void SAL_CALL SwXTextSection::setName(const OUString& rName) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwSectionFmt* pFmt = GetFmt(); + + SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); if(pFmt) { SwSection aSection(CONTENT_SECTION, aEmptyStr); - SwSection* pSect = pFmt->GetSection(); + SwSection *const pSect = pFmt->GetSection(); aSection = *pSect; String sNewName(rName); aSection.SetName(sNewName); @@ -1569,9 +1814,13 @@ void SwXTextSection::setName(const OUString& rName) throw( uno::RuntimeException for( sal_uInt16 i = 0; i < rFmts.Count(); i++ ) { if(rFmts[i]->GetSection() == pSect) + { nApplyPos = i; + } else if(sNewName == rFmts[i]->GetSection()->GetName()) + { throw uno::RuntimeException(); + } } if(nApplyPos != USHRT_MAX) { @@ -1585,46 +1834,50 @@ void SwXTextSection::setName(const OUString& rName) throw( uno::RuntimeException } } } - else if(m_bIsDescriptor) - m_sName = String(rName); + else if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_sName = rName; + } else + { throw uno::RuntimeException(); + } } /* -----------------02.11.99 11:30------------------- --------------------------------------------------*/ -OUString SwXTextSection::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXTextSection::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXTextSection"); } + /* -----------------02.11.99 11:30------------------- --------------------------------------------------*/ -sal_Bool SwXTextSection::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +static char const*const g_ServicesTextSection[] = { - return !rServiceName.compareToAscii("com.sun.star.text.TextSection") || - !rServiceName.compareToAscii("com.sun.star.document.LinkTarget") || - !rServiceName.compareToAscii("com.sun.star.text.TextContent"); -} -/* -----------------02.11.99 11:30------------------- + "com.sun.star.text.TextContent", + "com.sun.star.text.TextSection", + "com.sun.star.document.LinkTarget", +}; +static const size_t g_nServicesTextSection( + sizeof(g_ServicesTextSection)/sizeof(g_ServicesTextSection[0])); - --------------------------------------------------*/ -uno::Sequence< OUString > SwXTextSection::getSupportedServiceNames(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXTextSection::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(3); - OUString* pArr = aRet.getArray(); - pArr[0] = C2U("com.sun.star.text.TextSection"); - pArr[1] = C2U("com.sun.star.document.LinkTarget"); - pArr[2] = C2U("com.sun.star.text.TextContent"); - return aRet; + return ::sw::SupportsServiceImpl( + g_nServicesTextSection, g_ServicesTextSection, rServiceName); } -/*-- 20.12.2005 10:27:33--------------------------------------------------- +/* -----------------02.11.99 11:30------------------- - -----------------------------------------------------------------------*/ -SwSectionFmt* SwXTextSection::GetFmt()const + --------------------------------------------------*/ +uno::Sequence< OUString > SAL_CALL +SwXTextSection::getSupportedServiceNames() throw (uno::RuntimeException) { - return m_pClient ? - const_cast<SwSectionFmt*>(static_cast< const SwSectionFmt* >(m_pClient->GetRegisteredIn())) - : 0; + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesTextSection, g_ServicesTextSection); } + diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index 4caa5a735e..4f20d516fe 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -61,20 +61,15 @@ #include <com/sun/star/text/HoriOrientation.hpp> #include <com/sun/star/style/LineNumberPosition.hpp> #include <com/sun/star/awt/XBitmap.hpp> -#ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif #include <com/sun/star/style/VerticalAlignment.hpp> -#include <unoobj.hxx> #include <vcl/font.hxx> #include <svx/flstitem.hxx> #include <vcl/metric.hxx> #include <svtools/ctrltool.hxx> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> -#ifndef _TOOLKIT_UNOHLP_HXX #include <toolkit/helper/vclunohelper.hxx> -#endif #include <svx/unofdesc.hxx> #include <fmtornt.hxx> #include <SwStyleNameMapper.hxx> diff --git a/sw/source/core/unocore/unosrch.cxx b/sw/source/core/unocore/unosrch.cxx index 8ee8e3e141..dfb21c071c 100644 --- a/sw/source/core/unocore/unosrch.cxx +++ b/sw/source/core/unocore/unosrch.cxx @@ -30,13 +30,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#include "unosrch.hxx" - +#include "unosrch.hxx" #include <doc.hxx> #include <hints.hxx> #include <unomap.hxx> -#include <unoobj.hxx> +#include <unobaseclass.hxx> +#include <unomid.h> + #include <vos/mutex.hxx> #include <vcl/svapp.hxx> #include "svx/unolingu.hxx" diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index bc3203f764..979d542a75 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <hintids.hxx> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> @@ -61,7 +60,7 @@ #include <unoprnms.hxx> #include <shellio.hxx> #include <docstyle.hxx> -#include <unoobj.hxx> +#include <unotextbodyhf.hxx> #include <fmthdft.hxx> #include <fmtpdsc.hxx> #include <tools/urlobj.hxx> @@ -74,16 +73,9 @@ #include <SwStyleNameMapper.hxx> #include <sfx2/printer.hxx> #include <com/sun/star/style/ParagraphStyleCategory.hpp> -/* -#include <com/sun/star/frame/XModel.hpp> -*/ #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPPP_ #include <com/sun/star/beans/NamedValue.hpp> -#endif #include <istyleaccess.hxx> #include <GetMetricVal.hxx> #include <fmtfsize.hxx> @@ -3444,6 +3436,29 @@ void SwXPageStyle::setPropertyValues( /* -----------------------------04.11.03 13:50-------------------------------- ---------------------------------------------------------------------------*/ +static uno::Reference<text::XText> +lcl_makeHeaderFooter( + const sal_uInt16 nRes, const bool bHeader, SwFrmFmt const*const pFrmFmt) +{ + if (!pFrmFmt) { return 0; } + + const SfxItemSet& rSet = pFrmFmt->GetAttrSet(); + const SfxPoolItem* pItem; + if (SFX_ITEM_SET == rSet.GetItemState(nRes, sal_True, &pItem)) + { + SwFrmFmt *const pHeadFootFmt = (bHeader) + ? static_cast<SwFmtHeader*>(const_cast<SfxPoolItem*>(pItem))-> + GetHeaderFmt() + : static_cast<SwFmtFooter*>(const_cast<SfxPoolItem*>(pItem))-> + GetFooterFmt(); + if (pHeadFootFmt) + { + return SwXHeadFootText::CreateXHeadFootText(*pHeadFootFmt, bHeader); + } + } + return 0; +} + uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( const uno::Sequence< OUString >& rPropertyNames ) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) @@ -3476,7 +3491,8 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( GetBasePool()->SetSearchMask(GetFamily(), nSaveMask ); } sal_uInt16 nRes = 0; - sal_Bool bHeader = sal_False, bAll = sal_False, bLeft = sal_False, bRight = sal_False; + bool bHeader = false; + sal_Bool bAll = sal_False, bLeft = sal_False, bRight = sal_False; switch(pEntry->nWID) { case FN_UNO_HEADER_ON: @@ -3582,7 +3598,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( case FN_UNO_HEADER_RIGHT : bRight = sal_True; goto Header; Header: - bHeader = sal_True; + bHeader = true; nRes = RES_HEADER; goto MakeObject; case FN_UNO_FOOTER : bAll = sal_True; goto Footer; @@ -3603,27 +3619,18 @@ MakeObject: // TextRight does the same as Text and is for // comptability only. if( bLeft && !bShare ) + { pFrmFmt = &rDesc.GetLeft(); + } else + { pFrmFmt = &rDesc.GetMaster(); - if(pFrmFmt) + } + const uno::Reference< text::XText > xRet = + lcl_makeHeaderFooter(nRes, bHeader, pFrmFmt); + if (xRet.is()) { - const SfxItemSet& rSet = pFrmFmt->GetAttrSet(); - const SfxPoolItem* pItem; - SwFrmFmt* pHeadFootFmt; - if(SFX_ITEM_SET == rSet.GetItemState(nRes, sal_True, &pItem) && - 0 != (pHeadFootFmt = bHeader ? - ((SwFmtHeader*)pItem)->GetHeaderFmt() : - ((SwFmtFooter*)pItem)->GetFooterFmt())) - { - // gibt es schon ein Objekt dafuer? - SwXHeadFootText* pxHdFt = (SwXHeadFootText*)SwClientIter( *pHeadFootFmt ). - First( TYPE( SwXHeadFootText )); - uno::Reference< text::XText > xRet = pxHdFt; - if(!pxHdFt) - xRet = new SwXHeadFootText(*pHeadFootFmt, bHeader); - pRet[nProp].setValue(&xRet, ::getCppuType((uno::Reference<text::XText>*)0)); - } + pRet[nProp] <<= xRet; } } break; diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index b2e863595f..1fcc59f1da 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -33,16 +33,12 @@ #include "precompiled_sw.hxx" - - // STL includes #include <list> #include <float.h> // for DBL_MIN #include <swtypes.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif #include <unotbl.hxx> #include <unostyle.hxx> #include <section.hxx> @@ -73,6 +69,7 @@ #include <com/sun/star/text/WrapTextMode.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> #include <com/sun/star/text/TableColumnSeparator.hpp> +#include <com/sun/star/text/XTextSection.hpp> #include <com/sun/star/table/ShadowFormat.hpp> #include <com/sun/star/table/TableBorder.hpp> #include <com/sun/star/table/TableBorderDistances.hpp> @@ -86,7 +83,9 @@ #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp> #include <com/sun/star/table/CellContentType.hpp> #include <unotbl.hxx> -#include <unoobj.hxx> +#include <unotextrange.hxx> +#include <unotextcursor.hxx> +#include <unoparagraph.hxx> #include <svl/zforlist.hxx> // SvNumberFormatter #include <svx/brkitem.hxx> #include <svx/shaditem.hxx> @@ -101,16 +100,15 @@ #include <frmatr.hxx> #include <crsskip.hxx> #include <unochart.hxx> +#include <sortopt.hxx> #include <rtl/math.hxx> + using namespace ::com::sun::star; using ::rtl::OUString; -//----------------------------------------------------------------------------- -// from unoobj.cxx -extern void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) throw (lang::IllegalArgumentException); -extern void lcl_setCharStyle(SwDoc* pDoc, const uno::Any aValue, SfxItemSet& rSet) throw (lang::IllegalArgumentException); +//----------------------------------------------------------------------------- // from swtable.cxx extern void lcl_GetTblBoxColStr( sal_uInt16 nCol, String& rNm ); @@ -895,25 +893,32 @@ const SwStartNode *SwXCell::GetStartNode() const return pSttNd; } -uno::Reference< text::XTextCursor > SwXCell::createCursor() throw (uno::RuntimeException) +uno::Reference< text::XTextCursor > +SwXCell::CreateCursor() throw (uno::RuntimeException) { return createTextCursor(); } /*-- 11.12.98 10:56:24--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXCell::IsValid() +bool SwXCell::IsValid() const { + // FIXME: this is now a const method, to make SwXText::IsValid invisible + // but the const_cast here are still ridiculous. TODO: find a better way. SwFrmFmt* pTblFmt = pBox ? GetFrmFmt() : 0; if(!pTblFmt) - pBox = 0; + { + const_cast<SwXCell*>(this)->pBox = 0; + } else { SwTable* pTable = SwTable::FindTable( pTblFmt ); - const SwTableBox* pFoundBox ; - pFoundBox = FindBox(pTable, pBox); - if(!pFoundBox) - pBox = 0; + SwTableBox const*const pFoundBox = + const_cast<SwXCell*>(this)->FindBox(pTable, pBox); + if (!pFoundBox) + { + const_cast<SwXCell*>(this)->pBox = 0; + } } return 0 != pBox; } @@ -1037,10 +1042,11 @@ uno::Reference< text::XTextCursor > SwXCell::createTextCursor(void) throw( uno: { const SwStartNode* pSttNd = pStartNode ? pStartNode : pBox->GetSttNd(); SwPosition aPos(*pSttNd); - SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, CURSOR_TBLTEXT, GetDoc()); - SwUnoCrsr* pUnoCrsr = pCrsr->GetCrsr(); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*GetDoc(), this, CURSOR_TBLTEXT, aPos); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); pUnoCrsr->Move(fnMoveForward, fnGoNode); - aRef = (text::XWordCursor*)pCrsr; + aRef = static_cast<text::XWordCursor*>(pXCursor); // // no Cursor in protected sections // SwCrsrSaveState aSave( *pUnoCrsr ); // if(pUnoCrsr->IsInProtectTable( sal_True ) || @@ -1060,7 +1066,8 @@ uno::Reference< text::XTextCursor > SwXCell::createTextCursorByRange(const uno: vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextCursor > aRef; SwUnoInternalPaM aPam(*GetDoc()); - if((pStartNode || IsValid()) && SwXTextRange::XTextRangeToSwPaM(aPam, xTextPosition)) + if ((pStartNode || IsValid()) + && ::sw::XTextRangeToSwPaM(aPam, xTextPosition)) { const SwStartNode* pSttNd = pStartNode ? pStartNode : pBox->GetSttNd(); //skip sections @@ -1069,7 +1076,11 @@ uno::Reference< text::XTextCursor > SwXCell::createTextCursorByRange(const uno: p1 = p1->StartOfSectionNode(); if( p1 == pSttNd ) - aRef = (text::XWordCursor*)new SwXTextCursor(this , *aPam.GetPoint(), CURSOR_TBLTEXT, GetDoc(), aPam.GetMark()); + { + aRef = static_cast<text::XWordCursor*>( + new SwXTextCursor(*GetDoc(), this, CURSOR_TBLTEXT, + *aPam.GetPoint(), aPam.GetMark())); + } } else throw uno::RuntimeException(); @@ -1212,15 +1223,16 @@ uno::Reference< container::XEnumeration > SwXCell::createEnumeration(void) thro { const SwStartNode* pSttNd = pBox->GetSttNd(); SwPosition aPos(*pSttNd); - SwUnoCrsr* pUnoCrsr = GetDoc()->CreateUnoCrsr(aPos, sal_False); - pUnoCrsr->Move( fnMoveForward, fnGoNode ); + ::std::auto_ptr<SwUnoCrsr> pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); - SwXParagraphEnumeration *pEnum = new SwXParagraphEnumeration(this, pUnoCrsr, CURSOR_TBLTEXT); - const SwTableNode* pTblNode = pSttNd->FindTableNode(); // remember table and start node for later travelling // (used in export of tables in tables) - pEnum->SetOwnTable( &pTblNode->GetTable() ); - pEnum->SetOwnStartNode( pSttNd ); + SwTable const*const pTable( & pSttNd->FindTableNode()->GetTable() ); + SwXParagraphEnumeration *const pEnum = + new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_TBLTEXT, + pSttNd, pTable); aRef = pEnum; // // no Cursor in protected sections @@ -1854,12 +1866,6 @@ uno::Reference< beans::XPropertySetInfo > SwXTextTableCursor::getPropertySetInf /*-- 11.12.98 12:16:17--------------------------------------------------- -----------------------------------------------------------------------*/ -extern sal_Bool lcl_setCrsrPropertyValue(const SfxItemPropertySimpleEntry* pEntry, - SwPaM& rPam, - SfxItemSet& rSet, - const uno::Any& aValue ) throw (lang::IllegalArgumentException); - - void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue) throw( beans::UnknownPropertyException, @@ -1903,16 +1909,21 @@ void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, } break; case FN_UNO_PARA_STYLE: - lcl_SetTxtFmtColl(aValue, *pUnoCrsr); + SwUnoCursorHelper::SetTxtFmtColl(aValue, *pUnoCrsr); break; default: { SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID ); - SwXTextCursor::GetCrsrAttr( pTblCrsr->GetSelRing(), aItemSet ); + SwUnoCursorHelper::GetCrsrAttr(pTblCrsr->GetSelRing(), + aItemSet); - if(!lcl_setCrsrPropertyValue( pEntry, pTblCrsr->GetSelRing(), aItemSet, aValue )) - m_pPropSet->setPropertyValue( *pEntry, aValue, aItemSet ); - SwXTextCursor::SetCrsrAttr( pTblCrsr->GetSelRing(), aItemSet, CRSR_ATTR_MODE_TABLE ); + if (!SwUnoCursorHelper::SetCursorPropertyValue( + *pEntry, aValue, pTblCrsr->GetSelRing(), aItemSet)) + { + m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet); + } + SwUnoCursorHelper::SetCrsrAttr(pTblCrsr->GetSelRing(), + aItemSet, nsSetAttrMode::SETATTR_DEFAULT, true); } } } @@ -1956,7 +1967,8 @@ uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName) break; case FN_UNO_PARA_STYLE: { - SwFmtColl* pFmt = SwXTextCursor::GetCurTxtFmtColl(*pUnoCrsr, FALSE); + SwFmtColl *const pFmt = + SwUnoCursorHelper::GetCurTxtFmtColl(*pUnoCrsr, FALSE); OUString sRet; if(pFmt) sRet = pFmt->GetName(); @@ -1970,7 +1982,8 @@ uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName) RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, 0L); // erstmal die Attribute des Cursors - SwXTextCursor::GetCrsrAttr(pTblCrsr->GetSelRing(), aSet); + SwUnoCursorHelper::GetCrsrAttr(pTblCrsr->GetSelRing(), + aSet); m_pPropSet->getPropertyValue(*pEntry, aSet, aRet); } } @@ -2469,7 +2482,7 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex { SwUnoInternalPaM aPam(*pDoc); //das muss jetzt sal_True liefern - SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); + ::sw::XTextRangeToSwPaM(aPam, xTextRange); { UnoActionContext aCont( pDoc ); @@ -3162,7 +3175,8 @@ uno::Sequence< beans::PropertyValue > SwXTextTable::createSortDescriptor(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - return SwXTextCursor::createSortDescriptor(sal_True); + + return SwUnoCursorHelper::CreateSortDescriptor(true); } /*-- 11.12.98 12:42:49--------------------------------------------------- @@ -3174,7 +3188,7 @@ void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor SwSortOptions aSortOpt; SwFrmFmt* pFmt = GetFrmFmt(); if(pFmt && - SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) + SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)) { SwTable* pTable = SwTable::FindTable( pFmt ); SwSelBoxes aBoxes; @@ -3474,7 +3488,8 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName) throw( be case FN_UNO_ANCHOR_TYPES: case FN_UNO_TEXT_WRAP: case FN_UNO_ANCHOR_TYPE: - SwXParagraph::getDefaultTextContentValue(aRet, OUString(), pEntry->nWID); + ::sw::GetDefaultTextContentValue( + aRet, OUString(), pEntry->nWID); break; case FN_UNO_RANGE_ROW_LABEL: { @@ -4157,11 +4172,16 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, default: { SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID ); - SwXTextCursor::GetCrsrAttr( pCrsr->GetSelRing(), aItemSet ); + SwUnoCursorHelper::GetCrsrAttr(pCrsr->GetSelRing(), + aItemSet); - if(!lcl_setCrsrPropertyValue( pEntry, pCrsr->GetSelRing(), aItemSet, aValue )) - m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet ); - SwXTextCursor::SetCrsrAttr(pCrsr->GetSelRing(), aItemSet, CRSR_ATTR_MODE_TABLE ); + if (!SwUnoCursorHelper::SetCursorPropertyValue( + *pEntry, aValue, pCrsr->GetSelRing(), aItemSet)) + { + m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet); + } + SwUnoCursorHelper::SetCrsrAttr(pCrsr->GetSelRing(), + aItemSet, nsSetAttrMode::SETATTR_DEFAULT, true); } } } @@ -4214,7 +4234,8 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName) throw( be break; case FN_UNO_PARA_STYLE: { - SwFmtColl* pTmpFmt = SwXTextCursor::GetCurTxtFmtColl(*pTblCrsr, FALSE); + SwFmtColl *const pTmpFmt = + SwUnoCursorHelper::GetCurTxtFmtColl(*pTblCrsr, FALSE); OUString sRet; if(pFmt) sRet = pTmpFmt->GetName(); @@ -4242,7 +4263,7 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName) throw( be 0L); // erstmal die Attribute des Cursors SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr); - SwXTextCursor::GetCrsrAttr(pCrsr->GetSelRing(), aSet); + SwUnoCursorHelper::GetCrsrAttr(pCrsr->GetSelRing(), aSet); m_pPropSet->getPropertyValue(*pEntry, aSet, aRet); } } @@ -4875,7 +4896,8 @@ double SwXCellRange::getNotANumber(void) throw( uno::RuntimeException ) uno::Sequence< beans::PropertyValue > SwXCellRange::createSortDescriptor(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - return SwXTextCursor::createSortDescriptor(sal_True); + + return SwUnoCursorHelper::CreateSortDescriptor(true); } /*-- 11.12.98 14:27:39--------------------------------------------------- @@ -4887,7 +4909,7 @@ void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rD SwSortOptions aSortOpt; SwFrmFmt* pFmt = GetFrmFmt(); if(pFmt && - SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) + SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)) { SwUnoTableCrsr* pTableCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr); pTableCrsr->MakeBoxSels(); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 3876f861b2..ddbb40bccf 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -34,12 +34,22 @@ #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/text/ControlCharacter.hpp> +#include <com/sun/star/text/TableColumnSeparator.hpp> + +#include <rtl/uuid.h> -#include <cmdid.h> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> -#include <rtl/uuid.h> -#include <unoobj.hxx> +#include <comphelper/sequence.hxx> + +#include <cmdid.h> +#include <unotextbodyhf.hxx> +#include <unotext.hxx> +#include <unotextrange.hxx> +#include <unotextcursor.hxx> +#include <unosection.hxx> +#include <unobookmark.hxx> +#include <unorefmark.hxx> #include <unoport.hxx> #include <unotbl.hxx> #include <unoidx.hxx> @@ -51,6 +61,7 @@ #include <unomap.hxx> #include <unoprnms.hxx> #include <undobj.hxx> +#include <unoparagraph.hxx> #include <unocrsrhelper.hxx> #include <docsh.hxx> #include <docary.hxx> @@ -60,37 +71,125 @@ #include <section.hxx> #include <IMark.hxx> #include <fmtanchr.hxx> +#include <fmtcntnt.hxx> #include <crsskip.hxx> #include <ndtxt.hxx> -#include <com/sun/star/text/TableColumnSeparator.hpp> + #include <memory> #include <stdlib.h> #include <iostream> + using namespace ::com::sun::star; using ::rtl::OUString; + const sal_Char cInvalidObject[] = "this object is invalid"; + /****************************************************************** * SwXText ******************************************************************/ + +class SwXText::Impl +{ + +public: + SwXText & m_rThis; + SfxItemPropertySet const& m_rPropSet; + const enum CursorType m_eType; + SwDoc * m_pDoc; + bool m_bIsValid; + + Impl( SwXText & rThis, + SwDoc *const pDoc, const enum CursorType eType) + : m_rThis(rThis) + , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT)) + , m_eType(eType) + , m_pDoc(pDoc) + , m_bIsValid(0 != pDoc) + { + } + + uno::Reference< text::XTextRange > + finishOrAppendParagraph( + const bool bFinish, + const uno::Sequence< beans::PropertyValue >& + rCharacterAndParagraphProperties) + throw (lang::IllegalArgumentException, uno::RuntimeException); + + sal_Int16 ComparePositions( + const uno::Reference<text::XTextRange>& xPos1, + const uno::Reference<text::XTextRange>& xPos2) + throw (lang::IllegalArgumentException, uno::RuntimeException); + + bool CheckForOwnMember(const SwPaM & rPaM) + throw (lang::IllegalArgumentException, uno::RuntimeException); + + void ConvertCell( + const bool bFirstCell, + const uno::Sequence< uno::Reference< text::XTextRange > > & rCell, + ::std::vector<SwNodeRange> & rRowNodes, + ::std::auto_ptr< SwPaM > & rpFirstPaM, + SwPaM & rLastPaM, + bool & rbExcept); + +}; + +/* -----------------------------15.03.2002 12:39------------------------------ + + ---------------------------------------------------------------------------*/ +SwXText::SwXText(SwDoc *const pDoc, const enum CursorType eType) + : m_pImpl( new SwXText::Impl(*this, pDoc, eType) ) +{ +} +/*-- 09.12.98 12:43:55--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwXText::~SwXText() +{ +} + /*-- 09.12.98 12:44:07--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::PrepareForAttach( ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange > &, - const SwXTextRange* const, const SwPaM * const) +const SwDoc * SwXText::GetDoc() const { + return m_pImpl->m_pDoc; +} + SwDoc * SwXText::GetDoc() +{ + return m_pImpl->m_pDoc; } -bool SwXText::CheckForOwnMemberMeta(const SwXTextRange* const, - const SwPaM* const, bool) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) +bool SwXText::IsValid() const { - ASSERT(CURSOR_META != eCrsrType, "should not be called!"); + return m_pImpl->m_bIsValid; +} + +void SwXText::Invalidate() +{ + m_pImpl->m_bIsValid = false; +} + +void SwXText::SetDoc(SwDoc *const pDoc) +{ + OSL_ENSURE(!m_pImpl->m_pDoc || !pDoc, + "SwXText::SetDoc: already have a doc?"); + m_pImpl->m_pDoc = pDoc; + m_pImpl->m_bIsValid = (0 != pDoc); +} + +void +SwXText::PrepareForAttach(uno::Reference< text::XTextRange > &, const SwPaM &) +{ +} + +bool SwXText::CheckForOwnMemberMeta(const SwPaM &, const bool) + throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + ASSERT(CURSOR_META != m_pImpl->m_eType, "should not be called!"); return false; } @@ -99,7 +198,8 @@ const SwStartNode *SwXText::GetStartNode() const return GetDoc()->GetNodes().GetEndOfContent().StartOfSectionNode(); } -uno::Reference< text::XTextCursor > SwXText::createCursor() throw (uno::RuntimeException) +uno::Reference< text::XTextCursor > +SwXText::CreateCursor() throw (uno::RuntimeException) { uno::Reference< text::XTextCursor > xRet; if(IsValid()) @@ -107,546 +207,457 @@ uno::Reference< text::XTextCursor > SwXText::createCursor() throw (uno::Runtim SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); SwPosition aPos(rNode); xRet = static_cast<text::XWordCursor*>( - new SwXTextCursor(this, aPos, GetTextType(), GetDoc())); + new SwXTextCursor(*GetDoc(), this, m_pImpl->m_eType, aPos)); xRet->gotoStart(sal_False); } return xRet; } -/* -----------------------------15.03.2002 12:39------------------------------ - ---------------------------------------------------------------------------*/ -SwXText::SwXText(SwDoc* pDc, CursorType eType) : - pDoc(pDc), - bObjectValid(0 != pDc), - eCrsrType(eType), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT)) -{ -} -/*-- 09.12.98 12:43:55--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwXText::~SwXText() -{ -} /*-- 09.12.98 12:43:02--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SAL_CALL SwXText::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException) -{ - const uno::Type& rXTextType = ::getCppuType((uno::Reference< text::XText >*)0); - const uno::Type& rXTextRangeCompareType = ::getCppuType((uno::Reference< text::XTextRangeCompare >*)0); - const uno::Type& rXSimpleTextType = ::getCppuType((const uno::Reference< XSimpleText >*)0); - const uno::Type& rXTextRangeType = ::getCppuType((uno::Reference< text::XTextRange >*)0); - const uno::Type& rXTypeProviderType = ::getCppuType((uno::Reference< lang::XTypeProvider >*)0); - const uno::Type& rXTextContentInsert = ::getCppuType((uno::Reference< text::XRelativeTextContentInsert >*)0); - const uno::Type& rXTextContentRemove = ::getCppuType((uno::Reference< text::XRelativeTextContentRemove >*)0); - const uno::Type& rXPropertySet = ::getCppuType((uno::Reference<beans::XPropertySet>*)0); - const uno::Type& rXUnoTunnel = ::getCppuType((uno::Reference< lang::XUnoTunnel >*)0); - const uno::Type& rXTextPortionAppend = ::getCppuType((uno::Reference< text::XTextPortionAppend >*)0); - const uno::Type& rXParagraphAppend = ::getCppuType((uno::Reference< text::XParagraphAppend >*)0); - const uno::Type& rXTextContentAppend = ::getCppuType((uno::Reference< text::XTextContentAppend >*)0); - const uno::Type& rXTextConvert = ::getCppuType((uno::Reference< text::XTextConvert >*)0); - const uno::Type& rXTextAppend = ::getCppuType((uno::Reference< text::XTextAppend >*)0); - const uno::Type& rXTextAppendAndConvert = ::getCppuType((uno::Reference< text::XTextAppendAndConvert >*)0); - +uno::Any SAL_CALL +SwXText::queryInterface(const uno::Type& rType) throw (uno::RuntimeException) +{ uno::Any aRet; - if(rType == rXTextType) + if (rType == text::XText::static_type()) { - uno::Reference< text::XText > xRet = this; - aRet.setValue(&xRet, rXTextType); + aRet <<= uno::Reference< text::XText >(this); } - else if(rType == rXSimpleTextType) + else if (rType == text::XSimpleText::static_type()) { - uno::Reference< XSimpleText > xRet = this; - aRet.setValue(&xRet, rXSimpleTextType); + aRet <<= uno::Reference< text::XSimpleText >(this); } - else if(rType == rXTextRangeType) + else if (rType == text::XTextRange::static_type()) { - uno::Reference< text::XTextRange > xRet = this; - aRet.setValue(&xRet, rXTextRangeType); + aRet <<= uno::Reference< text::XTextRange>(this); } - else if(rType == rXTextRangeCompareType) + else if (rType == text::XTextRangeCompare::static_type()) { - uno::Reference< text::XTextRangeCompare > xRet = this; - aRet.setValue(&xRet, rXTextRangeCompareType); + aRet <<= uno::Reference< text::XTextRangeCompare >(this); } - else if(rType == rXTypeProviderType) + else if (rType == lang::XTypeProvider::static_type()) { - uno::Reference< lang::XTypeProvider > xRet = this; - aRet.setValue(&xRet, rXTypeProviderType); + aRet <<= uno::Reference< lang::XTypeProvider >(this); } - else if(rType == rXTextContentInsert) + else if (rType == text::XRelativeTextContentInsert::static_type()) { - uno::Reference< text::XRelativeTextContentInsert > xRet = this; - aRet.setValue(&xRet, rXTextContentInsert); + aRet <<= uno::Reference< text::XRelativeTextContentInsert >(this); } - else if(rType == rXTextContentRemove) + else if (rType == text::XRelativeTextContentRemove::static_type()) { - uno::Reference< text::XRelativeTextContentRemove > xRet = this; - aRet.setValue(&xRet, rXTextContentRemove); + aRet <<= uno::Reference< text::XRelativeTextContentRemove >(this); } - else if(rType == rXPropertySet) + else if (rType == beans::XPropertySet::static_type()) { - uno::Reference< beans::XPropertySet > xRet = this; - aRet.setValue(&xRet, rXPropertySet); + aRet <<= uno::Reference< beans::XPropertySet >(this); } - else if(rType == rXUnoTunnel ) + else if (rType == lang::XUnoTunnel::static_type()) { - uno::Reference< lang::XUnoTunnel > xRet = this; - aRet.setValue(&xRet, rXUnoTunnel); + aRet <<= uno::Reference< lang::XUnoTunnel >(this); } - else if(rType == rXTextAppendAndConvert ) + else if (rType == text::XTextAppendAndConvert::static_type()) { - uno::Reference< XTextAppendAndConvert > xRet = this; - aRet.setValue(&xRet, rXTextAppendAndConvert); + aRet <<= uno::Reference< text::XTextAppendAndConvert >(this); } - else if(rType == rXTextAppend ) + else if (rType == text::XTextAppend::static_type()) { - uno::Reference< XTextAppend > xRet = this; - aRet.setValue(&xRet, rXTextAppend); + aRet <<= uno::Reference< text::XTextAppend >(this); } - else if(rType == rXTextPortionAppend ) + else if (rType == text::XTextPortionAppend::static_type()) { - uno::Reference< XTextPortionAppend > xRet = this; - aRet.setValue(&xRet, rXTextPortionAppend); + aRet <<= uno::Reference< text::XTextPortionAppend >(this); } - else if(rType == rXParagraphAppend ) + else if (rType == text::XParagraphAppend::static_type()) { - uno::Reference< XParagraphAppend > xRet = this; - aRet.setValue(&xRet, rXParagraphAppend ); + aRet <<= uno::Reference< text::XParagraphAppend >(this); } - else if(rType == rXTextConvert ) + else if (rType == text::XTextConvert::static_type() ) { - uno::Reference< XTextConvert > xRet = this; - aRet.setValue(&xRet, rXParagraphAppend ); + aRet <<= uno::Reference< text::XTextConvert >(this); } - else if(rType == rXTextContentAppend ) + else if (rType == text::XTextContentAppend::static_type()) { - uno::Reference< XTextContentAppend > xRet = this; - aRet.setValue(&xRet, rXTextContentAppend ); + aRet <<= uno::Reference< text::XTextContentAppend >(this); } return aRet; } /* -----------------------------15.03.00 17:42-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Type > SAL_CALL SwXText::getTypes() throw(uno::RuntimeException) +uno::Sequence< uno::Type > SAL_CALL +SwXText::getTypes() throw (uno::RuntimeException) { uno::Sequence< uno::Type > aRet(12); uno::Type* pTypes = aRet.getArray(); - pTypes[0] = ::getCppuType((uno::Reference< text::XText >*)0); - pTypes[1] = ::getCppuType((uno::Reference< text::XTextRangeCompare >*)0); - pTypes[2] = ::getCppuType((uno::Reference< text::XRelativeTextContentInsert >*)0); - pTypes[3] = ::getCppuType((uno::Reference< text::XRelativeTextContentRemove >*)0); - pTypes[4] = ::getCppuType((uno::Reference< lang::XUnoTunnel >*)0); - pTypes[5] = ::getCppuType((uno::Reference< beans::XPropertySet >*)0); - pTypes[6] = ::getCppuType((uno::Reference< text::XTextPortionAppend >*)0); - pTypes[7] = ::getCppuType((uno::Reference< text::XParagraphAppend >*)0); - pTypes[8] = ::getCppuType((uno::Reference< text::XTextContentAppend >*)0); - pTypes[9] = ::getCppuType((uno::Reference< text::XTextConvert >*)0); - pTypes[10] = ::getCppuType((uno::Reference< text::XTextAppend >*)0); - pTypes[11] = ::getCppuType((uno::Reference< text::XTextAppendAndConvert >*)0); + pTypes[0] = text::XText::static_type(); + pTypes[1] = text::XTextRangeCompare::static_type(); + pTypes[2] = text::XRelativeTextContentInsert::static_type(); + pTypes[3] = text::XRelativeTextContentRemove::static_type(); + pTypes[4] = lang::XUnoTunnel::static_type(); + pTypes[5] = beans::XPropertySet::static_type(); + pTypes[6] = text::XTextPortionAppend::static_type(); + pTypes[7] = text::XParagraphAppend::static_type(); + pTypes[8] = text::XTextContentAppend::static_type(); + pTypes[9] = text::XTextConvert::static_type(); + pTypes[10] = text::XTextAppend::static_type(); + pTypes[11] = text::XTextAppendAndConvert::static_type(); return aRet; } // belongs the range in the text ? insert it then. -void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, - const OUString& aString, - sal_Bool bAbsorb) - throw( uno::RuntimeException ) +void SAL_CALL +SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, + const OUString& rString, sal_Bool bAbsorb) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(GetDoc() && xTextRange.is()) + + if (!xTextRange.is()) { - uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) + throw uno::RuntimeException(); + } + if (!GetDoc()) + { + throw uno::RuntimeException(); + } + const uno::Reference<lang::XUnoTunnel> xRangeTunnel(xTextRange, + uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel); + if ((!pRange || pRange ->GetDoc() != GetDoc()) && + (!pCursor || pCursor->GetDoc() != GetDoc())) + { + throw uno::RuntimeException(); + } + + const SwStartNode *const pOwnStartNode = GetStartNode(); + SwPaM aPam(GetDoc()->GetNodes()); + const SwPaM * pPam(0); + if (pCursor) + { + pPam = pCursor->GetPaM(); + } + else // pRange + { + if (pRange->GetPositions(aPam)) { - 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()) )); + pPam = &aPam; } + } + if (!pPam) + { + throw uno::RuntimeException(); + } - if( (pRange && pRange->GetDoc() == GetDoc()) || - (pCursor && pCursor->GetDoc() == GetDoc()) ) + const SwStartNode* pTmp(pPam->GetNode()->StartOfSectionNode()); + while (pTmp && pTmp->IsSectionNode()) + { + pTmp = pTmp->StartOfSectionNode(); + } + if (!pOwnStartNode || (pOwnStartNode != pTmp)) + { + throw uno::RuntimeException(); + } + + bool bForceExpandHints( false ); + if (CURSOR_META == m_pImpl->m_eType) + { + try { - const SwStartNode* pOwnStartNode = GetStartNode(); - if(pCursor) - { - const SwStartNode* pTmp = pCursor->GetPaM()->GetNode()->StartOfSectionNode(); - while(pTmp && pTmp->IsSectionNode()) - { - pTmp = pTmp->StartOfSectionNode(); - } - if( !pOwnStartNode || pOwnStartNode != pTmp) - { - throw uno::RuntimeException(); - } - } - else //dann pRange - { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - const SwStartNode* pTmp = pBkmk->GetMarkPos().nNode.GetNode().StartOfSectionNode(); - while(pTmp && pTmp->IsSectionNode()) - pTmp = pTmp->StartOfSectionNode(); - if(!pOwnStartNode || pOwnStartNode != pTmp) - throw uno::RuntimeException(); - } - bool bForceExpandHints( false ); - if (CURSOR_META == eCrsrType) - { - try - { - bForceExpandHints = CheckForOwnMemberMeta( - pRange, (pCursor) ? pCursor->GetPaM() : 0, bAbsorb); - } - catch (lang::IllegalArgumentException & iae) - { - // stupid method not allowed to throw iae - throw uno::RuntimeException(iae.Message, 0); - } - } - if(bAbsorb) + bForceExpandHints = CheckForOwnMemberMeta(*pPam, bAbsorb); + } + catch (lang::IllegalArgumentException & iae) + { + // stupid method not allowed to throw iae + throw uno::RuntimeException(iae.Message, 0); + } + } + if (bAbsorb) + { + //!! scan for CR characters and inserting the paragraph breaks + //!! has to be done in the called function. + //!! Implemented in SwXTextRange::DeleteAndInsert + if (pCursor) + { + SwXTextCursor * const pTextCursor( + dynamic_cast<SwXTextCursor*>(pCursor) ); + if (pTextCursor) { - //!! scan for CR characters and inserting the paragraph breaks - //!! has to be done in the called function. - //!! Implemented in SwXTextRange::DeleteAndInsert - if (pCursor) - { - SwXTextCursor * const pTextCursor( dynamic_cast<SwXTextCursor*>(pCursor) ); - if (pTextCursor) - { - pTextCursor->DeleteAndInsert(aString, bForceExpandHints); - } - else - { - xTextRange->setString(aString); - } - } - else - { - pRange->DeleteAndInsert(aString, bForceExpandHints); - } + pTextCursor->DeleteAndInsert(rString, bForceExpandHints); } else { - //hier wird ein PaM angelegt, der vor dem Parameter-PaM liegt, damit der - //Text davor eingefuegt wird - UnoActionContext aContext(GetDoc()); - const SwPosition* pPos = pCursor - ? pCursor->GetPaM()->Start() - : &pRange->GetBookmark()->GetMarkStart(); - SwPaM aInsertPam(*pPos); - const sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); - GetDoc()->DoGroupUndo(sal_False); - - SwUnoCursorHelper::DocInsertStringSplitCR( - *GetDoc(), aInsertPam, aString, bForceExpandHints ); - GetDoc()->DoGroupUndo(bGroupUndo); + xTextRange->setString(rString); } } else - throw uno::RuntimeException(); + { + pRange->DeleteAndInsert(rString, bForceExpandHints); + } } else - throw uno::RuntimeException(); + { + // create a PaM positioned before the parameter PaM, + // so the text is inserted before + UnoActionContext aContext(GetDoc()); + SwPaM aInsertPam(*pPam->Start()); + const sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); + GetDoc()->DoGroupUndo(sal_False); + + SwUnoCursorHelper::DocInsertStringSplitCR( + *GetDoc(), aInsertPam, rString, bForceExpandHints ); + GetDoc()->DoGroupUndo(bGroupUndo); + } } /*-- 09.12.98 12:43:16--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & xTextRange, - sal_Int16 nControlCharacter, sal_Bool bAbsorb) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXText::insertControlCharacter( + const uno::Reference< text::XTextRange > & xTextRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if (!xTextRange.is()) + { throw lang::IllegalArgumentException(); - if (GetDoc()) + } + if (!GetDoc()) { - SwUnoInternalPaM aPam(*GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange)) + throw uno::RuntimeException(); + } + + SwUnoInternalPaM aPam(*GetDoc()); + if (!::sw::XTextRangeToSwPaM(aPam, xTextRange)) + { + throw uno::RuntimeException(); + } + const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); + + const enum IDocumentContentOperations::InsertFlags nInsertFlags = + (bForceExpandHints) + ? static_cast<IDocumentContentOperations::InsertFlags>( + IDocumentContentOperations::INS_FORCEHINTEXPAND | + IDocumentContentOperations::INS_EMPTYEXPAND) + : IDocumentContentOperations::INS_EMPTYEXPAND; + + SwPaM aTmp(*aPam.Start()); + if (bAbsorb && aPam.HasMark()) + { + m_pImpl->m_pDoc->DeleteAndJoin(aPam); + } + + sal_Unicode cIns = 0; + switch (nControlCharacter) + { + case text::ControlCharacter::PARAGRAPH_BREAK : + // a table cell now becomes an ordinary text cell! + m_pImpl->m_pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode ); + m_pImpl->m_pDoc->SplitNode( *aTmp.GetPoint(), sal_False ); + break; + case text::ControlCharacter::APPEND_PARAGRAPH: { - const bool bForceExpandHints( - CheckForOwnMemberMeta( 0, &aPam, bAbsorb) ); - - const enum IDocumentContentOperations::InsertFlags nInsertFlags = - (bForceExpandHints) - ? static_cast<IDocumentContentOperations::InsertFlags>( - IDocumentContentOperations::INS_FORCEHINTEXPAND | - IDocumentContentOperations::INS_EMPTYEXPAND) - : IDocumentContentOperations::INS_EMPTYEXPAND; - - //Steuerzeichen einfuegen - SwPaM aTmp(*aPam.Start()); - if(bAbsorb && aPam.HasMark()) + m_pImpl->m_pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode ); + m_pImpl->m_pDoc->AppendTxtNode( *aTmp.GetPoint() ); + + const uno::Reference<lang::XUnoTunnel> xRangeTunnel( + xTextRange, uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation<OTextCursorHelper>( + xRangeTunnel); + if (pRange) { - pDoc->DeleteAndJoin(aPam); + pRange->SetPositions(aTmp); } - - sal_Unicode cIns = 0; - switch( nControlCharacter ) + else if (pCursor) { - case text::ControlCharacter::PARAGRAPH_BREAK : - // eine Tabellen Zelle wird jetzt zu einer normalen Textzelle! - pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode ); - pDoc->SplitNode( *aTmp.GetPoint(), sal_False ); - break; - case text::ControlCharacter::APPEND_PARAGRAPH: - { - pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode ); - pDoc->AppendTxtNode( *aTmp.GetPoint() ); - - uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) - { - 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()) )); - } - if(pRange) - { - pRange->_CreateNewBookmark(aTmp); - } - else if(pCursor) - { - SwPaM* pCrsr = pCursor->GetPaM(); - *pCrsr->GetPoint() = *aTmp.GetPoint(); - pCrsr->DeleteMark(); - } - } - break; - case text::ControlCharacter::LINE_BREAK: cIns = 10; break; - case text::ControlCharacter::SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break; - case text::ControlCharacter::HARD_HYPHEN: cIns = CHAR_HARDHYPHEN; break; - case text::ControlCharacter::HARD_SPACE: cIns = CHAR_HARDBLANK; break; + SwPaM *const pCrsr = pCursor->GetPaM(); + *pCrsr->GetPoint() = *aTmp.GetPoint(); + pCrsr->DeleteMark(); } - if( cIns ) + } + break; + case text::ControlCharacter::LINE_BREAK: cIns = 10; break; + case text::ControlCharacter::SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break; + case text::ControlCharacter::HARD_HYPHEN: cIns = CHAR_HARDHYPHEN; break; + case text::ControlCharacter::HARD_SPACE: cIns = CHAR_HARDBLANK; break; + } + if (cIns) + { + m_pImpl->m_pDoc->InsertString( aTmp, cIns, nInsertFlags ); + } + + if (bAbsorb) + { + const uno::Reference<lang::XUnoTunnel> xRangeTunnel( + xTextRange, uno::UNO_QUERY); + SwXTextRange *const pRange = + ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel); + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel); + + SwCursor aCrsr(*aTmp.GetPoint(),0,false); + SwUnoCursorHelper::SelectPam(aCrsr, true); + aCrsr.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); + //hier muss der uebergebene PaM umgesetzt werden: + if (pRange) + { + pRange->SetPositions(aCrsr); + } + else + { + SwPaM *const pUnoCrsr = pCursor->GetPaM(); + *pUnoCrsr->GetPoint() = *aCrsr.GetPoint(); + if (aCrsr.HasMark()) { - pDoc->InsertString( aTmp, cIns, nInsertFlags ); + pUnoCrsr->SetMark(); + *pUnoCrsr->GetMark() = *aCrsr.GetMark(); } - - if(bAbsorb) + else { - uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - if(xRangeTunnel.is()) - { - 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()) )); - } - - SwCursor aCrsr(*aTmp.GetPoint(),0,false); - SwXTextCursor::SelectPam(aCrsr, sal_True); - aCrsr.Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); - //hier muss der uebergebene PaM umgesetzt werden: - if(pRange) - pRange->_CreateNewBookmark(aCrsr); - else - { - SwPaM* pUnoCrsr = pCursor->GetPaM(); - *pUnoCrsr->GetPoint() = *aCrsr.GetPoint(); - if(aCrsr.HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *aCrsr.GetMark(); - } - else - pUnoCrsr->DeleteMark(); - } + pUnoCrsr->DeleteMark(); } } } - else - throw uno::RuntimeException(); } + /*-- 09.12.98 12:43:17--------------------------------------------------- -----------------------------------------------------------------------*/ - -void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRange, - const uno::Reference< text::XTextContent > & xContent, sal_Bool bAbsorb) - throw( lang::IllegalArgumentException, uno::RuntimeException ) +void SAL_CALL +SwXText::insertTextContent( + const uno::Reference< text::XTextRange > & xRange, + const uno::Reference< text::XTextContent > & xContent, + sal_Bool bAbsorb) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - // erstmal testen, ob der Range an der richtigen Stelle ist und dann - // am Sw-Content attachToRange aufrufen + + if (!xRange.is()) + { + lang::IllegalArgumentException aIllegal; + aIllegal.Message = C2U("first parameter invalid;"); + throw aIllegal; + } + if (!xContent.is()) + { + lang::IllegalArgumentException aIllegal; + aIllegal.Message += C2U("second parameter invalid"); + throw aIllegal; + } if(!GetDoc()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - if(xRange.is() && xContent.is()) - { - SwUnoInternalPaM aPam(*GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, xRange)) - { - uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; - SwXTextPortion* pPortion = 0; - SwXText* pText = 0; - if(xRangeTunnel.is()) - { - 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()) )); - pPortion = reinterpret_cast< SwXTextPortion * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextPortion::getUnoTunnelId()) )); - pText = reinterpret_cast< SwXText * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXText::getUnoTunnelId()) )); - } - - uno::Reference< text::XTextCursor > xOwnCursor = createCursor(); - uno::Reference<lang::XUnoTunnel> xOwnTunnel( xOwnCursor, uno::UNO_QUERY); -// OTextCursorHelper* pOwnCursor = reinterpret_cast< OTextCursorHelper * >( -// sal::static_int_cast< sal_IntPtr >( xOwnTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + SwUnoInternalPaM aPam(*GetDoc()); + if (!::sw::XTextRangeToSwPaM(aPam, xRange)) + { + lang::IllegalArgumentException aIllegal; + aIllegal.Message = C2U("first parameter invalid"); + throw aIllegal; + } + // first test if the range is at the right position, then call + // xContent->attach + const SwStartNode* pOwnStartNode = GetStartNode(); + SwStartNodeType eSearchNodeType = SwNormalStartNode; + switch (m_pImpl->m_eType) + { + case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break; + case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break; + case CURSOR_FOOTNOTE: eSearchNodeType = SwFootnoteStartNode; break; + case CURSOR_HEADER: eSearchNodeType = SwHeaderStartNode; break; + case CURSOR_FOOTER: eSearchNodeType = SwFooterStartNode; break; + //case CURSOR_INVALID: + //case CURSOR_BODY: + default: + break; + } - const SwStartNode* pOwnStartNode = GetStartNode(); - SwStartNodeType eSearchNodeType = SwNormalStartNode; - switch(eCrsrType) - { - case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break; - case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break; - case CURSOR_FOOTNOTE: eSearchNodeType = SwFootnoteStartNode; break; - case CURSOR_HEADER: eSearchNodeType = SwHeaderStartNode; break; - case CURSOR_FOOTER: eSearchNodeType = SwFooterStartNode; break; - //case CURSOR_INVALID: - //case CURSOR_BODY: - default: - ; - } + const SwStartNode* pTmp = + aPam.GetNode()->FindSttNodeByType(eSearchNodeType); - const SwNode* pSrcNode = 0; - if(pCursor && pCursor->GetPaM()) - { - pSrcNode = pCursor->GetPaM()->GetNode(); - } - else if (pRange && pRange->GetBookmark()) - { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - pSrcNode = &pBkmk->GetMarkPos().nNode.GetNode(); - } - else if (pPortion && pPortion->GetCursor()) - { - pSrcNode = pPortion->GetCursor()->GetNode(); - } - else if (pText) - { - uno::Reference<text::XTextCursor> xTextCursor = pText->createCursor(); - xTextCursor->gotoEnd(sal_True); - uno::Reference<lang::XUnoTunnel> xCrsrTunnel( xTextCursor, uno::UNO_QUERY ); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - pSrcNode = pCursor->GetPaM()->GetNode(); - } - else - throw lang::IllegalArgumentException(); + // ignore SectionNodes + while (pTmp && pTmp->IsSectionNode()) + { + pTmp = pTmp->StartOfSectionNode(); + } + // if the document starts with a section + while (pOwnStartNode->IsSectionNode()) + { + pOwnStartNode = pOwnStartNode->StartOfSectionNode(); + } + // this checks if (this) and xRange are in the same text::XText interface + if (pOwnStartNode != pTmp) + { + uno::RuntimeException aRunException; + aRunException.Message = C2U("text interface and cursor not related"); + throw aRunException; + } - const SwStartNode* pTmp = pSrcNode->FindSttNodeByType(eSearchNodeType); + const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb)); - //SectionNodes ueberspringen - while(pTmp && pTmp->IsSectionNode()) - { - pTmp = pTmp->StartOfSectionNode(); - } - //if the document starts with a section - while(pOwnStartNode->IsSectionNode()) - { - pOwnStartNode = pOwnStartNode->StartOfSectionNode(); - } - //this checks if (this) and xRange are in the same text::XText interface - if(pOwnStartNode != pTmp) - { - uno::RuntimeException aRunException; - aRunException.Message = C2U("text interface and cursor not related"); - throw aRunException; - } + // special treatment for Contents that do not replace the range, but + // instead are "overlaid" + const uno::Reference<lang::XUnoTunnel> xContentTunnel(xContent, + uno::UNO_QUERY); + if (!xContentTunnel.is()) + { + lang::IllegalArgumentException aArgException; + aArgException.Message = + C2U("text content does not support lang::XUnoTunnel"); + throw aArgException; + } + SwXDocumentIndexMark *const pDocumentIndexMark = + ::sw::UnoTunnelGetImplementation<SwXDocumentIndexMark>(xContentTunnel); + SwXTextSection *const pSection = + ::sw::UnoTunnelGetImplementation<SwXTextSection>(xContentTunnel); + SwXBookmark *const pBookmark = + ::sw::UnoTunnelGetImplementation<SwXBookmark>(xContentTunnel); + SwXReferenceMark *const pReferenceMark = + ::sw::UnoTunnelGetImplementation<SwXReferenceMark>(xContentTunnel); + SwXMeta *const pMeta = + ::sw::UnoTunnelGetImplementation<SwXMeta>(xContentTunnel); - const bool bForceExpandHints( CheckForOwnMemberMeta( - pRange, (pCursor) ? pCursor->GetPaM() : 0, bAbsorb) ); + const bool bAttribute = pBookmark || pDocumentIndexMark + || pSection || pReferenceMark || pMeta; - // Sonderbehandlung fuer Contents, die den Range nicht ersetzen, sonder darueber gelegt werden - // Bookmarks, IndexEntry - uno::Reference<lang::XUnoTunnel> xContentTunnel( xContent, uno::UNO_QUERY); - if(!xContentTunnel.is()) - { - lang::IllegalArgumentException aArgException; - aArgException.Message = C2U("text content doesn't support lang::XUnoTunnel"); - throw aArgException; - } - SwXDocumentIndexMark* pDocumentIndexMark = reinterpret_cast< SwXDocumentIndexMark * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXDocumentIndexMark::getUnoTunnelId()) )); - SwXTextSection* pSection = reinterpret_cast< SwXTextSection * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXTextSection::getUnoTunnelId()) )); - SwXBookmark* pBookmark = reinterpret_cast< SwXBookmark * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXBookmark::getUnoTunnelId()) )); - SwXReferenceMark* pReferenceMark = reinterpret_cast< SwXReferenceMark * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXReferenceMark::getUnoTunnelId()) )); - SwXMeta *const pMeta = reinterpret_cast< SwXMeta* >( - sal::static_int_cast< sal_IntPtr >( - xContentTunnel->getSomething( SwXMeta::getUnoTunnelId()))); - - const bool bAttribute = pBookmark || pDocumentIndexMark - || pSection || pReferenceMark || pMeta; - - if(bAbsorb && !bAttribute) - { - xRange->setString(aEmptyStr); - } - //hier wird tatsaechlich eingefuegt - uno::Reference< text::XTextRange > xTempRange; - if(bAttribute && bAbsorb) - xTempRange = xRange; - else - xTempRange = xRange->getStart(); - if (bForceExpandHints) - { - // if necessary, replace xTempRange with a new SwXTextCursor - PrepareForAttach(xTempRange, pRange, - (pCursor) ? pCursor->GetPaM() : 0); - } - xContent->attach(xTempRange); - } - else - { - lang::IllegalArgumentException aIllegal; - aIllegal.Message = C2U("first parameter invalid"); - throw aIllegal; - } + if (bAbsorb && !bAttribute) + { + xRange->setString(aEmptyStr); } - else + uno::Reference< text::XTextRange > xTempRange = + (bAttribute && bAbsorb) ? xRange : xRange->getStart(); + if (bForceExpandHints) { - lang::IllegalArgumentException aIllegal; - if(!xRange.is()) - aIllegal.Message = C2U("first parameter invalid;"); - if(!xContent.is()) - aIllegal.Message += C2U("second parameter invalid"); - throw aIllegal; + // if necessary, replace xTempRange with a new SwXTextCursor + PrepareForAttach(xTempRange, aPam); } - + xContent->attach(xTempRange); } + /* -----------------------------10.07.00 15:40-------------------------------- ---------------------------------------------------------------------------*/ -void SwXText::insertTextContentBefore( +void SAL_CALL +SwXText::insertTextContentBefore( const uno::Reference< text::XTextContent>& xNewContent, const uno::Reference< text::XTextContent>& xSuccessor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!GetDoc()) { uno::RuntimeException aRuntime; @@ -654,101 +665,123 @@ void SwXText::insertTextContentBefore( throw aRuntime; } - SwXParagraph* pPara = SwXParagraph::GetImplementation(xNewContent); - if(!pPara || !pPara->IsDescriptor() || !xSuccessor.is()) + const uno::Reference<lang::XUnoTunnel> xParaTunnel(xNewContent, + uno::UNO_QUERY); + SwXParagraph *const pPara = + ::sw::UnoTunnelGetImplementation<SwXParagraph>(xParaTunnel); + if (!pPara || !pPara->IsDescriptor() || !xSuccessor.is()) + { throw lang::IllegalArgumentException(); + } sal_Bool bRet = sal_False; - SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor ); - SwXTextTable* pXTable = SwXTextTable::GetImplementation(xSuccessor ); - SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; - SwUnoCrsr* pUnoCrsr = 0; + const uno::Reference<lang::XUnoTunnel> xSuccTunnel(xSuccessor, + uno::UNO_QUERY); + SwXTextSection *const pXSection = + ::sw::UnoTunnelGetImplementation<SwXTextSection>(xSuccTunnel); + SwXTextTable *const pXTable = + ::sw::UnoTunnelGetImplementation<SwXTextTable>(xSuccTunnel); + SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0; + SwTxtNode * pTxtNode = 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { - SwTable* pTable = SwTable::FindTable( pTableFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); + SwTable *const pTable = SwTable::FindTable( pTableFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); - SwNodeIndex aTblIdx( *pTblNode, -1 ); + const SwNodeIndex aTblIdx( *pTblNode, -1 ); SwPosition aBefore(aTblIdx); bRet = GetDoc()->AppendTxtNode( aBefore ); - pUnoCrsr = GetDoc()->CreateUnoCrsr( aBefore, FALSE); + pTxtNode = aBefore.nNode.GetNode().GetTxtNode(); } - else if(pXSection && - pXSection->GetFmt() && + else if (pXSection && pXSection->GetFmt() && pXSection->GetFmt()->GetDoc() == GetDoc()) { - SwSectionFmt* pSectFmt = pXSection->GetFmt(); - SwSectionNode* pSectNode = pSectFmt->GetSectionNode(); + SwSectionFmt *const pSectFmt = pXSection->GetFmt(); + SwSectionNode *const pSectNode = pSectFmt->GetSectionNode(); - SwNodeIndex aSectIdx( *pSectNode, -1 ); + const SwNodeIndex aSectIdx( *pSectNode, -1 ); SwPosition aBefore(aSectIdx); bRet = GetDoc()->AppendTxtNode( aBefore ); - pUnoCrsr = GetDoc()->CreateUnoCrsr( aBefore, FALSE); + pTxtNode = aBefore.nNode.GetNode().GetTxtNode(); } - if(!bRet) - throw lang::IllegalArgumentException(); - else + if (!bRet || !pTxtNode) { - pPara->attachToText(this, pUnoCrsr); + throw lang::IllegalArgumentException(); } - + pPara->attachToText(*this, *pTxtNode); } + /* -----------------------------10.07.00 15:40-------------------------------- ---------------------------------------------------------------------------*/ -void SwXText::insertTextContentAfter( +void SAL_CALL +SwXText::insertTextContentAfter( const uno::Reference< text::XTextContent>& xNewContent, const uno::Reference< text::XTextContent>& xPredecessor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!GetDoc()) + { throw uno::RuntimeException(); - SwXParagraph* pPara = SwXParagraph::GetImplementation(xNewContent); + } + + const uno::Reference<lang::XUnoTunnel> xParaTunnel(xNewContent, + uno::UNO_QUERY); + SwXParagraph *const pPara = + ::sw::UnoTunnelGetImplementation<SwXParagraph>(xParaTunnel); if(!pPara || !pPara->IsDescriptor() || !xPredecessor.is()) + { throw lang::IllegalArgumentException(); + } - SwUnoCrsr* pUnoCrsr = 0; - SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor ); - SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); - SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; + const uno::Reference<lang::XUnoTunnel> xPredTunnel(xPredecessor, + uno::UNO_QUERY); + SwXTextSection *const pXSection = + ::sw::UnoTunnelGetImplementation<SwXTextSection>(xPredTunnel); + SwXTextTable *const pXTable = + ::sw::UnoTunnelGetImplementation<SwXTextTable>(xPredTunnel); + SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0; sal_Bool bRet = sal_False; + SwTxtNode * pTxtNode = 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { - SwTable* pTable = SwTable::FindTable( pTableFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); + SwTable *const pTable = SwTable::FindTable( pTableFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); - SwEndNode* pTableEnd = pTblNode->EndOfSectionNode(); + SwEndNode *const pTableEnd = pTblNode->EndOfSectionNode(); SwPosition aTableEnd(*pTableEnd); bRet = GetDoc()->AppendTxtNode( aTableEnd ); - pUnoCrsr = GetDoc()->CreateUnoCrsr( aTableEnd, FALSE); + pTxtNode = aTableEnd.nNode.GetNode().GetTxtNode(); } - else if(pXSection && - pXSection->GetFmt() && + else if (pXSection && pXSection->GetFmt() && pXSection->GetFmt()->GetDoc() == GetDoc()) { - SwSectionFmt* pSectFmt = pXSection->GetFmt(); - SwSectionNode* pSectNode = pSectFmt->GetSectionNode(); - SwEndNode* pEnd = pSectNode->EndOfSectionNode(); + SwSectionFmt *const pSectFmt = pXSection->GetFmt(); + SwSectionNode *const pSectNode = pSectFmt->GetSectionNode(); + SwEndNode *const pEnd = pSectNode->EndOfSectionNode(); SwPosition aEnd(*pEnd); bRet = GetDoc()->AppendTxtNode( aEnd ); - pUnoCrsr = GetDoc()->CreateUnoCrsr( aEnd, FALSE); + pTxtNode = aEnd.nNode.GetNode().GetTxtNode(); } - if(!bRet) - throw lang::IllegalArgumentException(); - else + if (!bRet || !pTxtNode) { - pPara->attachToText(this, pUnoCrsr); + throw lang::IllegalArgumentException(); } + pPara->attachToText(*this, *pTxtNode); } + /* -----------------------------10.07.00 15:40-------------------------------- ---------------------------------------------------------------------------*/ -void SwXText::removeTextContentBefore( +void SAL_CALL +SwXText::removeTextContentBefore( const uno::Reference< text::XTextContent>& xSuccessor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!GetDoc()) { uno::RuntimeException aRuntime; @@ -757,29 +790,32 @@ void SwXText::removeTextContentBefore( } sal_Bool bRet = sal_False; - SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor ); - SwXTextTable* pXTable = SwXTextTable::GetImplementation( xSuccessor ); - SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; + const uno::Reference<lang::XUnoTunnel> xSuccTunnel(xSuccessor, + uno::UNO_QUERY); + SwXTextSection *const pXSection = + ::sw::UnoTunnelGetImplementation<SwXTextSection>(xSuccTunnel); + SwXTextTable *const pXTable = + ::sw::UnoTunnelGetImplementation<SwXTextTable>(xSuccTunnel); + SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { - SwTable* pTable = SwTable::FindTable( pTableFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); + SwTable *const pTable = SwTable::FindTable( pTableFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); - SwNodeIndex aTblIdx( *pTblNode, -1 ); + const SwNodeIndex aTblIdx( *pTblNode, -1 ); if(aTblIdx.GetNode().IsTxtNode()) { SwPaM aBefore(aTblIdx); bRet = GetDoc()->DelFullPara( aBefore ); } } - else if(pXSection && - pXSection->GetFmt() && + else if (pXSection && pXSection->GetFmt() && pXSection->GetFmt()->GetDoc() == GetDoc()) { - SwSectionFmt* pSectFmt = pXSection->GetFmt(); - SwSectionNode* pSectNode = pSectFmt->GetSectionNode(); + SwSectionFmt *const pSectFmt = pXSection->GetFmt(); + SwSectionNode *const pSectNode = pSectFmt->GetSectionNode(); - SwNodeIndex aSectIdx( *pSectNode, -1 ); + const SwNodeIndex aSectIdx( *pSectNode, -1 ); if(aSectIdx.GetNode().IsTxtNode()) { SwPaM aBefore(aSectIdx); @@ -787,15 +823,21 @@ void SwXText::removeTextContentBefore( } } if(!bRet) + { throw lang::IllegalArgumentException(); + } } + /* -----------------------------10.07.00 15:40-------------------------------- ---------------------------------------------------------------------------*/ -void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>& xPredecessor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +void SAL_CALL +SwXText::removeTextContentAfter( + const uno::Reference< text::XTextContent>& xPredecessor) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!GetDoc()) { uno::RuntimeException aRuntime; @@ -804,30 +846,33 @@ void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>& } sal_Bool bRet = sal_False; - SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor ); - SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); - SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; + const uno::Reference<lang::XUnoTunnel> xPredTunnel(xPredecessor, + uno::UNO_QUERY); + SwXTextSection *const pXSection = + ::sw::UnoTunnelGetImplementation<SwXTextSection>(xPredTunnel); + SwXTextTable *const pXTable = + ::sw::UnoTunnelGetImplementation<SwXTextTable>(xPredTunnel); + SwFrmFmt *const pTableFmt = (pXTable) ? pXTable->GetFrmFmt() : 0; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { - SwTable* pTable = SwTable::FindTable( pTableFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); - SwEndNode* pTableEnd = pTblNode->EndOfSectionNode(); + SwTable *const pTable = SwTable::FindTable( pTableFmt ); + SwTableNode *const pTblNode = pTable->GetTableNode(); + SwEndNode *const pTableEnd = pTblNode->EndOfSectionNode(); - SwNodeIndex aTblIdx( *pTableEnd, 1 ); + const SwNodeIndex aTblIdx( *pTableEnd, 1 ); if(aTblIdx.GetNode().IsTxtNode()) { SwPaM aPaM(aTblIdx); bRet = GetDoc()->DelFullPara( aPaM ); } } - else if(pXSection && - pXSection->GetFmt() && + else if (pXSection && pXSection->GetFmt() && pXSection->GetFmt()->GetDoc() == GetDoc()) { - SwSectionFmt* pSectFmt = pXSection->GetFmt(); - SwSectionNode* pSectNode = pSectFmt->GetSectionNode(); - SwEndNode* pEnd = pSectNode->EndOfSectionNode(); - SwNodeIndex aSectIdx( *pEnd, 1 ); + SwSectionFmt *const pSectFmt = pXSection->GetFmt(); + SwSectionNode *const pSectNode = pSectFmt->GetSectionNode(); + SwEndNode *const pEnd = pSectNode->EndOfSectionNode(); + const SwNodeIndex aSectIdx( *pEnd, 1 ); if(aSectIdx.GetNode().IsTxtNode()) { SwPaM aAfter(aSectIdx); @@ -835,42 +880,50 @@ void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>& } } if(!bRet) + { throw lang::IllegalArgumentException(); + } } + /*-- 09.12.98 12:43:19--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::removeTextContent(const uno::Reference< text::XTextContent > & xContent) - throw( container::NoSuchElementException, uno::RuntimeException ) +void SAL_CALL +SwXText::removeTextContent( + const uno::Reference< text::XTextContent > & xContent) +throw (container::NoSuchElementException, uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); + // forward: need no solar mutex here if(!xContent.is()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U("first parameter invalid"); throw aRuntime; } - else - xContent->dispose(); + xContent->dispose(); } + /*-- 09.12.98 12:43:22--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XText > SwXText::getText(void) - throw( uno::RuntimeException ) +uno::Reference< text::XText > SAL_CALL +SwXText::getText() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XText > xRet = (SwXText*)this; - return xRet; + const uno::Reference< text::XText > xRet(this); + return xRet; } + /*-- 09.12.98 12:43:24--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXText::getStart() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRef = createCursor(); + + const uno::Reference< text::XTextCursor > xRef = CreateCursor(); if(!xRef.is()) { uno::RuntimeException aRuntime; @@ -878,16 +931,18 @@ uno::Reference< text::XTextRange > SwXText::getStart(void) throw( uno::RuntimeE throw aRuntime; } xRef->gotoStart(sal_False); - uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); + const uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); return xRet; } /*-- 09.12.98 12:43:27--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SAL_CALL +SwXText::getEnd() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRef = createCursor(); + + const uno::Reference< text::XTextCursor > xRef = CreateCursor(); if(!xRef.is()) { uno::RuntimeException aRuntime; @@ -895,42 +950,52 @@ uno::Reference< text::XTextRange > SwXText::getEnd(void) throw( uno::RuntimeExc throw aRuntime; } xRef->gotoEnd(sal_False); - uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); + const uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); return xRet; } + /*-- 09.12.98 12:43:29--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXText::getString(void) throw( uno::RuntimeException ) +OUString SAL_CALL SwXText::getString() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRet = createCursor(); + + const uno::Reference< text::XTextCursor > xRet = CreateCursor(); if(!xRet.is()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - else - { - xRet->gotoEnd(sal_True); - } + xRet->gotoEnd(sal_True); return xRet->getString(); } /*-- 09.12.98 12:43:30--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::setString(const OUString& aString) throw( uno::RuntimeException ) +void SAL_CALL +SwXText::setString(const OUString& rString) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + if (!GetDoc()) + { + uno::RuntimeException aRuntime; + aRuntime.Message = C2U(cInvalidObject); + throw aRuntime; + } + const SwStartNode* pStartNode = GetStartNode(); - if(!pStartNode) + if (!pStartNode) + { throw uno::RuntimeException(); + } GetDoc()->StartUndo(UNDO_START, NULL); //insert an empty paragraph at the start and at the end to ensure that //all tables and sections can be removed by the selecting text::XTextCursor - if (CURSOR_META != eCrsrType) + if (CURSOR_META != m_pImpl->m_eType) { SwPosition aStartPos(*pStartNode); const SwEndNode* pEnd = pStartNode->EndOfSectionNode(); @@ -962,7 +1027,7 @@ void SwXText::setString(const OUString& aString) throw( uno::RuntimeException ) } } - uno::Reference< text::XTextCursor > xRet = createCursor(); + const uno::Reference< text::XTextCursor > xRet = CreateCursor(); if(!xRet.is()) { GetDoc()->EndUndo(UNDO_END, NULL); @@ -970,36 +1035,28 @@ void SwXText::setString(const OUString& aString) throw( uno::RuntimeException ) aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - else - { - xRet->gotoEnd(sal_True); - } - xRet->setString(aString); + xRet->gotoEnd(sal_True); + xRet->setString(rString); GetDoc()->EndUndo(UNDO_END, NULL); } //FIXME why is CheckForOwnMember duplicated in some insert methods? // Description: Checks if pRange/pCursor are member of the same text interface. // Only one of the pointers has to be set! -sal_Bool SwXText::CheckForOwnMember( - const SwXTextRange* pRange, - const OTextCursorHelper* pCursor) - throw(lang::IllegalArgumentException, uno::RuntimeException) +bool SwXText::Impl::CheckForOwnMember( + const SwPaM & rPaM) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - DBG_ASSERT((!pRange || !pCursor) && (pRange || pCursor), "only one pointer will be checked" ); - uno::Reference<text::XTextCursor> xOwnCursor = createCursor(); + const uno::Reference<text::XTextCursor> xOwnCursor(m_rThis.CreateCursor()); - uno::Reference<lang::XUnoTunnel> xTunnel( xOwnCursor, uno::UNO_QUERY); - OTextCursorHelper* pOwnCursor = 0; - if(xTunnel.is()) - { - pOwnCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(OTextCursorHelper::getUnoTunnelId()) )); - } + const uno::Reference<lang::XUnoTunnel> xTunnel(xOwnCursor, uno::UNO_QUERY); + OTextCursorHelper *const pOwnCursor = + ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xTunnel); DBG_ASSERT(pOwnCursor, "OTextCursorHelper::getUnoTunnelId() ??? "); - const SwStartNode* pOwnStartNode = pOwnCursor->GetPaM()->GetNode()->StartOfSectionNode(); + const SwStartNode* pOwnStartNode = + pOwnCursor->GetPaM()->GetNode()->StartOfSectionNode(); SwStartNodeType eSearchNodeType = SwNormalStartNode; - switch(eCrsrType) + switch (m_eType) { case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break; case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break; @@ -1012,105 +1069,62 @@ sal_Bool SwXText::CheckForOwnMember( ; } - const SwNode* pSrcNode; - if(pCursor) - pSrcNode = pCursor->GetPaM()->GetNode(); - else //dann pRange - { - ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); - pSrcNode = &pBkmk->GetMarkPos().nNode.GetNode(); - } + SwNode const*const pSrcNode(rPaM.GetNode()); + if (!pSrcNode) { return false; } const SwStartNode* pTmp = pSrcNode->FindSttNodeByType(eSearchNodeType); //SectionNodes ueberspringen while(pTmp && pTmp->IsSectionNode()) + { pTmp = pTmp->StartOfSectionNode(); + } //if the document starts with a section while(pOwnStartNode->IsSectionNode()) + { pOwnStartNode = pOwnStartNode->StartOfSectionNode(); + } //this checks if (this) and xRange are in the same text::XText interface - return(pOwnStartNode == pTmp); + return (pOwnStartNode == pTmp); } -sal_Int16 SwXText::ComparePositions( +sal_Int16 +SwXText::Impl::ComparePositions( const uno::Reference<text::XTextRange>& xPos1, const uno::Reference<text::XTextRange>& xPos2) - throw(lang::IllegalArgumentException, uno::RuntimeException) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - sal_Int16 nCompare = 0; - SwUnoInternalPaM aPam1(*GetDoc()); - SwUnoInternalPaM aPam2(*GetDoc()); + SwUnoInternalPaM aPam1(*m_pDoc); + SwUnoInternalPaM aPam2(*m_pDoc); - BOOL bExcept = FALSE; - if(SwXTextRange::XTextRangeToSwPaM(aPam1, xPos1) && - SwXTextRange::XTextRangeToSwPaM(aPam2, xPos2)) + if (!::sw::XTextRangeToSwPaM(aPam1, xPos1) || + !::sw::XTextRangeToSwPaM(aPam2, xPos2)) { - uno::Reference<lang::XUnoTunnel> xRangeTunnel1( xPos1, uno::UNO_QUERY); - SwXTextRange* pRange1 = 0; - OTextCursorHelper* pCursor1 = 0; - if(xRangeTunnel1.is()) - { - pRange1 = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel1->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor1 = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel1->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - } - uno::Reference<lang::XUnoTunnel> xRangeTunnel2( xPos2, uno::UNO_QUERY); - SwXTextRange* pRange2 = 0; - OTextCursorHelper* pCursor2 = 0; - if(xRangeTunnel2.is()) - { - pRange2 = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel2->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor2 = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel2->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - } - - if((pRange1||pCursor1) && (pRange2||pCursor2)) - { - if(CheckForOwnMember(pRange1, pCursor1) - && CheckForOwnMember( pRange2, pCursor2)) - { - const SwPosition *pStart1 = 0; - const SwPosition *pStart2 = 0; - - if(pRange1) - pStart1 = pRange1->GetBookmark() ? &(pRange1->GetBookmark()->GetMarkStart()) : 0; - else - pStart1 = pCursor1->GetPaM() ? pCursor1->GetPaM()->Start() : 0; - - if(pRange2) - pStart2 = pRange2->GetBookmark() ? &(pRange2->GetBookmark()->GetMarkStart()) : 0; - else - pStart2 = pCursor2->GetPaM() ? pCursor2->GetPaM()->Start() : 0; + throw lang::IllegalArgumentException(); + } + if (!CheckForOwnMember(aPam1) || !CheckForOwnMember(aPam2)) + { + throw lang::IllegalArgumentException(); + } - if(pStart1 && pStart2) - { - if(*pStart1 < *pStart2) - nCompare = 1; - else if(*pStart1 > *pStart2) - nCompare = -1; - else - { - DBG_ASSERT(*pStart1 == *pStart2, "SwPositions should be equal here"); - nCompare = 0; - } - } - else - bExcept = TRUE; - } - else - bExcept = TRUE; - } - else - bExcept = TRUE; + sal_Int16 nCompare = 0; + SwPosition const*const pStart1 = aPam1.Start(); + SwPosition const*const pStart2 = aPam2.Start(); + if (*pStart1 < *pStart2) + { + nCompare = 1; + } + else if (*pStart1 > *pStart2) + { + nCompare = -1; } else - bExcept = TRUE; - if(bExcept) - throw lang::IllegalArgumentException(); + { + DBG_ASSERT(*pStart1 == *pStart2, + "SwPositions should be equal here"); + nCompare = 0; + } return nCompare; } @@ -1118,50 +1132,64 @@ sal_Int16 SwXText::ComparePositions( /*-- 28.03.00 10:37:22--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int16 SwXText::compareRegionStarts( - const uno::Reference<text::XTextRange>& xR1, - const uno::Reference<text::XTextRange>& xR2) - throw(lang::IllegalArgumentException, uno::RuntimeException) +sal_Int16 SAL_CALL +SwXText::compareRegionStarts( + const uno::Reference<text::XTextRange>& xRange1, + const uno::Reference<text::XTextRange>& xRange2) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!xR1.is() || !xR2.is()) + + if (!xRange1.is() || !xRange2.is()) + { throw lang::IllegalArgumentException(); - uno::Reference<text::XTextRange> xStart1 = xR1->getStart(); - uno::Reference<text::XTextRange> xStart2 = xR2->getStart(); + } + const uno::Reference<text::XTextRange> xStart1 = xRange1->getStart(); + const uno::Reference<text::XTextRange> xStart2 = xRange2->getStart(); - return ComparePositions(xStart1, xStart2); + return m_pImpl->ComparePositions(xStart1, xStart2); } /*-- 28.03.00 10:37:25--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Int16 SwXText::compareRegionEnds( - const uno::Reference<text::XTextRange>& xR1, - const uno::Reference<text::XTextRange>& xR2) - throw(lang::IllegalArgumentException, uno::RuntimeException) +sal_Int16 SAL_CALL +SwXText::compareRegionEnds( + const uno::Reference<text::XTextRange>& xRange1, + const uno::Reference<text::XTextRange>& xRange2) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!xR1.is() || !xR2.is()) + + if (!xRange1.is() || !xRange2.is()) + { throw lang::IllegalArgumentException(); - uno::Reference<text::XTextRange> xEnd1 = xR1->getEnd(); - uno::Reference<text::XTextRange> xEnd2 = xR2->getEnd(); + } + uno::Reference<text::XTextRange> xEnd1 = xRange1->getEnd(); + uno::Reference<text::XTextRange> xEnd2 = xRange2->getEnd(); - return ComparePositions(xEnd1, xEnd2); + return m_pImpl->ComparePositions(xEnd1, xEnd2); } /*-- 15.03.2002 12:30:40--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXText::getPropertySetInfo( ) - throw(uno::RuntimeException) +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXText::getPropertySetInfo() throw(uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo = m_pPropSet->getPropertySetInfo(); + vos::OGuard g(Application::GetSolarMutex()); + + static uno::Reference< beans::XPropertySetInfo > xInfo = + m_pImpl->m_rPropSet.getPropertySetInfo(); return xInfo; } + /*-- 15.03.2002 12:30:42--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::setPropertyValue( const ::rtl::OUString& /*aPropertyName*/, const uno::Any& /*aValue*/ ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, +void SAL_CALL +SwXText::setPropertyValue(const ::rtl::OUString& /*aPropertyName*/, + const uno::Any& /*aValue*/) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { @@ -1170,100 +1198,113 @@ void SwXText::setPropertyValue( const ::rtl::OUString& /*aPropertyName*/, const /*-- 15.03.2002 12:30:42--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXText::getPropertyValue( - const ::rtl::OUString& rPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, - uno::RuntimeException) +uno::Any SAL_CALL +SwXText::getPropertyValue( + const ::rtl::OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) + { throw uno::RuntimeException(); - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); + } + + SfxItemPropertySimpleEntry const*const pEntry = + m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); + if (!pEntry) + { + beans::UnknownPropertyException aExcept; + aExcept.Message = C2U("Unknown property: "); + aExcept.Message += rPropertyName; + throw aExcept; + } + uno::Any aRet; - if(pEntry) + switch (pEntry->nWID) { - switch(pEntry->nWID) - { // no code necessary - the redline is always located at the end node // case FN_UNO_REDLINE_NODE_START: // break; - case FN_UNO_REDLINE_NODE_END: + case FN_UNO_REDLINE_NODE_END: + { + const SwRedlineTbl& rRedTbl = GetDoc()->GetRedlineTbl(); + const USHORT nRedTblCount = rRedTbl.Count(); + if (nRedTblCount > 0) { - const SwRedlineTbl& rRedTbl = GetDoc()->GetRedlineTbl(); - USHORT nRedTblCount = rRedTbl.Count(); - if ( nRedTblCount > 0 ) + SwStartNode const*const pStartNode = GetStartNode(); + const ULONG nOwnIndex = pStartNode->EndOfSectionIndex(); + for (USHORT nRed = 0; nRed < nRedTblCount; nRed++) { - const SwStartNode* pStartNode = GetStartNode(); - ULONG nOwnIndex = pStartNode->EndOfSectionIndex(); - for(USHORT nRed = 0; nRed < nRedTblCount; nRed++) + SwRedline const*const pRedline = rRedTbl[nRed]; + SwPosition const*const pRedStart = pRedline->Start(); + const SwNodeIndex nRedNode = pRedStart->nNode; + if (nOwnIndex == nRedNode.GetIndex()) { - const SwRedline* pRedline = rRedTbl[nRed]; - const SwPosition* pRedStart = pRedline->Start(); - const SwNodeIndex nRedNode = pRedStart->nNode; - if(nOwnIndex == nRedNode.GetIndex()) - { - aRet <<= SwXRedlinePortion::CreateRedlineProperties(*pRedline, TRUE); - break; - } + aRet <<= SwXRedlinePortion::CreateRedlineProperties( + *pRedline, TRUE); + break; } } } - break; } - } - else - { - beans::UnknownPropertyException aExcept; - aExcept.Message = C2U("Unknown property: "); - aExcept.Message += rPropertyName; - throw aExcept; + break; } return aRet; - } + /*-- 15.03.2002 12:30:42--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::addPropertyChangeListener( - const ::rtl::OUString& /*aPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, - uno::RuntimeException) +void SAL_CALL +SwXText::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - throw uno::RuntimeException(); + OSL_ENSURE(false, + "SwXText::addPropertyChangeListener(): not implemented"); } /*-- 15.03.2002 12:30:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::removePropertyChangeListener( - const ::rtl::OUString& /*aPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, - uno::RuntimeException) +void SAL_CALL +SwXText::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - throw uno::RuntimeException(); + OSL_ENSURE(false, + "SwXText::removePropertyChangeListener(): not implemented"); } /*-- 15.03.2002 12:30:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::addVetoableChangeListener( - const ::rtl::OUString& /*PropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, - uno::RuntimeException) +void SAL_CALL +SwXText::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) { - throw uno::RuntimeException(); + OSL_ENSURE(false, + "SwXText::addVetoableChangeListener(): not implemented"); } /*-- 15.03.2002 12:30:43--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXText::removeVetoableChangeListener( - const ::rtl::OUString& /*rPropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/ ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, +void SAL_CALL +SwXText::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - throw uno::RuntimeException(); + OSL_ENSURE(false, + "SwXText::removeVetoableChangeListener(): not implemented"); } /* -----------------------------08.01.01 09:07-------------------------------- @@ -1277,493 +1318,527 @@ const uno::Sequence< sal_Int8 > & SwXText::getUnoTunnelId() /* -----------------------------08.01.01 09:07-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SwXText::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL +SwXText::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<SwXText>(rId, this); } + /*-- 23.06.2006 08:56:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::appendParagraph( - const uno::Sequence< beans::PropertyValue > & rProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) +uno::Reference< text::XTextRange > SAL_CALL +SwXText::appendParagraph( + const uno::Sequence< beans::PropertyValue > & rProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - return finishOrAppendParagraph(false, rProperties); + vos::OGuard g(Application::GetSolarMutex()); + + return m_pImpl->finishOrAppendParagraph(false, rProperties); } /*-- 23.06.2006 08:56:22--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::finishParagraph( - const uno::Sequence< beans::PropertyValue > & rProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) +uno::Reference< text::XTextRange > SAL_CALL +SwXText::finishParagraph( + const uno::Sequence< beans::PropertyValue > & rProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - return finishOrAppendParagraph(true, rProperties); + vos::OGuard g(Application::GetSolarMutex()); + + return m_pImpl->finishOrAppendParagraph(true, rProperties); } /*-- 08.05.2006 13:26:26--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::finishOrAppendParagraph( - bool bFinish, - const uno::Sequence< beans::PropertyValue > & rProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) - +uno::Reference< text::XTextRange > +SwXText::Impl::finishOrAppendParagraph( + const bool bFinish, + const uno::Sequence< beans::PropertyValue > & rProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { - vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if (!m_bIsValid) + { throw uno::RuntimeException(); - uno::Reference< text::XTextRange > xRet; + } - const SwStartNode* pStartNode = GetStartNode(); + const SwStartNode* pStartNode = m_rThis.GetStartNode(); if(!pStartNode) + { throw uno::RuntimeException(); + } + + uno::Reference< text::XTextRange > xRet; + bool bIllegalException = false; + bool bRuntimeException = false; + ::rtl::OUString sMessage; + m_pDoc->StartUndo(UNDO_START , NULL); + // find end node, go backward - don't skip tables because the new + // paragraph has to be the last node + //aPam.Move( fnMoveBackward, fnGoNode ); + SwPosition aInsertPosition( + SwNodeIndex( *pStartNode->EndOfSectionNode(), -1 ) ); + SwPaM aPam(aInsertPosition); + m_pDoc->AppendTxtNode( *aPam.GetPoint() ); + // remove attributes from the previous paragraph + m_pDoc->ResetAttrs(aPam); + // in case of finishParagraph the PaM needs to be moved to the + // previous paragraph + if (bFinish) { - bool bIllegalException = false; - bool bRuntimeException = false; - ::rtl::OUString sMessage; - pDoc->StartUndo(UNDO_START , NULL); - //find end node, go backward - don't skip tables because the new paragraph has to be the last node - //aPam.Move( fnMoveBackward, fnGoNode ); - SwPosition aInsertPosition( SwNodeIndex( *pStartNode->EndOfSectionNode(), -1 ) ); - SwPaM aPam(aInsertPosition); - pDoc->AppendTxtNode( *aPam.GetPoint() ); - //remove attributes from the previous paragraph - pDoc->ResetAttrs(aPam); - //in case of finishParagraph the PaM needs to be moved to the previous paragraph - if(bFinish) - aPam.Move( fnMoveBackward, fnGoNode ); - if(rProperties.getLength()) - { - // now set the properties - const SfxItemPropertySet* pParaPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH); - const SfxItemPropertyMap* pParagraphMap = pParaPropSet->getPropertyMap(); + aPam.Move( fnMoveBackward, fnGoNode ); + } + if (rProperties.getLength()) + { + // now set the properties + SfxItemPropertySet const*const pParaPropSet = + aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH); + SfxItemPropertyMap const*const pParagraphMap = + pParaPropSet->getPropertyMap(); - const beans::PropertyValue* pValues = rProperties.getConstArray(); + const beans::PropertyValue* pValues = rProperties.getConstArray(); - for( sal_Int32 nProp = 0; nProp < rProperties.getLength(); ++nProp) + for (sal_Int32 nProp = 0; nProp < rProperties.getLength(); ++nProp) + { + if (!pParagraphMap->getByName(pValues[nProp].Name)) { - if(pParagraphMap->getByName( pValues[nProp].Name )) - { - try - { - SwXTextCursor::SetPropertyValue( - aPam, - *pParaPropSet, - pValues[nProp].Name, - pValues[nProp].Value); - } - catch( lang::IllegalArgumentException& rIllegal ) - { - sMessage = rIllegal.Message; - bIllegalException = true; - } - catch( uno::RuntimeException& rRuntime ) - { - sMessage = rRuntime.Message; - bRuntimeException = true; - } - } - else - bIllegalException = true; - if( bIllegalException || bRuntimeException ) - { - break; - } + bIllegalException = true; + break; } - } - pDoc->EndUndo(UNDO_END, NULL); - if( bIllegalException || bRuntimeException ) - { - SwUndoIter aUndoIter( &aPam, UNDO_EMPTY ); - pDoc->Undo(aUndoIter); - if(bIllegalException) + try + { + SwUnoCursorHelper::SetPropertyValue(aPam, *pParaPropSet, + pValues[nProp].Name, pValues[nProp].Value); + } + catch (lang::IllegalArgumentException& rIllegal) { - lang::IllegalArgumentException aEx; - aEx.Message = sMessage; - throw aEx; + sMessage = rIllegal.Message; + bIllegalException = true; + break; } - else //if(bRuntimeException) + catch (uno::RuntimeException& rRuntime) { - uno::RuntimeException aEx; - aEx.Message = sMessage; - throw aEx; + sMessage = rRuntime.Message; + bRuntimeException = true; + break; } } - SwTxtNode * pTxtNode( aPam.Start()->nNode.GetNode().GetTxtNode() ); - OSL_ENSURE(pTxtNode, "no SwTxtNode?"); - xRet = new SwXParagraph(this, pTxtNode); + } + m_pDoc->EndUndo(UNDO_END, NULL); + if (bIllegalException || bRuntimeException) + { + SwUndoIter aUndoIter( &aPam, UNDO_EMPTY ); + m_pDoc->Undo(aUndoIter); + if (bIllegalException) + { + lang::IllegalArgumentException aEx; + aEx.Message = sMessage; + throw aEx; + } + else // if(bRuntimeException) + { + uno::RuntimeException aEx; + aEx.Message = sMessage; + throw aEx; + } + } + SwTxtNode *const pTxtNode( aPam.Start()->nNode.GetNode().GetTxtNode() ); + OSL_ENSURE(pTxtNode, "no SwTxtNode?"); + if (pTxtNode) + { + xRet.set(SwXParagraph::CreateXParagraph(*m_pDoc, *pTxtNode, &m_rThis), + uno::UNO_QUERY); } return xRet; } + /*-- 08.05.2006 13:28:26--------------------------------------------------- Append text portions at the end of the last paragraph of the text interface. Support of import filters. -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::appendTextPortion( +uno::Reference< text::XTextRange > SAL_CALL +SwXText::appendTextPortion( const ::rtl::OUString& rText, - const uno::Sequence< beans::PropertyValue > & rCharacterAndParagraphProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) + const uno::Sequence< beans::PropertyValue > & + rCharacterAndParagraphProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) + { throw uno::RuntimeException(); - uno::Reference< text::XTextRange > xRet; - uno::Reference< text::XTextCursor > xTextCursor = createCursor(); + } + uno::Reference< text::XTextRange > xRet; + const uno::Reference< text::XTextCursor > xTextCursor = CreateCursor(); xTextCursor->gotoEnd(sal_False); - uno::Reference< lang::XUnoTunnel > xRangeTunnel( xTextCursor, uno::UNO_QUERY_THROW ); - SwXTextCursor* pTextCursor = reinterpret_cast< SwXTextCursor * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextCursor::getUnoTunnelId()))); - { - bool bIllegalException = false; - bool bRuntimeException = false; - ::rtl::OUString sMessage; - pDoc->StartUndo(UNDO_INSERT, NULL); + const uno::Reference< lang::XUnoTunnel > xRangeTunnel( + xTextCursor, uno::UNO_QUERY_THROW ); + SwXTextCursor *const pTextCursor = + ::sw::UnoTunnelGetImplementation<SwXTextCursor>(xRangeTunnel); -// SwPaM aPam(*pStartNode->EndOfSectionNode()); - //aPam.Move( fnMoveBackward, fnGoNode ); - SwUnoCrsr* pCursor = pTextCursor->GetCrsr(); - pCursor->MovePara( fnParaCurr, fnParaEnd ); - pDoc->DontExpandFmt( *pCursor->Start() ); + bool bIllegalException = false; + bool bRuntimeException = false; + ::rtl::OUString sMessage; + m_pImpl->m_pDoc->StartUndo(UNDO_INSERT, NULL); - if(rText.getLength()) - { - xub_StrLen nContentPos = pCursor->GetPoint()->nContent.GetIndex(); - SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *pCursor, rText, - false ); - SwXTextCursor::SelectPam(*pCursor, sal_True); - pCursor->GetPoint()->nContent = nContentPos; - } - - if(rCharacterAndParagraphProperties.getLength()) +// SwPaM aPam(*pStartNode->EndOfSectionNode()); + //aPam.Move( fnMoveBackward, fnGoNode ); + SwUnoCrsr *const pCursor = pTextCursor->GetCursor(); + pCursor->MovePara( fnParaCurr, fnParaEnd ); + m_pImpl->m_pDoc->DontExpandFmt( *pCursor->Start() ); + + if (rText.getLength()) + { + const xub_StrLen nContentPos = pCursor->GetPoint()->nContent.GetIndex(); + SwUnoCursorHelper::DocInsertStringSplitCR( + *m_pImpl->m_pDoc, *pCursor, rText, false); + SwUnoCursorHelper::SelectPam(*pCursor, true); + pCursor->GetPoint()->nContent = nContentPos; + } + + if (rCharacterAndParagraphProperties.getLength()) + { + SfxItemPropertyMap const*const pCursorMap = + aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR) + ->getPropertyMap(); + beans::PropertyValue const*const pValues = + rCharacterAndParagraphProperties.getConstArray(); + SfxItemPropertySet const*const pCursorPropSet = + aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR); + const sal_Int32 nLen(rCharacterAndParagraphProperties.getLength()); + for (sal_Int32 nProp = 0; nProp < nLen; ++nProp) { - const SfxItemPropertyMap* pCursorMap = aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)->getPropertyMap(); - const beans::PropertyValue* pValues = rCharacterAndParagraphProperties.getConstArray(); - const SfxItemPropertySet* pCursorPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR); - for( sal_Int32 nProp = 0; nProp < rCharacterAndParagraphProperties.getLength(); ++nProp) + if (!pCursorMap->getByName( pValues[nProp].Name )) { - if( pCursorMap->getByName( pValues[nProp].Name ) ) - { - try - { - SwXTextCursor::SetPropertyValue( - *pCursor, - *pCursorPropSet, - pValues[nProp].Name, - pValues[nProp].Value, - nsSetAttrMode::SETATTR_NOFORMATATTR); - } - catch( lang::IllegalArgumentException& rIllegal ) - { - sMessage = rIllegal.Message; - bIllegalException = true; - } - catch( uno::RuntimeException& rRuntime ) - { - sMessage = rRuntime.Message; - bRuntimeException = true; - } - } - else - bIllegalException = true; - if( bIllegalException || bRuntimeException ) - { - break; - } + bIllegalException = true; + break; } - } - pDoc->EndUndo(UNDO_INSERT, NULL); - if( bIllegalException || bRuntimeException ) - { - SwUndoIter aUndoIter( pCursor, UNDO_EMPTY ); - pDoc->Undo(aUndoIter); - delete pCursor; - pCursor = 0; - if(bIllegalException) + try { - lang::IllegalArgumentException aEx; - aEx.Message = sMessage; - throw aEx; + SwUnoCursorHelper::SetPropertyValue( + *pCursor, *pCursorPropSet, + pValues[nProp].Name, pValues[nProp].Value, + nsSetAttrMode::SETATTR_NOFORMATATTR); } - else //if(bRuntimeException) + catch( lang::IllegalArgumentException& rIllegal ) { - uno::RuntimeException aEx; - aEx.Message = sMessage; - throw aEx; + sMessage = rIllegal.Message; + bIllegalException = true; + break; + } + catch( uno::RuntimeException& rRuntime ) + { + sMessage = rRuntime.Message; + bRuntimeException = true; + break; } } - xRet = new SwXTextRange(*pCursor, this); - delete pCursor; } - return xRet; + m_pImpl->m_pDoc->EndUndo(UNDO_INSERT, NULL); + if (bIllegalException || bRuntimeException) + { + SwUndoIter aUndoIter( pCursor, UNDO_EMPTY ); + m_pImpl->m_pDoc->Undo(aUndoIter); + if (bIllegalException) + { + lang::IllegalArgumentException aEx; + aEx.Message = sMessage; + throw aEx; + } + else //if(bRuntimeException) + { + uno::RuntimeException aEx; + aEx.Message = sMessage; + throw aEx; + } + } + xRet = new SwXTextRange(*pCursor, this); + return xRet; } + /*-- 11.05.2006 15:46:26--------------------------------------------------- enable appending text contents like graphic objects, shapes and so on to support import filters -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXText::appendTextContent( +uno::Reference< text::XTextRange > SAL_CALL +SwXText::appendTextContent( const uno::Reference< text::XTextContent >& xTextContent, - const uno::Sequence< beans::PropertyValue >& rCharacterAndParagraphProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) + const uno::Sequence< beans::PropertyValue >& + rCharacterAndParagraphProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + + if (!IsValid()) + { throw uno::RuntimeException(); - const SwStartNode* pStartNode = GetStartNode(); + } + SwStartNode const*const pStartNode = GetStartNode(); if(!pStartNode) + { throw uno::RuntimeException(); + } + uno::Reference< text::XTextRange > xRet; + m_pImpl->m_pDoc->StartUndo(UNDO_INSERT, NULL); + // find end node, go backward - don't skip tables because the + // new paragraph has to be the last node + SwPaM aPam(*pStartNode->EndOfSectionNode()); + aPam.Move( fnMoveBackward, fnGoNode ); + // set cursor to the end of the last text node + SwCursor aCursor( *aPam.Start(), 0, false ); + xRet = new SwXTextRange(aCursor, this); + aCursor.MovePara( fnParaCurr, fnParaEnd ); + m_pImpl->m_pDoc->DontExpandFmt( *aCursor.Start() ); + // now attach the text content here + insertTextContent( xRet, xTextContent, false ); + // now apply the properties to the anchor + if (rCharacterAndParagraphProperties.getLength()) { - pDoc->StartUndo(UNDO_INSERT, NULL); - //find end node, go backward - don't skip tables because the new paragraph has to be the last node - SwPaM aPam(*pStartNode->EndOfSectionNode()); - aPam.Move( fnMoveBackward, fnGoNode ); - //set cursor to the end of the last text node - SwCursor* pCursor = new SwCursor( *aPam.Start(),0,false ); - xRet = new SwXTextRange(*pCursor, this); - pCursor->MovePara( fnParaCurr, fnParaEnd ); - pDoc->DontExpandFmt( *pCursor->Start() ); - //now attach the text content here - insertTextContent( xRet, xTextContent, false ); - //now apply the properties to the anchor - if( rCharacterAndParagraphProperties.getLength()) + try { - try + const sal_Int32 nLen(rCharacterAndParagraphProperties.getLength()); + const uno::Reference< beans::XPropertySet > xAnchor( + xTextContent->getAnchor(), uno::UNO_QUERY); + if (xAnchor.is()) { - uno::Reference< beans::XPropertySet > xAnchor( xTextContent->getAnchor(), uno::UNO_QUERY); - if( xAnchor.is() ) + for (sal_Int32 nElement = 0; nElement < nLen; ++nElement) { - for( sal_Int32 nElement = 0; nElement < rCharacterAndParagraphProperties.getLength(); ++nElement ) - { - xAnchor->setPropertyValue( rCharacterAndParagraphProperties[nElement].Name, rCharacterAndParagraphProperties[nElement].Value ); - } + xAnchor->setPropertyValue( + rCharacterAndParagraphProperties[nElement].Name, + rCharacterAndParagraphProperties[nElement].Value); } - - } - catch(const uno::Exception&) - { - throw uno::RuntimeException(); } } - delete pCursor; - pDoc->EndUndo(UNDO_INSERT, NULL); + catch (const uno::Exception&) + { + throw uno::RuntimeException(); + } } + m_pImpl->m_pDoc->EndUndo(UNDO_INSERT, NULL); return xRet; } // move previously appended paragraphs into a text frames // to support import filters -uno::Reference< text::XTextContent > SwXText::convertToTextFrame( +uno::Reference< text::XTextContent > SAL_CALL +SwXText::convertToTextFrame( const uno::Reference< text::XTextRange >& xStart, const uno::Reference< text::XTextRange >& xEnd, - const uno::Sequence< beans::PropertyValue >& rFrameProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) + const uno::Sequence< beans::PropertyValue >& rFrameProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) + { throw uno::RuntimeException(); + } uno::Reference< text::XTextContent > xRet; SwUnoInternalPaM aStartPam(*GetDoc()); - std::auto_ptr < SwUnoInternalPaM > pEndPam( new SwUnoInternalPaM(*GetDoc())); - if(SwXTextRange::XTextRangeToSwPaM(aStartPam, xStart) && - SwXTextRange::XTextRangeToSwPaM(*pEndPam, xEnd) ) - { - uno::Reference<lang::XUnoTunnel> xStartRangeTunnel( xStart, uno::UNO_QUERY); - SwXTextRange* pStartRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xStartRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - uno::Reference<lang::XUnoTunnel> xEndRangeTunnel( xEnd, uno::UNO_QUERY); - SwXTextRange* pEndRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xEndRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - //bookmarks have to be removed before the referenced text node is deleted in DelFullPara - if(pStartRange) - { - ::sw::mark::IMark const * const pStartBookmark = pStartRange->GetBookmark(); - if(pStartBookmark) - pDoc->getIDocumentMarkAccess()->deleteMark(pStartBookmark); - } - if(pEndRange) - { - ::sw::mark::IMark const * const pEndBookmark = pEndRange->GetBookmark(); - if(pEndBookmark) - pDoc->getIDocumentMarkAccess()->deleteMark(pEndBookmark); - } - - pDoc->StartUndo( UNDO_START, NULL ); - bool bIllegalException = false; - bool bRuntimeException = false; - ::rtl::OUString sMessage; - SwStartNode* pStartStartNode = aStartPam.GetNode()->StartOfSectionNode(); - while(pStartStartNode && pStartStartNode->IsSectionNode()) + std::auto_ptr< SwUnoInternalPaM > pEndPam(new SwUnoInternalPaM(*GetDoc())); + if (!::sw::XTextRangeToSwPaM(aStartPam, xStart) || + !::sw::XTextRangeToSwPaM(*pEndPam, xEnd)) + { + throw lang::IllegalArgumentException(); + } + + const uno::Reference<lang::XUnoTunnel> xStartRangeTunnel(xStart, + uno::UNO_QUERY); + SwXTextRange *const pStartRange = + ::sw::UnoTunnelGetImplementation<SwXTextRange>(xStartRangeTunnel); + const uno::Reference<lang::XUnoTunnel> xEndRangeTunnel(xEnd, + uno::UNO_QUERY); + SwXTextRange *const pEndRange = + ::sw::UnoTunnelGetImplementation<SwXTextRange>(xEndRangeTunnel); + // bookmarks have to be removed before the referenced text node + // is deleted in DelFullPara + if (pStartRange) + { + pStartRange->Invalidate(); + } + if (pEndRange) + { + pEndRange->Invalidate(); + } + + m_pImpl->m_pDoc->StartUndo( UNDO_START, NULL ); + bool bIllegalException = false; + bool bRuntimeException = false; + ::rtl::OUString sMessage; + SwStartNode* pStartStartNode = aStartPam.GetNode()->StartOfSectionNode(); + while (pStartStartNode && pStartStartNode->IsSectionNode()) + { + pStartStartNode = pStartStartNode->StartOfSectionNode(); + } + SwStartNode* pEndStartNode = pEndPam->GetNode()->StartOfSectionNode(); + while (pEndStartNode && pEndStartNode->IsSectionNode()) + { + pEndStartNode = pEndStartNode->StartOfSectionNode(); + } + bool bParaAfterInserted = false; + bool bParaBeforeInserted = false; + if (pStartStartNode != pEndStartNode || pStartStartNode != GetStartNode()) + { + // todo: if the start/end is in a table then insert a paragraph + // before/after, move the start/end nodes, then convert and + // remove the addtional paragraphs in the end + if (pStartStartNode->GetStartNodeType() == SwTableBoxStartNode) { - pStartStartNode = pStartStartNode->StartOfSectionNode(); + SwTableNode *const pSartTableNode(pStartStartNode->FindTableNode()); + const SwNodeIndex aTblIdx( *pSartTableNode, -1 ); + SwPosition aBefore(aTblIdx); + bParaBeforeInserted = GetDoc()->AppendTxtNode( aBefore ); + aStartPam.DeleteMark(); + *aStartPam.GetPoint() = aBefore; + pStartStartNode = aStartPam.GetNode()->StartOfSectionNode(); } - SwStartNode* pEndStartNode = pEndPam->GetNode()->StartOfSectionNode(); - while(pEndStartNode && pEndStartNode->IsSectionNode()) + if (pEndStartNode->GetStartNodeType() == SwTableBoxStartNode) { - pEndStartNode = pEndStartNode->StartOfSectionNode(); + SwTableNode *const pEndTableNode = pEndStartNode->FindTableNode(); + SwEndNode *const pTableEnd = pEndTableNode->EndOfSectionNode(); + SwPosition aTableEnd(*pTableEnd); + bParaAfterInserted = GetDoc()->AppendTxtNode( aTableEnd ); + pEndPam->DeleteMark(); + *pEndPam->GetPoint() = aTableEnd; + pEndStartNode = pEndPam->GetNode()->StartOfSectionNode(); } - bool bParaAfterInserted = false; - bool bParaBeforeInserted = false; - if(pStartStartNode != pEndStartNode || pStartStartNode != GetStartNode()) + // now we should have the positions in the same hierarchy + if ((pStartStartNode != pEndStartNode) || + (pStartStartNode != GetStartNode())) { - //todo: if the start/end is in a table then insert a paragraph before/after, move - //the start/end nodes, then convert and remove the addtional paragraphs in the end - if( pStartStartNode->GetStartNodeType() == SwTableBoxStartNode ) - { - SwTableNode* pSartTableNode = pStartStartNode->FindTableNode(); - SwNodeIndex aTblIdx( *pSartTableNode, -1 ); - SwPosition aBefore(aTblIdx); - bParaBeforeInserted = GetDoc()->AppendTxtNode( aBefore ); - aStartPam.DeleteMark(); - *aStartPam.GetPoint() = aBefore; - pStartStartNode = aStartPam.GetNode()->StartOfSectionNode(); - } - if( pEndStartNode->GetStartNodeType() == SwTableBoxStartNode ) + // if not - remove the additional paragraphs and throw + if (bParaBeforeInserted) { - SwTableNode* pEndTableNode = pEndStartNode->FindTableNode(); - SwEndNode* pTableEnd = pEndTableNode->EndOfSectionNode(); - SwPosition aTableEnd(*pTableEnd); - bParaAfterInserted = GetDoc()->AppendTxtNode( aTableEnd ); - pEndPam->DeleteMark(); - *pEndPam->GetPoint() = aTableEnd; - pEndStartNode = pEndPam->GetNode()->StartOfSectionNode(); + SwCursor aDelete(*aStartPam.GetPoint(), 0, false); + aDelete.MovePara(fnParaCurr, fnParaStart); + aDelete.SetMark(); + aDelete.MovePara(fnParaCurr, fnParaEnd); + GetDoc()->DelFullPara(aDelete); } - //now we should have the positions in the same hierarchy - if(pStartStartNode != pEndStartNode || pStartStartNode != GetStartNode()) + if (bParaAfterInserted) { - //if not - remove the additional paragraphs and throw - if( bParaBeforeInserted ) - { - SwCursor aDelete(*aStartPam.GetPoint(), 0, false); - aDelete.MovePara(fnParaCurr, fnParaStart); - aDelete.SetMark(); - aDelete.MovePara(fnParaCurr, fnParaEnd); - GetDoc()->DelFullPara(aDelete); - } - if( bParaAfterInserted ) - { - SwCursor aDelete(*pEndPam->GetPoint(), 0, false); - aDelete.MovePara(fnParaCurr, fnParaStart); - aDelete.SetMark(); - aDelete.MovePara(fnParaCurr, fnParaEnd); - GetDoc()->DelFullPara(aDelete); - } - throw lang::IllegalArgumentException(); + SwCursor aDelete(*pEndPam->GetPoint(), 0, false); + aDelete.MovePara(fnParaCurr, fnParaStart); + aDelete.SetMark(); + aDelete.MovePara(fnParaCurr, fnParaEnd); + GetDoc()->DelFullPara(aDelete); } - } - - //make a selection from aStartPam to a EndPam - SwSelBoxes aBoxes; - SfxItemSet aFrameItemSet(pDoc->GetAttrPool(), - RES_FRMATR_BEGIN, RES_FRMATR_END-1, - 0 ); - - aStartPam.SetMark(); - *aStartPam.End() = *pEndPam->End(); - pEndPam.reset(0); - - SwXTextFrame* pNewFrame; - uno::Reference< text::XTextFrame > xNewFrame = pNewFrame = new SwXTextFrame( pDoc ); - pNewFrame->SetSelection( aStartPam ); - try + throw lang::IllegalArgumentException(); + } + } + + // make a selection from aStartPam to a EndPam + SwSelBoxes aBoxes; + SfxItemSet aFrameItemSet(m_pImpl->m_pDoc->GetAttrPool(), + RES_FRMATR_BEGIN, RES_FRMATR_END-1, + 0 ); + + aStartPam.SetMark(); + *aStartPam.End() = *pEndPam->End(); + pEndPam.reset(0); + + SwXTextFrame *const pNewFrame = new SwXTextFrame(m_pImpl->m_pDoc); + const uno::Reference< text::XTextFrame > xNewFrame = pNewFrame; + pNewFrame->SetSelection( aStartPam ); + try + { + const beans::PropertyValue* pValues = rFrameProperties.getConstArray(); + for (sal_Int32 nProp = 0; nProp < rFrameProperties.getLength(); ++nProp) { - const beans::PropertyValue* pValues = rFrameProperties.getConstArray(); - for(sal_Int32 nProp = 0; nProp < rFrameProperties.getLength(); ++nProp) - pNewFrame->SwXFrame::setPropertyValue(pValues[nProp].Name, pValues[nProp].Value); - - {//has to be in a block to remove the SwIndexes before DelFullPara is called - uno::Reference< text::XTextRange> xInsertTextRange = new SwXTextRange(aStartPam, this); - pNewFrame->attach( xInsertTextRange ); - pNewFrame->setName(pDoc->GetUniqueFrameName()); + pNewFrame->SwXFrame::setPropertyValue( + pValues[nProp].Name, pValues[nProp].Value); + } + + { // has to be in a block to remove the SwIndexes before + // DelFullPara is called + const uno::Reference< text::XTextRange> xInsertTextRange = + new SwXTextRange(aStartPam, this); + pNewFrame->attach( xInsertTextRange ); + pNewFrame->setName(m_pImpl->m_pDoc->GetUniqueFrameName()); + } + + if (!aStartPam.GetTxt().Len()) + { + bool bMoved = false; + { // has to be in a block to remove the SwIndexes before + // DelFullPara is called + SwPaM aMovePam( *aStartPam.GetNode() ); + if (aMovePam.Move( fnMoveForward, fnGoCntnt )) + { + // move the anchor to the next paragraph + SwFmtAnchor aNewAnchor(pNewFrame->GetFrmFmt()->GetAnchor()); + aNewAnchor.SetAnchor( aMovePam.Start() ); + m_pImpl->m_pDoc->SetAttr( + aNewAnchor, *pNewFrame->GetFrmFmt() ); + } + bMoved = true; } - - if( !aStartPam.GetTxt().Len() ) + if (bMoved) { - - bool bMoved = false; - {//has to be in a block to remove the SwIndexes before DelFullPara is called - SwPaM aMovePam( *aStartPam.GetNode() ); - if( aMovePam.Move( fnMoveForward, fnGoCntnt ) ) - { - //move the anchor to the next paragraph - SwFmtAnchor aNewAnchor( pNewFrame->GetFrmFmt()->GetAnchor() ); - aNewAnchor.SetAnchor( aMovePam.Start() ); - pDoc->SetAttr( aNewAnchor, *pNewFrame->GetFrmFmt() ); - } - bMoved = true; - } - if(bMoved) - { - aStartPam.DeleteMark(); + aStartPam.DeleteMark(); // SwPaM aDelPam( *aStartPam.GetNode() ); - pDoc->DelFullPara(aStartPam/*aDelPam*/); - } + m_pImpl->m_pDoc->DelFullPara(aStartPam/*aDelPam*/); } } - catch( lang::IllegalArgumentException& rIllegal ) + } + catch (lang::IllegalArgumentException& rIllegal) + { + sMessage = rIllegal.Message; + bIllegalException = true; + } + catch (uno::RuntimeException& rRuntime) + { + sMessage = rRuntime.Message; + bRuntimeException = true; + } + xRet = pNewFrame; + if (bParaBeforeInserted || bParaAfterInserted) + { + const uno::Reference<text::XTextCursor> xFrameTextCursor = + pNewFrame->createTextCursor(); + const uno::Reference<XUnoTunnel> xTunnel(xFrameTextCursor, + uno::UNO_QUERY); + SwXTextCursor *const pFrameCursor = + ::sw::UnoTunnelGetImplementation<SwXTextCursor>(xTunnel); + if (bParaBeforeInserted) { - sMessage = rIllegal.Message; - bIllegalException = true; + // todo: remove paragraph before frame + m_pImpl->m_pDoc->DelFullPara(*pFrameCursor->GetPaM()); } - catch( uno::RuntimeException& rRuntime ) + if (bParaAfterInserted) { - sMessage = rRuntime.Message; - bRuntimeException = true; + xFrameTextCursor->gotoEnd(sal_False); + m_pImpl->m_pDoc->DelFullPara(*pFrameCursor->GetPaM()); } - xRet = pNewFrame; - uno::Reference<text::XTextCursor> xFrameTextCursor; - if( bParaBeforeInserted ) + } + + m_pImpl->m_pDoc->EndUndo(UNDO_END, NULL); + if (bIllegalException || bRuntimeException) + { + SwUndoIter aUndoIter( &aStartPam, UNDO_EMPTY ); + m_pImpl->m_pDoc->Undo(aUndoIter); + if (bIllegalException) { - //todo: remove paragraph before frame - xFrameTextCursor = pNewFrame->createTextCursor(); - uno::Reference<XUnoTunnel> xTunnel(xFrameTextCursor, uno::UNO_QUERY); - SwXTextCursor* pFrameCursor = reinterpret_cast< SwXTextCursor* >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXTextCursor::getUnoTunnelId()) )); - pDoc->DelFullPara(*pFrameCursor->GetPaM()); + lang::IllegalArgumentException aEx; + aEx.Message = sMessage; + throw aEx; } - if( bParaAfterInserted ) + else //if(bRuntimeException) { - //todo: remove paragraph after frame - if( xFrameTextCursor.is() ) - xFrameTextCursor = pNewFrame->createTextCursor(); - xFrameTextCursor->gotoEnd( false ); - uno::Reference<XUnoTunnel> xTunnel(xFrameTextCursor, uno::UNO_QUERY); - SwXTextCursor* pFrameCursor = reinterpret_cast< SwXTextCursor* >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXTextCursor::getUnoTunnelId()) )); - pDoc->DelFullPara(*pFrameCursor->GetPaM()); - } - - pDoc->EndUndo(UNDO_END, NULL); - if( bIllegalException || bRuntimeException ) - { - SwUndoIter aUndoIter( &aStartPam, UNDO_EMPTY ); - pDoc->Undo(aUndoIter); - if(bIllegalException) - { - lang::IllegalArgumentException aEx; - aEx.Message = sMessage; - throw aEx; - } - else //if(bRuntimeException) - { - uno::RuntimeException aEx; - aEx.Message = sMessage; - throw aEx; - } + uno::RuntimeException aEx; + aEx.Message = sMessage; + throw aEx; } } - else - throw lang::IllegalArgumentException(); return xRet; } + /*-- 11.05.2006 15:46:26--------------------------------------------------- Move previously imported paragraphs into a new text table. @@ -1774,155 +1849,407 @@ struct VerticallyMergedCell sal_Int32 nLeftPosition; bool bOpen; - VerticallyMergedCell( uno::Reference< beans::XPropertySet >& rxCell, sal_Int32 nLeft ) : - nLeftPosition( nLeft ), - bOpen( true ) - { - aCells.push_back( rxCell ); - } + VerticallyMergedCell(uno::Reference< beans::XPropertySet > const& rxCell, + const sal_Int32 nLeft) + : nLeftPosition( nLeft ) + , bOpen( true ) + { + aCells.push_back( rxCell ); + } }; #define COL_POS_FUZZY 2 -bool lcl_SimilarPosition( sal_Int32 nPos1, sal_Int32 nPos2 ) +static bool lcl_SimilarPosition( const sal_Int32 nPos1, const sal_Int32 nPos2 ) { return abs( nPos1 - nPos2 ) < COL_POS_FUZZY; } -uno::Reference< text::XTextTable > SwXText::convertToTable( - const uno::Sequence< uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > > >& rTableRanges, - const uno::Sequence< uno::Sequence< uno::Sequence< beans::PropertyValue > > >& rCellProperties, - const uno::Sequence< uno::Sequence< beans::PropertyValue > >& rRowProperties, - const uno::Sequence< beans::PropertyValue >& rTableProperties ) - throw (lang::IllegalArgumentException, uno::RuntimeException) +void SwXText::Impl::ConvertCell( + const bool bFirstCell, + const uno::Sequence< uno::Reference< text::XTextRange > > & rCell, + ::std::vector<SwNodeRange> & rRowNodes, + ::std::auto_ptr< SwPaM > & rpFirstPaM, + SwPaM & rLastPaM, + bool & rbExcept) { - vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) - throw uno::RuntimeException(); + if (rCell.getLength() != 2) + { + throw lang::IllegalArgumentException(); + } + const uno::Reference<text::XTextRange> xStartRange = rCell[0]; + const uno::Reference<text::XTextRange> xEndRange = rCell[1]; + SwUnoInternalPaM aStartCellPam(*m_pDoc); + SwUnoInternalPaM aEndCellPam(*m_pDoc); - //at first collect the text ranges as SwPaMs - const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >* pTableRanges = rTableRanges.getConstArray(); - std::auto_ptr < SwPaM > pFirstPaM; - std::vector< std::vector<SwNodeRange> > aTableNodes; - bool bExcept = false; - SwPaM aLastPaM(pDoc->GetNodes()); - for( sal_Int32 nRow = 0; !bExcept && (nRow < rTableRanges.getLength()); ++nRow) + // !!! TODO - PaMs in tables and sections do not work here - + // the same applies to PaMs in frames !!! + + if (!::sw::XTextRangeToSwPaM(aStartCellPam, xStartRange) || + !::sw::XTextRangeToSwPaM(aEndCellPam, xEndRange)) { - std::vector<SwNodeRange> aRowNodes; - const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >& rRow = pTableRanges[nRow]; - const uno::Sequence< uno::Reference< text::XTextRange > >* pRow = pTableRanges[nRow].getConstArray(); + throw lang::IllegalArgumentException(); + } + /** check the nodes between start and end + it is allowed to have pairs of StartNode/EndNodes + */ + if (aStartCellPam.Start()->nNode < aEndCellPam.End()->nNode) + { + // increment on each StartNode and decrement on each EndNode + // we must reach zero at the end and must not go below zero + long nOpenNodeBlock = 0; + SwNodeIndex aCellIndex = aStartCellPam.Start()->nNode; + while (aCellIndex < aEndCellPam.End()->nNode.GetIndex()) + { + if (aCellIndex.GetNode().IsStartNode()) + { + ++nOpenNodeBlock; + } + else if (aCellIndex.GetNode().IsEndNode()) + { + --nOpenNodeBlock; + } + if (nOpenNodeBlock < 0) + { + rbExcept = true; + break; + } + ++aCellIndex; + } + if (nOpenNodeBlock != 0) + { + rbExcept = true; + return; + } + } - for( sal_Int32 nCell = 0; nCell < rRow.getLength(); ++nCell) + /** The vector<vector> NodeRanges has to contain consecutive nodes. + In rTableRanges the ranges don't need to be full paragraphs but + they have to follow each other. To process the ranges they + have to be aligned on paragraph borders by inserting paragraph + breaks. Non-consecutive ranges must initiate an exception. + */ + if (bFirstCell) + { + // align the beginning - if necessary + if (aStartCellPam.Start()->nContent.GetIndex()) { - if( pRow[nCell].getLength() != 2 ) - throw lang::IllegalArgumentException(); - const uno::Reference< text::XTextRange > xStartRange = pRow[nCell][0]; - const uno::Reference< text::XTextRange > xEndRange = pRow[nCell][1]; - SwUnoInternalPaM aStartCellPam(*pDoc); - SwUnoInternalPaM aEndCellPam(*pDoc); - - // !!! TODO - PaMs in tables and sections do not work here - the same applies to PaMs in frames !!! - - if(!SwXTextRange::XTextRangeToSwPaM(aStartCellPam, xStartRange) || - !SwXTextRange::XTextRangeToSwPaM(aEndCellPam, xEndRange) ) - throw lang::IllegalArgumentException(); - /** check the nodes between start and end - it is allowed to have pairs of StartNode/EndNodes - */ - if(aStartCellPam.Start()->nNode < aEndCellPam.End()->nNode) + m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + } + } + else + { + // check the predecessor + const ULONG nLastNodeIndex = rLastPaM.End()->nNode.GetIndex(); + const ULONG nStartCellNodeIndex = + aStartCellPam.Start()->nNode.GetIndex(); + const ULONG nLastNodeEndIndex = rLastPaM.End()->nNode.GetIndex(); + if (nLastNodeIndex == nStartCellNodeIndex) + { + // same node as predecessor then equal nContent? + if (rLastPaM.End()->nContent != aStartCellPam.Start()->nContent) { - // increment on each StartNode and decrement on each EndNode - // we must reach zero at the end and must not go below zero - long nOpenNodeBlock = 0; - SwNodeIndex aCellIndex = aStartCellPam.Start()->nNode; - while( aCellIndex < aEndCellPam.End()->nNode.GetIndex()) - { - if( aCellIndex.GetNode().IsStartNode() ) - ++nOpenNodeBlock; - else if(aCellIndex.GetNode().IsEndNode() ) - --nOpenNodeBlock; - if( nOpenNodeBlock < 0 ) - { - bExcept = true; - break; - } - ++aCellIndex; - } - if( nOpenNodeBlock != 0) - { - bExcept = true; - break; - } + rbExcept = true; + } + else + { + m_pDoc->SplitNode(*aStartCellPam.Start(), sal_False); } + } + else if (nStartCellNodeIndex == (nLastNodeEndIndex + 1)) + { + // next paragraph - now the content index of the new should be 0 + // and of the old one should be equal to the text length + // but if it isn't we don't care - the cell is being inserted on + // the node border anyway + } + else + { + rbExcept = true; + } + } + // now check if there's a need to insert another paragraph break + if (aEndCellPam.End()->nContent.GetIndex() < + aEndCellPam.End()->nNode.GetNode().GetTxtNode()->Len()) + { + m_pDoc->SplitNode(*aEndCellPam.End(), sal_False); + // take care that the new start/endcell is moved to the right position + // aStartCellPam has to point to the start of the new (previous) node + // aEndCellPam has to point to the end of the new (previous) node + aStartCellPam.DeleteMark(); + aStartCellPam.Move(fnMoveBackward, fnGoNode); + aStartCellPam.GetPoint()->nContent = 0; + aEndCellPam.DeleteMark(); + aEndCellPam.Move(fnMoveBackward, fnGoNode); + aEndCellPam.GetPoint()->nContent = + aEndCellPam.GetNode()->GetTxtNode()->Len(); + } + + *rLastPaM.GetPoint() = *aEndCellPam.Start(); + if (aStartCellPam.HasMark()) + { + rLastPaM.SetMark(); + *rLastPaM.GetMark() = *aEndCellPam.End(); + } + else + { + rLastPaM.DeleteMark(); + } + + SwNodeRange aCellRange(aStartCellPam.Start()->nNode, + aEndCellPam.End()->nNode); + rRowNodes.push_back(aCellRange); + if (bFirstCell) + { + rpFirstPaM.reset(new SwPaM(*aStartCellPam.Start())); + } +} - /** The vector<vector> NodeRanges has to contain consecutive nodes. - In rTableRanges the ranges don't need to be full paragraphs but they have to follow - each other. To process the ranges they have to be aligned on paragraph borders - by inserting paragraph breaks. Non-consecutive ranges must initiate an - exception. +typedef uno::Sequence< text::TableColumnSeparator > TableColumnSeparators; + +static void +lcl_ApplyRowProperties( + uno::Sequence<beans::PropertyValue> const& rRowProperties, + uno::Any const& rRow, + TableColumnSeparators & rRowSeparators) +{ + uno::Reference< beans::XPropertySet > xRow; + rRow >>= xRow; + const beans::PropertyValue* pProperties = rRowProperties.getConstArray(); + for (sal_Int32 nProperty = 0; nProperty < rRowProperties.getLength(); + ++nProperty) + { + if (pProperties[ nProperty ].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("TableColumnSeparators"))) + { + // add the separators to access the cell's positions + // for vertical merging later + TableColumnSeparators aSeparators; + pProperties[ nProperty ].Value >>= aSeparators; + rRowSeparators = aSeparators; + } + xRow->setPropertyValue( + pProperties[ nProperty ].Name, pProperties[ nProperty ].Value); + } +} - */ - if(!nRow && !nCell) +#ifdef DEBUG +//-->debug cell properties of all rows +static void +lcl_DebugCellProperties( + const uno::Sequence< uno::Sequence< uno::Sequence< + beans::PropertyValue > > >& rCellProperties) +{ + ::rtl::OUString sNames; + for (sal_Int32 nDebugRow = 0; nDebugRow < rCellProperties.getLength(); + ++nDebugRow) + { + const uno::Sequence< beans::PropertyValues > aDebugCurrentRow = + rCellProperties[nDebugRow]; + sal_Int32 nDebugCells = aDebugCurrentRow.getLength(); + (void) nDebugCells; + for (sal_Int32 nDebugCell = 0; nDebugCell < nDebugCells; + ++nDebugCell) + { + const uno::Sequence< beans::PropertyValue >& + rDebugCellProperties = aDebugCurrentRow[nDebugCell]; + const sal_Int32 nDebugCellProperties = + rDebugCellProperties.getLength(); + for (sal_Int32 nDebugProperty = 0; + nDebugProperty < nDebugCellProperties; ++nDebugProperty) { - //align the beginning - if necessary - if(aStartCellPam.Start()->nContent.GetIndex()) - pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + const ::rtl::OUString sName = + rDebugCellProperties[nDebugProperty].Name; + sNames += sName; + sNames += ::rtl::OUString('-'); } - else + sNames += ::rtl::OUString('+'); + } + sNames += ::rtl::OUString('|'); + } + (void)sNames; +} +//--< +#endif + + +static void +lcl_ApplyCellProperties( + const sal_Int32 nCell, + TableColumnSeparators const& rRowSeparators, + const uno::Sequence< beans::PropertyValue >& rCellProperties, + uno::Reference< uno::XInterface > xCell, + ::std::vector<VerticallyMergedCell> & rMergedCells) +{ + const sal_Int32 nCellProperties = rCellProperties.getLength(); + const uno::Reference< beans::XPropertySet > xCellPS(xCell, uno::UNO_QUERY); + for (sal_Int32 nProperty = 0; nProperty < nCellProperties; ++nProperty) + { + const OUString & rName = rCellProperties[nProperty].Name; + const uno::Any & rValue = rCellProperties[nProperty].Value; + if (rName.equalsAscii("VerticalMerge")) + { + // determine left border position + // add the cell to a queue of merged cells + sal_Bool bMerge = sal_False; + rValue >>= bMerge; + sal_Int32 nLeftPos = -1; + if (!nCell) + { + nLeftPos = 0; + } + else if (rRowSeparators.getLength() >= nCell) { - //check the predecessor - ULONG nLastNodeIndex = aLastPaM.End()->nNode.GetIndex(); - ULONG nStartCellNodeIndex = aStartCellPam.Start()->nNode.GetIndex(); - ULONG nLastNodeEndIndex = aLastPaM.End()->nNode.GetIndex(); - if( nLastNodeIndex == nStartCellNodeIndex) + const text::TableColumnSeparator* pSeparators = + rRowSeparators.getConstArray(); + nLeftPos = pSeparators[nCell - 1].Position; + } + if (bMerge) + { + // 'close' all the cell with the same left position + // if separate vertical merges in the same column exist + if (rMergedCells.size()) { - //- same node as predecessor then equal nContent? - if(aLastPaM.End()->nContent != aStartCellPam.Start()->nContent) - bExcept = true; - else + std::vector<VerticallyMergedCell>::iterator aMergedIter = + rMergedCells.begin(); + while (aMergedIter != rMergedCells.end()) { - pDoc->SplitNode(*aStartCellPam.Start(), sal_False); + if (lcl_SimilarPosition(aMergedIter->nLeftPosition, + nLeftPos)) + { + aMergedIter->bOpen = false; + } + ++aMergedIter; } } - else if(nStartCellNodeIndex == ( nLastNodeEndIndex + 1)) - { - //next paragraph - now the content index of the new should be 0 - //and of the old one should be equal to the text length - //but if it isn't we don't care - the cell is being inserted on the - //node border anyway - } - else + // add the new group of merged cells + rMergedCells.push_back(VerticallyMergedCell(xCellPS, nLeftPos)); + } + else + { + // find the cell that + DBG_ASSERT(rMergedCells.size(), + "the first merged cell is missing"); + if (rMergedCells.size()) { - bExcept = true; + std::vector<VerticallyMergedCell>::iterator aMergedIter = + rMergedCells.begin(); +#if OSL_DEBUG_LEVEL > 1 + bool bDbgFound = false; +#endif + while (aMergedIter != rMergedCells.end()) + { + if (aMergedIter->bOpen && + lcl_SimilarPosition(aMergedIter->nLeftPosition, + nLeftPos)) + { + aMergedIter->aCells.push_back( xCellPS ); +#if OSL_DEBUG_LEVEL > 1 + bDbgFound = true; +#endif + } + ++aMergedIter; + } +#if OSL_DEBUG_LEVEL > 1 + DBG_ASSERT( bDbgFound, + "couldn't find first vertically merged cell" ); +#endif } } - //now check if there's a need to insert another paragraph break - if( aEndCellPam.End()->nContent.GetIndex() < aEndCellPam.End()->nNode.GetNode().GetTxtNode()->Len()) - { - pDoc->SplitNode(*aEndCellPam.End(), sal_False); - //take care that the new start/endcell is moved to the right position - //aStartCellPam has to point to the start of the new (previous) node - //aEndCellPam has to point the the end of the new (previous) node - aStartCellPam.DeleteMark(); - aStartCellPam.Move(fnMoveBackward, fnGoNode); - aStartCellPam.GetPoint()->nContent = 0; - aEndCellPam.DeleteMark(); - aEndCellPam.Move(fnMoveBackward, fnGoNode); - aEndCellPam.GetPoint()->nContent = aEndCellPam.GetNode()->GetTxtNode()->Len(); - - } - - *aLastPaM.GetPoint() = *aEndCellPam.Start(); - if( aStartCellPam.HasMark() ) + } + else + { + try { - aLastPaM.SetMark(); - *aLastPaM.GetMark() = *aEndCellPam.End(); + xCellPS->setPropertyValue(rName, rValue); } - else - aLastPaM.DeleteMark(); + catch (uno::Exception const& e) + { + // Apply the paragraph and char properties to the cell's content + const uno::Reference< text::XText > xCellText(xCell, + uno::UNO_QUERY); + const uno::Reference< text::XTextCursor > xCellCurs = + xCellText->createTextCursor(); + xCellCurs->gotoStart( sal_False ); + xCellCurs->gotoEnd( sal_True ); + const uno::Reference< beans::XPropertySet > xCellTextProps( + xCellCurs, uno::UNO_QUERY); + xCellTextProps->setPropertyValue(rName, rValue); + } + } + } +} + +static void +lcl_MergeCells(::std::vector<VerticallyMergedCell> & rMergedCells) +{ + if (rMergedCells.size()) + { + std::vector<VerticallyMergedCell>::iterator aMergedIter = + rMergedCells.begin(); + while (aMergedIter != rMergedCells.end()) + { + sal_Int32 nCellCount = + static_cast<sal_Int32>(aMergedIter->aCells.size()); + std::vector<uno::Reference< beans::XPropertySet > >::iterator + aCellIter = aMergedIter->aCells.begin(); + bool bFirstCell = true; + // the first of the cells gets the number of cells set as RowSpan + // the others get the inverted number of remaining merged cells + // (3,-2,-1) + while (aCellIter != aMergedIter->aCells.end()) + { + (*aCellIter)->setPropertyValue( + C2U(SW_PROP_NAME_STR(UNO_NAME_ROW_SPAN)), + uno::makeAny(nCellCount)); + if (bFirstCell) + { + nCellCount *= -1; + bFirstCell = false; + } + ++nCellCount; + ++aCellIter; + } + ++aMergedIter; + } + } +} + +uno::Reference< text::XTextTable > SAL_CALL +SwXText::convertToTable( + const uno::Sequence< uno::Sequence< uno::Sequence< + uno::Reference< text::XTextRange > > > >& rTableRanges, + const uno::Sequence< uno::Sequence< uno::Sequence< + beans::PropertyValue > > >& rCellProperties, + const uno::Sequence< uno::Sequence< beans::PropertyValue > >& + rRowProperties, + const uno::Sequence< beans::PropertyValue >& rTableProperties) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + if(!IsValid()) + { + throw uno::RuntimeException(); + } - SwNodeRange aCellRange( aStartCellPam.Start()->nNode, aEndCellPam.End()->nNode); - aRowNodes.push_back(aCellRange); - if( !nRow && !nCell ) - pFirstPaM.reset( new SwPaM(*aStartCellPam.Start())); + //at first collect the text ranges as SwPaMs + const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >* + pTableRanges = rTableRanges.getConstArray(); + std::auto_ptr < SwPaM > pFirstPaM; + std::vector< std::vector<SwNodeRange> > aTableNodes; + bool bExcept = false; + SwPaM aLastPaM(m_pImpl->m_pDoc->GetNodes()); + for (sal_Int32 nRow = 0; !bExcept && (nRow < rTableRanges.getLength()); + ++nRow) + { + std::vector<SwNodeRange> aRowNodes; + const uno::Sequence< uno::Reference< text::XTextRange > >* pRow = + pTableRanges[nRow].getConstArray(); + const sal_Int32 nCells(pTableRanges[nRow].getLength()); + + for (sal_Int32 nCell = 0; nCell < nCells; ++nCell) + { + m_pImpl->ConvertCell((nCell == 0) && (nRow == 0), pRow[nCell], + aRowNodes, pFirstPaM, aLastPaM, bExcept); } aTableNodes.push_back(aRowNodes); } @@ -1930,220 +2257,84 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( if(bExcept) { SwUndoIter aUndoIter( &aLastPaM, UNDO_EMPTY ); - pDoc->Undo(aUndoIter); + m_pImpl->m_pDoc->Undo(aUndoIter); throw lang::IllegalArgumentException(); } - typedef uno::Sequence< text::TableColumnSeparator > TableColumnSeparators; - std::vector< TableColumnSeparators > aRowSeparators(rRowProperties.getLength()); - std::vector<VerticallyMergedCell> aMergedCells; + std::vector< TableColumnSeparators > + aRowSeparators(rRowProperties.getLength()); + std::vector<VerticallyMergedCell> aMergedCells; - const SwTable* pTable = pDoc->TextToTable( aTableNodes ); - SwXTextTable* pTextTable = 0; - uno::Reference< text::XTextTable > xRet = pTextTable = new SwXTextTable( *pTable->GetFrmFmt() ); - uno::Reference< beans::XPropertySet > xPrSet = pTextTable; - // set properties to the table - catch lang::WrappedTargetException and lang::IndexOutOfBoundsException + SwTable const*const pTable = m_pImpl->m_pDoc->TextToTable( aTableNodes ); + SwXTextTable *const pTextTable = new SwXTextTable( *pTable->GetFrmFmt() ); + const uno::Reference< text::XTextTable > xRet = pTextTable; + const uno::Reference< beans::XPropertySet > xPrSet = pTextTable; + // set properties to the table + // catch lang::WrappedTargetException and lang::IndexOutOfBoundsException try { //apply table properties - const beans::PropertyValue* pTableProperties = rTableProperties.getConstArray(); - sal_Int32 nProperty = 0; - for( ; nProperty < rTableProperties.getLength(); ++nProperty) + const beans::PropertyValue* pTableProperties = + rTableProperties.getConstArray(); + for (sal_Int32 nProperty = 0; nProperty < rTableProperties.getLength(); + ++nProperty) { - try + try { - xPrSet->setPropertyValue( pTableProperties[nProperty].Name, pTableProperties[nProperty].Value ); + xPrSet->setPropertyValue( pTableProperties[nProperty].Name, + pTableProperties[nProperty].Value ); } - catch ( const uno::Exception e ) + catch ( uno::Exception const& e ) { #if DEBUG std::clog << "Exception when setting property: "; - std::clog << rtl::OUStringToOString( pTableProperties[nProperty].Name, RTL_TEXTENCODING_UTF8 ).getStr( ); + std::clog << rtl::OUStringToOString( + pTableProperties[nProperty].Name, RTL_TEXTENCODING_UTF8) + .getStr(); std::clog << ". Message: "; - std::clog << rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr( ); + std::clog << rtl::OUStringToOString( e.Message, + RTL_TEXTENCODING_UTF8 ).getStr(); std::clog << std::endl; #endif } } //apply row properties - uno::Reference< table::XTableRows > xRows = xRet->getRows(); - const beans::PropertyValues* pRowProperties = rRowProperties.getConstArray(); - sal_Int32 nRow = 0; - for( ; nRow < xRows->getCount(); ++nRow) + const uno::Reference< table::XTableRows > xRows = xRet->getRows(); + + const beans::PropertyValues* pRowProperties = + rRowProperties.getConstArray(); + for (sal_Int32 nRow = 0; nRow < xRows->getCount(); ++nRow) { if( nRow >= rRowProperties.getLength()) { break; } - uno::Reference< beans::XPropertySet > xRow; - xRows->getByIndex( nRow ) >>= xRow; - const beans::PropertyValue* pProperties = pRowProperties[nRow].getConstArray(); - for( nProperty = 0; nProperty < pRowProperties[nRow].getLength(); ++nProperty) - { - if( pProperties[ nProperty ].Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM ( "TableColumnSeparators" ))) - { - //add the separators to access the cell's positions for vertical merging later - TableColumnSeparators aSeparators; - pProperties[ nProperty ].Value >>= aSeparators; - aRowSeparators[nRow] = aSeparators; - } - xRow->setPropertyValue( pProperties[ nProperty ].Name, pProperties[ nProperty ].Value ); - } + lcl_ApplyRowProperties(pRowProperties[nRow], + xRows->getByIndex(nRow), aRowSeparators[nRow]); } #ifdef DEBUG -//-->debug cell properties of all rows - { - ::rtl::OUString sNames; - for( sal_Int32 nDebugRow = 0; nDebugRow < rCellProperties.getLength(); ++nDebugRow) - { - const uno::Sequence< beans::PropertyValues > aDebugCurrentRow = rCellProperties[nDebugRow]; - sal_Int32 nDebugCells = aDebugCurrentRow.getLength(); - (void) nDebugCells; - for( sal_Int32 nDebugCell = 0; nDebugCell < nDebugCells; ++nDebugCell) - { - const uno::Sequence< beans::PropertyValue >& aDebugCellProperties = aDebugCurrentRow[nDebugCell]; - sal_Int32 nDebugCellProperties = aDebugCellProperties.getLength(); - for( sal_Int32 nDebugProperty = 0; nDebugProperty < nDebugCellProperties; ++nDebugProperty) - { - const ::rtl::OUString sName = aDebugCellProperties[nDebugProperty].Name; - sNames += sName; - sNames += ::rtl::OUString('-'); - } - sNames += ::rtl::OUString('+'); - } - sNames += ::rtl::OUString('|'); - } - (void)sNames; - } -//--< + lcl_DebugCellProperties(rCellProperties); #endif - //apply cell properties - for( nRow = 0; nRow < rCellProperties.getLength(); ++nRow) + for (sal_Int32 nRow = 0; nRow < rCellProperties.getLength(); ++nRow) { - const uno::Sequence< beans::PropertyValues > aCurrentRow = rCellProperties[nRow]; + const uno::Sequence< beans::PropertyValues > aCurrentRow = + rCellProperties[nRow]; sal_Int32 nCells = aCurrentRow.getLength(); - for( sal_Int32 nCell = 0; nCell < nCells; ++nCell) - { - const uno::Sequence< beans::PropertyValue >& aCellProperties = aCurrentRow[nCell]; - sal_Int32 nCellProperties = aCellProperties.getLength(); - uno::Reference< beans::XPropertySet > xCell( pTextTable->getCellByPosition(nCell, nRow), uno::UNO_QUERY ); - for( nProperty = 0; nProperty < nCellProperties; ++nProperty) - { - const OUString& rName = aCellProperties[nProperty].Name; - if( rName.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM ( "VerticalMerge"))) - { - //determine left border position - //add the cell to a queue of merged cells - // - sal_Bool bMerge = sal_False; - aCellProperties[nProperty].Value >>= bMerge; - sal_Int32 nLeftPos = -1; - if( !nCell ) - nLeftPos = 0; - else if( aRowSeparators[nRow].getLength() >= nCell ) - { - const text::TableColumnSeparator* pSeparators = aRowSeparators[nRow].getConstArray(); - nLeftPos = pSeparators[nCell - 1].Position; - } - if( bMerge ) - { - // 'close' all the cell with the same left position - // if separate vertical merges in the same column exist - if( aMergedCells.size() ) - { - std::vector<VerticallyMergedCell>::iterator aMergedIter = aMergedCells.begin(); - while( aMergedIter != aMergedCells.end()) - { - if( lcl_SimilarPosition( aMergedIter->nLeftPosition, nLeftPos) ) - { - aMergedIter->bOpen = false; - } - ++aMergedIter; - } - } - //add the new group of merged cells - aMergedCells.push_back(VerticallyMergedCell(xCell, nLeftPos )); - } - else - { - //find the cell that - DBG_ASSERT(aMergedCells.size(), "the first merged cell is missing"); - if( aMergedCells.size() ) - { - std::vector<VerticallyMergedCell>::iterator aMergedIter = aMergedCells.begin(); -#if OSL_DEBUG_LEVEL > 1 - bool bDbgFound = false; -#endif - while( aMergedIter != aMergedCells.end()) - { - if( aMergedIter->bOpen && - lcl_SimilarPosition( aMergedIter->nLeftPosition, nLeftPos) ) - { - aMergedIter->aCells.push_back( xCell ); -#if OSL_DEBUG_LEVEL > 1 - bDbgFound = true; -#endif - } - ++aMergedIter; - } -#if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( bDbgFound, "couldn't find first vertically merged cell" ); -#endif - } - } - } - else - { - try - { - xCell->setPropertyValue(rName, aCellProperties[nProperty].Value); - } - catch ( const uno::Exception e ) - { - // Apply the paragraph and char properties to the cell's content - uno::Reference< text::XText > xCellText( xCell, uno::UNO_QUERY ); - uno::Reference< text::XTextCursor > xCellCurs = xCellText->createTextCursor( ); - xCellCurs->gotoStart( false ); - xCellCurs->gotoEnd( true ); - - uno::Reference< beans::XPropertySet > xCellTextProps( xCellCurs, uno::UNO_QUERY ); - xCellTextProps->setPropertyValue( rName, aCellProperties[nProperty].Value ); - } - } - } - } - } - //now that the cell properties are set the vertical merge values have to be applied - if( aMergedCells.size() ) - { - std::vector<VerticallyMergedCell>::iterator aMergedIter = aMergedCells.begin(); - while( aMergedIter != aMergedCells.end()) + for (sal_Int32 nCell = 0; nCell < nCells; ++nCell) { - sal_Int32 nCellCount = (sal_Int32)aMergedIter->aCells.size(); - std::vector<uno::Reference< beans::XPropertySet > >::iterator aCellIter = aMergedIter->aCells.begin(); - bool bFirstCell = true; - //the first of the cells get's the number of cells set as RowSpan - //the others get the inverted number of remaining merged cells (3,-2,-1) - while( aCellIter != aMergedIter->aCells.end() ) - { - (*aCellIter)->setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ROW_SPAN)), uno::makeAny( nCellCount )); - if( bFirstCell ) - { - nCellCount *= -1; - bFirstCell = false; - } - ++nCellCount; - ++aCellIter; - } - ++aMergedIter; + lcl_ApplyCellProperties(nCell, + aRowSeparators[nRow], aCurrentRow[nCell], + pTextTable->getCellByPosition(nCell, nRow), + aMergedCells); } } + // now that the cell properties are set the vertical merge values + // have to be applied + lcl_MergeCells(aMergedCells); } catch( const lang::WrappedTargetException& rWrapped ) { @@ -2154,37 +2345,14 @@ uno::Reference< text::XTextTable > SwXText::convertToTable( (void)rBounds; } - - bool bIllegalException = false; - bool bRuntimeException = false; - ::rtl::OUString sMessage; - pDoc->StartUndo(UNDO_START, NULL); - pDoc->EndUndo(UNDO_START, NULL); - if( bIllegalException || bRuntimeException ) - { - SwUndoIter aUndoIter( pFirstPaM.get(), UNDO_EMPTY ); - pDoc->Undo(aUndoIter); - if(bIllegalException) - { - lang::IllegalArgumentException aEx; - aEx.Message = sMessage; - throw aEx; - } - else //if(bRuntimeException) - { - uno::RuntimeException aEx; - aEx.Message = sMessage; - throw aEx; - } - } return xRet; } /****************************************************************** * SwXBodyText ******************************************************************/ -SwXBodyText::SwXBodyText(SwDoc* _pDoc) : - SwXText(_pDoc, CURSOR_BODY) +SwXBodyText::SwXBodyText(SwDoc *const pDoc) + : SwXText(pDoc, CURSOR_BODY) { } @@ -2198,82 +2366,81 @@ SwXBodyText::~SwXBodyText() /* -----------------------------06.04.00 16:33-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXBodyText::getImplementationName(void) throw( uno::RuntimeException ) +OUString SAL_CALL +SwXBodyText::getImplementationName() throw (uno::RuntimeException) { return C2U("SwXBodyText"); } /* -----------------------------06.04.00 16:33-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXBodyText::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +static char const*const g_ServicesBodyText[] = { - return C2U("com.sun.star.text.Text") == rServiceName; + "com.sun.star.text.Text", +}; +static const size_t g_nServicesBodyText( + sizeof(g_ServicesBodyText)/sizeof(g_ServicesBodyText[0])); + +sal_Bool SAL_CALL SwXBodyText::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesBodyText, g_ServicesBodyText, rServiceName); } -/* -----------------------------06.04.00 16:33-------------------------------- - ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXBodyText::getSupportedServiceNames(void) throw( uno::RuntimeException ) +uno::Sequence< OUString > SAL_CALL +SwXBodyText::getSupportedServiceNames() throw (uno::RuntimeException) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.Text"); - return aRet; + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesBodyText, g_ServicesBodyText); } + /*-- 10.12.98 11:17:27--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXBodyText::queryAggregation( - const uno::Type& rType ) - throw(uno::RuntimeException) +uno::Any SAL_CALL +SwXBodyText::queryAggregation(const uno::Type& rType) +throw (uno::RuntimeException) { uno::Any aRet; - const uno::Type& rXEnumerationAccessType = ::getCppuType((uno::Reference< container::XEnumerationAccess >*)0); - const uno::Type& rXElementAccessType = ::getCppuType((uno::Reference< container::XElementAccess >*)0); - const uno::Type& rXServiceInfoType = ::getCppuType((uno::Reference< lang::XServiceInfo >*)0); - - if(rType == rXEnumerationAccessType) + if (rType == container::XEnumerationAccess::static_type()) { - uno::Reference<container::XEnumerationAccess> xRet = this; - aRet.setValue(&xRet, rXEnumerationAccessType); + aRet <<= uno::Reference< container::XEnumerationAccess >(this); } - else if(rType == rXElementAccessType) + else if (rType == container::XElementAccess::static_type()) { - uno::Reference<container::XElementAccess> xRet = this; - aRet.setValue(&xRet, rXElementAccessType); + aRet <<= uno::Reference< container::XElementAccess >(this); } - else if(rType == rXServiceInfoType) + else if (rType == lang::XServiceInfo::static_type()) { - uno::Reference<lang::XServiceInfo> xRet = this; - aRet.setValue(&xRet, rXServiceInfoType); + aRet <<= uno::Reference< lang::XServiceInfo >(this); } else { aRet = SwXText::queryInterface( rType ); } if(aRet.getValueType() == ::getCppuVoidType()) + { aRet = OWeakAggObject::queryAggregation( rType ); + } return aRet; } /*-- 10.12.98 11:17:28--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Sequence< uno::Type > SwXBodyText::getTypes( ) throw(uno::RuntimeException) -{ - uno::Sequence< uno::Type > aTypes = SwXBodyTextBaseClass::getTypes(); - uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); - long nIndex = aTypes.getLength(); - aTypes.realloc(aTypes.getLength() + aTextTypes.getLength()); - uno::Type* pTypes = aTypes.getArray(); - const uno::Type* pTextTypes = aTextTypes.getConstArray(); - for(int i = 0; i < aTextTypes.getLength(); i++) - pTypes[nIndex++] = pTextTypes[i]; - return aTypes; +uno::Sequence< uno::Type > SAL_CALL +SwXBodyText::getTypes() throw (uno::RuntimeException) +{ + const uno::Sequence< uno::Type > aTypes = SwXBodyText_Base::getTypes(); + const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); + return ::comphelper::concatSequences(aTypes, aTextTypes); } /* -----------------------------21.03.00 15:39-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< sal_Int8 > SwXBodyText::getImplementationId( ) throw(uno::RuntimeException) +uno::Sequence< sal_Int8 > SAL_CALL +SwXBodyText::getImplementationId() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); static uno::Sequence< sal_Int8 > aId( 16 ); @@ -2289,74 +2456,83 @@ uno::Sequence< sal_Int8 > SwXBodyText::getImplementationId( ) throw(uno::Runtim -----------------------------------------------------------------------*/ uno::Any SAL_CALL - SwXBodyText::queryInterface( const uno::Type& rType ) - throw(uno::RuntimeException) +SwXBodyText::queryInterface(const uno::Type& rType) +throw (uno::RuntimeException) { - uno::Any aRet = SwXText::queryInterface( rType ); - if(aRet.getValueType() == ::getCppuVoidType()) - aRet = SwXBodyTextBaseClass::queryInterface( rType ); - return aRet; + const uno::Any ret = SwXText::queryInterface(rType); + return (ret.getValueType() == ::getCppuVoidType()) + ? SwXBodyText_Base::queryInterface(rType) + : ret; } /* -----------------------------05.01.00 11:07-------------------------------- ---------------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXBodyText::CreateTextCursor(sal_Bool bIgnoreTables) +SwXTextCursor * SwXBodyText::CreateTextCursor(const bool bIgnoreTables) { - uno::Reference< text::XTextCursor > xRet; - if(IsValid()) + if(!IsValid()) { - SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); - //the cursor has to skip tables contained in this text - SwPaM aPam(rNode); - aPam.Move( fnMoveBackward, fnGoDoc ); - if(!bIgnoreTables) + return 0; + } + + // the cursor has to skip tables contained in this text + SwPaM aPam(GetDoc()->GetNodes().GetEndOfContent()); + aPam.Move( fnMoveBackward, fnGoDoc ); + if (!bIgnoreTables) + { + SwTableNode * pTblNode = aPam.GetNode()->FindTableNode(); + SwCntntNode * pCont = 0; + while (pTblNode) { - SwTableNode* pTblNode = aPam.GetNode()->FindTableNode(); - SwCntntNode* pCont = 0; - while( pTblNode ) - { - aPam.GetPoint()->nNode = *pTblNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode); - pTblNode = pCont->FindTableNode(); - } - if(pCont) - aPam.GetPoint()->nContent.Assign(pCont, 0); + aPam.GetPoint()->nNode = *pTblNode->EndOfSectionNode(); + pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode); + pTblNode = pCont->FindTableNode(); + } + if (pCont) + { + aPam.GetPoint()->nContent.Assign(pCont, 0); } - xRet = (text::XWordCursor*)new SwXTextCursor(this, *aPam.GetPoint(), CURSOR_BODY, GetDoc()); } - return xRet; + return new SwXTextCursor(*GetDoc(), this, CURSOR_BODY, *aPam.GetPoint()); } + /*-- 10.12.98 11:17:29--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXBodyText::createTextCursor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXBodyText::createTextCursor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > aRef = CreateTextCursor(sal_False); - if(!aRef.is()) + + const uno::Reference< text::XTextCursor > xRef( + static_cast<text::XWordCursor*>(CreateTextCursor(false)) ); + if (!xRef.is()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - return aRef; + return xRef; } /*-- 10.12.98 11:17:29--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXBodyText::createTextCursorByRange( - const uno::Reference< text::XTextRange > & aTextPosition) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXBodyText::createTextCursorByRange( + const uno::Reference< text::XTextRange > & xTextPosition) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > aRef; + if(!IsValid()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } + + uno::Reference< text::XTextCursor > aRef; SwUnoInternalPaM aPam(*GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, aTextPosition)) + if (::sw::XTextRangeToSwPaM(aPam, xTextPosition)) { SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); @@ -2366,152 +2542,232 @@ uno::Reference< text::XTextCursor > SwXBodyText::createTextCursorByRange( { p1 = p1->StartOfSectionNode(); } - SwStartNode* p2 = rNode.StartOfSectionNode(); + SwStartNode *const p2 = rNode.StartOfSectionNode(); if(p1 == p2) - aRef = (text::XWordCursor*)new SwXTextCursor(this , *aPam.GetPoint(), CURSOR_BODY, GetDoc(), aPam.GetMark()); + { + aRef = static_cast<text::XWordCursor*>( + new SwXTextCursor(*GetDoc(), this, CURSOR_BODY, + *aPam.GetPoint(), aPam.GetMark())); + } } if(!aRef.is()) + { throw uno::RuntimeException(); + } return aRef; } + /*-- 10.12.98 11:17:30--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXBodyText::createEnumeration(void) - throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXBodyText::createEnumeration() +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< container::XEnumeration > aRef; - if(IsValid()) - { - SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); - SwPosition aPos(rNode); - SwUnoCrsr* pUnoCrsr = GetDoc()->CreateUnoCrsr(aPos, sal_False); - pUnoCrsr->Move( fnMoveBackward, fnGoDoc ); - aRef = new SwXParagraphEnumeration(this, pUnoCrsr, CURSOR_BODY); - } - else + + if (!IsValid()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - return aRef; + SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); + SwPosition aPos(rNode); + ::std::auto_ptr<SwUnoCrsr> pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveBackward, fnGoDoc); + const uno::Reference< container::XEnumeration > xRet + = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_BODY); + return xRet; } + /* -----------------18.12.98 13:36------------------- * * --------------------------------------------------*/ -uno::Type SwXBodyText::getElementType(void) throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXBodyText::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference<text::XTextRange>*)0); + return text::XTextRange::static_type(); } /* -----------------18.12.98 13:36------------------- * * --------------------------------------------------*/ -sal_Bool SwXBodyText::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL +SwXBodyText::hasElements() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(IsValid()) - return sal_True; - else + + if (!IsValid()) { uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } + + return sal_True; } + /****************************************************************** * SwXHeadFootText ******************************************************************/ -TYPEINIT1(SwXHeadFootText, SwClient); -/* -----------------------------06.04.00 16:40-------------------------------- - ---------------------------------------------------------------------------*/ -OUString SwXHeadFootText::getImplementationName(void) throw( uno::RuntimeException ) +class SwXHeadFootText::Impl + : public SwClient { - return C2U("SwXHeadFootText"); + +public: + + bool m_bIsHeader; + + Impl( SwXHeadFootText & /*rThis*/, + SwFrmFmt & rHeadFootFmt, const bool bIsHeader) + : SwClient(& rHeadFootFmt) + , m_bIsHeader(bIsHeader) + { + } + + SwFrmFmt * GetHeadFootFmt() const { + return static_cast<SwFrmFmt*>( + const_cast<SwModify*>(GetRegisteredIn())); + } + + SwFrmFmt & GetHeadFootFmtOrThrow() { + SwFrmFmt *const pFmt( GetHeadFootFmt() ); + if (!pFmt) { + throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM( + "SwXHeadFootText: disposed or invalid")), 0); + } + return *pFmt; + } + + // SwClient + virtual void Modify(SfxPoolItem *pOld, SfxPoolItem *pNew); + +}; + +/*-- 11.12.98 10:14:51--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SwXHeadFootText::Impl::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) +{ + ClientModify(this, pOld, pNew); } -/* -----------------------------06.04.00 16:40-------------------------------- - ---------------------------------------------------------------------------*/ -BOOL SwXHeadFootText::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) +bool SwXHeadFootText::IsXHeadFootText(SwClient *const pClient) { - return C2U("com.sun.star.text.Text") == rServiceName; + return 0 != dynamic_cast<SwXHeadFootText::Impl*>(pClient); } -/* -----------------------------06.04.00 16:40-------------------------------- - ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXHeadFootText::getSupportedServiceNames(void) throw( uno::RuntimeException ) +uno::Reference< text::XText > +SwXHeadFootText::CreateXHeadFootText( + SwFrmFmt & rHeadFootFmt, const bool bIsHeader) { - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = C2U("com.sun.star.text.Text"); - return aRet; + // re-use existing SwXHeadFootText + // #i105557#: do not iterate over the registered clients: race condition + uno::Reference< text::XText > xText(rHeadFootFmt.GetXObject(), + uno::UNO_QUERY); + if (!xText.is()) + { + SwXHeadFootText *const pXHFT( + new SwXHeadFootText(rHeadFootFmt, bIsHeader)); + xText.set(pXHFT); + rHeadFootFmt.SetXObject(xText); + } + return xText; } + /*-- 11.12.98 10:14:48--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXHeadFootText::SwXHeadFootText(SwFrmFmt& rHeadFootFmt, BOOL bHeader) : - SwXText(rHeadFootFmt.GetDoc(), bHeader ? CURSOR_HEADER : CURSOR_FOOTER), - SwClient(&rHeadFootFmt), - bIsHeader(bHeader) +SwXHeadFootText::SwXHeadFootText(SwFrmFmt & rHeadFootFmt, const bool bIsHeader) + : SwXText(rHeadFootFmt.GetDoc(), + (bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER) + , m_pImpl( new SwXHeadFootText::Impl(*this, rHeadFootFmt, bIsHeader) ) { - } + /*-- 11.12.98 10:14:48--------------------------------------------------- -----------------------------------------------------------------------*/ SwXHeadFootText::~SwXHeadFootText() { +} + +/* -----------------------------06.04.00 16:40-------------------------------- + + ---------------------------------------------------------------------------*/ +OUString SAL_CALL +SwXHeadFootText::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXHeadFootText"); +} + +/* -----------------------------06.04.00 16:40-------------------------------- + + ---------------------------------------------------------------------------*/ +static char const*const g_ServicesHeadFootText[] = +{ + "com.sun.star.text.Text", +}; +static const size_t g_nServicesHeadFootText( + sizeof(g_ServicesHeadFootText)/sizeof(g_ServicesHeadFootText[0])); +sal_Bool SAL_CALL SwXHeadFootText::supportsService(const OUString& rServiceName) +throw (uno::RuntimeException) +{ + return ::sw::SupportsServiceImpl( + g_nServicesHeadFootText, g_ServicesHeadFootText, rServiceName); } + +uno::Sequence< OUString > SAL_CALL +SwXHeadFootText::getSupportedServiceNames() throw (uno::RuntimeException) +{ + return ::sw::GetSupportedServiceNamesImpl( + g_nServicesHeadFootText, g_ServicesHeadFootText); +} + /*-- 11.12.98 10:14:49--------------------------------------------------- -----------------------------------------------------------------------*/ const SwStartNode *SwXHeadFootText::GetStartNode() const { const SwStartNode *pSttNd = 0; - SwFrmFmt* pHeadFootFmt = GetFmt(); + SwFrmFmt *const pHeadFootFmt = m_pImpl->GetHeadFootFmt(); if(pHeadFootFmt) { const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); if( rFlyCntnt.GetCntntIdx() ) + { pSttNd = rFlyCntnt.GetCntntIdx()->GetNode().GetStartNode(); + } } return pSttNd; } -uno::Reference< text::XTextCursor > SwXHeadFootText::createCursor() throw(uno::RuntimeException) +uno::Reference< text::XTextCursor > +SwXHeadFootText::CreateCursor() throw (uno::RuntimeException) { return createTextCursor(); } /* -----------------------------21.03.00 15:39-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< uno::Type > SwXHeadFootText::getTypes( ) throw(uno::RuntimeException) +uno::Sequence< uno::Type > SAL_CALL +SwXHeadFootText::getTypes() throw (uno::RuntimeException) { - uno::Sequence< uno::Type > aHFTypes = SwXHeadFootTextBaseClass::getTypes(); - uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); - - long nIndex = aHFTypes.getLength(); - aHFTypes.realloc( - aHFTypes.getLength() + - aTextTypes.getLength()); - - uno::Type* pHFTypes = aHFTypes.getArray(); - const uno::Type* pTextTypes = aTextTypes.getConstArray(); - for(long nPos = 0; nPos < aTextTypes.getLength(); nPos++) - pHFTypes[nIndex++] = pTextTypes[nPos]; - - return aHFTypes; + const uno::Sequence< uno::Type > aTypes = SwXHeadFootText_Base::getTypes(); + const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); + return ::comphelper::concatSequences(aTypes, aTextTypes); } /* -----------------------------21.03.00 15:39-------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< sal_Int8 > SwXHeadFootText::getImplementationId( ) throw(uno::RuntimeException) +uno::Sequence< sal_Int8 > SAL_CALL +SwXHeadFootText::getImplementationId() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); static uno::Sequence< sal_Int8 > aId( 16 ); @@ -2526,140 +2782,141 @@ uno::Sequence< sal_Int8 > SwXHeadFootText::getImplementationId( ) throw(uno::Ru /* -----------------------------21.03.00 15:46-------------------------------- ---------------------------------------------------------------------------*/ -uno::Any SwXHeadFootText::queryInterface( const uno::Type& aType ) throw(uno::RuntimeException) +uno::Any SAL_CALL +SwXHeadFootText::queryInterface(const uno::Type& rType) +throw (uno::RuntimeException) { - uno::Any aRet = SwXHeadFootTextBaseClass::queryInterface(aType); - if(aRet.getValueType() == ::getCppuVoidType() ) - aRet = SwXText::queryInterface(aType); - return aRet; + const uno::Any ret = SwXHeadFootText_Base::queryInterface(rType); + return (ret.getValueType() == ::getCppuVoidType()) + ? SwXText::queryInterface(rType) + : ret; } /*-- 11.12.98 10:14:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXHeadFootText::createTextCursor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXHeadFootText::createTextCursor() throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRet; - SwFrmFmt* pHeadFootFmt = GetFmt(); - if(pHeadFootFmt) - { - const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); - const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); - SwPosition aPos(rNode); - SwXTextCursor* pCrsr = new SwXTextCursor(this, aPos, bIsHeader ? CURSOR_HEADER : CURSOR_FOOTER, GetDoc()); - SwUnoCrsr* pUnoCrsr = pCrsr->GetCrsr(); - pUnoCrsr->Move(fnMoveForward, fnGoNode); - - //save current start node to be able to check if there is content after the table - - //otherwise the cursor would be in the body text! - - const SwStartNode* pOwnStartNode = rNode.FindSttNodeByType( - bIsHeader ? SwHeaderStartNode : SwFooterStartNode); - //steht hier eine Tabelle? - SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); - SwCntntNode* pCont = 0; - while( pTblNode ) - { - pUnoCrsr->GetPoint()->nNode = *pTblNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&pUnoCrsr->GetPoint()->nNode); - pTblNode = pCont->FindTableNode(); - } - if(pCont) - pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); - const SwStartNode* pNewStartNode = pUnoCrsr->GetNode()->FindSttNodeByType( - bIsHeader ? SwHeaderStartNode : SwFooterStartNode); - if(!pNewStartNode || pNewStartNode != pOwnStartNode) - { - pCrsr = NULL; - uno::RuntimeException aExcept; - aExcept.Message = S2U("no text available"); - throw aExcept; - } - xRet = (text::XWordCursor*)pCrsr; - } - else - { - uno::RuntimeException aRuntime; - aRuntime.Message = C2U(cInvalidObject); - throw aRuntime; + + SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() ); + + uno::Reference< text::XTextCursor > xRet; + const SwFmtCntnt& rFlyCntnt = rHeadFootFmt.GetCntnt(); + const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); + SwPosition aPos(rNode); + SwXTextCursor *const pXCursor = new SwXTextCursor(*GetDoc(), this, + (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, aPos); + SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); + pUnoCrsr->Move(fnMoveForward, fnGoNode); + + // save current start node to be able to check if there is content + // after the table - otherwise the cursor would be in the body text! + SwStartNode const*const pOwnStartNode = rNode.FindSttNodeByType( + (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode); + // is there a table here? + SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode(); + SwCntntNode* pCont = 0; + while (pTblNode) + { + pUnoCrsr->GetPoint()->nNode = *pTblNode->EndOfSectionNode(); + pCont = GetDoc()->GetNodes().GoNext(&pUnoCrsr->GetPoint()->nNode); + pTblNode = pCont->FindTableNode(); + } + if (pCont) + { + pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0); + } + SwStartNode const*const pNewStartNode = + pUnoCrsr->GetNode()->FindSttNodeByType( + (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode); + if (!pNewStartNode || (pNewStartNode != pOwnStartNode)) + { + uno::RuntimeException aExcept; + aExcept.Message = S2U("no text available"); + throw aExcept; } + xRet = static_cast<text::XWordCursor*>(pXCursor); return xRet; } + /*-- 11.12.98 10:14:50--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextCursor > SwXHeadFootText::createTextCursorByRange( - const uno::Reference< text::XTextRange > & aTextPosition) throw( uno::RuntimeException ) +uno::Reference< text::XTextCursor > SAL_CALL +SwXHeadFootText::createTextCursorByRange( + const uno::Reference< text::XTextRange > & xTextPosition) +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Reference< text::XTextCursor > xRet; - SwFrmFmt* pHeadFootFmt = GetFmt(); + + SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() ); + SwUnoInternalPaM aPam(*GetDoc()); - if(pHeadFootFmt && SwXTextRange::XTextRangeToSwPaM(aPam, aTextPosition)) + if (!::sw::XTextRangeToSwPaM(aPam, xTextPosition)) { - SwNode& rNode = pHeadFootFmt->GetCntnt().GetCntntIdx()->GetNode(); - SwPosition aPos(rNode); - SwPaM aHFPam(aPos); - aHFPam.Move(fnMoveForward, fnGoNode); - SwStartNode* pOwnStartNode = aHFPam.GetNode()->FindSttNodeByType( - bIsHeader ? SwHeaderStartNode : SwFooterStartNode); - SwStartNode* p1 = aPam.GetNode()->FindSttNodeByType( - bIsHeader ? SwHeaderStartNode : SwFooterStartNode); - if(p1 == pOwnStartNode) - xRet = (text::XWordCursor*)new SwXTextCursor(this, *aPam.GetPoint(), - bIsHeader ? CURSOR_HEADER : CURSOR_FOOTER, GetDoc(), aPam.GetMark()); + uno::RuntimeException aRuntime; + aRuntime.Message = C2U(cInvalidObject); + throw aRuntime; + } + + uno::Reference< text::XTextCursor > xRet; + SwNode& rNode = rHeadFootFmt.GetCntnt().GetCntntIdx()->GetNode(); + SwPosition aPos(rNode); + SwPaM aHFPam(aPos); + aHFPam.Move(fnMoveForward, fnGoNode); + SwStartNode *const pOwnStartNode = aHFPam.GetNode()->FindSttNodeByType( + (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode); + SwStartNode *const p1 = aPam.GetNode()->FindSttNodeByType( + (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode); + if (p1 == pOwnStartNode) + { + xRet = static_cast<text::XWordCursor*>( + new SwXTextCursor(*GetDoc(), this, + (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER, + *aPam.GetPoint(), aPam.GetMark())); } return xRet; } + /* -----------------19.03.99 15:44------------------- * * --------------------------------------------------*/ -uno::Reference< container::XEnumeration > SwXHeadFootText::createEnumeration(void) - throw( uno::RuntimeException ) +uno::Reference< container::XEnumeration > SAL_CALL +SwXHeadFootText::createEnumeration() +throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); + + SwFrmFmt & rHeadFootFmt( m_pImpl->GetHeadFootFmtOrThrow() ); + uno::Reference< container::XEnumeration > aRef; - //wenn this ungueltig ist, dann kommt die uno::Exception aus createTextCursor() - SwFrmFmt* pHeadFootFmt = GetFmt(); - if(pHeadFootFmt) - { - const SwFmtCntnt& rFlyCntnt = pHeadFootFmt->GetCntnt(); - const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); - SwPosition aPos(rNode); - SwUnoCrsr* pUnoCrsr = GetDoc()->CreateUnoCrsr(aPos, sal_False); - pUnoCrsr->Move(fnMoveForward, fnGoNode); - aRef = new SwXParagraphEnumeration(this, pUnoCrsr, bIsHeader ? CURSOR_HEADER : CURSOR_FOOTER); - } - else - { - uno::RuntimeException aRuntime; - aRuntime.Message = C2U(cInvalidObject); - throw aRuntime; - } + const SwFmtCntnt& rFlyCntnt = rHeadFootFmt.GetCntnt(); + const SwNode& rNode = rFlyCntnt.GetCntntIdx()->GetNode(); + SwPosition aPos(rNode); + ::std::auto_ptr<SwUnoCrsr> pUnoCursor( + GetDoc()->CreateUnoCrsr(aPos, sal_False)); + pUnoCursor->Move(fnMoveForward, fnGoNode); + aRef = new SwXParagraphEnumeration(this, pUnoCursor, + (m_pImpl->m_bIsHeader) ? CURSOR_HEADER : CURSOR_FOOTER); return aRef; } + /* -----------------19.03.99 15:50------------------- * * --------------------------------------------------*/ -uno::Type SwXHeadFootText::getElementType(void) throw( uno::RuntimeException ) +uno::Type SAL_CALL +SwXHeadFootText::getElementType() throw (uno::RuntimeException) { - return ::getCppuType((uno::Reference<text::XTextRange>*)0); + return text::XTextRange::static_type(); } /* -----------------19.03.99 15:50------------------- * * --------------------------------------------------*/ -sal_Bool SwXHeadFootText::hasElements(void) throw( uno::RuntimeException ) +sal_Bool SAL_CALL SwXHeadFootText::hasElements() throw (uno::RuntimeException) { return sal_True; } -/*-- 11.12.98 10:14:51--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void SwXHeadFootText::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) -{ - ClientModify( this, pOld, pNew); -} - diff --git a/sw/source/core/view/vdraw.cxx b/sw/source/core/view/vdraw.cxx index 518a6bc39d..201bd24b03 100644 --- a/sw/source/core/view/vdraw.cxx +++ b/sw/source/core/view/vdraw.cxx @@ -46,10 +46,8 @@ #include <svx/svdoutl.hxx> #ifdef DBG_UTIL -#ifndef _SVX_FMGLOB_HXX #include <svx/fmglob.hxx> #endif -#endif #include "fesh.hxx" #include "pagefrm.hxx" @@ -63,9 +61,8 @@ #include "flyfrm.hxx" #include <vcl/svapp.hxx> -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include <IDocumentDrawModelAccess.hxx> -#endif + /************************************************************************* |* @@ -345,8 +342,10 @@ void SwViewImp::NotifySizeChg( const Size &rNewSz ) const SwFrm *pAnchor = ((SwDrawContact*)pCont)->GetAnchorFrm(); if ( !pAnchor || pAnchor->IsInFly() || !pAnchor->IsValid() || !pAnchor->GetUpper() || !pAnchor->FindPageFrm() || - FLY_IN_CNTNT == pCont->GetFmt()->GetAnchor().GetAnchorId() ) + (FLY_AS_CHAR == pCont->GetFmt()->GetAnchor().GetAnchorId()) ) + { continue; + } // OD 19.06.2003 #108784# - no move for drawing objects in header/footer if ( pAnchor->FindFooterOrHeader() ) diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index a1fb3d5aeb..d4483831d9 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -34,9 +34,7 @@ #include <tools/date.hxx> #include <tools/time.hxx> #include <svl/urihelper.hxx> -#ifndef SVTOOLS_FSTATHELPER_HXX #include <svl/fstathelper.hxx> -#endif #include <unotools/moduleoptions.hxx> #include <sfx2/docfile.hxx> #include <svx/lrspitem.hxx> @@ -60,9 +58,7 @@ #include <pagedesc.hxx> #include <poolfmt.hxx> #include <fltini.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <redline.hxx> #include <swerror.h> @@ -72,6 +68,7 @@ #include <pausethreadstarting.hxx> // <-- + using namespace ::com::sun::star; ////////////////////////////////////////////////////////////////////////// @@ -241,9 +238,9 @@ ULONG SwReader::Read( const Reader& rOptions ) { SwPosition const*const pFrameAnchor( rAnchor.GetCntntAnchor()); - if ( (FLY_PAGE == rAnchor.GetAnchorId()) + if ( (FLY_AT_PAGE == rAnchor.GetAnchorId()) || ( pFrameAnchor - && ( ( (FLY_AT_CNTNT == rAnchor.GetAnchorId()) + && ( ( (FLY_AT_PARA == rAnchor.GetAnchorId()) && ( (pUndoPam->GetPoint()->nNode == pFrameAnchor->nNode) || (pUndoPam->GetMark()->nNode == @@ -251,7 +248,7 @@ ULONG SwReader::Read( const Reader& rOptions ) ) ) // #i97570# also check frames anchored AT char - || ( (FLY_AUTO_CNTNT == rAnchor.GetAnchorId()) + || ( (FLY_AT_CHAR == rAnchor.GetAnchorId()) && !IsDestroyFrameAnchoredAtChar( *pFrameAnchor, *pUndoPam->GetPoint(), @@ -262,7 +259,7 @@ ULONG SwReader::Read( const Reader& rOptions ) ) { if( bChkHeaderFooter && - FLY_AT_CNTNT == rAnchor.GetAnchorId() && + (FLY_AT_PARA == rAnchor.GetAnchorId()) && RES_DRAWFRMFMT == pFrmFmt->Which() ) { // DrawObjecte in Kopf-/Fusszeilen ist nicht @@ -286,15 +283,19 @@ ULONG SwReader::Read( const Reader& rOptions ) pFrmFmt->DelFrms(); } - if( FLY_PAGE == rAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == rAnchor.GetAnchorId()) { if( !rAnchor.GetCntntAnchor() ) + { pFrmFmt->MakeFrms(); + } else if( pCrsr ) + { // seitengebundene Flys eingefuegt, dann schalte // die Optimierungs-Flags vom SwDoc ab. Sonst // werden die Flys nicht an der Position erzeugt. pDoc->SetLoaded( FALSE ); + } } else pFrmFmt->MakeFrms(); diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx index 4bb446e1f4..3fd0513632 100644 --- a/sw/source/filter/html/css1atr.cxx +++ b/sw/source/filter/html/css1atr.cxx @@ -35,9 +35,7 @@ #include "hintids.hxx" #include <vcl/svapp.hxx> -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <svl/whiter.hxx> #include <svx/boxitem.hxx> #include <svx/ulspitem.hxx> @@ -2130,8 +2128,8 @@ void SwHTMLWriter::OutCSS1_FrmFmtOptions( const SwFrmFmt& rFrmFmt, const SwFmtAnchor& rAnchor = rFrmFmt.GetAnchor(); switch( rAnchor.GetAnchorId() ) { - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: if( text::RelOrientation::FRAME == rHoriOri.GetRelationOrient() || text::RelOrientation::PRINT_AREA == rHoriOri.GetRelationOrient() ) { @@ -2146,7 +2144,7 @@ void SwHTMLWriter::OutCSS1_FrmFmtOptions( const SwFrmFmt& rFrmFmt, break; } - case FLY_PAGE: + case FLY_AT_PAGE: case FLY_AT_FLY: { // position @@ -2375,7 +2373,7 @@ void SwHTMLWriter::OutCSS1_FrmFmtBackground( const SwFrmFmt& rFrmFmt ) const SwFmtAnchor& rAnchor = rFrmFmt.GetAnchor(); RndStdIds eAnchorId = rAnchor.GetAnchorId(); const SwPosition *pAnchorPos = rAnchor.GetCntntAnchor(); - if( FLY_PAGE != eAnchorId && pAnchorPos ) + if (FLY_AT_PAGE != eAnchorId && pAnchorPos) { const SwNode& rNode = pAnchorPos->nNode.GetNode(); if( rNode.IsCntntNode() ) diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx index 62ae86f551..51d3e62c82 100644 --- a/sw/source/filter/html/htmlcss1.cxx +++ b/sw/source/filter/html/htmlcss1.cxx @@ -39,17 +39,12 @@ #include <svl/urihelper.hxx> #include <i18npool/mslangid.hxx> #include <sfx2/docfile.hxx> -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif #include <svx/fhgtitem.hxx> #include <svx/brshitem.hxx> #include <svx/lrspitem.hxx> #include <svx/ulspitem.hxx> -#ifndef _SVX_BOXITEM_HXX //autogen - #include <svx/boxitem.hxx> -#endif #include <svx/fhgtitem.hxx> #include <svx/flstitem.hxx> #include <svx/brkitem.hxx> @@ -2094,7 +2089,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( const SfxItemSet & /*rItemSet*/, } else { - aAnchor.SetType( FLY_PAGE ); + aAnchor.SetType( FLY_AT_PAGE ); aAnchor.SetPageNum( 1 ); } nHoriPos = rPropInfo.nLeft; @@ -2102,7 +2097,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( const SfxItemSet & /*rItemSet*/, } else { - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); aAnchor.SetAnchor( pPam->GetPoint() ); eVertOri = text::VertOrientation::TOP; eVertRel = text::RelOrientation::CHAR; @@ -2128,14 +2123,14 @@ void SwHTMLParser::SetAnchorAndAdjustment( const SfxItemSet & /*rItemSet*/, xub_StrLen nCntnt = pPam->GetPoint()->nContent.GetIndex(); if( nCntnt ) { - aAnchor.SetType( FLY_AUTO_CNTNT ); + aAnchor.SetType( FLY_AT_CHAR ); pPam->Move( fnMoveBackward ); eVertOri = text::VertOrientation::CHAR_BOTTOM; eVertRel = text::RelOrientation::CHAR; } else { - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); eVertOri = text::VertOrientation::TOP; eVertRel = text::RelOrientation::PRINT_AREA; } diff --git a/sw/source/filter/html/htmldraw.cxx b/sw/source/filter/html/htmldraw.cxx index 0b44d5d790..51fd729c56 100644 --- a/sw/source/filter/html/htmldraw.cxx +++ b/sw/source/filter/html/htmldraw.cxx @@ -34,9 +34,7 @@ #include "hintids.hxx" #include <vcl/svapp.hxx> -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <svx/svdmodel.hxx> #include <svx/svdpage.hxx> #include <svx/svdobj.hxx> @@ -182,7 +180,7 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, aFrmSet.Put( aULItem ); } - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); if( SVX_CSS1_POS_ABSOLUTE == rCSS1PropInfo.ePosition && SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eLeftType && SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eTopType ) @@ -198,7 +196,7 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, } else { - aAnchor.SetType( FLY_PAGE ); + aAnchor.SetType( FLY_AT_PAGE ); } // OD 2004-04-13 #i26791# - direct positioning for <SwDoc::Insert(..)> pNewDrawObj->SetRelativePos( Point(rCSS1PropInfo.nLeft + nLeftSpace, @@ -208,7 +206,7 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, else if( SVX_ADJUST_LEFT == rCSS1PropInfo.eFloat || text::HoriOrientation::LEFT == eHoriOri ) { - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); aFrmSet.Put( SwFmtSurround(bHidden ? SURROUND_THROUGHT : SURROUND_RIGHT) ); // OD 2004-04-13 #i26791# - direct positioning for <SwDoc::Insert(..)> @@ -219,10 +217,14 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, aFrmSet.Put( SwFmtVertOrient( 0, eVertOri ) ); } - if( FLY_PAGE == aAnchor.GetAnchorId() ) + if (FLY_AT_PAGE == aAnchor.GetAnchorId()) + { aAnchor.SetPageNum( 1 ); + } else if( FLY_AT_FLY != aAnchor.GetAnchorId() ) + { aAnchor.SetAnchor( pPam->GetPoint() ); + } aFrmSet.Put( aAnchor ); pDoc->Insert( *pPam, *pNewDrawObj, &aFrmSet, NULL ); diff --git a/sw/source/filter/html/htmlfly.cxx b/sw/source/filter/html/htmlfly.cxx index b53df3f464..22cd272d7e 100644 --- a/sw/source/filter/html/htmlfly.cxx +++ b/sw/source/filter/html/htmlfly.cxx @@ -39,12 +39,8 @@ #include "hintids.hxx" #include <tools/string.hxx> #include <svl/urihelper.hxx> -#ifndef _APP_HXX #include <vcl/svapp.hxx> -#endif -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <svtools/htmlkywd.hxx> #include <svtools/htmlout.hxx> #include <svtools/imap.hxx> @@ -338,12 +334,12 @@ void SwHTMLWriter::CollectFlyFrms() sal_Int16 eHoriRel = rFrmFmt.GetHoriOrient().GetRelationOrient(); switch( rAnchor.GetAnchorId() ) { - case FLY_PAGE: + case FLY_AT_PAGE: case FLY_AT_FLY: nMode = aHTMLOutFrmPageFlyTable[eType][nExportMode]; break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: // Absatz-gebundene Rahmen werden nur dann vor den // Absatz geschrieben, wenn der Absatz einen Abstand // hat. @@ -362,7 +358,7 @@ void SwHTMLWriter::CollectFlyFrms() nMode = aHTMLOutFrmParaPrtAreaTable[eType][nExportMode]; break; - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: if( text::RelOrientation::FRAME == eHoriRel || text::RelOrientation::PRINT_AREA == eHoriRel ) nMode = aHTMLOutFrmParaPrtAreaTable[eType][nExportMode]; else @@ -594,7 +590,7 @@ void SwHTMLWriter::OutFrmFmtOptions( const SwFrmFmt &rFrmFmt, const sal_Char *pStr = 0; RndStdIds eAnchorId = rFrmFmt.GetAnchor().GetAnchorId(); if( (nFrmOpts & HTML_FRMOPT_ALIGN) && - (FLY_AT_CNTNT == eAnchorId || FLY_AUTO_CNTNT == eAnchorId) ) + ((FLY_AT_PARA == eAnchorId) || (FLY_AT_CHAR == eAnchorId)) ) { // MIB 12.3.98: Ist es nicht schlauer, absatzgebundene // Rahmen notfalls links auszurichten als sie @@ -611,7 +607,7 @@ void SwHTMLWriter::OutFrmFmtOptions( const SwFrmFmt &rFrmFmt, } if( (nFrmOpts & HTML_FRMOPT_ALIGN) && !pStr && ( (nFrmOpts & HTML_FRMOPT_S_ALIGN) == 0 || - FLY_IN_CNTNT == eAnchorId ) && + (FLY_AS_CHAR == eAnchorId) ) && SFX_ITEM_SET == rItemSet.GetItemState( RES_VERT_ORIENT, TRUE, &pItem )) { switch( ((SwFmtVertOrient*)pItem)->GetVertOrient() ) @@ -764,8 +760,8 @@ void SwHTMLWriter::OutFrmFmtOptions( const SwFrmFmt &rFrmFmt, // Umlauf fuer absatzgeb. Grafiken als <BR CLEAR=...> in den String // schreiben if( (nFrmOpts & HTML_FRMOPT_BRCLEAR) && - (FLY_AT_CNTNT== rFrmFmt.GetAnchor().GetAnchorId() || - FLY_AUTO_CNTNT== rFrmFmt.GetAnchor().GetAnchorId()) && + ((FLY_AT_PARA == rFrmFmt.GetAnchor().GetAnchorId()) || + (FLY_AT_CHAR == rFrmFmt.GetAnchor().GetAnchorId())) && SFX_ITEM_SET == rItemSet.GetItemState( RES_SURROUND, TRUE, &pItem )) { const SwFmtSurround* pSurround = (const SwFmtSurround*)pItem; @@ -1893,7 +1889,7 @@ SwHTMLPosFlyFrm::SwHTMLPosFlyFrm( const SwPosFlyFrm& rPosFly, nOutputMode( nOutMode ) { const SwFmtAnchor& rAnchor = rPosFly.GetFmt().GetAnchor(); - if( FLY_AUTO_CNTNT==rAnchor.GetAnchorId() && + if ((FLY_AT_CHAR == rAnchor.GetAnchorId()) && HTML_POS_INSIDE == GetOutPos() ) { // Auto-gebundene Rahmen werden ein Zeichen weiter hinten diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx index 8de7daea6d..9c35e6d4a3 100644 --- a/sw/source/filter/html/htmlform.cxx +++ b/sw/source/filter/html/htmlform.cxx @@ -34,22 +34,16 @@ #include <hintids.hxx> #include <vcl/svapp.hxx> -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <vcl/imgcons.hxx> -#ifndef _TOOLKIT_UNOHLP_HXX #include <toolkit/helper/vclunohelper.hxx> -#endif #include <svtools/htmlkywd.hxx> #include <svtools/htmltokn.h> #include <svl/urihelper.hxx> #include <sfx2/request.hxx> #include <sfx2/docfile.hxx> -#ifndef _SFXAPP_HXX #include <sfx2/viewfrm.hxx> -#endif #include <svx/lrspitem.hxx> #include <svx/ulspitem.hxx> #include <svx/brshitem.hxx> @@ -87,13 +81,14 @@ #include <docsh.hxx> #include <viewsh.hxx> #include <unodraw.hxx> -#include <unoobj.hxx> +#include <unotextrange.hxx> #include "dcontact.hxx" #include "swcss1.hxx" #include "swhtml.hxx" #include "htmlform.hxx" + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx index 07b3c78d85..7259f7456f 100644 --- a/sw/source/filter/html/htmlforw.cxx +++ b/sw/source/filter/html/htmlforw.cxx @@ -45,18 +45,14 @@ #include <com/sun/star/awt/XTextLayoutConstrains.hpp> #include <hintids.hxx> #include <vcl/svapp.hxx> -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <svl/macitem.hxx> #include <tools/urlobj.hxx> #include <svtools/htmlout.hxx> #include <svtools/htmltokn.h> #include <svtools/htmlkywd.hxx> -#include "svl/urihelper.hxx" -#ifndef _TOOLKIT_UNOHLP_HXX +#include <svl/urihelper.hxx> #include <toolkit/helper/vclunohelper.hxx> -#endif #include <svx/svdouno.hxx> #include <svx/fmglob.hxx> #include <svx/brshitem.hxx> @@ -67,7 +63,7 @@ #include <svx/postitem.hxx> #include <svx/udlnitem.hxx> #include <svx/crsditem.hxx> -#include <unoobj.hxx> + #include <docsh.hxx> #include <fmtanchr.hxx> #include <docary.hxx> @@ -81,6 +77,7 @@ #include "htmlfly.hxx" #include "htmlform.hxx" + using namespace ::com::sun::star; using ::rtl::OUString; /* */ @@ -1427,7 +1424,7 @@ void SwHTMLWriter::GetControls() const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); const SwPosition *pPos = rAnchor.GetCntntAnchor(); - if( FLY_IN_CNTNT != rAnchor.GetAnchorId() || !pPos ) + if ((FLY_AS_CHAR != rAnchor.GetAnchorId()) || !pPos) continue; const SdrObject *pSdrObj = diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index e1a3141de0..b69d5fabc0 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -33,9 +33,7 @@ #include "hintids.hxx" #include <vcl/svapp.hxx> -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <i18npool/mslangid.hxx> #include <svl/stritem.hxx> #include <svl/urihelper.hxx> @@ -208,7 +206,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( sal_Int16 eVertOri, BOOL bDontAppend ) { BOOL bMoveBackward = FALSE; - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); sal_Int16 eVertRel = text::RelOrientation::FRAME; if( text::HoriOrientation::NONE != eHoriOri ) @@ -267,14 +265,14 @@ void SwHTMLParser::SetAnchorAndAdjustment( sal_Int16 eVertOri, xub_StrLen nCntnt = pPam->GetPoint()->nContent.GetIndex(); if( nCntnt ) { - aAnchor.SetType( FLY_AUTO_CNTNT ); + aAnchor.SetType( FLY_AT_CHAR ); bMoveBackward = TRUE; eVertOri = text::VertOrientation::CHAR_BOTTOM; eVertRel = text::RelOrientation::CHAR; } else { - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); eVertOri = text::VertOrientation::TOP; eVertRel = text::RelOrientation::PRINT_AREA; } @@ -301,7 +299,7 @@ void SwHTMLParser::RegisterFlyFrm( SwFrmFmt *pFlyFmt ) // automatisch verankerte Rahmen muessen noch um eine Position // nach vorne verschoben werden. if( RES_DRAWFRMFMT != pFlyFmt->Which() && - FLY_AT_CNTNT == pFlyFmt->GetAnchor().GetAnchorId() && + (FLY_AT_PARA == pFlyFmt->GetAnchor().GetAnchorId()) && SURROUND_THROUGHT == pFlyFmt->GetSurround().GetSurround() ) { aMoveFlyFrms.Insert( pFlyFmt, aMoveFlyFrms.Count() ); @@ -778,7 +776,7 @@ IMAGE_SETEVENT: aMacroItem.SetMacro( aEvents[ n ], *pMacro ); } - if( FLY_IN_CNTNT == pFlyFmt->GetAnchor().GetAnchorId() && + if ((FLY_AS_CHAR == pFlyFmt->GetAnchor().GetAnchorId()) && aAttrTab.pINetFmt->GetSttPara() == pPam->GetPoint()->nNode && aAttrTab.pINetFmt->GetSttCnt() == @@ -1342,20 +1340,16 @@ void SwHTMLParser::StripTrailingPara() { ULONG nNodeIdx = pPam->GetPoint()->nNode.GetIndex(); - USHORT i; - - const SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); - for( i=0; i<rFrmFmtTbl.Count(); i++ ) + for( USHORT i=0; i<rFrmFmtTbl.Count(); i++ ) { - pFmt = rFrmFmtTbl[i]; - pAnchor = &pFmt->GetAnchor(); - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - (FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId()) && + SwFrmFmt const*const pFmt = rFrmFmtTbl[i]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && pAPos->nNode == nNodeIdx ) return; // den Knoten duerfen wir nicht loeschen diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx index 125cce095a..fab6e845e0 100644 --- a/sw/source/filter/html/htmlplug.cxx +++ b/sw/source/filter/html/htmlplug.cxx @@ -33,8 +33,6 @@ #include <com/sun/star/embed/EmbedStates.hpp> #include <com/sun/star/beans/XPropertySet.hpp> - - #include "hintids.hxx" #include <svl/urihelper.hxx> #define _SVSTDARR_ULONGS @@ -42,9 +40,7 @@ #include <vcl/svapp.hxx> #include <sfx2/frmhtml.hxx> #include <sfx2/frmhtmlw.hxx> -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <sot/storage.hxx> #include <svx/xoutbmp.hxx> #include <svx/ulspitem.hxx> @@ -465,7 +461,7 @@ void SwHTMLParser::InsertEmbed() } else { - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); aAnchor.SetAnchor( pPam->GetPoint() ); aFrmSet.Put( aAnchor ); aFrmSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME) ); @@ -1167,7 +1163,7 @@ Writer& OutHTML_FrmFmtOLENode( Writer& rWrt, const SwFrmFmt& rFrmFmt, sOut = '\"'; } - if( FLY_AT_CNTNT == rFrmFmt.GetAnchor().GetAnchorId() && + if ((FLY_AT_PARA == rFrmFmt.GetAnchor().GetAnchorId()) && SURROUND_THROUGHT == rFrmFmt.GetSurround().GetSurround() ) { // Das Plugin ist HIDDEN diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index ae4a704777..5f32140265 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -2837,7 +2837,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, SwFrmFmt *pFrmFmt = aMoveFlyFrms[ --n ]; const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); - ASSERT( FLY_AT_CNTNT==rAnchor.GetAnchorId(), + ASSERT( FLY_AT_PARA == rAnchor.GetAnchorId(), "Nur Auto-Rahmen brauchen eine Spezialbehandlung" ); const SwPosition *pFlyPos = rAnchor.GetCntntAnchor(); ULONG nFlyParaIdx = pFlyPos->nNode.GetIndex(); @@ -2862,7 +2862,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, pAttrPam->GetPoint()->nContent.Assign( pAttrPam->GetCntntNode(), aMoveFlyCnts[n] ); SwFmtAnchor aAnchor( rAnchor ); - aAnchor.SetType( FLY_AUTO_CNTNT ); + aAnchor.SetType( FLY_AT_CHAR ); aAnchor.SetAnchor( pAttrPam->GetPoint() ); pFrmFmt->SetFmtAttr( aAnchor ); @@ -4411,27 +4411,23 @@ BOOL SwHTMLParser::HasCurrentParaFlys( BOOL bNoSurroundOnly, // sonst: Der Absatz enthaelt irgendeinen Rahmen SwNodeIndex& rNodeIdx = pPam->GetPoint()->nNode; - SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); - USHORT i; BOOL bFound = FALSE; - for( i=0; i<rFrmFmtTbl.Count(); i++ ) + for ( USHORT i=0; i<rFrmFmtTbl.Count(); i++ ) { - pFmt = rFrmFmtTbl[i]; - pAnchor = &pFmt->GetAnchor(); + SwFrmFmt *const pFmt = rFrmFmtTbl[i]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); // Ein Rahmen wurde gefunden, wenn // - er absatzgebunden ist, und // - im aktuellen Absatz verankert ist, und // - jeder absatzgebunene Rahmen zaehlt, oder // - (nur Rahmen oder umlauf zaehlen und ) der Rahmen keinen // Umlauf besitzt - - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - (FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId()) && + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && pAPos->nNode == rNodeIdx ) { if( !(bNoSurroundOnly || bSurroundOnly) ) @@ -5073,18 +5069,16 @@ void SwHTMLParser::InsertLineBreak() SwTxtNode* pTxtNd = rNodeIdx.GetNode().GetTxtNode(); if( pTxtNd ) { - SwFrmFmt* pFmt; - const SwFmtAnchor* pAnchor; - const SwPosition* pAPos; const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); for( USHORT i=0; i<rFrmFmtTbl.Count(); i++ ) { - pFmt = rFrmFmtTbl[i]; - pAnchor = &pFmt->GetAnchor(); - if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && - (FLY_AT_CNTNT == pAnchor->GetAnchorId() || - FLY_AUTO_CNTNT == pAnchor->GetAnchorId()) && + SwFrmFmt *const pFmt = rFrmFmtTbl[i]; + SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); + SwPosition const*const pAPos = pAnchor->GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == pAnchor->GetAnchorId()) || + (FLY_AT_CHAR == pAnchor->GetAnchorId())) && pAPos->nNode == rNodeIdx && pFmt->GetSurround().GetSurround() != SURROUND_NONE ) { diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx index 463a4305c4..fbc2662c84 100644 --- a/sw/source/filter/inc/fltshell.hxx +++ b/sw/source/filter/inc/fltshell.hxx @@ -36,9 +36,7 @@ #include <com/sun/star/text/VertOrientation.hpp> #include <com/sun/star/text/RelOrientation.hpp> #include <hintids.hxx> -#ifndef _KEYCOD_HXX //autogen #include <vcl/keycod.hxx> -#endif #include <tools/datetime.hxx> #include <svx/brkitem.hxx> #include <poolfmt.hxx> @@ -150,12 +148,12 @@ class SW_DLLPUBLIC SwFltAnchor : public SfxPoolItem { SwFrmFmt* pFrmFmt; SwFltAnchorClient * pClient; - + public: SwFltAnchor(SwFrmFmt* pFlyFmt); SwFltAnchor(const SwFltAnchor&); virtual ~SwFltAnchor(); - + // "pure virtual Methoden" vom SfxPoolItem virtual int operator==(const SfxPoolItem&) const; virtual SfxPoolItem* Clone(SfxItemPool* = 0) const; @@ -167,10 +165,10 @@ public: class SwFltAnchorClient : public SwClient { SwFltAnchor * m_pFltAnchor; - + public: SwFltAnchorClient(SwFltAnchor * pFltAnchor); - + virtual void Modify (SfxPoolItem *pOld, SfxPoolItem *pNew); }; @@ -556,7 +554,7 @@ public: pOut->EndTable(); } // methoden zur verwaltung von Flys BOOL IsInFly() { return pOut->IsInFly(); } - BOOL BeginFly( RndStdIds eAnchor = FLY_AT_CNTNT, BOOL bAbsolutePos = FALSE ); + BOOL BeginFly( RndStdIds eAnchor = FLY_AT_PARA, BOOL bAbsolutePos = FALSE ); void SetFlyAnchor( RndStdIds eAnchor ) { pOut->SetFlyAnchor( eAnchor ); } void SetFlyXPos( short nXPos, sal_Int16 eHRel = com::sun::star::text::RelOrientation::FRAME, diff --git a/sw/source/filter/rtf/rtfatr.cxx b/sw/source/filter/rtf/rtfatr.cxx index 89a74504cd..46426620b3 100644 --- a/sw/source/filter/rtf/rtfatr.cxx +++ b/sw/source/filter/rtf/rtfatr.cxx @@ -38,9 +38,7 @@ */ #include <hintids.hxx> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif #include <vcl/cvtgrf.hxx> #include <svl/urihelper.hxx> #include <svl/stritem.hxx> @@ -50,9 +48,7 @@ #include <svl/itemiter.hxx> #include <svx/fontitem.hxx> #include <svx/hyznitem.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/lspcitem.hxx> #include <svx/langitem.hxx> #include <svx/keepitem.hxx> @@ -72,16 +68,12 @@ #include <svx/lrspitem.hxx> #include <svx/boxitem.hxx> #include <svx/crsditem.hxx> -#ifndef _SVX_CNTRITEM_HXX //autogen #include <svx/cntritem.hxx> -#endif #include <svx/postitem.hxx> #include <svx/shdditem.hxx> #include <svx/wghtitem.hxx> #include <svx/wrlmitem.hxx> -#ifndef _SVX_EMPHITEM_HXX #include <svx/emphitem.hxx> -#endif #include <svx/twolinesitem.hxx> #include <svx/charscaleitem.hxx> #include <svx/charrotateitem.hxx> @@ -127,9 +119,7 @@ #include <flddat.hxx> #include <pagedesc.hxx> // fuer SwPageDesc ... #include <swtable.hxx> // fuer SwPageDesc ... -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <swrect.hxx> #include <section.hxx> #include <wrtswtbl.hxx> @@ -3592,7 +3582,7 @@ static Writer& OutRTF_SwFmtVertOrient ( Writer& rWrt, const SfxPoolItem& rHt ) const char* pOrient; RndStdIds eAnchor = rRTFWrt.pFlyFmt->GetAnchor().GetAnchorId(); sal_Int16 eOrient = rFlyVert.GetRelationOrient(); - if( FLY_PAGE == eAnchor ) + if (FLY_AT_PAGE == eAnchor) { if( text::RelOrientation::PAGE_FRAME == eOrient || text::RelOrientation::FRAME == eOrient ) pOrient = OOO_STRING_SVTOOLS_RTF_PVPG; @@ -3648,7 +3638,7 @@ static Writer& OutRTF_SwFmtHoriOrient( Writer& rWrt, const SfxPoolItem& rHt ) const char* pS; RndStdIds eAnchor = rRTFWrt.pFlyFmt->GetAnchor().GetAnchorId(); sal_Int16 eOrient = rFlyHori.GetRelationOrient(); - if( FLY_PAGE == eAnchor ) + if (FLY_AT_PAGE == eAnchor) { if( text::RelOrientation::PAGE_FRAME == eOrient || text::RelOrientation::FRAME == eOrient ) pS = OOO_STRING_SVTOOLS_RTF_PHPG; @@ -3702,12 +3692,12 @@ static Writer& OutRTF_SwFmtAnchor( Writer& rWrt, const SfxPoolItem& rHt ) rRTFWrt.bOutFmtAttr = TRUE; switch( nId ) { - case FLY_PAGE: + case FLY_AT_PAGE: rWrt.Strm() << OOO_STRING_SVTOOLS_RTF_FLYPAGE; rWrt.OutULong( rAnchor.GetPageNum() ); break; - case FLY_AT_CNTNT: - case FLY_IN_CNTNT: + case FLY_AT_PARA: + case FLY_AS_CHAR: rWrt.Strm() << OOO_STRING_SVTOOLS_RTF_FLYCNTNT; break; } diff --git a/sw/source/filter/rtf/rtffly.cxx b/sw/source/filter/rtf/rtffly.cxx index c761fe1cd9..0e3dffa2dc 100644 --- a/sw/source/filter/rtf/rtffly.cxx +++ b/sw/source/filter/rtf/rtffly.cxx @@ -64,15 +64,9 @@ #include <txtflcnt.hxx> #include <fmtflcnt.hxx> #include <fltini.hxx> -#ifndef __SGI_STL_DEQUE #include <deque> -#endif -#ifndef __SGI_STL_MAP #include <map> -#endif -#ifndef __SGI_STL_UTILITY #include <utility> -#endif // --> OD 2004-06-30 #i27767# #include <fmtwrapinfluenceonobjpos.hxx> // <-- @@ -82,6 +76,7 @@ #include "dcontact.hxx" // <-- + using namespace ::com::sun::star; #define ANCHOR(p) ((SwFmtAnchor*)p) @@ -459,7 +454,7 @@ void SwRTFParser::SetFlysInDoc() SwFlyFrmFmt* pFmt = pDoc->MakeFlyFrmFmt( aEmptyStr, pParent ); pFmt->SetFmtAttr( pFlySave->aFlySet ); const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); - if( FLY_IN_CNTNT != rAnchor.GetAnchorId() ) + if (FLY_AS_CHAR != rAnchor.GetAnchorId()) { // korrigiere noch den Absatz, ist immer der vorhergehende ! // JP 20.09.95: wenn es diesen gibt! (DocAnfang!) @@ -568,7 +563,7 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) // RTF-Defaults setzen: // --> OD 2004-06-24 #i27767# - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); SwFmtHoriOrient aHori( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME ); SwFmtVertOrient aVert( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ); @@ -844,7 +839,7 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) switch( GetNextToken() ) { case RTF_FLY_PAGE: - aAnchor.SetType( FLY_PAGE ); + aAnchor.SetType( FLY_AT_PAGE ); aAnchor.SetPageNum( USHORT(nTokenValue)); aAnchor.SetAnchor( 0 ); break; @@ -854,7 +849,7 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) SwNodeIndex aIdx( pPam->GetPoint()->nNode ); pDoc->GetNodes().GoPrevious( &aIdx ); SwPosition aPos( aIdx ); - aAnchor.SetType( FLY_AT_CNTNT ); + aAnchor.SetType( FLY_AT_PARA ); aAnchor.SetAnchor( &aPos ); } break; @@ -1288,7 +1283,7 @@ void SwRTFParser::InsPicture( const String& rGrfNm, const Graphic* pGrf, RES_VERT_ORIENT,*/ RES_ANCHOR ); const SwPosition* pPos = pPam->GetPoint(); - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); aAnchor.SetAnchor( pPos ); aFlySet.Put( aAnchor ); aFlySet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP )); diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index b07a93f0bb..1050ac0986 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -35,18 +35,14 @@ #include <stack> -#ifndef __RSC //autogen #include <tools/errinf.hxx> -#endif #include <tools/stream.hxx> #include <svl/itemiter.hxx> #include <svtools/rtftoken.h> #include <svl/intitem.hxx> #include <svx/fhgtitem.hxx> #include <svx/ulspitem.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/lspcitem.hxx> #include <svx/lrspitem.hxx> #include <svx/escpitem.hxx> @@ -82,18 +78,14 @@ #include <fltini.hxx> #include <fchrfmt.hxx> #include <paratr.hxx> -#ifndef _SECTIOM_HXX #include <section.hxx> -#endif #include <fmtclbl.hxx> #include <viewsh.hxx> #include <shellres.hxx> #include <hfspacingitem.hxx> #include <tox.hxx> #include <swerror.h> -#ifndef _CMDID_H #include <cmdid.h> -#endif #ifndef _STATSTR_HRC #include <statstr.hrc> // ResId fuer Statusleiste #endif @@ -471,8 +463,8 @@ if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( FALSE ).nNode.GetIndex() ) for ( USHORT nI = pFrmFmts->Count(); nI; --nI ) { const SwFmtAnchor & rAnchor = (*pFrmFmts)[ nI - 1 ]->GetAnchor(); - if ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) + if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) { const SwPosition * pObjPos = rAnchor.GetCntntAnchor(); if ( pObjPos && nNodeIdx == pObjPos->nNode.GetIndex() ) @@ -1270,14 +1262,7 @@ void SwRTFParser::ReadDrawingObject() sw::util::SetLayer aSetLayer(*pDoc); aSetLayer.SendObjectToHeaven(*pStroke); */ - /* - FLY_AT_CNTNT, //Absatzgebundener Rahmen <to paragraph> - FLY_IN_CNTNT, //Zeichengebundener Rahmen <as character> - FLY_PAGE, //Seitengebundener Rahmen <to page> - FLY_AT_FLY, //Rahmengebundener Rahmen ( LAYER_IMPL ) <to frame> - FLY_AUTO_CNTNT, //Automatisch positionierter, absatzgebundener Rahmen <to character> - */ - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); aAnchor.SetAnchor( pPam->GetPoint() ); aFlySet.Put( aAnchor ); @@ -1343,7 +1328,7 @@ void SwRTFParser::InsertShpObject(SdrObject* pStroke, int _nZOrder) SwFmtFollowTextFlow aFollowTextFlow( FALSE ); aFlySet.Put( aFollowTextFlow ); - SwFmtAnchor aAnchor( FLY_AT_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_PARA ); aAnchor.SetAnchor( pPam->GetPoint() ); aFlySet.Put( aAnchor ); @@ -3710,8 +3695,9 @@ void SwRTFParser::ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc ) xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex(); SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 ); - aSet.Put( SwFmtAnchor( FLY_IN_CNTNT )); - pHdFtFmt = pDoc->MakeFlySection( FLY_IN_CNTNT, pPam->GetPoint(), &aSet ); + aSet.Put( SwFmtAnchor( FLY_AS_CHAR )); + pHdFtFmt = pDoc->MakeFlySection( FLY_AS_CHAR, + pPam->GetPoint(), &aSet ); pTxtAttr = pPam->GetNode()->GetTxtNode()->GetTxtAttrForCharAt( nPos, RES_TXTATR_FLYCNT ); diff --git a/sw/source/filter/rtf/wrtrtf.cxx b/sw/source/filter/rtf/wrtrtf.cxx index 65828f6d53..100c2ab209 100644 --- a/sw/source/filter/rtf/wrtrtf.cxx +++ b/sw/source/filter/rtf/wrtrtf.cxx @@ -46,9 +46,7 @@ #include <svx/brshitem.hxx> #include <svx/colritem.hxx> #include <svx/boxitem.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/ulspitem.hxx> #include <svx/lrspitem.hxx> #include <svx/frmdiritem.hxx> @@ -85,6 +83,7 @@ #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> + #if defined(UNX) const sal_Char SwRTFWriter::sNewLine = '\012'; #else @@ -1129,7 +1128,7 @@ bool ExportAsInline(const SwFlyFrmFmt& rFlyFrmFmt) { //if not an inline element (hack in our limitations here as to only //graphics like this!!!! - return rFlyFrmFmt.GetAnchor().GetAnchorId() == FLY_IN_CNTNT; + return rFlyFrmFmt.GetAnchor().GetAnchorId() == FLY_AS_CHAR; } void SwRTFWriter::OutRTFFlyFrms(const SwFlyFrmFmt& rFlyFrmFmt) @@ -1779,7 +1778,7 @@ short SwRTFWriter::TrueFrameDirection(const SwFrmFmt &rFlyFmt) const { pItem = 0; const SwFmtAnchor* pAnchor = &pFlyFmt2->GetAnchor(); - if( FLY_PAGE != pAnchor->GetAnchorId() && + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor() ) { pFlyFmt2 = pAnchor->GetCntntAnchor()->nNode. diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx index 0e66638169..6e7097f97e 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/ww1/fltshell.cxx @@ -35,9 +35,7 @@ #include <hintids.hxx> #include <hints.hxx> -#ifndef _GRAPH_HXX //autogen #include <vcl/graph.hxx> -#endif #include <svl/urihelper.hxx> #include <svx/impgrf.hxx> #include <svx/boxitem.hxx> @@ -72,13 +70,12 @@ #include <section.hxx> // class SwSection #include <tblsel.hxx> // class SwSelBoxes #include <pagedesc.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> // class SwDocSh -#endif #include <fltshell.hxx> #include <viewsh.hxx> #include <shellres.hxx> + #define MAX_FIELDLEN 64000 using namespace com::sun::star; @@ -437,7 +434,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* // Damit die Frames bei Einfuegen in existierendes Doc // erzeugt werden (erst nach Setzen des Ankers!): if(pDoc->GetRootFrm() - && FLY_AT_CNTNT == pFmt->GetAnchor().GetAnchorId()) + && (FLY_AT_PARA == pFmt->GetAnchor().GetAnchorId())) { pFmt->MakeFrms(); } @@ -1285,7 +1282,7 @@ SwFltOutBase::~SwFltOutBase() } SwFltOutBase::SwFltOutBase(SwDoc& rDocu) - : rDoc(rDocu), eFlyAnchor(FLY_AT_CNTNT), bFlyAbsPos(false) + : rDoc(rDocu), eFlyAnchor(FLY_AT_PARA), bFlyAbsPos(false) { } @@ -1702,8 +1699,8 @@ BOOL SwFltOutBase::BeginFly( RndStdIds eAnchor /*= FLY_AT_CNTNT*/, ASSERT( FALSE, "SetFlyAnchor() ohne Fly" ); return; } - if( eAnchor == FLY_IN_CNTNT ){ - ASSERT( FALSE, "SetFlyAnchor( FLY_IN_CNTNT ) nicht implementiert" ); + if ( eAnchor == FLY_AS_CHAR ){ + ASSERT( FALSE, "SetFlyAnchor( FLY_AS_CHAR ) nicht implementiert" ); return; } SwFmtAnchor& rAnchor = (SwFmtAnchor&)GetFlyFrmAttr( RES_ANCHOR ); diff --git a/sw/source/filter/ww1/w1sprm.cxx b/sw/source/filter/ww1/w1sprm.cxx index a90dd0fe2f..83a8fd68ba 100644 --- a/sw/source/filter/ww1/w1sprm.cxx +++ b/sw/source/filter/ww1/w1sprm.cxx @@ -31,9 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - - - #include <hintids.hxx> #include <tools/solar.h> @@ -46,10 +43,7 @@ #include <svx/shaditem.hxx> #include <svx/ulspitem.hxx> #include <svx/lspcitem.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif - #include <fmtclds.hxx> #include <fmtfsize.hxx> @@ -595,13 +589,13 @@ void Ww1SingleSprmPpc::Start( sal_Int16 eVRel; // Seite oder Seitenrand switch ( ( nPpc & 0x30 ) >> 4 ){ // Y - Bindung bestimmt Sw-Bindung - case 0: eAnchor = FLY_AT_CNTNT; // Vert Margin + case 0: eAnchor = FLY_AT_PARA; // Vert Margin eVRel = text::RelOrientation::PRINT_AREA; // if( nYPos < 0 ) // nYPos = 0; // koennen wir nicht break; /* case 1:*/ // Vert. Seite - default:eAnchor = FLY_PAGE; // Vert Page oder unknown + default:eAnchor = FLY_AT_PAGE; // Vert Page oder unknown eVRel = text::RelOrientation::FRAME; break; // 2=Vert. Paragraph, 3=Use Default } diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index 8b6a98eca8..6ead178825 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -190,7 +190,7 @@ namespace sw meWriterType(eTxtBox), mpStartFrameContent(0), // --> OD 2007-04-19 #i43447# - move to initialization list - mbIsInline( (rFmt.GetAnchor().GetAnchorId() == FLY_IN_CNTNT) ) + mbIsInline( (rFmt.GetAnchor().GetAnchorId() == FLY_AS_CHAR) ) // <-- { switch (rFmt.Which()) diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index b05a763210..27c0903e76 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -588,7 +588,7 @@ void PlcDrawObj::WritePlc( WW8Export& rWrt ) const //fHdr/bx/by/wr/wrk/fRcaSimple/fBelowText/fAnchorLock USHORT nFlags=0; //If nFlags isn't 0x14 its overridden by the escher properties - if( FLY_PAGE == rFmt.GetAnchor().GetAnchorId()) + if (FLY_AT_PAGE == rFmt.GetAnchor().GetAnchorId()) nFlags = 0x0000; else nFlags = 0x0014; // x-rel to text, y-rel to text @@ -2118,7 +2118,7 @@ bool WinwordAnchoring::ConvertPosition( SwFmtHoriOrient& _iorHoriOri, { const RndStdIds eAnchor = _rFrmFmt.GetAnchor().GetAnchorId(); - if ( FLY_IN_CNTNT == eAnchor || FLY_AT_FLY == eAnchor ) + if ( (FLY_AS_CHAR == eAnchor) || (FLY_AT_FLY == eAnchor) ) { // no conversion for as-character or at frame anchored objects return false; @@ -2167,7 +2167,7 @@ bool WinwordAnchoring::ConvertPosition( SwFmtHoriOrient& _iorHoriOri, // the fact, that the object is anchored at a paragraph, which has a "column // break before" attribute bool bConvDueToAnchoredAtColBreakPara( false ); - if ( ( eAnchor == FLY_AT_CNTNT || eAnchor == FLY_AUTO_CNTNT ) && + if ( ( (eAnchor == FLY_AT_PARA) || (eAnchor == FLY_AT_CHAR) ) && _rFrmFmt.GetAnchor().GetCntntAnchor() && _rFrmFmt.GetAnchor().GetCntntAnchor()->nNode.GetNode().IsTxtNode() ) { @@ -2404,7 +2404,7 @@ bool WinwordAnchoring::ConvertPosition( SwFmtHoriOrient& _iorHoriOri, void WinwordAnchoring::SetAnchoring(const SwFrmFmt& rFmt) { const RndStdIds eAnchor = rFmt.GetAnchor().GetAnchorId(); - mbInline = (eAnchor == FLY_IN_CNTNT); + mbInline = (eAnchor == FLY_AS_CHAR); SwFmtHoriOrient rHoriOri = rFmt.GetHoriOrient(); SwFmtVertOrient rVertOri = rFmt.GetVertOrient(); @@ -2488,13 +2488,13 @@ void WinwordAnchoring::SetAnchoring(const SwFrmFmt& rFmt) case text::RelOrientation::FRAME: case text::RelOrientation::FRAME_LEFT: //:-( case text::RelOrientation::FRAME_RIGHT: //:-( - if (eAnchor == FLY_PAGE) + if (eAnchor == FLY_AT_PAGE) mnXRelTo = 1; else mnXRelTo = 2; break; case text::RelOrientation::PRINT_AREA: - if (eAnchor == FLY_PAGE) + if (eAnchor == FLY_AT_PAGE) mnXRelTo = 0; else mnXRelTo = 2; @@ -2516,13 +2516,13 @@ void WinwordAnchoring::SetAnchoring(const SwFrmFmt& rFmt) mnYRelTo = 1; break; case text::RelOrientation::PRINT_AREA: - if (eAnchor == FLY_PAGE) + if (eAnchor == FLY_AT_PAGE) mnYRelTo = 0; else mnYRelTo = 2; break; case text::RelOrientation::FRAME: - if (eAnchor == FLY_PAGE) + if (eAnchor == FLY_AT_PAGE) mnYRelTo = 1; else mnYRelTo = 2; diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index a9b5351f79..05153480bd 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -376,7 +376,7 @@ xub_StrLen SwAttrIter::SearchNext( xub_StrLen nStartPos ) if (nPos >= nStartPos && nPos <= nMinPos) nMinPos = nPos; - if (maFlyIter->GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AUTO_CNTNT) + if (maFlyIter->GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AT_CHAR) { ++nPos; if (nPos >= nStartPos && nPos <= nMinPos) @@ -1301,7 +1301,7 @@ short MSWordExportBase::TrueFrameDirection( const SwFrmFmt &rFlyFmt ) const { pItem = 0; const SwFmtAnchor* pAnchor = &pFlyFmt->GetAnchor(); - if ( FLY_PAGE != pAnchor->GetAnchorId() && + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor() ) { pFlyFmt = pAnchor->GetCntntAnchor()->nNode.GetNode().GetFlyFmt(); @@ -1359,7 +1359,7 @@ SvxBrushItem WW8Export::TrueFrameBgBrush(const SwFrmFmt &rFlyFmt) const { pRet = 0; const SwFmtAnchor* pAnchor = &pFlyFmt->GetAnchor(); - if (FLY_PAGE != pAnchor->GetAnchorId() && + if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor()) { pFlyFmt = @@ -2497,12 +2497,13 @@ void WW8AttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFmt, const Point aOffset -= aPageRect.Pos(); m_rWW8Export.pFlyOffset = &aOffset; - m_rWW8Export.eNewAnchorType = FLY_PAGE; + m_rWW8Export.eNewAnchorType = FLY_AT_PAGE; } m_rWW8Export.mpParentFrame = &rFmt; if ( - m_rWW8Export.bIsInTable && (FLY_PAGE != rAnch.GetAnchorId()) && + m_rWW8Export.bIsInTable && + (FLY_AT_PAGE != rAnch.GetAnchorId()) && !m_rWW8Export.pDoc->GetNodes()[ nStt ]->IsNoTxtNode() ) { @@ -2534,7 +2535,7 @@ void AttributeOutputBase::OutputFlyFrame( const sw::Frame& rFmt ) Point* pLayPos; bool bValidNdPos = false, bValidPgPos = false; - if ( FLY_PAGE == rFmt.GetFrmFmt().GetAnchor().GetAnchorId() ) + if (FLY_AT_PAGE == rFmt.GetFrmFmt().GetAnchor().GetAnchorId()) { // get the Layout Node-Position. if ( !bValidPgPos ) diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index b6e7c4d76d..ccf8c0e741 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2897,7 +2897,7 @@ void MSWordExportBase::ExportDocument( bool bWriteAll ) mpParentFrame = 0; pFlyOffset = 0; - eNewAnchorType = FLY_PAGE; + eNewAnchorType = FLY_AT_PAGE; nTxtTyp = TXT_MAINTEXT; // --> OD 2007-04-19 #i43447# - removed // nFlyWidth = nFlyHeight = 0; diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx index 3e6b3de46c..f1f5781555 100644 --- a/sw/source/filter/ww8/wrtww8gr.cxx +++ b/sw/source/filter/ww8/wrtww8gr.cxx @@ -404,7 +404,7 @@ void WW8Export::OutGrf(const sw::Frame &rFrame) const SwFrmFmt &rFlyFmt = rFrame.GetFrmFmt(); const RndStdIds eAn = rFlyFmt.GetAttrSet().GetAnchor(false).GetAnchorId(); - if( eAn == FLY_IN_CNTNT ) + if (eAn == FLY_AS_CHAR) { sal_Int16 eVert = rFlyFmt.GetVertOrient().GetVertOrient(); if ((eVert == text::VertOrientation::CHAR_CENTER) || (eVert == text::VertOrientation::LINE_CENTER)) @@ -465,8 +465,8 @@ void WW8Export::OutGrf(const sw::Frame &rFrame) // Otherwise, an additional paragraph is exported for a graphic, which is // forced to be treated as inline, because it's anchored inside another frame. if ( !rFrame.IsInline() && - ( ( eAn == FLY_AT_CNTNT && ( bWrtWW8 || !bIsInTable ) ) || - eAn == FLY_PAGE ) ) + ( ((eAn == FLY_AT_PARA) && ( bWrtWW8 || !bIsInTable )) || + (eAn == FLY_AT_PAGE)) ) // <-- { WriteChar( (char)0x0d ); // umgebenden Rahmen mit CR abschliessen diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 7d95e8eda4..b0a40f6b54 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -128,9 +128,7 @@ #include <writerfilter/doctok/sprmids.hxx> -#if OSL_DEBUG_LEVEL > 1 -# include <fmtcntnt.hxx> -#endif +#include <fmtcntnt.hxx> #include "writerhelper.hxx" #include "writerwordglue.hxx" #include "wrtww8.hxx" @@ -4087,15 +4085,15 @@ void WW8AttributeOutput::FormatAnchor( const SwFmtAnchor& rAnchor ) BYTE nP = 0; switch ( rAnchor.GetAnchorId() ) { - case FLY_PAGE: + case FLY_AT_PAGE: // Vert: Page | Horz: Page nP |= (1 << 4) | (2 << 6); break; // Im Fall eine Flys als Zeichen: Absatz-gebunden setzen!!! case FLY_AT_FLY: - case FLY_AUTO_CNTNT: - case FLY_AT_CNTNT: - case FLY_IN_CNTNT: + case FLY_AT_CHAR: + case FLY_AT_PARA: + case FLY_AS_CHAR: // Vert: Page | Horz: Page nP |= (2 << 4) | (0 << 6); break; diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx index b41d6cf90e..429e62ce83 100644 --- a/sw/source/filter/ww8/ww8glsy.cxx +++ b/sw/source/filter/ww8/ww8glsy.cxx @@ -36,14 +36,10 @@ #include <svl/urihelper.hxx> #include <rtl/tencinfo.h> #include <swerror.h> -#ifndef _NDTXT #include <ndtxt.hxx> -#endif #include <pam.hxx> #include <shellio.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <fmtanchr.hxx> #include <frmfmt.hxx> #include <doc.hxx> @@ -51,6 +47,7 @@ #include "ww8glsy.hxx" #include "ww8par.hxx" + WW8Glossary::WW8Glossary(SvStorageStreamRef &refStrm, BYTE nVersion, SvStorage *pStg) : pGlossary(0), rStrm(refStrm), xStg(pStg), nStrings(0) @@ -82,10 +79,10 @@ bool WW8Glossary::HasBareGraphicEnd(SwDoc *pDoc,SwNodeIndex &rIdx) RES_DRAWFRMFMT != pFrmFmt->Which() ) continue; const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); - const SwPosition* pAPos; - if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() || - FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) && - 0 != ( pAPos = rAnchor.GetCntntAnchor()) && + SwPosition const*const pAPos = rAnchor.GetCntntAnchor(); + if (pAPos && + ((FLY_AT_PARA == rAnchor.GetAnchorId()) || + (FLY_AT_CHAR == rAnchor.GetAnchorId())) && rIdx == pAPos->nNode.GetIndex() ) { bRet=true; diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index e1c5b25092..f8f6303e81 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -58,9 +58,7 @@ #include <svx/adjitem.hxx> #include <svx/wghtitem.hxx> #include <svx/crsditem.hxx> -#ifndef _SVX_CNTRITEM_HXX #include <svx/cntritem.hxx> -#endif #include <svx/shdditem.hxx> #include <svx/fontitem.hxx> #include <svx/ulspitem.hxx> @@ -191,13 +189,13 @@ bool SwWW8ImplReader::ReadGrafStart(void* pData, short nDataSiz, } pStrm->Read(pData, nDataSiz); - RndStdIds eAnchor = (SVBT8ToByte(pDo->by) < 2) ? FLY_PAGE : FLY_AT_CNTNT; + RndStdIds eAnchor = (SVBT8ToByte(pDo->by) < 2) ? FLY_AT_PAGE : FLY_AT_PARA; rSet.Put(SwFmtAnchor(eAnchor)); nDrawXOfs2 = nDrawXOfs; nDrawYOfs2 = nDrawYOfs; - if( eAnchor == FLY_AT_CNTNT ) + if (eAnchor == FLY_AT_PARA) { if( SVBT8ToByte( pDo->bx ) == 1 ) // Pos: echt links nDrawXOfs2 = static_cast< short >(nDrawXOfs2 - maSectionManager.GetPageLeft()); @@ -2248,7 +2246,7 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec* pRecord, { ASSERT(pRecord || pFSPA, "give me something! to work with for anchoring"); if (!pRecord && !pFSPA) - return FLY_PAGE; + return FLY_AT_PAGE; SvxMSDffImportRec aRecordFromFSPA; if (!pRecord) @@ -2299,7 +2297,7 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec* pRecord, UINT32 nYRelTo = nCntRelTo > pRecord->nYRelTo ? pRecord->nYRelTo : 1; // --> OD 2005-03-03 #i43718# - RndStdIds eAnchor = IsInlineEscherHack() ? FLY_IN_CNTNT : FLY_AUTO_CNTNT; + RndStdIds eAnchor = IsInlineEscherHack() ? FLY_AS_CHAR : FLY_AT_CHAR; // <-- SwFmtAnchor aAnchor( eAnchor ); @@ -2463,7 +2461,7 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec* pRecord, if ( (pFSPA->nYaTop < 0) && (eVertOri == text::VertOrientation::NONE) && - ((eAnchor == FLY_AT_CNTNT) || (eAnchor == FLY_AUTO_CNTNT)) + ((eAnchor == FLY_AT_PARA) || (eAnchor == FLY_AT_CHAR)) ) { maTracer.Log(sw::log::eNegativeVertPlacement); @@ -2846,7 +2844,7 @@ SwFrmFmt* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp ) SwFrmFmt *SwWW8ImplReader::AddAutoAnchor(SwFrmFmt *pFmt) { - if (pFmt && (pFmt->GetAnchor().GetAnchorId() != FLY_IN_CNTNT)) + if (pFmt && (pFmt->GetAnchor().GetAnchorId() != FLY_AS_CHAR)) { sal_uInt16 nTextAreaWidth = static_cast< sal_uInt16 >( maSectionManager.GetPageWidth() - maSectionManager.GetPageRight() - maSectionManager.GetPageLeft()); @@ -2861,8 +2859,10 @@ SwFrmFmt *SwWW8ImplReader::AddAutoAnchor(SwFrmFmt *pFmt) * * Leave to later and set the correct location then. */ - if ((pFmt) && (pFmt->GetAnchor().GetAnchorId() != FLY_IN_CNTNT)) + if ((pFmt) && (pFmt->GetAnchor().GetAnchorId() != FLY_AS_CHAR)) + { pAnchorStck->AddAnchor(*pPaM->GetPoint(), pFmt); + } return pFmt; } @@ -3235,7 +3235,7 @@ void SwWW8ImplReader::GrafikDtor() void SwWW8FltAnchorStack::AddAnchor(const SwPosition& rPos, SwFrmFmt *pFmt) { - ASSERT(pFmt->GetAnchor().GetAnchorId() != FLY_IN_CNTNT, + ASSERT(pFmt->GetAnchor().GetAnchorId() != FLY_AS_CHAR, "Don't use fltanchors with inline frames, slap!"); NewAttr(rPos, SwFltAnchor(pFmt)); } diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx index 004d04d9d4..d6db64e57d 100644 --- a/sw/source/filter/ww8/ww8graf2.cxx +++ b/sw/source/filter/ww8/ww8graf2.cxx @@ -33,9 +33,7 @@ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ -#ifndef __SGI_STL_ITERATOR #include <iterator> -#endif #include <hintids.hxx> #include <svl/urihelper.hxx> #include <svx/impgrf.hxx> @@ -415,7 +413,7 @@ SwFlyFrmFmt* SwWW8ImplReader::MakeGrafNotInCntnt(const WW8PicDesc& rPD, // Damit die Frames bei Einfuegen in existierendes Doc erzeugt werden: if (rDoc.GetRootFrm() && - (FLY_AT_CNTNT == pFlyFmt->GetAnchor().GetAnchorId())) + (FLY_AT_PARA == pFlyFmt->GetAnchor().GetAnchorId())) { pFlyFmt->MakeFrms(); } @@ -548,9 +546,11 @@ SwFrmFmt* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj, // it is anchored in content; because this anchor add // a character into the textnode. // IussueZilla task 2806 - if( FLY_IN_CNTNT == + if (FLY_AS_CHAR == pFlyFmtOfJustInsertedGraphic->GetAnchor().GetAnchorId() ) + { aFlySet.ClearItem( RES_ANCHOR ); + } pFlyFmtOfJustInsertedGraphic->SetFmtAttr( aFlySet ); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 809f0dd94d..2120fee8fa 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1649,7 +1649,7 @@ void SwWW8ImplReader::Read_HdFtTextAsHackedFrame(long nStart, long nLen, pPaM->GetPoint()->nNode = pSttIdx->GetIndex() + 1; pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0); - SwFlyFrmFmt *pFrame = rDoc.MakeFlySection(FLY_AT_CNTNT, pPaM->GetPoint()); + SwFlyFrmFmt *pFrame = rDoc.MakeFlySection(FLY_AT_PARA, pPaM->GetPoint()); pFrame->SetFmtAttr(SwFmtFrmSize(ATT_MIN_SIZE, nPageWidth, MINLAY)); pFrame->SetFmtAttr(SwFmtSurround(SURROUND_THROUGHT)); diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 04e75b06a1..24e69665c0 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -3482,7 +3482,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) // --> OD 2005-03-21 #i45301# - anchor nested table inside Writer fly frame // only at-character, if absolute position object attributes are available. // Thus, default anchor type is as-character anchored. - RndStdIds eAnchor( FLY_IN_CNTNT ); + RndStdIds eAnchor( FLY_AS_CHAR ); // <-- if ( nInTable ) { @@ -3514,7 +3514,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) // <-- // --> OD 2005-03-21 #i45301# - anchor nested table Writer fly // frame at-character - eAnchor = FLY_AUTO_CNTNT; + eAnchor = FLY_AT_CHAR; // <-- } } @@ -3532,7 +3532,8 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) "how could we be in a local apo and have no apo"); } - if ( eAnchor == FLY_AUTO_CNTNT && !maTableStack.empty() && !InEqualApo(nNewInTable) ) + if ((eAnchor == FLY_AT_CHAR) + && !maTableStack.empty() && !InEqualApo(nNewInTable) ) { pTableDesc->pParentPos = new SwPosition(*pPaM->GetPoint()); SfxItemSet aItemSet(rDoc.GetAttrPool(), @@ -3560,7 +3561,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) if ( pTableWFlyPara && pTableSFlyPara ) { WW8FlySet aFlySet( *this, pTableWFlyPara, pTableSFlyPara, false ); - SwFmtAnchor aAnchor( FLY_AUTO_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_CHAR ); aAnchor.SetAnchor( pTableDesc->pParentPos ); aFlySet.Put( aAnchor ); pTableDesc->pFlyFmt->SetFmtAttr( aFlySet ); @@ -3615,8 +3616,8 @@ bool lcl_PamContainsFly(SwPaM & rPam) switch (pAnchor->GetAnchorId()) { - case FLY_AT_CNTNT: - case FLY_AUTO_CNTNT: + case FLY_AT_PARA: + case FLY_AT_CHAR: { const SwPosition* pAPos = pAnchor->GetCntntAnchor(); diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index b6b91459fc..5925751f3c 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -77,7 +77,7 @@ #include <svx/postitem.hxx> #include <filter/msfilter/msocximex.hxx> #include <errhdl.hxx> -#include <unoobj.hxx> +#include <unotextrange.hxx> #include <doc.hxx> #include <docary.hxx> #include <docsh.hxx> diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx index eda0dea5fa..75f7554179 100644 --- a/sw/source/filter/ww8/ww8par4.cxx +++ b/sw/source/filter/ww8/ww8par4.cxx @@ -35,12 +35,8 @@ #include "writerhelper.hxx" #include <com/sun/star/embed/XClassifiedObject.hpp> -#ifndef __SGI_STL_ALGORITHM #include <algorithm> -#endif -#ifndef __SGI_STL_FUNCTIONAL #include <functional> -#endif #include <osl/endian.h> #include <sot/storage.hxx> #include <com/sun/star/drawing/XShape.hpp> @@ -59,9 +55,7 @@ #include <frmfmt.hxx> #include <pam.hxx> #include <ndgrf.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> // fuer Ole-Node -#endif #include <mdiexp.hxx> // Progress #include <redline.hxx> #include <fltshell.hxx> @@ -296,7 +290,7 @@ SwFrmFmt* SwWW8ImplReader::ImportOle(const Graphic* pGrf, if (!mbNewDoc) Reader::ResetFrmFmtAttrs( *pTempSet ); - SwFmtAnchor aAnchor( FLY_IN_CNTNT ); + SwFmtAnchor aAnchor( FLY_AS_CHAR ); aAnchor.SetAnchor( pPaM->GetPoint() ); pTempSet->Put( aAnchor ); diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 7e6e294866..4dca5848aa 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -45,17 +45,11 @@ #include <svl/zformat.hxx> #include <sfx2/linkmgr.hxx> -#ifndef _UCBHELPER_CONTENT_HXX_ #include <ucbhelper/content.hxx> -#endif -#ifndef _UCBHELPER_CONTENTBROKER_HXX_ #include <ucbhelper/contentbroker.hxx> -#endif #include <ucbhelper/commandenvironment.hxx> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif #include <hintids.hxx> #include <svx/fontitem.hxx> #include <svx/fhgtitem.hxx> @@ -2216,7 +2210,7 @@ eF_ResT SwWW8ImplReader::Read_F_IncludePicture( WW8FieldDesc*, String& rStr ) */ SfxItemSet aFlySet( rDoc.GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 ); - aFlySet.Put( SwFmtAnchor( FLY_IN_CNTNT ) ); + aFlySet.Put( SwFmtAnchor( FLY_AS_CHAR ) ); aFlySet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME )); pFlyFmtOfJustInsertedGraphic = rDoc.Insert( *pPaM, aGrfName, diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 9739922e4a..90530c310f 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -44,9 +44,7 @@ #include <svx/langitem.hxx> #include <svx/cmapitem.hxx> #include <svx/shdditem.hxx> -#ifndef _SVX_CNTRITEM_HXX //autogen #include <svx/cntritem.hxx> -#endif #include <svx/crsditem.hxx> #include <svx/postitem.hxx> #include <svx/wghtitem.hxx> @@ -65,19 +63,13 @@ #include <svx/boxitem.hxx> #include <svx/ulspitem.hxx> #include <svx/lrspitem.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/akrnitem.hxx> #include <svx/paperinf.hxx> -#ifndef _SVX_EMPHITEM_HXX //autogen #include <svx/emphitem.hxx> -#endif #include <svx/forbiddenruleitem.hxx> #include <svx/twolinesitem.hxx> -#ifndef _SVX_SCRIPSPACEITEM_HXX #include <svx/scriptspaceitem.hxx> -#endif #include <svx/hngpnctitem.hxx> #include <svx/pbinitem.hxx> #include <svx/charscaleitem.hxx> @@ -1995,7 +1987,7 @@ WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM, nYBind = (( rWW.nSp29 & 0x30 ) >> 4); // --> OD 2005-08-24 #i53725# - absolute positioned objects have to be // anchored at-paragraph to assure its correct anchor position. - eAnchor = FLY_AT_CNTNT; + eAnchor = FLY_AT_PARA; // <-- switch (nYBind) { @@ -2287,7 +2279,7 @@ void WW8FlySet::Init(const SwWW8ImplReader& rReader, const SwPaM* pPaM) Reader::ResetFrmFmtAttrs(*this); // Abstand/Umrandung raus Put(SvxLRSpaceItem(RES_LR_SPACE)); //inline writer ole2 objects start with 0.2cm l/r - SwFmtAnchor aAnchor(FLY_IN_CNTNT); + SwFmtAnchor aAnchor(FLY_AS_CHAR); aAnchor.SetAnchor(pPaM->GetPoint()); Put(aAnchor); @@ -2519,8 +2511,10 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, pWWZOrder->InsertTextLayerObject(pOurNewObject); } - if (FLY_IN_CNTNT != pSFlyPara->eAnchor) + if (FLY_AS_CHAR != pSFlyPara->eAnchor) + { pAnchorStck->AddAnchor(*pPaM->GetPoint(),pSFlyPara->pFlyFmt); + } // merke Pos im Haupttext pSFlyPara->pMainTextPos = new SwPosition( *pPaM->GetPoint() ); @@ -3206,7 +3200,7 @@ SwFrmFmt *SwWW8ImplReader::ContainsSingleInlineGraphic(const SwPaM &rRegion) subscripting to force the graphic into a centered position on the line, so we must check when applying sub/super to see if it the subscript range contains only a single graphic, and if that graphic is anchored as - FLY_IN_CNTNT and then we can change its anchoring to centered in the line. + FLY_AS_CHAR and then we can change its anchoring to centered in the line. */ SwFrmFmt *pRet=0; SwNodeIndex aBegin(rRegion.Start()->nNode); @@ -3223,8 +3217,8 @@ SwFrmFmt *SwWW8ImplReader::ContainsSingleInlineGraphic(const SwPaM &rRegion) { const SwFmtFlyCnt& rFly = pTFlyAttr->GetFlyCnt(); SwFrmFmt *pFlyFmt = rFly.GetFrmFmt(); - if( pFlyFmt && - FLY_IN_CNTNT == pFlyFmt->GetAnchor().GetAnchorId() ) + if (pFlyFmt && + (FLY_AS_CHAR == pFlyFmt->GetAnchor().GetAnchorId())) { pRet = pFlyFmt; } @@ -3240,7 +3234,7 @@ bool SwWW8ImplReader::ConvertSubToGraphicPlacement() subscripting to force the graphic into a centered position on the line, so we must check when applying sub/super to see if it the subscript range contains only a single graphic, and if that graphic is anchored as - FLY_IN_CNTNT and then we can change its anchoring to centered in the line. + FLY_AS_CHAR and then we can change its anchoring to centered in the line. */ bool bIsGraphicPlacementHack = false; USHORT nPos; diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index 76029cc249..c0f195a1a4 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -33,7 +33,8 @@ #include "XMLRedlineImportHelper.hxx" -#include "unoobj.hxx" +#include <unotextcursor.hxx> +#include <unotextrange.hxx> #include <unocrsr.hxx> #include "doc.hxx" #include <tools/datetime.hxx> @@ -161,7 +162,7 @@ void XTextRangeOrNodeIndexPosition::SetAsNodeIndex( #ifdef DBG_UTIL sal_Bool bSuccess = #endif - SwXTextRange::XTextRangeToSwPaM( aPaM, rRange); + ::sw::XTextRangeToSwPaM(aPaM, rRange); DBG_ASSERT(bSuccess, "illegal range"); // PaM -> Index @@ -179,7 +180,7 @@ void XTextRangeOrNodeIndexPosition::CopyPositionInto(SwPosition& rPos) #ifdef DBG_UTIL sal_Bool bSuccess = #endif - SwXTextRange::XTextRangeToSwPaM(aUnoPaM, xRange); + ::sw::XTextRangeToSwPaM(aUnoPaM, xRange); DBG_ASSERT(bSuccess, "illegal range"); rPos = *aUnoPaM.GetPoint(); @@ -499,11 +500,11 @@ Reference<XTextCursor> XMLRedlineImportHelper::CreateRedlineTextSection( // create (UNO-) cursor SwPosition aPos(*pRedlineNode); - SwXTextCursor* pCursor = - new SwXTextCursor(pXText, aPos, CURSOR_REDLINE, pDoc); - pCursor->GetCrsr()->Move(fnMoveForward, fnGoNode); - - xReturn = (XWordCursor*)pCursor; // cast to avoid ambigiouty + SwXTextCursor *const pXCursor = + new SwXTextCursor(*pDoc, pXText, CURSOR_REDLINE, aPos); + pXCursor->GetCursor()->Move(fnMoveForward, fnGoNode); + // cast to avoid ambiguity + xReturn = static_cast<text::XWordCursor*>(pXCursor); } // else: unknown redline -> Ignore diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index 90af842e88..af5caae2ee 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -72,7 +72,7 @@ #include <fltini.hxx> #include <doc.hxx> #include <docsh.hxx> -#include <unoobj.hxx> +#include <unotextrange.hxx> #include <swmodule.hxx> #include <SwXMLSectionList.hxx> @@ -788,9 +788,8 @@ ULONG XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const S } else if( bInsertMode ) { - uno::Reference<XTextRange> xInsertTextRange = - SwXTextRange::CreateTextRangeFromPosition( &rDoc, *rPaM.GetPoint(), - 0 ); + const uno::Reference<text::XTextRange> xInsertTextRange = + SwXTextRange::CreateXTextRange(rDoc, *rPaM.GetPoint(), 0); OUString sTextInsertModeRange( RTL_CONSTASCII_USTRINGPARAM("TextInsertModeRange")); xInfoSet->setPropertyValue( sTextInsertModeRange, diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index 25544a79c5..e4149fa60f 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -41,7 +40,6 @@ #include <com/sun/star/xforms/XFormsSupplier.hpp> #include <svx/svdmodel.hxx> #include <svx/svdpage.hxx> -#include <svx/xmlgrhlp.hxx> #include <svx/xmleohlp.hxx> #include <svx/xmlgrhlp.hxx> #include <svx/eeitem.hxx> @@ -58,7 +56,7 @@ #include <docsh.hxx> #include <docstat.hxx> #include <swerror.h> -#include <unoobj.hxx> +#include <unotext.hxx> #include <xmltexte.hxx> #include <xmlexp.hxx> #include <sfx2/viewsh.hxx> @@ -76,6 +74,7 @@ #include <pausethreadstarting.hxx> // <-- + using ::rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::frame; diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx index 49be1e08ce..c3f19af3d2 100644 --- a/sw/source/filter/xml/xmlfmt.cxx +++ b/sw/source/filter/xml/xmlfmt.cxx @@ -43,7 +43,6 @@ #include <format.hxx> #include <fmtcol.hxx> #include <hints.hxx> -#include <unoobj.hxx> #include <poolfmt.hxx> #include <charfmt.hxx> #include <paratr.hxx> @@ -57,19 +56,11 @@ #include <xmloff/xmltkmap.hxx> #include "xmlitem.hxx" #include <xmloff/xmlstyle.hxx> -#ifndef _XMLOFF_TXTSTYLI_HXX #include <xmloff/txtstyli.hxx> -#endif -#ifndef _XMLOFF_TXTIMP_HXX #include <xmloff/txtimp.hxx> -#endif -#ifndef _XMLOFF_FAMILIES_HXX #include <xmloff/families.hxx> -#endif #include <xmloff/XMLTextMasterStylesContext.hxx> -#ifndef _XMLOFF_XMLTEXTSHAPESTYLECONTEXT_HXX #include <xmloff/XMLTextShapeStyleContext.hxx> -#endif #include <xmloff/XMLGraphicsDefaultStyle.hxx> #include "xmlimp.hxx" #include "xmltbli.hxx" @@ -79,6 +70,7 @@ #include <unotxdoc.hxx> #include <docsh.hxx> + using namespace ::com::sun::star; using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/sw/source/filter/xml/xmlfonte.cxx b/sw/source/filter/xml/xmlfonte.cxx index 8ee621903f..f2503ec54e 100644 --- a/sw/source/filter/xml/xmlfonte.cxx +++ b/sw/source/filter/xml/xmlfonte.cxx @@ -31,15 +31,15 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include "hintids.hxx" #include <com/sun/star/text/XTextDocument.hpp> #include <xmloff/XMLFontAutoStylePool.hxx> #include <svx/fontitem.hxx> -#include <unoobj.hxx> +#include <unotext.hxx> #include <doc.hxx> #include <xmlexp.hxx> + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::text; diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index a2856b65ad..b7c76dafd8 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/text/XTextRange.hpp> #include <com/sun/star/drawing/XDrawPage.hpp> @@ -38,19 +39,17 @@ #include <xmloff/xmlnmspe.hxx> #include <xmloff/xmltkmap.hxx> #include <xmloff/xmlictxt.hxx> -#ifndef _XMLOFF_TXTIMP_HXX #include <xmloff/txtimp.hxx> -#endif #include <xmloff/nmspmap.hxx> -#ifndef _XMLOFF_XMLTEXTSHAPEIMPORTHELPER_HXX_ #include <xmloff/XMLTextShapeImportHelper.hxx> -#endif #include <xmloff/XMLFontStylesContext.hxx> #include <xmloff/ProgressBarHelper.hxx> #include <com/sun/star/i18n/XForbiddenCharacters.hpp> #include <com/sun/star/document/PrinterIndependentLayout.hpp> #include <doc.hxx> -#include <unoobj.hxx> +#include <TextCursorHelper.hxx> +#include <unotext.hxx> +#include <unotextrange.hxx> #include "unocrsr.hxx" #include <poolfmt.hxx> #include <ndtxt.hxx> @@ -714,9 +713,9 @@ void SwXMLImport::startDocument( void ) } if( pCrsrSh ) { - Reference<XTextRange> xInsertTextRange( - SwXTextRange::CreateTextRangeFromPosition( - pDoc, *pCrsrSh->GetCrsr()->GetPoint(), 0 ) ); + const uno::Reference<text::XTextRange> xInsertTextRange( + SwXTextRange::CreateXTextRange( + *pDoc, *pCrsrSh->GetCrsr()->GetPoint(), 0 ) ); setTextInsertMode( xInsertTextRange ); xTextCursor = GetTextImport()->GetCursor(); pTxtCrsr = 0; diff --git a/sw/source/filter/xml/xmlmeta.cxx b/sw/source/filter/xml/xmlmeta.cxx index 3bac5aa2b4..d6ebfb2d25 100644 --- a/sw/source/filter/xml/xmlmeta.cxx +++ b/sw/source/filter/xml/xmlmeta.cxx @@ -45,7 +45,6 @@ #include "docstat.hxx" #include "docsh.hxx" #include <doc.hxx> -#include <unoobj.hxx> #include "xmlimp.hxx" #include "xmlexp.hxx" diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx index 4aaa7bceaa..4378eb99df 100644 --- a/sw/source/filter/xml/xmltble.cxx +++ b/sw/source/filter/xml/xmltble.cxx @@ -31,10 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextSection.hpp> #include <hintids.hxx> #include <rtl/ustrbuf.hxx> -#include <com/sun/star/text/XTextTable.hpp> #include <xmloff/xmlnmspe.hxx> #include <xmloff/xmltoken.hxx> #include <xmloff/xmluconv.hxx> @@ -44,9 +45,7 @@ #include <svx/brshitem.hxx> #include <svx/boxitem.hxx> #include <fmtrowsplt.hxx> -#ifndef _SVX_FRAMEDIRITEM_HXX #include <svx/frmdiritem.hxx> -#endif #include <list> #include "swtable.hxx" @@ -62,7 +61,6 @@ #include <ndole.hxx> #include <xmloff/nmspmap.hxx> #include <sfx2/linkmgr.hxx> // for cTokenSeperator -#include "unoobj.hxx" #include "unotbl.hxx" #include "xmltexte.hxx" #include "xmlexp.hxx" diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index 7e6c33c9e7..2af534923e 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -32,7 +32,6 @@ #include "precompiled_sw.hxx" - #include "hintids.hxx" #include <limits.h> @@ -58,6 +57,7 @@ #include "swtblfmt.hxx" #include "pam.hxx" #include "unotbl.hxx" +#include "unotextrange.hxx" #include "unocrsr.hxx" #include "cellatr.hxx" #include "swddetbl.hxx" @@ -2926,8 +2926,8 @@ const SwStartNode *SwXMLTableContext::InsertTableSection( SwPosition aPos( *pCNd ); aPos.nContent.Assign( pCNd, 0U ); - Reference < XTextRange > xTextRange = - SwXTextRange::CreateTextRangeFromPosition( pDoc, aPos, 0 ); + const uno::Reference< text::XTextRange > xTextRange = + SwXTextRange::CreateXTextRange( *pDoc, aPos, 0 ); Reference < XText > xText = xTextRange->getText(); Reference < XTextCursor > xTextCursor = xText->createTextCursorByRange( xTextRange ); diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx index e577bf8a57..04387b13e8 100644 --- a/sw/source/filter/xml/xmltexte.cxx +++ b/sw/source/filter/xml/xmltexte.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <sot/clsids.hxx> #include <com/sun/star/embed/XEmbedObjectCreator.hpp> #include <com/sun/star/embed/XEmbeddedObject.hpp> @@ -44,13 +43,12 @@ #include <xmloff/families.hxx> #include <xmloff/xmlnmspe.hxx> #include <xmloff/xmltoken.hxx> -#ifndef _XMLOFF_TXTPRMAP_HXX #include <xmloff/txtprmap.hxx> -#endif #include <svx/svdobj.hxx> #include <doc.hxx> #include <ndole.hxx> +#include <fmtcntnt.hxx> #include <unostyle.hxx> #include <unoframe.hxx> #include <ndgrf.hxx> @@ -65,6 +63,7 @@ #include <sfx2/frmdescr.hxx> #include <SwStyleNameMapper.hxx> + using ::rtl::OUString; using ::rtl::OUStringBuffer; using namespace ::com::sun::star; diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx index 695bb1a3b5..00534cd5e5 100644 --- a/sw/source/filter/xml/xmltexti.cxx +++ b/sw/source/filter/xml/xmltexti.cxx @@ -47,17 +47,16 @@ #include <xmloff/prstylei.hxx> #include <xmloff/maptype.hxx> #include <xmloff/xmlprmap.hxx> -#ifndef _XMLOFF_TXTPRMAP_HXX #include <xmloff/txtprmap.hxx> -#endif #include <xmloff/i18nmap.hxx> #include "unocrsr.hxx" -#include "unoobj.hxx" +#include "TextCursorHelper.hxx" #include "unoframe.hxx" #include "doc.hxx" #include "unocoll.hxx" #include <fmtfsize.hxx> #include <fmtanchr.hxx> +#include <fmtcntnt.hxx> #include "xmlimp.hxx" #include "xmltbli.hxx" #include "xmltexti.hxx" @@ -76,6 +75,7 @@ #include <svtools/embedhlp.hxx> #include <svl/urihelper.hxx> + using ::rtl::OUString; using ::rtl::OUStringBuffer; using namespace ::com::sun::star; @@ -126,7 +126,7 @@ static void lcl_putHeightAndWidth ( SfxItemSet &rItemSet, rItemSet.Put( SwFmtFrmSize( ATT_FIX_SIZE, nWidth, nHeight ) ); } - SwFmtAnchor aAnchor( FLY_AUTO_CNTNT ); + SwFmtAnchor aAnchor( FLY_AT_CHAR ); rItemSet.Put( aAnchor ); if( pTwipWidth ) diff --git a/sw/source/ui/app/appenv.cxx b/sw/source/ui/app/appenv.cxx index e300e0d322..b31b84e86d 100644 --- a/sw/source/ui/app/appenv.cxx +++ b/sw/source/ui/app/appenv.cxx @@ -43,18 +43,12 @@ #include <svx/svxids.hrc> #include <svtools/svmedit.hxx> -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <sfx2/app.hxx> #include <sfx2/docfac.hxx> #include <sfx2/printer.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <sfx2/dispatch.hxx> #include <svx/boxitem.hxx> #include <svx/lrspitem.hxx> @@ -67,21 +61,13 @@ #include <paratr.hxx> #include <swmodule.hxx> #include <wrtsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <frmatr.hxx> #include <fldbas.hxx> #include <swundo.hxx> -#ifndef IDOCUMENTDEVICEACCESS_HXX_INCLUDED #include <IDocumentDeviceAccess.hxx> -#endif -#ifndef _DBMGR_HXX #include <dbmgr.hxx> -#endif #include <fmtcol.hxx> #include <frmmgr.hxx> #include <fldmgr.hxx> @@ -91,9 +77,7 @@ #include <SwStyleNameMapper.hxx> #include <crsskip.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif #ifndef _GLOBALS_HRC #include <globals.hrc> #endif @@ -478,7 +462,7 @@ static USHORT nTitleNo = 0; if (rItem.bSend) { pSh->SttEndDoc(TRUE); - aMgr.InsertFlyFrm(FLY_PAGE, + aMgr.InsertFlyFrm(FLY_AT_PAGE, Point(rItem.lSendFromLeft + lLeft, rItem.lSendFromTop + lUpper), Size (rItem.lAddrFromLeft - rItem.lSendFromLeft, 0)); @@ -494,7 +478,7 @@ static USHORT nTitleNo = 0; // Empfaenger pSh->SttEndDoc(TRUE); - aMgr.InsertFlyFrm(FLY_PAGE, + aMgr.InsertFlyFrm(FLY_AT_PAGE, Point(rItem.lAddrFromLeft + lLeft, rItem.lAddrFromTop + lUpper), Size (nPageW - rItem.lAddrFromLeft - 566, 0)); pSh->EnterSelFrmMode(); diff --git a/sw/source/ui/app/applab.cxx b/sw/source/ui/app/applab.cxx index 889b131c14..a90c3beeaf 100644 --- a/sw/source/ui/app/applab.cxx +++ b/sw/source/ui/app/applab.cxx @@ -39,15 +39,9 @@ #include <hintids.hxx> -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <sfx2/app.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/printer.hxx> @@ -71,21 +65,13 @@ #include <frmatr.hxx> #include <paratr.hxx> #include <swmodule.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <fldbas.hxx> #include <swundo.hxx> #include <wrtsh.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _DBMGR_HXX #include <dbmgr.hxx> -#endif #include <fmtcol.hxx> #include <expfld.hxx> #include <fldmgr.hxx> @@ -126,7 +112,7 @@ const SwFrmFmt *lcl_InsertBCText( SwWrtShell& rSh, const SwLabItem& rItem, sal_uInt16 nPhyPageNum, nVirtPageNum; rSh.GetPageNum( nPhyPageNum, nVirtPageNum ); - aSet.Put(SwFmtAnchor(bPage ? FLY_IN_CNTNT : FLY_PAGE, nPhyPageNum)); + aSet.Put(SwFmtAnchor(bPage ? FLY_AS_CHAR : FLY_AT_PAGE, nPhyPageNum)); if (!bPage) { aSet.Put(SwFmtHoriOrient(rItem.lLeft + nCol * rItem.lHDist, @@ -166,7 +152,7 @@ const SwFrmFmt *lcl_InsertLabText( SwWrtShell& rSh, const SwLabItem& rItem, sal_uInt16 nPhyPageNum, nVirtPageNum; rSh.GetPageNum( nPhyPageNum, nVirtPageNum ); - aSet.Put(SwFmtAnchor(bPage ? FLY_IN_CNTNT : FLY_PAGE, nPhyPageNum)); + aSet.Put(SwFmtAnchor(bPage ? FLY_AS_CHAR : FLY_AT_PAGE, nPhyPageNum)); if (!bPage) { aSet.Put(SwFmtHoriOrient(rItem.lLeft + nCol * rItem.lHDist, diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index d20154e789..d614c74673 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -30,30 +30,19 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#ifndef _COM_SUN_STAR_LANG_XMultiServiceFactory_HPP_ -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#endif -#ifndef _UNOTOOLS_PROCESSFACTORY_HXX -#include <comphelper/processfactory.hxx> -#endif +#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/frame/XDispatchHelper.hpp> +#include <comphelper/processfactory.hxx> #include <hintids.hxx> #include <tools/urlobj.hxx> #include <unotools/tempfile.hxx> -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svl/lckbitem.hxx> #include <svl/eitem.hxx> -/* -#include <svl/macitem.hxx> -*/ #include <svl/zforlist.hxx> #include <svl/zformat.hxx> #include <unotools/pathoptions.hxx> @@ -90,51 +79,33 @@ #include <swunodef.hxx> #include <fmtcol.hxx> #include <swevent.hxx> -#ifndef _VIEW_HXX #include <view.hxx> // fuer die aktuelle Sicht -#endif -#ifndef _DOCSH_HXX #include <docsh.hxx> // Dokumenterzeugung -#endif #include <wrtsh.hxx> #include <fldbas.hxx> #include <viewopt.hxx> -#ifndef _GLOBDOC_HXX #include <globdoc.hxx> -#endif #include <fldwrap.hxx> -#ifndef _REDLNDLG_HXX #include <redlndlg.hxx> -#endif #include <docstyle.hxx> #include <doc.hxx> #include <pagedesc.hxx> #include <shellio.hxx> -#ifndef _PVIEW_HXX #include <pview.hxx> -#endif -#ifndef _SRCVIEW_HXX #include <srcview.hxx> -#endif #include <poolfmt.hxx> #include <usrpref.hxx> -#ifndef _WDOCSH_HXX #include <wdocsh.hxx> -#endif #include <unotxdoc.hxx> #include <acmplwrd.hxx> #include <swmodule.hxx> -#include <unoobj.hxx> +#include <unobaseclass.hxx> #include <swwait.hxx> #include <swcli.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif #include <globals.h> -#ifndef _HELPID_H #include <helpid.h> -#endif #ifndef _APP_HRC #include <app.hrc> #endif diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx index 1560648be9..05f38af1e7 100644 --- a/sw/source/ui/dbui/mmlayoutpage.cxx +++ b/sw/source/ui/dbui/mmlayoutpage.cxx @@ -42,9 +42,7 @@ #include <unotools/tempfile.hxx> #include <uitool.hxx> #include <svx/dlgutil.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <swundo.hxx> #include <sfx2/dispatch.hxx> #include <svl/stritem.hxx> @@ -56,9 +54,7 @@ #include <fldbas.hxx> #include <poolfmt.hxx> #include <unotxdoc.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <doc.hxx> #include <wrtsh.hxx> #include <fmtsrnd.hxx> @@ -325,7 +321,7 @@ SwFrmFmt* SwMailMergeLayoutPage::InsertAddressFrame( RES_FRM_SIZE, RES_FRM_SIZE, RES_SURROUND, RES_SURROUND, 0 ); - aSet.Put(SwFmtAnchor(FLY_PAGE, 1)); + aSet.Put(SwFmtAnchor(FLY_AT_PAGE, 1)); if(bAlignLeft) aSet.Put(SwFmtHoriOrient( 0, text::HoriOrientation::NONE, text::RelOrientation::PAGE_PRINT_AREA )); else diff --git a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx index ae783c9917..6f8bd1f466 100644 --- a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx +++ b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <SwSpellDialogChildWindow.hxx> #include <vcl/msgbox.hxx> #include <svx/svxacorr.hxx> @@ -50,21 +51,20 @@ #include <unotools/linguprops.hxx> #include <unotools/lingucfg.hxx> #include <doc.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <docary.hxx> #include <frmfmt.hxx> #include <dcontact.hxx> #include <edtwin.hxx> #include <pam.hxx> #include <drawbase.hxx> -#include <unoobj.hxx> +#include <unotextrange.hxx> #ifndef _DIALOG_HXX #include <dialog.hrc> #endif #include <cmdid.h> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::text; @@ -258,8 +258,10 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) //mark the start position only if not at start of doc if(!pWrtShell->IsStartOfDoc()) { - m_pSpellState->m_xStartRange = SwXTextRange::CreateTextRangeFromPosition( - pWrtShell->GetDoc(), *pCrsr->Start(), pCrsr->End()); + m_pSpellState->m_xStartRange = + SwXTextRange::CreateXTextRange( + *pWrtShell->GetDoc(), + *pCrsr->Start(), pCrsr->End()); } pWrtShell->SpellStart( DOCPOS_START, DOCPOS_END, DOCPOS_CURR, FALSE ); } @@ -390,7 +392,8 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) if(RET_YES == nRet) { SwUnoInternalPaM aPam(*pWrtShell->GetDoc()); - if(SwXTextRange::XTextRangeToSwPaM(aPam, m_pSpellState->m_xStartRange)) + if (::sw::XTextRangeToSwPaM(aPam, + m_pSpellState->m_xStartRange)) { pWrtShell->SetSelection(aPam); pWrtShell->SpellStart(DOCPOS_START, DOCPOS_CURR, DOCPOS_START); diff --git a/sw/source/ui/dialog/regionsw.cxx b/sw/source/ui/dialog/regionsw.cxx index 6c850d9936..9a35c75d0d 100644 --- a/sw/source/ui/dialog/regionsw.cxx +++ b/sw/source/ui/dialog/regionsw.cxx @@ -36,37 +36,24 @@ #include <uitool.hxx> #include <svl/urihelper.hxx> #include <svl/PasswordHelper.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svl/stritem.hxx> #include <svl/eitem.hxx> #include <sot/formats.hxx> -#ifndef _PASSWD_HXX //autogen #include <sfx2/passwd.hxx> -#endif #include <sfx2/docfilt.hxx> #include <sfx2/request.hxx> #include <sfx2/docfile.hxx> #include <sfx2/linkmgr.hxx> -#ifndef _SVX_SIZEITEM_HXX //autogen - #include <svx/sizeitem.hxx> -#endif #include <svx/htmlcfg.hxx> #include <section.hxx> #include <docary.hxx> #include <regionsw.hxx> -#ifndef _BASESH_HXX #include <basesh.hxx> -#endif -#ifndef _WDOCSH_HXX #include <wdocsh.hxx> -#endif -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <swmodule.hxx> #include <wrtsh.hxx> #include <swundo.hxx> // fuer Undo-Ids @@ -75,12 +62,8 @@ #include <swunodef.hxx> #include <shellio.hxx> -#ifndef _HELPID_H #include <helpid.h> -#endif -#ifndef _CMDID_H #include <cmdid.h> -#endif #ifndef _REGIONSW_HRC #include <regionsw.hrc> #endif @@ -118,7 +101,7 @@ void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) if (!pSet || pSet->Count()==0) { SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nWidth = aRect.Width(); aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); @@ -154,7 +137,7 @@ void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) { SwFmtCol aCol; SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nWidth = aRect.Width(); USHORT nCol = ((SfxUInt16Item *)pItem)->GetValue(); @@ -232,7 +215,7 @@ IMPL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSection*, pSect ) SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, 0); SwRect aRect; - pThis->CalcBoundRect(aRect, FLY_IN_CNTNT); + pThis->CalcBoundRect(aRect, FLY_AS_CHAR); long nWidth = aRect.Width(); aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); // Hoehe=Breite fuer konsistentere Vorschau (analog zu Bereich bearbeiten) diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index a548726ad7..6a22daafde 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -50,16 +50,12 @@ #include <sot/storage.hxx> #include <svl/macitem.hxx> #include <unotools/securityoptions.hxx> -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include <basic/sbxvar.hxx> -#endif #include <svl/ctloptions.hxx> #include <basic/sbx.hxx> #include <svl/eitem.hxx> #include <svl/stritem.hxx> -#ifndef _SFX_CLIENTSH_HXX #include <sfx2/ipclient.hxx> -#endif #include <sfx2/viewfrm.hxx> #include <sfx2/request.hxx> #include <sfx2/bindings.hxx> @@ -69,9 +65,6 @@ #include <svx/langitem.hxx> #include <svx/htmlmode.hxx> #include <svx/svdview.hxx> -//#ifndef _SVDVMARK_HXX //autogen -//#include <svx/svdvmark.hxx> -//#endif #include <svx/svdhdl.hxx> #include <svx/svdoutl.hxx> #include <svx/editeng.hxx> @@ -128,12 +121,8 @@ #include <breakit.hxx> #include <checkit.hxx> -#ifndef _HELPID_H #include <helpid.h> -#endif -#ifndef _CMDID_H #include <cmdid.h> -#endif #ifndef _DOCVW_HRC #include <docvw.hrc> #endif @@ -1019,7 +1008,7 @@ void SwEditWin::ChangeFly( BYTE nDir, BOOL bWeb ) default: ASSERT( TRUE, "ChangeFly: Unknown direction." ); } BOOL bSet = FALSE; - if( FLY_IN_CNTNT == eAnchorId && ( nDir % 2 ) ) + if ((FLY_AS_CHAR == eAnchorId) && ( nDir % 2 )) { long aDiff = aTmp.Top() - aRefPoint.Y(); if( aDiff > 0 ) @@ -1064,7 +1053,8 @@ void SwEditWin::ChangeFly( BYTE nDir, BOOL bWeb ) aSet.Put( aVert ); bSet = TRUE; } - if( bWeb && FLY_AT_CNTNT == eAnchorId && ( nDir==MOVE_LEFT_SMALL || nDir==MOVE_RIGHT_BIG ) ) + if (bWeb && (FLY_AT_PARA == eAnchorId) + && ( nDir==MOVE_LEFT_SMALL || nDir==MOVE_RIGHT_BIG )) { SwFmtHoriOrient aHori( (SwFmtHoriOrient&)aSet.Get(RES_HORI_ORIENT) ); sal_Int16 eNew; @@ -1091,11 +1081,13 @@ void SwEditWin::ChangeFly( BYTE nDir, BOOL bWeb ) rSh.StartAllAction(); if( bSet ) rSh.SetFlyFrmAttr( aSet ); - BOOL bSetPos = FLY_IN_CNTNT != eAnchorId; + BOOL bSetPos = (FLY_AS_CHAR != eAnchorId); if(bSetPos && bWeb) { - if(FLY_PAGE != eAnchorId) + if (FLY_AT_PAGE != eAnchorId) + { bSetPos = FALSE; + } else { bSetPos = (::GetHtmlMode(rView.GetDocShell()) & HTMLMODE_SOME_ABS_POS) ? @@ -1185,7 +1177,8 @@ void SwEditWin::ChangeDrawing( BYTE nDir ) BOOL bDummy; const bool bVertAnchor = rSh.IsFrmVertical( TRUE, bDummy ); const bool bHoriMove = !bVertAnchor == !( nDir % 2 ); - const bool bMoveAllowed = !bHoriMove || rSh.GetAnchorId() != FLY_IN_CNTNT; + const bool bMoveAllowed = + !bHoriMove || (rSh.GetAnchorId() != FLY_AS_CHAR); if ( bMoveAllowed ) { // <-- diff --git a/sw/source/ui/envelp/labelexp.cxx b/sw/source/ui/envelp/labelexp.cxx index 21a9dcf599..0b0f557bbb 100644 --- a/sw/source/ui/envelp/labelexp.cxx +++ b/sw/source/ui/envelp/labelexp.cxx @@ -43,7 +43,7 @@ #include <labfmt.hxx> #include <unotools.hxx> #include <unoatxt.hxx> -#include <unoobj.hxx> +#include <unomid.h> #include <unoprnms.hxx> diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx index b7d67803ff..c7298118cd 100644 --- a/sw/source/ui/frmdlg/column.cxx +++ b/sw/source/ui/frmdlg/column.cxx @@ -125,7 +125,7 @@ SwColumnDlg::SwColumnDlg(Window* pParent, SwWrtShell& rSh) : FreeResource(); SwRect aRect; - rWrtShell.CalcBoundRect(aRect, FLY_IN_CNTNT); + rWrtShell.CalcBoundRect(aRect, FLY_AS_CHAR); nSelectionWidth = aRect.Width(); diff --git a/sw/source/ui/frmdlg/frmmgr.cxx b/sw/source/ui/frmdlg/frmmgr.cxx index 97bd17351f..359b3a595b 100644 --- a/sw/source/ui/frmdlg/frmmgr.cxx +++ b/sw/source/ui/frmdlg/frmmgr.cxx @@ -31,12 +31,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - - #include "cmdid.h" #include "hintids.hxx" - #include <svl/stritem.hxx> #include <svx/protitem.hxx> #include <svx/boxitem.hxx> @@ -212,11 +209,11 @@ void SwFlyFrmAttrMgr::InsertFlyFrm(RndStdIds eAnchorType, const Size &rSize, BOOL bAbs ) { - ASSERT( eAnchorType == FLY_PAGE || - eAnchorType == FLY_AT_CNTNT || - eAnchorType == FLY_AUTO_CNTNT || - eAnchorType == FLY_AT_FLY || - eAnchorType == FLY_IN_CNTNT, "Rahmentyp nicht erlaubt" ); + ASSERT( eAnchorType == FLY_AT_PAGE || + eAnchorType == FLY_AT_PARA || + eAnchorType == FLY_AT_CHAR || + eAnchorType == FLY_AT_FLY || + eAnchorType == FLY_AS_CHAR, "invalid frame type" ); if ( bAbs ) SetAbsPos( rPos ); @@ -238,8 +235,8 @@ void SwFlyFrmAttrMgr::SetAnchor( RndStdIds eId ) pOwnSh->GetPageNum( nPhyPageNum, nVirtPageNum ); aSet.Put( SwFmtAnchor( eId, nPhyPageNum ) ); - if( FLY_PAGE == eId || FLY_AT_CNTNT == eId || FLY_AUTO_CNTNT == eId - || FLY_AT_FLY == eId ) + if ((FLY_AT_PAGE == eId) || (FLY_AT_PARA == eId) || (FLY_AT_CHAR == eId) + || (FLY_AT_FLY == eId)) { SwFmtVertOrient aVertOrient( GetVertOrient() ); SwFmtHoriOrient aHoriOrient( GetHoriOrient() ); @@ -319,7 +316,7 @@ void SwFlyFrmAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal, rVal.nWidth = rVal.nHeight; rVal.nHeight = nTmp; } - if ( eAnchorType == FLY_PAGE || eAnchorType == FLY_AT_FLY ) + if ((eAnchorType == FLY_AT_PAGE) || (eAnchorType == FLY_AT_FLY)) { // MinimalPosition rVal.nMinHPos = aBoundRect.Left(); @@ -369,8 +366,8 @@ void SwFlyFrmAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal, } // OD 12.11.2003 #i22341# - handle to character anchored objects vertical // aligned at character or top of line in a special case - else if ( eAnchorType == FLY_AT_CNTNT || - ( eAnchorType == FLY_AUTO_CNTNT && + else if ((eAnchorType == FLY_AT_PARA) || + ((eAnchorType == FLY_AT_CHAR) && !(rVal.nVRelOrient == text::RelOrientation::CHAR) && !(rVal.nVRelOrient == text::RelOrientation::TEXT_LINE) ) ) { @@ -437,7 +434,7 @@ void SwFlyFrmAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal, // vertical aligned at character or top of line. // Note: (1) positive vertical values are positions above the top of line // (2) negative vertical values are positions below the top of line - else if ( eAnchorType == FLY_AUTO_CNTNT && + else if ( (eAnchorType == FLY_AT_CHAR) && ( rVal.nVRelOrient == text::RelOrientation::CHAR || rVal.nVRelOrient == text::RelOrientation::TEXT_LINE ) ) { @@ -484,7 +481,7 @@ void SwFlyFrmAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal, rVal.nMaxHeight = aBoundRect.Height(); } } - else if ( eAnchorType == FLY_IN_CNTNT ) + else if ( eAnchorType == FLY_AS_CHAR ) { rVal.nMinHPos = 0; rVal.nMaxHPos = 0; diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index 2bbaa672f5..8908f1f4a3 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -37,12 +37,8 @@ #include <com/sun/star/embed/Aspects.hpp> #include <com/sun/star/embed/EmbedMisc.hpp> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _HELPID_H #include <helpid.h> -#endif #include <hintids.hxx> #include <vcl/msgbox.hxx> #include <vcl/mnemonic.hxx> @@ -68,9 +64,7 @@ #include <wrtsh.hxx> #include <swmodule.hxx> #include <uitool.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <viewopt.hxx> #include <frmatr.hxx> #include <frmdlg.hxx> @@ -881,10 +875,10 @@ void SwFrmPage::Reset( const SfxItemSet &rSet ) // Allgemeiner Initialisierungteil switch(rAnchor.GetAnchorId()) { - case FLY_PAGE: aAnchorAtPageRB.Check(); break; - case FLY_AT_CNTNT: aAnchorAtParaRB.Check(); break; - case FLY_AUTO_CNTNT: aAnchorAtCharRB.Check(); break; - case FLY_IN_CNTNT: aAnchorAsCharRB.Check(); break; + case FLY_AT_PAGE: aAnchorAtPageRB.Check(); break; + case FLY_AT_PARA: aAnchorAtParaRB.Check(); break; + case FLY_AT_CHAR: aAnchorAtCharRB.Check(); break; + case FLY_AS_CHAR: aAnchorAsCharRB.Check(); break; case FLY_AT_FLY: aAnchorAtFrameRB.Check();break; default:; //prevent warning } @@ -911,7 +905,7 @@ void SwFrmPage::Reset( const SfxItemSet &rSet ) } if( 0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS)) { - if(GetAnchor() == FLY_PAGE) + if (GetAnchor() == FLY_AT_PAGE) { aAnchorAtParaRB.Check(); } @@ -1048,8 +1042,10 @@ BOOL SwFrmPage::FillItemSet(SfxItemSet &rSet) // Vertikale Position // fuer zeichengebundene Rahmen Offset umrechenen SwTwips nY = static_cast< SwTwips >(aAtVertPosED.Denormalize(aAtVertPosED.GetValue(FUNIT_TWIP))); - if (eAnchorId == FLY_IN_CNTNT) + if (eAnchorId == FLY_AS_CHAR) + { nY *= -1; + } aVertOrient.SetPos( nY ); } pOldItem = GetOldItem(rSet, FN_VERT_ORIENT); @@ -1188,7 +1184,7 @@ void SwFrmPage::InitPos(RndStdIds eId, } BOOL bEnable = TRUE; - if ( eId == FLY_PAGE ) + if ( eId == FLY_AT_PAGE ) { pVMap = bHtmlMode ? aVPageHtmlMap : aVPageMap; pHMap = bHtmlMode ? aHPageHtmlMap : aHPageMap; @@ -1200,7 +1196,7 @@ void SwFrmPage::InitPos(RndStdIds eId, pVMap = bHtmlMode ? aVFlyHtmlMap : aVFrameMap; pHMap = bHtmlMode ? aHFlyHtmlMap : aHFrameMap; } - else if ( eId == FLY_AT_CNTNT ) + else if ( eId == FLY_AT_PARA ) { if(bHtmlMode) { @@ -1213,7 +1209,7 @@ void SwFrmPage::InitPos(RndStdIds eId, pHMap = aHParaMap; } } - else if ( eId == FLY_AUTO_CNTNT ) + else if ( eId == FLY_AT_CHAR ) { if(bHtmlMode) { @@ -1226,7 +1222,7 @@ void SwFrmPage::InitPos(RndStdIds eId, pHMap = aHCharMap; } } - else if ( eId == FLY_IN_CNTNT ) + else if ( eId == FLY_AS_CHAR ) { pVMap = bHtmlMode ? aVAsCharHtmlMap : aVAsCharMap; pHMap = 0; @@ -1257,7 +1253,7 @@ void SwFrmPage::InitPos(RndStdIds eId, FillRelLB(pVMap, nMapPos, nV, nVRel, aVertRelationLB, aVertRelationFT); // Edits init - bEnable = nH == text::HoriOrientation::NONE && eId != FLY_IN_CNTNT;//#61359# warum nicht in Formaten&& !bFormat; + bEnable = nH == text::HoriOrientation::NONE && eId != FLY_AS_CHAR; if (!bEnable) { aAtHorzPosED.SetValue( 0, FUNIT_TWIP ); @@ -1281,7 +1277,7 @@ void SwFrmPage::InitPos(RndStdIds eId, } else { - if ( eId == FLY_IN_CNTNT ) + if ( eId == FLY_AS_CHAR ) { if ( nY == LONG_MAX ) nY = 0; @@ -1608,15 +1604,23 @@ USHORT SwFrmPage::GetMapPos( const FrmMap *pMap, ListBox &rAlignLB ) RndStdIds SwFrmPage::GetAnchor() { - RndStdIds nRet = FLY_PAGE; + RndStdIds nRet = FLY_AT_PAGE; if(aAnchorAtParaRB.IsChecked()) - nRet = FLY_AT_CNTNT; + { + nRet = FLY_AT_PARA; + } else if(aAnchorAtCharRB.IsChecked()) - nRet = FLY_AUTO_CNTNT; + { + nRet = FLY_AT_CHAR; + } else if(aAnchorAsCharRB.IsChecked()) - nRet = FLY_IN_CNTNT; + { + nRet = FLY_AS_CHAR; + } else if(aAnchorAtFrameRB.IsChecked()) + { nRet = FLY_AT_FLY; + } return nRet; } @@ -1818,8 +1822,10 @@ IMPL_LINK( SwFrmPage, RangeModifyHdl, Edit *, EMPTYARG ) if ( aVal.nHPos != nAtHorzPosVal ) aAtHorzPosED.SetValue(aAtHorzPosED.Normalize(aVal.nHPos), FUNIT_TWIP); - SwTwips nUpperOffset = aVal.nAnchorType == FLY_IN_CNTNT ? nUpperBorder : 0; - SwTwips nLowerOffset = aVal.nAnchorType == FLY_IN_CNTNT ? nLowerBorder : 0; + const SwTwips nUpperOffset = (aVal.nAnchorType == FLY_AS_CHAR) + ? nUpperBorder : 0; + const SwTwips nLowerOffset = (aVal.nAnchorType == FLY_AS_CHAR) + ? nLowerBorder : 0; aAtVertPosED.SetMin(aAtVertPosED.Normalize(aVal.nMinVPos + nLowerOffset + nUpperOffset), FUNIT_TWIP); aAtVertPosED.SetMax(aAtVertPosED.Normalize(aVal.nMaxVPos), FUNIT_TWIP); @@ -1905,7 +1911,7 @@ IMPL_LINK( SwFrmPage, PosHdl, ListBox *, pLB ) // Sonderbehandlung fuer HTML-Mode mit horz-vert-Abhaengigkeiten if(bHtmlMode && nHtmlMode&HTMLMODE_SOME_ABS_POS && - FLY_AUTO_CNTNT == (RndStdIds)GetAnchor()) + (FLY_AT_CHAR == GetAnchor())) { BOOL bSet = FALSE; if(bHori) @@ -1977,7 +1983,7 @@ IMPL_LINK( SwFrmPage, RelHdl, ListBox *, pLB ) else bAtVertPosModified = TRUE; - if(bHtmlMode && FLY_AUTO_CNTNT == (RndStdIds)GetAnchor()) // wieder Sonderbehandlung + if (bHtmlMode && (FLY_AT_CHAR == GetAnchor())) { if(bHori) { @@ -2219,7 +2225,7 @@ void SwFrmPage::Init(const SfxItemSet& rSet, BOOL bReset) nOldV = rVert.GetVertOrient(), nOldVRel = rVert.GetRelationOrient(); - if (eAnchorId == FLY_PAGE) + if (eAnchorId == FLY_AT_PAGE) { if (nOldHRel == text::RelOrientation::FRAME) nOldHRel = text::RelOrientation::PAGE_FRAME; diff --git a/sw/source/ui/frmdlg/wrap.cxx b/sw/source/ui/frmdlg/wrap.cxx index c9488c26ba..8b4771ca69 100644 --- a/sw/source/ui/frmdlg/wrap.cxx +++ b/sw/source/ui/frmdlg/wrap.cxx @@ -36,7 +36,6 @@ #endif - #include "hintids.hxx" #include <vcl/graph.hxx> #include <svx/htmlmode.hxx> @@ -141,7 +140,7 @@ SwWrapTabPage::SwWrapTabPage(Window *pParent, const SfxItemSet &rSet) : aWrapIL (SW_RES(IL_WRAP)), aWrapILH (SW_RES(ILH_WRAP)), - nAnchorId(FLY_AT_CNTNT), + nAnchorId(FLY_AT_PARA), nHtmlMode(0), pWrtSh(0), @@ -254,10 +253,15 @@ void SwWrapTabPage::Reset(const SfxItemSet &rSet) const SwFmtAnchor &rAnch = (const SwFmtAnchor&)rSet.Get(RES_ANCHOR); nAnchorId = rAnch.GetAnchorId(); - if ( (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) && nSur != SURROUND_NONE ) + if (((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) + && (nSur != SURROUND_NONE)) + { aWrapAnchorOnlyCB.Check( rSurround.IsAnchorOnly() ); + } else + { aWrapAnchorOnlyCB.Enable( FALSE ); + } BOOL bContour = rSurround.IsContour(); aWrapOutlineCB.Check( bContour ); @@ -452,7 +456,7 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) // Anchor const SwFmtAnchor &rAnch = (const SwFmtAnchor&)rSet.Get(RES_ANCHOR); nAnchorId = rAnch.GetAnchorId(); - BOOL bEnable = nAnchorId != FLY_IN_CNTNT; + BOOL bEnable = (nAnchorId != FLY_AS_CHAR); if (!bDrawMode) { @@ -521,7 +525,7 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) } else { - if (aVal.nAnchorType == FLY_IN_CNTNT) + if (aVal.nAnchorType == FLY_AS_CHAR) { nLeft = nRight; @@ -566,7 +570,8 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) sal_Int16 eHOrient = rHori.GetHoriOrient(); sal_Int16 eHRelOrient = rHori.GetRelationOrient(); aWrapOutlineCB.Hide(); - BOOL bAllHtmlModes = (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) && + const bool bAllHtmlModes = + ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) && (eHOrient == text::HoriOrientation::RIGHT || eHOrient == text::HoriOrientation::LEFT); aWrapAnchorOnlyCB.Enable( bAllHtmlModes && nSur != SURROUND_NONE ); aWrapOutsideCB.Hide(); @@ -574,17 +579,26 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) aWrapTransparentCB.Enable( FALSE ); - aNoWrapRB.Enable( FLY_AT_CNTNT == nAnchorId ); + aNoWrapRB.Enable( FLY_AT_PARA == nAnchorId ); aWrapParallelRB.Enable( FALSE ); - aWrapLeftRB .Enable( FLY_AT_CNTNT == nAnchorId || - (FLY_AUTO_CNTNT == nAnchorId && eHOrient == text::HoriOrientation::RIGHT && eHRelOrient == text::RelOrientation::PRINT_AREA)); - aWrapRightRB .Enable( FLY_AT_CNTNT == nAnchorId || - ( FLY_AUTO_CNTNT == nAnchorId && eHOrient == text::HoriOrientation::LEFT && eHRelOrient == text::RelOrientation::PRINT_AREA)); - - aWrapThroughRB.Enable( (FLY_PAGE == nAnchorId || - (FLY_AUTO_CNTNT == nAnchorId && eHRelOrient != text::RelOrientation::PRINT_AREA) || FLY_AT_CNTNT == nAnchorId ) - && bSomeAbsPos && - eHOrient != text::HoriOrientation::RIGHT); + aWrapLeftRB .Enable + ( (FLY_AT_PARA == nAnchorId) + || ( (FLY_AT_CHAR == nAnchorId) + && (eHOrient == text::HoriOrientation::RIGHT) + && (eHRelOrient == text::RelOrientation::PRINT_AREA))); + aWrapRightRB .Enable + ( (FLY_AT_PARA == nAnchorId) + || ( (FLY_AT_CHAR == nAnchorId) + && (eHOrient == text::HoriOrientation::LEFT) + && (eHRelOrient == text::RelOrientation::PRINT_AREA))); + + aWrapThroughRB.Enable + ( ( (FLY_AT_PAGE == nAnchorId) + || ( (FLY_AT_CHAR == nAnchorId) + && (eHRelOrient != text::RelOrientation::PRINT_AREA)) + || (FLY_AT_PARA == nAnchorId)) + && bSomeAbsPos + && (eHOrient != text::HoriOrientation::RIGHT)); if(aNoWrapRB.IsChecked() && !aNoWrapRB.IsEnabled()) { if(aWrapThroughRB.IsEnabled()) @@ -624,7 +638,8 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) aIdealWrapRB.Enable( bEnable ); aWrapThroughRB.Enable( bEnable ); aWrapParallelRB.Enable( bEnable ); - aWrapAnchorOnlyCB.Enable( (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) + aWrapAnchorOnlyCB.Enable( + ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) && nSur != SURROUND_NONE ); } ContourHdl(0); @@ -693,10 +708,11 @@ IMPL_LINK( SwWrapTabPage, WrapTypeHdl, ImageRadioButton *, pBtn ) { BOOL bWrapThrough = (pBtn == &aWrapThroughRB); aWrapTransparentCB.Enable( bWrapThrough && !bHtmlMode ); - bWrapThrough |= ( nAnchorId == FLY_IN_CNTNT ); + bWrapThrough |= ( nAnchorId == FLY_AS_CHAR ); aWrapOutlineCB.Enable( !bWrapThrough && pBtn != &aNoWrapRB); aWrapOutsideCB.Enable( !bWrapThrough && aWrapOutlineCB.IsChecked() ); - aWrapAnchorOnlyCB.Enable( (nAnchorId == FLY_AT_CNTNT || nAnchorId == FLY_AUTO_CNTNT) && + aWrapAnchorOnlyCB.Enable( + ((nAnchorId == FLY_AT_PARA) || (nAnchorId == FLY_AT_CHAR)) && (pBtn != &aNoWrapRB) ); ContourHdl(0); diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index e2d5cd7f3f..10a6a2bf6c 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -30,25 +30,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #ifdef SW_DLLIMPLEMENTATION #undef SW_DLLIMPLEMENTATION #endif - - #define _SVSTDARR_STRINGSDTOR #define _SVSTDARR_STRINGS #include <hintids.hxx> -#ifndef _MENU_HXX //autogen #include <vcl/menu.hxx> -#endif -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif -#ifndef _HELP_HXX //autogen #include <vcl/help.hxx> -#endif #ifndef _SVSTDARR_HXX #include <svl/svstdarr.hxx> #endif @@ -64,7 +57,6 @@ #include <sfx2/viewfrm.hxx> #include <unocrsr.hxx> #include <unotools.hxx> -#include <unoobj.hxx> #include <comphelper/processfactory.hxx> #include <ucbhelper/content.hxx> #include <com/sun/star/ui/dialogs/XFilePicker.hpp> @@ -75,12 +67,8 @@ #include <swwait.hxx> #include <swtypes.hxx> #include <wrtsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif -#ifndef _BASESH_HXX #include <basesh.hxx> -#endif #include <glossary.hxx> #include <gloshdl.hxx> #include <glosbib.hxx> @@ -88,20 +76,12 @@ #include <glosdoc.hxx> #include <macassgn.hxx> #include <swevent.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <shellio.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _HELPID_H #include <helpid.h> -#endif -#ifndef _SWERROR_H #include <swerror.h> -#endif #ifndef _GLOBALS_HRC #include <globals.hrc> #endif diff --git a/sw/source/ui/ribbar/conrect.cxx b/sw/source/ui/ribbar/conrect.cxx index 2bd57967d2..d676b8eaaf 100644 --- a/sw/source/ui/ribbar/conrect.cxx +++ b/sw/source/ui/ribbar/conrect.cxx @@ -43,21 +43,14 @@ #include <svx/svdview.hxx> #include <svx/svdocapt.hxx> #include <svx/outlobj.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <edtwin.hxx> #include <wrtsh.hxx> #include <viewopt.hxx> -#ifndef _DRAWBASE_HXX #include <drawbase.hxx> -#endif -#ifndef _CONRECT_HXX #include <conrect.hxx> -#endif + /************************************************************************* |* @@ -119,7 +112,7 @@ BOOL ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt) case OBJ_TEXT: if( bMarquee ) { - m_pSh->ChgAnchor(FLY_IN_CNTNT); + m_pSh->ChgAnchor(FLY_AS_CHAR); if( pObj ) { diff --git a/sw/source/ui/ribbar/drawbase.cxx b/sw/source/ui/ribbar/drawbase.cxx index e79d25ec9f..89bfd4081d 100644 --- a/sw/source/ui/ribbar/drawbase.cxx +++ b/sw/source/ui/ribbar/drawbase.cxx @@ -344,7 +344,8 @@ BOOL SwDrawBase::MouseButtonUp(const MouseEvent& rMEvt) if ( xRecorder.is() ) { SfxRequest aReq(m_pSh->GetView().GetViewFrame(),FN_INSERT_FRAME); - aReq.AppendItem(SfxUInt16Item( FN_INSERT_FRAME, (USHORT)FLY_AT_CNTNT )); + aReq.AppendItem(SfxUInt16Item( FN_INSERT_FRAME, + static_cast<USHORT>(FLY_AT_PARA) )); aReq.AppendItem(SfxPointItem( FN_PARAM_1, m_pSh->GetAnchorObjDiff())); aReq.AppendItem(SvxSizeItem( FN_PARAM_2, m_pSh->GetObjSize())); aReq.Done(); diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx index 993772ad76..50add375c8 100644 --- a/sw/source/ui/shells/basesh.cxx +++ b/sw/source/ui/shells/basesh.cxx @@ -100,9 +100,7 @@ #include <tblafmt.hxx> #include <caption.hxx> #include <swwait.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif #ifndef _GLOBALS_HRC #include <globals.hrc> #endif @@ -1063,14 +1061,14 @@ void SwBaseShell::Execute(SfxRequest &rReq) case FN_TOOL_ANKER_FRAME: { RndStdIds eSet = nSlot == FN_TOOL_ANKER_PAGE - ? FLY_PAGE + ? FLY_AT_PAGE : nSlot == FN_TOOL_ANKER_PARAGRAPH - ? FLY_AT_CNTNT + ? FLY_AT_PARA : nSlot == FN_TOOL_ANKER_FRAME ? FLY_AT_FLY : nSlot == FN_TOOL_ANKER_CHAR - ? FLY_IN_CNTNT - : FLY_AUTO_CNTNT; + ? FLY_AS_CHAR + : FLY_AT_CHAR; rSh.StartUndo(); if( rSh.IsObjSelected() ) rSh.ChgAnchor( eSet ); @@ -1101,7 +1099,7 @@ void SwBaseShell::Execute(SfxRequest &rReq) switch( eSet ) { case FLY_AT_FLY: - case FLY_PAGE: + case FLY_AT_PAGE: //Durchlauf, links oder von links, oben, von oben if(eSurround != SURROUND_THROUGHT) @@ -1114,7 +1112,7 @@ void SwBaseShell::Execute(SfxRequest &rReq) aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT)); break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: //links, von links, rechts, oben, kein Uml, li+re Umlauf, if(eSurround != SURROUND_LEFT || eSurround != SURROUND_RIGHT) aSet.Put(SwFmtSurround(SURROUND_LEFT)); @@ -1126,7 +1124,7 @@ void SwBaseShell::Execute(SfxRequest &rReq) aSet.Put(SwFmtHoriOrient(0, text::HoriOrientation::LEFT)); break; - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: //links, von links, rechts, oben, Durchlauf if(eSurround != SURROUND_THROUGHT) aSet.Put(SwFmtSurround(SURROUND_THROUGHT)); @@ -1624,12 +1622,17 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) else rSh.GetFlyFrmAttr(aSet); RndStdIds eSet = ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId(); - BOOL bSet; - bSet = (nWhich == FN_TOOL_ANKER_PAGE && eSet == FLY_PAGE) || - (nWhich == FN_TOOL_ANKER_PARAGRAPH && eSet == FLY_AT_CNTNT) || - (nWhich == FN_TOOL_ANKER_FRAME && eSet == FLY_AT_FLY) || - (nWhich == FN_TOOL_ANKER_AT_CHAR && eSet == FLY_AUTO_CNTNT) || - (nWhich == FN_TOOL_ANKER_CHAR && eSet == FLY_IN_CNTNT); + const BOOL bSet = + ((nWhich == FN_TOOL_ANKER_PAGE) && + (eSet == FLY_AT_PAGE)) + || ((nWhich == FN_TOOL_ANKER_PARAGRAPH) && + (eSet == FLY_AT_PARA)) + || ((nWhich == FN_TOOL_ANKER_FRAME) && + (eSet == FLY_AT_FLY)) + || ((nWhich == FN_TOOL_ANKER_AT_CHAR) && + (eSet == FLY_AT_CHAR)) + || ((nWhich == FN_TOOL_ANKER_CHAR) && + (eSet == FLY_AS_CHAR)); if(nWhich != FN_TOOL_ANKER) { USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); @@ -1646,16 +1649,16 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) switch (eSet) { - case FLY_PAGE: + case FLY_AT_PAGE: nSlotId = FN_TOOL_ANKER_PAGE; break; - case FLY_AT_CNTNT: + case FLY_AT_PARA: nSlotId = FN_TOOL_ANKER_PARAGRAPH; break; - case FLY_IN_CNTNT: + case FLY_AS_CHAR: nSlotId = FN_TOOL_ANKER_CHAR; break; - case FLY_AUTO_CNTNT: + case FLY_AT_CHAR: nSlotId = FN_TOOL_ANKER_AT_CHAR; break; case FLY_AT_FLY: @@ -1705,15 +1708,18 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) SwSurround nSurround = rWrap.GetSurround(); BOOL bSet = FALSE; - BOOL bDisable = nAnchorType == - 1 || nAnchorType == FLY_IN_CNTNT; - BOOL bHtmlMode = 0 != ::GetHtmlMode(GetView().GetDocShell()); + bool bDisable = + (nAnchorType == - 1) || (nAnchorType == FLY_AS_CHAR); + const bool bHtmlMode = + 0 != ::GetHtmlMode(GetView().GetDocShell()); switch( nWhich ) { case FN_FRAME_NOWRAP: bDisable |= - ( nAnchorType != FLY_AT_CNTNT && - nAnchorType != FLY_AUTO_CNTNT && nAnchorType != FLY_PAGE); + ( (nAnchorType != FLY_AT_PARA) + && (nAnchorType != FLY_AT_CHAR) + && (nAnchorType != FLY_AT_PAGE)); bSet = nSurround == SURROUND_NONE; break; case FN_FRAME_WRAP: @@ -1726,7 +1732,9 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) break; case FN_FRAME_WRAPTHRU: bDisable |= (bHtmlMode || - (nAnchorType != FLY_AT_CNTNT&& nAnchorType != FLY_AUTO_CNTNT && nAnchorType != FLY_PAGE)); + ( (nAnchorType != FLY_AT_PARA) + && (nAnchorType != FLY_AT_CHAR) + && (nAnchorType != FLY_AT_PAGE))); if(bObj) bSet = nSurround == SURROUND_THROUGHT && rSh.GetLayerId(); else @@ -1766,7 +1774,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) break; case FN_WRAP_ANCHOR_ONLY: bDisable |= (bHtmlMode || - (nAnchorType != FLY_AT_CNTNT)); + (nAnchorType != FLY_AT_PARA)); bSet = rWrap.IsAnchorOnly(); break; case FN_FRAME_WRAP_LEFT: diff --git a/sw/source/ui/shells/drwbassh.cxx b/sw/source/ui/shells/drwbassh.cxx index 2b5aa3db2a..c5f0cb2a35 100644 --- a/sw/source/ui/shells/drwbassh.cxx +++ b/sw/source/ui/shells/drwbassh.cxx @@ -49,9 +49,7 @@ #include <svx/htmlmode.hxx> #include <uitool.hxx> #include <fmtornt.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif #include <swmodule.hxx> #include <wrtsh.hxx> #include <wview.hxx> @@ -479,7 +477,7 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq) { // Objekte nicht aneinander ausrichten USHORT nAnchor = pSh->GetAnchorId(); - if (nAnchor == FLY_IN_CNTNT) + if (nAnchor == FLY_AS_CHAR) { sal_Int16 nVertOrient = -1; @@ -509,7 +507,7 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq) } break; } - if (nAnchor == FLY_AT_CNTNT) + if (nAnchor == FLY_AT_PARA) break; // Absatzverankerte Rahmen nicht ausrichten } @@ -855,7 +853,7 @@ IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation pValidation->nWidth = pValidation->nHeight; pValidation->nHeight = nTmp; } - if ( eAnchorType == FLY_PAGE || eAnchorType == FLY_AT_FLY ) + if ((eAnchorType == FLY_AT_PAGE) || (eAnchorType == FLY_AT_FLY)) { // MinimalPosition pValidation->nMinHPos = aBoundRect.Left(); @@ -903,7 +901,7 @@ IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation pValidation->nMaxVPos = aBoundRect.Bottom() - pValidation->nHeight; pValidation->nMaxWidth = aBoundRect.Right() - nH; } - else if ( eAnchorType == FLY_AT_CNTNT || eAnchorType == FLY_AUTO_CNTNT ) + else if ((eAnchorType == FLY_AT_PARA) || (eAnchorType == FLY_AT_CHAR)) { if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right()) { @@ -964,7 +962,7 @@ IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation pValidation->nMaxHeight = pValidation->nMaxVPos + pValidation->nHeight - nV; pValidation->nMaxWidth = pValidation->nMaxHPos + pValidation->nWidth - nH; } - else if ( eAnchorType == FLY_IN_CNTNT ) + else if (eAnchorType == FLY_AS_CHAR) { pValidation->nMinHPos = 0; pValidation->nMaxHPos = 0; diff --git a/sw/source/ui/shells/drwtxtsh.cxx b/sw/source/ui/shells/drwtxtsh.cxx index 1d7f5bbd84..a1012eac8c 100644 --- a/sw/source/ui/shells/drwtxtsh.cxx +++ b/sw/source/ui/shells/drwtxtsh.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> #include <i18npool/lang.h> #include <svl/slstitm.hxx> @@ -53,7 +54,6 @@ #include <svx/outliner.hxx> #include <svx/editstat.hxx> #include <svx/svdoutl.hxx> -#include <unoobj.hxx> #include <com/sun/star/i18n/TransliterationModules.hpp> #include <com/sun/star/i18n/TextConversionOption.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> @@ -67,12 +67,8 @@ #include <swundo.hxx> #include <breakit.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _HELPID_H #include <helpid.h> -#endif #ifndef _GLOBALS_HRC #include <globals.hrc> #endif diff --git a/sw/source/ui/shells/tabsh.cxx b/sw/source/ui/shells/tabsh.cxx index 0ce16da163..d86a79f0e9 100644 --- a/sw/source/ui/shells/tabsh.cxx +++ b/sw/source/ui/shells/tabsh.cxx @@ -108,16 +108,12 @@ #ifndef _TABLE_HRC #include <table.hrc> #endif -#ifndef _CMDID_H #include <cmdid.h> -#endif #ifndef _GLOBALS_HRC #include <globals.hrc> #endif -#ifndef _HELPID_H #include <helpid.h> -#endif -#include <unoobj.hxx> +#include <unobaseclass.hxx> #define SwTableShell #include <sfx2/msg.hxx> diff --git a/sw/source/ui/shells/textdrw.cxx b/sw/source/ui/shells/textdrw.cxx index 92704d307d..0cb414385a 100644 --- a/sw/source/ui/shells/textdrw.cxx +++ b/sw/source/ui/shells/textdrw.cxx @@ -39,23 +39,17 @@ #include <com/sun/star/form/FormButtonType.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <wrtsh.hxx> #include <edtwin.hxx> #include <swundo.hxx> -#ifndef _BASESH_HXX #include <basesh.hxx> -#endif #ifndef _POOLFMT_HRC #include <poolfmt.hrc> #endif -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <sfx2/docfile.hxx> #include <svl/urihelper.hxx> #include <avmedia/mediawindow.hxx> diff --git a/sw/source/ui/shells/textidx.cxx b/sw/source/ui/shells/textidx.cxx index 643169e309..8e88eded78 100644 --- a/sw/source/ui/shells/textidx.cxx +++ b/sw/source/ui/shells/textidx.cxx @@ -32,9 +32,7 @@ #include "precompiled_sw.hxx" #include <hintids.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <sfx2/request.hxx> #include <sfx2/viewfrm.hxx> #include <svl/stritem.hxx> @@ -55,6 +53,8 @@ #include "swabstdlg.hxx" #include <index.hrc> #include <globals.hrc> + + // STATIC DATA ----------------------------------------------------------- void SwTextShell::ExecIdx(SfxRequest &rReq) @@ -136,7 +136,7 @@ void SwTextShell::ExecIdx(SfxRequest &rReq) 0 ); SwWrtShell& rSh = GetShell(); SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nWidth = aRect.Width(); aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); diff --git a/sw/source/ui/shells/textsh.cxx b/sw/source/ui/shells/textsh.cxx index 79bc6334e3..fe9cda4f7c 100644 --- a/sw/source/ui/shells/textsh.cxx +++ b/sw/source/ui/shells/textsh.cxx @@ -39,9 +39,7 @@ #include <sfx2/objface.hxx> #include <sfx2/lnkbase.hxx> -#ifndef __RSC //autogen #include <tools/errinf.hxx> -#endif #include <svx/svdview.hxx> #include <svl/ptitem.hxx> #include <svl/stritem.hxx> @@ -82,9 +80,7 @@ #include <docsh.hxx> #include <doc.hxx> #include <uitool.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif #ifndef _GLOBALS_HRC #include <globals.hrc> #endif @@ -112,9 +108,7 @@ #ifndef _POPUP_HRC #include <popup.hrc> #endif -#ifndef _SWERROR_H #include <swerror.h> -#endif #include <SwAppletImpl.hxx> #include <unochart.hxx> @@ -566,7 +560,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() ); aMgr.SetCol( aCol ); } - aMgr.InsertFlyFrm(FLY_AT_CNTNT, aStartPos, aSize); + aMgr.InsertFlyFrm(FLY_AT_PARA, aStartPos, aSize); GetShell().EndAllAction(); GetShell().UnlockPaint(); } @@ -600,7 +594,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) Size aSize(aMgr.GetSize()); aSize.Width() = GetShell().GetAnyCurRect(RECT_PAGE_PRT).Width(); Point aPos = aMgr.GetPos(); - RndStdIds eAnchor = FLY_AT_CNTNT; + RndStdIds eAnchor = FLY_AT_PARA; if(pArgs->GetItemState(nSlot, FALSE, &pItem) == SFX_ITEM_SET) eAnchor = (RndStdIds)((SfxUInt16Item *)pItem)->GetValue(); if(pArgs->GetItemState(FN_PARAM_1, FALSE, &pItem) == SFX_ITEM_SET) @@ -764,7 +758,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq) SwFlyFrmAttrMgr aFrmMgr( TRUE, &rSh, FRMMGR_TYPE_GRF ); // am FrmMgr muessen die richtigen Parameter eingestellt werden - aFrmMgr.SetAnchor(FLY_IN_CNTNT); + aFrmMgr.SetAnchor(FLY_AS_CHAR); rSh.SplitNode( FALSE, FALSE ); rSh.SplitNode( FALSE, FALSE ); diff --git a/sw/source/ui/table/chartins.cxx b/sw/source/ui/table/chartins.cxx index c8a836cc43..1032536616 100644 --- a/sw/source/ui/table/chartins.cxx +++ b/sw/source/ui/table/chartins.cxx @@ -33,9 +33,7 @@ #include <sfx2/viewfrm.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <sfx2/dispatch.hxx> #include <sfx2/basedlgs.hxx> #include <IDocumentUndoRedo.hxx> @@ -45,24 +43,19 @@ #include <swmodule.hxx> #include <wrtsh.hxx> #include <docsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <chartins.hxx> #include <tablemgr.hxx> #include <frmfmt.hxx> #include <swtable.hxx> #include <tblsel.hxx> -#include <unoobj.hxx> #include <unochart.hxx> #include <autoedit.hxx> #include <doc.hxx> #include <edtwin.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif #ifndef _CHARTINS_HRC #include <chartins.hrc> #endif diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index 15338aa201..cac139f875 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -34,12 +34,6 @@ #include <com/sun/star/util/SearchFlags.hpp> #include <com/sun/star/i18n/TransliterationModules.hpp> -// #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_ -// #include <com/sun/star/lang/Locale.hpp> -// #endif -// #ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKER_HPP_ -// #include <com/sun/star/ui/dialogs/XFilePicker.hpp> -// #endif #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp> @@ -49,9 +43,6 @@ #include <svl/svstdarr.hxx> #include <svl/aeitem.hxx> -// #ifndef _FILTER_HXX -// #include <svtools/filter.hxx> -// #endif #include <SwStyleNameMapper.hxx> #include <docary.hxx> #include <hintids.hxx> @@ -69,12 +60,8 @@ #include <svx/viewlayoutitem.hxx> #include <svx/zoomslideritem.hxx> #include <svx/htmlmode.hxx> -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <sfx2/app.hxx> #include <sfx2/request.hxx> #include <sfx2/bindings.hxx> @@ -94,9 +81,7 @@ #include <svl/whiter.hxx> #include <svl/ptitem.hxx> #include <svx/linkmgr.hxx> -#ifndef __RSC //autogen #include <tools/errinf.hxx> -#endif #include <tools/urlobj.hxx> #include <svx/svdview.hxx> #include <swtypes.hxx> @@ -148,10 +133,6 @@ #include <PostItMgr.hxx> #include <postit.hxx> -// #ifndef _FRMMGR_HXX -// #include <frmmgr.hxx> -// #endif - #include <ndtxt.hxx> //#outline level,added by zhaojianwei #include <comphelper/processfactory.hxx> diff --git a/sw/source/ui/uiview/viewtab.cxx b/sw/source/ui/uiview/viewtab.cxx index 9e4c4060fe..c1f532748e 100644 --- a/sw/source/ui/uiview/viewtab.cxx +++ b/sw/source/ui/uiview/viewtab.cxx @@ -347,7 +347,7 @@ void SwView::ExecTabWin( SfxRequest& rReq ) if(aSize.GetWidthPercent()) { SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nPrtWidth = aRect.Width(); aSize.SetWidthPercent(BYTE((nPageWidth - aLongLR.GetLeft() - aLongLR.GetRight()) * 100 /nPrtWidth)); } @@ -472,7 +472,7 @@ void SwView::ExecTabWin( SfxRequest& rReq ) if(aSize.GetHeightPercent()) { SwRect aRect; - rSh.CalcBoundRect(aRect, FLY_IN_CNTNT); + rSh.CalcBoundRect(aRect, FLY_AS_CHAR); long nPrtHeight = aRect.Height(); aSize.SetHeightPercent(BYTE(nHeight * 100 /nPrtHeight)); } diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx index a3fbd23474..88b9e291a4 100644 --- a/sw/source/ui/uno/SwXDocumentSettings.cxx +++ b/sw/source/ui/uno/SwXDocumentSettings.cxx @@ -30,16 +30,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <vos/mutex.hxx> #include <sfx2/sfxbasecontroller.hxx> #include <SwXDocumentSettings.hxx> #include <SwXPrintPreviewSettings.hxx> -#ifndef _COMPHELPER_MASTERPROPERTSETINFO_HXX_ #include <comphelper/MasterPropertySetInfo.hxx> -#endif -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif #include <com/sun/star/i18n/XForbiddenCharacters.hpp> #include <com/sun/star/document/PrinterIndependentLayout.hpp> #include <doc.hxx> @@ -50,7 +47,6 @@ #include <editsh.hxx> #include <drawdoc.hxx> #include <svl/zforlist.hxx> -#include <unoobj.hxx> #include <unotxdoc.hxx> #include <cmdid.h> #include <svx/zoomitem.hxx> diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index df941b500a..74158364f2 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -34,10 +34,7 @@ #define _SVSTDARR_STRINGS - -#ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif #include <vos/mutex.hxx> #include <tools/debug.hxx> #include <vcl/svapp.hxx> @@ -52,7 +49,10 @@ #include <gloslst.hxx> #include <unoatxt.hxx> #include <unomap.hxx> -#include <unoobj.hxx> +#include <unomid.h> +#include <unotextbodyhf.hxx> +#include <unotextrange.hxx> +#include <TextCursorHelper.hxx> #include <swevent.hxx> #include <doc.hxx> #include <unocrsr.hxx> @@ -68,6 +68,7 @@ #include <memory> + SV_IMPL_REF ( SwDocShell ) using namespace ::com::sun::star; using ::rtl::OUString; @@ -410,25 +411,25 @@ sal_Bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextR SwCntntNode * pNd = aIdx.GetNode().GetCntntNode(); SwPosition aPos( aIdx, SwIndex( pNd, pNd->Len() )); - sal_Bool bRet = sal_False; + bool bRet = false; pInsDoc->LockExpFlds(); { + SwDoc *const pDoc((pxCursor) ? pxCursor->GetDoc() : pxRange->GetDoc()); + SwPaM aPam(pDoc->GetNodes()); + SwPaM * pPam(0); if(pxCursor) { - SwPaM* pUnoCrsr = pxCursor->GetPaM(); - bRet = pxCursor->GetDoc()->CopyRange( *pUnoCrsr, aPos, false ) - || bRet; + pPam = pxCursor->GetPaM(); } else { - const ::sw::mark::IMark* const pBkmk = pxRange->GetBookmark(); - if(pBkmk && pBkmk->IsExpanded()) + if (pxRange->GetPositions(aPam)) { - SwPaM aTmp(pBkmk->GetOtherMarkPos(), pBkmk->GetMarkPos()); - bRet = pxRange->GetDoc()->CopyRange(aTmp, aPos, false) - || bRet; + pPam = & aPam; } } + if (!pPam) { return false; } + bRet = pDoc->CopyRange( *pPam, aPos, false ) || bRet; } pInsDoc->UnlockExpFlds(); @@ -1112,7 +1113,7 @@ void SwXAutoTextEntry::applyTo(const uno::Reference< text::XTextRange > & xTextR } SwDoc* pDoc = 0; - if ( pRange && pRange->GetBookmark()) + if (pRange) pDoc = pRange->GetDoc(); else if ( pCursor ) pDoc = pCursor->GetDoc(); @@ -1130,29 +1131,23 @@ void SwXAutoTextEntry::applyTo(const uno::Reference< text::XTextRange > & xTextR if(!pDoc) throw uno::RuntimeException(); - SwPaM* pInsertPaM = 0; - if(pRange) + + SwPaM InsertPaM(pDoc->GetNodes()); + if (pRange) { - const ::sw::mark::IMark* const pBkmk = pRange->GetBookmark(); - if(pBkmk->IsExpanded()) - pInsertPaM = new SwPaM(pBkmk->GetOtherMarkPos(), pBkmk->GetMarkPos()); - else - pInsertPaM = new SwPaM(pBkmk->GetMarkPos()); + if (!pRange->GetPositions(InsertPaM)) + { + throw uno::RuntimeException(); + } } else { - SwPaM* pCrsr = pCursor->GetPaM(); - if(pCrsr->HasMark()) - pInsertPaM = new SwPaM(*pCrsr->GetPoint(), *pCrsr->GetMark()); - else - pInsertPaM = new SwPaM(*pCrsr->GetPoint()); + InsertPaM = *pCursor->GetPaM(); } - SwTextBlocks* pBlock = pGlossaries->GetGroupDoc(sGroupName); - sal_Bool bResult = pBlock && !pBlock->GetError() && - pDoc->InsertGlossary( *pBlock, sEntryName, *pInsertPaM); - delete pBlock; - delete pInsertPaM; + ::std::auto_ptr<SwTextBlocks> pBlock(pGlossaries->GetGroupDoc(sGroupName)); + const bool bResult = pBlock.get() && !pBlock->GetError() + && pDoc->InsertGlossary( *pBlock, sEntryName, InsertPaM); if(!bResult) throw uno::RuntimeException(); diff --git a/sw/source/ui/uno/unodispatch.cxx b/sw/source/ui/uno/unodispatch.cxx index 44b82239b1..02e669d3b2 100644 --- a/sw/source/ui/uno/unodispatch.cxx +++ b/sw/source/ui/uno/unodispatch.cxx @@ -31,17 +31,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <vcl/svapp.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/dispatch.hxx> +#include <svx/dataaccessdescriptor.hxx> + #include <unodispatch.hxx> -#include <unoobj.hxx> +#include <unobaseclass.hxx> #include <view.hxx> #include <cmdid.h> #include "wrtsh.hxx" #include "dbmgr.hxx" -#include <svx/dataaccessdescriptor.hxx> + using namespace ::com::sun::star; using namespace rtl; diff --git a/sw/source/ui/uno/unomod.cxx b/sw/source/ui/uno/unomod.cxx index e06733b6cb..4d077c5b9f 100644 --- a/sw/source/ui/uno/unomod.cxx +++ b/sw/source/ui/uno/unomod.cxx @@ -35,7 +35,7 @@ #include <swtypes.hxx> #include <tools/debug.hxx> #include <unomod.hxx> -#include <unoobj.hxx> +#include <unomid.h> #include <unoprnms.hxx> #include <unomap.hxx> #include <prtopt.hxx> diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index b75f8af5f6..c46d668dac 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -53,7 +53,10 @@ #include <svl/stritem.hxx> #include <unotxdoc.hxx> #include <svl/numuno.hxx> -#include <unoobj.hxx> +#include <fldbas.hxx> +#include <unotextbodyhf.hxx> +#include <unotextrange.hxx> +#include <unotextcursor.hxx> #include <unosett.hxx> #include <unocoll.hxx> #include <unoredlines.hxx> @@ -764,19 +767,12 @@ Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor( SwUnoCrsr* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xCrsr) { getText(); - XText* pText = xBodyText.get(); + XText *const pText = xBodyText.get(); SwXBodyText* pBText = (SwXBodyText*)pText; - xCrsr = pBText->CreateTextCursor(sal_True); + SwXTextCursor *const pXTextCursor = pBText->CreateTextCursor(true); + xCrsr.set( static_cast<text::XWordCursor*>(pXTextCursor) ); - Reference<XUnoTunnel> xRangeTunnel( xCrsr, UNO_QUERY); - SwXTextCursor* pxUnoCrsr = 0; - if(xRangeTunnel.is()) - { - pxUnoCrsr = reinterpret_cast<SwXTextCursor*>(xRangeTunnel->getSomething( - SwXTextCursor::getUnoTunnelId())); - } - - SwUnoCrsr* pUnoCrsr = pxUnoCrsr->GetCrsr(); + SwUnoCrsr *const pUnoCrsr = pXTextCursor->GetCursor(); pUnoCrsr->SetRemainInSection(sal_False); return pUnoCrsr; } @@ -1007,10 +1003,7 @@ Reference< XIndexAccess > if(!pResultCrsr) throw RuntimeException(); Reference< XIndexAccess > xRet; - if(nResult) - xRet = new SwXTextRanges(pResultCrsr); - else - xRet = new SwXTextRanges(); + xRet = new SwXTextRanges( (nResult) ? pResultCrsr : 0 ); delete pResultCrsr; return xRet; } @@ -1030,11 +1023,10 @@ Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSear Reference< XInterface > xRet; if(nResult) { - Reference< XTextRange > xTempRange = SwXTextRange::CreateTextRangeFromPosition( - pDocShell->GetDoc(), - *pResultCrsr->GetPoint(), - pResultCrsr->GetMark()); - xRet = *new SwXTextCursor(xTempRange->getText(), pResultCrsr); + const uno::Reference< text::XText > xParent = + ::sw::CreateParentXText(*pDocShell->GetDoc(), + *pResultCrsr->GetPoint()); + xRet = *new SwXTextCursor(xParent, *pResultCrsr); delete pResultCrsr; } return xRet; @@ -1058,12 +1050,11 @@ Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface > Reference< XInterface > xRet; if(nResult) { - Reference< XTextRange > xTempRange = SwXTextRange::CreateTextRangeFromPosition( - pDocShell->GetDoc(), - *pResultCrsr->GetPoint(), - pResultCrsr->GetMark()); + const uno::Reference< text::XText > xParent = + ::sw::CreateParentXText(*pDocShell->GetDoc(), + *pResultCrsr->GetPoint()); - xRet = *new SwXTextCursor(xTempRange->getText(), pResultCrsr); + xRet = *new SwXTextCursor(xParent, *pResultCrsr); delete pResultCrsr; } return xRet; diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 6bcf01d50f..e2b40a8a9e 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -77,6 +77,10 @@ #include <SwStyleNameMapper.hxx> #include <crsskip.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> +#include <unobookmark.hxx> +#include <unoparagraph.hxx> +#include <unocrsrhelper.hxx> +#include <unotextrange.hxx> #include <svx/editview.hxx> #include <sfx2/docfile.hxx> @@ -104,24 +108,8 @@ SV_IMPL_PTRARR( SelectionChangeListenerArr, XSelectionChangeListenerPtr ); * --------------------------------------------------*/ SwPaM* lcl_createPamCopy(const SwPaM& rPam) { - SwPaM* pRet = new SwPaM(*rPam.GetPoint()); - if(rPam.HasMark()) - { - pRet->SetMark(); - *pRet->GetMark() = *rPam.GetMark(); - } - if(rPam.GetNext() != (const Ring*)&rPam) - { - SwPaM *_pStartCrsr = (SwPaM *)rPam.GetNext(); - do - { - //neuen PaM erzeugen - SwPaM* pPaM = new SwPaM(*_pStartCrsr); - //und in den Ring einfuegen - pPaM->MoveTo(pRet); - - } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != rPam.GetNext() ); - } + SwPaM *const pRet = new SwPaM(*rPam.GetPoint()); + ::sw::DeepCopyPaM(rPam, *pRet); return pRet; } /****************************************************************** @@ -329,8 +317,9 @@ sal_Bool SwXTextView::select(const uno::Any& aInterface) throw( lang::IllegalArg : 0; if(pCursor && pCursor->GetDoc() == GetView()->GetDocShell()->GetDoc()) - pPam = lcl_createPamCopy(*((SwXTextCursor*)pCursor)->GetPaM()); - + { + pPam = lcl_createPamCopy(*pCursor->GetPaM()); + } } else if(xPosN.is() && xIfcTunnel.is() && @@ -346,7 +335,7 @@ sal_Bool SwXTextView::select(const uno::Any& aInterface) throw( lang::IllegalArg else if(!pFrame && !pCell && xPos.is()) { SwUnoInternalPaM aPam(*pDoc); - if(SwXTextRange::XTextRangeToSwPaM(aPam, xPos)) + if (::sw::XTextRangeToSwPaM(aPam, xPos)) { pPam = lcl_createPamCopy(aPam); } @@ -429,19 +418,14 @@ sal_Bool SwXTextView::select(const uno::Any& aInterface) throw( lang::IllegalArg if(xBkm.is() && xIfcTunnel.is()) { - SwXBookmark* pBkm = reinterpret_cast<SwXBookmark*>( - xIfcTunnel->getSomething(SwXBookmark::getUnoTunnelId())); - if(pBkm && pBkm->GetDoc() == pDoc) + ::sw::mark::IMark const*const pMark( + SwXBookmark::GetBookmarkInDoc(pDoc, xIfcTunnel) ); + if (pMark) { - IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess(); - IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->findMark(pBkm->getName()); - if( ppMark != pMarkAccess->getMarksEnd() ) - { - rSh.EnterStdMode(); - rSh.GotoMark( ppMark->get() ); - } - return sal_True; + rSh.EnterStdMode(); + rSh.GotoMark(pMark); } + return sal_True; } // IndexMark, Index, TextField, Draw, Section, Footnote, Paragraph // @@ -1379,8 +1363,10 @@ void SwXTextViewCursor::gotoRange( throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) ); SwUnoInternalPaM rDestPam(*m_pView->GetDocShell()->GetDoc()); - if(!SwXTextRange::XTextRangeToSwPaM( rDestPam, xRange)) - throw IllegalArgumentException(); + if (!::sw::XTextRangeToSwPaM(rDestPam, xRange)) + { + throw uno::RuntimeException(); + } ShellModes eSelMode = m_pView->GetShellMode(); SwWrtShell& rSh = m_pView->GetWrtShell(); @@ -1435,10 +1421,13 @@ void SwXTextViewCursor::gotoRange( { pSrcNode = pCursor->GetPaM()->GetNode(); } - else if(pRange && pRange->GetBookmark()) + else if (pRange) { - const ::sw::mark::IMark* const pBkmk = pRange->GetBookmark(); - pSrcNode = &(pBkmk->GetMarkPos().nNode.GetNode()); + SwPaM aPam(pRange->GetDoc()->GetNodes()); + if (pRange->GetPositions(aPam)) + { + pSrcNode = aPam.GetNode(); + } } else if (pPara && pPara->GetTxtNode()) { @@ -1713,9 +1702,7 @@ uno::Reference< text::XText > SwXTextViewCursor::getText(void) throw( uno::Runt SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); - uno::Reference< text::XTextRange > xRg = SwXTextRange::CreateTextRangeFromPosition(pDoc, - *pShellCrsr->Start(), 0); - xRet = xRg->getText(); + xRet = ::sw::CreateParentXText(*pDoc, *pShellCrsr->Start()); } else throw uno::RuntimeException(); @@ -1736,8 +1723,7 @@ uno::Reference< text::XTextRange > SwXTextViewCursor::getStart(void) throw( uno SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); - xRet = SwXTextRange::CreateTextRangeFromPosition(pDoc, - *pShellCrsr->Start(), 0); + xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->Start(), 0); } else throw uno::RuntimeException(); @@ -1758,8 +1744,7 @@ uno::Reference< text::XTextRange > SwXTextViewCursor::getEnd(void) throw( uno:: SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); - xRet = SwXTextRange::CreateTextRangeFromPosition(pDoc, - *pShellCrsr->End(), 0); + xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->End(), 0); } else throw uno::RuntimeException(); @@ -1791,7 +1776,7 @@ OUString SwXTextViewCursor::getString(void) throw( uno::RuntimeException ) { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - SwXTextCursor::getTextFromPam(*pShellCrsr, uRet); + SwUnoCursorHelper::GetTextFromPam(*pShellCrsr, uRet); } default:;//prevent warning } @@ -1823,7 +1808,7 @@ void SwXTextViewCursor::setString(const OUString& aString) throw( uno::RuntimeEx { SwWrtShell& rSh = m_pView->GetWrtShell(); SwCursor* pShellCrsr = rSh.GetSwCrsr(); - SwXTextCursor::SetString( *pShellCrsr, aString ); + SwUnoCursorHelper::SetString(*pShellCrsr, aString); } default:;//prevent warning } @@ -1852,7 +1837,10 @@ void SwXTextViewCursor::setPropertyValue( const OUString& rPropertyName, const SwPaM* pShellCrsr = rSh.GetCrsr(); SwNode *pNode = pShellCrsr->GetNode(); if (pNode && pNode->IsTxtNode()) - SwXTextCursor::SetPropertyValue(*pShellCrsr, *m_pPropSet, rPropertyName, aValue ); + { + SwUnoCursorHelper::SetPropertyValue( + *pShellCrsr, *m_pPropSet, rPropertyName, aValue ); + } else throw RuntimeException(); } @@ -1871,7 +1859,8 @@ Any SwXTextViewCursor::getPropertyValue( const OUString& rPropertyName ) { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - aRet = SwXTextCursor::GetPropertyValue( *pShellCrsr, *m_pPropSet, rPropertyName); + aRet = SwUnoCursorHelper::GetPropertyValue( + *pShellCrsr, *m_pPropSet, rPropertyName); } else throw RuntimeException(); @@ -1920,7 +1909,8 @@ PropertyState SwXTextViewCursor::getPropertyState( const OUString& rPropertyNam { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - eState = SwXTextCursor::GetPropertyState( *pShellCrsr, *m_pPropSet, rPropertyName); + eState = SwUnoCursorHelper::GetPropertyState( + *pShellCrsr, *m_pPropSet, rPropertyName); } else throw RuntimeException(); @@ -1938,7 +1928,8 @@ Sequence< PropertyState > SwXTextViewCursor::getPropertyStates( { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - aRet = SwXTextCursor::GetPropertyStates(*pShellCrsr, *m_pPropSet, rPropertyNames); + aRet = SwUnoCursorHelper::GetPropertyStates( + *pShellCrsr, *m_pPropSet, rPropertyNames); } return aRet; } @@ -1953,7 +1944,8 @@ void SwXTextViewCursor::setPropertyToDefault( const OUString& rPropertyName ) { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - SwXTextCursor::SetPropertyToDefault( *pShellCrsr, *m_pPropSet, rPropertyName); + SwUnoCursorHelper::SetPropertyToDefault( + *pShellCrsr, *m_pPropSet, rPropertyName); } } /*-- 29.06.00 17:33:43--------------------------------------------------- @@ -1968,7 +1960,8 @@ Any SwXTextViewCursor::getPropertyDefault( const OUString& rPropertyName ) { SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCrsr = rSh.GetCrsr(); - aRet = SwXTextCursor::GetPropertyDefault( *pShellCrsr, *m_pPropSet, rPropertyName); + aRet = SwUnoCursorHelper::GetPropertyDefault( + *pShellCrsr, *m_pPropSet, rPropertyName); } return aRet; } diff --git a/sw/source/ui/utlui/attrdesc.cxx b/sw/source/ui/utlui/attrdesc.cxx index a25d2c801d..75b8b6188a 100644 --- a/sw/source/ui/utlui/attrdesc.cxx +++ b/sw/source/ui/utlui/attrdesc.cxx @@ -53,9 +53,7 @@ #include <fmturl.hxx> #include <fmthdft.hxx> #include <fmtcnct.hxx> -#ifndef _FMTLINE_HXX #include <fmtline.hxx> -#endif #include <tgrditem.hxx> #include <hfspacingitem.hxx> #include <fmtruby.hxx> @@ -687,13 +685,13 @@ SfxItemPresentation SwFmtAnchor::GetPresentation USHORT nId = 0; switch ( GetAnchorId() ) { - case FLY_AT_CNTNT: //Absatzgebundener Rahmen + case FLY_AT_PARA: nId = STR_FLY_AT_CNTNT; break; - case FLY_IN_CNTNT: //Zeichengebundener Rahmen + case FLY_AS_CHAR: nId = STR_FLY_IN_CNTNT; break; - case FLY_PAGE: //Seitengebundener Rahmen + case FLY_AT_PAGE: nId = STR_FLY_PAGE; break; default:;//prevent warning diff --git a/sw/source/ui/utlui/swrenamexnameddlg.cxx b/sw/source/ui/utlui/swrenamexnameddlg.cxx index e3340c37f0..1cba05bef1 100644 --- a/sw/source/ui/utlui/swrenamexnameddlg.cxx +++ b/sw/source/ui/utlui/swrenamexnameddlg.cxx @@ -63,7 +63,6 @@ #include <view.hxx> #include <wrtsh.hxx> #include <swmodule.hxx> -#include <unoobj.hxx> #include <unocrsr.hxx> #include "swrenamexnameddlg.hxx" diff --git a/sw/source/ui/utlui/unotools.cxx b/sw/source/ui/utlui/unotools.cxx index 324768ab7d..9e38253d32 100644 --- a/sw/source/ui/utlui/unotools.cxx +++ b/sw/source/ui/utlui/unotools.cxx @@ -59,12 +59,13 @@ #include <view.hxx> #include <wrtsh.hxx> #include <swmodule.hxx> -#include <unoobj.hxx> +#include <TextCursorHelper.hxx> #include <unocrsr.hxx> #include <doc.hxx> #include <unomid.h> + using namespace ::com::sun::star; using ::rtl::OUString; diff --git a/sw/source/ui/wrtsh/select.cxx b/sw/source/ui/wrtsh/select.cxx index 67372ea5d1..e7f0a00645 100644 --- a/sw/source/ui/wrtsh/select.cxx +++ b/sw/source/ui/wrtsh/select.cxx @@ -39,15 +39,9 @@ #include <svl/macitem.hxx> #include <unotools/charclass.hxx> #include <svx/scripttypeitem.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _VIEW_HXX #include <view.hxx> -#endif -#ifndef _BASESH_HXX #include <basesh.hxx> -#endif #include <wrtsh.hxx> #include <frmatr.hxx> #include <initui.hxx> |