diff options
185 files changed, 6547 insertions, 3637 deletions
diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx index 9228e12d992c..eb3559f355ed 100644 --- a/sw/inc/IDocumentContentOperations.hxx +++ b/sw/inc/IDocumentContentOperations.hxx @@ -67,11 +67,19 @@ DOC_NO_DELFRMS = 0x08 }; + // constants for inserting text + enum InsertFlags + { INS_DEFAULT = 0x00 // no extras + , INS_EMPTYEXPAND = 0x01 // expand empty hints at insert position + , INS_NOHINTEXPAND = 0x02 // do not expand any hints at insert pos + , INS_FORCEHINTEXPAND = 0x04 // expand all hints at insert position + }; + public: /** Kopieren eines Bereiches im oder in ein anderes Dokument ! Die Position kann auch im Bereich liegen !! */ - virtual bool Copy(SwPaM&, SwPosition&, bool bCopyAll ) const = 0; + virtual bool CopyRange(SwPaM&, SwPosition&, const bool bCopyAll ) const = 0; /** Loesche die Section, in der der Node steht. */ @@ -79,7 +87,7 @@ /** loeschen eines BereichesSwFlyFrmFmt */ - virtual bool Delete(SwPaM&) = 0; + virtual bool DeleteRange(SwPaM&) = 0; /** loeschen gesamter Absaetze */ @@ -96,34 +104,24 @@ /** verschieben eines Bereiches */ - virtual bool Move(SwPaM&, SwPosition&, SwMoveFlags) = 0; + virtual bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags) = 0; /** verschieben ganzer Nodes */ - virtual bool Move(SwNodeRange&, SwNodeIndex&, SwMoveFlags) = 0; + virtual bool MoveNodeRange(SwNodeRange&, SwNodeIndex&, SwMoveFlags) = 0; /** verschieben eines Bereiches */ virtual bool MoveAndJoin(SwPaM&, SwPosition&, SwMoveFlags) = 0; - /** Ueberschreiben eines einzelnen Zeichens. rRg.Start() bezeichnet - den Node und die Position in dem Node, an der eingefuegt wird, - */ - virtual bool Overwrite(const SwPaM &rRg, sal_Unicode c) = 0; - /** Ueberschreiben eines Strings in einem bestehenden Textnode. */ virtual bool Overwrite(const SwPaM &rRg, const String& rStr) = 0; - /** Einfuegen eines einzelnen Zeichens. rRg.Start() bezeichnet - den Node und die Position in dem Node, an der eingefuegt wird. - */ - virtual bool Insert(const SwPaM &rRg, sal_Unicode c) = 0; - - /** Einfuegen eines Strings in einen bestehenden - Textnode. Der Text wird kopiert. + /** Insert string into existing text node at position rRg.Point(). */ - virtual bool Insert(const SwPaM &rRg, const String&, bool bHintExpand) = 0; + virtual bool InsertString(const SwPaM &rRg, const String&, + const enum InsertFlags nInsertMode = INS_EMPTYEXPAND ) = 0; /** change text to Upper/Lower/Hiragana/Katagana/... */ @@ -171,7 +169,8 @@ z.B.: Fnd: "zzz", Repl: "xx\t\\t..&..\&" --> "xx\t<Tab>..zzz..&" */ - virtual bool Replace(SwPaM& rPam, const String& rNewStr, bool bRegExpRplc) = 0; + virtual bool ReplaceRange(SwPaM& rPam, const String& rNewStr, + const bool bRegExReplace) = 0; /** Einfuegen eines Attributs. Erstreckt sich rRg ueber mehrere Nodes, wird das Attribut aufgespaltet, sofern @@ -187,11 +186,13 @@ hinzugefuegt. Wenn das Attribut nicht eingefuegt werden konnte, liefert die Methode sal_False. */ - virtual bool Insert(const SwPaM &rRg, const SfxPoolItem&, sal_uInt16 nFlags) = 0; + virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&, + const sal_uInt16 nFlags) = 0; /** */ - virtual bool Insert(const SwPaM &rRg, const SfxItemSet&, sal_uInt16 nFlags) = 0; + virtual bool InsertItemSet (const SwPaM &rRg, const SfxItemSet&, + const sal_uInt16 nFlags) = 0; /** Removes any leading white space from the paragraph */ diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 6ae8e73cfb8d..d8cd78622d4c 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -911,6 +911,7 @@ Achtung: Ab sofort sind in diesem File keine C++-Kommentare (//) mehr #define FN_UNO_PARA_CONT_PREV_SUBTREE (FN_EXTRA2 + 109) #define FN_UNO_PARA_NUM_STRING (FN_EXTRA2 + 110) #define FN_UNO_TABLE_NAME (FN_EXTRA2 + 111) +#define FN_UNO_META (FN_EXTRA2 + 112) /*-------------------------------------------------------------------- Bereich: Hilfe diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 35656514a4c8..30faa66f13e1 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -218,6 +218,9 @@ class IGrammarContact; namespace sw { namespace mark { class MarkManager; }} +namespace sw { + class MetaFieldManager; +} namespace com { namespace sun { namespace star { namespace i18n { @@ -298,6 +301,7 @@ class SW_DLLPUBLIC SwDoc : mutable com::sun::star::uno::Reference< com::sun::star::linguistic2::XProofreadingIterator > m_xGCIterator; const ::boost::scoped_ptr< ::sw::mark::MarkManager> pMarkManager; + const ::boost::scoped_ptr< ::sw::MetaFieldManager > m_pMetaFieldManager; // ------------------------------------------------------------------- // die Pointer @@ -614,8 +618,8 @@ private: // nur fuer den internen Gebrauch deshalb privat. // Kopieren eines Bereiches im oder in ein anderes Dokument ! // Die Position darf nicht im Bereich liegen !! - sal_Bool _Copy( SwPaM&, SwPosition&, - sal_Bool MakeNewFrms /*= sal_True*/, bool bCopyAll, SwPaM* pCpyRng /*= 0*/ ) const; // in ndcopy.cxx + bool CopyImpl( SwPaM&, SwPosition&, const bool MakeNewFrms /*= true */, + const bool bCopyAll, SwPaM *const pCpyRng /*= 0*/ ) const; SwFlyFrmFmt* _MakeFlySection( const SwPosition& rAnchPos, const SwCntntNode& rNode, RndStdIds eRequestId, @@ -627,9 +631,10 @@ private: const SfxItemSet* pGrfAttrSet, SwFrmFmt* = 0 ); - void _CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, - const SwNodeIndex& rSttIdx, - sal_Bool bCopyFlyAtFly = sal_False ) const; // steht im ndcopy.cxx + void CopyFlyInFlyImpl( const SwNodeRange& rRg, + const xub_StrLen nEndContentIndex, + const SwNodeIndex& rStartIdx, + const bool bCopyFlyAtFly = false ) const; sal_Int8 SetFlyFrmAnchor( SwFrmFmt& rFlyFmt, SfxItemSet& rSet, sal_Bool bNewFrms ); // --> OD 2005-01-13 #i40550# @@ -639,7 +644,7 @@ private: FNCopyFmt fnCopyFmt, const SwFmt& rDfltFmt ); void CopyFmtArr( const SvPtrarr& rSourceArr, SvPtrarr& rDestArr, FNCopyFmt fnCopyFmt, SwFmt& rDfltFmt ); - void _CopyPageDescHeaderFooter( sal_Bool bCpyHeader, + void CopyPageDescHeaderFooterImpl( bool bCpyHeader, const SwFrmFmt& rSrcFmt, SwFrmFmt& rDestFmt ); SwFmt* FindFmtByName( const SvPtrarr& rFmtArr, const String& rName ) const; @@ -702,6 +707,11 @@ private: void InitTOXTypes(); void Paste( const SwDoc& ); + bool DeleteAndJoinImpl(SwPaM&, const bool); + bool DeleteAndJoinWithRedlineImpl(SwPaM&, const bool unused = false); + bool DeleteRangeImpl(SwPaM&, const bool unused = false); + bool ReplaceRangeImpl(SwPaM&, String const&, const bool); + public: /** Life cycle @@ -878,9 +888,9 @@ public: /** IDocumentContentOperations */ - virtual bool Copy(SwPaM&, SwPosition&, bool bCopyAll) const; + virtual bool CopyRange(SwPaM&, SwPosition&, const bool bCopyAll) const; virtual void DeleteSection(SwNode* pNode); - virtual bool Delete(SwPaM&); + virtual bool DeleteRange(SwPaM&); virtual bool DelFullPara(SwPaM&); // --> OD 2009-08-20 #i100466# // Add optional parameter <bForceJoinNext>, default value <false> @@ -888,13 +898,12 @@ public: virtual bool DeleteAndJoin( SwPaM&, const bool bForceJoinNext = false ); // <-- - virtual bool Move(SwPaM&, SwPosition&, SwMoveFlags); - virtual bool Move(SwNodeRange&, SwNodeIndex&, SwMoveFlags); + virtual bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags); + virtual bool MoveNodeRange(SwNodeRange&, SwNodeIndex&, SwMoveFlags); virtual bool MoveAndJoin(SwPaM&, SwPosition&, SwMoveFlags); - virtual bool Overwrite(const SwPaM &rRg, sal_Unicode c); virtual bool Overwrite(const SwPaM &rRg, const String& rStr); - virtual bool Insert(const SwPaM &rRg, sal_Unicode c); - virtual bool Insert(const SwPaM &rRg, const String&, bool bHintExpand); + virtual bool InsertString(const SwPaM &rRg, const String&, + const enum InsertFlags nInsertMode = INS_EMPTYEXPAND ); virtual SwFlyFrmFmt* Insert(const SwPaM &rRg, const String& rGrfName, const String& rFltName, const Graphic* pGraphic, const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrmFmt*); virtual SwFlyFrmFmt* Insert(const SwPaM& rRg, const GraphicObject& rGrfObj, const SfxItemSet* pFlyAttrSet, @@ -902,8 +911,10 @@ public: virtual SwDrawFrmFmt* Insert(const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet* pFlyAttrSet, SwFrmFmt*); virtual SwFlyFrmFmt* Insert(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrmFmt*); - virtual bool Insert(const SwPaM &rRg, const SfxPoolItem&, sal_uInt16 nFlags); - virtual bool Insert(const SwPaM &rRg, const SfxItemSet&, sal_uInt16 nFlags); + virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&, + const SetAttrMode nFlags); + virtual bool InsertItemSet (const SwPaM &rRg, const SfxItemSet&, + const SetAttrMode nFlags); virtual void ReRead(SwPaM&, const String& rGrfName, const String& rFltName, const Graphic* pGraphic, const GraphicObject* pGrfObj); virtual void TransliterateText(const SwPaM& rPaM, utl::TransliterationWrapper&); virtual SwFlyFrmFmt* InsertOLE(const SwPaM &rRg, const String& rObjName, sal_Int64 nAspect, const SfxItemSet* pFlyAttrSet, @@ -911,7 +922,8 @@ public: virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart); virtual bool AppendTxtNode(SwPosition& rPos); virtual void SetModified(SwPaM &rPaM); - virtual bool Replace(SwPaM& rPam, const String& rNewStr, bool bRegExpRplc); + virtual bool ReplaceRange(SwPaM& rPam, const String& rNewStr, + const bool bRegExReplace); virtual void RemoveLeadingWhiteSpace(const SwPosition & rPos ); /** IDocumentStylePoolAccess @@ -1358,11 +1370,11 @@ public: // kopiere die Kopzeile (mit dem Inhalt!) aus dem SrcFmt // ins DestFmt ( auch ueber Doc grenzen hinaus!) void CopyHeader( const SwFrmFmt& rSrcFmt, SwFrmFmt& rDestFmt ) - { _CopyPageDescHeaderFooter( sal_True, rSrcFmt, rDestFmt ); } + { CopyPageDescHeaderFooterImpl( true, rSrcFmt, rDestFmt ); } // kopiere die Fusszeile (mit dem Inhalt!) aus dem SrcFmt // ins DestFmt ( auch ueber Doc grenzen hinaus!) void CopyFooter( const SwFrmFmt& rSrcFmt, SwFrmFmt& rDestFmt ) - { _CopyPageDescHeaderFooter( sal_False, rSrcFmt, rDestFmt ); } + { CopyPageDescHeaderFooterImpl( false, rSrcFmt, rDestFmt ); } //fuer Reader @@ -1394,7 +1406,7 @@ public: // Methoden fuer die Verzeichnisse: // - Verzeichnismarke einfuegen loeschen travel sal_uInt16 GetCurTOXMark( const SwPosition& rPos, SwTOXMarks& ) const; - void Delete( const SwTOXMark* pTOXMark ); + void DeleteTOXMark( const SwTOXMark* pTOXMark ); const SwTOXMark& GotoTOXMark( const SwTOXMark& rCurTOXMark, SwTOXSearch eDir, sal_Bool bInReadOnly ); @@ -1770,9 +1782,9 @@ public: inline void SetOle2Link(const Link& rLink) {aOle2Link = rLink;} inline const Link& GetOle2Link() const {return aOle2Link;} - // SS fuer Bereiche - SwSection* Insert( const SwPaM& rRange, const SwSection& rNew, - const SfxItemSet* pAttr = 0, sal_Bool bUpdate = sal_True ); + // insert section (the ODF kind of section, not the nodesarray kind) + SwSection* InsertSwSection( const SwPaM& rRange, const SwSection& rNew, + const SfxItemSet* pAttr = 0, bool bUpdate = true); sal_uInt16 IsInsRegionAvailable( const SwPaM& rRange, const SwNode** ppSttNd = 0 ) const; SwSection* GetCurrSection( const SwPosition& rPos ) const; @@ -2094,6 +2106,7 @@ public: } ::sfx2::IXmlIdRegistry& GetXmlIdRegistry(); + ::sw::MetaFieldManager & GetMetaFieldManager(); SwDoc* CreateCopy() const; }; diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index 77be46c1acc4..1ce87e0df410 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -181,7 +181,7 @@ class SW_DLLPUBLIC SwEditShell: public SwCrsrShell public: // Editieren (immer auf allen selektierten Bereichen) void Insert( sal_Unicode, BOOL bOnlyCurrCrsr = FALSE ); - void Insert( const String &); + void Insert2( const String &, const bool bForceExpandHints = false ); void Overwrite( const String & ); // Ersetz einen selektierten Bereich in einem TextNode mit dem @@ -332,7 +332,7 @@ public: { return (SwCharFmt*)SwEditShell::GetFmtFromPool( nId ); } // Felder - void Insert(SwField&); + void Insert2(SwField&, const bool bForceExpandHints = false); SwField* GetCurFld() const; void UpdateFlds( SwField & ); // ein einzelnes Feld diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index 325638b5df00..3f2bdf6f07ae 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -127,8 +127,8 @@ RES_TXTATR_WITHEND_BEGIN = RES_TXTATR_BEGIN , RES_TXTATR_DUMMY5, // 46 RES_TXTATR_CJK_RUBY, // 47 RES_TXTATR_UNKNOWN_CONTAINER, // 48 - RES_TXTATR_DUMMY6, // 49 - RES_TXTATR_DUMMY7, // 50 + RES_TXTATR_META, // 49 + RES_TXTATR_METAFIELD, // 50 RES_TXTATR_WITHEND_END, // alle TextAttribute ohne ein Ende @@ -136,8 +136,8 @@ RES_TXTATR_NOEND_BEGIN = RES_TXTATR_WITHEND_END, RES_TXTATR_FIELD = RES_TXTATR_NOEND_BEGIN, // 51 RES_TXTATR_FLYCNT, // 52 RES_TXTATR_FTN, // 53 - RES_TXTATR_SOFTHYPH, // 54 - RES_TXTATR_HARDBLANK, // 55 + RES_TXTATR_DUMMY4, // 54 + RES_TXTATR_DUMMY3, // 55 RES_TXTATR_DUMMY1, // 56 RES_TXTATR_DUMMY2, // 57 RES_TXTATR_NOEND_END, diff --git a/sw/inc/index.hxx b/sw/inc/index.hxx index 5a57724f2540..9837a4e664bc 100644 --- a/sw/inc/index.hxx +++ b/sw/inc/index.hxx @@ -132,8 +132,8 @@ class SwIndexReg static SwIndexReg* pEmptyIndexArray; protected: - virtual void Update( const SwIndex & aPos, xub_StrLen nLen, - BOOL bNegativ = FALSE, BOOL bDelete = FALSE ); + virtual void Update( SwIndex const & rPos, const xub_StrLen nChangeLen, + const bool bNegative = false, const bool bDelete = false ); void ChkArr(); diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx index fe58df27613b..6bbd72778498 100644 --- a/sw/inc/ndarr.hxx +++ b/sw/inc/ndarr.hxx @@ -180,7 +180,7 @@ public: BOOL _MoveNodes( const SwNodeRange&, SwNodes& rNodes, const SwNodeIndex&, BOOL bNewFrms = TRUE ); - void Move( SwPaM&, SwPosition&, SwNodes& rNodes, BOOL bSplitNd=TRUE ); + void MoveRange( SwPaM&, SwPosition&, SwNodes& rNodes ); void _Copy( const SwNodeRange& rRg, const SwNodeIndex& rInsPos, BOOL bNewFrms = TRUE ) const diff --git a/sw/inc/ndhints.hxx b/sw/inc/ndhints.hxx index 04bf3a7914b3..e5a3ee794e0b 100644 --- a/sw/inc/ndhints.hxx +++ b/sw/inc/ndhints.hxx @@ -34,11 +34,30 @@ #include <svtools/svarray.hxx> #include <tools/mempool.hxx> +#include "swtypes.hxx" + //#include "numrule.hxx" class SwTxtNode; class SwRegHistory; // steht im RolBck.hxx class SwTxtAttr; +class SwTxtAttrNesting; + +class SfxPoolItem; +class SfxItemSet; +class SwDoc; + +SW_DLLPRIVATE SwTxtAttr * +MakeTxtAttr( SwDoc & rDoc, SfxPoolItem & rNew, + xub_StrLen nStt, xub_StrLen nEnd ); +SW_DLLPRIVATE SwTxtAttr * +MakeTxtAttr( SwDoc & rDoc, const SfxItemSet & rSet, + xub_StrLen nStt, xub_StrLen nEnd ); + +// create redline dummy text hint that must not be inserted into hints array +SW_DLLPRIVATE SwTxtAttr* +MakeRedlineTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr ); + /* * Ableitung der Klasse SwpHints ueber den Umweg ueber SwpHts, da @@ -148,7 +167,10 @@ private: return m_bHasHiddenParaField; } - void BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMode ); + void InsertNesting(SwTxtAttrNesting & rNewHint); + bool TryInsertNesting(SwTxtNode & rNode, SwTxtAttrNesting & rNewHint); + void BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, + const SetAttrMode nMode ); bool MergePortions( SwTxtNode& rNode ); public: @@ -162,7 +184,10 @@ public: void DeRegister() { Register(0); } SwRegHistory* GetHistory() const { return m_pHistory; } - void Insert( SwTxtAttr* pHt, SwTxtNode &rNode, USHORT nMode = 0 ); + /// try to insert the hint + /// @return true iff hint successfully inserted + bool TryInsertHint( SwTxtAttr * const pHint, SwTxtNode & rNode, + const SetAttrMode nMode = nsSetAttrMode::SETATTR_DEFAULT ); inline bool HasFtn() const { return m_bFootnote; } inline bool IsInSplitNode() const { return m_bInSplitNode; } diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index dffa47f898f3..d4d59afa3d9c 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -38,6 +38,7 @@ #include <errhdl.hxx> #include <modeltoviewhelper.hxx> #include <SwNumberTreeTypes.hxx> +#include <IDocumentContentOperations.hxx> #include <sfx2/Metadatable.hxx> @@ -75,11 +76,6 @@ class SwScriptInfo; struct SwDocStat; struct SwParaIdleData_Impl; -// Konstanten fuer das Text-Insert: -#define INS_DEFAULT 0x0000 // keine Extras -#define INS_EMPTYEXPAND 0x0001 // leere Hints beim Einfuegen aufspannen -#define INS_NOHINTEXPAND 0x0002 // Hints an der InsPos nicht aufspannen - namespace com { namespace sun { namespace star { namespace uno { template < class > class Sequence; }}}} @@ -97,8 +93,6 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode, public ::sfx2::Metadatable friend class SwNodes; friend class SwTxtFrm; friend class SwScriptInfo; - friend void SwpHints::Insert( SwTxtAttr*, SwTxtNode&, USHORT ); - friend void SwpHints::BuildPortions( SwTxtNode&, SwTxtAttr&, USHORT ); //Kann 0 sein, nur dann nicht 0 wenn harte Attribute drin stehen. //Also niemals direkt zugreifen! @@ -148,11 +142,10 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode, public ::sfx2::Metadatable SW_DLLPRIVATE SwTxtNode* _MakeNewTxtNode( const SwNodeIndex&, BOOL bNext = TRUE, BOOL bChgFollow = TRUE ); - SW_DLLPRIVATE void _Cut( SwTxtNode *pDest, const SwIndex &rDestStart, - const SwIndex &rStart, xub_StrLen nLen, BOOL bUpdate = TRUE ); - - SW_DLLPRIVATE SwTxtAttr* MakeTxtAttr( const SfxPoolItem& rNew, xub_StrLen nStt, xub_StrLen nEnd, bool bRedlineAttr = false ); - SW_DLLPRIVATE SwTxtAttr* MakeTxtAttr( const SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd ); + SW_DLLPRIVATE void CutImpl( + SwTxtNode * const pDest, const SwIndex & rDestStart, + const SwIndex & rStart, /*const*/ xub_StrLen nLen, + const bool bUpdate = true ); // Verlagere alles umfassende harte Attribute in den AttrSet des Absatzes SW_DLLPRIVATE void MoveTxtAttr_To_AttrSet(); // wird von SplitNode gerufen. @@ -258,21 +251,30 @@ public: virtual USHORT ResetAllAttr(); // <-- - /* - * Einfuegen anderer Datentypen durch Erzeugen eines - * temporaeren Strings. - */ - SwTxtNode& Insert( xub_Unicode c, const SwIndex &rIdx ); - SwTxtNode& Insert( const XubString &rStr, const SwIndex &rIdx, - const USHORT nMode = INS_DEFAULT ); + /// insert text content + void InsertText( const XubString & rStr, const SwIndex & rIdx, + const enum IDocumentContentOperations::InsertFlags nMode + = IDocumentContentOperations::INS_DEFAULT ); - SwTxtNode& Erase( const SwIndex &rIdx, xub_StrLen nCount = STRING_LEN, - const USHORT nMode = INS_DEFAULT ); - - // Aktionen auf Attributen - // loesche alle TextAttribute die als Attribut im Set vorhanden sind - // (Set-Pointer != 0 ) oder alle deren Which-Wert mit nWhich mappen - // oder wenn Which = 0, alle. + /** delete text content + ATTENTION: must not be called with a range that overlaps the start of + an attribute with both extent and dummy char + */ + void EraseText ( const SwIndex &rIdx, const xub_StrLen nCount = STRING_LEN, + const enum IDocumentContentOperations::InsertFlags nMode + = IDocumentContentOperations::INS_DEFAULT ); + + /** delete all attributes. + If neither pSet nor nWhich is given, delete all attributes (except + refmarks, toxmarks, meta) in range. + @param rIdx start position + @param nLen range in which attributes will be deleted + @param pSet if not 0, delete only attributes contained in pSet + @param nWhich if not 0, delete only attributes with matching which + @param bInclRefToxMark + refmarks, toxmarks, and metas will be ignored unless this is true + ATTENTION: setting bInclRefToxMark is only allowed from UNDO! + */ void RstAttr( const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich = 0, const SfxItemSet* pSet = 0, BOOL bInclRefToxMark = FALSE ); void GCAttr(); @@ -283,17 +285,20 @@ public: // loesche alle Attribute aus dem SwpHintsArray. void ClearSwpHintsArr( bool bDelFields ); - // Insert pAttr into hints array. - BOOL Insert( SwTxtAttr *pAttr, USHORT nMode = 0 ); - // lege ein neues TextAttribut an und fuege es ins SwpHints-Array ein - // returne den neuen Pointer (oder 0 bei Fehlern)! - SwTxtAttr* InsertItem( const SfxPoolItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnd, USHORT nMode = 0 ); + /// Insert pAttr into hints array. @return true iff inserted successfully + bool InsertHint( SwTxtAttr * const pAttr, + const SetAttrMode nMode = nsSetAttrMode::SETATTR_DEFAULT ); + /// create new text attribute from rAttr and insert it + /// @return inserted hint; 0 if not sure the hint is inserted + SwTxtAttr* InsertItem( SfxPoolItem& rAttr, + const xub_StrLen nStart, const xub_StrLen nEnd, + const SetAttrMode nMode = nsSetAttrMode::SETATTR_DEFAULT ); // setze diese Attribute am TextNode. Wird der gesamte Bereich umspannt, // dann setze sie nur im AutoAttrSet (SwCntntNode:: SetAttr) BOOL SetAttr( const SfxItemSet& rSet, - xub_StrLen nStt, xub_StrLen nEnd, USHORT nMode = 0 ); + xub_StrLen nStt, xub_StrLen nEnd, + const SetAttrMode nMode = nsSetAttrMode::SETATTR_DEFAULT ); // erfrage die Attribute vom TextNode ueber den Bereich // --> OD 2008-01-16 #newlistlevelattrs# // Introduce 4th optional parameter <bMergeIndentValuesOfNumRule>. @@ -311,32 +316,34 @@ public: // uebertrage Attribute eines AttrSets ( AutoFmt ) in das SwpHintsArray void FmtToTxtAttr( SwTxtNode* pNd ); - // loeschen eines einzelnen Attributes (fuer SwUndoAttr) - // ( nur das Attribut loeschen, dass mit Which,Start und End oder - // mit pTxtHint identisch ist (es gibt nur ein gueltiges)) - // AUSNAHME: ToxMarks !!! - void Delete( USHORT nTxtWhich, xub_StrLen nStart, xub_StrLen nEnd = 0 ); - void Delete( SwTxtAttr * pTxtAttr, BOOL bThisOnly = FALSE ); + /// delete all attributes of type nWhich at nStart (opt. end nEnd) + void DeleteAttributes( const USHORT nWhich, + const xub_StrLen nStart, const xub_StrLen nEnd = 0 ); + /// delete the attribute pTxtAttr + void DeleteAttribute ( SwTxtAttr * const pTxtAttr ); // Aktionen auf Text und Attributen // --> OD 2008-11-18 #i96213# // introduce optional parameter to control, if all attributes have to be copied. - void Copy( SwTxtNode *pDest, + void CopyText( SwTxtNode * const pDest, const SwIndex &rStart, - USHORT nLen, + const xub_StrLen nLen, const bool bForceCopyOfAllAttrs = false ); - void Copy( SwTxtNode *pDest, + void CopyText( SwTxtNode * const pDest, const SwIndex &rDestStart, const SwIndex &rStart, xub_StrLen nLen, const bool bForceCopyOfAllAttrs = false ); // <-- - void Cut(SwTxtNode *pDest, const SwIndex &rStart, xub_StrLen nLen); - inline void Cut(SwTxtNode *pDest, const SwIndex &rDestStart, - const SwIndex &rStart, xub_StrLen nLen); - // ersetze im String an Position nIdx das Zeichen - void Replace( const SwIndex& rStart, xub_Unicode cCh ); - void Replace( const SwIndex& rStart, xub_StrLen nLen, const XubString& rText ); + + void CutText(SwTxtNode * const pDest, + const SwIndex & rStart, const xub_StrLen nLen); + inline void CutText(SwTxtNode * const pDest, const SwIndex &rDestStart, + const SwIndex & rStart, const xub_StrLen nLen); + + /// replace nDelLen characters at rStart with rText + void ReplaceText( const SwIndex& rStart, const xub_StrLen nDelLen, + const XubString& rText ); void ReplaceTextOnly( xub_StrLen nPos, xub_StrLen nLen, const XubString& rText, const ::com::sun::star::uno::Sequence<sal_Int32>& rOffsets ); @@ -355,18 +362,21 @@ public: // gebe das vorgegebene Attribut, welches an der TextPosition (rIdx) // gesetzt ist zurueck. Gibt es keines, returne 0-Pointer // gesetzt heisst: Start <= rIdx < End + // FIXME: this function does not seem to be well-defined for those + // hints of which several may cover a single position, like TOXMark, + // or CharFmt SwTxtAttr *GetTxtAttr( const SwIndex& rIdx, USHORT nWhichHt, BOOL bExpand = FALSE ) const; - // Diese Methode liefert nur Textattribute auf der Position nIdx - // zurueck, die kein EndIdx besitzen und denselben Which besitzen. - // Ueblicherweise steht an dieser Position ein CH_TXTATR. - // Bei RES_TXTATR_END entfaellt die Pruefung auf den Which-Wert. - SwTxtAttr *GetTxtAttr( const xub_StrLen nIdx, - const USHORT nWhichHt = RES_TXTATR_END ) const; - - SwTxtFld *GetTxtFld( const SwIndex& rIdx ) - { return (SwTxtFld *)GetTxtAttr( rIdx, RES_TXTATR_FIELD ); } + /** get the text attribute at position nIndex which owns + the dummy character CH_TXTATR_* at that position, if one exists. + @param nIndex the position in the text + @param nWhich if different from RES_TXTATR_END, return only + attribute with given which id + @return the text attribute at nIndex of type nWhich, if it exists + */ + SwTxtAttr *GetTxtAttrForCharAt( const xub_StrLen nIndex, + const RES_TXTATR nWhich = RES_TXTATR_END ) const; // Aktuelles Wort zurueckliefern XubString GetCurWord(xub_StrLen) const; @@ -754,17 +764,14 @@ public: bool IsHidden() const; // <-- - inline SwTxtAttr* MakeRedlineTxtAttr( const SfxPoolItem& rNew ) - { return MakeTxtAttr( rNew, 0, 0, true ); } - TYPEINFO(); // fuer rtti // fuers Umhaengen der TxtFmtCollections (Outline-Nummerierung!!) virtual void Modify( SfxPoolItem*, SfxPoolItem* ); - // aus SwIndexReg - virtual void Update( const SwIndex & aPos, USHORT xub_StrLen, - BOOL bNegativ = FALSE, BOOL bDelete = FALSE ); + // override SwIndexReg + virtual void Update( SwIndex const & rPos, const xub_StrLen nChangeLen, + const bool bNegative = false, const bool bDelete = false ); // change text to Upper/Lower/Hiragana/Katagana/... void TransliterateText( utl::TransliterationWrapper& rTrans, @@ -865,11 +872,11 @@ inline const SwTxtNode *SwNode::GetTxtNode() const } #endif -inline void SwTxtNode::Cut(SwTxtNode *pDest, const SwIndex &rDestStart, - const SwIndex &rStart, xub_StrLen nLen) +inline void +SwTxtNode::CutText(SwTxtNode * const pDest, const SwIndex & rDestStart, + const SwIndex & rStart, const xub_StrLen nLen) { - _Cut( pDest, rDestStart, rStart, nLen, TRUE ); + CutImpl( pDest, rDestStart, rStart, nLen, true ); } - #endif diff --git a/sw/inc/rolbck.hxx b/sw/inc/rolbck.hxx index bd97b81f1b6b..f910a44ca859 100644 --- a/sw/inc/rolbck.hxx +++ b/sw/inc/rolbck.hxx @@ -40,6 +40,10 @@ //Nur die History anziehen, um das docnew.cxx gegen die CLOOK's zu behaupten. +namespace sfx2 { + class MetadatableUndo; +} + class SwDoc; class SwFmt; class SwFmtColl; @@ -295,6 +299,7 @@ class SwHistoryBookmark : public SwHistoryHint const bool m_bSaveOtherPos; const bool m_bHadOtherPos; const IDocumentMarkAccess::MarkType m_eBkmkType; + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo; }; class SwHistorySetAttrSet : public SwHistoryHint @@ -446,13 +451,16 @@ public: // --> OD 2008-02-27 #refactorlists# - removed <rDoc> SwRegHistory( SwHistory* pHst ); // <-- - SwRegHistory( SwTxtNode* pTxtNode, const SfxItemSet& rSet, - xub_StrLen nStart, xub_StrLen nEnd, USHORT nFlags, - SwHistory* pHst ); SwRegHistory( const SwNode& rNd, SwHistory* pHst ); SwRegHistory( SwModify* pRegIn, const SwNode& rNd, SwHistory* pHst ); virtual void Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ); + + /// @return true iff at least 1 item was inserted + bool InsertItems( const SfxItemSet& rSet, + xub_StrLen const nStart, xub_StrLen const nEnd, + SetAttrMode const nFlags ); + void AddHint( SwTxtAttr* pHt, const bool bNew = false ); void RegisterInModify( SwModify* pRegIn, const SwNode& rNd ); diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx index 176377f3e6f4..64cd8231f0ef 100644 --- a/sw/inc/swtypes.hxx +++ b/sw/inc/swtypes.hxx @@ -229,6 +229,8 @@ namespace nsSetAttrMode const SetAttrMode SETATTR_DONTCHGNUMRULE = 0x0020; // nicht die NumRule veraendern const SetAttrMode SETATTR_APICALL = 0x0040; // called from API (all UI related // functionality will be disabled) + /// force hint expand (only matters for hints with CH_TXTATR) + const SetAttrMode SETATTR_FORCEHINTEXPAND= 0x0080; } //Umrechnung Twip<-> 1/100 mm fuer UNO diff --git a/sw/inc/txatbase.hxx b/sw/inc/txatbase.hxx index 90602a7b941c..2a49460a05ca 100644 --- a/sw/inc/txatbase.hxx +++ b/sw/inc/txatbase.hxx @@ -39,76 +39,51 @@ class SfxItemPool; -class SvxBrushItem; -class SvxFontItem; -class SvxPostureItem; -class SvxWeightItem; -class SvxUnderlineItem; -class SvxOverlineItem; -class SvxFontHeightItem; -class SvxPropSizeItem; -class SvxShadowedItem; -class SvxAutoKernItem; -class SvxWordLineModeItem; -class SvxContourItem; -class SvxCrossedOutItem; -class SvxColorItem; -class SvxCharSetColorItem; class SvXMLAttrContainerItem; class SwFmtRuby; -class SvxTwoLinesItem; -class SvxEmphasisMarkItem; -class SvxCharScaleWidthItem; -class SvxCharRotateItem; -class SvxCharReliefItem; -class SvxCharHiddenItem; - class SwFmtCharFmt; class SwFmtAutoFmt; class SwFmtINetFmt; -class SvxKerningItem; -class SvxCaseMapItem; -class SvxLanguageItem; -class SvxEscapementItem; -class SvxBlinkItem; -class SvxNoHyphenItem; -class SwFmtSoftHyph; -class SwFmtHardBlank; class SwFmtFld; class SwFmtFtn; class SwFmtFlyCnt; class SwTOXMark; class SwFmtRefMark; +class SwFmtMeta; + class SwTxtAttr : private boost::noncopyable { - const SfxPoolItem* m_pAttr; +private: + SfxPoolItem * const m_pAttr; xub_StrLen m_nStart; bool m_bDontExpand : 1; bool m_bLockExpandFlag : 1; - bool m_bDontMergeAttr : 1; // refmarks, toxmarks, ruby bool m_bDontMoveAttr : 1; // refmarks, toxmarks bool m_bCharFmtAttr : 1; // charfmt, inet bool m_bOverlapAllowedAttr : 1; // refmarks, toxmarks bool m_bPriorityAttr : 1; // attribute has priority (redlining) bool m_bDontExpandStart : 1; // don't expand start at paragraph start (ruby) + bool m_bNesting : 1; // SwTxtAttrNesting + bool m_bHasDummyChar : 1; // without end + meta protected: - SwTxtAttr( const SfxPoolItem& rAttr, xub_StrLen nStart ); + SwTxtAttr( SfxPoolItem& rAttr, xub_StrLen nStart ); + virtual ~SwTxtAttr(); void SetLockExpandFlag( bool bFlag ) { m_bLockExpandFlag = bFlag; } - void SetDontMergeAttr( bool bFlag ) { m_bDontMergeAttr = bFlag; } void SetDontMoveAttr( bool bFlag ) { m_bDontMoveAttr = bFlag; } void SetCharFmtAttr( bool bFlag ) { m_bCharFmtAttr = bFlag; } void SetOverlapAllowedAttr( bool bFlag ){ m_bOverlapAllowedAttr = bFlag; } void SetDontExpandStartAttr(bool bFlag) { m_bDontExpandStart = bFlag; } + void SetNesting(const bool bFlag) { m_bNesting = bFlag; } + void SetHasDummyChar(const bool bFlag) { m_bHasDummyChar = bFlag; } public: - virtual ~SwTxtAttr(); - // RemoveFromPool muss immer vorm DTOR Aufruf erfolgen!! - void RemoveFromPool( SfxItemPool& rPool ); + /// destroy instance + static void Destroy( SwTxtAttr * pToDestroy, SfxItemPool& rPool ); /// start position xub_StrLen* GetStart() { return & m_nStart; } @@ -123,44 +98,23 @@ public: inline void SetDontExpand( bool bDontExpand ); bool DontExpand() const { return m_bDontExpand; } bool IsLockExpandFlag() const { return m_bLockExpandFlag; } - bool IsDontMergeAttr() const { return m_bDontMergeAttr; } bool IsDontMoveAttr() const { return m_bDontMoveAttr; } bool IsCharFmtAttr() const { return m_bCharFmtAttr; } bool IsOverlapAllowedAttr() const { return m_bOverlapAllowedAttr; } bool IsPriorityAttr() const { return m_bPriorityAttr; } void SetPriorityAttr( bool bFlag ) { m_bPriorityAttr = bFlag; } bool IsDontExpandStartAttr() const { return m_bDontExpandStart; } + bool IsNesting() const { return m_bNesting; } + bool HasDummyChar() const { return m_bHasDummyChar; } inline const SfxPoolItem& GetAttr() const; + inline SfxPoolItem& GetAttr(); inline USHORT Which() const { return GetAttr().Which(); } virtual int operator==( const SwTxtAttr& ) const; - inline const SvxFontItem &GetFont() const; - inline const SvxPostureItem &GetPosture() const; - inline const SvxWeightItem &GetWeight() const; - inline const SvxUnderlineItem &GetUnderline() const; - inline const SvxOverlineItem &GetOverline() const; - inline const SvxFontHeightItem &GetFontSize() const; - inline const SvxPropSizeItem &GetPropSize() const; - inline const SvxShadowedItem &GetShadowed() const; - inline const SvxAutoKernItem &GetAutoKern() const; - inline const SvxWordLineModeItem &GetWordLineMode() const; - inline const SvxContourItem &GetContour() const; - inline const SvxCrossedOutItem &GetCrossedOut() const; - inline const SvxColorItem &GetColor() const; - inline const SvxCharSetColorItem &GetCharSetColor() const; inline const SwFmtCharFmt &GetCharFmt() const; inline const SwFmtAutoFmt &GetAutoFmt() const; - inline const SvxKerningItem &GetKerning() const; - inline const SvxCaseMapItem &GetCaseMap() const; - inline const SvxLanguageItem &GetLanguage() const; - inline const SvxEscapementItem &GetEscapement() const; - inline const SvxBlinkItem &GetBlink() const; - inline const SvxBrushItem &GetChrBackground() const; - inline const SvxNoHyphenItem &GetNoHyphenHere() const; - inline const SwFmtSoftHyph &GetSoftHyph() const; - inline const SwFmtHardBlank &GetHardBlank() const; inline const SwFmtFld &GetFld() const; inline const SwFmtFtn &GetFtn() const; inline const SwFmtFlyCnt &GetFlyCnt() const; @@ -169,25 +123,19 @@ public: inline const SwFmtINetFmt &GetINetFmt() const; inline const SvXMLAttrContainerItem &GetXMLAttrContainer() const; inline const SwFmtRuby &GetRuby() const; - inline const SvxTwoLinesItem &Get2Lines() const; - inline const SvxEmphasisMarkItem &GetEmphasisMark() const; - inline const SvxCharScaleWidthItem &GetCharScaleW() const; - inline const SvxCharRotateItem &GetCharRotate() const; - inline const SvxCharReliefItem &GetCharRelief() const; - inline const SvxCharHiddenItem &GetCharHidden() const; + inline const SwFmtMeta &GetMeta() const; }; class SwTxtAttrEnd : public SwTxtAttr { - using SwTxtAttr::GetEnd; - protected: xub_StrLen m_nEnd; public: - SwTxtAttrEnd( const SfxPoolItem& rAttr, USHORT nStart, USHORT nEnd ); + SwTxtAttrEnd( SfxPoolItem& rAttr, USHORT nStart, USHORT nEnd ); + using SwTxtAttr::GetEnd; virtual xub_StrLen* GetEnd(); }; @@ -211,6 +159,12 @@ inline const SfxPoolItem& SwTxtAttr::GetAttr() const return *m_pAttr; } +inline SfxPoolItem& SwTxtAttr::GetAttr() +{ + return const_cast<SfxPoolItem&>( + const_cast<const SwTxtAttr*>(this)->GetAttr()); +} + inline void SwTxtAttr::SetDontExpand( bool bDontExpand ) { if ( !m_bLockExpandFlag ) @@ -219,102 +173,7 @@ inline void SwTxtAttr::SetDontExpand( bool bDontExpand ) } } -inline const SvxFontItem& SwTxtAttr::GetFont() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_FONT, "Wrong attribute" ); - return (const SvxFontItem&)(*m_pAttr); -} - -inline const SvxPostureItem& SwTxtAttr::GetPosture() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_POSTURE, - "Wrong attribute" ); - return (const SvxPostureItem&)(*m_pAttr); -} - -inline const SvxWeightItem& SwTxtAttr::GetWeight() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_WEIGHT, - "Wrong attribute" ); - return (const SvxWeightItem&)(*m_pAttr); -} - -inline const SvxUnderlineItem& SwTxtAttr::GetUnderline() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_UNDERLINE, - "Wrong attribute" ); - return (const SvxUnderlineItem&)(*m_pAttr); -} - -inline const SvxOverlineItem& SwTxtAttr::GetOverline() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_OVERLINE, - "Wrong attribute" ); - return (const SvxOverlineItem&)(*m_pAttr); -} - -inline const SvxFontHeightItem& SwTxtAttr::GetFontSize() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_FONTSIZE, - "Wrong attribute" ); - return (const SvxFontHeightItem&)(*m_pAttr); -} - -inline const SvxPropSizeItem& SwTxtAttr::GetPropSize() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_PROPORTIONALFONTSIZE, - "Wrong attribute" ); - return (const SvxPropSizeItem&)(*m_pAttr); -} - -inline const SvxShadowedItem& SwTxtAttr::GetShadowed() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_SHADOWED, - "Wrong attribute" ); - return (const SvxShadowedItem&)(*m_pAttr); -} - -inline const SvxAutoKernItem& SwTxtAttr::GetAutoKern() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_AUTOKERN, - "Wrong attribute" ); - return (const SvxAutoKernItem&)(*m_pAttr); -} - -inline const SvxWordLineModeItem& SwTxtAttr::GetWordLineMode() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_WORDLINEMODE, - "Wrong attribute" ); - return (const SvxWordLineModeItem&)(*m_pAttr); -} - -inline const SvxContourItem& SwTxtAttr::GetContour() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CONTOUR, - "Wrong attribute" ); - return (const SvxContourItem&)(*m_pAttr); -} - -inline const SvxCrossedOutItem& SwTxtAttr::GetCrossedOut() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CROSSEDOUT, - "Wrong attribute" ); - return (const SvxCrossedOutItem&)(*m_pAttr); -} - -inline const SvxColorItem& SwTxtAttr::GetColor() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_COLOR, - "Wrong attribute" ); - return (const SvxColorItem&)(*m_pAttr); -} - -inline const SvxCharSetColorItem& SwTxtAttr::GetCharSetColor() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CHARSETCOLOR, - "Wrong attribute" ); - return (const SvxCharSetColorItem&)(*m_pAttr); -} +//------------------------------------------------------------------------ inline const SwFmtCharFmt& SwTxtAttr::GetCharFmt() const { @@ -330,69 +189,6 @@ inline const SwFmtAutoFmt& SwTxtAttr::GetAutoFmt() const return (const SwFmtAutoFmt&)(*m_pAttr); } -inline const SvxKerningItem& SwTxtAttr::GetKerning() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_KERNING, - "Wrong attribute" ); - return (const SvxKerningItem&)(*m_pAttr); -} - -inline const SvxCaseMapItem& SwTxtAttr::GetCaseMap() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CASEMAP, - "Wrong attribute" ); - return (const SvxCaseMapItem&)(*m_pAttr); -} - -inline const SvxLanguageItem& SwTxtAttr::GetLanguage() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_LANGUAGE, - "Wrong attribute" ); - return (const SvxLanguageItem&)(*m_pAttr); -} - -inline const SvxEscapementItem& SwTxtAttr::GetEscapement() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_ESCAPEMENT, - "Wrong attribute" ); - return (const SvxEscapementItem&)(*m_pAttr); -} - -inline const SvxBlinkItem& SwTxtAttr::GetBlink() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_BLINK, - "Wrong attribute" ); - return (const SvxBlinkItem&)(*m_pAttr); -} - -inline const SvxBrushItem& SwTxtAttr::GetChrBackground() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_BACKGROUND, - "Wrong attribute" ); - return (const SvxBrushItem&)(*m_pAttr); -} - -inline const SvxNoHyphenItem& SwTxtAttr::GetNoHyphenHere() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_NOHYPHEN, - "Wrong attribute" ); - return (const SvxNoHyphenItem&)(*m_pAttr); -} - -inline const SwFmtSoftHyph& SwTxtAttr::GetSoftHyph() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_SOFTHYPH, - "Wrong attribute" ); - return (const SwFmtSoftHyph&)(*m_pAttr); -} - -inline const SwFmtHardBlank& SwTxtAttr::GetHardBlank() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_HARDBLANK, - "Wrong attribute" ); - return (const SwFmtHardBlank&)(*m_pAttr); -} - inline const SwFmtFld& SwTxtAttr::GetFld() const { ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_FIELD, @@ -447,46 +243,13 @@ inline const SwFmtRuby& SwTxtAttr::GetRuby() const "Wrong attribute" ); return (const SwFmtRuby&)(*m_pAttr); } -inline const SvxTwoLinesItem& SwTxtAttr::Get2Lines() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_TWO_LINES, - "Wrong attribute" ); - return (const SvxTwoLinesItem&)(*m_pAttr); -} - -inline const SvxEmphasisMarkItem& SwTxtAttr::GetEmphasisMark() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_EMPHASIS_MARK, - "Wrong attribute" ); - return (const SvxEmphasisMarkItem&)(*m_pAttr); -} - -inline const SvxCharScaleWidthItem& SwTxtAttr::GetCharScaleW() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_SCALEW, - "Wrong attribute" ); - return (const SvxCharScaleWidthItem&)(*m_pAttr); -} - -inline const SvxCharRotateItem& SwTxtAttr::GetCharRotate() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_ROTATE, - "Wrong attribute" ); - return (const SvxCharRotateItem&)(*m_pAttr); -} - -inline const SvxCharReliefItem& SwTxtAttr::GetCharRelief() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_RELIEF, - "Wrong attribute" ); - return (const SvxCharReliefItem&)(*m_pAttr); -} -inline const SvxCharHiddenItem& SwTxtAttr::GetCharHidden() const +inline const SwFmtMeta& SwTxtAttr::GetMeta() const { - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_HIDDEN, + ASSERT( m_pAttr && (m_pAttr->Which() == RES_TXTATR_META || + m_pAttr->Which() == RES_TXTATR_METAFIELD), "Wrong attribute" ); - return (const SvxCharHiddenItem&)(*m_pAttr); + return (const SwFmtMeta&)(*m_pAttr); } #endif diff --git a/sw/inc/txtatr.hxx b/sw/inc/txtatr.hxx index 3b03173e17ed..92b51fede495 100644 --- a/sw/inc/txtatr.hxx +++ b/sw/inc/txtatr.hxx @@ -29,14 +29,13 @@ ************************************************************************/ #ifndef _TXTATR_HXX #define _TXTATR_HXX -#include <tools/gen.hxx> -#include <tools/color.hxx> + #include <txatbase.hxx> // SwTxtAttr/SwTxtAttrEnd #include <calbck.hxx> + class SwTxtNode; // fuer SwTxtFld class SwCharFmt; -class SvxTwoLinesItem; // ATT_CHARFMT ********************************************* @@ -60,29 +59,45 @@ public: USHORT GetSortNumber() const { return m_nSortNumber; } }; -// ATT_HARDBLANK ****************************** -class SwTxtHardBlank : public SwTxtAttr -{ - sal_Unicode m_Char; +// ATT_XMLCONTAINERITEM ****************************** +class SwTxtXMLAttrContainer : public SwTxtAttrEnd +{ public: - SwTxtHardBlank( const SwFmtHardBlank& rAttr, xub_StrLen nStart ); - inline sal_Unicode GetChar() const { return m_Char; } + SwTxtXMLAttrContainer( SvXMLAttrContainerItem& rAttr, + xub_StrLen nStart, xub_StrLen nEnd ); }; -// ATT_XNLCONTAINERITEM ****************************** +// ****************************** -class SwTxtXMLAttrContainer : public SwTxtAttrEnd +class SwTxtAttrNesting : public SwTxtAttrEnd { public: - SwTxtXMLAttrContainer( const SvXMLAttrContainerItem& rAttr, - xub_StrLen nStart, xub_StrLen nEnd ); + SwTxtAttrNesting( SfxPoolItem & i_rAttr, + const xub_StrLen i_nStart, const xub_StrLen i_nEnd ); + virtual ~SwTxtAttrNesting(); +}; + +class SwTxtMeta : public SwTxtAttrNesting +{ +private: + SwTxtNode * m_pTxtNode; + +public: + SwTxtMeta( SwFmtMeta & i_rAttr, + const xub_StrLen i_nStart, const xub_StrLen i_nEnd ); + virtual ~SwTxtMeta(); + + void ChgTxtNode( SwTxtNode * const pNode ) { m_pTxtNode = pNode; } + SwTxtNode * GetTxtNode() const { return m_pTxtNode; } + }; + // ****************************** -class SW_DLLPUBLIC SwTxtRuby : public SwTxtAttrEnd, public SwClient +class SW_DLLPUBLIC SwTxtRuby : public SwTxtAttrNesting, public SwClient { SwTxtNode* m_pTxtNode; @@ -101,16 +116,7 @@ public: SwCharFmt* GetCharFmt(); const SwCharFmt* GetCharFmt() const - { return ((SwTxtRuby*)this)->GetCharFmt(); } -}; - -// ****************************** - -class SwTxt2Lines : public SwTxtAttrEnd -{ -public: - SwTxt2Lines( const SvxTwoLinesItem& rAttr, - xub_StrLen nStart, xub_StrLen nEnd ); + { return (const_cast<SwTxtRuby*>(this))->GetCharFmt(); } }; // --------------- Inline Implementierungen ------------------------ diff --git a/sw/inc/txtftn.hxx b/sw/inc/txtftn.hxx index 6ed95e05ba06..9eaa1926238e 100644 --- a/sw/inc/txtftn.hxx +++ b/sw/inc/txtftn.hxx @@ -52,7 +52,7 @@ public: inline SwNodeIndex *GetStartNode() const { return m_pStartNode; } void SetStartNode( const SwNodeIndex *pNode, BOOL bDelNodes = TRUE ); void SetNumber( const USHORT nNumber, const String* = 0 ); - void CopyFtn( SwTxtFtn *pDest ); + void CopyFtn( SwTxtFtn *pDest ) const; // get and set TxtNode pointer inline const SwTxtNode& GetTxtNode() const; diff --git a/sw/inc/txtinet.hxx b/sw/inc/txtinet.hxx index e37a18a3f823..5aa683277e14 100644 --- a/sw/inc/txtinet.hxx +++ b/sw/inc/txtinet.hxx @@ -31,6 +31,7 @@ #define _TXTINET_HXX #include <txatbase.hxx> +#include <txtatr.hxx> #include <calbck.hxx> class SwTxtNode; @@ -38,7 +39,7 @@ class SwCharFmt; // ATT_INETFMT ********************************************* -class SW_DLLPUBLIC SwTxtINetFmt : public SwTxtAttrEnd, public SwClient +class SW_DLLPUBLIC SwTxtINetFmt : public SwTxtAttrNesting, public SwClient { SwTxtNode * m_pTxtNode; bool m_bVisited : 1; // visited link? diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx index 2c7282778053..aaafa3fca76a 100644 --- a/sw/inc/undobj.hxx +++ b/sw/inc/undobj.hxx @@ -49,6 +49,7 @@ #include <swundo.hxx> #include <IMark.hxx> +#include <IDocumentContentOperations.hxx> // --> OD 2006-11-01 #130889# #include <vector> // <-- @@ -362,6 +363,8 @@ class SwUndoInsert: public SwUndo, private SwUndoSaveCntnt BOOL bIsWordDelim : 1; BOOL bIsAppend : 1; + const IDocumentContentOperations::InsertFlags m_nInsertFlags; + friend class SwDoc; // eigentlich nur SwDoc::Insert( String ) BOOL CanGrouping( sal_Unicode cIns ); BOOL CanGrouping( const SwPosition& rPos ); @@ -373,6 +376,7 @@ class SwUndoInsert: public SwUndo, private SwUndoSaveCntnt public: SwUndoInsert( const SwNodeIndex& rNode, xub_StrLen nCntnt, xub_StrLen nLen, + const IDocumentContentOperations::InsertFlags nInsertFlags, BOOL bWDelim = TRUE ); SwUndoInsert( const SwNodeIndex& rNode ); virtual ~SwUndoInsert(); @@ -572,13 +576,13 @@ class SwUndoAttr : public SwUndo, private SwUndRng ::std::auto_ptr<SwRedlineData> m_pRedlineData; // Redlining ::std::auto_ptr<SwRedlineSaveDatas> m_pRedlineSaveData; ULONG m_nNodeIndex; // Offset: for Redlining - const USHORT m_nInsertFlags; // insert flags + const SetAttrMode m_nInsertFlags; // insert flags void RemoveIdx( SwDoc& rDoc ); public: - SwUndoAttr( const SwPaM&, const SfxItemSet&, USHORT nFlags = 0 ); - SwUndoAttr( const SwPaM&, const SfxPoolItem&, USHORT nFlags = 0 ); + SwUndoAttr( const SwPaM&, const SfxItemSet &, const SetAttrMode nFlags ); + SwUndoAttr( const SwPaM&, const SfxPoolItem&, const SetAttrMode nFlags ); virtual ~SwUndoAttr(); virtual void Undo( SwUndoIter& ); virtual void Redo( SwUndoIter& ); diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx index f728c51293e9..1a7401fd4a33 100644 --- a/sw/inc/unocoll.hxx +++ b/sw/inc/unocoll.hxx @@ -163,11 +163,11 @@ class SwUnoCollection #define SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY 73 #define SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS 74 #define SW_SERVICE_FIELDTYPE_DROPDOWN 75 -#define SW_SERVICE_FIELDTYPE_DUMMY_4 76 -#define SW_SERVICE_FIELDTYPE_DUMMY_5 77 -#define SW_SERVICE_FIELDTYPE_DUMMY_6 78 -#define SW_SERVICE_FIELDTYPE_DUMMY_7 79 -#define SW_SERVICE_FIELDTYPE_DUMMY_8 80 +#define SW_SERVICE_FIELDTYPE_METAFIELD 76 +#define SW_SERVICE_FIELDTYPE_DUMMY_4 77 +#define SW_SERVICE_FIELDTYPE_DUMMY_5 78 +#define SW_SERVICE_FIELDTYPE_DUMMY_6 79 +#define SW_SERVICE_FIELDTYPE_DUMMY_7 80 #define SW_SERVICE_FIELDMASTER_USER 81 #define SW_SERVICE_FIELDMASTER_DDE 82 #define SW_SERVICE_FIELDMASTER_SET_EXP 83 @@ -196,8 +196,9 @@ class SwUnoCollection #define SW_SERVICE_CHART2_DATA_PROVIDER 106 #define SW_SERVICE_TYPE_FIELDMARK 107 #define SW_SERVICE_TYPE_FORMFIELDMARK 108 +#define SW_SERVICE_TYPE_META 109 -#define SW_SERVICE_LAST SW_SERVICE_TYPE_FORMFIELDMARK +#define SW_SERVICE_LAST SW_SERVICE_TYPE_META #define SW_SERVICE_INVALID USHRT_MAX diff --git a/sw/inc/unocrsrhelper.hxx b/sw/inc/unocrsrhelper.hxx index 7133f6edba46..613a5e51eb89 100644 --- a/sw/inc/unocrsrhelper.hxx +++ b/sw/inc/unocrsrhelper.hxx @@ -96,7 +96,8 @@ namespace SwUnoCursorHelper com::sun::star::beans::PropertyState& eState); sal_Bool DocInsertStringSplitCR( SwDoc &rDoc, - const SwPaM &rNewCursor, const String &rText ); + const SwPaM &rNewCursor, const String &rText, + const bool bForceExpandHints ); void makeRedline( SwPaM& rPaM, 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); diff --git a/sw/inc/unofield.hxx b/sw/inc/unofield.hxx index 92e8f469d62d..bef657b5b797 100644 --- a/sw/inc/unofield.hxx +++ b/sw/inc/unofield.hxx @@ -43,7 +43,6 @@ class SwDoc; class SwFmtFld; class SwField; class SwSetExpField; -class String; class SwTextAPIObject; /* -----------------04.12.98 12:49------------------- @@ -208,6 +207,11 @@ public: void Invalidate(); }; + +/// @return a SwXTextField, either an already existing one or a new one +SwXTextField * CreateSwXTextField(SwDoc & rDoc, SwFmtFld const& rFmt); + + /* -----------------21.12.98 10:26------------------- * * --------------------------------------------------*/ diff --git a/sw/inc/unomap.hxx b/sw/inc/unomap.hxx index 9de2db4f493c..e569383a335e 100644 --- a/sw/inc/unomap.hxx +++ b/sw/inc/unomap.hxx @@ -131,8 +131,9 @@ #define PROPERTY_MAP_RUBY_AUTO_STYLE 95 #define PROPERTY_MAP_PARA_AUTO_STYLE 96 #define PROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM 97 +#define PROPERTY_MAP_METAFIELD 98 -#define PROPERTY_MAP_END 98 +#define PROPERTY_MAP_END 99 //S&E #define WID_WORDS 0 diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index dc0bd7dfafc3..b7a6c54d2bd2 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -30,8 +30,10 @@ ************************************************************************/ #ifndef _UNOOBJ_HXX #define _UNOOBJ_HXX + #include <unoevtlstnr.hxx> #include <unobaseclass.hxx> +#include <unocrsr.hxx> #include <svtools/itemprop.hxx> #include <svtools/svarray.hxx> #include <frmfmt.hxx> @@ -92,13 +94,29 @@ #include <IDocumentMarkAccess.hxx> #include <sfx2/Metadatable.hxx> +#include <deque> +#include <boost/shared_ptr.hpp> + -class SwUnoCrsr; -class SwCursor; 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------------------- * * --------------------------------------------------*/ @@ -114,36 +132,21 @@ enum CursorType CURSOR_REDLINE, CURSOR_ALL, // fuer Search&Replace CURSOR_SELECTION, // create a paragraph enumeration from a text range or cursor - CURSOR_SELECTION_IN_TABLE + CURSOR_SELECTION_IN_TABLE, + CURSOR_META, // meta/meta-field }; -/* -----------------29.04.98 07:35------------------- - * - * --------------------------------------------------*/ -#define PUNOPAM (_pStartCrsr) - -#define FOREACHUNOPAM_START(pCrsr) \ - {\ - SwPaM *_pStartCrsr = pCrsr, *__pStartCrsr = _pStartCrsr; \ - do { - -#define FOREACHUNOPAM_END() \ - } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != __pStartCrsr ); \ - } - /* -----------------26.06.98 16:18------------------- * * --------------------------------------------------*/ -SV_DECL_PTRARR(SwDependArr, SwDepend*, 2, 2) - 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, - SwDependArr& rFrameArr, + FrameDependSortList_t & rFrames, const bool _bAtCharAnchoredObjs ); /* -----------------29.04.98 07:35------------------- @@ -212,8 +215,13 @@ class SwXText : public ::com::sun::star::lang::XTypeProvider, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & CharacterAndParagraphProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); -protected: + 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(); @@ -293,6 +301,10 @@ public: 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;} @@ -345,8 +357,6 @@ class SwXTextCursor : public SwXTextCursor_Base, bool mbRemoveUserEvent; // <-- - void DeleteAndInsert(const String& rText); - DECL_STATIC_LINK( SwXTextCursor, RemoveCursor_Impl, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>* ); @@ -354,6 +364,7 @@ class SwXTextCursor : public SwXTextCursor_Base, 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); @@ -506,6 +517,8 @@ public: // --> FME 2006-03-07 #126177# void DoNotRemoveUserEvent() { mbRemoveUserEvent = false; } // <-- + + bool IsAtEndOfMeta() const; }; /*-----------------20.03.98 07:47------------------- @@ -557,18 +570,19 @@ public: }; */ -typedef cppu::WeakImplHelper5 +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 > -SwRefMarkBaseClass; +SwBookmarkBaseClass; class SwXBookmark - : public SwRefMarkBaseClass + : public SwBookmarkBaseClass , private SwClient { private: @@ -634,8 +648,15 @@ class SwXBookmark //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; } }; @@ -740,7 +761,8 @@ class SW_DLLPUBLIC SwXTextRange : public cppu::WeakImplHelper8 void _CreateNewBookmark(SwPaM& rPam); //TODO: new exception type for protected content - void DeleteAndInsert(const String& rText) throw( ::com::sun::star::uno::RuntimeException ); + void DeleteAndInsert(const String& rText, const bool bForceExpandHints) + throw( ::com::sun::star::uno::RuntimeException ); protected: virtual ~SwXTextRange(); @@ -1277,79 +1299,39 @@ class SwXParaFrameEnumeration : public cppu::WeakImplHelper2 >, public SwClient { - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xNextObject; //hasMoreElements legt das Objekt schon an - SwDependArr aFrameArr; //wird im Ctor gefuellt + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > + m_xNextObject; // created by hasMoreElements + FrameDependList_t m_Frames; - SwUnoCrsr* GetCrsr(){return (SwUnoCrsr*)GetRegisteredIn();} - BOOL CreateNextObject(); - void FillFrame(SwUnoCrsr& rUnoCrsr); + 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 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 ); + // 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.05.98 14:42------------------- - * - * --------------------------------------------------*/ - -class SwXTextPortionEnumeration : public cppu::WeakImplHelper3 -< - ::com::sun::star::container::XEnumeration, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::lang::XUnoTunnel ->, - public SwClient -{ - XTextRangeArr aPortionArr; //all portions are created in the ctor - SwDependArr aFrameArr; //wird im Ctor gefuellt - mit am Zeichen gebundenen Rahmen - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent; - BOOL bAtEnd; - BOOL bFirstPortion; - - const sal_Int32 nStartPos; - const sal_Int32 nEndPos; - - SwUnoCrsr* GetCrsr() const { return (SwUnoCrsr*)GetRegisteredIn(); } - SwXTextPortionEnumeration(); - void CreatePortions(); -protected: - virtual ~SwXTextPortionEnumeration(); -public: - SwXTextPortionEnumeration(SwPaM& rParaCrsr, - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent, - sal_Int32 nStart, sal_Int32 nEnd ); - - - 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); - - //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); -}; /* -----------------29.09.98 09:01------------------- * @@ -1437,6 +1419,16 @@ public: /* -----------------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 { @@ -1447,7 +1439,7 @@ class SwXReferenceMark : public SwRefMarkBaseClass, BOOL m_bIsDescriptor; BOOL IsValid() const {return 0 != GetRegisteredIn();} - void InsertRefMark( SwPaM& rPam ); + void InsertRefMark( SwPaM& rPam, SwXTextCursor * pCursor ); public: SwXReferenceMark(SwDoc* pDoc, const SwFmtRefMark* pMark); ~SwXReferenceMark(); diff --git a/sw/inc/unoport.hxx b/sw/inc/unoport.hxx index 889442d47a21..ef20027994cf 100644 --- a/sw/inc/unoport.hxx +++ b/sw/inc/unoport.hxx @@ -29,27 +29,41 @@ ************************************************************************/ #ifndef _UNOPORT_HXX #define _UNOPORT_HXX + +#include <unocrsr.hxx> #include <unoevtlstnr.hxx> #include <calbck.hxx> -#include <cppuhelper/implbase6.hxx> + #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/text/XTextRange.hpp> +#include <com/sun/star/container/XEnumeration.hpp> #include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/container/XEnumerationAccess.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/text/XTextField.hpp> +#include <com/sun/star/text/XFootnote.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <cppuhelper/implbase8.hxx> -#include <cppuhelper/implbase9.hxx> +#include <cppuhelper/implbase3.hxx> #include <svtools/itemprop.hxx> +#include <memory> +#include <deque> + + class SwFmtFld; class SwFrmFmt; -class SwUnoCrsr; class SwTxtRuby; + + +typedef ::std::deque< + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > > + TextRangeList_t; + + /* -----------------29.05.98 14:42------------------- * * --------------------------------------------------*/ @@ -59,7 +73,7 @@ enum SwTextPortionType PORTION_FIELD, PORTION_FRAME, PORTION_FOOTNOTE, - PORTION_CONTROL_CHAR, +// obsolete! PORTION_CONTROL_CHAR, PORTION_REFMARK_START, PORTION_REFMARK_END, PORTION_TOXMARK_START, @@ -71,20 +85,19 @@ enum SwTextPortionType PORTION_RUBY_START, PORTION_RUBY_END, PORTION_SOFT_PAGEBREAK, + PORTION_META, PORTION_FIELD_START, PORTION_FIELD_END, PORTION_FIELD_START_END }; -class SwXRubyPortion; -class SwXTextPortion : public cppu::WeakImplHelper9 +class SwXTextPortion : public cppu::WeakImplHelper8 < ::com::sun::star::beans::XTolerantMultiPropertySet, ::com::sun::star::beans::XMultiPropertySet, ::com::sun::star::beans::XPropertySet, ::com::sun::star::text::XTextRange, - ::com::sun::star::text::XTextField, ::com::sun::star::beans::XPropertyState, ::com::sun::star::container::XContentEnumerationAccess, ::com::sun::star::lang::XUnoTunnel, @@ -92,29 +105,39 @@ class SwXTextPortion : public cppu::WeakImplHelper9 >, public SwClient { - friend class SwXRubyPortion; - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xRefMark; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xTOXMark; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xBookmark; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xFootnote; - ::com::sun::star::uno::Any* pRubyText; - ::com::sun::star::uno::Any* pRubyStyle; - ::com::sun::star::uno::Any* pRubyAdjust; - ::com::sun::star::uno::Any* pRubyIsAbove; - - const SwFmtFld* pFmtFld; - SwDepend aFrameDepend; - SwFrmFmt* pFrameFmt; - SwTextPortionType ePortionType; - sal_Int16 nControlChar; - - BOOL bIsCollapsed; - - SwFmtFld* GetFldFmt(BOOL bInit = sal_False); +private: + + SwEventListenerContainer m_ListenerContainer; + const SfxItemPropertySet * m_pPropSet; + const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + m_xParentText; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > + m_xRefMark; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > + m_xTOXMark; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > + m_xBookmark; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XFootnote > + m_xFootnote; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > + m_xTextField; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > + m_xMeta; + ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyText; + ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyStyle; + ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyAdjust; + ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyIsAbove; + + const SwDepend m_FrameDepend; + SwFrmFmt * m_pFrameFmt; + const SwTextPortionType m_ePortionType; + + bool m_bIsCollapsed; + + SwFmtFld * GetFldFmt(bool bInit = false); + protected: + //SfxItemPropertySet& GetPropSet() { return aPropSet; } void SAL_CALL SetPropertyValues_Impl( @@ -140,16 +163,23 @@ protected: sal_Bool bDirectValuesOnly ) throw (::com::sun::star::uno::RuntimeException); virtual ~SwXTextPortion(); + public: SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, SwTextPortionType eType ); SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, SwFrmFmt& rFmt ); + // for Ruby + SwXTextPortion(const SwUnoCrsr* pPortionCrsr, + SwTxtRuby const& rAttr, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + const& xParent, + sal_Bool bIsEnd ); //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 ::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& aString) throw( ::com::sun::star::uno::RuntimeException ); //XTolerantMultiPropertySet @@ -180,15 +210,12 @@ public: 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); - //XTextField - virtual rtl::OUString SAL_CALL getPresentation(BOOL bShowCommand) 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 dispose() 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 ); @@ -197,48 +224,105 @@ public: virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) 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 ); + 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 ); //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 ); + virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames() throw( ::com::sun::star::uno::RuntimeException ); //SwClient virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - void SetRefMark( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xMark) - {xRefMark = xMark;} + void SetRefMark( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > xMark) + { m_xRefMark = xMark; } - void SetTOXMark( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xMark) - {xTOXMark = xMark;} + void SetTOXMark( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > xMark) + { m_xTOXMark = xMark; } - void SetBookmark( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xMark) - {xBookmark = xMark;} + void SetBookmark( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > xMark) + { m_xBookmark = xMark; } - void SetFootnote( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xMark) - {xFootnote = xMark;} + void SetFootnote( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XFootnote > xNote) + { m_xFootnote = xNote; } - void SetControlChar(sal_Int16 nSet) {nControlChar = nSet;} + void SetTextField( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextField> xField) + { m_xTextField = xField; } - BOOL IsCollapsed() const { return bIsCollapsed;} - void SetCollapsed(BOOL bSet) { bIsCollapsed = bSet;} + void SetMeta( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > xMeta) + { m_xMeta = xMeta; } - SwTextPortionType GetTextPortionType() const {return ePortionType;} + bool IsCollapsed() const { return m_bIsCollapsed; } + void SetCollapsed(bool bSet) { m_bIsCollapsed = bSet;} - SwUnoCrsr* GetCrsr() const { return (SwUnoCrsr*)GetRegisteredIn(); } + SwTextPortionType GetTextPortionType() const { return m_ePortionType; } + + SwUnoCrsr* GetCursor() const + {return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));} }; -/* -----------------------------19.02.01 10:46-------------------------------- - ---------------------------------------------------------------------------*/ -class SwXRubyPortion : public SwXTextPortion +/* -----------------29.05.98 14:42------------------- + * + * --------------------------------------------------*/ +class SwXTextPortionEnumeration + : public ::cppu::WeakImplHelper3 + < ::com::sun::star::container::XEnumeration + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::lang::XUnoTunnel + > + , public SwClient { + TextRangeList_t m_Portions; // contains all portions, filled by ctor + + SwUnoCrsr* GetCursor() const + {return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));} + +protected: + virtual ~SwXTextPortionEnumeration(); + public: - SwXRubyPortion(const SwUnoCrsr* pPortionCrsr, - SwTxtRuby& rAttr, - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, - sal_Bool bEnd ); - ~SwXRubyPortion(); + SwXTextPortionEnumeration(SwPaM& rParaCrsr, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + const & xParent, + const sal_Int32 nStart, const sal_Int32 nEnd ); + + SwXTextPortionEnumeration(SwPaM& rParaCrsr, + TextRangeList_t const & rPortions ); + + + 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); + + //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); }; + #endif diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index c9f4d1d01265..56360281915d 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -807,7 +807,8 @@ enum SwPropNameIds // --> OD 2009-07-13 #i73249# /* 0737 */ UNO_NAME_DESCRIPTION, // <-- -/* 0738 */ SW_PROPNAME_END +/* 0738 */ UNO_NAME_META, // #i91565# +/* 0739 */ SW_PROPNAME_END }; diff --git a/sw/qa/complex/writer/makefile.mk b/sw/qa/complex/writer/makefile.mk index 7bcc7fe934c9..de5200d47142 100755 --- a/sw/qa/complex/writer/makefile.mk +++ b/sw/qa/complex/writer/makefile.mk @@ -41,7 +41,7 @@ PACKAGE = complex$/writer #----- compile .java files ----------------------------------------- JARFILES = mysql.jar sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar -JAVAFILES = CheckIndexedPropertyValues.java CheckNamedPropertyValues.java CheckCrossReferences.java CheckBookmarks.java CheckFlies.java +JAVAFILES = CheckIndexedPropertyValues.java CheckNamedPropertyValues.java CheckCrossReferences.java CheckBookmarks.java CheckFlies.java TextPortionEnumerationTest.java JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) #----- make a jar from compiled files ------------------------------ @@ -85,7 +85,9 @@ run: \ CheckCrossReferences \ CheckIndexedPropertyValues \ CheckNamedPropertyValues \ - CheckFlies + CheckFlies \ + TextPortionEnumerationTest \ + RUN: run @@ -105,3 +107,6 @@ CheckBookmarks: CheckFlies: +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) -tdoc $(PWD)$/testdocuments $(CT_PACKAGE).CheckFlies +TextPortionEnumerationTest: + +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) -tdoc $(PWD)$/testdocuments $(CT_PACKAGE).TextPortionEnumerationTest + diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx index 63b4f56b1cbd..cecbb7308f49 100644 --- a/sw/source/core/bastyp/index.cxx +++ b/sw/source/core/bastyp/index.cxx @@ -328,10 +328,10 @@ SwIndexReg::~SwIndexReg() -void SwIndexReg::Update( const SwIndex& rIdx, xub_StrLen nDiff, BOOL bNeg, - BOOL /* argument is only used in derived class*/ ) +void SwIndexReg::Update( SwIndex const & rIdx, const xub_StrLen nDiff, + const bool bNeg, const bool /* argument is only used in derived class*/ ) { - SwIndex* pStt = (SwIndex*)&rIdx; + SwIndex* pStt = const_cast<SwIndex*>(&rIdx); xub_StrLen nNewVal = rIdx.nIndex; if( bNeg ) { diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx index 97ec66969d28..cd0d5321da1e 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -46,9 +46,7 @@ #include <svx/shaditem.hxx> #include <svx/prntitem.hxx> #include <svx/brkitem.hxx> -#ifndef _SVX_TSTPITEM_HXX #include <svx/tstpitem.hxx> -#endif #include <svx/langitem.hxx> #include <svx/wrlmitem.hxx> #include <svx/kernitem.hxx> @@ -62,13 +60,9 @@ #include <svx/lspcitem.hxx> #include <svx/blnkitem.hxx> #include <svx/akrnitem.hxx> -#ifndef _SVX_EMPHITEM_HXX #include <svx/emphitem.hxx> -#endif #include <svx/twolinesitem.hxx> -#ifndef _SVX_SCRIPSPACEITEM_HXX #include <svx/scriptspaceitem.hxx> -#endif #include <svx/hngpnctitem.hxx> #include <svx/cmapitem.hxx> #include <svx/charscaleitem.hxx> @@ -94,7 +88,6 @@ #include <unotools/transliterationwrapper.hxx> #include <svx/acorrcfg.hxx> #include <vcl/svapp.hxx> -#include <fmthbsh.hxx> #include <fmtanchr.hxx> #include <fmtornt.hxx> #include <fmtsrnd.hxx> @@ -116,9 +109,7 @@ #include <fmtautofmt.hxx> #include <fmtinfmt.hxx> #include <fmtcnct.hxx> -#ifndef _FMTLINE_HXX #include <fmtline.hxx> -#endif #include <fmtftntx.hxx> #include <fmtruby.hxx> #include <fmtautofmt.hxx> @@ -137,9 +128,7 @@ #include <doc.hxx> #include <acmplwrd.hxx> #include <fmtclbl.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif #include <breakit.hxx> #include <checkit.hxx> #include <swcalwrp.hxx> @@ -150,6 +139,9 @@ // OD 2004-05-05 #i28701# #include <fmtwrapinfluenceonobjpos.hxx> +#include <fmtmeta.hxx> + + using namespace ::com::sun::star; extern void _FrmFinit(); @@ -327,14 +319,14 @@ SfxItemInfo __FAR_DATA aSlotTab[] = { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY5 { SID_ATTR_CHAR_CJK_RUBY, 0 }, // RES_TXTATR_CJK_RUBY, { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_UNKNOWN_CONTAINER, - { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY6, - { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY7, + { 0, 0 }, // RES_TXTATR_META, + { 0, 0 }, // RES_TXTATR_METAFIELD, { 0, 0 }, // RES_TXTATR_FIELD { 0, 0 }, // RES_TXTATR_FLYCNT { 0, 0 }, // RES_TXTATR_FTN - { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_SOFTHYPH - { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_HARDBLANK + { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY4 + { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY3 { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY1 { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY2 @@ -544,19 +536,19 @@ void _InitCore() aAttrTab[ RES_TXTATR_CHARFMT- POOLATTR_BEGIN ] = new SwFmtCharFmt( 0 ); aAttrTab[ RES_TXTATR_CJK_RUBY - POOLATTR_BEGIN ] = new SwFmtRuby( aEmptyStr ); aAttrTab[ RES_TXTATR_UNKNOWN_CONTAINER - POOLATTR_BEGIN ] = new SvXMLAttrContainerItem( RES_TXTATR_UNKNOWN_CONTAINER ); + aAttrTab[ RES_TXTATR_META - POOLATTR_BEGIN ] = SwFmtMeta::CreatePoolDefault(RES_TXTATR_META); + aAttrTab[ RES_TXTATR_METAFIELD - POOLATTR_BEGIN ] = SwFmtMeta::CreatePoolDefault(RES_TXTATR_METAFIELD); aAttrTab[ RES_TXTATR_FIELD- POOLATTR_BEGIN ] = new SwFmtFld; aAttrTab[ RES_TXTATR_FLYCNT - POOLATTR_BEGIN ] = new SwFmtFlyCnt( 0 ); aAttrTab[ RES_TXTATR_FTN - POOLATTR_BEGIN ] = new SwFmtFtn; - aAttrTab[ RES_TXTATR_SOFTHYPH- POOLATTR_BEGIN ] = new SwFmtSoftHyph; - aAttrTab[ RES_TXTATR_HARDBLANK- POOLATTR_BEGIN ] = new SwFmtHardBlank( ' ', FALSE ); // TextAttr - Dummies + aAttrTab[ RES_TXTATR_DUMMY4 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY4 ); + aAttrTab[ RES_TXTATR_DUMMY3 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY3 ); aAttrTab[ RES_TXTATR_DUMMY1 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY1 ); aAttrTab[ RES_TXTATR_DUMMY2 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY2 ); aAttrTab[ RES_TXTATR_DUMMY5 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY5 ); - aAttrTab[ RES_TXTATR_DUMMY6 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY6 ); - aAttrTab[ RES_TXTATR_DUMMY7 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY7 ); // TextAttr - Dummies aAttrTab[ RES_PARATR_LINESPACING- POOLATTR_BEGIN ] = new SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT, RES_PARATR_LINESPACING ); diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 3179e3fb3330..3cdfa7ec03e4 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -42,8 +42,10 @@ #include <svx/linkmgr.hxx> #include <swtypes.hxx> #include <undobj.hxx> +#include <unoobj.hxx> #include <rtl/random.h> + SV_IMPL_REF( SwServerObject ) using namespace ::sw::mark; @@ -85,9 +87,13 @@ namespace const SwPaM aEndPaM(rEnd); io_pDoc->StartUndo(UNDO_UI_REPLACE, NULL); if(ch_start != aStartMark) - io_pDoc->Insert(aStartPaM, aStartMark); + { + io_pDoc->InsertString(aStartPaM, aStartMark); + } if(aEndMark && ch_end != aEndMark) - io_pDoc->Insert(aEndPaM, aEndMark); + { + io_pDoc->InsertString(aEndPaM, aEndMark); + } io_pDoc->EndUndo(UNDO_UI_REPLACE, NULL); }; } @@ -190,6 +196,7 @@ namespace sw { namespace mark const ::rtl::OUString& rName, const ::rtl::OUString& rShortName) : DdeBookmark(aPaM) + , ::sfx2::Metadatable() , m_aCode(rCode) , m_sShortName(rShortName) { @@ -206,6 +213,54 @@ namespace sw { namespace mark io_pDoc->SetModified(); } + // ::sfx2::Metadatable + ::sfx2::IXmlIdRegistry& Bookmark::GetRegistry() + { + SwDoc *const pDoc( GetMarkPos().GetDoc() ); + OSL_ENSURE(pDoc, "Bookmark::MakeUnoObject: no doc?"); + return pDoc->GetXmlIdRegistry(); + } + + bool Bookmark::IsInClipboard() const + { + SwDoc *const pDoc( GetMarkPos().GetDoc() ); + OSL_ENSURE(pDoc, "Bookmark::IsInClipboard: no doc?"); + return pDoc->IsClipBoard(); + } + + bool Bookmark::IsInUndo() const + { + return false; + } + + bool Bookmark::IsInContent() const + { + SwDoc *const pDoc( GetMarkPos().GetDoc() ); + OSL_ENSURE(pDoc, "Bookmark::IsInContent: no doc?"); + return !pDoc->IsInHeaderFooter( SwNodeIndex(GetMarkPos().nNode) ); + } + + ::com::sun::star::uno::Reference< ::com::sun::star::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); + } + + Fieldmark::Fieldmark(const SwPaM& rPaM) : MarkBase(rPaM, MarkBase::GenerateNewName(our_sNamePrefix)) { diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 87a579150e76..23a9bf139ef1 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -1124,8 +1124,8 @@ BOOL SwCrsrShell::GetContentAtPos( const Point& rPt, if( !bRet && ( SwContentAtPos::SW_FIELD | SwContentAtPos::SW_CLICKFIELD ) & rCntntAtPos.eCntntAtPos && !aTmpState.bFtnNoInfo ) { - pTxtAttr = pTxtNd->GetTxtAttr( aPos.nContent.GetIndex(), - RES_TXTATR_FIELD ); + pTxtAttr = pTxtNd->GetTxtAttrForCharAt( + aPos.nContent.GetIndex(), RES_TXTATR_FIELD ); const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0; @@ -1190,7 +1190,7 @@ BOOL SwCrsrShell::GetContentAtPos( const Point& rPt, if( bRet ) rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FTN; } - else if( 0 != ( pTxtAttr = pTxtNd->GetTxtAttr( + else if ( 0 != ( pTxtAttr = pTxtNd->GetTxtAttrForCharAt( aPos.nContent.GetIndex(), RES_TXTATR_FTN )) ) { bRet = TRUE; @@ -1526,9 +1526,8 @@ const SwPostItField* SwCrsrShell::GetPostItFieldAtCursor() const const SwTxtNode* pTxtNd = pCursorPos->nNode.GetNode().GetTxtNode(); if ( pTxtNd ) { - SwTxtAttr* pTxtAttr = - pTxtNd->GetTxtAttr( pCursorPos->nContent.GetIndex(), - RES_TXTATR_FIELD ); + SwTxtAttr* pTxtAttr = pTxtNd->GetTxtAttrForCharAt( + pCursorPos->nContent.GetIndex(), RES_TXTATR_FIELD ); const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0; if ( pFld && pFld->Which()== RES_POSTITFLD ) { @@ -1766,7 +1765,7 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) if( n < aFPos.nColumnCnt ) { *pCurCrsr->GetPoint() = aPos; - GetDoc()->Insert( *pCurCrsr, + GetDoc()->InsertPoolItem( *pCurCrsr, SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE, RES_BREAK ), 0); } } @@ -1792,7 +1791,7 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) if( SVX_ADJUST_LEFT != rAdj.GetAdjust() ) aSet.Put( SvxAdjustItem( SVX_ADJUST_LEFT, RES_PARATR_ADJUST ) ); - GetDoc()->Insert( *pCurCrsr, aSet, 0 ); + GetDoc()->InsertItemSet( *pCurCrsr, aSet, 0 ); } else { ASSERT( !this, "wo ist mein CntntNode?" ); @@ -1812,7 +1811,9 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) sInsert += sSpace; } if( sInsert.Len() ) - GetDoc()->Insert( *pCurCrsr, sInsert, true ); + { + GetDoc()->InsertString( *pCurCrsr, sInsert ); + } } // kein break - Ausrichtung muss noch gesetzt werden case FILL_MARGIN: @@ -1830,7 +1831,7 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) default: break; } - GetDoc()->Insert( *pCurCrsr, aAdj, 0 ); + GetDoc()->InsertPoolItem( *pCurCrsr, aAdj, 0 ); } break; } diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx index 4a98c1ce558e..5697912b21fe 100644 --- a/sw/source/core/crsr/findattr.cxx +++ b/sw/source/core/crsr/findattr.cxx @@ -1189,7 +1189,8 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion, if( bReplaceTxt ) { - int bRegExp = SearchAlgorithms_REGEXP == pSearchOpt->algorithmType; + const bool bRegExp( + SearchAlgorithms_REGEXP == pSearchOpt->algorithmType); SwIndex& rSttCntIdx = pCrsr->Start()->nContent; xub_StrLen nSttCnt = rSttCntIdx.GetIndex(); @@ -1202,12 +1203,11 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion, ((Ring*)pRegion)->MoveRingTo( &rCursor ); } - String *pRepl = bRegExp ? ReplaceBackReferences( *pSearchOpt, pCrsr ) : 0; - if( pRepl ) - rCursor.GetDoc()->Replace( *pCrsr, *pRepl, bRegExp ); - else - rCursor.GetDoc()->Replace( *pCrsr, pSearchOpt->replaceString, bRegExp ); - delete pRepl; + ::std::auto_ptr<String> pRepl( (bRegExp) ? + ReplaceBackReferences( *pSearchOpt, pCrsr ) : 0 ); + rCursor.GetDoc()->ReplaceRange( *pCrsr, + (pRepl.get()) ? *pRepl : String(pSearchOpt->replaceString), + bRegExp ); rCursor.SaveTblBoxCntnt( pCrsr->GetPoint() ); if( bRegExp ) @@ -1235,7 +1235,9 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion, // ReplaceSet angegeben, auf Default zurueck gesetzt if( !pSet->Count() ) - pCrsr->GetDoc()->Insert( *pCrsr, *pReplSet, 0 ); + { + pCrsr->GetDoc()->InsertItemSet( *pCrsr, *pReplSet, 0 ); + } else { SfxItemPool* pPool = pReplSet->GetPool(); @@ -1255,7 +1257,7 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion, pItem = aIter.NextItem(); } aSet.Put( *pReplSet ); - pCrsr->GetDoc()->Insert( *pCrsr, aSet, 0 ); + pCrsr->GetDoc()->InsertItemSet( *pCrsr, aSet, 0 ); } #endif return FIND_NO_RING; diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx index 4736127597d4..e5e87a33bc5d 100644 --- a/sw/source/core/crsr/findtxt.cxx +++ b/sw/source/core/crsr/findtxt.cxx @@ -126,7 +126,7 @@ String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart, if ( bNewHint ) { const SwTxtAttr* pHt = (*pHts)[n]; - if ( !pHt->GetEnd() && nStt >= nStart ) + if ( pHt->HasDummyChar() && (nStt >= nStart) ) { //JP 17.05.00: Task 75806 ask for ">=" and not for ">" switch( pHt->Which() ) @@ -136,7 +136,9 @@ String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart, case RES_TXTATR_FIELD: case RES_TXTATR_REFMARK: case RES_TXTATR_TOXMARK: - { + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + { // JP 06.05.98: mit Bug 50100 werden sie als Trenner erwuenscht und nicht // mehr zum Wort dazu gehoerend. // MA 23.06.98: mit Bug 51215 sollen sie konsequenterweise auch am @@ -161,9 +163,6 @@ String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart, } } break; - case RES_TXTATR_HARDBLANK: - rRet.SetChar( nAkt, ((SwTxtHardBlank*)pHt)->GetChar() ); - break; default: ASSERT( false, "unknown case in lcl_CleanStr" ) break; @@ -593,7 +592,7 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove, if( bFnd && bReplace ) // String ersetzen ?? { // Replace-Methode vom SwDoc benutzen - int bRegExp = SearchAlgorithms_REGEXP == rSearchOpt.algorithmType; + const bool bRegExp(SearchAlgorithms_REGEXP == rSearchOpt.algorithmType); SwIndex& rSttCntIdx = pCrsr->Start()->nContent; xub_StrLen nSttCnt = rSttCntIdx.GetIndex(); // damit die Region auch verschoben wird, in den Shell-Cursr-Ring @@ -605,12 +604,11 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove, ((Ring*)pRegion)->MoveRingTo( &rCursor ); } - String *pRepl = bRegExp ? ReplaceBackReferences( rSearchOpt, pCrsr ) : 0; - if( pRepl ) - rCursor.GetDoc()->Replace( *pCrsr, *pRepl, bRegExp ); - else - rCursor.GetDoc()->Replace( *pCrsr, rSearchOpt.replaceString, bRegExp ); - delete pRepl; + ::std::auto_ptr<String> pRepl( (bRegExp) + ? ReplaceBackReferences( rSearchOpt, pCrsr ) : 0 ); + rCursor.GetDoc()->ReplaceRange( *pCrsr, + (pRepl.get()) ? *pRepl : String(rSearchOpt.replaceString), + bRegExp ); rCursor.SaveTblBoxCntnt( pCrsr->GetPoint() ); if( bRegExp ) diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index 6ca8a6de62c2..4b2f9332fb78 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -198,7 +198,12 @@ SwComparePosition ComparePosition( nRet = POS_INSIDE; } else - nRet = POS_OVERLAP_BEHIND; + { + if (rStt1 == rStt2) + nRet = POS_OUTSIDE; + else + nRet = POS_OVERLAP_BEHIND; + } } else if( rEnd2 == rStt1 ) nRet = POS_COLLIDE_START; @@ -237,7 +242,12 @@ SwComparePosition ComparePosition( nRet = POS_INSIDE; } else - nRet = POS_OVERLAP_BEHIND; + { + if (nStt1 == nStt2) + nRet = POS_OUTSIDE; + else + nRet = POS_OVERLAP_BEHIND; + } } else if( nEnd2 == nStt1 ) nRet = POS_COLLIDE_START; diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx index e86a7d23b600..3df68068714d 100644 --- a/sw/source/core/doc/dbgoutsw.cxx +++ b/sw/source/core/doc/dbgoutsw.cxx @@ -173,13 +173,13 @@ map<USHORT,String,CompareUShort> & GetItemWhichMap() aItemWhichMap[RES_TXTATR_DUMMY5] = String("TXTATR_DUMMY5", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_CJK_RUBY] = String("TXTATR_CJK_RUBY", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_UNKNOWN_CONTAINER] = String("TXTATR_UNKNOWN_CONTAINER", RTL_TEXTENCODING_ASCII_US); - aItemWhichMap[RES_TXTATR_DUMMY6] = String("TXTATR_DUMMY6", RTL_TEXTENCODING_ASCII_US); - aItemWhichMap[RES_TXTATR_DUMMY7] = String("TXTATR_DUMMY7", RTL_TEXTENCODING_ASCII_US); + aItemWhichMap[RES_TXTATR_META] = String("TXTATR_META", RTL_TEXTENCODING_ASCII_US); + aItemWhichMap[RES_TXTATR_METAFIELD] = String("TXTATR_METAFIELD", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_FIELD] = String("TXTATR_FIELD", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_FLYCNT] = String("TXTATR_FLYCNT", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_FTN] = String("TXTATR_FTN", RTL_TEXTENCODING_ASCII_US); - aItemWhichMap[RES_TXTATR_SOFTHYPH] = String("TXTATR_SOFTHYPH", RTL_TEXTENCODING_ASCII_US); - aItemWhichMap[RES_TXTATR_HARDBLANK] = String("TXTATR_HARDBLANK", RTL_TEXTENCODING_ASCII_US); + aItemWhichMap[RES_TXTATR_DUMMY4] = String("TXTATR_DUMMY4", RTL_TEXTENCODING_ASCII_US); + aItemWhichMap[RES_TXTATR_DUMMY3] = String("TXTATR_DUMMY3", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_DUMMY1] = String("TXTATR_DUMMY1", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_DUMMY2] = String("TXTATR_DUMMY2", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_PARATR_LINESPACING] = String("PARATR_LINESPACING", RTL_TEXTENCODING_ASCII_US); diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 926a555c8a4e..4fd1988a2f7b 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -627,7 +627,7 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) { SwCntntNode *pNode = rPos.nNode.GetNode().GetCntntNode(); if(0 == pNode) - return FALSE; + return false; { // Bug 26675: DataChanged vorm loeschen verschicken, dann bekommt @@ -642,7 +642,10 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) ClearRedo(); // einfuegen vom Undo-Object, z.Z. nur beim TextNode if( pNode->IsTxtNode() ) - AppendUndo( pUndo = new SwUndoSplitNode( this, rPos, bChkTableStart )); + { + pUndo = new SwUndoSplitNode( this, rPos, bChkTableStart ); + AppendUndo(pUndo); + } } //JP 28.01.97: Sonderfall fuer SplitNode am Tabellenanfang: @@ -712,7 +715,7 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) if( pUndo ) pUndo->SetTblFlag(); SetModified(); - return TRUE; + return true; } } } @@ -721,7 +724,10 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) SvULongs aBkmkArr( 15, 15 ); _SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), aBkmkArr, SAVEFLY_SPLIT ); - if( 0 != ( pNode = pNode->SplitCntntNode( rPos ) )) + // FIXME: only SwTxtNode has a valid implementation of SplitCntntNode! + ASSERT(pNode->IsTxtNode(), "splitting non-text node?"); + pNode = pNode->SplitCntntNode( rPos ); + if (pNode) { // verschiebe noch alle Bookmarks/TOXMarks/FlyAtCnt if( aBkmkArr.Count() ) @@ -740,7 +746,7 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) } SetModified(); - return TRUE; + return true; } bool SwDoc::AppendTxtNode( SwPosition& rPos ) @@ -783,73 +789,86 @@ bool SwDoc::AppendTxtNode( SwPosition& rPos ) return TRUE; } -bool SwDoc::Insert( const SwPaM &rRg, const String &rStr, bool bHintExpand ) +bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr, + const enum InsertFlags nInsertMode ) { if( DoesUndo() ) + { ClearRedo(); + } - const SwPosition* pPos = rRg.GetPoint(); + const SwPosition& rPos = *rRg.GetPoint(); if( pACEWord ) // Aufnahme in die Autokorrektur { if( 1 == rStr.Len() && pACEWord->IsDeleted() ) - pACEWord->CheckChar( *pPos, rStr.GetChar( 0 ) ); + { + pACEWord->CheckChar( rPos, rStr.GetChar( 0 ) ); + } delete pACEWord, pACEWord = 0; } - SwTxtNode *pNode = pPos->nNode.GetNode().GetTxtNode(); + SwTxtNode *const pNode = rPos.nNode.GetNode().GetTxtNode(); if(!pNode) - return FALSE; + { + return false; + } - const USHORT nInsMode = bHintExpand ? INS_EMPTYEXPAND - : INS_NOHINTEXPAND; SwDataChanged aTmp( rRg, 0 ); if( !DoesUndo() || !DoesGroupUndo() ) { - pNode->Insert( rStr, pPos->nContent, nInsMode ); + pNode->InsertText( rStr, rPos.nContent, nInsertMode ); if( DoesUndo() ) - AppendUndo( new SwUndoInsert( pPos->nNode, - pPos->nContent.GetIndex(), rStr.Len() )); + { + SwUndoInsert * const pUndo( new SwUndoInsert( + rPos.nNode, rPos.nContent.GetIndex(), rStr.Len(), nInsertMode)); + AppendUndo(pUndo); + } } else { // ist Undo und Gruppierung eingeschaltet, ist alles anders ! - USHORT nUndoSize = pUndos->Count(); - xub_StrLen nInsPos = pPos->nContent.GetIndex(); SwUndoInsert * pUndo = NULL; // #111827# - CharClass& rCC = GetAppCharClass(); + // don't group the start if hints at the start should be expanded + if (!(nInsertMode & IDocumentContentOperations::INS_FORCEHINTEXPAND)) // -> #111827# - bool bNewUndo = false; - if( 0 == nUndoSize) - bNewUndo = true; - else { - pUndo = (SwUndoInsert*)(*pUndos)[ --nUndoSize ]; - - switch (pUndo->GetId()) + USHORT const nUndoSize = pUndos->Count(); + if (0 != nUndoSize) { - case UNDO_INSERT: - case UNDO_TYPING: - bNewUndo = !pUndo->CanGrouping( *pPos ); + SwUndo * const pLastUndo = (*pUndos)[ nUndoSize - 1 ]; - break; + switch (pLastUndo->GetId()) + { + case UNDO_INSERT: + case UNDO_TYPING: + if (static_cast<SwUndoInsert*>(pLastUndo) + ->CanGrouping( rPos )) + { + pUndo = static_cast<SwUndoInsert*>(pLastUndo); + } + break; - default: - bNewUndo = true; + default: + break; + } } } // <- #111827# - if (bNewUndo) + CharClass const& rCC = GetAppCharClass(); + xub_StrLen nInsPos = rPos.nContent.GetIndex(); + + if (!pUndo) { - pUndo = new SwUndoInsert( pPos->nNode, nInsPos, 0, + pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 0, nInsertMode, !rCC.isLetterNumeric( rStr, 0 ) ); AppendUndo( pUndo ); } - pNode->Insert( rStr, pPos->nContent, nInsMode ); + pNode->InsertText( rStr, rPos.nContent, nInsertMode ); for( xub_StrLen i = 0; i < rStr.Len(); ++i ) { @@ -857,7 +876,7 @@ bool SwDoc::Insert( const SwPaM &rRg, const String &rStr, bool bHintExpand ) // wenn CanGrouping() TRUE returnt, ist schon alles erledigt if( !pUndo->CanGrouping( rStr.GetChar( i ) )) { - pUndo = new SwUndoInsert( pPos->nNode, nInsPos, 1, + pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 1, nInsertMode, !rCC.isLetterNumeric( rStr, i ) ); AppendUndo( pUndo ); } @@ -866,16 +885,21 @@ bool SwDoc::Insert( const SwPaM &rRg, const String &rStr, bool bHintExpand ) if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() )) { - SwPaM aPam( pPos->nNode, aTmp.GetCntnt(), - pPos->nNode, pPos->nContent.GetIndex()); + SwPaM aPam( rPos.nNode, aTmp.GetCntnt(), + rPos.nNode, rPos.nContent.GetIndex()); if( IsRedlineOn() ) - AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); + { + AppendRedline( + new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); + } else + { SplitRedline( aPam ); + } } SetModified(); - return TRUE; + return true; } SwFlyFrmFmt* SwDoc::_InsNoTxtNode( const SwPosition& rPos, SwNoTxtNode* pNode, @@ -1506,7 +1530,7 @@ BOOL SwDoc::RemoveInvisibleContent() ( 1 == pTxtNd->EndOfSectionIndex() - pTxtNd->GetIndex() && !GetNodes()[ pTxtNd->GetIndex() - 1 ]->GetTxtNode() ) ) { - Delete( aPam ); + DeleteRange( aPam ); } else { @@ -1542,7 +1566,7 @@ BOOL SwDoc::RemoveInvisibleContent() ( 1 == pTxtNd->EndOfSectionIndex() - pTxtNd->GetIndex() && !GetNodes()[ pTxtNd->GetIndex() - 1 ]->GetTxtNode() ) ) { - Delete( aPam ); + DeleteRange( aPam ); } else { @@ -1628,7 +1652,7 @@ BOOL SwDoc::RemoveInvisibleContent() &aPam.GetPoint()->nNode ); aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); - Delete( aPam ); + DeleteRange( aPam ); } else { @@ -1712,7 +1736,8 @@ BOOL SwDoc::ConvertFieldsToText() //now remove the field and insert the string SwPaM aPam1(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); aPam1.Move(); - Insert( aPam1, sText, true );//insert first to keep the field's attributes + //insert first to keep the field's attributes + InsertString( aPam1, sText ); SwPaM aPam2(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); aPam2.SetMark(); aPam2.Move(); @@ -1918,24 +1943,19 @@ String SwDoc::GetPaMDescr(const SwPaM & rPam) const // -> #111840# SwField * SwDoc::GetField(const SwPosition & rPos) { - SwField * pResult = NULL; - - SwTxtFld * pAttr = rPos.nNode.GetNode().GetTxtNode()-> - GetTxtFld(rPos.nContent); - - if (pAttr) - pResult = (SwField *) pAttr->GetFld().GetFld(); + SwTxtFld * const pAttr = GetTxtFld(rPos); - return pResult; + return (pAttr) ? const_cast<SwField *>( pAttr->GetFld().GetFld() ) : 0; } SwTxtFld * SwDoc::GetTxtFld(const SwPosition & rPos) { - SwTxtNode *pNode = rPos.nNode.GetNode().GetTxtNode(); - if( pNode ) - return pNode->GetTxtFld( rPos.nContent ); - else - return 0; + SwTxtNode * const pNode = rPos.nNode.GetNode().GetTxtNode(); + + return (pNode) + ? static_cast<SwTxtFld*>( pNode->GetTxtAttrForCharAt( + rPos.nContent.GetIndex(), RES_TXTATR_FIELD) ) + : 0; } // <- #111840# diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index d838b277bdf5..e1b4f3ee4322 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -995,6 +995,14 @@ SaveBookmark::SaveBookmark( { m_aShortName = pBookmark->GetShortName(); m_aCode = pBookmark->GetKeyCode(); + + ::sfx2::Metadatable * const pMetadatable( + const_cast< ::sfx2::Metadatable * >( // CreateUndo should be const? + dynamic_cast< ::sfx2::Metadatable const* >(pBookmark))); + if (pMetadatable) + { + m_pMetadataUndo = pMetadatable->CreateUndo(); + } } m_nNode1 = rBkmk.GetMarkPos().nNode.GetIndex(); m_nCntnt1 = rBkmk.GetMarkPos().nContent.GetIndex(); @@ -1073,6 +1081,16 @@ void SaveBookmark::SetInDoc( { pBookmark->SetKeyCode(m_aCode); pBookmark->SetShortName(m_aShortName); + if (m_pMetadataUndo) + { + ::sfx2::Metadatable * const pMeta( + dynamic_cast< ::sfx2::Metadatable* >(pBookmark)); + OSL_ENSURE(pMeta, "metadata undo, but not metadatable?"); + if (pMeta) + { + pMeta->RestoreMetadata(m_pMetadataUndo); + } + } } } } diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index fb94d433d14f..68c84dd3b644 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -1196,7 +1196,8 @@ BOOL SwCompareLine::ChangesInLine( const SwCompareLine& rLine, SwPaM aCpyPam( rSrcNd, nStt ); aCpyPam.SetMark(); aCpyPam.GetPoint()->nContent = nSEnd; - aCpyPam.GetDoc()->Copy( aCpyPam, *aPam.GetPoint(), false ); + aCpyPam.GetDoc()->CopyRange( aCpyPam, *aPam.GetPoint(), + false ); pDoc->DoUndo( bUndo ); } @@ -1624,7 +1625,9 @@ USHORT _SaveMergeRedlines::InsertRedline( FNInsUndo pFn ) RedlineMode_t eOld = pDoc->GetRedlineMode(); pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); - pSrcRedl->GetDoc()->Copy( *(SwPaM*)pSrcRedl, *pDestRedl->GetPoint(), false ); + pSrcRedl->GetDoc()->CopyRange( + *const_cast<SwPaM*>(static_cast<const SwPaM*>(pSrcRedl)), + *pDestRedl->GetPoint(), false ); pDoc->SetRedlineMode_intern( eOld ); pDoc->DoUndo( bUndo ); diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index cf55334fadc1..ddc6024c89ae 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -163,24 +163,11 @@ SV_DECL_PTRARR_DEL( _SaveRedlines, _SaveRedline*, 0, 4 ) SV_IMPL_VARARR( _SaveFlyArr, _SaveFly ) SV_IMPL_PTRARR( _SaveRedlines, _SaveRedline* ) -sal_Bool lcl_MayOverwrite( const SwTxtNode *pNode, const xub_StrLen nPos ) +bool lcl_MayOverwrite( const SwTxtNode *pNode, const xub_StrLen nPos ) { - sal_Bool bRet = sal_True; - const SwTxtAttr *pHt; sal_Unicode cChr = pNode->GetTxt().GetChar( nPos ); - if( ( CH_TXTATR_BREAKWORD == cChr || CH_TXTATR_INWORD == cChr ) && - 0 != (pHt = pNode->GetTxtAttr( nPos )) ) - switch( pHt->Which() ) - { - case RES_TXTATR_FLYCNT: - case RES_TXTATR_FTN: - case RES_TXTATR_FIELD: - case RES_TXTATR_REFMARK: - case RES_TXTATR_TOXMARK: - bRet = sal_False; - break; - } - return bRet; + return !( ( CH_TXTATR_BREAKWORD == cChr || CH_TXTATR_INWORD == cChr ) && + (0 != pNode->GetTxtAttrForCharAt( nPos ) ) ); } void lcl_SkipAttr( const SwTxtNode *pNode, SwIndex &rIdx, xub_StrLen &rStart ) @@ -421,7 +408,7 @@ bool lcl_SaveFtn( const SwNodeIndex& rSttNd, const SwNodeIndex& rEndNd, { SwTxtNode& rTxtNd = (SwTxtNode&)pSrch->GetTxtNode(); SwIndex aIdx( &rTxtNd, nFtnSttIdx ); - rTxtNd.Erase( aIdx, 1 ); + rTxtNd.EraseText( aIdx, 1 ); } else { @@ -449,7 +436,7 @@ bool lcl_SaveFtn( const SwNodeIndex& rSttNd, const SwNodeIndex& rEndNd, // dann weg damit SwTxtNode& rTxtNd = (SwTxtNode&)pSrch->GetTxtNode(); SwIndex aIdx( &rTxtNd, nFtnSttIdx ); - rTxtNd.Erase( aIdx, 1 ); + rTxtNd.EraseText( aIdx, 1 ); } else { @@ -764,64 +751,6 @@ void SwDoc::DeleteSection( SwNode *pNode ) } - -/************************************************************************* -|* SwDoc::Insert(char) -|* Beschreibung Zeichen einfuegen -*************************************************************************/ - -bool SwDoc::Insert( const SwPaM &rRg, sal_Unicode c ) -{ - if( DoesUndo() ) - ClearRedo(); - - const SwPosition & rPos = *rRg.GetPoint(); - - if( pACEWord ) // Aufnahme in die Autokorrektur - { - if( pACEWord->IsDeleted() ) - pACEWord->CheckChar( rPos, c ); - delete pACEWord, pACEWord = 0; - } - SwTxtNode *pNode = rPos.nNode.GetNode().GetTxtNode(); - if(!pNode) - return sal_False; - sal_Bool bInsOneChar = sal_True; - - SwDataChanged aTmp( rRg, 0 ); - - pNode->Insert( c, rPos.nContent ); - - if ( DoesUndo() ) - { - sal_uInt16 nUndoSize = pUndos->Count(); - SwUndo * pUndo; - if( DoesGroupUndo() && bInsOneChar && nUndoSize-- && - UNDO_INSERT == ( pUndo = (*pUndos)[ nUndoSize ])->GetId() && - ((SwUndoInsert*)pUndo)->CanGrouping( rPos, c )) - ; // wenn CanGrouping() sal_True returnt, ist schon alles erledigt - else - AppendUndo( new SwUndoInsert( rPos.nNode, - rPos.nContent.GetIndex(), 1, - !GetAppCharClass().isLetterNumeric( - pNode->GetTxt(), - rPos.nContent.GetIndex() - 1 ))); - } - - if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() )) - { - SwPaM aPam( rPos.nNode, rPos.nContent.GetIndex() - 1, - rPos.nNode, rPos.nContent.GetIndex() ); - if( IsRedlineOn() ) - AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); - else - SplitRedline( aPam ); - } - - SetModified(); - return sal_True; -} - void SwDoc::SetModified(SwPaM &rPaM) { SwDataChanged aTmp( rPaM, 0 ); @@ -829,91 +758,8 @@ void SwDoc::SetModified(SwPaM &rPaM) } /************************************************************************* -|* SwDoc::Overwrite(char) -|* Beschreibung Zeichen ueberschreiben -*************************************************************************/ - -bool SwDoc::Overwrite( const SwPaM &rRg, sal_Unicode c ) -{ - SwPosition& rPt = *(SwPosition*)rRg.GetPoint(); - if( pACEWord ) // Aufnahme in die Autokorrektur - { - pACEWord->CheckChar( rPt, c ); - delete pACEWord, pACEWord = 0; - } - - SwTxtNode *pNode = rPt.nNode.GetNode().GetTxtNode(); - if(!pNode) - return sal_False; - - sal_uInt16 nOldAttrCnt = pNode->GetpSwpHints() - ? pNode->GetpSwpHints()->Count() : 0; - SwDataChanged aTmp( rRg, 0 ); - SwIndex& rIdx = rPt.nContent; - xub_StrLen nStart = rIdx.GetIndex(); - - // hinter das Zeichen (zum aufspannen der Attribute !!) - if( nStart < pNode->GetTxt().Len() ) - lcl_SkipAttr( pNode, rIdx, nStart ); - - if( DoesUndo() ) - { - ClearRedo(); - sal_uInt16 nUndoSize = pUndos->Count(); - SwUndo * pUndo; - if( DoesGroupUndo() && nUndoSize-- && - UNDO_OVERWRITE == ( pUndo = (*pUndos)[ nUndoSize ])->GetId() && - ((SwUndoOverwrite*)pUndo)->CanGrouping( this, rPt, c )) - ;// wenn CanGrouping() sal_True returnt, ist schon alles erledigt - else - AppendUndo( new SwUndoOverwrite( this, rPt, c )); - } - else - { - BOOL bOldExpFlg = pNode->IsIgnoreDontExpand(); - pNode->SetIgnoreDontExpand( TRUE ); - - // hinter das Zeichen (zum aufspannen der Attribute !!) - if( nStart < pNode->GetTxt().Len() ) - rIdx++; - pNode->Insert( c, rIdx ); - if( nStart+1 < rIdx.GetIndex() ) - { - rIdx = nStart; - pNode->Erase( rIdx, 1 ); - rIdx++; - } - pNode->SetIgnoreDontExpand( bOldExpFlg ); - } - - sal_uInt16 nNewAttrCnt = pNode->GetpSwpHints() - ? pNode->GetpSwpHints()->Count() : 0; - if( nOldAttrCnt != nNewAttrCnt ) - { - SwUpdateAttr aHint( 0, 0, 0 ); - SwClientIter aIter( *pNode ); - SwClient* pGTO = aIter.First(TYPE( SwCrsrShell )); - while( pGTO ) - { - pGTO->Modify( 0, &aHint ); - pGTO = aIter.Next(); - } - } - - if( !DoesUndo() && !IsIgnoreRedline() && GetRedlineTbl().Count() ) - { - SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() ); - DeleteRedline( aPam, true, USHRT_MAX ); - } - else if( IsRedlineOn() ) - { - SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() ); - AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); - } - - SetModified(); - return sal_True; -} + * SwDoc::Overwrite() + ************************************************************************/ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) { @@ -949,8 +795,11 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) for( xub_StrLen nCnt = 0; nCnt < rStr.Len(); ++nCnt ) { // hinter das Zeichen (zum aufspannen der Attribute !!) - if( (nStart = rIdx.GetIndex()) < pNode->GetTxt().Len() ) + nStart = rIdx.GetIndex(); + if ( nStart < pNode->GetTxt().Len() ) + { lcl_SkipAttr( pNode, rIdx, nStart ); + } c = rStr.GetChar( nCnt ); if( DoesUndo() ) { @@ -969,11 +818,11 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) // hinter das Zeichen (zum Aufspannen der Attribute !!) if( nStart < pNode->GetTxt().Len() ) rIdx++; - pNode->Insert( c, rIdx ); + pNode->InsertText( c, rIdx, INS_EMPTYEXPAND ); if( nStart+1 < rIdx.GetIndex() ) { rIdx = nStart; - pNode->Erase( rIdx, 1 ); + pNode->EraseText( rIdx, 1 ); rIdx++; } } @@ -1001,6 +850,8 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) } else if( IsRedlineOn() ) { + // FIXME: this redline is WRONG: there is no DELETE, and the skipped + // characters are also included in aPam SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() ); AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); } @@ -1017,7 +868,7 @@ bool SwDoc::MoveAndJoin( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) sal_Bool bOneNode = rPaM.GetPoint()->nNode == rPaM.GetMark()->nNode; aIdx--; // vor den Move Bereich !! - sal_Bool bRet = Move( rPaM, rPos, eMvFlags ); + bool bRet = MoveRange( rPaM, rPos, eMvFlags ); if( bRet && !bOneNode ) { if( bJoinTxt ) @@ -1036,12 +887,15 @@ bool SwDoc::MoveAndJoin( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) return bRet; } -bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) +// mst: it seems that this is mostly used by SwDoc internals; the only +// way to call this from the outside seems to be the special case in +// SwDoc::CopyRange (but i have not managed to actually hit that case) +bool SwDoc::MoveRange( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) { // keine Moves-Abfangen const SwPosition *pStt = rPaM.Start(), *pEnd = rPaM.End(); if( !rPaM.HasMark() || *pStt >= *pEnd || (*pStt <= rPos && rPos < *pEnd)) - return sal_False; + return false; // sicher die absatzgebundenen Flys, damit sie verschoben werden koennen. _SaveFlyArr aSaveFlyArr; @@ -1088,7 +942,7 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) } sal_Bool bSplit = sal_False; - SwPaM * pSavePam = new SwPaM( rPos, rPos ); + SwPaM aSavePam( rPos, rPos ); // stelle den SPoint an den Anfang vom Bereich (Definition) if( rPaM.GetPoint() == pEnd ) @@ -1116,7 +970,7 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) _SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), aBkmkArr, SAVEFLY_SPLIT ); - pTNd = (SwTxtNode*)pTNd->SplitCntntNode( rPos ); + pTNd = static_cast<SwTxtNode*>(pTNd->SplitCntntNode( rPos )); if( aBkmkArr.Count() ) _RestoreCntntIdx( this, aBkmkArr, rPos.nNode.GetIndex()-1, 0, sal_True ); @@ -1132,9 +986,11 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) // setze den Pam um einen "Inhalt" zurueck; dadurch steht er immer // ausserhalb des manipulierten Bereiches. Falls kein Inhalt mehr vor- // handen, dann auf den StartNode (es ist immer einer vorhanden !!!) - sal_Bool bNullCntnt = !pSavePam->Move( fnMoveBackward, fnGoCntnt ); + sal_Bool bNullCntnt = !aSavePam.Move( fnMoveBackward, fnGoCntnt ); if( bNullCntnt ) - pSavePam->GetPoint()->nNode--; + { + aSavePam.GetPoint()->nNode--; + } // kopiere alle Bookmarks, die im Move Bereich stehen in ein // Array, das alle Angaben auf die Position als Offset speichert. @@ -1151,31 +1007,33 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) // Bereich mehr existiert, ist das immernoch ein gueltiger Move! if( *rPaM.GetPoint() != *rPaM.GetMark() ) { - // jetzt kommt das eigentliche Verschieben - GetNodes().Move( rPaM, rPos, GetNodes() ); + // now do the actual move + GetNodes().MoveRange( rPaM, rPos, GetNodes() ); - if( rPaM.HasMark() ) // es wurde kein Move ausgefuehrt !! + // after a MoveRange() the Mark is deleted + if ( rPaM.HasMark() ) // => no Move occurred! { - delete pSavePam; delete pUndoMove; - return sal_False; // Nach einem Move() ist der GetMark geloescht + return false; } } else rPaM.DeleteMark(); - ASSERT( *pSavePam->GetMark() == rPos || - ( pSavePam->GetMark()->nNode.GetNode().GetCntntNode() == NULL ), + ASSERT( *aSavePam.GetMark() == rPos || + ( aSavePam.GetMark()->nNode.GetNode().GetCntntNode() == NULL ), "PaM wurde nicht verschoben, am Anfang/Ende keine ContentNodes?" ); - *pSavePam->GetMark() = rPos; + *aSavePam.GetMark() = rPos; rPaM.SetMark(); // um den neuen Bereich eine Sel. aufspannen - pTNd = pSavePam->GetNode()->GetTxtNode(); + pTNd = aSavePam.GetNode()->GetTxtNode(); if( DoesUndo() ) { // korrigiere erstmal den Content vom SavePam if( bNullCntnt ) - pSavePam->GetPoint()->nContent = 0; + { + aSavePam.GetPoint()->nContent = 0; + } // die Methode SwEditShell::Move() fuegt nach dem Move den Text-Node // zusammen, in dem der rPaM steht. Wurde der Inhalt nach hinten @@ -1189,7 +1047,7 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) bCorrSavePam = bCorrSavePam && 0 != ( pPamTxtNd = rPaM.GetNode()->GetTxtNode() ) && pPamTxtNd->CanJoinNext() - && *rPaM.GetPoint() <= *pSavePam->GetPoint(); + && (*rPaM.GetPoint() <= *aSavePam.GetPoint()); // muessen am SavePam 2 Nodes zusammengefasst werden ?? if( bJoin && pTNd->CanJoinNext() ) @@ -1198,16 +1056,20 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) // kein temp. sdbcx::Index bei && // es sollten wohl nur die Indexwerte verglichen werden. if( bCorrSavePam && rPaM.GetPoint()->nNode.GetIndex()+1 == - pSavePam->GetPoint()->nNode.GetIndex() ) - pSavePam->GetPoint()->nContent += pPamTxtNd->Len(); + aSavePam.GetPoint()->nNode.GetIndex() ) + { + aSavePam.GetPoint()->nContent += pPamTxtNd->Len(); + } bJoin = sal_False; } // else if( !bCorrSavePam && !pSavePam->Move( fnMoveForward, fnGoCntnt )) - else if( !pSavePam->Move( fnMoveForward, fnGoCntnt )) - pSavePam->GetPoint()->nNode++; + else if ( !aSavePam.Move( fnMoveForward, fnGoCntnt ) ) + { + aSavePam.GetPoint()->nNode++; + } // zwischen SPoint und GetMark steht jetzt der neu eingefuegte Bereich - pUndoMove->SetDestRange( *pSavePam, *rPaM.GetPoint(), + pUndoMove->SetDestRange( aSavePam, *rPaM.GetPoint(), bJoin, bCorrSavePam ); AppendUndo( pUndoMove ); } @@ -1229,15 +1091,17 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) } if( bNullCntnt ) { - pSavePam->GetPoint()->nNode++; - pSavePam->GetPoint()->nContent.Assign( pSavePam->GetCntntNode(), 0 ); + aSavePam.GetPoint()->nNode++; + aSavePam.GetPoint()->nContent.Assign( aSavePam.GetCntntNode(), 0 ); } else if( bRemove ) // No move forward after joining with next paragraph - pSavePam->Move( fnMoveForward, fnGoCntnt ); + { + aSavePam.Move( fnMoveForward, fnGoCntnt ); + } } // setze jetzt wieder die text::Bookmarks in das Dokument - *rPaM.GetMark() = *pSavePam->Start(); + *rPaM.GetMark() = *aSavePam.Start(); for( ::std::vector< ::sw::mark::SaveBookmark>::iterator pBkmk = aSaveBkmks.begin(); pBkmk != aSaveBkmks.end(); @@ -1246,15 +1110,16 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) this, rPaM.GetMark()->nNode, &rPaM.GetMark()->nContent); - *rPaM.GetPoint() = *pSavePam->End(); + *rPaM.GetPoint() = *aSavePam.End(); // verschiebe die Flys an die neue Position _RestFlyInRange( aSaveFlyArr, rPaM.Start()->nNode, &(rPos.nNode) ); // restore redlines (if DOC_MOVEREDLINES is used) if( aSaveRedl.Count() ) - lcl_RestoreRedlines( this, *pSavePam->Start(), aSaveRedl ); - delete pSavePam; // Better to delete an object _after_ the last use + { + lcl_RestoreRedlines( this, *aSavePam.Start(), aSaveRedl ); + } if( bUpdateFtn ) { @@ -1268,10 +1133,11 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) } SetModified(); - return sal_True; + return true; } -bool SwDoc::Move( SwNodeRange& rRange, SwNodeIndex& rPos, SwMoveFlags eMvFlags ) +bool SwDoc::MoveNodeRange( SwNodeRange& rRange, SwNodeIndex& rPos, + SwMoveFlags eMvFlags ) { // bewegt alle Nodes an die neue Position. Dabei werden die // text::Bookmarks mit verschoben !! (zur Zeit ohne Undo) @@ -1539,7 +1405,7 @@ void lcl_JoinText( SwPaM& rPam, sal_Bool bJoinPrev ) pOldTxtNd->Len(), aBkmkArr ); SwIndex aAlphaIdx(pTxtNd); - pOldTxtNd->Cut( pTxtNd, aAlphaIdx, SwIndex(pOldTxtNd), + pOldTxtNd->CutText( pTxtNd, aAlphaIdx, SwIndex(pOldTxtNd), pOldTxtNd->Len() ); SwPosition aAlphaPos( aIdx, aAlphaIdx ); pDoc->CorrRel( rPam.GetPoint()->nNode, aAlphaPos, 0, sal_True ); @@ -1609,14 +1475,85 @@ void lcl_JoinText( SwPaM& rPam, sal_Bool bJoinPrev ) } } -// OD 2009-08-20 #i100466# -// Add handling of new optional parameter <bForceJoinNext> -bool SwDoc::DeleteAndJoin( SwPaM & rPam, - const bool bForceJoinNext ) +static void +lcl_CalcBreaks( ::std::vector<xub_StrLen> & rBreaks, SwPaM const & rPam ) { - if( lcl_StrLenOverFlow( rPam ) ) - return sal_False; - if( IsRedlineOn() ) + SwTxtNode const * const pTxtNode( + rPam.End()->nNode.GetNode().GetTxtNode() ); + if (!pTxtNode) + return; // left-overlap only possible at end of selection... + + const xub_StrLen nStart(rPam.Start()->nContent.GetIndex()); + const xub_StrLen nEnd (rPam.End ()->nContent.GetIndex()); + if (nEnd == pTxtNode->Len()) + return; // paragraph selected until the end + + for (xub_StrLen i = nStart; i < nEnd; ++i) + { + const sal_Unicode c(pTxtNode->GetTxt().GetChar(i)); + if ((CH_TXTATR_INWORD == c) || (CH_TXTATR_BREAKWORD == c)) + { + SwTxtAttr const * const pAttr( pTxtNode->GetTxtAttrForCharAt(i) ); + if (pAttr && pAttr->GetEnd() && (*pAttr->GetEnd() > nEnd)) + { + ASSERT(pAttr->HasDummyChar(), "GetTxtAttrForCharAt broken?"); + rBreaks.push_back(i); + } + } + } +} + +bool lcl_DoWithBreaks(SwDoc & rDoc, SwPaM & rPam, + bool (SwDoc::*pFunc)(SwPaM&, bool), const bool bForceJoinNext = false) +{ + ::std::vector<xub_StrLen> Breaks; + + lcl_CalcBreaks(Breaks, rPam); + + if (!Breaks.size()) + { + return (rDoc.*pFunc)(rPam, bForceJoinNext); + } + + // N.B.: deletion must be split into several parts if the text node + // contains a text attribute with end and with dummy character + // and the selection does not contain the text attribute completely, + // but overlaps its start (left), where the dummy character is. + + SwPosition const & rSelectionEnd( *rPam.End() ); + + bool bRet( true ); + // iterate from end to start, to avoid invalidating the offsets! + ::std::vector<xub_StrLen>::reverse_iterator iter( Breaks.rbegin() ); + SwPaM aPam( rSelectionEnd, rSelectionEnd ); // end node! + SwPosition & rEnd( *aPam.End() ); + SwPosition & rStart( *aPam.Start() ); + + while (iter != Breaks.rend()) + { + rStart.nContent = *iter + 1; + if (rEnd.nContent > rStart.nContent) // check if part is empty + { + bRet &= (rDoc.*pFunc)(aPam, bForceJoinNext); + } + rEnd.nContent = *iter; + ++iter; + } + + rStart = *rPam.Start(); // set to original start + if (rEnd.nContent > rStart.nContent) // check if part is empty + { + bRet &= (rDoc.*pFunc)(aPam, bForceJoinNext); + } + + return bRet; +} + + +bool SwDoc::DeleteAndJoinWithRedlineImpl( SwPaM & rPam, const bool ) +{ + ASSERT( IsRedlineOn(), "DeleteAndJoinWithRedline: redline off" ); + { sal_uInt16 nUndoSize = 0; SwUndoRedlineDelete* pUndo = 0; @@ -1656,9 +1593,13 @@ bool SwDoc::DeleteAndJoin( SwPaM & rPam, //JP 06.01.98: MUSS noch optimiert werden!!! SetRedlineMode( eOld ); } - return sal_True; + return true; } +} +bool SwDoc::DeleteAndJoinImpl( SwPaM & rPam, + const bool bForceJoinNext ) +{ sal_Bool bJoinTxt, bJoinPrev; lcl_GetJoinFlags( rPam, bJoinTxt, bJoinPrev ); // --> OD 2009-08-20 #i100466# @@ -1674,8 +1615,9 @@ SetRedlineMode( eOld ); SwPaM aDelPam( *rPam.GetMark(), *rPam.GetPoint() ); ::PaMCorrAbs( aDelPam, *aDelPam.GetPoint() ); - if( !Delete( aDelPam ) ) - return sal_False; + const bool bSuccess( DeleteRangeImpl( aDelPam ) ); + if (!bSuccess) + return false; *rPam.GetPoint() = *aDelPam.GetPoint(); } @@ -1685,15 +1627,15 @@ SetRedlineMode( eOld ); lcl_JoinText( rPam, bJoinPrev ); } - return sal_True; + return true; } -bool SwDoc::Delete( SwPaM & rPam ) +bool SwDoc::DeleteRangeImpl( SwPaM & rPam, const bool ) { SwPosition *pStt = (SwPosition*)rPam.Start(), *pEnd = (SwPosition*)rPam.End(); if( !rPam.HasMark() || *pStt >= *pEnd ) - return sal_False; + return false; if( pACEWord ) { @@ -1748,7 +1690,7 @@ bool SwDoc::Delete( SwPaM & rPam ) SetModified(); - return sal_True; + return true; } if( !IsIgnoreRedline() && GetRedlineTbl().Count() ) @@ -1782,7 +1724,7 @@ bool SwDoc::Delete( SwPaM & rPam ) // falls schon leer, dann nicht noch aufrufen if( nLen ) { - pStartTxtNode->Erase( pStt->nContent, nLen ); + pStartTxtNode->EraseText( pStt->nContent, nLen ); if( !pStartTxtNode->Len() ) { @@ -1814,7 +1756,7 @@ bool SwDoc::Delete( SwPaM & rPam ) if( pEnd->nContent.GetIndex() ) { SwIndex aIdx( pCNd, 0 ); - pEndTxtNode->Erase( aIdx, pEnd->nContent.GetIndex() ); + pEndTxtNode->EraseText( aIdx, pEnd->nContent.GetIndex() ); if( !pEndTxtNode->Len() ) { @@ -1859,9 +1801,29 @@ bool SwDoc::Delete( SwPaM & rPam ) CompressRedlines(); SetModified(); - return sal_True; + return true; +} + +// OD 2009-08-20 #i100466# +// Add handling of new optional parameter <bForceJoinNext> +bool SwDoc::DeleteAndJoin( SwPaM & rPam, + const bool bForceJoinNext ) +{ + if ( lcl_StrLenOverFlow( rPam ) ) + return false; + + return lcl_DoWithBreaks( *this, rPam, (IsRedlineOn()) + ? &SwDoc::DeleteAndJoinWithRedlineImpl + : &SwDoc::DeleteAndJoinImpl, + bForceJoinNext ); } +bool SwDoc::DeleteRange( SwPaM & rPam ) +{ + return lcl_DoWithBreaks( *this, rPam, &SwDoc::DeleteRangeImpl ); +} + + void lcl_syncGrammarError( SwTxtNode &rTxtNode, linguistic2::ProofreadingResult& rResult, xub_StrLen /*nBeginGrammarCheck*/, const ModelToViewHelper::ConversionMap* pConversionMap ) { @@ -2235,12 +2197,86 @@ sal_Bool lcl_GetTokenToParaBreak( String& rStr, String& rRet, sal_Bool bRegExpRp return bRet; } +bool SwDoc::ReplaceRange( SwPaM& rPam, const String& rStr, + const bool bRegExReplace ) +{ + // unfortunately replace works slightly differently from delete, + // so we cannot use lcl_DoWithBreaks here... + + ::std::vector<xub_StrLen> Breaks; + + SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() ); + aPam.Normalize(FALSE); + if (aPam.GetPoint()->nNode != aPam.GetMark()->nNode) + { + aPam.Move(fnMoveBackward); + } + ASSERT((aPam.GetPoint()->nNode == aPam.GetMark()->nNode), "invalid pam?"); + + lcl_CalcBreaks(Breaks, aPam); + + while (!Breaks.empty() // skip over prefix of dummy chars + && (aPam.GetMark()->nContent.GetIndex() == *Breaks.begin()) ) + { + // skip! + ++aPam.GetMark()->nContent; // always in bounds if Breaks valid + Breaks.erase(Breaks.begin()); + } + *rPam.Start() = *aPam.GetMark(); // update start of original pam w/ prefix + + if (!Breaks.size()) + { + return ReplaceRangeImpl(rPam, rStr, bRegExReplace); // original pam! + } + + // N.B.: deletion must be split into several parts if the text node + // contains a text attribute with end and with dummy character + // and the selection does not contain the text attribute completely, + // but overlaps its start (left), where the dummy character is. + + bool bRet( true ); + // iterate from end to start, to avoid invalidating the offsets! + ::std::vector<xub_StrLen>::reverse_iterator iter( Breaks.rbegin() ); + ASSERT(aPam.GetPoint() == aPam.End(), "wrong!"); + SwPosition & rEnd( *aPam.End() ); + SwPosition & rStart( *aPam.Start() ); + + // set end of temp pam to original end (undo Move backward above) + rEnd = *rPam.End(); + // after first deletion, rEnd will point into the original text node again! + + while (iter != Breaks.rend()) + { + rStart.nContent = *iter + 1; + if (rEnd.nContent != rStart.nContent) // check if part is empty + { + bRet &= (IsRedlineOn()) + ? DeleteAndJoinWithRedlineImpl(aPam) + : DeleteAndJoinImpl(aPam, false); + } + rEnd.nContent = *iter; + ++iter; + } + + rStart = *rPam.Start(); // set to original start + ASSERT(rEnd.nContent > rStart.nContent, "replace part empty!"); + if (rEnd.nContent > rStart.nContent) // check if part is empty + { + bRet &= ReplaceRangeImpl(aPam, rStr, bRegExReplace); + } + + rPam = aPam; // update original pam (is this required?) + + return bRet; +} + // N.B.: it is possible to call Replace with a PaM that spans 2 paragraphs: // search with regex for "$", then replace _all_ -bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) +bool SwDoc::ReplaceRangeImpl( SwPaM& rPam, const String& rStr, + const bool bRegExReplace ) { if( !rPam.HasMark() || *rPam.GetPoint() == *rPam.GetMark() ) - return sal_False; + return false; sal_Bool bJoinTxt, bJoinPrev; lcl_GetJoinFlags( rPam, bJoinTxt, bJoinPrev ); @@ -2257,7 +2293,7 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) ASSERT( pStt->nNode == pEnd->nNode || ( pStt->nNode.GetIndex() + 1 == pEnd->nNode.GetIndex() && !pEnd->nContent.GetIndex() ), - "Point & Mark zeigen auf verschiedene Nodes" ); + "invalid range: Point and Mark on different nodes" ); sal_Bool bOneNode = pStt->nNode == pEnd->nNode; // eigenes Undo ???? @@ -2304,6 +2340,10 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) aSet.ClearItem( RES_TXTATR_REFMARK ); aSet.ClearItem( RES_TXTATR_TOXMARK ); + aSet.ClearItem( RES_TXTATR_CJK_RUBY ); + aSet.ClearItem( RES_TXTATR_INETFMT ); + aSet.ClearItem( RES_TXTATR_META ); + aSet.ClearItem( RES_TXTATR_METAFIELD ); if( aDelPam.GetPoint() != aDelPam.End() ) aDelPam.Exchange(); @@ -2314,9 +2354,9 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) sal_Bool bFirst = sal_True; String sIns; - while( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExpRplc )) + while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) ) { - Insert( aDelPam, sIns, true ); + InsertString( aDelPam, sIns ); if( bFirst ) { SwNodeIndex aMkNd( aDelPam.GetMark()->nNode, -1 ); @@ -2334,7 +2374,9 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) SplitNode( *aDelPam.GetPoint(), false ); } if( sIns.Len() ) - Insert( aDelPam, sIns, true ); + { + InsertString( aDelPam, sIns ); + } SwPaM aTmpRange( *aDelPam.GetPoint() ); aTmpRange.SetMark(); @@ -2346,7 +2388,7 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) *aTmpRange.GetMark() = *aDelPam.GetPoint(); RstTxtAttrs( aTmpRange ); - Insert( aTmpRange, aSet, 0 ); + InsertItemSet( aTmpRange, aSet, 0 ); } if( DoesUndo() ) @@ -2396,7 +2438,7 @@ SetRedlineMode( eOld ); pUndoRpl = new SwUndoReplace(); AppendUndo( pUndoRpl ); } - pUndoRpl->AddEntry( aDelPam, sRepl, bRegExpRplc ); + pUndoRpl->AddEntry( aDelPam, sRepl, bRegExReplace ); DoUndo( sal_False ); } @@ -2414,12 +2456,16 @@ SetRedlineMode( eOld ); sal_Bool bFirst = sal_True; String sIns; - while( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExpRplc )) + while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) ) { if( !bFirst || nStt == pTxtNd->GetTxt().Len() ) - Insert( aDelPam, sIns, true ); + { + InsertString( aDelPam, sIns ); + } else if( nStt < nEnd || sIns.Len() ) - pTxtNd->Replace( pStt->nContent, nEnd - nStt, sIns ); + { + pTxtNd->ReplaceText( pStt->nContent, nEnd - nStt, sIns ); + } SplitNode( *pStt, false); bFirst = sal_False; } @@ -2427,9 +2473,13 @@ SetRedlineMode( eOld ); if( bFirst || sIns.Len() ) { if( !bFirst || nStt == pTxtNd->GetTxt().Len() ) - Insert( aDelPam, sIns, true ); + { + InsertString( aDelPam, sIns ); + } else if( nStt < nEnd || sIns.Len() ) - pTxtNd->Replace( pStt->nContent, nEnd - nStt, sIns ); + { + pTxtNd->ReplaceText( pStt->nContent, nEnd - nStt, sIns ); + } } *rPam.GetMark() = *aDelPam.GetMark(); @@ -2453,7 +2503,7 @@ SetRedlineMode( eOld ); lcl_JoinText( rPam, bJoinPrev ); SetModified(); - return sal_True; + return true; } // speicher die akt. Werte fuer die automatische Aufnahme von Ausnahmen @@ -2750,7 +2800,7 @@ void SwDoc::RemoveLeadingWhiteSpace(const SwPosition & rPos ) aPam.GetPoint()->nContent = 0; aPam.SetMark(); aPam.GetMark()->nContent = nIdx; - Delete( aPam ); + DeleteRange( aPam ); } } } diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index 184fd08a4afc..507e63ba7a47 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -274,18 +274,17 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); -#ifndef PRODUCT + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( nIdx, RES_TXTATR_FLYCNT ); ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == &rFmt, "Wrong TxtFlyCnt-Hint." ); -#endif - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); //Die Verbindung ist geloest, jetzt muss noch das Attribut vernichtet //werden. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx ); } //Endlich kann das Attribut gesetzt werden. Es muss das erste Attribut @@ -305,8 +304,8 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms SwTxtNode *pNd = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pNd, "Crsr steht nicht auf TxtNode." ); - pNd->InsertItem( SwFmtFlyCnt( (SwFlyFrmFmt*)&rFmt ), - pPos->nContent.GetIndex(), 0 ); + SwFmtFlyCnt aFmt( static_cast<SwFlyFrmFmt*>(&rFmt) ); + pNd->InsertItem( aFmt, pPos->nContent.GetIndex(), 0 ); } if( SFX_ITEM_SET != rSet.GetItemState( RES_VERT_ORIENT, FALSE, &pItem )) @@ -830,10 +829,10 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, // 'center to baseline' SetAttr( SwFmtVertOrient( 0, text::VertOrientation::CENTER, text::RelOrientation::FRAME ), *pContact->GetFmt() ); SwTxtNode *pNd = aPos.nNode.GetNode().GetTxtNode(); - ASSERT( pNd, "Crsr steht nicht auf TxtNode." ); + ASSERT( pNd, "Cursor not positioned at TxtNode." ); - pNd->InsertItem( SwFmtFlyCnt( pContact->GetFmt() ), - aPos.nContent.GetIndex(), 0 ); + SwFmtFlyCnt aFmt( pContact->GetFmt() ); + pNd->InsertItem( aFmt, aPos.nContent.GetIndex(), 0 ); } break; default: @@ -880,12 +879,13 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, SwTxtNode* pTxtNode( pOldAsCharAnchorPos->nNode.GetNode().GetTxtNode() ); ASSERT( pTxtNode, "<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object" ); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); - SwTxtAttr* pHnt = pTxtNode->GetTxtAttr( nIndx, RES_TXTATR_FLYCNT ); - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( nIndx, RES_TXTATR_FLYCNT ); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); //Die Verbindung ist geloest, jetzt muss noch das Attribut vernichtet //werden. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIndx, nIndx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIndx, nIndx ); delete pOldAsCharAnchorPos; } // <-- diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index f3c7fa2e4bf9..948741067967 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -461,6 +461,7 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, const SwPosition *pStt = pPam->Start(), *pEnd = pPam->End(); ParaRstFmt aPara( pStt, pEnd, pHst ); + // mst: not including META here; it seems attrs with CH_TXTATR are omitted USHORT __FAR_DATA aResetableSetRange[] = { RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_CHRATR_BEGIN, RES_CHRATR_END-1, @@ -524,12 +525,15 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, { if ( pHst ) { - SwRegHistory( pTNd, aCharSet, 0, pTNd->GetTxt().Len(), nsSetAttrMode::SETATTR_NOFORMATATTR, pHst ); + SwRegHistory history( pTNd, *pTNd, pHst ); + history.InsertItems( aCharSet, 0, pTNd->GetTxt().Len(), + nsSetAttrMode::SETATTR_NOFORMATATTR ); } else { - SwTxtAttr* pNew = pTNd->MakeTxtAttr( aCharSet, 0, pTNd->GetTxt().Len() ); - pTNd->Insert( pNew ); + SwTxtAttr* pNew = + MakeTxtAttr( *this, aCharSet, 0, pTNd->GetTxt().Len() ); + pTNd->InsertHint( pNew ); } } } @@ -550,11 +554,12 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, { if( IsInRange( aCharFmtSetRange, pItem->Which() )) { - SwTxtAttr* pTAttr = pTNd->MakeTxtAttr( *pItem, 0, - pTNd->GetTxt().Len() ); + SwTxtAttr* pTAttr = MakeTxtAttr( *this, + const_cast<SfxPoolItem&>(*pItem), + 0, pTNd->GetTxt().Len() ); SwpHints & rHints = pTNd->GetOrCreateSwpHints(); rHints.SwpHintsArray::Insert( pTAttr ); - if( pHst ) + if ( pHst ) { SwRegHistory aRegH( pTNd, *pTNd, pHst ); pTNd->ResetAttr( pItem->Which() ); @@ -597,8 +602,9 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, // Einfuegen der Hints nach Inhaltsformen; // wird in SwDoc::Insert(..., SwFmtHint &rHt) benutzt -BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, - USHORT nFlags, SwUndoAttr* pUndo ) +static bool +lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, + const SetAttrMode nFlags, SwUndoAttr *const pUndo) { // teil die Sets auf (fuer Selektion in Nodes) const SfxItemSet* pCharSet = 0; @@ -668,7 +674,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, } SwHistory* pHistory = pUndo ? &pUndo->GetHistory() : 0; - BOOL bRet = FALSE; + bool bRet = false; const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End(); SwCntntNode* pNode = pStt->nNode.GetNode().GetCntntNode(); @@ -686,7 +692,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, ASSERT( false, "<InsAttr(..)> - PaM in front of label, but text node has no numbering rule set. This is a serious defect, please inform OD." ); DELETECHARSETS - return FALSE; + return false; } // <-- @@ -704,7 +710,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, } DELETECHARSETS - return TRUE; + return true; } // <- #i27615# @@ -718,12 +724,12 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, aTxtSet.Put( rChgSet ); if( aTxtSet.Count() ) { - SwRegHistory( (SwTxtNode*)pNode, aTxtSet, rSt.GetIndex(), - rSt.GetIndex(), nFlags, pHistory ); - bRet = TRUE; + SwRegHistory history( pNode, *pNode, pHistory ); + bRet = history.InsertItems( + aTxtSet, rSt.GetIndex(), rSt.GetIndex(), nFlags ) || bRet; - if( pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline() && - pDoc->GetRedlineTbl().Count() )) + if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline() + && pDoc->GetRedlineTbl().Count()))) { SwPaM aPam( pStt->nNode, pStt->nContent.GetIndex()-1, pStt->nNode, pStt->nContent.GetIndex() ); @@ -757,12 +763,12 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, USHORT nEnd = pStt->nNode == pEnd->nNode ? pEnd->nContent.GetIndex() : pNode->Len(); - SwRegHistory( (SwTxtNode*)pNode, aTxtSet, nInsCnt, - nEnd, nFlags, pHistory ); - bRet = TRUE; + SwRegHistory history( pNode, *pNode, pHistory ); + bRet = history.InsertItems( aTxtSet, nInsCnt, nEnd, nFlags ) + || bRet; - if( pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline() && - pDoc->GetRedlineTbl().Count() ) ) + if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline() + && pDoc->GetRedlineTbl().Count()))) { // wurde Text-Inhalt eingefuegt? (RefMark/TOXMarks ohne Ende) BOOL bTxtIns = nInsCnt != rSt.GetIndex(); @@ -784,7 +790,6 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, // bei PageDesc's, die am Node gesetzt werden, muss immer das // Auto-Flag gesetzt werden!! - const SvxLRSpaceItem* pLRSpace = 0; if( pOtherSet && pOtherSet->Count() ) { SwTableNode* pTblNd; @@ -811,11 +816,12 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, SwFrmFmt* pFmt = pTblNd->GetTable().GetFrmFmt(); SwRegHistory aRegH( pFmt, *pTblNd, pHistory ); pFmt->SetFmtAttr( aNew ); + bRet = true; } else { SwRegHistory aRegH( pNode, *pNode, pHistory ); - pNode->SetAttr( aNew ); + bRet = pNode->SetAttr( aNew ) || bRet; } } @@ -823,13 +829,13 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, // we know, that there is only one attribute in pOtherSet. We cannot // perform the following operations, instead we return: if ( bOtherAttr ) - return TRUE; + return bRet; const_cast<SfxItemSet*>(pOtherSet)->ClearItem( RES_PAGEDESC ); if( !pOtherSet->Count() ) { DELETECHARSETS - return TRUE; + return bRet; } } @@ -848,25 +854,22 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, SwFrmFmt* pFmt = pTblNd->GetTable().GetFrmFmt(); SwRegHistory aRegH( pFmt, *pTblNd, pHistory ); pFmt->SetFmtAttr( *pBreak ); + bRet = true; // bOtherAttr = true means that pOtherSet == rChgSet. In this case // we know, that there is only one attribute in pOtherSet. We cannot // perform the following operations, instead we return: if ( bOtherAttr ) - return TRUE; + return bRet; const_cast<SfxItemSet*>(pOtherSet)->ClearItem( RES_BREAK ); if( !pOtherSet->Count() ) { DELETECHARSETS - return TRUE; + return bRet; } } - // fuer Sonderbehandlung von LR-Space innerhalb einer Numerierung !!! - pOtherSet->GetItemState( RES_LR_SPACE, FALSE, - (const SfxPoolItem**)&pLRSpace ); - { // wenns eine PoolNumRule ist, diese ggfs. anlegen const SwNumRuleItem* pRule; @@ -891,7 +894,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() ) { - SwTxtNode* pTxtNd = (SwTxtNode*)pNode; + SwTxtNode* pTxtNd = static_cast<SwTxtNode*>(pNode); const SwIndex& rSt = pStt->nContent; USHORT nMkPos, nPtPos = rSt.GetIndex(); const String& rStr = pTxtNd->GetTxt(); @@ -946,10 +949,10 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, pTxtNd->RstAttr( aSt, nPtPos, 0, pCharSet ); } - // eintragen des Attributes im Node erledigt die SwRegHistory !! - SwRegHistory( (SwTxtNode*)pNode, *pCharSet, - nMkPos, nPtPos, nFlags, pHistory ); - bRet = TRUE; + // the SwRegHistory inserts the attribute into the TxtNode! + SwRegHistory history( pNode, *pNode, pHistory ); + bRet = history.InsertItems( *pCharSet, nMkPos, nPtPos, nFlags ) + || bRet; if( pDoc->IsRedlineOn() ) { @@ -963,8 +966,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, if( pOtherSet && pOtherSet->Count() ) { SwRegHistory aRegH( pNode, *pNode, pHistory ); - pNode->SetAttr( *pOtherSet ); - bRet = TRUE; + bRet = pNode->SetAttr( *pOtherSet ) || bRet; } DELETECHARSETS @@ -993,25 +995,26 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, if( pStt->nContent.GetIndex() != 0 || aCntEnd.GetIndex() != nLen ) { - // eintragen des Attributes im Node erledigt die SwRegHistory !! + // the SwRegHistory inserts the attribute into the TxtNode! if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() ) { - SwRegHistory( (SwTxtNode*)pNode, *pCharSet, - pStt->nContent.GetIndex(), aCntEnd.GetIndex(), - nFlags, pHistory ); + SwRegHistory history( pNode, *pNode, pHistory ); + bRet = history.InsertItems(*pCharSet, + pStt->nContent.GetIndex(), aCntEnd.GetIndex(), nFlags) + || bRet; } if( pOtherSet && pOtherSet->Count() ) { SwRegHistory aRegH( pNode, *pNode, pHistory ); - pNode->SetAttr( *pOtherSet ); + bRet = pNode->SetAttr( *pOtherSet ) || bRet; } // lediglich Selektion in einem Node. if( pStt->nNode == pEnd->nNode ) { DELETECHARSETS - return TRUE; + return bRet; } ++nNodes; aSt.Assign( pStt->nNode.GetNode(), +1 ); @@ -1036,11 +1039,12 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, USHORT nLen = pNode->Len(); if( aCntEnd.GetIndex() != nLen ) { - // eintragen des Attributes im Node erledigt die SwRegHistory !! + // the SwRegHistory inserts the attribute into the TxtNode! if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() ) { - SwRegHistory( (SwTxtNode*)pNode, *pCharSet, - 0, aCntEnd.GetIndex(), nFlags, pHistory ); + SwRegHistory history( pNode, *pNode, pHistory ); + history.InsertItems(*pCharSet, + 0, aCntEnd.GetIndex(), nFlags); } if( pOtherSet && pOtherSet->Count() ) @@ -1113,14 +1117,14 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, } DELETECHARSETS - return nNodes != 0; + return (nNodes != 0) || bRet; } -bool SwDoc::Insert( const SwPaM &rRg, const SfxPoolItem &rHt, USHORT nFlags ) +bool SwDoc::InsertPoolItem( const SwPaM &rRg, const SfxPoolItem &rHt, + const SetAttrMode nFlags ) { SwDataChanged aTmp( rRg, 0 ); - BOOL bRet; SwUndoAttr* pUndoAttr = 0; if( DoesUndo() ) { @@ -1130,7 +1134,7 @@ bool SwDoc::Insert( const SwPaM &rRg, const SfxPoolItem &rHt, USHORT nFlags ) SfxItemSet aSet( GetAttrPool(), rHt.Which(), rHt.Which() ); aSet.Put( rHt ); - bRet = InsAttr( this, rRg, aSet, nFlags, pUndoAttr ); + bool bRet = lcl_InsAttr( this, rRg, aSet, nFlags, pUndoAttr ); if( DoesUndo() ) AppendUndo( pUndoAttr ); @@ -1140,17 +1144,18 @@ bool SwDoc::Insert( const SwPaM &rRg, const SfxPoolItem &rHt, USHORT nFlags ) return bRet; } -bool SwDoc::Insert( const SwPaM &rRg, const SfxItemSet &rSet, USHORT nFlags ) +bool SwDoc::InsertItemSet ( const SwPaM &rRg, const SfxItemSet &rSet, + const SetAttrMode nFlags ) { SwDataChanged aTmp( rRg, 0 ); SwUndoAttr* pUndoAttr = 0; if( DoesUndo() ) { ClearRedo(); - pUndoAttr = new SwUndoAttr( rRg, rSet ); + pUndoAttr = new SwUndoAttr( rRg, rSet, nFlags ); } - BOOL bRet = InsAttr( this, rRg, rSet, nFlags, pUndoAttr ); + bool bRet = lcl_InsAttr( this, rRg, rSet, nFlags, pUndoAttr ); if( DoesUndo() ) AppendUndo( pUndoAttr ); @@ -2096,7 +2101,7 @@ void SwDoc::CopyFmtArr( const SvPtrarr& rSourceArr, } } -void SwDoc::_CopyPageDescHeaderFooter( BOOL bCpyHeader, +void SwDoc::CopyPageDescHeaderFooterImpl( bool bCpyHeader, const SwFrmFmt& rSrcFmt, SwFrmFmt& rDestFmt ) { // jetzt noch Header-/Footer-Attribute richtig behandeln @@ -2139,7 +2144,7 @@ void SwDoc::_CopyPageDescHeaderFooter( BOOL bCpyHeader, aTmpIdx = *pSttNd->EndOfSectionNode(); rSrcNds._Copy( aRg, aTmpIdx ); aTmpIdx = *pSttNd; - rSrcFmt.GetDoc()->_CopyFlyInFly( aRg, 0, aTmpIdx ); + rSrcFmt.GetDoc()->CopyFlyInFlyImpl( aRg, 0, aTmpIdx ); pNewFmt->SetFmtAttr( SwFmtCntnt( pSttNd )); } else @@ -2499,7 +2504,7 @@ void SwDoc::SetTxtFmtCollByAutoFmt( const SwPosition& rPos, USHORT nPoolId, { aPam.SetMark(); aPam.GetMark()->nContent.Assign( pTNd, pTNd->GetTxt().Len() ); - Insert( aPam, *pSet, 0 ); + InsertItemSet( aPam, *pSet, 0 ); } } @@ -2541,7 +2546,7 @@ void SwDoc::SetFmtItemByAutoFmt( const SwPaM& rPam, const SfxItemSet& rSet ) SetRedlineMode_intern( (RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); } - Insert( rPam, rSet, nsSetAttrMode::SETATTR_DONTEXPAND ); + InsertItemSet( rPam, rSet, nsSetAttrMode::SETATTR_DONTEXPAND ); SetRedlineMode_intern( eOld ); } diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index b340b1ce45fb..113319494e03 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -307,7 +307,7 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, pDoc->GetNodes().Delete( aIdx, 1 ); // alle Flys in dem Bereich - _CopyFlyInFly( aRg, 0, aIdx ); + CopyFlyInFlyImpl( aRg, 0, aIdx ); // und noch alle Bookmarks @@ -653,7 +653,7 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, int nOutlineLevel ) pDoc->GetNodes().Delete( aIdx, 1 ); // alle Flys in dem Bereich - _CopyFlyInFly( aRg, 0, aIdx ); + CopyFlyInFlyImpl( aRg, 0, aIdx ); // und noch alle Bookmarks diff --git a/sw/source/core/doc/docglos.cxx b/sw/source/core/doc/docglos.cxx index 2f3f58e76f3b..a118bf754025 100644 --- a/sw/source/core/doc/docglos.cxx +++ b/sw/source/core/doc/docglos.cxx @@ -183,7 +183,7 @@ BOOL SwDoc::InsertGlossary( SwTextBlocks& rBlock, const String& rEntry, SwDontExpandItem aACD; aACD.SaveDontExpandItems( rInsPos ); - pGDoc->Copy( aCpyPam, rInsPos, false ); + pGDoc->CopyRange( aCpyPam, rInsPos, false ); aACD.RestoreDontExpandItems( rInsPos ); if( pShell ) diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 77df07dcb2d3..1af12a64bf2f 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -362,17 +362,20 @@ void SwDoc::DelLayoutFmt( SwFrmFmt *pFmt ) { const SwPosition* pPos = rAnchor.GetCntntAnchor(); SwTxtNode *pTxtNd = pPos->nNode.GetNode().GetTxtNode(); - SwTxtFlyCnt* pAttr; - // Attribut steht noch im TextNode, loeschen - if( pTxtNd && 0 != ( pAttr = ((SwTxtFlyCnt*)pTxtNd->GetTxtAttr( - pPos->nContent.GetIndex() ))) && - pAttr->GetFlyCnt().GetFrmFmt() == pFmt ) + // attribute is still in text node, delete it + if ( pTxtNd ) { - // Pointer auf 0, nicht loeschen - ((SwFmtFlyCnt&)pAttr->GetFlyCnt()).SetFlyFmt(); - SwIndex aIdx( pPos->nContent ); - pTxtNd->Erase( aIdx, 1 ); + SwTxtFlyCnt* const pAttr = static_cast<SwTxtFlyCnt*>( + pTxtNd->GetTxtAttrForCharAt( pPos->nContent.GetIndex(), + RES_TXTATR_FLYCNT )); + if ( pAttr && (pAttr->GetFlyCnt().GetFrmFmt() == pFmt) ) + { + // dont delete, set pointer to 0 + const_cast<SwFmtFlyCnt&>(pAttr->GetFlyCnt()).SetFlyFmt(); + SwIndex aIdx( pPos->nContent ); + pTxtNd->EraseText( aIdx, 1 ); + } } } @@ -550,9 +553,10 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource, if( bSetTxtFlyAtt && FLY_IN_CNTNT == rNewAnchor.GetAnchorId() ) { - SwPosition* pPos = (SwPosition*)rNewAnchor.GetCntntAnchor(); - pPos->nNode.GetNode().GetTxtNode()->InsertItem(SwFmtFlyCnt( pDest ), - pPos->nContent.GetIndex(), 0 ); + const SwPosition* pPos = rNewAnchor.GetCntntAnchor(); + SwFmtFlyCnt aFmt( pDest ); + pPos->nNode.GetNode().GetTxtNode()->InsertItem( + aFmt, pPos->nContent.GetIndex(), 0 ); } if( bMakeFrms ) @@ -698,7 +702,10 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, ASSERT(pTxtNode!= 0, "There should be a SwTxtNode!"); if (pTxtNode != NULL) - pTxtNode->InsertItem(SwFmtFlyCnt( pFmt ), nStt, nStt ); + { + SwFmtFlyCnt aFmt( pFmt ); + pTxtNode->InsertItem( aFmt, nStt, nStt ); + } } if( SFX_ITEM_SET != pFmt->GetAttrSet().GetItemState( RES_FRM_SIZE )) @@ -844,7 +851,7 @@ SwFlyFrmFmt* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet, GetNodes().MakeTxtNode( aRg.aStart, (SwTxtFmtColl*)GetDfltTxtFmtColl() ); - Move( aRg, aPos.nNode, DOC_MOVEDEFAULT ); + MoveNodeRange( aRg, aPos.nNode, DOC_MOVEDEFAULT ); } else { @@ -885,8 +892,11 @@ if( DoesUndo() ) // werden erstmal alle Undo - Objecte geloescht. do { if( pTmp->HasMark() && *pTmp->GetPoint() != *pTmp->GetMark() ) - Copy( *pTmp, aPos, false ); - } while( &rPam != ( pTmp = (SwPaM*)pTmp->GetNext() ) ); + { + CopyRange( *pTmp, aPos, false ); + } + pTmp = static_cast<SwPaM*>(pTmp->GetNext()); + } while ( &rPam != pTmp ); mbCopyIsMove = bOldFlag; mbUndo = bOldUndo; @@ -894,8 +904,11 @@ if( DoesUndo() ) // werden erstmal alle Undo - Objecte geloescht. do { if( pTmp->HasMark() && *pTmp->GetPoint() != *pTmp->GetMark() ) + { DeleteAndJoin( *pTmp ); - } while( &rPam != ( pTmp = (SwPaM*)pTmp->GetNext() ) ); + } + pTmp = static_cast<SwPaM*>(pTmp->GetNext()); + } while ( &rPam != pTmp ); } } while( sal_False ); } @@ -982,8 +995,9 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, if( FLY_IN_CNTNT == eAnchorId ) { xub_StrLen nStt = rRg.GetPoint()->nContent.GetIndex(); + SwFmtFlyCnt aFmt( pFmt ); rRg.GetPoint()->nNode.GetNode().GetTxtNode()->InsertItem( - SwFmtFlyCnt( pFmt ), nStt, nStt ); + aFmt, nStt, nStt ); } SwDrawContact* pContact = new SwDrawContact( pFmt, &rDrawObj ); @@ -1379,16 +1393,16 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr *pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt(nIdx, RES_TXTATR_FLYCNT); -#ifndef PRODUCT ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); - ASSERT( pHnt && ((SwFmtFlyCnt&)pHnt->GetFlyCnt()). - GetFrmFmt() == pOldFmt, + ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pOldFmt, "Wrong TxtFlyCnt-Hint." ); -#endif - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt( pNewFmt ); + + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt( + pNewFmt ); } @@ -1466,7 +1480,7 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co //String einfuegen SwIndex aIdx( pNew, 0 ); - pNew->Insert( aTxt, aIdx ); + pNew->InsertText( aTxt, aIdx ); // //Feld einfuegen @@ -1475,7 +1489,8 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co SwSetExpField aFld( (SwSetExpFieldType*)pType, aEmptyStr, SVX_NUM_ARABIC); if( bOrderNumberingFirst ) nIdx = 0; - pNew->InsertItem( SwFmtFld( aFld ), nIdx, nIdx ); + SwFmtFld aFmt( aFld ); + pNew->InsertItem( aFmt, nIdx, nIdx ); if(rCharacterStyle.Len()) { SwCharFmt* pCharFmt = FindCharFmtByName( rCharacterStyle ); @@ -1484,9 +1499,12 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co const USHORT nMyId = SwStyleNameMapper::GetPoolIdFromUIName(rCharacterStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT); pCharFmt = GetCharFmtFromPool( nMyId ); } - if(pCharFmt) - pNew->InsertItem( SwFmtCharFmt( pCharFmt ), 0, - nSepIdx + 1, nsSetAttrMode::SETATTR_DONTEXPAND ); + if (pCharFmt) + { + SwFmtCharFmt aCharFmt( pCharFmt ); + pNew->InsertItem( aCharFmt, 0, + nSepIdx + 1, nsSetAttrMode::SETATTR_DONTEXPAND ); + } } } @@ -1672,7 +1690,8 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr *pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( nIdx, RES_TXTATR_FLYCNT ); #ifndef PRODUCT ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, @@ -1681,7 +1700,7 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, GetFrmFmt() == (SwFrmFmt*)pOldFmt, "Wrong TxtFlyCnt-Hint." ); #endif - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt( pNewFmt ); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt( pNewFmt ); } @@ -1751,7 +1770,7 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, // insert text SwIndex aIdx( pNew, 0 ); - pNew->Insert( aTxt, aIdx ); + pNew->InsertText( aTxt, aIdx ); // insert field if ( pType ) @@ -1759,7 +1778,8 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, SwSetExpField aFld( (SwSetExpFieldType*)pType, aEmptyStr, SVX_NUM_ARABIC ); if( bOrderNumberingFirst ) nIdx = 0; - pNew->InsertItem( SwFmtFld( aFld ), nIdx, nIdx ); + SwFmtFld aFmt( aFld ); + pNew->InsertItem( aFmt, nIdx, nIdx ); if ( rCharacterStyle.Len() ) { SwCharFmt* pCharFmt = FindCharFmtByName( rCharacterStyle ); @@ -1769,7 +1789,11 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, pCharFmt = GetCharFmtFromPool( nMyId ); } if ( pCharFmt ) - pNew->InsertItem( SwFmtCharFmt( pCharFmt ), 0, nSepIdx + 1, nsSetAttrMode::SETATTR_DONTEXPAND ); + { + SwFmtCharFmt aCharFmt( pCharFmt ); + pNew->InsertItem( aCharFmt, 0, nSepIdx + 1, + nsSetAttrMode::SETATTR_DONTEXPAND ); + } } } } diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 67c64e27b9d0..2a36ce970615 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -123,6 +123,7 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <sfx2/Metadatable.hxx> +#include <fmtmeta.hxx> // MetaFieldManager using namespace ::com::sun::star; @@ -206,6 +207,7 @@ SwDoc::SwDoc() : aUndoNodes( this ), mpAttrPool(new SwAttrPool(this)), pMarkManager(new ::sw::mark::MarkManager(*this)), + m_pMetaFieldManager(new ::sw::MetaFieldManager()), pDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ), pEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, pDfltFrmFmt ) ), pColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, pDfltFrmFmt ) ), @@ -1039,6 +1041,12 @@ SwDoc::GetXmlIdRegistry() return *m_pXmlIdRegistry; } +::sw::MetaFieldManager & +SwDoc::GetMetaFieldManager() +{ + return *m_pMetaFieldManager; +} + void SwDoc::InitTOXTypes() { ShellResource* pShellRes = ViewShell::GetShellRes(); @@ -1379,7 +1387,7 @@ void SwDoc::Paste( const SwDoc& rSource ) aIndexBefore--; - rSource.Copy( aCpyPam, rInsPos, true ); + rSource.CopyRange( aCpyPam, rInsPos, true ); { aIndexBefore++; diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index a26b82134c86..d0afa8debc27 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -1031,12 +1031,14 @@ void SwDoc::SetNumRule( const SwPaM& rPam, "<SwDoc::SetNumRule(..)> - could not create new list. Serious defect -> please inform OD." ); sListId = pNewList->GetListId(); } - Insert( rPam, SfxStringItem( RES_PARATR_LIST_ID, sListId ), 0 ); + InsertPoolItem( rPam, + SfxStringItem( RES_PARATR_LIST_ID, sListId ), 0 ); } else if ( sContinuedListId.Len() > 0 ) { // apply given list id - Insert( rPam, SfxStringItem( RES_PARATR_LIST_ID, sContinuedListId ), 0 ); + InsertPoolItem( rPam, + SfxStringItem( RES_PARATR_LIST_ID, sContinuedListId ), 0 ); } } // <-- @@ -1084,7 +1086,7 @@ void SwDoc::SetNumRule( const SwPaM& rPam, if ( bSetItem ) // <-- { - Insert( rPam, SwNumRuleItem( pNew->GetName() ), 0 ); + InsertPoolItem( rPam, SwNumRuleItem( pNew->GetName() ), 0 ); } // --> OD 2008-02-08 #newlistlevelattrs# @@ -1124,7 +1126,8 @@ void SwDoc::SetCounted(const SwPaM & rPam, bool bCounted) } else { - Insert( rPam, SfxBoolItem( RES_PARATR_LIST_ISCOUNTED, FALSE ), 0 ); + InsertPoolItem( rPam, + SfxBoolItem( RES_PARATR_LIST_ISCOUNTED, FALSE ), 0 ); } } @@ -1144,7 +1147,7 @@ void SwDoc::SetCounted(const SwPaM & rPam, bool bCounted) // { // SwPaM aPam(*pCNd); -// Insert(aPam, SwNumRuleItem(rNumRule.GetName()), 0); +// InsertPoolItem(aPam, SwNumRuleItem(rNumRule.GetName()), 0); // } // } @@ -2275,7 +2278,7 @@ BOOL SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, BOOL bIsOutlMv ) } } - Copy( aPam, aInsPos, false ); + CopyRange( aPam, aInsPos, false ); if( bDelLastPara ) { // dann muss der letzte leere Node wieder entfernt werden @@ -2361,7 +2364,7 @@ SetRedlineMode( eOld ); } - Move( aMvRg, aIdx, DOC_MOVEREDLINES ); + MoveNodeRange( aMvRg, aIdx, DOC_MOVEREDLINES ); if( pUndo ) { diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index fe537adf82d8..daeda48ccae3 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -1725,7 +1725,7 @@ BOOL lcl_AcceptRedline( SwRedlineTbl& rArr, USHORT& rPos, rDoc.DeleteAndJoin( aPam ); else { - rDoc.Delete( aPam ); + rDoc.DeleteRange( aPam ); if( pCSttNd && !pCEndNd ) { @@ -1835,7 +1835,7 @@ BOOL lcl_RejectRedline( SwRedlineTbl& rArr, USHORT& rPos, rDoc.DeleteAndJoin( aPam ); else { - rDoc.Delete( aPam ); + rDoc.DeleteRange( aPam ); if( pCSttNd && !pCEndNd ) { @@ -2899,10 +2899,12 @@ void SwRedlineExtraData_FmtColl::Reject( SwPaM& rPam ) const // nicht angefasst. SfxItemSet aTmp( *pSet ); aTmp.Differentiate( *pTNd->GetpSwAttrSet() ); - pDoc->Insert( rPam, aTmp, 0 ); + pDoc->InsertItemSet( rPam, aTmp, 0 ); } else - pDoc->Insert( rPam, *pSet, 0 ); + { + pDoc->InsertItemSet( rPam, *pSet, 0 ); + } } rPam.DeleteMark(); } @@ -2964,7 +2966,10 @@ void SwRedlineExtraData_Format::Reject( SwPaM& rPam ) const // eigentlich muesste hier das Attribut zurueck gesetzt werden!!! for( USHORT n = 0, nEnd = aWhichIds.Count(); n < nEnd; ++n ) - pDoc->Insert( rPam, *GetDfltAttr( aWhichIds[ n ] ), nsSetAttrMode::SETATTR_DONTEXPAND ); + { + pDoc->InsertPoolItem( rPam, *GetDfltAttr( aWhichIds[ n ] ), + nsSetAttrMode::SETATTR_DONTEXPAND ); + } pDoc->SetRedlineMode_intern( eOld ); } @@ -3359,7 +3364,8 @@ void SwRedline::MoveToSection() { if( pCSttNd && !pCEndNd ) bDelLastPara = TRUE; - pDoc->Move( aPam, aPos, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveRange( aPam, aPos, + IDocumentContentOperations::DOC_MOVEDEFAULT ); } } else @@ -3368,7 +3374,8 @@ void SwRedline::MoveToSection() SwNormalStartNode ); SwPosition aPos( *pSttNd->EndOfSectionNode() ); - pDoc->Move( aPam, aPos, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveRange( aPam, aPos, + IDocumentContentOperations::DOC_MOVEDEFAULT ); } pCntntSect = new SwNodeIndex( *pSttNd ); @@ -3419,7 +3426,7 @@ void SwRedline::CopyToSection() SwNodeIndex aNdIdx( *pSttNd, 1 ); SwTxtNode* pTxtNd = aNdIdx.GetNode().GetTxtNode(); SwPosition aPos( aNdIdx, SwIndex( pTxtNd )); - pDoc->Copy( *this, aPos, false ); + pDoc->CopyRange( *this, aPos, false ); // JP 08.10.98: die Vorlage vom EndNode ggfs. mit uebernehmen // - ist im Doc::Copy nicht erwuenscht @@ -3444,7 +3451,7 @@ void SwRedline::CopyToSection() if( pCEndNd ) { SwPosition aPos( *pSttNd->EndOfSectionNode() ); - pDoc->Copy( *this, aPos, false ); + pDoc->CopyRange( *this, aPos, false ); } else { @@ -3498,7 +3505,7 @@ void SwRedline::DelCopyOfSection() { if( pCSttNd && !pCEndNd ) bDelLastPara = TRUE; - pDoc->Delete( aPam ); + pDoc->DeleteRange( aPam ); if( bDelLastPara ) { @@ -3539,7 +3546,9 @@ void SwRedline::DelCopyOfSection() } } else - pDoc->Delete( aPam ); + { + pDoc->DeleteRange( aPam ); + } if( pStt == GetPoint() ) Exchange(); @@ -3622,7 +3631,10 @@ void SwRedline::MoveFromSection() pDoc->AppendTxtNode( aPos ); } else - pDoc->Move( aPam, aPos, IDocumentContentOperations::DOC_MOVEALLFLYS ); + { + pDoc->MoveRange( aPam, aPos, + IDocumentContentOperations::DOC_MOVEALLFLYS ); + } SetMark(); *GetPoint() = aPos; diff --git a/sw/source/core/doc/docruby.cxx b/sw/source/core/doc/docruby.cxx index 1237614825d3..09977c9e0f7b 100644 --- a/sw/source/core/doc/docruby.cxx +++ b/sw/source/core/doc/docruby.cxx @@ -147,16 +147,20 @@ USHORT SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList, { // set/reset the attribut if( pEntry->GetRubyAttr().GetText().Len() ) - Insert( aPam, pEntry->GetRubyAttr(), 0 ); + { + InsertPoolItem( aPam, pEntry->GetRubyAttr(), 0 ); + } else + { ResetAttrs( aPam, TRUE, &aDelArr ); + } } if( aCheckEntry.GetText() != pEntry->GetText() && pEntry->GetText().Len() ) { // text is changed, so replace the original - Replace( aPam, pEntry->GetText(), FALSE ); + ReplaceRange( aPam, pEntry->GetText(), false ); } aPam.DeleteMark(); } @@ -176,10 +180,11 @@ USHORT SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList, if( pEntry->GetRubyAttr().GetText().Len() && pEntry->GetText().Len() ) { - Insert( aPam, pEntry->GetText(), true ); + InsertString( aPam, pEntry->GetText() ); aPam.SetMark(); aPam.GetMark()->nContent -= pEntry->GetText().Len(); - Insert( aPam, pEntry->GetRubyAttr(), nsSetAttrMode::SETATTR_DONTEXPAND ); + InsertPoolItem( aPam, pEntry->GetRubyAttr(), + nsSetAttrMode::SETATTR_DONTEXPAND ); } else break; diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index c69483346a96..67fec1f7d33d 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -452,7 +452,8 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) aRg.aEnd = aRg.aStart.GetIndex() + 1; // Nodes verschieben - Move( aRg, aStart, IDocumentContentOperations::DOC_MOVEDEFAULT ); + MoveNodeRange( aRg, aStart, + IDocumentContentOperations::DOC_MOVEDEFAULT ); // Undo Verschiebungen einpflegen if(pUndoSort) @@ -777,7 +778,8 @@ void MoveCell(SwDoc* pDoc, const SwTableBox* pSource, const SwTableBox* pTar, // Einfuegen der Source SwNodeIndex aIns( *pTar->GetSttNd()->EndOfSectionNode() ); - pDoc->Move( aRg, aIns, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveNodeRange( aRg, aIns, + IDocumentContentOperations::DOC_MOVEDEFAULT ); // Falls erster Node leer -> weg damit if(bDelFirst) diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 6cc034c572d8..0119274f7b5e 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -182,7 +182,7 @@ USHORT SwDoc::GetCurTOXMark( const SwPosition& rPos, Beschreibung: Marke loeschen --------------------------------------------------------------------*/ -void SwDoc::Delete( const SwTOXMark* pTOXMark ) +void SwDoc::DeleteTOXMark( const SwTOXMark* pTOXMark ) { // hole den TextNode und const SwTxtTOXMark* pTxtTOXMark = pTOXMark->GetTxtTOXMark(); @@ -202,12 +202,15 @@ void SwDoc::Delete( const SwTOXMark* pTOXMark ) SwRegHistory aRHst( rTxtNd, &pUndo->GetHistory() ); rTxtNd.GetpSwpHints()->Register( &aRHst ); - rTxtNd.Delete( const_cast<SwTxtTOXMark*>( pTxtTOXMark ), TRUE ); + } + + rTxtNd.DeleteAttribute( const_cast<SwTxtTOXMark*>(pTxtTOXMark) ); + + if ( DoesUndo() ) + { if( rTxtNd.GetpSwpHints() ) rTxtNd.GetpSwpHints()->DeRegister(); } - else - rTxtNd.Delete( const_cast<SwTxtTOXMark*>( pTxtTOXMark ), TRUE ); SetModified(); } @@ -372,7 +375,7 @@ const SwTOXBaseSection* SwDoc::InsertTableOf( const SwPosition& rPos, pNew->SetTOXName(sSectNm); pNew->SwSection::SetName(sSectNm); SwPaM aPam( rPos ); - SwSection* pSect = Insert( aPam, *pNew, pSet, FALSE ); + SwSection* pSect = InsertSwSection( aPam, *pNew, pSet, false ); if( pSect ) { SwSectionNode* pSectNd = pSect->GetFmt()->GetSectionNode(); @@ -956,7 +959,7 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr, SwTxtNode* pHeadNd = pDoc->GetNodes().MakeTxtNode( aIdx, GetTxtFmtColl( FORM_TITLE ) ); - pHeadNd->Insert( GetTitle(), SwIndex( pHeadNd )); + pHeadNd->InsertText( GetTitle(), SwIndex( pHeadNd ) ); String sNm( GetTOXName() ); // ??Resource @@ -1939,9 +1942,12 @@ void SwTOXBaseSection::GenerateText( USHORT nArrayIdx, else pCharFmt = pDoc->FindCharFmtByName( aToken.sCharStyleName); - if(pCharFmt) - pTOXNd->InsertItem( SwFmtCharFmt( pCharFmt ), nStartCharStyle, - rTxt.Len(), nsSetAttrMode::SETATTR_DONTEXPAND ); + if (pCharFmt) + { + SwFmtCharFmt aFmt( pCharFmt ); + pTOXNd->InsertItem( aFmt, nStartCharStyle, + rTxt.Len(), nsSetAttrMode::SETATTR_DONTEXPAND ); + } } aIt++; // #i21237# @@ -2139,7 +2145,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, break; } } - pNd->Erase(aPos, nEndPos - nStartPos + 2); + pNd->EraseText(aPos, nEndPos - nStartPos + 2); for( i = 1; i < rNums.Count(); ++i) { @@ -2213,7 +2219,8 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, GetNumType() ).GetNumStr( nBeg+nCount ); } } - pNd->Insert( aNumStr, aPos, INS_EMPTYEXPAND ); + pNd->InsertText( aNumStr, aPos, + IDocumentContentOperations::INS_EMPTYEXPAND ); if(pPageNoCharFmt) { SwFmtCharFmt aCharFmt( pPageNoCharFmt ); diff --git a/sw/source/core/doc/extinput.cxx b/sw/source/core/doc/extinput.cxx index bbb2f51b8302..03cb8f5366f3 100644 --- a/sw/source/core/doc/extinput.cxx +++ b/sw/source/core/doc/extinput.cxx @@ -89,7 +89,7 @@ SwExtTextInput::~SwExtTextInput() if ( bLang ) { SvxLanguageItem aLangItem( eInputLanguage, nWhich ); - pDoc->Insert(*this, aLangItem, 0 ); + pDoc->InsertPoolItem(*this, aLangItem, 0 ); } } rIdx = nSttCnt; @@ -100,9 +100,9 @@ SwExtTextInput::~SwExtTextInput() if( nLen > sOverwriteText.Len() ) { rIdx += sOverwriteText.Len(); - pTNd->Erase( rIdx, nLen - sOverwriteText.Len() ); + pTNd->EraseText( rIdx, nLen - sOverwriteText.Len() ); rIdx = nSttCnt; - pTNd->Replace( rIdx, sOverwriteText.Len(), + pTNd->ReplaceText( rIdx, sOverwriteText.Len(), sOverwriteText ); if( bInsText ) { @@ -110,13 +110,15 @@ SwExtTextInput::~SwExtTextInput() pDoc->StartUndo( UNDO_OVERWRITE, NULL ); pDoc->Overwrite( *this, sTxt.Copy( 0, sOverwriteText.Len() )); - pDoc->Insert( *this, sTxt.Copy( sOverwriteText.Len() ), true); + pDoc->InsertString( *this, + sTxt.Copy( sOverwriteText.Len() ) ); pDoc->EndUndo( UNDO_OVERWRITE, NULL ); } } else { - pTNd->Replace( rIdx, nLen, sOverwriteText.Copy( 0, nLen )); + pTNd->ReplaceText( rIdx, nLen, + sOverwriteText.Copy( 0, nLen )); if( bInsText ) { rIdx = nSttCnt; @@ -126,10 +128,12 @@ SwExtTextInput::~SwExtTextInput() } else { - pTNd->Erase( rIdx, nEndCnt - nSttCnt ); + pTNd->EraseText( rIdx, nEndCnt - nSttCnt ); if( bInsText ) - pDoc->Insert( *this, sTxt, true ); + { + pDoc->InsertString( *this, sTxt ); + } } } } @@ -159,7 +163,7 @@ void SwExtTextInput::SetInputData( const CommandExtTextInputData& rData ) // some characters nReplace = nReplace - rNewStr.Len(); aIdx += rNewStr.Len(); - pTNd->Replace( aIdx, nReplace, + pTNd->ReplaceText( aIdx, nReplace, sOverwriteText.Copy( rNewStr.Len(), nReplace )); aIdx = nSttCnt; nReplace = rNewStr.Len(); @@ -168,14 +172,14 @@ void SwExtTextInput::SetInputData( const CommandExtTextInputData& rData ) { nReplace = nReplace - sOverwriteText.Len(); aIdx += sOverwriteText.Len(); - pTNd->Erase( aIdx, nReplace ); + pTNd->EraseText( aIdx, nReplace ); aIdx = nSttCnt; nReplace = sOverwriteText.Len(); } else if( (nReplace = sOverwriteText.Len()) > rNewStr.Len() ) nReplace = rNewStr.Len(); - pTNd->Replace( aIdx, nReplace, rNewStr ); + pTNd->ReplaceText( aIdx, nReplace, rNewStr ); if( !HasMark() ) SetMark(); GetMark()->nContent = aIdx; @@ -183,9 +187,12 @@ void SwExtTextInput::SetInputData( const CommandExtTextInputData& rData ) else { if( nSttCnt < nEndCnt ) - pTNd->Erase( aIdx, nEndCnt - nSttCnt ); + { + pTNd->EraseText( aIdx, nEndCnt - nSttCnt ); + } - pTNd->Insert( rNewStr, aIdx, INS_EMPTYEXPAND ); + pTNd->InsertText( rNewStr, aIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); if( !HasMark() ) SetMark(); } diff --git a/sw/source/core/doc/makefile.mk b/sw/source/core/doc/makefile.mk index 9e01f6ff1e80..c7459cd164a0 100644 --- a/sw/source/core/doc/makefile.mk +++ b/sw/source/core/doc/makefile.mk @@ -49,6 +49,7 @@ EXCEPTIONSFILES = \ $(SLO)$/docbm.obj \ $(SLO)$/doccomp.obj \ $(SLO)$/docdraw.obj \ + $(SLO)$/docedt.obj \ $(SLO)$/docfmt.obj \ $(SLO)$/docglbl.obj \ $(SLO)$/docglos.obj \ @@ -70,7 +71,6 @@ SLOFILES = $(EXCEPTIONSFILES) \ $(SLO)$/doccorr.obj \ $(SLO)$/docdde.obj \ $(SLO)$/docdesc.obj \ - $(SLO)$/docedt.obj \ $(SLO)$/docfld.obj \ $(SLO)$/docfly.obj \ $(SLO)$/docftn.obj \ diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index c41257a4769b..a2263bc3f442 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -203,6 +203,14 @@ namespace pNewBookmark->SetKeyCode(pOldBookmark->GetKeyCode()); pNewBookmark->SetShortName(pOldBookmark->GetShortName()); } + ::sfx2::Metadatable const*const pMetadatable( + dynamic_cast< ::sfx2::Metadatable const* >(pMark)); + ::sfx2::Metadatable *const pNewMetadatable( + dynamic_cast< ::sfx2::Metadatable * >(pNewMark)); + if (pMetadatable && pNewMetadatable) + { + pNewMetadatable->RegisterAsCopyOf(*pMetadatable); + } } pDestDoc->DoUndo(bDoesUndo); } @@ -271,7 +279,8 @@ SwCntntNode* SwTxtNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const // ??? reicht das ??? was ist mit PostIts/Feldern/FeldTypen ??? // --> OD 2008-11-18 #i96213# - force copy of all attributes - pCpyTxtNd->Copy( pTxtNd, SwIndex( pCpyTxtNd ), pCpyTxtNd->GetTxt().Len(), true ); + pCpyTxtNd->CopyText( pTxtNd, SwIndex( pCpyTxtNd ), + pCpyTxtNd->GetTxt().Len(), true ); // <-- //FEATURE::CONDCOLL @@ -673,7 +682,8 @@ void lcl_DeleteRedlines( const SwNodeRange& rRg, SwNodeRange& rCpyRg ) // Kopieren eines Bereiches im oder in ein anderes Dokument ! -bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const +bool +SwDoc::CopyRange( SwPaM& rPam, SwPosition& rPos, const bool bCopyAll ) const { const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End(); @@ -682,7 +692,7 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const // kein Copy abfangen. if( !rPam.HasMark() || ( *pStt >= *pEnd && !bColumnSel ) ) - return FALSE; + return false; // verhinder das Kopieren in Fly's, die im Bereich verankert sind. if( pDoc == this ) @@ -699,7 +709,9 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const --nEnd, --nDiff; if( nDiff && lcl_ChkFlyFly( pDoc, nStt, nEnd, rPos.nNode.GetIndex() ) ) - return FALSE; + { + return false; + } } SwPaM* pRedlineRange = 0; @@ -709,20 +721,25 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const RedlineMode_t eOld = pDoc->GetRedlineMode(); - BOOL bRet = FALSE; + bool bRet = false; if( pDoc != this ) - bRet = _Copy( rPam, rPos, TRUE, bCopyAll, pRedlineRange ); // nur normales Kopieren + { // ordinary copy + bRet = CopyImpl( rPam, rPos, true, bCopyAll, pRedlineRange ); + } // Copy in sich selbst (ueber mehrere Nodes wird hier gesondert // behandelt; in einem TextNode wird normal behandelt) else if( ! ( *pStt <= rPos && rPos < *pEnd && ( pStt->nNode != pEnd->nNode || !pStt->nNode.GetNode().IsTxtNode() )) ) - bRet = _Copy( rPam, rPos, TRUE, bCopyAll, pRedlineRange ); // nur normales Kopieren - + { // ordinary copy + bRet = CopyImpl( rPam, rPos, true, bCopyAll, pRedlineRange ); + } else { ASSERT( this == pDoc, " falscher Copy-Zweig!" ); + ASSERT(false, "mst: i thought this could be dead code;" + "please tell me what you did to get here!"); pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); BOOL bDoUndo = pDoc->DoesUndo(); @@ -742,7 +759,8 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const SwStartNode* pSttNd = pDoc->GetNodes().MakeEmptySection( SwNodeIndex( GetNodes().GetEndOfAutotext() )); aPam.GetPoint()->nNode = *pSttNd->EndOfSectionNode(); - pDoc->_Copy( rPam, *aPam.GetPoint(), FALSE, bCopyAll, 0 ); // kopieren ohne Frames + // copy without Frames + pDoc->CopyImpl( rPam, *aPam.GetPoint(), false, bCopyAll, 0 ); aPam.GetPoint()->nNode = pDoc->GetNodes().GetEndOfAutotext(); aPam.SetMark(); @@ -752,7 +770,8 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const aPam.GetPoint()->nNode = *aPam.GetNode()->StartOfSectionNode(); pNode = pDoc->GetNodes().GoNext( &aPam.GetPoint()->nNode ); pNode->MakeStartIndex( &aPam.GetPoint()->nContent ); - pDoc->Move( aPam, rPos, DOC_MOVEDEFAULT ); // auf gewuenschte Position moven + // move to desired position + pDoc->MoveRange( aPam, rPos, DOC_MOVEDEFAULT ); pNode = aPam.GetCntntNode(); *aPam.GetPoint() = rPos; // Cursor umsetzen fuers Undo ! @@ -776,7 +795,7 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const } pDoc->SetModified(); - bRet = TRUE; + bRet = true; } pDoc->SetRedlineMode_intern( eOld ); @@ -848,8 +867,9 @@ bool lcl_ContainsOnlyParagraphsInList( const SwPaM& rPam ) } // <-- -BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, - BOOL bMakeNewFrms, bool bCopyAll, SwPaM* pCpyRange ) const +bool SwDoc::CopyImpl( SwPaM& rPam, SwPosition& rPos, + const bool bMakeNewFrms, const bool bCopyAll, + SwPaM *const pCpyRange ) const { SwDoc* pDoc = rPos.nNode.GetNode().GetDoc(); const bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection(); @@ -862,7 +882,9 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, //JP 29.6.2001: 88963 - dont copy if inspos is in region of start to end //JP 15.11.2001: don't test inclusive the end, ever exclusive ( pDoc == this && *pStt <= rPos && rPos < *pEnd )) - return FALSE; + { + return false; + } const bool bEndEqualIns = pDoc == this && rPos == *pEnd; @@ -1019,11 +1041,12 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, if( !bCopyOk ) { - xub_StrLen nCpyLen = ( bOneNode + const xub_StrLen nCpyLen = ( (bOneNode) ? pEnd->nContent.GetIndex() : pSttTxtNd->GetTxt().Len() ) - pStt->nContent.GetIndex(); - pSttTxtNd->Copy( pDestTxtNd, aDestIdx, pStt->nContent, nCpyLen ); + pSttTxtNd->CopyText( pDestTxtNd, aDestIdx, + pStt->nContent, nCpyLen ); if( bEndEqualIns ) pEnd->nContent -= nCpyLen; } @@ -1165,8 +1188,8 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, // <-- /* #107213# */ - BOOL bEmptyDestNd = 0 == pDestTxtNd->GetTxt().Len(); - pEndTxtNd->Copy( pDestTxtNd, aDestIdx, SwIndex( pEndTxtNd ), + const bool bEmptyDestNd = 0 == pDestTxtNd->GetTxt().Len(); + pEndTxtNd->CopyText( pDestTxtNd, aDestIdx, SwIndex( pEndTxtNd ), pEnd->nContent.GetIndex() ); // auch alle FormatVorlagen kopieren @@ -1283,7 +1306,7 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, pDoc->SetRedlineMode_intern( eOld ); pDoc->SetModified(); - return TRUE; + return true; } @@ -1328,7 +1351,7 @@ void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndConte // Undo abschalten BOOL bUndo = pDest->DoesUndo(); pDest->DoUndo( FALSE ); - _CopyFlyInFly( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly ); + CopyFlyInFlyImpl( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly ); pDest->DoUndo( bUndo ); SwNodeRange aCpyRange( aSavePos, rInsPos ); @@ -1364,14 +1387,15 @@ void lcl_ChainFmts( SwFlyFrmFmt *pSrc, SwFlyFrmFmt *pDest ) } } -void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, const SwNodeIndex& rSttIdx, - BOOL bCopyFlyAtFly ) const +void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, + const xub_StrLen nEndContentIndex, const SwNodeIndex& rStartIdx, + const bool bCopyFlyAtFly ) const { // Bug 22727: suche erst mal alle Flys zusammen, sortiere sie entsprechend // ihrer Ordnungsnummer und kopiere sie erst dann. Damit wird // die Ordnungsnummer (wird nur im DrawModel verwaltet) // beibehalten. - SwDoc* pDest = rSttIdx.GetNode().GetDoc(); + SwDoc *const pDest = rStartIdx.GetNode().GetDoc(); _ZSortFlys aArr; USHORT nArrLen = GetSpzFrmFmts()->Count(); USHORT n; @@ -1488,10 +1512,10 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentI nAnchorTxtNdNumInRange = 1; } // Second, search corresponding text node in destination document - // by counting forward from start insert position <rSttIdx> the + // by counting forward from start insert position <rStartIdx> the // determined number of text nodes. - aIdx = rSttIdx; - SwNodeIndex aAnchorNdIdx( rSttIdx ); + aIdx = rStartIdx; + SwNodeIndex aAnchorNdIdx( rStartIdx ); const SwNode& aEndOfContentNd = aIdx.GetNode().GetNodes().GetEndOfContent(); while ( nAnchorTxtNdNumInRange > 0 && @@ -1511,7 +1535,7 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentI // text node in the destination document. ASSERT( false, "<SwDoc::_CopyFlyInFly(..)> - found anchor node index isn't a text node" ); - aAnchorNdIdx = rSttIdx; + aAnchorNdIdx = rStartIdx; while ( !aAnchorNdIdx.GetNode().IsTxtNode() ) { ++aAnchorNdIdx; @@ -1523,7 +1547,7 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentI else { long nOffset = pNewPos->nNode.GetIndex() - rRg.aStart.GetIndex(); - SwNodeIndex aIdx( rSttIdx, nOffset ); + SwNodeIndex aIdx( rStartIdx, nOffset ); pNewPos->nNode = aIdx; } // <-- @@ -1548,8 +1572,8 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentI const SwStartNode* pSNd; if( rCntnt.GetCntntIdx() && 0 != ( pSNd = rCntnt.GetCntntIdx()->GetNode().GetStartNode() ) && - pSNd->GetIndex() < rSttIdx.GetIndex() && - rSttIdx.GetIndex() < pSNd->EndOfSectionIndex() ) + pSNd->GetIndex() < rStartIdx.GetIndex() && + rStartIdx.GetIndex() < pSNd->EndOfSectionIndex() ) { bMakeCpy = FALSE; aArr.Remove( n, 1 ); diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index 67838b7fb3f7..0f44f1f3898a 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -158,8 +158,8 @@ void lcl_CheckEmptyLayFrm( SwNodes& rNds, SwSection& rSect, } } -SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, - const SfxItemSet* pAttr, BOOL bUpdate ) +SwSection* SwDoc::InsertSwSection( const SwPaM& rRange, const SwSection& rNew, + const SfxItemSet* pAttr, bool bUpdate ) { const SwNode* pPrvNd = 0; USHORT nRegionRet = 0; @@ -178,10 +178,11 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, if( !pStt->nContent.GetIndex() && pEnd->nNode.GetNode().GetCntntNode()->Len() == pEnd->nContent.GetIndex() ) - - ::lcl_CheckEmptyLayFrm( GetNodes(), (SwSection&)rNew, + { + ::lcl_CheckEmptyLayFrm( GetNodes(), const_cast<SwSection&>(rNew), pStt->nNode.GetNode(), pEnd->nNode.GetNode() ); + } } SwUndoInsSection* pUndoInsSect = 0; @@ -193,9 +194,11 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, DoUndo( FALSE ); } - SwSectionFmt* pFmt = MakeSectionFmt( 0 ); - if( pAttr ) + SwSectionFmt* const pFmt = MakeSectionFmt( 0 ); + if ( pAttr ) + { pFmt->SetFmtAttr( *pAttr ); + } SwSectionNode* pNewSectNode = 0; @@ -222,16 +225,27 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, { if( pUndoInsSect ) { - SwTxtNode* pTNd; if( !( pPrvNd && 1 == nRegionRet ) && - pSttPos->nContent.GetIndex() && - 0 != ( pTNd = pSttPos->nNode.GetNode().GetTxtNode() )) - pUndoInsSect->SaveSplitNode( pTNd, TRUE ); - - if( !( pPrvNd && 2 == nRegionRet ) && - 0 != ( pTNd = pEndPos->nNode.GetNode().GetTxtNode() ) && - pTNd->GetTxt().Len() != pEndPos->nContent.GetIndex() ) - pUndoInsSect->SaveSplitNode( pTNd, FALSE ); + pSttPos->nContent.GetIndex() ) + { + SwTxtNode* const pTNd = + pSttPos->nNode.GetNode().GetTxtNode(); + if (pTNd) + { + pUndoInsSect->SaveSplitNode( pTNd, TRUE ); + } + } + + if ( !( pPrvNd && 2 == nRegionRet ) ) + { + SwTxtNode *const pTNd = + pEndPos->nNode.GetNode().GetTxtNode(); + if (pTNd && + (pTNd->GetTxt().Len() != pEndPos->nContent.GetIndex())) + { + pUndoInsSect->SaveSplitNode( pTNd, FALSE ); + } + } } const SwCntntNode* pCNd; @@ -241,7 +255,9 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, pSttPos->nContent.Assign( pSttPos->nNode.GetNode().GetCntntNode(), 0 ); } else if( pSttPos->nContent.GetIndex() ) + { SplitNode( *pSttPos, false ); + } if( pPrvNd && 2 == nRegionRet ) { @@ -293,7 +309,9 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, else { if( pUndoInsSect && pCNd->IsTxtNode() ) + { pUndoInsSect->SaveSplitNode( (SwTxtNode*)pCNd, TRUE ); + } SplitNode( *pPos, false ); pNewSectNode = GetNodes().InsertSection( pPos->nNode, *pFmt, rNew, 0, TRUE ); } @@ -309,9 +327,13 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, { SwPaM aPam( *pNewSectNode->EndOfSectionNode(), *pNewSectNode, 1 ); if( IsRedlineOn() ) + { AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); + } else + { SplitRedline( aPam ); + } } // ist eine Condition gesetzt @@ -320,7 +342,9 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, // dann berechne bis zu dieser Position SwCalc aCalc( *this ); if( ! IsInReading() ) + { FldsToCalc( aCalc, pNewSectNode->GetIndex(), USHRT_MAX ); + } SwSection& rNewSect = pNewSectNode->GetSection(); rNewSect.SetCondHidden( aCalc.Calculate( rNewSect.GetCondition() ).GetBool() ); } @@ -335,7 +359,9 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, ( FTNEND_ATTXTEND_OWNNUMSEQ == ( nVal = ((SwFmtEndAtTxtEnd&) pAttr->Get( RES_END_AT_TXTEND )).GetValue() ) || FTNEND_ATTXTEND_OWNNUMANDFMT == nVal )) + { bUpdateFtn = TRUE; + } } if( pUndoInsSect ) @@ -346,10 +372,14 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, } if( rNew.IsLinkType() ) + { pNewSectNode->GetSection().CreateLink( bUpdate ? CREATE_UPDATE : CREATE_CONNECT ); + } if( bUpdateFtn ) + { GetFtnIdxs().UpdateFtn( SwNodeIndex( *pNewSectNode )); + } SetModified(); return &pNewSectNode->GetSection(); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index a832c33ec958..a7e7675966c3 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -1034,7 +1034,7 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh, nChPos + 1 ); // Trennzeichen loeschen und SuchString korrigieren - pTxtNd->Erase( aCntPos.nContent, 1 ); + pTxtNd->EraseText( aCntPos.nContent, 1 ); pTxt = pTxtNd->GetTxt().GetBuffer(); nChPos = 0; --nChPos, --pTxt; // for the ++ in the for loop !!! @@ -1551,7 +1551,8 @@ BOOL lcl_DelBox( const SwTableBox*& rpBox, void* pPara ) { // Inserting the seperator SwIndex aCntIdx( pDelPara->pLastNd, pDelPara->pLastNd->GetTxt().Len()); - pDelPara->pLastNd->Insert( pDelPara->cCh, aCntIdx ); + pDelPara->pLastNd->InsertText( pDelPara->cCh, aCntIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); if( pDelPara->pUndo ) pDelPara->pUndo->AddBoxPos( *pDoc, nNdIdx, aDelRg.aEnd.GetIndex(), aCntIdx.GetIndex() ); diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index ef39f7ced4a4..ce24e4ba06b5 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -47,6 +47,7 @@ #include <ddefld.hxx> #include <swddetbl.hxx> #include <frame.hxx> +#include <fmtmeta.hxx> #include <docsh.hxx> #include <svtools/smplhint.hxx> @@ -288,7 +289,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, SwTxtNode* pTxtNd = pCNd->GetTxtNode(); if( pTxtNd ) { - const SwpHints* pHts = pTxtNd->GetpSwpHints(); + SwpHints * const pHts = pTxtNd->GetpSwpHints(); // setze die OultineNodes im neuen Nodes-Array //if( bInsOutlineIdx && NO_NUMBERING != //#outline level,removed by zhaojianwei // pTxtNd->GetTxtColl()->GetOutlineLevel() ) @@ -306,16 +307,17 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, // Sonderbehandlung fuer die Felder! if( pHts && pHts->Count() ) { - const SwTxtAttr* pAttr; int bToUndo = &pDestDoc->GetNodes() != &rNds; for( USHORT i = pHts->Count(); i; ) { USHORT nDelMsg = 0; - switch( (pAttr = (*pHts)[ --i ])->Which() ) + SwTxtAttr * const pAttr = pHts->GetTextHint( --i ); + switch ( pAttr->Which() ) { case RES_TXTATR_FIELD: { - SwTxtFld* pTxtFld = (SwTxtFld*)pAttr; + SwTxtFld* pTxtFld = + static_cast<SwTxtFld*>(pAttr); rNds.GetDoc()->InsDelFldInFldLst( !bToUndo, *pTxtFld ); const SwFieldType* pTyp = pTxtFld->GetFld().GetFld()->GetTyp(); @@ -345,6 +347,15 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, case RES_TXTATR_REFMARK: nDelMsg = RES_REFMARK_DELETED; break; + + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + static_cast<SwFmtMeta&>(pAttr->GetAttr()) + .NotifyRemoval(); + break; + + default: + break; } if( nDelMsg && bToUndo ) { @@ -1762,10 +1773,10 @@ USHORT HighestLevel( SwNodes & rNodes, const SwNodeRange & rRange ) |* Letzte Aenderung JP 09.07.92 |* *************************************************************************/ -void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, - BOOL ) +void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) { - SwPosition *pStt = (SwPosition*)rPam.Start(), *pEnd = (SwPosition*)rPam.End(); + SwPosition * const pStt = rPam.Start(); + SwPosition * const pEnd = rPam.End(); if( !rPam.HasMark() || *pStt >= *pEnd ) return; @@ -1775,10 +1786,9 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, SwNodeIndex aEndIdx( pEnd->nNode ); SwNodeIndex aSttIdx( pStt->nNode ); - SwTxtNode* pSrcNd = (*this)[ aSttIdx ]->GetTxtNode(); + SwTxtNode* const pSrcNd = (*this)[ aSttIdx ]->GetTxtNode(); SwTxtNode* pDestNd = rNodes[ rPos.nNode ]->GetTxtNode(); BOOL bSplitDestNd = TRUE; - BOOL bSttTxtNd = 0 != pSrcNd; BOOL bCopyCollFmt = pDestNd && !pDestNd->GetTxt().Len(); if( pSrcNd ) @@ -1792,67 +1802,74 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, rPos.nContent.Assign( pDestNd, 0 ); bCopyCollFmt = TRUE; } -/*!NOSPLIT bSplitDestNd = !bSplitNd && - ( pDestNd->Len() > rPos.nContent.GetIndex() || - !aEndIdx.GetNode().IsTxtNode() ); -*/ -// ASSERT( bSplitNd, "Move mit bSplitNode = FALSE" ); bSplitDestNd = pDestNd->Len() > rPos.nContent.GetIndex() || pEnd->nNode.GetNode().IsTxtNode(); // verschiebe jetzt noch den Inhalt in den neuen Node BOOL bOneNd = pStt->nNode == pEnd->nNode; - xub_StrLen nLen = ( bOneNd ? pEnd->nContent.GetIndex() : pSrcNd->Len() ) - - pStt->nContent.GetIndex(); + const xub_StrLen nLen = + ( (bOneNd) ? pEnd->nContent.GetIndex() : pSrcNd->Len() ) + - pStt->nContent.GetIndex(); if( !pEnd->nNode.GetNode().IsCntntNode() ) { bOneNd = TRUE; - ULONG nSttNdIdx = pStt->nNode.GetIndex() + 1, - nEndNdIdx = pEnd->nNode.GetIndex(); + ULONG nSttNdIdx = pStt->nNode.GetIndex() + 1; + const ULONG nEndNdIdx = pEnd->nNode.GetIndex(); for( ; nSttNdIdx < nEndNdIdx; ++nSttNdIdx ) + { if( (*this)[ nSttNdIdx ]->IsCntntNode() ) { bOneNd = FALSE; break; } + } } // das kopieren / setzen der Vorlagen darf erst nach // dem Splitten erfolgen -//!NOSPLIT if( !bOneNd && ( bSplitNd || bSplitDestNd )) if( !bOneNd && bSplitDestNd ) { if( !rPos.nContent.GetIndex() ) + { bCopyCollFmt = TRUE; + } if( rNodes.IsDocNodes() ) { - SwDoc* pInsDoc = pDestNd->GetDoc(); - BOOL bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( FALSE ); + SwDoc* const pInsDoc = pDestNd->GetDoc(); + const bool bIsUndo = pInsDoc->DoesUndo(); + pInsDoc->DoUndo( false ); pInsDoc->SplitNode( rPos, false ); pInsDoc->DoUndo( bIsUndo ); } else + { pDestNd->SplitCntntNode( rPos ); + } if( rPos.nNode == aEndIdx ) + { aEndIdx--; + } bSplitDestNd = TRUE; pDestNd = rNodes[ rPos.nNode.GetIndex() - 1 ]->GetTxtNode(); if( nLen ) - pSrcNd->Cut( pDestNd, SwIndex( pDestNd, pDestNd->Len()), + { + pSrcNd->CutText( pDestNd, SwIndex( pDestNd, pDestNd->Len()), pStt->nContent, nLen ); + } + } + else if ( nLen ) + { + pSrcNd->CutText( pDestNd, rPos.nContent, pStt->nContent, nLen ); } - else if( nLen ) - pSrcNd->Cut( pDestNd, rPos.nContent, pStt->nContent, nLen ); if( bCopyCollFmt ) { - SwDoc* pInsDoc = pDestNd->GetDoc(); - BOOL bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( FALSE ); + SwDoc* const pInsDoc = pDestNd->GetDoc(); + const bool bIsUndo = pInsDoc->DoesUndo(); + pInsDoc->DoUndo( false ); pSrcNd->CopyCollFmt( *pDestNd ); pInsDoc->DoUndo( bIsUndo ); bCopyCollFmt = FALSE; @@ -1865,7 +1882,8 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, // wird aufgehoben ! pEnd->nContent = pStt->nContent; rPam.DeleteMark(); - GetDoc()->GetDocShell()->Broadcast( SwFmtFldHint( 0, rNodes.IsDocNodes() ? SWFMTFLD_INSERTED : SWFMTFLD_REMOVED ) ); + GetDoc()->GetDocShell()->Broadcast( SwFmtFldHint( 0, + rNodes.IsDocNodes() ? SWFMTFLD_INSERTED : SWFMTFLD_REMOVED ) ); return; } @@ -1875,106 +1893,117 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, { if( rPos.nContent.GetIndex() ) { -//!NOSPLIT if( !bSplitNd && rPos.nContent.GetIndex() == pDestNd->Len() ) if( rPos.nContent.GetIndex() == pDestNd->Len() ) + { rPos.nNode++; + } else if( rPos.nContent.GetIndex() ) { // falls im EndNode gesplittet wird, dann muss der EndIdx // korrigiert werden !! - BOOL bCorrEnde = aEndIdx == rPos.nNode; + const bool bCorrEnd = aEndIdx == rPos.nNode; // es wird kein Text an den TextNode angehaengt, also splitte ihn if( rNodes.IsDocNodes() ) { - SwDoc* pInsDoc = pDestNd->GetDoc(); - BOOL bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( FALSE ); + SwDoc* const pInsDoc = pDestNd->GetDoc(); + const bool bIsUndo = pInsDoc->DoesUndo(); + pInsDoc->DoUndo( false ); pInsDoc->SplitNode( rPos, false ); pInsDoc->DoUndo( bIsUndo ); } else + { pDestNd->SplitCntntNode( rPos ); + } pDestNd = rPos.nNode.GetNode().GetTxtNode(); - if( bCorrEnde ) + if ( bCorrEnd ) + { aEndIdx--; + } } } // am Ende steht noch ein leerer Text Node herum. bSplitDestNd = TRUE; } - pSrcNd = (*this)[ aEndIdx ]->GetTxtNode(); - if( pSrcNd ) + SwTxtNode* const pEndSrcNd = (*this)[ aEndIdx ]->GetTxtNode(); + if ( pEndSrcNd ) { -// if( pEnd->nContent.GetIndex() ? TRUE : aEndIdx != pStt->nNode ) { // am Bereichsende entsteht ein neuer TextNode if( !bSplitDestNd ) { if( rPos.nNode < rNodes.GetEndOfContent().GetIndex() ) + { rPos.nNode++; + } - pDestNd = rNodes.MakeTxtNode( rPos.nNode, pSrcNd->GetTxtColl() ); + pDestNd = + rNodes.MakeTxtNode( rPos.nNode, pEndSrcNd->GetTxtColl() ); rPos.nNode--; rPos.nContent.Assign( pDestNd, 0 ); } else + { pDestNd = rNodes[ rPos.nNode ]->GetTxtNode(); + } if( pDestNd && pEnd->nContent.GetIndex() ) { // verschiebe jetzt noch den Inhalt in den neuen Node - SwIndex aIdx( pSrcNd, 0 ); - pSrcNd->Cut( pDestNd, rPos.nContent, aIdx, + SwIndex aIdx( pEndSrcNd, 0 ); + pEndSrcNd->CutText( pDestNd, rPos.nContent, aIdx, pEnd->nContent.GetIndex()); } if( bCopyCollFmt ) { - SwDoc* pInsDoc = pDestNd->GetDoc(); - BOOL bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( FALSE ); - pSrcNd->CopyCollFmt( *pDestNd ); + SwDoc* const pInsDoc = pDestNd->GetDoc(); + const bool bIsUndo = pInsDoc->DoesUndo(); + pInsDoc->DoUndo( false ); + pEndSrcNd->CopyCollFmt( *pDestNd ); pInsDoc->DoUndo( bIsUndo ); } } } else { - if( bSttTxtNd && aEndIdx.GetNode().IsCntntNode() ) + if ( pSrcNd && aEndIdx.GetNode().IsCntntNode() ) + { aEndIdx++; -//!NOSPLIT + } if( !bSplitDestNd ) { rPos.nNode++; rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), 0 ); } -//!NOSPLIT } if( aEndIdx != aSttIdx ) { // verschiebe jetzt die Nodes in das NodesArary - SwNodeIndex aPrvIdx( rPos.nNode, -1 ); - ULONG nSttDiff = aSttIdx.GetIndex() - pStt->nNode.GetIndex(); + const ULONG nSttDiff = aSttIdx.GetIndex() - pStt->nNode.GetIndex(); SwNodeRange aRg( aSttIdx, aEndIdx ); _MoveNodes( aRg, rNodes, rPos.nNode ); // falls ins gleiche Nodes-Array verschoben wurde, stehen die // Indizies jetzt auch an der neuen Position !!!! // (also alles wieder umsetzen) if( &rNodes == this ) + { pStt->nNode = aRg.aEnd.GetIndex() - nSttDiff; + } } // falls der Start-Node verschoben wurde, in dem der Cursor stand, so // muss der Content im akt. Content angemeldet werden !!! - if( &pStt->nNode.GetNode() == &GetEndOfContent() && - !GoPrevious( &pStt->nNode )) + if ( &pStt->nNode.GetNode() == &GetEndOfContent() ) { - ASSERT( FALSE, "Move() - kein ContentNode mehr vorhanden" ); + const bool bSuccess = GoPrevious( &pStt->nNode ); + ASSERT( bSuccess, "Move() - no ContentNode here" ); + (void) bSuccess; } pStt->nContent.Assign( (*this)[ pStt->nNode ]->GetCntntNode(), pStt->nContent.GetIndex() ); @@ -1983,7 +2012,8 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, // wird aufgehoben ! *pEnd = *pStt; rPam.DeleteMark(); - GetDoc()->GetDocShell()->Broadcast( SwFmtFldHint( 0, rNodes.IsDocNodes() ? SWFMTFLD_INSERTED : SWFMTFLD_REMOVED ) ); + GetDoc()->GetDocShell()->Broadcast( SwFmtFldHint( 0, + rNodes.IsDocNodes() ? SWFMTFLD_INSERTED : SWFMTFLD_REMOVED ) ); } diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 33cd325c669a..1a174d9d54de 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -1414,7 +1414,10 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType, if( pSrcDoc != pDoc || pCpyPam->Start()->nNode > rInsPos || rInsPos >= pCpyPam->End()->nNode ) - pSrcDoc->Copy( *pCpyPam, *pPam->GetPoint(), false ); + { + pSrcDoc->CopyRange( *pCpyPam, *pPam->GetPoint(), + false ); + } delete pCpyPam; } if( pCpyRg && pSrcDoc == pDoc && diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx index 3867d0a4a891..0ed60f355085 100644 --- a/sw/source/core/edit/acorrect.cxx +++ b/sw/source/core/edit/acorrect.cxx @@ -42,7 +42,6 @@ #include <fmtinfmt.hxx> #include <txtatr.hxx> #include <txtinet.hxx> -#include <fmthbsh.hxx> #include <editsh.hxx> #include <doc.hxx> #include <pam.hxx> @@ -125,7 +124,9 @@ void SwAutoCorrDoc::DeleteSel( SwPaM& rDelPam ) pDoc->DeleteAndJoin( rDelPam ); } else - pDoc->Delete( rDelPam ); + { + pDoc->DeleteRange( rDelPam ); + } } BOOL SwAutoCorrDoc::Delete( xub_StrLen nStt, xub_StrLen nEnd ) @@ -143,7 +144,7 @@ BOOL SwAutoCorrDoc::Delete( xub_StrLen nStt, xub_StrLen nEnd ) BOOL SwAutoCorrDoc::Insert( xub_StrLen nPos, const String& rTxt ) { SwPaM aPam( rCrsr.GetPoint()->nNode.GetNode(), nPos ); - rEditSh.GetDoc()->Insert( aPam, rTxt, true ); + rEditSh.GetDoc()->InsertString( aPam, rTxt ); if( !bUndoIdInitialized ) { bUndoIdInitialized = true; @@ -163,23 +164,27 @@ BOOL SwAutoCorrDoc::Replace( xub_StrLen nPos, const String& rTxt ) pPam->GetPoint()->nContent = nPos; } - BOOL bChg = TRUE; - SwTxtNode* pNd = pPam->GetNode()->GetTxtNode(); - if( pNd ) + SwTxtNode * const pNd = pPam->GetNode()->GetTxtNode(); + if ( !pNd ) { - // TextAttribute ohne Ende duerfen nie ersetzt werden! - sal_Unicode cChr; - for( xub_StrLen n = 0, nLen = rTxt.Len(); n < nLen; ++n ) - if( ( CH_TXTATR_BREAKWORD == (cChr = pNd->GetTxt(). - GetChar( n + nPos )) || CH_TXTATR_INWORD == cChr ) && - pNd->GetTxtAttr( n + nPos ) ) - { - bChg = FALSE; - break; - } + return FALSE; + } + + // text attributes with dummy characters must not be replaced! + bool bDoReplace = true; + xub_StrLen const nLen = rTxt.Len(); + for ( xub_StrLen n = 0; n < nLen; ++n ) + { + sal_Unicode const Char = pNd->GetTxt().GetChar( n + nPos ); + if ( ( CH_TXTATR_BREAKWORD == Char || CH_TXTATR_INWORD == Char ) + && pNd->GetTxtAttrForCharAt( n + nPos ) ) + { + bDoReplace = false; + break; + } } - if( bChg ) + if ( bDoReplace ) { SwDoc* pDoc = rEditSh.GetDoc(); @@ -190,7 +195,9 @@ BOOL SwAutoCorrDoc::Replace( xub_StrLen nPos, const String& rTxt ) if( pDoc->IsAutoFmtRedline() ) { if( nPos == pNd->GetTxt().Len() ) // am Ende erfolgt ein Insert - pDoc->Insert( *pPam, rTxt, true ); + { + pDoc->InsertString( *pPam, rTxt ); + } else { _PaMIntoCrsrShellRing aTmp( rEditSh, rCrsr, *pPam ); @@ -198,7 +205,7 @@ BOOL SwAutoCorrDoc::Replace( xub_StrLen nPos, const String& rTxt ) pPam->SetMark(); pPam->GetPoint()->nContent = Min( pNd->GetTxt().Len(), xub_StrLen( nPos + rTxt.Len() )); - pDoc->Replace( *pPam, rTxt, FALSE ); + pDoc->ReplaceRange( *pPam, rTxt, false ); pPam->Exchange(); pPam->DeleteMark(); } @@ -333,7 +340,7 @@ BOOL SwAutoCorrDoc::ChgAutoCorrWord( xub_StrLen & rSttPos, xub_StrLen nEndPos, '.' != pFnd->GetLong().GetChar( pFnd->GetLong().Len() - 1 ) ) { // replace the selection - pDoc->Replace( aPam, pFnd->GetLong(), false); + pDoc->ReplaceRange( aPam, pFnd->GetLong(), false); bRet = TRUE; } } @@ -374,7 +381,7 @@ BOOL SwAutoCorrDoc::ChgAutoCorrWord( xub_StrLen & rSttPos, xub_StrLen nEndPos, SwDontExpandItem aExpItem; aExpItem.SaveDontExpandItems( *aPam.GetPoint() ); - pAutoDoc->Copy( aCpyPam, *aPam.GetPoint(), false ); + pAutoDoc->CopyRange( aCpyPam, *aPam.GetPoint(), false ); aExpItem.RestoreDontExpandItems( *aPam.GetPoint() ); diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 164011a48a8f..7bacee8fbde4 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -44,9 +44,7 @@ #include <svx/lrspitem.hxx> #include <svx/brkitem.hxx> #include <svx/adjitem.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/fontitem.hxx> #include <svx/langitem.hxx> #include <svx/cscoitem.hxx> @@ -74,7 +72,6 @@ #include <acorrect.hxx> #include <shellres.hxx> #include <section.hxx> -#include <fmthbsh.hxx> #include <frmatr.hxx> #include <charatr.hxx> #include <mdiexp.hxx> @@ -645,7 +642,7 @@ BOOL SwAutoFormat::DoUnderline() aBox.SetLine( &aLine, BOX_LINE_BOTTOM ); aBox.SetDistance( 42 ); // ~0,75 mm aSet.Put(aBox); - pDoc->Insert( aDelPam, aSet, 0 ); + pDoc->InsertItemSet( aDelPam, aSet, 0 ); aDelPam.DeleteMark(); } @@ -1300,7 +1297,9 @@ void SwAutoFormat::DelMoreLinesBlanks( BOOL bWithLineBreaks ) BOOL bHasBlnks = HasSelBlanks( *pNxt ); DeleteSel( *pNxt ); if( !bHasBlnks ) - pDoc->Insert( *pNxt, ' ' ); + { + pDoc->InsertString( *pNxt, sal_Unicode(' ') ); + } } if( pNxt == &aDelPam ) @@ -1357,7 +1356,9 @@ void SwAutoFormat::BuildIndent() IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() )) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; pNxtNd = GetNextNode(); @@ -1396,7 +1397,9 @@ void SwAutoFormat::BuildTextIndent() bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() ) ) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; pNxtNd = GetNextNode(); @@ -1430,7 +1433,9 @@ void SwAutoFormat::BuildText() bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() ) ) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; const SwTxtNode* pCurrNode = pNxtNd; @@ -1705,7 +1710,7 @@ void SwAutoFormat::BuildEnum( USHORT nLvl, USHORT nDigitLevel ) String sChgStr( '\t' ); if( bChgBullet ) sChgStr.Insert( aFlags.cBullet, 0 ); - pDoc->Insert( aDelPam, sChgStr, true ); + pDoc->InsertString( aDelPam, sChgStr ); SfxItemSet aSet( pDoc->GetAttrPool(), aTxtNodeSetRange ); if( bChgBullet ) @@ -1745,7 +1750,9 @@ void SwAutoFormat::BuildEnum( USHORT nLvl, USHORT nDigitLevel ) bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() ) ) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; const SwTxtNode* pCurrNode = pNxtNd; @@ -1813,7 +1820,9 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces ) aDelPam.GetMark()->nContent = nSpaceStt; DeleteSel( aDelPam ); if( bInsTab ) - pDoc->Insert( aDelPam, '\t' ); + { + pDoc->InsertString( aDelPam, sal_Unicode('\t') ); + } } } @@ -1831,7 +1840,9 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces ) IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() ) ) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; pNxtNd = GetNextNode(); @@ -1942,7 +1953,7 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos ) sReplace.Erase( 1 ); bSetHardBlank = TRUE; } - pDoc->Replace( aDelPam, sReplace, FALSE ); + pDoc->ReplaceRange( aDelPam, sReplace, false ); if( aFlags.bWithRedlining ) { @@ -1957,7 +1968,7 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos ) aDelPam.DeleteMark(); if( bSetHardBlank ) { - pDoc->Insert( aDelPam, CHAR_HARDBLANK ); + pDoc->InsertString( aDelPam, CHAR_HARDBLANK ); ++nPos; } } @@ -1994,7 +2005,7 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos ) aDelPam.SetMark(); aDelPam.GetPoint()->nContent = nPos+1; - pDoc->Replace( aDelPam, sReplace, FALSE ); + pDoc->ReplaceRange( aDelPam, sReplace, false ); if( aFlags.bWithRedlining ) { @@ -2012,7 +2023,7 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos ) if( bSetHardBlank ) { aDelPam.GetPoint()->nContent = nPos; - pDoc->Insert( aDelPam, CHAR_HARDBLANK ); + pDoc->InsertString( aDelPam, CHAR_HARDBLANK ); aDelPam.GetPoint()->nContent = ++nPos; } } diff --git a/sw/source/core/edit/edatmisc.cxx b/sw/source/core/edit/edatmisc.cxx index bcdea59eaa16..4ec1934f0e87 100644 --- a/sw/source/core/edit/edatmisc.cxx +++ b/sw/source/core/edit/edatmisc.cxx @@ -141,7 +141,9 @@ void SwEditShell::SetAttr( const SfxPoolItem& rHint, USHORT nFlags ) FOREACHPAM_START(this) if( PCURCRSR->HasMark() && ( bIsTblMode || *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() )) - GetDoc()->Insert(*PCURCRSR, rHint, nFlags ); + { + GetDoc()->InsertPoolItem(*PCURCRSR, rHint, nFlags ); + } FOREACHPAM_END() GetDoc()->EndUndo(UNDO_INSATTR, NULL); @@ -150,7 +152,7 @@ void SwEditShell::SetAttr( const SfxPoolItem& rHint, USHORT nFlags ) { if( !HasSelection() ) UpdateAttr(); - GetDoc()->Insert( *pCrsr, rHint, nFlags ); + GetDoc()->InsertPoolItem( *pCrsr, rHint, nFlags ); } EndAllAction(); } @@ -169,7 +171,9 @@ void SwEditShell::SetAttr( const SfxItemSet& rSet, USHORT nFlags ) FOREACHPAM_START(this) if( PCURCRSR->HasMark() && ( bIsTblMode || *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() )) - GetDoc()->Insert(*PCURCRSR, rSet, nFlags ); + { + GetDoc()->InsertItemSet(*PCURCRSR, rSet, nFlags ); + } FOREACHPAM_END() GetDoc()->EndUndo(UNDO_INSATTR, NULL); @@ -178,7 +182,7 @@ void SwEditShell::SetAttr( const SfxItemSet& rSet, USHORT nFlags ) { if( !HasSelection() ) UpdateAttr(); - GetDoc()->Insert( *pCrsr, rSet, nFlags ); + GetDoc()->InsertItemSet( *pCrsr, rSet, nFlags ); } EndAllAction(); } diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index 5d1b4fb43c94..5ca8e4f2c3cb 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -452,17 +452,21 @@ BOOL lcl_IsNoEndTxtAttrAtPos( const SwTxtNode& rTNd, xub_StrLen nPos, } // and fields - const SwTxtAttr* pTFld; - if( CH_TXTATR_BREAKWORD == rTxt.GetChar( nPos ) && - 0 != ( pTFld = rTNd.GetTxtAttr( nPos ) ) ) + if ( CH_TXTATR_BREAKWORD == rTxt.GetChar( nPos ) ) { - bRet = TRUE; // all other then fields can be - // defined as weak-script ? - const SwField* pFld; - if( RES_TXTATR_FIELD == pTFld->Which() && - 0 != (pFld = pTFld->GetFld().GetFld() ) ) + const SwTxtAttr* const pAttr = rTNd.GetTxtAttrForCharAt( nPos ); + if (pAttr) { - sExp += pFld->Expand(); + bRet = TRUE; // all other than fields can be + // defined as weak-script ? + if ( RES_TXTATR_FIELD == pAttr->Which() ) + { + const SwField* const pFld = pAttr->GetFld().GetFld(); + if (pFld) + { + sExp += pFld->Expand(); + } + } } } diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx index 384aa414895a..b2a090be6fdc 100644 --- a/sw/source/core/edit/eddel.cxx +++ b/sw/source/core/edit/eddel.cxx @@ -249,7 +249,8 @@ long SwEditShell::Copy( SwEditShell* pDestShell ) bFirstMove = FALSE; } - if( !GetDoc()->Copy( *PCURCRSR, *pPos, false )) + const bool bSuccess( GetDoc()->CopyRange( *PCURCRSR, *pPos, false ) ); + if (!bSuccess) continue; SwPaM aInsertPaM(*pPos, SwPosition(aSttNdIdx)); @@ -319,7 +320,8 @@ BOOL SwEditShell::Replace( const String& rNewStr, BOOL bRegExpRplc ) FOREACHPAM_START(this) if( PCURCRSR->HasMark() && *PCURCRSR->GetMark() != *PCURCRSR->GetPoint() ) { - bRet = GetDoc()->Replace( *PCURCRSR, rNewStr, bRegExpRplc ) || bRet; + bRet = GetDoc()->ReplaceRange( *PCURCRSR, rNewStr, bRegExpRplc ) + || bRet; SaveTblBoxCntnt( PCURCRSR->GetPoint() ); } FOREACHPAM_END() diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx index 128da7d38f59..c112f257d77a 100644 --- a/sw/source/core/edit/edfld.cxx +++ b/sw/source/core/edit/edfld.cxx @@ -232,8 +232,8 @@ void SwEditShell::FieldToText( SwFieldType* pType ) String aEntry( pFmtFld->GetFld()->Expand() ); pPaM->SetMark(); pPaM->Move( fnMoveForward ); - GetDoc()->Delete( *pPaM ); - GetDoc()->Insert( *pPaM, aEntry, true ); + GetDoc()->DeleteRange( *pPaM ); + GetDoc()->InsertString( *pPaM, aEntry ); } else if( bDDEFld ) { @@ -258,17 +258,20 @@ void SwEditShell::FieldToText( SwFieldType* pType ) |* Quelle: vgl. SwEditShell::Insert( String ) |* *************************************************************************/ -void SwEditShell::Insert(SwField& rFld) +void SwEditShell::Insert2(SwField& rFld, const bool bForceExpandHints) { SET_CURR_SHELL( this ); StartAllAction(); SwFmtFld aFld( rFld ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND + : nsSetAttrMode::SETATTR_DEFAULT; + FOREACHPAM_START(this) // fuer jeden PaM - if( !GetDoc()->Insert( *PCURCRSR, aFld, 0 ) ) - { - ASSERT( FALSE, "Doc->Insert(Field) failed") - } + bool bSuccess(GetDoc()->InsertPoolItem(*PCURCRSR, aFld, nInsertFlags)); + ASSERT( bSuccess, "Doc->Insert(Field) failed"); + (void) bSuccess; FOREACHPAM_END() // fuer jeden PaM EndAllAction(); @@ -285,11 +288,11 @@ void SwEditShell::Insert(SwField& rFld) inline SwTxtFld *GetDocTxtFld( const SwPosition* pPos ) { - SwTxtNode *pNode = pPos->nNode.GetNode().GetTxtNode(); - if( pNode ) - return pNode->GetTxtFld( pPos->nContent ); - else - return 0; + SwTxtNode * const pNode = pPos->nNode.GetNode().GetTxtNode(); + return (pNode) + ? static_cast<SwTxtFld*>( pNode->GetTxtAttrForCharAt( + pPos->nContent.GetIndex(), RES_TXTATR_FIELD )) + : 0; } SwField* SwEditShell::GetCurFld() const diff --git a/sw/source/core/edit/edglbldc.cxx b/sw/source/core/edit/edglbldc.cxx index 9ff65d7efbc0..84c43f4d830a 100644 --- a/sw/source/core/edit/edglbldc.cxx +++ b/sw/source/core/edit/edglbldc.cxx @@ -343,8 +343,10 @@ BOOL SwEditShell::MoveGlobalDocContent( const SwGlblDocContents& rArr , else aInsPos = pMyDoc->GetNodes().GetEndOfContent(); - BOOL bRet = pMyDoc->Move( aRg, aInsPos, - IDocumentContentOperations::SwMoveFlags(IDocumentContentOperations::DOC_MOVEALLFLYS|IDocumentContentOperations::DOC_CREATEUNDOOBJ )); + bool bRet = pMyDoc->MoveNodeRange( aRg, aInsPos, + static_cast<IDocumentContentOperations::SwMoveFlags>( + IDocumentContentOperations::DOC_MOVEALLFLYS + | IDocumentContentOperations::DOC_CREATEUNDOOBJ )); EndAllAction(); return bRet; diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index b408a1c33c81..64ed3068d79c 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -168,7 +168,7 @@ USHORT SwEditShell::SaveGlossaryDoc( SwTextBlocks& rBlock, aStt = pGDoc->GetNodes().GetEndOfExtras(); pCntntNd = pGDoc->GetNodes().GoNext( &aStt ); SwPosition aInsPos( aStt, SwIndex( pCntntNd )); - pMyDoc->Copy( aCpyPam, aInsPos, false ); + pMyDoc->CopyRange( aCpyPam, aInsPos, false ); nRet = rBlock.PutDoc(); } @@ -250,13 +250,16 @@ BOOL SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd ) { PCURCRSR->SetMark(); PCURCRSR->Move( fnMoveForward, fnGoCntnt ); - bRet = GetDoc()->Copy( *PCURCRSR, aPos, false ) || bRet; + bRet = GetDoc()->CopyRange( *PCURCRSR, aPos, false ) + || bRet; PCURCRSR->Exchange(); PCURCRSR->DeleteMark(); } } else - bRet = GetDoc()->Copy( *PCURCRSR, aPos, false ) || bRet; + { + bRet = GetDoc()->CopyRange( *PCURCRSR, aPos, false ) || bRet; + } FOREACHPAM_END() } diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 4553038f3abb..4d7cbc07e4ad 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -86,10 +86,9 @@ void SwEditShell::Insert( sal_Unicode c, BOOL bOnlyCurrCrsr ) StartAllAction(); FOREACHPAM_START(this) - if( !GetDoc()->Insert(*PCURCRSR, c) ) - { - ASSERT( FALSE, "Doc->Insert(c) failed." ) - } + const bool bSuccess = GetDoc()->InsertString(*PCURCRSR, c); + ASSERT( bSuccess, "Doc->Insert() failed." ); + (void) bSuccess; SaveTblBoxCntnt( PCURCRSR->GetPoint() ); if( bOnlyCurrCrsr ) @@ -106,17 +105,24 @@ void SwEditShell::Insert( sal_Unicode c, BOOL bOnlyCurrCrsr ) ******************************************************************************/ -void SwEditShell::Insert(const String &rStr) +void SwEditShell::Insert2(const String &rStr, const bool bForceExpandHints ) { StartAllAction(); { + const enum IDocumentContentOperations::InsertFlags nInsertFlags = + (bForceExpandHints) + ? static_cast<IDocumentContentOperations::InsertFlags>( + IDocumentContentOperations::INS_FORCEHINTEXPAND | + IDocumentContentOperations::INS_EMPTYEXPAND) + : IDocumentContentOperations::INS_EMPTYEXPAND; + SwPaM *_pStartCrsr = getShellCrsr( true ), *__pStartCrsr = _pStartCrsr; do { //OPT: GetSystemCharSet - if( !GetDoc()->Insert( *_pStartCrsr, rStr, true ) ) - { - ASSERT( FALSE, "Doc->Insert(Str) failed." ) - } + const bool bSuccess = + GetDoc()->InsertString(*_pStartCrsr, rStr, nInsertFlags); + ASSERT( bSuccess, "Doc->Insert() failed." ); + (void) bSuccess; SaveTblBoxCntnt( _pStartCrsr->GetPoint() ); @@ -778,7 +784,7 @@ BOOL SwEditShell::InsertURL( const SwFmtINetFmt& rFmt, const String& rStr, BOOL if( bInsTxt ) { - Insert( rStr ); + Insert2( rStr ); SetMark(); ExtendSelection( FALSE, rStr.Len() ); } diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx index f444f293f6c5..5a455bb295f7 100644 --- a/sw/source/core/edit/edlingu.cxx +++ b/sw/source/core/edit/edlingu.cxx @@ -49,7 +49,6 @@ #include <svx/langitem.hxx> #include <svx/SpellPortions.hxx> #include <svx/scripttypeitem.hxx> -#include <fmthbsh.hxx> #include <charatr.hxx> #include <editsh.hxx> #include <doc.hxx> @@ -70,6 +69,8 @@ #include <redline.hxx> // SwRedline #include <docary.hxx> // SwRedlineTbl #include <docsh.hxx> +#include <txatbase.hxx> + using namespace ::svx; using namespace ::com::sun::star; @@ -682,7 +683,7 @@ void SwHyphIter::InsertSoftHyph( const xub_StrLen nHyphPos ) DelSoftHyph( *pCrsr ); pSttPos->nContent += nHyphPos; SwPaM aRg( *pSttPos ); - pDoc->Insert( aRg, CHAR_SOFTHYPHEN ); + pDoc->InsertString( aRg, CHAR_SOFTHYPHEN ); // Durch das Einfuegen des SoftHyphs ist ein Zeichen hinzugekommen //JP 18.07.95: warum, ist doch ein SwIndex, dieser wird doch mitverschoben !! // pSttPos->nContent++; @@ -1342,7 +1343,7 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, // ... and apply language if necessary if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage) SetAttr( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId), nLangWhichId ); - pDoc->Insert(*pCrsr, aCurrentNewPortion->sText, true); + pDoc->InsertString(*pCrsr, aCurrentNewPortion->sText); } else if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage) { @@ -1388,7 +1389,7 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, if(rLang.GetLanguage() != aCurrentNewPortion->eLanguage) SetAttr( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId) ); //insert the new string - pDoc->Insert(*pCrsr, aCurrentNewPortion->sText, true); + pDoc->InsertString(*pCrsr, aCurrentNewPortion->sText); //set the cursor to the end of the inserted string *pCrsr->Start() = *pCrsr->End(); @@ -1819,20 +1820,18 @@ void SwSpellIter::AddPortion(uno::Reference< XSpellAlternatives > xAlt, xub_Unicode cChar = pTxtNode->GetTxt().GetChar( pCrsr->GetMark()->nContent.GetIndex() ); if( CH_TXTATR_BREAKWORD == cChar || CH_TXTATR_INWORD == cChar) { - const SwTxtAttr* pTxtAttr = pTxtNode->GetTxtAttr( - pCrsr->GetMark()->nContent.GetIndex(), RES_TXTATR_FIELD ); - bField = 0 != pTxtAttr; - if(!bField) - { - const SwTxtAttr* pTmpTxtAttr = pTxtNode->GetTxtAttr( - pCrsr->GetMark()->nContent.GetIndex(), RES_TXTATR_FTN ); - bField = 0 != pTmpTxtAttr; - } - if(!bField) + const SwTxtAttr* pTxtAttr = pTxtNode->GetTxtAttrForCharAt( + pCrsr->GetMark()->nContent.GetIndex() ); + const USHORT nWhich = pTxtAttr + ? pTxtAttr->Which() + : static_cast<USHORT>(RES_TXTATR_END); + switch (nWhich) { - const SwTxtAttr* pTmpTxtAttr = pTxtNode->GetTxtAttr( - pCrsr->GetMark()->nContent.GetIndex(), RES_TXTATR_FLYCNT ); - bField = 0 != pTmpTxtAttr; + case RES_TXTATR_FIELD: + case RES_TXTATR_FTN: + case RES_TXTATR_FLYCNT: + bField = true; + break; } } diff --git a/sw/source/core/edit/edsect.cxx b/sw/source/core/edit/edsect.cxx index bf6565d352fd..e630c3ff5f0a 100644 --- a/sw/source/core/edit/edsect.cxx +++ b/sw/source/core/edit/edsect.cxx @@ -56,8 +56,8 @@ const SwSection* SwEditShell::InsertSection( const SwSection& rNew, GetDoc()->StartUndo( UNDO_INSSECTION, NULL ); FOREACHPAM_START(this) - const SwSection* pNew = GetDoc()->Insert( *PCURCRSR, - rNew, pAttr ); + const SwSection* const pNew = + GetDoc()->InsertSwSection( *PCURCRSR, rNew, pAttr ); if( !pRet ) pRet = pNew; FOREACHPAM_END() diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx index 01c9b6f6cb76..0888693eaedc 100644 --- a/sw/source/core/edit/edtox.cxx +++ b/sw/source/core/edit/edtox.cxx @@ -82,10 +82,13 @@ void SwEditShell::Insert(const SwTOXMark& rMark) if( bInsAtPos ) { SwPaM aTmp( *pStt ); - GetDoc()->Insert( aTmp, rMark, 0 ); + GetDoc()->InsertPoolItem( aTmp, rMark, 0 ); } else if( *pEnd != *pStt ) - GetDoc()->Insert( *PCURCRSR, rMark, nsSetAttrMode::SETATTR_DONTEXPAND ); + { + GetDoc()->InsertPoolItem( *PCURCRSR, rMark, + nsSetAttrMode::SETATTR_DONTEXPAND ); + } FOREACHPAM_END() EndAllAction(); @@ -98,7 +101,7 @@ void SwEditShell::DeleteTOXMark( SwTOXMark* pMark ) SET_CURR_SHELL( this ); StartAllAction(); - pDoc->Delete( pMark ); + pDoc->DeleteTOXMark( pMark ); EndAllAction(); } diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx index 029759a6c056..6a6ffb9d3fbd 100644 --- a/sw/source/core/fields/cellfml.cxx +++ b/sw/source/core/fields/cellfml.cxx @@ -159,13 +159,13 @@ double SwTableBox::GetValue( SwTblCalcPara& rCalcPara ) const // beginnt an erster Position ein "RechenFeld", dann erfrage den Wert // von diesem - sal_Unicode cChr; - if( nSttPos < rTxt.Len() && - ( CH_TXTATR_BREAKWORD == ( cChr = rTxt.GetChar(nSttPos)) || - CH_TXTATR_INWORD == cChr )) + sal_Unicode const Char = rTxt.GetChar(nSttPos); + if ( nSttPos < rTxt.Len() && + ( CH_TXTATR_BREAKWORD == Char || CH_TXTATR_INWORD == Char ) ) { SwIndex aIdx( pTxtNd, nSttPos ); - SwTxtFld* pTxtFld = pTxtNd->GetTxtFld( aIdx ); + SwTxtFld * const pTxtFld = static_cast<SwTxtFld*>( + pTxtNd->GetTxtAttrForCharAt(aIdx.GetIndex(), RES_TXTATR_FIELD)); if( !pTxtFld ) break; diff --git a/sw/source/core/fields/ddetbl.cxx b/sw/source/core/fields/ddetbl.cxx index 141ef1b080de..8fd7124a6c91 100644 --- a/sw/source/core/fields/ddetbl.cxx +++ b/sw/source/core/fields/ddetbl.cxx @@ -131,8 +131,8 @@ void SwDDETable::ChangeContent() SwTxtNode* pTxtNode = aNdIdx.GetNode().GetTxtNode(); ASSERT( pTxtNode, "Kein Node" ); SwIndex aCntIdx( pTxtNode, 0 ); - pTxtNode->Erase( aCntIdx ); - pTxtNode->Insert( aLine.GetToken( i, '\t' ), aCntIdx ); + pTxtNode->EraseText( aCntIdx ); + pTxtNode->InsertText( aLine.GetToken( i, '\t' ), aCntIdx ); SwTableBoxFmt* pBoxFmt = (SwTableBoxFmt*)pBox->GetFrmFmt(); pBoxFmt->LockModify(); diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index e9e8644c5eb3..372cf878f842 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -331,8 +331,8 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) case REF_ONLYCAPTION: { - const SwTxtAttr* pTxtAttr = pTxtNd->GetTxtAttr( nStt, - RES_TXTATR_FIELD ); + const SwTxtAttr* const pTxtAttr = + pTxtNd->GetTxtAttrForCharAt(nStt, RES_TXTATR_FIELD); if( pTxtAttr ) nStt = SwGetExpField::GetReferenceTextPos( pTxtAttr->GetFld(), *pDoc ); diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index 07c8a0911080..ccd2d86e4531 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -34,13 +34,7 @@ #include <hintids.hxx> -#ifdef WIN -#define NEEDED_BY_FESHVIEW -#endif - -#ifndef _GRAPH_HXX #include <vcl/graph.hxx> -#endif #include <sot/formats.hxx> #include <sot/storage.hxx> #include <svtools/pathoptions.hxx> @@ -58,9 +52,7 @@ #include <svx/svdogrp.hxx> #include <svx/xoutbmp.hxx> #include <svx/svdoole2.hxx> -#ifndef _FM_FMMODEL_HXX #include <svx/fmmodel.hxx> -#endif #include <svx/unomodel.hxx> // --> OD 2005-08-03 #i50824# #include <svx/svditer.hxx> @@ -93,9 +85,7 @@ #include <dview.hxx> #include <dcontact.hxx> #include <dflyobj.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <pagedesc.hxx> #include <mvsave.hxx> #include <vcl/virdev.hxx> @@ -145,7 +135,7 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) // benutzen. if( pNewClpTxt ) { - pTxtNd->Insert( *pNewClpTxt, SwIndex( pTxtNd ) ); + pTxtNd->InsertText( *pNewClpTxt, SwIndex( pTxtNd ) ); return TRUE; // das wars. } @@ -198,7 +188,7 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) if( pTxtFly ) { ((SwFmtFlyCnt&)pTxtFly->GetFlyCnt()).SetFlyFmt( 0 ); - pTxtNd->Erase( rIdx, 1 ); + pTxtNd->EraseText( rIdx, 1 ); } } bRet = TRUE; @@ -840,7 +830,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) { SwNodeIndex aIndexBefore(rInsPos.nNode); aIndexBefore--; - pClpDoc->Copy( rCopy, rInsPos, false ); + pClpDoc->CopyRange( rCopy, rInsPos, false ); { aIndexBefore++; SwPaM aPaM(SwPosition(aIndexBefore, 0), @@ -1069,7 +1059,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) aIndexBefore--; - pClpDoc->Copy( aCpyPam, rInsPos, false ); + pClpDoc->CopyRange( aCpyPam, rInsPos, false ); { aIndexBefore++; diff --git a/sw/source/core/frmedt/fedesc.cxx b/sw/source/core/frmedt/fedesc.cxx index d7ee250cf216..e8e91ae37621 100644 --- a/sw/source/core/frmedt/fedesc.cxx +++ b/sw/source/core/frmedt/fedesc.cxx @@ -127,7 +127,7 @@ void SwFEShell::ChgCurPageDesc( const SwPageDesc& rDesc ) else { SwPaM aPaM( *((SwCntntFrm*)pFlow)->GetNode() ); - GetDoc()->Insert( aPaM, aNew, 0 ); + GetDoc()->InsertPoolItem( aPaM, aNew, 0 ); } EndAllActionAndCall(); } diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index 6d7059b3cf0e..d465abc4403e 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -34,7 +34,6 @@ #include "hintids.hxx" #ifdef WIN -#define NEEDED_BY_FESHVIEW #define _FESHVIEW_ONLY_INLINE_NEEDED #endif @@ -1874,7 +1873,8 @@ BOOL SwFEShell::ImpEndCreate() { ASSERT( aAnch.GetAnchorId() == FLY_IN_CNTNT, "wrong AnchorType" ); SwTxtNode *pNd = aAnch.GetCntntAnchor()->nNode.GetNode().GetTxtNode(); - pNd->InsertItem( SwFmtFlyCnt( pFmt ), + SwFmtFlyCnt aFmt( pFmt ); + pNd->InsertItem(aFmt, aAnch.GetCntntAnchor()->nContent.GetIndex(), 0 ); SwFmtVertOrient aVertical( pFmt->GetVertOrient() ); aVertical.SetVertOrient( text::VertOrientation::LINE_CENTER ); diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx index 13e6a5e732b3..d82b1de4cfdb 100644 --- a/sw/source/core/frmedt/fews.cxx +++ b/sw/source/core/frmedt/fews.cxx @@ -411,7 +411,9 @@ void lcl_SetAPageOffset( USHORT nOffset, SwPageFrm* pPage, SwFEShell* pThis ) if ( pFrm->IsInTab() ) pThis->GetDoc()->SetAttr( aDesc, *pFrm->FindTabFrm()->GetFmt() ); else - pThis->GetDoc()->Insert( *pThis->GetCrsr(), aDesc, 0 ); + { + pThis->GetDoc()->InsertPoolItem( *pThis->GetCrsr(), aDesc, 0 ); + } pThis->EndAllAction(); } diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index ba550304e04a..f971be8d79e4 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -1462,7 +1462,10 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, if( pUndo ) pUndo->MoveBoxCntnt( pDoc, aRg, rInsPosNd ); else - pDoc->Move( aRg, rInsPosNd, IDocumentContentOperations::DOC_MOVEDEFAULT ); + { + pDoc->MoveNodeRange( aRg, rInsPosNd, + IDocumentContentOperations::DOC_MOVEDEFAULT ); + } // wo steht jetzt aInsPos ?? if( bCalcWidth ) diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx index e1344138babf..18f8860ecab9 100644 --- a/sw/source/core/inc/bookmrk.hxx +++ b/sw/source/core/inc/bookmrk.hxx @@ -32,6 +32,8 @@ #define _BOOKMRK_HXX #include <IMark.hxx> +#include <sfx2/Metadatable.hxx> + #include <boost/scoped_ptr.hpp> #include <boost/noncopyable.hpp> @@ -144,6 +146,7 @@ namespace sw { namespace mark class Bookmark : virtual public IBookmark , public DdeBookmark + , public ::sfx2::Metadatable { public: Bookmark(const SwPaM& rPaM, @@ -160,6 +163,15 @@ namespace sw { namespace mark { m_sShortName = rShortName; } virtual void SetKeyCode(const KeyCode& rCode) { m_aCode = rCode; } + + // ::sfx2::Metadatable + virtual ::sfx2::IXmlIdRegistry& GetRegistry(); + virtual bool IsInClipboard() const; + virtual bool IsInUndo() const; + virtual bool IsInContent() const; + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable > MakeUnoObject(); + private: KeyCode m_aCode; ::rtl::OUString m_sShortName; diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx index b8704dac0166..6cbdd743761d 100644 --- a/sw/source/core/inc/mvsave.hxx +++ b/sw/source/core/inc/mvsave.hxx @@ -39,6 +39,10 @@ #include <IDocumentMarkAccess.hxx> #include <vector> +namespace sfx2 { + class MetadatableUndo; +} + class SvNumberFormatter; class SvULongs; class SwDoc; @@ -80,6 +84,7 @@ namespace sw { namespace mark ULONG m_nNode2; xub_StrLen m_nCntnt1; xub_StrLen m_nCntnt2; + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo; }; }} diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx index c36d5d9d4192..7cb8c80b305d 100644 --- a/sw/source/core/inc/swfont.hxx +++ b/sw/source/core/inc/swfont.hxx @@ -141,6 +141,7 @@ class SwFont Color aOverColor; // color of the overlining BYTE nToxCnt; // Zaehlt die Schachtelungstiefe der Tox BYTE nRefCnt; // Zaehlt die Schachtelungstiefe der Refs + BYTE m_nMetaCount; // count META/METAFIELD BYTE nActual; // actual font (Latin, CJK or CTL) // Schalter fuer die Font-Extensions @@ -245,6 +246,9 @@ public: inline BYTE &GetRef() { return nRefCnt; } inline BYTE GetRef() const { return nRefCnt; } inline BOOL IsRef() const { return ( 0 != nRefCnt ); } + inline BYTE &GetMeta() { return m_nMetaCount; } + inline BYTE GetMeta() const { return m_nMetaCount; } + inline bool IsMeta() const { return (0 != m_nMetaCount); } inline void SetURL( const BOOL bURL ); inline BOOL IsURL() const { return bURL; } inline void SetGreyWave( const BOOL bNew ); diff --git a/sw/source/core/inc/txttypes.hxx b/sw/source/core/inc/txttypes.hxx index 7ab8779c6696..d8818100c956 100644 --- a/sw/source/core/inc/txttypes.hxx +++ b/sw/source/core/inc/txttypes.hxx @@ -64,6 +64,7 @@ #define POR_ISOTOX 0x808a #define POR_REF 0x808b #define POR_ISOREF 0x808c +#define POR_META 0x808d #define POR_EXP 0xc080 #define POR_BLANK 0xc081 diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx index 70738152e1bd..56995fcfcb26 100644 --- a/sw/source/core/layout/laycache.cxx +++ b/sw/source/core/layout/laycache.cxx @@ -727,7 +727,8 @@ void lcl_ApplyWorkaroundForB6375613( SwFrm* p_pFirstFrmOnNewPage ) SwDoc* pDoc( pFirstTextFrmOnNewPage->GetTxtNode()->GetDoc() ); IDocumentContentOperations* pIDCO = pFirstTextFrmOnNewPage->GetTxtNode()->getIDocumentContentOperations(); const SwPaM aTmpPaM( *(pFirstTextFrmOnNewPage->GetTxtNode()) ); - pIDCO->Insert( aTmpPaM, SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0 ); + pIDCO->InsertPoolItem( aTmpPaM, + SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0 ); pFirstTextFrmOnNewPage->GetTxtNode()->UnlockModify(); uno::Reference< document::XDocumentInfoSupplier > xDoc( diff --git a/sw/source/core/swg/SwXMLTextBlocks.cxx b/sw/source/core/swg/SwXMLTextBlocks.cxx index 6a9c6585e296..1c8a224a7143 100644 --- a/sw/source/core/swg/SwXMLTextBlocks.cxx +++ b/sw/source/core/swg/SwXMLTextBlocks.cxx @@ -641,6 +641,6 @@ void SwXMLTextBlocks::MakeBlockText( const String& rText ) } SwIndex aIdx( pTxtNode ); String sTemp(rText.GetToken( 0, '\015', nPos ) ); - pTxtNode->Insert( sTemp, aIdx ); + pTxtNode->InsertText( sTemp, aIdx ); } while ( STRING_NOTFOUND != nPos ); } diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx index e1c10ab74a09..62634d31d744 100644 --- a/sw/source/core/table/swnewtable.cxx +++ b/sw/source/core/table/swnewtable.cxx @@ -909,7 +909,10 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, if( pUndo ) pUndo->MoveBoxCntnt( pDoc, aRg, rInsPosNd ); else - pDoc->Move( aRg, rInsPosNd, IDocumentContentOperations::DOC_NO_DELFRMS ); + { + pDoc->MoveNodeRange( aRg, rInsPosNd, + IDocumentContentOperations::DOC_NO_DELFRMS ); + } } } // Only the cell of the first selected column will stay alive diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 715fa0eed2a6..070e8eb625f9 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2177,8 +2177,10 @@ void ChgTextToNum( SwTableBox& rBox, const String& rTxt, const Color* pCol, pDoc->DeleteRedline(aTemp, true, USHRT_MAX); } - pTNd->Erase( aIdx, n, INS_EMPTYEXPAND ); - pTNd->Insert( rTxt, aIdx, INS_EMPTYEXPAND ); + pTNd->EraseText( aIdx, n, + IDocumentContentOperations::INS_EMPTYEXPAND ); + pTNd->InsertText( rTxt, aIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); if( pDoc->IsRedlineOn() ) { @@ -2222,8 +2224,10 @@ void ChgNumToText( SwTableBox& rBox, ULONG nFmt ) // zuruecksetzen, damit sie wieder aufgespannt werden pTNd->DontExpandFmt( aIdx, FALSE, FALSE ); aIdx = 0; - pTNd->Erase( aIdx, STRING_LEN, INS_EMPTYEXPAND ); - pTNd->Insert( sTmp, aIdx, INS_EMPTYEXPAND ); + pTNd->EraseText( aIdx, STRING_LEN, + IDocumentContentOperations::INS_EMPTYEXPAND ); + pTNd->InsertText( sTmp, aIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); } } diff --git a/sw/source/core/text/atrhndl.hxx b/sw/source/core/text/atrhndl.hxx index 42e2a4a80463..3e24ba0a49e1 100644 --- a/sw/source/core/text/atrhndl.hxx +++ b/sw/source/core/text/atrhndl.hxx @@ -32,7 +32,7 @@ #define _ATRHNDL_HXX #define INITIAL_NUM_ATTR 3 -#define NUM_ATTRIBUTE_STACKS 39 +#define NUM_ATTRIBUTE_STACKS 40 #include <txatbase.hxx> #include <swfntcch.hxx> diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx index bd9a0b1418d3..f8d617061d3e 100644 --- a/sw/source/core/text/atrstck.cxx +++ b/sw/source/core/text/atrstck.cxx @@ -136,8 +136,8 @@ const BYTE StackPos[ static_cast<USHORT>(RES_TXTATR_WITHEND_END) - 0, // RES_TXTATR_DUMMY5 // 46 38, // RES_TXTATR_CJK_RUBY, // 47 0, // RES_TXTATR_UNKNOWN_CONTAINER, // 48 - 0, // RES_TXTATR_DUMMY6, // 49 - 0 // RES_TXTATR_DUMMY7, // 50 + 39, // RES_TXTATR_META, // 49 + 39 // RES_TXTATR_METAFIELD, // 50 }; /************************************************************************* @@ -650,6 +650,10 @@ void SwAttrHandler::ActivateTop( SwFont& rFnt, const USHORT nAttr ) rFnt.GetRef()--; else if ( RES_TXTATR_TOXMARK == nAttr ) rFnt.GetTox()--; + else if ( (RES_TXTATR_META == nAttr) || (RES_TXTATR_METAFIELD == nAttr) ) + { + rFnt.GetMeta()--; + } else if ( RES_TXTATR_CJK_RUBY == nAttr ) { // ruby stack has no more attributes @@ -928,6 +932,13 @@ void SwAttrHandler::FontChg(const SfxPoolItem& rItem, SwFont& rFnt, sal_Bool bPu else rFnt.GetTox()--; break; + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + if ( bPush ) + rFnt.GetMeta()++; + else + rFnt.GetMeta()--; + break; } } diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 46e74abe1da3..fea63bf2dca0 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -1277,7 +1277,8 @@ void SwTxtPaintInfo::DrawViewOpt( const SwLinePortion &rPor, case POR_URL: case POR_HIDDEN: case POR_TOX: - case POR_REF : + case POR_REF: + case POR_META: case POR_CONTROLCHAR: if ( !GetOpt().IsPagePreview() && !GetOpt().IsReadonly() && diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index bf5e1b041d4e..bd51317f77fe 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -45,7 +45,6 @@ #include <fmtflcnt.hxx> #include <fmtcntnt.hxx> #include <fmtftn.hxx> -#include <fmthbsh.hxx> #include <frmatr.hxx> #include <frmfmt.hxx> #include <fmtfld.hxx> @@ -126,19 +125,7 @@ SwAttrIter::~SwAttrIter() SwTxtAttr *SwAttrIter::GetAttr( const xub_StrLen nPosition ) const { - if ( pHints ) - { - for ( USHORT i = 0; i < pHints->Count(); ++i ) - { - SwTxtAttr *pPos = pHints->GetTextHint(i); - xub_StrLen nStart = *pPos->GetStart(); - if( nPosition < nStart ) - return 0; - if( nPosition == nStart && !pPos->GetEnd() ) - return pPos; - } - } - return 0; + return (m_pTxtNode) ? m_pTxtNode->GetTxtAttrForCharAt(nPosition) : 0; } /************************************************************************* diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 2f01085b89f9..cb54872d19e2 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -107,6 +107,7 @@ void SwTxtFormatter::CtorInitTxtFormatter( SwTxtFrm *pNewFrm, SwTxtFormatInfo *p nCntMidHyph = 0; nLeftScanIdx = STRING_LEN; nRightScanIdx = 0; + m_nHintEndIndex = 0; if( nStart > GetInfo().GetTxt().Len() ) { @@ -313,7 +314,14 @@ SwLinePortion *SwTxtFormatter::UnderFlow( SwTxtFormatInfo &rInf ) } } pPor->Truncate(); - delete rInf.GetRest(); + SwLinePortion *const pRest( rInf.GetRest() ); + if (pRest && pRest->InFldGrp() && + static_cast<SwFldPortion*>(pRest)->IsNoLength()) + { + // HACK: decrement again, so we pick up the suffix in next line! + --m_nHintEndIndex; + } + delete pRest; rInf.SetRest(0); return pPor; } @@ -820,6 +828,34 @@ void SwTxtFormatter::CalcAscent( SwTxtFormatInfo &rInf, SwLinePortion *pPor ) } /************************************************************************* + * class SwMetaPortion + *************************************************************************/ + +class SwMetaPortion : public SwTxtPortion +{ +public: + inline SwMetaPortion() { SetWhichPor( POR_META ); } + virtual void Paint( const SwTxtPaintInfo &rInf ) const; +// OUTPUT_OPERATOR +}; + +//CLASSIO( SwMetaPortion ) + +/************************************************************************* + * virtual SwMetaPortion::Paint() + *************************************************************************/ + +void SwMetaPortion::Paint( const SwTxtPaintInfo &rInf ) const +{ + if ( Width() ) + { + rInf.DrawViewOpt( *this, POR_META ); + SwTxtPortion::Paint( rInf ); + } +} + + +/************************************************************************* * SwTxtFormatter::WhichTxtPor() *************************************************************************/ @@ -832,6 +868,10 @@ SwTxtPortion *SwTxtFormatter::WhichTxtPor( SwTxtFormatInfo &rInf ) const { if( GetFnt()->IsRef() ) pPor = new SwRefPortion; + else if (GetFnt()->IsMeta()) + { + pPor = new SwMetaPortion; + } else { // Erst zum Schluss ! @@ -1068,6 +1108,12 @@ SwLinePortion *SwTxtFormatter::WhichFirstPortion(SwTxtFormatInfo &rInf) pPor = NewTabPortion( rInf, true ); } + // 11) suffix of meta-field + if (!pPor) + { + pPor = TryNewNoLengthPortion(rInf); + } + return pPor; } diff --git a/sw/source/core/text/itrform2.hxx b/sw/source/core/text/itrform2.hxx index f1bb7e05c099..7eaaeb396d3d 100644 --- a/sw/source/core/text/itrform2.hxx +++ b/sw/source/core/text/itrform2.hxx @@ -60,6 +60,7 @@ class SwTxtFormatter : public SwTxtPainter sal_Bool bChanges : 1; // Flag, fuer die Berechnung des Repaint-Rechtecks sal_Bool bTruncLines : 1; // Flag, Repaint-Rechtecks ggf. erweitern sal_Bool bUnclipped : 1; // Flag, ob Repaint groesser als feste Zeilenhoehe + USHORT m_nHintEndIndex; // HACK for TryNewNoLengthPortion SwLinePortion *NewPortion( SwTxtFormatInfo &rInf ); SwTxtPortion *NewTxtPortion( SwTxtFormatInfo &rInf ); SwLinePortion *NewExtraPortion( SwTxtFormatInfo &rInf ); @@ -75,6 +76,7 @@ class SwTxtFormatter : public SwTxtPainter SwTxtAttr *pHt ) const; SwLinePortion *WhichFirstPortion( SwTxtFormatInfo &rInf ); SwTxtPortion *WhichTxtPor( SwTxtFormatInfo &rInf ) const; + SwExpandPortion * TryNewNoLengthPortion( SwTxtFormatInfo & rInfo ); // Das Herzstueck der Formatierung void BuildPortions( SwTxtFormatInfo &rInf ); diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx index 965de6545fe2..7cfb941545a8 100644 --- a/sw/source/core/text/itrpaint.cxx +++ b/sw/source/core/text/itrpaint.cxx @@ -48,7 +48,6 @@ #include <fmtftn.hxx> #include <fmtfld.hxx> #include <fldbas.hxx> // SwField -#include <fmthbsh.hxx> #include <rootfrm.hxx> #include <pagefrm.hxx> #include <pagedesc.hxx> // SwPageDesc diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index b9fdc5cfc2f7..932eb1c72b6f 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -85,6 +85,7 @@ SwFldPortion *SwFldPortion::Clone( const XubString &rExpand ) const pNewFnt = new SwFont( *pFnt ); SwFldPortion* pClone = new SwFldPortion( rExpand, pNewFnt ); pClone->SetNextOffset( nNextOffset ); + pClone->m_bNoLength = this->m_bNoLength; return pClone; } @@ -99,6 +100,7 @@ void SwFldPortion::TakeNextOffset( const SwFldPortion* pFld ) SwFldPortion::SwFldPortion( const XubString &rExpand, SwFont *pFont, sal_Bool bPlaceHold ) : aExpand(rExpand), pFnt(pFont), nNextOffset(0), nNextScriptChg(STRING_LEN), nViewWidth(0), bFollow( sal_False ), bHasFollow( sal_False ), bPlaceHolder( bPlaceHold ) + , m_bNoLength( sal_False ) { SetWhichPor( POR_FLD ); } @@ -114,6 +116,7 @@ SwFldPortion::SwFldPortion( const SwFldPortion& rFld ) bCenter( rFld.IsCenter() ), bHasFollow( rFld.HasFollow() ), bPlaceHolder( rFld.bPlaceHolder ) + , m_bNoLength( rFld.m_bNoLength ) { if ( rFld.HasFont() ) pFnt = new SwFont( *rFld.GetFont() ); @@ -378,7 +381,7 @@ sal_Bool SwFldPortion::Format( SwTxtFormatInfo &rInf ) // Das Zeichen wird in der ersten Portion gehalten. // Unbedingt nach Format! - SetLen( nFollow ); + SetLen( (m_bNoLength) ? 0 : nFollow ); if( nRest ) { diff --git a/sw/source/core/text/porfld.hxx b/sw/source/core/text/porfld.hxx index 1786691ff5bc..331ee8d401c7 100644 --- a/sw/source/core/text/porfld.hxx +++ b/sw/source/core/text/porfld.hxx @@ -61,8 +61,12 @@ protected: sal_Bool bNoPaint : 1; // wird von SwGrfNumPortion benutzt sal_Bool bReplace : 1; // wird von SwGrfNumPortion benutzt sal_Bool bPlaceHolder : 1; + sal_Bool m_bNoLength : 1; // HACK for meta suffix (no CH_TXTATR) inline void SetFont( SwFont *pNew ) { pFnt = pNew; } + inline bool IsNoLength() const { return m_bNoLength; } + inline void SetNoLength() { m_bNoLength = sal_True; } + public: SwFldPortion( const SwFldPortion& rFld ); SwFldPortion( const XubString &rExpand, SwFont *pFnt = 0, sal_Bool bPlaceHolder = sal_False ); diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index c70dc46f0183..76eba6b1e77b 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -1566,7 +1566,7 @@ void SwScriptInfo::DeleteHiddenRanges( SwTxtNode& rNode ) nHiddenStart = *(rFirst++); SwPaM aPam( rNode, nHiddenStart, rNode, nHiddenEnd ); - rNode.getIDocumentContentOperations()->Delete( aPam ); + rNode.getIDocumentContentOperations()->DeleteRange( aPam ); } } diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index 4ea048f28aad..2124b4156d75 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -34,9 +34,7 @@ #include <hintids.hxx> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif #include <svx/twolinesitem.hxx> #include <svx/charrotateitem.hxx> #include <vcl/outdev.hxx> @@ -194,13 +192,11 @@ SwRotatedPortion::SwRotatedPortion( const SwMultiCreator& rCreate, if( !pRot ) { const SwTxtAttr& rAttr = *rCreate.pAttr; - if( RES_CHRATR_ROTATE == rAttr.Which() ) - pRot = &rAttr.GetCharRotate(); - else + const SfxPoolItem *const pItem = + CharFmt::GetItem(rAttr, RES_CHRATR_ROTATE); + if ( pItem ) { - const SfxPoolItem* pItem = CharFmt::GetItem( rAttr, RES_CHRATR_ROTATE ); - if ( pItem ) - pRot = (SvxCharRotateItem*)pItem; + pRot = static_cast<const SvxCharRotateItem*>(pItem); } } if( pRot ) @@ -319,13 +315,11 @@ SwDoubleLinePortion::SwDoubleLinePortion( const SwMultiCreator& rCreate, const SwTxtAttr& rAttr = *rCreate.pAttr; pBracket->nStart = *rAttr.GetStart(); - if( RES_CHRATR_TWO_LINES == rAttr.Which() ) - pTwo = &rAttr.Get2Lines(); - else + const SfxPoolItem * const pItem = + CharFmt::GetItem( rAttr, RES_CHRATR_TWO_LINES ); + if ( pItem ) { - const SfxPoolItem* pItem = CharFmt::GetItem( rAttr, RES_CHRATR_TWO_LINES ); - if ( pItem ) - pTwo = (SvxTwoLinesItem*)pItem; + pTwo = static_cast<const SvxTwoLinesItem*>(pItem); } } if( pTwo ) diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx index 1f7824c446f4..3ecc266865ed 100644 --- a/sw/source/core/text/redlnitr.cxx +++ b/sw/source/core/text/redlnitr.cxx @@ -263,7 +263,8 @@ short SwRedlineItr::_Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld ) pSet->ClearItem(); else { - SwAttrPool& rPool = (SwAttrPool& )rDoc.GetAttrPool(); + SwAttrPool& rPool = + const_cast<SwDoc&>(rDoc).GetAttrPool(); pSet = new SfxItemSet(rPool, RES_CHRATR_BEGIN, RES_CHRATR_END-1); } @@ -279,7 +280,9 @@ short SwRedlineItr::_Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld ) if( ( nWhich < RES_CHRATR_END ) && ( SFX_ITEM_SET == pSet->GetItemState( nWhich, sal_True, &pItem ) ) ) { - SwTxtAttr* pAttr = ((SwTxtNode&)rNd).MakeRedlineTxtAttr( *pItem ); + SwTxtAttr* pAttr = MakeRedlineTxtAttr( + const_cast<SwDoc&>(rDoc), + *const_cast<SfxPoolItem*>(pItem) ); pAttr->SetPriorityAttr( sal_True ); aHints.C40_INSERT( SwTxtAttr, pAttr, aHints.Count()); rAttrHandler.PushAndChg( *pAttr, rFnt ); @@ -352,7 +355,7 @@ void SwRedlineItr::_Clear( SwFont* pFnt ) rAttrHandler.PopAndChg( *pPos, *pFnt ); else rAttrHandler.Pop( *pPos ); - delete pPos; + SwTxtAttr::Destroy(pPos, const_cast<SwDoc&>(rDoc).GetAttrPool() ); } if( pFnt ) pFnt->SetNoCol( sal_False ); diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx index ce269743f866..f77a252a1e72 100644 --- a/sw/source/core/text/txtdrop.cxx +++ b/sw/source/core/text/txtdrop.cxx @@ -152,19 +152,7 @@ SwDropPortion::~SwDropPortion() sal_Bool SwTxtSizeInfo::_HasHint( const SwTxtNode* pTxtNode, xub_StrLen nPos ) { - const SwpHints *pHints = pTxtNode->GetpSwpHints(); - if( !pHints ) - return sal_False; - for ( USHORT i = 0; i < pHints->Count(); ++i ) - { - const SwTxtAttr *pPos = (*pHints)[i]; - xub_StrLen nStart = *pPos->GetStart(); - if( nPos < nStart ) - return sal_False; - if( nPos == nStart && !pPos->GetEnd() ) - return sal_True; - } - return sal_False; + return 0 != pTxtNode->GetTxtAttrForCharAt(nPos); } /************************************************************************* diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index 0e50f7d269e4..cc549ae4ef00 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -63,6 +63,7 @@ #include "docufld.hxx" #include "pagedesc.hxx" // NewFldPortion, GetNum() #include <pormulti.hxx> // SwMultiPortion +#include "fmtmeta.hxx" // lcl_NewMetaPortion /************************************************************************* @@ -257,12 +258,65 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf, return pRet; } +/************************************************************************* + * SwTxtFormatter::TryNewNoLengthPortion() + *************************************************************************/ + +SwFldPortion * lcl_NewMetaPortion(SwTxtAttr & rHint, const bool bPrefix) +{ + ::sw::Meta *const pMeta( + static_cast<SwFmtMeta &>(rHint.GetAttr()).GetMeta() ); + ::rtl::OUString fix; + ::sw::MetaField *const pField( dynamic_cast< ::sw::MetaField * >(pMeta) ); + OSL_ENSURE(pField, "lcl_NewMetaPortion: no meta field?"); + if (pField) + { + pField->GetPrefixAndSuffix((bPrefix) ? &fix : 0, (bPrefix) ? 0 : &fix); + } + return new SwFldPortion( fix ); +} + +/** Try to create a new portion with zero length, for an end of a hint + (where there is no CH_TXTATR). Because there may be multiple hint ends at a + given index, m_nHintEndIndex is used to keep track of the already created + portions. But the portions created here may actually be deleted again, + due to UnderFlow. In that case, m_nHintEndIndex must be decremented, + so the portion will be created again on the next line. + */ +SwExpandPortion * +SwTxtFormatter::TryNewNoLengthPortion(SwTxtFormatInfo & rInfo) +{ + if (pHints) + { + const xub_StrLen nIdx(rInfo.GetIdx()); + while (m_nHintEndIndex < pHints->GetEndCount()) + { + SwTxtAttr & rHint( *pHints->GetEnd(m_nHintEndIndex) ); + xub_StrLen const nEnd( *rHint.GetAnyEnd() ); + if (nEnd > nIdx) + { + break; + } + ++m_nHintEndIndex; + if (nEnd == nIdx) + { + if (RES_TXTATR_METAFIELD == rHint.Which()) + { + SwFldPortion *const pPortion( + lcl_NewMetaPortion(rHint, false)); + pPortion->SetNoLength(); // no CH_TXTATR at hint end! + return pPortion; + } + } + } + } + return 0; +} /************************************************************************* * SwTxtFormatter::NewExtraPortion() *************************************************************************/ - SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf ) { SwTxtAttr *pHint = GetAttr( rInf.GetIdx() ); @@ -290,16 +344,6 @@ SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf ) pRet = NewFtnPortion( rInf, pHint ); break; } - case RES_TXTATR_SOFTHYPH : - { - pRet = new SwSoftHyphPortion; - break; - } - case RES_TXTATR_HARDBLANK : - { - pRet = new SwBlankPortion( ((SwTxtHardBlank*)pHint)->GetChar() ); - break; - } case RES_TXTATR_FIELD : { pRet = NewFldPortion( rInf, pHint ); @@ -315,6 +359,11 @@ SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf ) pRet = new SwIsoToxPortion; break; } + case RES_TXTATR_METAFIELD: + { + pRet = lcl_NewMetaPortion( *pHint, true ); + break; + } default: ; } if( !pRet ) diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index f447e380aff9..14944264d39e 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -500,26 +500,10 @@ bool lcl_HideObj( const SwTxtFrm& _rFrm, _rFrm.GetTxtNode()->GetTxt().GetChar( _nObjAnchorPos ); if ( cAnchorChar == CH_TXTATR_BREAKWORD ) { - SwpHints* pHints = - const_cast<SwTxtFrm&>(_rFrm).GetTxtNode()->GetpSwpHints(); - const SwTxtAttr* pHint( 0 ); - if( pHints ) - { - for ( USHORT i = 0; i < pHints->Count(); ++i ) - { - SwTxtAttr* pPos = pHints->GetTextHint(i); - xub_StrLen nStart = *pPos->GetStart(); - if ( _nObjAnchorPos < nStart ) - break; - if ( _nObjAnchorPos == nStart && !pPos->GetEnd() ) - { - pHint = pPos; - break; - } - } - } - if ( pHint && - pHint->Which() == RES_TXTATR_FLYCNT ) + const SwTxtAttr* const pHint( + _rFrm.GetTxtNode()->GetTxtAttrForCharAt(_nObjAnchorPos, + RES_TXTATR_FLYCNT) ); + if ( pHint ) { const SwFrmFmt* pFrmFmt = static_cast<const SwTxtFlyCnt*>(pHint)->GetFlyCnt().GetFrmFmt(); diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx index 0a06f88bc371..b51ffb862f3c 100644 --- a/sw/source/core/tox/txmsrt.cxx +++ b/sw/source/core/tox/txmsrt.cxx @@ -223,7 +223,7 @@ void SwTOXSortTabBase::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, GetTxt( sMyTxt, sMyTxtReading ); - rNd.Insert( sMyTxt, rInsPos ); + rNd.InsertText( sMyTxt, rInsPos ); } BOOL SwTOXSortTabBase::operator==( const SwTOXSortTabBase& rCmp ) @@ -459,7 +459,7 @@ void SwTOXIndex::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, USHORT ) cons else GetTxt( sTmp, sTmpReading ); - rNd.Insert( sTmp, rInsPos ); + rNd.InsertText( sTmp, rInsPos ); } @@ -582,7 +582,7 @@ void SwTOXContent::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, USHORT ) co { String sTmp, sTmpReading; GetTxt( sTmp, sTmpReading ); - rNd.Insert( sTmp, rInsPos ); + rNd.InsertText( sTmp, rInsPos ); } } @@ -684,7 +684,7 @@ void SwTOXPara::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, USHORT ) const String sTmp, sTmpReading; GetTxt( sTmp, sTmpReading ); sTmp.SearchAndReplaceAll('\t', ' '); - rNd.Insert( sTmp, rInsPos ); + rNd.InsertText( sTmp, rInsPos ); } } @@ -904,7 +904,7 @@ void SwTOXAuthority::FillText( SwTxtNode& rNd, } else sText = (pField->GetFieldText((ToxAuthorityField) nAuthField)); - rNd.Insert( sText, rInsPos ); + rNd.InsertText( sText, rInsPos ); } /* -----------------14.10.99 09:35------------------- diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 2bf117afb251..9c54bc60e239 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -166,6 +166,8 @@ void SwFmtFld::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) { switch( pNew->Which() ) { + case RES_OBJECTDYING: + return; // don't do anything, especially not expand! case RES_TXTATR_FLDCHG: // "Farbe hat sich geaendert !" // this, this fuer "nur Painten" @@ -261,6 +263,7 @@ SwTxtFld::SwTxtFld( SwFmtFld& rAttr, xub_StrLen nStartPos ) , m_pTxtNode( 0 ) { rAttr.pTxtAttr = this; + SetHasDummyChar(true); } SwTxtFld::~SwTxtFld( ) diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx index d738497507a8..fa0a734f79c1 100644 --- a/sw/source/core/txtnode/atrflyin.cxx +++ b/sw/source/core/txtnode/atrflyin.cxx @@ -74,6 +74,7 @@ SwTxtFlyCnt::SwTxtFlyCnt( SwFmtFlyCnt& rAttr, xub_StrLen nStartPos ) : SwTxtAttr( rAttr, nStartPos ) { rAttr.pTxtAttr = this; + SetHasDummyChar(true); } diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx index 4b51e94e3404..fd35ccd1477c 100644 --- a/sw/source/core/txtnode/atrftn.cxx +++ b/sw/source/core/txtnode/atrftn.cxx @@ -182,6 +182,7 @@ SwTxtFtn::SwTxtFtn( SwFmtFtn& rAttr, xub_StrLen nStartPos ) , m_nSeqNo( USHRT_MAX ) { rAttr.pTxtAttr = this; + SetHasDummyChar(true); } @@ -291,7 +292,7 @@ void SwTxtFtn::SetNumber( const USHORT nNewNum, const XubString* pStr ) } // Die Fussnoten duplizieren -void SwTxtFtn::CopyFtn( SwTxtFtn *pDest ) +void SwTxtFtn::CopyFtn( SwTxtFtn *pDest ) const { if ( m_pStartNode && pDest->GetStartNode() ) { diff --git a/sw/source/core/txtnode/atrref.cxx b/sw/source/core/txtnode/atrref.cxx index ea427f8e8877..d545a22d720e 100644 --- a/sw/source/core/txtnode/atrref.cxx +++ b/sw/source/core/txtnode/atrref.cxx @@ -91,7 +91,10 @@ SwTxtRefMark::SwTxtRefMark( SwFmtRefMark& rAttr, m_nEnd = *pEnd; m_pEnd = & m_nEnd; } - SetDontMergeAttr( true ); + else + { + SetHasDummyChar(true); + } SetDontMoveAttr( true ); SetOverlapAllowedAttr( true ); } diff --git a/sw/source/core/txtnode/atrtox.cxx b/sw/source/core/txtnode/atrtox.cxx index 5cc9388dcbcd..32ef6dc378eb 100644 --- a/sw/source/core/txtnode/atrtox.cxx +++ b/sw/source/core/txtnode/atrtox.cxx @@ -50,7 +50,10 @@ SwTxtTOXMark::SwTxtTOXMark( SwTOXMark& rAttr, m_nEnd = *pEnd; m_pEnd = & m_nEnd; } - SetDontMergeAttr( true ); + else + { + SetHasDummyChar(true); + } SetDontMoveAttr( true ); SetOverlapAllowedAttr( true ); } diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 19b827d0b9f9..b9c5ec4b6964 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -31,14 +31,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - - #include "hintids.hxx" #include "unomid.h" -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include <basic/sbxvar.hxx> -#endif #include <svtools/macitem.hxx> #include <svtools/stritem.hxx> #include <svtools/stylepool.hxx> @@ -51,16 +47,24 @@ #include <hints.hxx> // SwUpdateAttr #include <unostyle.hxx> #include <unoevent.hxx> // SwHyperlinkEventDescriptor -#ifndef _COM_SUN_STAR_TEXT_RUBYADJUST_HDL_ #include <com/sun/star/text/RubyAdjust.hdl> -#endif -#ifndef _CMDID_H #include <cmdid.h> -#endif #include <com/sun/star/uno/Any.h> #include <SwStyleNameMapper.hxx> +#include <fmtmeta.hxx> +#include <ndtxt.hxx> // for meta +#include <doc.hxx> // for meta +#include <unometa.hxx> +#include <unoobj.hxx> // SwXTextRange +#include <docsh.hxx> +#include <svtools/zforlist.hxx> // GetNumberFormat + +#include <boost/bind.hpp> +#include <algorithm> + + using namespace ::com::sun::star; using ::rtl::OUString; @@ -578,3 +582,327 @@ BOOL SwFmtRuby::PutValue( const uno::Any& rVal, return bRet; } + +/************************************************************************* + class SwFmtMeta + ************************************************************************/ + +SwFmtMeta * SwFmtMeta::CreatePoolDefault(const USHORT i_nWhich) +{ + return new SwFmtMeta(i_nWhich); +} + +SwFmtMeta::SwFmtMeta(const USHORT i_nWhich) + : SfxPoolItem( i_nWhich ) + , m_pMeta() + , m_pTxtAttr( 0 ) +{ + ASSERT((RES_TXTATR_META == i_nWhich) || (RES_TXTATR_METAFIELD == i_nWhich), + "ERROR: SwFmtMeta: invalid which id!"); +} + +SwFmtMeta::SwFmtMeta( ::boost::shared_ptr< ::sw::Meta > const & i_pMeta, + const USHORT i_nWhich ) + : SfxPoolItem( i_nWhich ) + , m_pMeta( i_pMeta ) + , m_pTxtAttr( 0 ) +{ + ASSERT((RES_TXTATR_META == i_nWhich) || (RES_TXTATR_METAFIELD == i_nWhich), + "ERROR: SwFmtMeta: invalid which id!"); + ASSERT(m_pMeta, "SwFmtMeta: no Meta ?"); + // DO NOT call m_pMeta->SetFmtMeta(this) here; only from SetTxtAttr! +} + +SwFmtMeta::~SwFmtMeta() +{ + if (m_pMeta->GetFmtMeta() == this) + { + m_pMeta->SetFmtMeta(0); + } +} + +int SwFmtMeta::operator==( const SfxPoolItem & i_rOther ) const +{ + ASSERT( SfxPoolItem::operator==( i_rOther ), "i just copied this assert" ); + return SfxPoolItem::operator==( i_rOther ) + && (m_pMeta == static_cast<SwFmtMeta const &>( i_rOther ).m_pMeta); +} + +SfxPoolItem * SwFmtMeta::Clone( SfxItemPool * /*pPool*/ ) const +{ + // if this is indeed a copy, then DoCopy must be called later! + return new SwFmtMeta( m_pMeta, Which() ); +} + +void SwFmtMeta::SetTxtAttr(SwTxtMeta * const i_pTxtAttr) +{ + ASSERT(!(m_pTxtAttr && i_pTxtAttr), + "SwFmtMeta::SetTxtAttr: already has text attribute?"); + ASSERT( m_pTxtAttr || i_pTxtAttr , + "SwFmtMeta::SetTxtAttr: no attribute to remove?"); + m_pTxtAttr = i_pTxtAttr; + ASSERT(m_pMeta, "inserted SwFmtMeta has no sw::Meta?"); + // the sw::Meta must be able to find the current text attribute! + if (i_pTxtAttr && m_pMeta) + { + m_pMeta->SetFmtMeta(this); + } +} + +void SwFmtMeta::NotifyRemoval() +{ + // 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); + } +} + +void SwFmtMeta::DoCopy(SwFmtMeta & rOriginalMeta) +{ + ASSERT(m_pMeta, "DoCopy called for SwFmtMeta with no sw::Meta?"); + if (m_pMeta) + { + const ::boost::shared_ptr< ::sw::Meta> pOriginal( m_pMeta ); + // UGLY: original sw::Meta now points at _this_ due to being already + // 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); + if (RES_TXTATR_META == Which()) + { + m_pMeta.reset( new ::sw::Meta(this) ); + } + else + { + ::sw::MetaField *const pMetaField( + static_cast< ::sw::MetaField* >(pOriginal.get())); + SwDoc * const pTargetDoc( GetTxtAttr()->GetTxtNode()->GetDoc() ); + m_pMeta = pTargetDoc->GetMetaFieldManager().makeMetaField( this, + pMetaField->m_nNumberFormat, pMetaField->IsFixedLanguage() ); + } + m_pMeta->RegisterAsCopyOf(*pOriginal); + } +} + + +namespace sw { + +/************************************************************************* + class sw::Meta + ************************************************************************/ + +Meta::Meta(SwFmtMeta * const i_pFmt) + : ::sfx2::Metadatable() + , SwModify() + , m_pFmt( i_pFmt ) +{ +} + +Meta::~Meta() +{ +} + +SwTxtMeta * Meta::GetTxtAttr() const +{ + return (m_pFmt) ? m_pFmt->GetTxtAttr() : 0; +} + +SwTxtNode * Meta::GetTxtNode() const +{ + SwTxtMeta * const pTxtAttr( GetTxtAttr() ); + return (pTxtAttr) ? pTxtAttr->GetTxtNode() : 0; +} + +// SwClient +void Meta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) +{ + SwTxtNode * const pTxtNode( GetTxtNode() ); + if (pTxtNode && (GetRegisteredIn() != pTxtNode)) + { + pTxtNode->Add(this); + } + SwModify::Modify(pOld, pNew); +} + +// sw::Metadatable +::sfx2::IXmlIdRegistry& Meta::GetRegistry() +{ + SwTxtNode * const pTxtNode( GetTxtNode() ); + // GetRegistry may only be called on a meta that is actually in the + // document, which means it has a pointer to its text node + OSL_ENSURE(pTxtNode, "ERROR: GetRegistry: no text node?"); + if (!pTxtNode) + throw uno::RuntimeException(); + return pTxtNode->GetRegistry(); +} + +bool Meta::IsInClipboard() const +{ + const SwTxtNode * const pTxtNode( GetTxtNode() ); +// no text node: in UNDO OSL_ENSURE(pTxtNode, "IsInClipboard: no text node?"); + return (pTxtNode) ? pTxtNode->IsInClipboard() : false; +} + +bool Meta::IsInUndo() const +{ + const SwTxtNode * const pTxtNode( GetTxtNode() ); +// no text node: in UNDO OSL_ENSURE(pTxtNode, "IsInUndo: no text node?"); + return (pTxtNode) ? pTxtNode->IsInUndo() : true; +} + +bool Meta::IsInContent() const +{ + const SwTxtNode * const pTxtNode( GetTxtNode() ); + OSL_ENSURE(pTxtNode, "IsInContent: no text node?"); + return (pTxtNode) ? pTxtNode->IsInContent() : true; +} + +::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); +} + +/************************************************************************* + class sw::MetaField + ************************************************************************/ + +MetaField::MetaField(SwFmtMeta * const i_pFmt, + const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage) + : Meta(i_pFmt) + , m_nNumberFormat( nNumberFormat ) + , m_bIsFixedLanguage( bIsFixedLanguage ) +{ +} + +void MetaField::GetPrefixAndSuffix( + ::rtl::OUString *const o_pPrefix, ::rtl::OUString *const o_pSuffix) +{ + try + { + const uno::Reference<rdf::XMetadatable> xMetaField( MakeUnoObject() ); + OSL_ENSURE(dynamic_cast<SwXMetaField*>(xMetaField.get()), + "GetPrefixAndSuffix: no SwXMetaField?"); + if (xMetaField.is()) + { + SwTxtNode * const pTxtNode( GetTxtNode() ); + SwDocShell const * const pShell(pTxtNode->GetDoc()->GetDocShell()); + const uno::Reference<frame::XModel> xModel( + (pShell) ? pShell->GetModel() : 0, uno::UNO_SET_THROW); + getPrefixAndSuffix(xModel, xMetaField, o_pPrefix, o_pSuffix); + } + } catch (uno::Exception) { + OSL_ENSURE(false, "exception?"); + } +} + +sal_uInt32 MetaField::GetNumberFormat(::rtl::OUString const & rContent) const +{ + //TODO: this probably lacks treatment for some special cases + sal_uInt32 nNumberFormat( m_nNumberFormat ); + SwTxtNode * const pTxtNode( GetTxtNode() ); + if (pTxtNode) + { + SvNumberFormatter *const pNumberFormatter( + pTxtNode->GetDoc()->GetNumberFormatter() ); + double number; + (void) pNumberFormatter->IsNumberFormat( + rContent, nNumberFormat, number ); + } + return nNumberFormat; +} + +void MetaField::SetNumberFormat(sal_uInt32 nNumberFormat) +{ + // effectively, the member is only a default: + // GetNumberFormat checks if the text actually conforms + m_nNumberFormat = nNumberFormat; +} + + +/************************************************************************* + class sw::MetaFieldManager + ************************************************************************/ + + +MetaFieldManager::MetaFieldManager() +{ +} + +::boost::shared_ptr<MetaField> +MetaFieldManager::makeMetaField(SwFmtMeta * const i_pFmt, + const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage) +{ + const ::boost::shared_ptr<MetaField> pMetaField( + new MetaField(i_pFmt, nNumberFormat, bIsFixedLanguage) ); + m_MetaFields.push_back(pMetaField); + return pMetaField; +} + +struct IsInUndo +{ + bool operator()(::boost::weak_ptr<MetaField> const & pMetaField) { + return pMetaField.lock()->IsInUndo(); + } +}; + +struct MakeUnoObject +{ + uno::Reference<text::XTextField> + operator()(::boost::weak_ptr<MetaField> const & pMetaField) { + return uno::Reference<text::XTextField>( + pMetaField.lock()->MakeUnoObject(), uno::UNO_QUERY); + } +}; + +::std::vector< uno::Reference<text::XTextField> > +MetaFieldManager::getMetaFields() +{ + // erase deleted fields + const MetaFieldList_t::iterator iter( + ::std::remove_if(m_MetaFields.begin(), m_MetaFields.end(), + ::boost::bind(&::boost::weak_ptr<MetaField>::expired, _1))); + m_MetaFields.erase(iter, m_MetaFields.end()); + // filter out fields in UNDO + MetaFieldList_t filtered(m_MetaFields.size()); + const MetaFieldList_t::iterator iter2( + ::std::remove_copy_if(m_MetaFields.begin(), m_MetaFields.end(), + filtered.begin(), IsInUndo())); + filtered.erase(iter2, filtered.end()); + // create uno objects + ::std::vector< uno::Reference<text::XTextField> > ret(filtered.size()); + ::std::transform(filtered.begin(), filtered.end(), ret.begin(), + MakeUnoObject()); + return ret; +} + +} // namespace sw + diff --git a/sw/source/core/txtnode/makefile.mk b/sw/source/core/txtnode/makefile.mk index f4fbf70014c8..36c6e09d6b7c 100644 --- a/sw/source/core/txtnode/makefile.mk +++ b/sw/source/core/txtnode/makefile.mk @@ -53,7 +53,6 @@ SLOFILES = \ $(SLO)$/atrref.obj \ $(SLO)$/atrtox.obj \ $(SLO)$/chrfmt.obj \ - $(SLO)$/fmtatr1.obj \ $(SLO)$/fmtatr2.obj \ $(SLO)$/fntcap.obj \ $(SLO)$/fntcache.obj \ @@ -71,6 +70,7 @@ SLOFILES = \ EXCEPTIONSFILES = \ + $(SLO)$/fmtatr2.obj \ $(SLO)$/atrtox.obj \ $(SLO)$/atrflyin.obj \ $(SLO)$/docnew.obj \ @@ -78,7 +78,7 @@ EXCEPTIONSFILES = \ $(SLO)$/ndtxt.obj \ $(SLO)$/thints.obj \ $(SLO)$/txtedt.obj - + .IF "$(dbutil)" != "" OFILES+=$(SLO)$/dbchratr.$(QBJX) diff --git a/sw/source/core/txtnode/ndhints.cxx b/sw/source/core/txtnode/ndhints.cxx index 64ca41cf8516..6fdacb37a456 100644 --- a/sw/source/core/txtnode/ndhints.cxx +++ b/sw/source/core/txtnode/ndhints.cxx @@ -37,6 +37,11 @@ #include "ndhints.hxx" #include <txtatr.hxx> +#ifndef PRODUCT +#include <pam.hxx> +#endif + + _SV_IMPL_SORTAR_ALG( SwpHtStart, SwTxtAttr* ) _SV_IMPL_SORTAR_ALG( SwpHtEnd, SwTxtAttr* ) @@ -99,15 +104,15 @@ static BOOL lcl_IsLessStart( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) { if ( *rHt1.GetStart() == *rHt2.GetStart() ) { - xub_StrLen nHt1 = *rHt1.GetAnyEnd(); - xub_StrLen nHt2 = *rHt2.GetAnyEnd(); + const xub_StrLen nHt1 = *rHt1.GetAnyEnd(); + const xub_StrLen nHt2 = *rHt2.GetAnyEnd(); if ( nHt1 == nHt2 ) { - nHt1 = rHt1.Which(); - nHt2 = rHt2.Which(); - if ( nHt1 == nHt2 ) + const USHORT nWhich1 = rHt1.Which(); + const USHORT nWhich2 = rHt2.Which(); + if ( nWhich1 == nWhich2 ) { - if ( RES_TXTATR_CHARFMT == nHt1 ) + if ( RES_TXTATR_CHARFMT == nWhich1 ) { const USHORT nS1 = static_cast<const SwTxtCharFmt&>(rHt1).GetSortNumber(); const USHORT nS2 = static_cast<const SwTxtCharFmt&>(rHt2).GetSortNumber(); @@ -118,6 +123,8 @@ static BOOL lcl_IsLessStart( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) return (long)&rHt1 < (long)&rHt2; } + // the order must ensure that META is inside RUBY! + return ( nWhich1 < nWhich2 ); } return ( nHt1 > nHt2 ); } @@ -131,18 +138,17 @@ static BOOL lcl_IsLessStart( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) // Zuerst nach Ende danach nach Ptr static BOOL lcl_IsLessEnd( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) { - xub_StrLen nHt1 = *rHt1.GetAnyEnd(); - xub_StrLen nHt2 = *rHt2.GetAnyEnd(); + const xub_StrLen nHt1 = *rHt1.GetAnyEnd(); + const xub_StrLen nHt2 = *rHt2.GetAnyEnd(); if ( nHt1 == nHt2 ) { if ( *rHt1.GetStart() == *rHt2.GetStart() ) { - nHt1 = rHt1.Which(); - nHt2 = rHt2.Which(); - - if ( nHt1 == nHt2 ) + const USHORT nWhich1 = rHt1.Which(); + const USHORT nWhich2 = rHt2.Which(); + if ( nWhich1 == nWhich2 ) { - if ( RES_TXTATR_CHARFMT == nHt1 ) + if ( RES_TXTATR_CHARFMT == nWhich1 ) { const USHORT nS1 = static_cast<const SwTxtCharFmt&>(rHt1).GetSortNumber(); const USHORT nS2 = static_cast<const SwTxtCharFmt&>(rHt2).GetSortNumber(); @@ -153,7 +159,8 @@ static BOOL lcl_IsLessEnd( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) return (long)&rHt1 > (long)&rHt2; } - // else return nHt1 < nHt2, see below + // the order must ensure that META is inside RUBY! + return ( nWhich1 > nWhich2 ); } else return ( *rHt1.GetStart() > *rHt2.GetStart() ); @@ -375,6 +382,37 @@ bool SwpHintsArray::Check() const ( *pHtThis->GetStart() == *pHtThis->GetEnd() ), "HintsCheck: Portion inconsistency. " "This can be temporarily ok during undo operations" ); + + if (pHtThis->IsNesting()) + { + for ( USHORT j = 0; j < Count(); ++j ) + { + SwTxtAttr const * const pOther( m_HintStarts[j] ); + if ( pOther->IsNesting() && (i != j) ) + { + SwComparePosition cmp = ComparePosition( + *pHtThis->GetStart(), *pHtThis->GetEnd(), + *pOther->GetStart(), *pOther->GetEnd()); + CHECK_ERR( (POS_OVERLAP_BEFORE != cmp) && + (POS_OVERLAP_BEHIND != cmp), + "HintsCheck: overlapping nesting hints!!!" ); + } + } + } + + // 9) dummy char check (unfortunately cannot check SwTxtNode::m_Text) + if (pHtThis->HasDummyChar()) + { + for ( USHORT j = 0; j < i; ++j ) + { + SwTxtAttr const * const pOther( m_HintStarts[j] ); + if (pOther->HasDummyChar()) + { + CHECK_ERR( (*pOther->GetStart() != *pHtThis->GetStart()), + "HintsCheck: multiple hints claim same CH_TXTATR!"); + } + } + } #endif } return true; diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 98025e708bd9..6c5aafb4667d 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -52,7 +52,6 @@ #include <fmtinfmt.hxx> #include <fmtpdsc.hxx> #include <txtatr.hxx> -#include <fmthbsh.hxx> #include <fmtrfmrk.hxx> #include <txttxmrk.hxx> #include <fchrfmt.hxx> @@ -64,6 +63,7 @@ #include <ftnidx.hxx> #include <ftninfo.hxx> #include <fmtftn.hxx> +#include <fmtmeta.hxx> #include <charfmt.hxx> #include <ndtxt.hxx> #include <doc.hxx> @@ -398,9 +398,10 @@ void lcl_ChangeFtnRef( SwTxtNode &rNode ) SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) { // lege den Node "vor" mir an - xub_StrLen nSplitPos = rPos.nContent.GetIndex(); - xub_StrLen nTxtLen = m_Text.Len(); - SwTxtNode* pNode = _MakeNewTxtNode( rPos.nNode, FALSE, nSplitPos==nTxtLen ); + const xub_StrLen nSplitPos = rPos.nContent.GetIndex(); + const xub_StrLen nTxtLen = m_Text.Len(); + SwTxtNode* const pNode = + _MakeNewTxtNode( rPos.nNode, FALSE, nSplitPos==nTxtLen ); // the first paragraph gets the XmlId, // _except_ if it is empty and the second is not empty @@ -452,21 +453,27 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) //Ersten Teil des Inhalts in den neuen Node uebertragen und //im alten Node loeschen. SwIndex aIdx( this ); - Cut( pNode, aIdx, nSplitPos ); + CutText( pNode, aIdx, nSplitPos ); if( GetWrong() ) + { pNode->SetWrong( GetWrong()->SplitList( nSplitPos ) ); + } SetWrongDirty( true ); if( GetGrammarCheck() ) + { pNode->SetGrammarCheck( GetGrammarCheck()->SplitGrammarList( nSplitPos ) ); + } SetGrammarCheckDirty( true ); SetWordCountDirty( true ); // SMARTTAGS if( GetSmartTags() ) + { pNode->SetSmartTags( GetSmartTags()->SplitList( nSplitPos ) ); + } SetSmartTagDirty( true ); if ( pNode->HasHints() ) @@ -487,21 +494,22 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) // Attribute loeschen if ( HasHints() ) { - SwTxtAttr* pHt; - xub_StrLen* pEnd; for ( USHORT j = m_pSwpHints->Count(); j; ) { - pHt = m_pSwpHints->GetTextHint( --j ); + SwTxtAttr* const pHt = m_pSwpHints->GetTextHint( --j ); if ( RES_TXTATR_FLYCNT == pHt ->Which() ) { pHt->GetFlyCnt().GetFrmFmt()->DelFrms(); } - else if( pHt->DontExpand() && 0 != ( pEnd = pHt->GetEnd() ) - && *pHt->GetStart() == *pEnd ) + else if ( pHt->DontExpand() ) { - // delete it! - m_pSwpHints->DeleteAtPos( j ); - DestroyAttr( pHt ); + const xub_StrLen* const pEnd = pHt->GetEnd(); + if (pEnd && *pHt->GetStart() == *pEnd ) + { + // delete it! + m_pSwpHints->DeleteAtPos( j ); + DestroyAttr( pHt ); + } } } } @@ -511,6 +519,7 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) SwClientIter aIter( *this ); SwClient* pLastFrm = aIter.GoStart(); if( pLastFrm ) + { do { SwCntntFrm *pFrm = PTR_CAST( SwCntntFrm, pLastFrm ); if ( pFrm ) @@ -520,7 +529,9 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) ((SwTxtFrm*)pFrm)->GetOfst() ) ((SwTxtFrm*)pFrm)->SetOfst( 0 ); } - } while( 0 != ( pLastFrm = aIter++ )); + pLastFrm = aIter++; + } while ( pLastFrm ); + } if ( IsInCache() ) { @@ -530,13 +541,12 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) UnlockModify(); // Benachrichtigungen wieder freischalten - const SwRootFrm *pRootFrm; + const SwRootFrm * const pRootFrm = pNode->GetDoc()->GetRootFrm(); // If there is an accessible layout we must call modify even // with length zero, because we have to notify about the changed // text node. - if( nTxtLen != nSplitPos || - ( (pRootFrm = pNode->GetDoc()->GetRootFrm()) != 0 && - pRootFrm->IsAnyShellAccessible() ) ) + if ( (nTxtLen != nSplitPos) || + ( pRootFrm && pRootFrm->IsAnyShellAccessible() ) ) { // dann sage den Frames noch, das am Ende etwas "geloescht" wurde @@ -576,18 +586,16 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) SetSmartTagDirty( true ); SwIndex aIdx( this ); - Cut( pNode, aIdx, rPos.nContent.GetIndex() ); + CutText( pNode, aIdx, nSplitPos ); // JP 01.10.96: alle leeren und nicht zu expandierenden // Attribute loeschen if ( HasHints() ) { - SwTxtAttr* pHt; - xub_StrLen* pEnd; for ( USHORT j = m_pSwpHints->Count(); j; ) { - pHt = m_pSwpHints->GetTextHint( --j ); - pEnd = pHt->GetEnd(); + SwTxtAttr* const pHt = m_pSwpHints->GetTextHint( --j ); + const xub_StrLen* const pEnd = pHt->GetEnd(); if ( pHt->DontExpand() && pEnd && (*pHt->GetStart() == *pEnd) ) { // delete it! @@ -618,7 +626,9 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) } if ( GetDepends() ) + { MakeFrms( *pNode ); // neue Frames anlegen. + } lcl_ChangeFtnRef( *pNode ); } @@ -630,7 +640,9 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) const SfxPoolItem *pItem; if( GetDepends() && SFX_ITEM_SET == pNode->GetSwAttrSet(). GetItemState( RES_PAGEDESC, TRUE, &pItem ) ) + { pNode->Modify( (SfxPoolItem*)pItem, (SfxPoolItem*)pItem ); + } } return pNode; } @@ -735,7 +747,7 @@ SwCntntNode *SwTxtNode::JoinNext() } { // wg. SwIndex - pTxtNode->Cut( this, SwIndex(pTxtNode), pTxtNode->Len() ); + pTxtNode->CutText( this, SwIndex(pTxtNode), pTxtNode->Len() ); } // verschiebe noch alle Bookmarks/TOXMarks if( aBkmkArr.Count() ) @@ -830,7 +842,7 @@ SwCntntNode *SwTxtNode::JoinPrev() } { // wg. SwIndex - pTxtNode->Cut( this, SwIndex( this ), SwIndex(pTxtNode), nLen ); + pTxtNode->CutText( this, SwIndex(this), SwIndex(pTxtNode), nLen ); } // verschiebe noch alle Bookmarks/TOXMarks if( aBkmkArr.Count() ) @@ -877,51 +889,49 @@ void SwTxtNode::NewAttrSet( SwAttrPool& rPool ) } -// Ueberladen der virtuellen Update-Methode von SwIndexReg. Dadurch -// benoetigen die Text-Attribute nur xub_StrLen statt SwIndizies! -void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, - BOOL bNegativ, BOOL bDelete ) +// override SwIndexReg::Update => text hints do not need SwIndex for start/end! +void SwTxtNode::Update( SwIndex const & rPos, const xub_StrLen nChangeLen, + const bool bNegative, const bool bDelete ) { SetAutoCompleteWordDirty( TRUE ); - TmpHints* pCollector = NULL; + ::std::auto_ptr<TmpHints> pCollector; + const xub_StrLen nChangePos = rPos.GetIndex(); + if ( HasHints() ) { - xub_StrLen nPos = aPos.GetIndex(); - xub_StrLen* pIdx; - SwTxtAttr* pHt; - if( bNegativ ) + if ( bNegative ) { - xub_StrLen nMax = nPos + nLen; + const xub_StrLen nChangeEnd = nChangePos + nChangeLen; for ( USHORT n = 0; n < m_pSwpHints->Count(); ++n ) { - BOOL bSttBefore = FALSE; - pHt = m_pSwpHints->GetTextHint(n); - pIdx = pHt->GetStart(); - if( *pIdx >= nPos ) + SwTxtAttr * const pHint = m_pSwpHints->GetTextHint(n); + xub_StrLen * const pStart = pHint->GetStart(); + if ( *pStart > nChangePos ) { - if( *pIdx > nMax ) - *pIdx = *pIdx - nLen; + if ( *pStart > nChangeEnd ) + { + *pStart = *pStart - nChangeLen; + } else { - *pIdx = nPos; + *pStart = nChangePos; } } - else - bSttBefore = TRUE; - - if( 0 == (pIdx = pHt->GetEnd()) ) - continue; - if( *pIdx >= nPos ) + xub_StrLen * const pEnd = pHint->GetEnd(); + if (pEnd) { - if( *pIdx > nMax ) - { - *pIdx = *pIdx - nLen; - } - else if( *pIdx != nPos ) + if ( *pEnd > nChangePos ) { - *pIdx = nPos; + if( *pEnd > nChangeEnd ) + { + *pEnd = *pEnd - nChangeLen; + } + else + { + *pEnd = nChangePos; + } } } } @@ -930,9 +940,8 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, } else { - xub_StrLen* pEnd; - BOOL bNoExp = FALSE; - BOOL bResort = FALSE; + bool bNoExp = false; + bool bResort = false; const USHORT coArrSz = static_cast<USHORT>(RES_TXTATR_WITHEND_END) - static_cast<USHORT>(RES_CHRATR_BEGIN) + static_cast<USHORT>(RES_UNKNOWNATR_END) - @@ -943,27 +952,29 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, for ( USHORT n = 0; n < m_pSwpHints->Count(); ++n ) { - pHt = m_pSwpHints->GetTextHint(n); - pIdx = pHt->GetStart(); - pEnd = pHt->GetEnd(); - if ( *pIdx >= nPos ) + SwTxtAttr * const pHint = m_pSwpHints->GetTextHint(n); + xub_StrLen * const pStart = pHint->GetStart(); + xub_StrLen * const pEnd = pHint->GetEnd(); + if ( *pStart >= nChangePos ) { - *pIdx = *pIdx + nLen; + *pStart = *pStart + nChangeLen; if ( pEnd ) { - *pEnd = *pEnd + nLen; + *pEnd = *pEnd + nChangeLen; } } - else if ( pEnd && *pEnd >= nPos ) + else if ( pEnd && (*pEnd >= nChangePos) ) { - if( *pEnd > nPos || IsIgnoreDontExpand() ) + if ( (*pEnd > nChangePos) || IsIgnoreDontExpand() ) { - *pEnd = *pEnd + nLen; + *pEnd = *pEnd + nChangeLen; } - else + else // *pEnd == nChangePos { - USHORT nWhPos, nWhich = pHt->Which(); + USHORT nWhPos; + const USHORT nWhich = pHint->Which(); + ASSERT(!isCHRATR(nWhich), "Update: char attr hint?"); if (isCHRATR(nWhich) || isTXTATR_WITHEND(nWhich)) { nWhPos = static_cast<USHORT>(nWhich - @@ -983,13 +994,13 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, if( aDontExp[ nWhPos ] ) continue; - if( pHt->DontExpand() ) + if ( pHint->DontExpand() ) { - pHt->SetDontExpand( FALSE ); - bResort = TRUE; - if( pHt->IsCharFmtAttr() ) + pHint->SetDontExpand( false ); + bResort = true; + if ( pHint->IsCharFmtAttr() ) { - bNoExp = TRUE; + bNoExp = true; aDontExp[ static_cast<USHORT>(RES_TXTATR_CHARFMT) - static_cast<USHORT>(RES_CHRATR_BEGIN) ] = TRUE; aDontExp[ static_cast<USHORT>(RES_TXTATR_INETFMT) - static_cast<USHORT>(RES_CHRATR_BEGIN) ] @@ -1000,8 +1011,10 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, } else if( bNoExp ) { - if( !pCollector ) - pCollector = new TmpHints; + if ( !pCollector.get() ) + { + pCollector.reset( new TmpHints ); + } USHORT nCollCnt = pCollector->Count(); for( USHORT i = 0; i < nCollCnt; ++i ) { @@ -1009,22 +1022,24 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, if( nWhich == pTmp->Which() ) { pCollector->Remove( i ); - delete pTmp; + SwTxtAttr::Destroy( pTmp, + GetDoc()->GetAttrPool() ); break; } } - SwTxtAttr *pTmp = MakeTxtAttr( pHt->GetAttr(), - nPos, nPos + nLen ); + SwTxtAttr * const pTmp = MakeTxtAttr( *GetDoc(), + pHint->GetAttr(), + nChangePos, nChangePos + nChangeLen); pCollector->C40_INSERT( SwTxtAttr, pTmp, pCollector->Count() ); } else { - *pEnd = *pEnd + nLen; + *pEnd = *pEnd + nChangeLen; } } } } - if( bResort ) + if ( bResort ) { m_pSwpHints->Resort(); } @@ -1032,45 +1047,51 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, } SwIndexReg aTmpIdxReg; - if( !bNegativ && !bDelete ) + if ( !bNegative && !bDelete ) { - SwIndex* pIdx; const SwRedlineTbl& rTbl = GetDoc()->GetRedlineTbl(); - if( rTbl.Count() ) - for( USHORT i = 0; i < rTbl.Count(); ++i ) + for ( USHORT i = 0; i < rTbl.Count(); ++i ) + { + SwRedline *const pRedl = rTbl[ i ]; + if ( pRedl->HasMark() ) { - SwRedline* pRedl = rTbl[ i ]; - if( pRedl->HasMark() ) + SwPosition* const pEnd = pRedl->End(); + if ( this == &pEnd->nNode.GetNode() && + *pRedl->GetPoint() != *pRedl->GetMark() ) { - SwPosition* pEnd = pRedl->End(); - - if( this == &pEnd->nNode.GetNode() && - *pRedl->GetPoint() != *pRedl->GetMark() && - aPos.GetIndex() == - (pIdx = &pEnd->nContent)->GetIndex() ) - pIdx->Assign( &aTmpIdxReg, pIdx->GetIndex() ); + SwIndex & rIdx = pEnd->nContent; + if (nChangePos == rIdx.GetIndex()) + { + rIdx.Assign( &aTmpIdxReg, rIdx.GetIndex() ); + } } - else if( this == &pRedl->GetPoint()->nNode.GetNode() && - aPos.GetIndex() == (pIdx = &pRedl->GetPoint()-> - nContent)->GetIndex() ) + } + else if ( this == &pRedl->GetPoint()->nNode.GetNode() ) + { + SwIndex & rIdx = pRedl->GetPoint()->nContent; + if (nChangePos == rIdx.GetIndex()) { - pIdx->Assign( &aTmpIdxReg, pIdx->GetIndex() ); - if( &pRedl->GetBound( TRUE ) == pRedl->GetPoint() ) + rIdx.Assign( &aTmpIdxReg, rIdx.GetIndex() ); + // mst: FIXME: why does this adjust the unused position??? + SwIndex * pIdx; + if ( &pRedl->GetBound( true ) == pRedl->GetPoint() ) { - pRedl->GetBound( FALSE ) = pRedl->GetBound( TRUE ); - pIdx = &pRedl->GetBound( FALSE ).nContent; + pRedl->GetBound( false ) = pRedl->GetBound( true ); + pIdx = &pRedl->GetBound( false ).nContent; } else { - pRedl->GetBound( TRUE ) = pRedl->GetBound( FALSE ); - pIdx = &pRedl->GetBound( TRUE ).nContent; + pRedl->GetBound( true ) = pRedl->GetBound( false ); + pIdx = &pRedl->GetBound( true ).nContent; } pIdx->Assign( &aTmpIdxReg, pIdx->GetIndex() ); } } + } const IDocumentMarkAccess* const pMarkAccess = getIDocumentMarkAccess(); - for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin(); + for(IDocumentMarkAccess::const_iterator_t ppMark = + pMarkAccess->getMarksBegin(); ppMark != pMarkAccess->getMarksEnd(); ppMark++) { @@ -1080,21 +1101,25 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, // to the left of the inserted text (used in XML import). const ::sw::mark::IMark* const pMark = ppMark->get(); const SwPosition* pEnd = &pMark->GetMarkEnd(); - pIdx = (SwIndex*)&pEnd->nContent; + SwIndex & rIdx = const_cast<SwIndex&>(pEnd->nContent); if( this == &pEnd->nNode.GetNode() && - aPos.GetIndex() == pIdx->GetIndex() ) - pIdx->Assign( &aTmpIdxReg, pIdx->GetIndex() ); + rPos.GetIndex() == rIdx.GetIndex() ) + { + rIdx.Assign( &aTmpIdxReg, rIdx.GetIndex() ); + } } } - SwIndexReg::Update( aPos, nLen, bNegativ ); - if( pCollector ) + + // base class + SwIndexReg::Update( rPos, nChangeLen, bNegative, bDelete ); + + if ( pCollector.get() ) { - USHORT nCount = pCollector->Count(); - for( USHORT i = 0; i < nCount; ++i ) + const USHORT nCount = pCollector->Count(); + for ( USHORT i = 0; i < nCount; ++i ) { - m_pSwpHints->Insert( (*pCollector)[ i ], *this, FALSE ); + m_pSwpHints->TryInsertHint( (*pCollector)[ i ], *this ); } - delete pCollector; } aTmpIdxReg.MoveTo( *this ); @@ -1260,8 +1285,8 @@ SwCharFmt* lcl_FindCharFmt( const SwCharFmts* pCharFmts, const XubString& rName return NULL; } -void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, - SwTxtAttr *pNewHt, SwDoc* pOtherDoc, SwTxtNode *pDest ) +void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr * const pHt, + SwTxtAttr *const pNewHt, SwDoc *const pOtherDoc, SwTxtNode *const pDest ) { ASSERT( nWhich == pHt->Which(), "Falsche Hint-Id" ); switch( nWhich ) @@ -1269,7 +1294,8 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, // Wenn wir es mit einem Fussnoten-Attribut zu tun haben, // muessen wir natuerlich auch den Fussnotenbereich kopieren. case RES_TXTATR_FTN : - ((SwTxtFtn*)pHt)->CopyFtn( (SwTxtFtn*)pNewHt ); + static_cast<const SwTxtFtn*>(pHt)->CopyFtn( + static_cast<SwTxtFtn*>(pNewHt)); break; // Beim Kopieren von Feldern in andere Dokumente @@ -1280,19 +1306,24 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, { const SwFmtFld& rFld = pHt->GetFld(); if( pOtherDoc ) - ((SwTxtFld*)pHt)->CopyFld( (SwTxtFld*)pNewHt ); + { + static_cast<const SwTxtFld*>(pHt)->CopyFld( + static_cast<SwTxtFld*>(pNewHt) ); + } // Tabellenformel ?? if( RES_TABLEFLD == rFld.GetFld()->GetTyp()->Which() - && ((SwTblField*)rFld.GetFld())->IsIntrnlName() ) + && static_cast<const SwTblField*>(rFld.GetFld())->IsIntrnlName()) { // wandel die interne in eine externe Formel um - const SwTableNode* pDstTblNd = ((SwTxtFld*)pHt)-> + const SwTableNode* const pDstTblNd = + static_cast<const SwTxtFld*>(pHt)-> GetTxtNode().FindTableNode(); if( pDstTblNd ) { - SwTblField* pTblFld = (SwTblField*) - pNewHt->GetFld().GetFld(); + SwTblField* const pTblFld = const_cast<SwTblField*>( + static_cast<const SwTblField*>( + pNewHt->GetFld().GetFld())); pTblFld->PtrToBoxNm( &pDstTblNd->GetTable() ); } } @@ -1302,9 +1333,11 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, case RES_TXTATR_TOXMARK : if( pOtherDoc && pDest && pDest->GetpSwpHints() && USHRT_MAX != pDest->GetpSwpHints()->GetPos( pNewHt ) ) + { // Beim Kopieren von TOXMarks(Client) in andere Dokumente // muss der Verzeichnis (Modify) ausgetauscht werden - ((SwTxtTOXMark*)pNewHt)->CopyTOXMark( pOtherDoc ); + static_cast<SwTxtTOXMark*>(pNewHt)->CopyTOXMark( pOtherDoc ); + } break; case RES_TXTATR_CHARFMT : @@ -1313,21 +1346,27 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, if( pDest && pDest->GetpSwpHints() && USHRT_MAX != pDest->GetpSwpHints()->GetPos( pNewHt ) ) { - SwCharFmt* pFmt = (SwCharFmt*)pHt->GetCharFmt().GetCharFmt(); + SwCharFmt* pFmt = + static_cast<SwCharFmt*>(pHt->GetCharFmt().GetCharFmt()); if( pFmt && pOtherDoc ) + { pFmt = pOtherDoc->CopyCharFmt( *pFmt ); - ((SwFmtCharFmt&)pNewHt->GetCharFmt()).SetCharFmt( pFmt ); + } + const_cast<SwFmtCharFmt&>( static_cast<const SwFmtCharFmt&>( + pNewHt->GetCharFmt() ) ).SetCharFmt( pFmt ); } break; case RES_TXTATR_INETFMT : + { // Wenn wir es mit benutzerdefinierten INet-Zeichenvorlagen // zu tun haben, muessen wir natuerlich auch die Formate kopieren. if( pOtherDoc && pDest && pDest->GetpSwpHints() && USHRT_MAX != pDest->GetpSwpHints()->GetPos( pNewHt ) ) { - const SwDoc* pDoc; - if( 0!=( pDoc = ((SwTxtINetFmt*)pHt)->GetTxtNode().GetDoc() ) ) + const SwDoc* const pDoc = static_cast<const SwTxtINetFmt*>(pHt) + ->GetTxtNode().GetDoc(); + if ( pDoc ) { const SwCharFmts* pCharFmts = pDoc->GetCharFmts(); const SwFmtINetFmt& rFmt = pHt->GetINetFmt(); @@ -1343,11 +1382,27 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, //JP 24.04.98: Bug 49753 - ein TextNode muss am Attribut // gesetzt sein, damit die Vorlagen erzeugt // werden koenne - if( !((SwTxtINetFmt*)pNewHt)->GetpTxtNode() ) - ((SwTxtINetFmt*)pNewHt)->ChgTxtNode( pDest ); + SwTxtINetFmt* const pINetHt = static_cast<SwTxtINetFmt*>(pNewHt); + if ( !pINetHt->GetpTxtNode() ) + { + pINetHt->ChgTxtNode( pDest ); + } //JP 22.10.97: Bug 44875 - Verbindung zum Format herstellen - ((SwTxtINetFmt*)pNewHt)->GetCharFmt(); + pINetHt->GetCharFmt(); + break; + } + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + ASSERT(pNewHt, "copying META should not fail! cannot call DoCopy"); + ASSERT(pDest && (CH_TXTATR_INWORD == + pDest->GetTxt().GetChar(*pNewHt->GetStart())), + "missing CH_TXTATR?"); + if (pNewHt) + { + SwFmtMeta & rMeta(static_cast<SwFmtMeta&>(pNewHt->GetAttr())); + rMeta.DoCopy( const_cast<SwFmtMeta&>(pHt->GetMeta()) ); + } break; } } @@ -1366,40 +1421,41 @@ void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, { if ( HasHints() ) // keine Attribute, keine Kekse { - const xub_StrLen *pEndIdx = 0; - const SwTxtAttr *pHt = 0; - SwTxtAttr *pNewHt = 0; - xub_StrLen nAttrStartIdx = 0; - USHORT nWhich; - - SwDoc* pOtherDoc = pDest->GetDoc(); - if( pOtherDoc == GetDoc() ) - pOtherDoc = 0; + SwDoc* const pOtherDoc = (pDest->GetDoc() != GetDoc()) ? + pDest->GetDoc() : 0; for ( USHORT i = 0; i < m_pSwpHints->Count(); i++ ) { - pHt = (*m_pSwpHints)[i]; - if( nTxtStartIdx < ( nAttrStartIdx = *pHt->GetStart() ) ) + SwTxtAttr *const pHt = m_pSwpHints->GetTextHint(i); + xub_StrLen const nAttrStartIdx = *pHt->GetStart(); + if ( nTxtStartIdx < nAttrStartIdx ) break; // ueber das Textende, da nLen == 0 - pEndIdx = pHt->GetEnd(); - if( pEndIdx ) + const xub_StrLen *const pEndIdx = pHt->GetEnd(); + if ( pEndIdx && !pHt->HasDummyChar() ) { if( ( *pEndIdx > nTxtStartIdx || ( *pEndIdx == nTxtStartIdx && nAttrStartIdx == nTxtStartIdx ) ) ) { - if( RES_TXTATR_REFMARK != ( nWhich = pHt->Which()) ) + USHORT const nWhich = pHt->Which(); + if ( RES_TXTATR_REFMARK != nWhich ) { - // Attribut liegt im Bereich, also kopieren - if( 0 != ( pNewHt = pDest->InsertItem( pHt->GetAttr(), - nOldPos, nOldPos ) ) ) - lcl_CopyHint( nWhich, pHt, pNewHt, pOtherDoc, pDest ); + // attribute in the area => copy + SwTxtAttr *const pNewHt = pDest->InsertItem( + pHt->GetAttr(), nOldPos, nOldPos ); + if ( pNewHt ) + { + lcl_CopyHint( nWhich, pHt, pNewHt, + pOtherDoc, pDest ); + } } else if( !pOtherDoc ? GetDoc()->IsCopyIsMove() : 0 == pOtherDoc->GetRefMark( pHt->GetRefMark().GetRefName() ) ) + { pDest->InsertItem( pHt->GetAttr(), nOldPos, nOldPos ); + } } } } @@ -1421,19 +1477,19 @@ void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, // --> OD 2008-11-18 #i96213# // introduction of new optional parameter to control, if all attributes have to be copied. -void SwTxtNode::Copy( SwTxtNode *pDest, +void SwTxtNode::CopyText( SwTxtNode *const pDest, const SwIndex &rStart, - xub_StrLen nLen, + const xub_StrLen nLen, const bool bForceCopyOfAllAttrs ) { SwIndex aIdx( pDest, pDest->m_Text.Len() ); - Copy( pDest, aIdx, rStart, nLen, bForceCopyOfAllAttrs ); + CopyText( pDest, aIdx, rStart, nLen, bForceCopyOfAllAttrs ); } // <-- // --> OD 2008-11-18 #i96213# // introduction of new optional parameter to control, if all attributes have to be copied. -void SwTxtNode::Copy( SwTxtNode *pDest, +void SwTxtNode::CopyText( SwTxtNode *const pDest, const SwIndex &rDestStart, const SwIndex &rStart, xub_StrLen nLen, @@ -1468,36 +1524,33 @@ void SwTxtNode::Copy( SwTxtNode *pDest, 0 ); aCharSet.Put( *GetpSwAttrSet() ); if( aCharSet.Count() ) + { pDest->SetAttr( aCharSet, nDestStart, nDestStart ); + } } else + { GetpSwAttrSet()->CopyToModify( *pDest ); + } } return; } // 1. Text kopieren - xub_StrLen i = pDest->m_Text.Len() - nDestStart; + const xub_StrLen oldLen = pDest->m_Text.Len(); //JP 15.02.96: Bug 25537 - Attributbehandlung am Ende fehlt! Darum // ueber die InsertMethode den Text einfuegen und nicht // selbst direkt - pDest->Insert( m_Text.Copy( nTxtStartIdx, nLen ), rDestStart, - INS_EMPTYEXPAND ); + pDest->InsertText( m_Text.Copy( nTxtStartIdx, nLen ), rDestStart, + IDocumentContentOperations::INS_EMPTYEXPAND ); // um reale Groesse Updaten ! - nLen = pDest->m_Text.Len() - nDestStart - i; + nLen = pDest->m_Text.Len() - oldLen; if ( !nLen ) // string not longer? return; - i = 0; - const xub_StrLen *pEndIdx = 0; - xub_StrLen nAttrStartIdx = 0; - const SwTxtAttr *pHt = 0; - SwTxtAttr *pNewHt = 0; - - SwDoc* pOtherDoc = pDest->GetDoc(); - if( pOtherDoc == GetDoc() ) - pOtherDoc = 0; + SwDoc* const pOtherDoc = (pDest->GetDoc() != GetDoc()) ? + pDest->GetDoc() : 0; // harte Absatz umspannende Attribute kopieren if( HasSwAttrSet() ) @@ -1518,26 +1571,27 @@ void SwTxtNode::Copy( SwTxtNode *pDest, 0 ); aCharSet.Put( *GetpSwAttrSet() ); if( aCharSet.Count() ) + { pDest->SetAttr( aCharSet, nDestStart, nDestStart + nLen ); + } } else + { GetpSwAttrSet()->CopyToModify( *pDest ); + } } - - const BOOL bUndoNodes = !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); + const bool bUndoNodes = !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); // Ende erst jetzt holen, weil beim Kopieren in sich selbst der // Start-Index und alle Attribute vorher aktualisiert werden. nTxtStartIdx = rStart.GetIndex(); - xub_StrLen nEnd = nTxtStartIdx + nLen; + const xub_StrLen nEnd = nTxtStartIdx + nLen; // 2. Attribute kopieren // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu kopierenden Bereich liegt - USHORT nWhich; - USHORT nSize = m_pSwpHints ? m_pSwpHints->Count() : 0; - xub_StrLen nAttrStt, nAttrEnd; + const USHORT nSize = m_pSwpHints ? m_pSwpHints->Count() : 0; // wird in sich selbst kopiert, dann kann beim Einfuegen ein // Attribut geloescht werden. Darum erst ins Tmp-Array kopieren und @@ -1548,13 +1602,15 @@ void SwTxtNode::Copy( SwTxtNode *pDest, SwpHts aRefMrkArr; //Achtung: kann ungueltig sein!! - while ( ( i < nSize ) && - ((nAttrStartIdx = *(*m_pSwpHints)[i]->GetStart()) < nEnd) ) + for (USHORT n = 0; ( n < nSize ); ++n) { - pHt = (*m_pSwpHints)[i]; - pNewHt = 0; - pEndIdx = pHt->GetEnd(); - nWhich = pHt->Which(); + const xub_StrLen nAttrStartIdx = *(*m_pSwpHints)[n]->GetStart(); + if (!( nAttrStartIdx < nEnd)) + break; + + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(n); + const xub_StrLen * const pEndIdx = pHt->GetEnd(); + const USHORT nWhich = pHt->Which(); // JP 26.04.94: REFMARK's werden nie kopiert. Hat das Refmark aber // keinen Bereich umspannt, so steht im Text ein 255 @@ -1569,44 +1625,52 @@ void SwTxtNode::Copy( SwTxtNode *pDest, if( pEndIdx && RES_TXTATR_REFMARK == nWhich && !bCopyRefMark ) { - ++i; continue; } + xub_StrLen nAttrStt; + xub_StrLen nAttrEnd; + if( nAttrStartIdx < nTxtStartIdx ) { - // Anfang liegt vor dem Bereich - if( pEndIdx && ( nAttrEnd = *pEndIdx ) > nTxtStartIdx ) + // start is before selection + // copy hints with end and CH_TXTATR only if dummy char is copied + if ( pEndIdx && (*pEndIdx > nTxtStartIdx) && !pHt->HasDummyChar() ) { - // Attribut mit einem Bereich - // und das Ende des Attribut liegt im Bereich + // attribute with extent and the end is in the selection nAttrStt = nDestStart; - nAttrEnd = nAttrEnd > nEnd + nAttrEnd = (*pEndIdx > nEnd) ? rDestStart.GetIndex() - : nDestStart + nAttrEnd - nTxtStartIdx; + : nDestStart + (*pEndIdx) - nTxtStartIdx; } else { - ++i; continue; } } else { - // der Anfang liegt innerhalb des Bereiches + // start is in the selection nAttrStt = nDestStart + ( nAttrStartIdx - nTxtStartIdx ); if( pEndIdx ) + { nAttrEnd = *pEndIdx > nEnd ? rDestStart.GetIndex() : nDestStart + ( *pEndIdx - nTxtStartIdx ); + } else + { nAttrEnd = nAttrStt; + } } + SwTxtAttr * pNewHt = 0; + if( pDest == this ) { // die Daten kopieren - pNewHt = MakeTxtAttr( pHt->GetAttr(), nAttrStt, nAttrEnd ); + pNewHt = MakeTxtAttr( *GetDoc(), pHt->GetAttr(), + nAttrStt, nAttrEnd ); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //JP 23.04.95: erstmal so gesondert hier behandeln. Am Besten ist es @@ -1631,38 +1695,28 @@ void SwTxtNode::Copy( SwTxtNode *pDest, else { pNewHt = pDest->InsertItem( pHt->GetAttr(), nAttrStt, - nAttrEnd, nsSetAttrMode::SETATTR_NOTXTATRCHR ); - if( pNewHt ) - lcl_CopyHint( nWhich, pHt, pNewHt, pOtherDoc, pDest ); - else if( !pEndIdx ) - { - // Attribut wurde nicht kopiert, hat seinen Inhalt mitgenommen! - // Damit der rest aber korrekt kopiert werden kann, muss das - // Zeichen wieder an der Position stehen. Darum hier ein - // "Dummy-TextAttribut" einfuegen, wird am Ende wieder entfernt! - pNewHt = pDest->InsertItem( SwFmtHardBlank( 0xB7 ), nAttrStt, 0 - /*???, INS_NOHINTEXPAND*/ ); - aRefMrkArr.C40_INSERT( SwTxtAttr, pNewHt, aRefMrkArr.Count() ); - } + nAttrEnd, nsSetAttrMode::SETATTR_NOTXTATRCHR ); + lcl_CopyHint( nWhich, pHt, pNewHt, pOtherDoc, pDest ); } if( RES_TXTATR_REFMARK == nWhich && !pEndIdx && !bCopyRefMark ) { aRefMrkArr.C40_INSERT( SwTxtAttr, pNewHt, aRefMrkArr.Count() ); } - - ++i; } // nur falls im Array Attribute stehen (kann nur beim Kopieren // sich selbst passieren!!) - for( i = 0; i < aArr.Count(); ++i ) - Insert( aArr[ i ], nsSetAttrMode::SETATTR_NOTXTATRCHR ); + for ( USHORT i = 0; i < aArr.Count(); ++i ) + { + InsertHint( aArr[ i ], nsSetAttrMode::SETATTR_NOTXTATRCHR ); + } if( pDest->GetpSwpHints() ) - for( i = 0; i < aRefMrkArr.Count(); ++i ) + { + for ( USHORT i = 0; i < aRefMrkArr.Count(); ++i ) { - pNewHt = aRefMrkArr[i]; + SwTxtAttr * const pNewHt = aRefMrkArr[i]; if( pNewHt->GetEnd() ) { pDest->GetpSwpHints()->Delete( pNewHt ); @@ -1671,69 +1725,77 @@ void SwTxtNode::Copy( SwTxtNode *pDest, else { const SwIndex aIdx( pDest, *pNewHt->GetStart() ); - pDest->Erase( aIdx, 1 ); + pDest->EraseText( aIdx, 1 ); } } + } CHECK_SWPHINTS(this); } -/* - * Rudimentaeres Editieren, damit die SwDoc-Insert-Methoden - * funktionieren. - */ - -SwTxtNode& SwTxtNode::Insert( const XubString &rStr, - const SwIndex &rIdx, const USHORT nMode ) +void SwTxtNode::InsertText( const XubString & rStr, const SwIndex & rIdx, + const IDocumentContentOperations::InsertFlags nMode ) { - ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::Insert: invalid index." ); + ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::InsertText: invalid index." ); ASSERT( (ULONG)m_Text.Len() + (ULONG)rStr.Len() <= STRING_LEN, - "SwTxtNode::Insert: node text with insertion > STRING_LEN." ); + "SwTxtNode::InsertText: node text with insertion > STRING_LEN." ); xub_StrLen aPos = rIdx.GetIndex(); xub_StrLen nLen = m_Text.Len() - aPos; m_Text.Insert( rStr, aPos ); nLen = m_Text.Len() - aPos - nLen; - if( !nLen ) - return *this; - Update( rIdx, nLen ); // um reale Groesse Updaten ! + + if ( !nLen ) return; + + BOOL bOldExpFlg = IsIgnoreDontExpand(); + if (nMode & IDocumentContentOperations::INS_FORCEHINTEXPAND) + { + SetIgnoreDontExpand( TRUE ); + } + + Update( rIdx, nLen ); // text content changed! + + if (nMode & IDocumentContentOperations::INS_FORCEHINTEXPAND) + { + SetIgnoreDontExpand( bOldExpFlg ); + } // analog zu Insert(char) in txtedt.cxx: // 1) bei bHintExp leere Hints an rIdx.GetIndex suchen und aufspannen // 2) bei bHintExp == FALSE mitgezogene Feldattribute zuruecksetzen - USHORT i; - if ( HasHints() ) { - for ( i = 0; i < m_pSwpHints->Count() && + for ( USHORT i = 0; i < m_pSwpHints->Count() && rIdx >= *(*m_pSwpHints)[i]->GetStart(); ++i ) { - SwTxtAttr *pHt = m_pSwpHints->GetTextHint( i ); - xub_StrLen* pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint( i ); + xub_StrLen * const pEndIdx = pHt->GetEnd(); if( !pEndIdx ) continue; if( rIdx == *pEndIdx ) { - if( nMode & INS_NOHINTEXPAND || pHt->DontExpand() ) + if ( (nMode & IDocumentContentOperations::INS_NOHINTEXPAND) || + (!(nMode & IDocumentContentOperations::INS_FORCEHINTEXPAND) + && pHt->DontExpand()) ) { // bei leeren Attributen auch Start veraendern if( rIdx == *pHt->GetStart() ) *pHt->GetStart() = *pHt->GetStart() - nLen; *pEndIdx = *pEndIdx - nLen; m_pSwpHints->DeleteAtPos(i); - Insert( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); + InsertHint( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); } - // leere Hints an rIdx.GetIndex ? - else if( nMode & INS_EMPTYEXPAND && - *pEndIdx == *pHt->GetStart() ) + // empty hints at insert position? + else if ( (nMode & IDocumentContentOperations::INS_EMPTYEXPAND) + && (*pEndIdx == *pHt->GetStart()) ) { *pHt->GetStart() = *pHt->GetStart() - nLen; const USHORT nAktLen = m_pSwpHints->Count(); m_pSwpHints->DeleteAtPos(i); - Insert( pHt/* AUTOSTYLES:, nsSetAttrMode::SETATTR_NOHINTADJUST*/ ); + InsertHint( pHt/* AUTOSTYLES:, nsSetAttrMode::SETATTR_NOHINTADJUST*/ ); if ( nAktLen > m_pSwpHints->Count() && i ) { --i; @@ -1745,14 +1807,14 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, continue; } } - if ( !(nMode & INS_NOHINTEXPAND) && + if ( !(nMode & IDocumentContentOperations::INS_NOHINTEXPAND) && rIdx == nLen && *pHt->GetStart() == rIdx.GetIndex() && !pHt->IsDontExpandStartAttr() ) { // Kein Feld, am Absatzanfang, HintExpand m_pSwpHints->DeleteAtPos(i); *pHt->GetStart() = *pHt->GetStart() - nLen; - Insert( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); + InsertHint( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); } } TryDeleteSwpHints(); @@ -1769,7 +1831,6 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, SetCalcHiddenCharFlags(); CHECK_SWPHINTS(this); - return *this; } /************************************************************************* @@ -1782,32 +1843,41 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, |* *************************************************************************/ -void SwTxtNode::Cut( SwTxtNode *pDest, const SwIndex &rStart, xub_StrLen nLen ) +void SwTxtNode::CutText( SwTxtNode * const pDest, + const SwIndex & rStart, const xub_StrLen nLen ) { if(pDest) { SwIndex aDestStt( pDest, pDest->GetTxt().Len() ); - _Cut( pDest, aDestStt, rStart, nLen, FALSE ); + CutImpl( pDest, aDestStt, rStart, nLen, false ); } else - Erase( rStart, nLen ); + { + ASSERT(false, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); + EraseText( rStart, nLen ); + } } -void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, - const SwIndex &rStart, xub_StrLen nLen, BOOL bUpdate ) +void SwTxtNode::CutImpl( SwTxtNode * const pDest, const SwIndex & rDestStart, + const SwIndex & rStart, /*const*/ xub_StrLen nLen, const bool bUpdate ) { if(!pDest) { - Erase( rStart, nLen ); + ASSERT(false, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); + EraseText( rStart, nLen ); return; } // nicht im Dokument verschieben ? if( GetDoc() != pDest->GetDoc() ) { - Copy( pDest, rDestStart, rStart, nLen); - Erase(rStart,nLen); + ASSERT(false, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); + CopyText( pDest, rDestStart, rStart, nLen); + EraseText(rStart, nLen); return; } @@ -1821,48 +1891,46 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, xub_StrLen nTxtStartIdx = rStart.GetIndex(); xub_StrLen nDestStart = rDestStart.GetIndex(); // alte Pos merken - xub_StrLen nInitSize = pDest->m_Text.Len(); - - xub_StrLen *pEndIdx = 0; - xub_StrLen nAttrStartIdx = 0; - SwTxtAttr *pHt = 0; - SwTxtAttr *pNewHt = 0; + const xub_StrLen nInitSize = pDest->m_Text.Len(); // wird in sich selbst verschoben, muss es gesondert behandelt werden !! if( pDest == this ) { + ASSERT(false, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); m_Text.Insert( m_Text, nTxtStartIdx, nLen, nDestStart ); m_Text.Erase( nTxtStartIdx + (nDestStart<nTxtStartIdx ? nLen : 0), nLen ); - xub_StrLen nEnd = rStart.GetIndex() + nLen; - USHORT n; + const xub_StrLen nEnd = rStart.GetIndex() + nLen; // dann suche mal alle Attribute zusammen, die im verschobenen // Bereich liegen. Diese werden in das extra Array verschoben, // damit sich die Indizies beim Updaten nicht veraendern !!! - SwIndexReg aTmpRegArr; SwpHts aArr( 5 ); // 2. Attribute verschieben // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu verschiebenden Bereich liegt - USHORT nAttrCnt = 0, nWhich; - while ( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() && - (nAttrStartIdx = *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))-> - GetStart()) < nEnd ) + USHORT nAttrCnt = 0; + while ( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() ) { - pNewHt = 0; - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(nAttrCnt); + const xub_StrLen nAttrStartIdx = *pHt->GetStart(); + if (!( nAttrStartIdx < nEnd )) + break; + const xub_StrLen * const pEndIdx = pHt->GetEnd(); + const USHORT nWhich = pHt->Which(); + SwTxtAttr *pNewHt = 0; if(nAttrStartIdx < nTxtStartIdx) { // Anfang liegt vor dem Bereich - if( RES_TXTATR_REFMARK != ( nWhich = pHt->Which() ) && + if ( RES_TXTATR_REFMARK != nWhich && !pHt->HasDummyChar() && pEndIdx && *pEndIdx > nTxtStartIdx ) { // Attribut mit einem Bereich // und das Ende des Attribut liegt im Bereich - pNewHt = MakeTxtAttr( pHt->GetAttr(), 0, + pNewHt = MakeTxtAttr( *GetDoc(), pHt->GetAttr(), 0, *pEndIdx > nEnd ? nLen : *pEndIdx - nTxtStartIdx ); @@ -1883,9 +1951,9 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, continue; // while-Schleife weiter, ohne ++ ! } // das Ende liegt dahinter - else if( RES_TXTATR_REFMARK != ( nWhich = pHt->Which() )) + else if (RES_TXTATR_REFMARK != nWhich && !pHt->HasDummyChar()) { - pNewHt = MakeTxtAttr( pHt->GetAttr(), + pNewHt = MakeTxtAttr( *GetDoc(), pHt->GetAttr(), nAttrStartIdx - nTxtStartIdx, !pEndIdx ? 0 : ( *pEndIdx > nEnd @@ -1903,8 +1971,10 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, } if( bUpdate ) + { // Update aller Indizies Update( rDestStart, nLen, FALSE, TRUE ); + } #ifdef CUTNOEXPAND else // wird am Ende eingefuegt, nur die Attribut-Indizies verschieben @@ -1912,10 +1982,10 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, { // check if there was the end of an attribute at the insertion // position: if it is not a field, it must be expanded - for ( n = 0; n < m_pSwpHints->Count(); n++ ) + for ( USHORT n = 0; n < m_pSwpHints->Count(); n++ ) { - pHt = m_pSwpHints->GetTextHint(n); - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(n); + const xub_StrLen * const pEndIdx = pHt->GetEnd(); if ( pEndIdx && (*pEndIdx == nInitSize) ) { *pEndIdx = *pEndIdx + nLen; @@ -1931,33 +2001,39 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, // dann setze die kopierten/geloeschten Attribute in den Node if( nDestStart <= nTxtStartIdx ) + { nTxtStartIdx = nTxtStartIdx + nLen; + } else + { nDestStart = nDestStart - nLen; + } - for( n = 0; n < aArr.Count(); ++n ) + for ( USHORT n = 0; n < aArr.Count(); ++n ) { - pNewHt = aArr[n]; + SwTxtAttr *const pNewHt = aArr[n]; *pNewHt->GetStart() = nDestStart + *pNewHt->GetStart(); - if( 0 != ( pEndIdx = pNewHt->GetEnd() )) + xub_StrLen * const pEndIdx = pNewHt->GetEnd(); + if ( pEndIdx ) + { *pEndIdx = nDestStart + *pEndIdx; - Insert( pNewHt, nsSetAttrMode::SETATTR_NOTXTATRCHR ); + } + InsertHint( pNewHt, nsSetAttrMode::SETATTR_NOTXTATRCHR ); } } else { - xub_StrLen i = nInitSize - nDestStart; pDest->m_Text.Insert( m_Text, nTxtStartIdx, nLen, nDestStart ); m_Text.Erase( nTxtStartIdx, nLen ); - nLen = pDest->m_Text.Len() - nDestStart - i; // update w/ current size! + nLen = pDest->m_Text.Len() - nInitSize; // update w/ current size! if( !nLen ) // String nicht gewachsen ?? return; - i = 0; - if( bUpdate ) + { // Update aller Indizies pDest->Update( rDestStart, nLen, FALSE, TRUE); + } #ifdef CUTNOEXPAND else // wird am Ende eingefuegt, nur die Attribut-Indizies verschieben @@ -1967,8 +2043,8 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, // position: if it is not a field, it must be expanded for ( USHORT n = 0; n < pDest->m_pSwpHints->Count(); n++ ) { - pHt = pDest->m_pSwpHints->GetTextHint(n); - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = pDest->m_pSwpHints->GetTextHint(n); + const xub_StrLen * const pEndIdx = pHt->GetEnd(); if ( pEndIdx && (*pEndIdx == nInitSize) ) { *pEndIdx = *pEndIdx + nLen; @@ -1978,11 +2054,14 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, #endif CHECK_SWPHINTS(pDest); - USHORT nEnd = rStart.GetIndex() + nLen; - SwDoc* pOtherDoc = pDest->GetDoc(); - if( pOtherDoc == GetDoc() ) - pOtherDoc = 0; - const BOOL bUndoNodes = !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); + const xub_StrLen nEnd = rStart.GetIndex() + nLen; + SwDoc* const pOtherDoc = (pDest->GetDoc() != GetDoc()) + ? pDest->GetDoc() : 0; + const bool bUndoNodes = + !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); + + ASSERT(!pOtherDoc, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); // harte Absatz umspannende Attribute kopieren if( HasSwAttrSet() ) @@ -2002,30 +2081,37 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, pDest->SetAttr( aCharSet, nDestStart, nDestStart + nLen ); } else + { GetpSwAttrSet()->CopyToModify( *pDest ); + } } // 2. Attribute verschieben // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu verschiebenden Bereich liegt - USHORT nAttrCnt = 0, nWhich; - while ( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() && - ( (nAttrStartIdx = *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))-> - GetStart()) < nEnd ) ) + USHORT nAttrCnt = 0; + while ( m_pSwpHints && (nAttrCnt < m_pSwpHints->Count()) ) { - pNewHt = 0; - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(nAttrCnt); + const xub_StrLen nAttrStartIdx = *pHt->GetStart(); + if (!( nAttrStartIdx < nEnd )) + break; + const xub_StrLen * const pEndIdx = pHt->GetEnd(); + const USHORT nWhich = pHt->Which(); + SwTxtAttr *pNewHt = 0; + // if the hint has a dummy character, then it must not be split! if(nAttrStartIdx < nTxtStartIdx) { // Anfang liegt vor dem Bereich - if( ( RES_TXTATR_REFMARK != ( nWhich = pHt->Which() ) + if( !pHt->HasDummyChar() && ( RES_TXTATR_REFMARK != nWhich || bUndoNodes ) && pEndIdx && *pEndIdx > nTxtStartIdx ) { // Attribut mit einem Bereich // und das Ende des Attribut liegt im Bereich - pNewHt = pDest->MakeTxtAttr( pHt->GetAttr(), nDestStart, - nDestStart + ( + pNewHt = MakeTxtAttr( *pDest->GetDoc(), pHt->GetAttr(), + nDestStart, + nDestStart + ( *pEndIdx > nEnd ? nLen : *pEndIdx - nTxtStartIdx ) ); @@ -2034,33 +2120,40 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, else { // der Anfang liegt vollstaendig im Bereich - nWhich = pHt->Which(); if( !pEndIdx || *pEndIdx < nEnd || - ( !pOtherDoc && !bUndoNodes && RES_TXTATR_REFMARK - == nWhich ) ) + (!pOtherDoc && !bUndoNodes && RES_TXTATR_REFMARK == nWhich) + || pHt->HasDummyChar() ) { // do not delete note and later add it -> sidebar flickering if ( GetDoc()->GetDocShell() ) + { GetDoc()->GetDocShell()->Broadcast( SfxSimpleHint(SFX_HINT_USER04)); + } // Attribut verschieben m_pSwpHints->Delete( pHt ); // die Start/End Indicies neu setzen *pHt->GetStart() = nDestStart + (nAttrStartIdx - nTxtStartIdx); if( pEndIdx ) + { *pHt->GetEnd() = nDestStart + ( *pEndIdx > nEnd ? nLen : *pEndIdx - nTxtStartIdx ); - pDest->Insert( pHt, nsSetAttrMode::SETATTR_NOTXTATRCHR | nsSetAttrMode::SETATTR_DONTREPLACE ); + } + pDest->InsertHint( pHt, + nsSetAttrMode::SETATTR_NOTXTATRCHR + | nsSetAttrMode::SETATTR_DONTREPLACE ); if ( GetDoc()->GetDocShell() ) + { GetDoc()->GetDocShell()->Broadcast( SfxSimpleHint(SFX_HINT_USER04)); + } continue; // while-Schleife weiter, ohne ++ ! } // das Ende liegt dahinter else if( RES_TXTATR_REFMARK != nWhich || bUndoNodes ) { - pNewHt = MakeTxtAttr( pHt->GetAttr(), + pNewHt = MakeTxtAttr( *GetDoc(), pHt->GetAttr(), nDestStart + (nAttrStartIdx - nTxtStartIdx), !pEndIdx ? 0 : nDestStart + ( *pEndIdx > nEnd @@ -2070,8 +2163,13 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, } if ( pNewHt ) { - if( pDest->Insert( pNewHt, nsSetAttrMode::SETATTR_NOTXTATRCHR | nsSetAttrMode::SETATTR_DONTREPLACE )) + const bool bSuccess( pDest->InsertHint( pNewHt, + nsSetAttrMode::SETATTR_NOTXTATRCHR + | nsSetAttrMode::SETATTR_DONTREPLACE ) ); + if (bSuccess) + { lcl_CopyHint( nWhich, pHt, pNewHt, pOtherDoc, pDest ); + } } ++nAttrCnt; } @@ -2082,29 +2180,35 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, if( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() ) { SwpHts aArr( 5 ); - for ( ; nAttrCnt < m_pSwpHints->Count() && - nEnd == *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))->GetStart(); - ++nAttrCnt ) + while ( nAttrCnt < m_pSwpHints->Count() ) { - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(nAttrCnt); + if ( nEnd != *pHt->GetStart() ) + break; + const xub_StrLen * const pEndIdx = pHt->GetEnd(); if ( pEndIdx && *pEndIdx == nEnd ) { aArr.C40_INSERT( SwTxtAttr, pHt, aArr.Count() ); m_pSwpHints->Delete( pHt ); - --nAttrCnt; + } + else + { + ++nAttrCnt; } } Update( rStart, nLen, TRUE, TRUE ); - for( nAttrCnt = 0; nAttrCnt < aArr.Count(); ++nAttrCnt ) + for ( USHORT n = 0; n < aArr.Count(); ++n ) { - pHt = aArr[ nAttrCnt ]; + SwTxtAttr * const pHt = aArr[ n ]; *pHt->GetStart() = *pHt->GetEnd() = rStart.GetIndex(); - Insert( pHt ); + InsertHint( pHt ); } } else + { Update( rStart, nLen, TRUE, TRUE ); + } CHECK_SWPHINTS(this); } @@ -2119,98 +2223,112 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, } -SwTxtNode& SwTxtNode::Erase(const SwIndex &rIdx, xub_StrLen nCount, - const USHORT nMode ) +void SwTxtNode::EraseText(const SwIndex &rIdx, const xub_StrLen nCount, + const IDocumentContentOperations::InsertFlags nMode ) { - ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::Erase: invalid index." ); + ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::EraseText: invalid index." ); - const xub_StrLen nCnt = STRING_LEN == nCount - ? m_Text.Len() - rIdx.GetIndex() : nCount; - m_Text.Erase( rIdx.GetIndex(), nCnt ); + const xub_StrLen nStartIdx = rIdx.GetIndex(); + const xub_StrLen nCnt = (STRING_LEN == nCount) + ? m_Text.Len() - nStartIdx : nCount; + const xub_StrLen nEndIdx = nStartIdx + nCnt; + m_Text.Erase( nStartIdx, nCnt ); /* GCAttr(); alle leeren weggwerfen ist zu brutal. * Es duerfen nur die wegggeworfen werden, * die im Bereich liegen und nicht am Ende des Bereiches liegen */ - // check m_pSwpHints because fields and FlyFrames delete text (recursion!) for ( USHORT i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { SwTxtAttr *pHt = m_pSwpHints->GetTextHint(i); - const xub_StrLen nHtStt = *pHt->GetStart(); + const xub_StrLen nHintStart = *pHt->GetStart(); - if( nHtStt < rIdx.GetIndex() ) + if ( nHintStart < nStartIdx ) continue; - // TextFelder und FlyFrames loeschen Text (Rekursion)!! - const xub_StrLen nEndIdx = rIdx.GetIndex() + nCnt; - if( nHtStt > nEndIdx ) - // die Hints sind nach Ende sortiert, also ist Start - // vom Hint groesser als EndIdx dann Abbrechen - break; + if ( nHintStart > nEndIdx ) + break; // hints are sorted by end, so break here const xub_StrLen* pHtEndIdx = pHt->GetEnd(); const USHORT nWhich = pHt->Which(); if( !pHtEndIdx ) { + ASSERT(pHt->HasDummyChar(), + "attribute with neither end nor CH_TXTATR?"); if (isTXTATR(nWhich) && - (nHtStt >= rIdx.GetIndex()) && (nHtStt < nEndIdx)) + (nHintStart >= nStartIdx) && (nHintStart < nEndIdx)) { m_pSwpHints->DeleteAtPos(i); - // Damit im Dtor der TxtAttr ohne End die CH_TXTATR nicht - // geloescht werden... - *(pHt->GetStart()) = USHRT_MAX; DestroyAttr( pHt ); --i; } continue; } + ASSERT (!( (nHintStart < nEndIdx) && (*pHtEndIdx > nEndIdx) + && pHt->HasDummyChar() ) + // next line: deleting exactly dummy char: DeleteAttributes + || ((nHintStart == nStartIdx) && (nHintStart + 1 == nEndIdx)), + "ERROR: deleting left-overlapped attribute with CH_TXTATR"); + // Delete the hint if: // 1. The hint ends before the deletion end position or // 2. The hint ends at the deletion end position and // we are not in empty expand mode and // the hint is a [toxmark|refmark|ruby] text attribute - if( *pHtEndIdx >= nEndIdx && - !( - *pHtEndIdx == nEndIdx && - !(INS_EMPTYEXPAND & nMode) && - (nWhich == RES_TXTATR_TOXMARK || nWhich == RES_TXTATR_REFMARK || - // --> FME 2006-03-03 #i62668# Ruby text attribute has to be treated - // just like toxmark and refmarks - nWhich == RES_TXTATR_CJK_RUBY) ) + // 3. deleting exactly the dummy char of an hint with end and dummy + // char deletes the hint + if ( (*pHtEndIdx < nEndIdx) + || ( (*pHtEndIdx == nEndIdx) && + !(IDocumentContentOperations::INS_EMPTYEXPAND & nMode) && + ( (RES_TXTATR_TOXMARK == nWhich) || + (RES_TXTATR_REFMARK == nWhich) || + // --> FME 2006-03-03 #i62668# Ruby text attribute must be + // treated just like toxmark and refmarks + (RES_TXTATR_CJK_RUBY == nWhich) ) ) // <-- - ) - continue; - - m_pSwpHints->DeleteAtPos(i); - DestroyAttr( pHt ); - --i; +#if 0 + || ( (nHintStart == nStartIdx) && + (nHintStart + 1 == nEndIdx)&& +#else // generalize this to left-overlapped dummy char hints (see ASSERT) + || ( (nHintStart < nEndIdx) && +#endif + pHt->HasDummyChar() ) + ) + { + m_pSwpHints->DeleteAtPos(i); + DestroyAttr( pHt ); + --i; + } } + ASSERT(rIdx.GetIndex() == nStartIdx, "huh? start index has changed?"); + TryDeleteSwpHints(); Update( rIdx, nCnt, TRUE ); if( 1 == nCnt ) { - SwDelChr aHint( rIdx.GetIndex() ); + SwDelChr aHint( nStartIdx ); SwModify::Modify( 0, &aHint ); } else { - SwDelTxt aHint( rIdx.GetIndex(), nCnt ); + SwDelTxt aHint( nStartIdx, nCnt ); SwModify::Modify( 0, &aHint ); } + ASSERT(rIdx.GetIndex() == nStartIdx, "huh? start index has changed?"); + // By deleting a character, the hidden flags // at the TxtNode can become invalid: SetCalcHiddenCharFlags(); CHECK_SWPHINTS(this); - return *this; } /*********************************************************************** @@ -2229,9 +2347,7 @@ void SwTxtNode::GCAttr() if ( !HasHints() ) return; - const SwTxtAttr *pHt = 0; - const xub_StrLen *pEndIdx = 0; - BOOL bChanged = FALSE; + bool bChanged = false; USHORT nMin = m_Text.Len(), nMax = 0; BOOL bAll = nMin != 0; // Bei leeren Absaetzen werden nur die @@ -2239,21 +2355,23 @@ void SwTxtNode::GCAttr() for ( USHORT i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { - pHt = (*m_pSwpHints)[i]; + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(i); // wenn Ende und Start gleich sind --> loeschen - pEndIdx = pHt->GetEnd(); - if( pEndIdx && (*pEndIdx == *pHt->GetStart()) + const xub_StrLen * const pEndIdx = pHt->GetEnd(); + if (pEndIdx && !pHt->HasDummyChar() && (*pEndIdx == *pHt->GetStart()) && ( bAll || pHt->Which() == RES_TXTATR_INETFMT ) ) { - bChanged = TRUE; + bChanged = true; nMin = Min( nMin, *pHt->GetStart() ); nMax = Max( nMax, *pHt->GetEnd() ); DestroyAttr( m_pSwpHints->Cut(i) ); --i; } else - ((SwTxtAttr*)pHt)->SetDontExpand( FALSE ); + { + pHt->SetDontExpand( false ); + } } TryDeleteSwpHints(); @@ -2266,6 +2384,7 @@ void SwTxtNode::GCAttr() SwModify::Modify( 0, &aNew ); } } + // #i23726# SwNumRule* SwTxtNode::_GetNumRule(BOOL bInParent) const { @@ -2608,30 +2727,25 @@ SwCntntNode* SwTxtNode::AppendNode( const SwPosition & rPos ) /************************************************************************* * SwTxtNode::GetTxtAttr - * - * Diese Methode liefert nur Textattribute auf der Position nIdx - * zurueck, die kein EndIdx besitzen und denselben Which besitzen. - * Ueblicherweise steht an dieser Position ein CH_TXTATR. - * Bei RES_TXTATR_END entfaellt die Pruefung auf den Which-Wert. *************************************************************************/ -SwTxtAttr *SwTxtNode::GetTxtAttr( const xub_StrLen nIdx, - const USHORT nWhichHt ) const +SwTxtAttr * SwTxtNode::GetTxtAttrForCharAt( const xub_StrLen nIndex, + const RES_TXTATR nWhich ) const { if ( HasHints() ) { for ( USHORT i = 0; i < m_pSwpHints->Count(); ++i ) { - SwTxtAttr *pPos = m_pSwpHints->GetTextHint(i); - const xub_StrLen nStartPos = *pPos->GetStart(); - if( nIdx < nStartPos ) + SwTxtAttr * const pHint = m_pSwpHints->GetTextHint(i); + const xub_StrLen nStartPos = *pHint->GetStart(); + if ( nIndex < nStartPos ) + { return 0; - if( nIdx == nStartPos && !pPos->GetEnd() ) + } + if ( (nIndex == nStartPos) && pHint->HasDummyChar() ) { - if( RES_TXTATR_END == nWhichHt || nWhichHt == pPos->Which() ) - return pPos; - else - return 0; + return ( RES_TXTATR_END == nWhich || nWhich == pHint->Which() ) + ? pHint : 0; } } } @@ -2843,7 +2957,8 @@ void SwTxtNode::Replace0xFF( XubString& rTxt, xub_StrLen& rTxtStt, xub_StrLen nPos = rTxt.Search( cSrchChr ); while( STRING_NOTFOUND != nPos && nPos < nEndPos ) { - const SwTxtAttr* pAttr = GetTxtAttr( rTxtStt + nPos ); + const SwTxtAttr* const pAttr = + GetTxtAttrForCharAt( rTxtStt + nPos ); if( pAttr ) { switch( pAttr->Which() ) @@ -2861,11 +2976,6 @@ void SwTxtNode::Replace0xFF( XubString& rTxt, xub_StrLen& rTxtStt, } ++rTxtStt; break; - case RES_TXTATR_HARDBLANK: - rTxt.SetChar( nPos, ((SwTxtHardBlank*)pAttr)->GetChar() ); - ++nPos; - ++nEndPos; - break; case RES_TXTATR_FTN: rTxt.Erase( nPos, 1 ); if( bExpandFlds ) @@ -2967,7 +3077,7 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, SwScriptInfo::MaskHiddenRanges( *this, sTmpText, 0, sTmpText.Len(), cChar ); sTmpText = sTmpText.Copy( nIdx, nLen ); - rDestNd.Insert( sTmpText, aDestIdx ); + rDestNd.InsertText( sTmpText, aDestIdx ); nLen = aDestIdx.GetIndex() - nDestStt; // alle FontAttribute mit CHARSET Symbol in dem Bereich setzen @@ -2977,25 +3087,28 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, for ( USHORT i = 0; i < m_pSwpHints->Count(); i++ ) { const SwTxtAttr* pHt = (*m_pSwpHints)[i]; - xub_StrLen nAttrStartIdx; - USHORT nWhich = pHt->Which(); - if( nIdx + nLen <= ( nAttrStartIdx = *pHt->GetStart() ) ) + const xub_StrLen nAttrStartIdx = *pHt->GetStart(); + const USHORT nWhich = pHt->Which(); + if (nIdx + nLen <= nAttrStartIdx) break; // ueber das Textende - const SvxFontItem* pFont; const xub_StrLen *pEndIdx = pHt->GetEnd(); if( pEndIdx && *pEndIdx > nIdx && ( RES_CHRATR_FONT == nWhich || RES_TXTATR_CHARFMT == nWhich || - RES_TXTATR_AUTOFMT == nWhich ) && - 0 != ( pFont = static_cast<const SvxFontItem*>(CharFmt::GetItem( *pHt, RES_CHRATR_FONT )) ) && - RTL_TEXTENCODING_SYMBOL == pFont->GetCharSet() ) + RES_TXTATR_AUTOFMT == nWhich )) { - // Attribut liegt im Bereich, also kopieren - rDestNd.InsertItem( *pFont, nInsPos + nAttrStartIdx, - nInsPos + *pEndIdx ); + const SvxFontItem* const pFont = + static_cast<const SvxFontItem*>( + CharFmt::GetItem( *pHt, RES_CHRATR_FONT )); + if ( pFont && RTL_TEXTENCODING_SYMBOL == pFont->GetCharSet() ) + { + // attribute in area => copy + rDestNd.InsertItem( *const_cast<SvxFontItem*>(pFont), + nInsPos + nAttrStartIdx, nInsPos + *pEndIdx ); + } } - else if( !pEndIdx && nAttrStartIdx >= nIdx ) + else if ( pHt->HasDummyChar() && (nAttrStartIdx >= nIdx) ) { aDestIdx = nInsPos + nAttrStartIdx; switch( nWhich ) @@ -3006,20 +3119,15 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, if( aExpand.Len() ) { aDestIdx++; // dahinter einfuegen; - rDestNd.Insert( aExpand, aDestIdx ); + rDestNd.InsertText( aExpand, aDestIdx ); aDestIdx = nInsPos + nAttrStartIdx; nInsPos = nInsPos + aExpand.Len(); } - rDestNd.Erase( aDestIdx, 1 ); + rDestNd.EraseText( aDestIdx, 1 ); --nInsPos; } break; - case RES_TXTATR_HARDBLANK: - rDestNd.m_Text.SetChar( nInsPos + nAttrStartIdx, - ((SwTxtHardBlank*)pHt)->GetChar() ); - break; - case RES_TXTATR_FTN: { if ( bWithFtn ) @@ -3036,23 +3144,25 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, GetNumStr( rFtn.GetNumber() ); if( sExpand.Len() ) { - aDestIdx++; // dahinter einfuegen; - rDestNd.InsertItem( SvxEscapementItem( - SVX_ESCAPEMENT_SUPERSCRIPT ), + aDestIdx++; // insert behind + SvxEscapementItem aItem( + SVX_ESCAPEMENT_SUPERSCRIPT ); + rDestNd.InsertItem(aItem, aDestIdx.GetIndex(), aDestIdx.GetIndex() ); - rDestNd.Insert( sExpand, aDestIdx, INS_EMPTYEXPAND ); + rDestNd.InsertText( sExpand, aDestIdx, + IDocumentContentOperations::INS_EMPTYEXPAND); aDestIdx = nInsPos + nAttrStartIdx; nInsPos = nInsPos + sExpand.Len(); } } - rDestNd.Erase( aDestIdx, 1 ); + rDestNd.EraseText( aDestIdx, 1 ); --nInsPos; } break; default: - rDestNd.Erase( aDestIdx, 1 ); + rDestNd.EraseText( aDestIdx, 1 ); --nInsPos; } } @@ -3062,7 +3172,7 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, if( bWithNum ) { aDestIdx = nDestStt; - rDestNd.Insert( GetNumString(), aDestIdx ); + rDestNd.InsertText( GetNumString(), aDestIdx ); } if ( nHiddenChrs > 0 ) @@ -3076,7 +3186,7 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, while ( nIndex < rDestNd.GetTxt().Len() && cChar == rDestNd.GetTxt().GetChar( ++nIndex ) ) ; - rDestNd.Erase( aDestIdx, nIndex - aDestIdx.GetIndex() ); + rDestNd.EraseText( aDestIdx, nIndex - aDestIdx.GetIndex() ); } else ++aDestIdx; @@ -3196,55 +3306,35 @@ XubString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen, } /************************************************************************* - * SwTxtNode::GetExpandTxt + * SwTxtNode::ReplaceText *************************************************************************/ -// Felder werden expandiert: -void SwTxtNode::Replace( const SwIndex& rStart, xub_Unicode cCh ) -{ - ASSERT( rStart.GetIndex() < m_Text.Len(), - "SwTxtNode::Replace: invalid index." ); - - SwTxtAttr* pHt; - if ( ( CH_TXTATR_BREAKWORD == m_Text.GetChar( rStart.GetIndex() ) || - CH_TXTATR_INWORD == m_Text.GetChar( rStart.GetIndex() )) && - 0 != ( pHt = GetTxtAttr( rStart.GetIndex() ) )) - { - Delete( pHt ); - m_Text.Insert( cCh, rStart.GetIndex() ); - } - else - { - m_Text.SetChar( rStart.GetIndex(), cCh ); - } - - SwDelTxt aDelHint( rStart.GetIndex(), 1 ); - SwModify::Modify( 0, &aDelHint ); - - SwInsTxt aHint( rStart.GetIndex(), 1 ); - SwModify::Modify( 0, &aHint ); -} - - -void SwTxtNode::Replace( const SwIndex& rStart, xub_StrLen nLen, - const XubString& rText ) +void SwTxtNode::ReplaceText( const SwIndex& rStart, const xub_StrLen nDelLen, + const XubString& rText ) { ASSERT( rStart.GetIndex() < m_Text.Len() && - rStart.GetIndex() + nLen <= m_Text.Len(), - "ausserhalb des Strings" ); - SwTxtAttr* pHt; + rStart.GetIndex() + nDelLen <= m_Text.Len(), + "SwTxtNode::ReplaceText: index out of bounds" ); const xub_StrLen nStartPos = rStart.GetIndex(); - xub_StrLen nEnde = nStartPos + nLen; - xub_StrLen nDelLen = nLen; - for( xub_StrLen nPos = nStartPos; nPos < nEnde; ++nPos ) + xub_StrLen nEndPos = nStartPos + nDelLen; + xub_StrLen nLen = nDelLen; + for ( xub_StrLen nPos = nStartPos; nPos < nEndPos; ++nPos ) { - if ( ( CH_TXTATR_BREAKWORD == m_Text.GetChar( nPos ) || - CH_TXTATR_INWORD == m_Text.GetChar( nPos )) && - 0 != ( pHt = GetTxtAttr( nPos ) )) + if ( ( CH_TXTATR_BREAKWORD == m_Text.GetChar( nPos ) ) || + ( CH_TXTATR_INWORD == m_Text.GetChar( nPos ) ) ) { - Delete( pHt ); - --nEnde; - --nLen; + SwTxtAttr *const pHint = GetTxtAttrForCharAt( nPos ); + if (pHint) + { + ASSERT (!( pHint->GetEnd() && pHint->HasDummyChar() + && (*pHint->GetStart() < nEndPos) + && (*pHint->GetEnd() > nEndPos) ), + "ReplaceText: ERROR: " + "deleting left-overlapped attribute with CH_TXTATR"); + DeleteAttribute( pHint ); + --nEndPos; + --nLen; + } } } @@ -3259,20 +3349,21 @@ void SwTxtNode::Replace( const SwIndex& rStart, xub_StrLen nLen, ((SwIndex&)rStart)++; m_Text.Erase( rStart.GetIndex(), nLen - 1 ); - Update( rStart, nLen - 1, TRUE ); + Update( rStart, nLen - 1, true ); XubString aTmpTxt( rText ); aTmpTxt.Erase( 0, 1 ); m_Text.Insert( aTmpTxt, rStart.GetIndex() ); - Update( rStart, aTmpTxt.Len(), FALSE ); + Update( rStart, aTmpTxt.Len(), false ); } else { m_Text.Erase( nStartPos, nLen ); - Update( rStart, nLen, TRUE ); + Update( rStart, nLen, true ); m_Text.Insert( rText, nStartPos ); - Update( rStart, rText.Len(), FALSE ); + Update( rStart, rText.Len(), false ); } + SetIgnoreDontExpand( bOldExpFlg ); SwDelTxt aDelHint( nStartPos, nDelLen ); SwModify::Modify( 0, &aDelHint ); diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx index c70d8aaa4a14..3c2a643099cb 100644 --- a/sw/source/core/txtnode/swfont.cxx +++ b/sw/source/core/txtnode/swfont.cxx @@ -445,7 +445,9 @@ SwFont::SwFont( const SwFont &rFont ) pBackColor = rFont.pBackColor ? new Color( *rFont.pBackColor ) : NULL; aUnderColor = rFont.GetUnderColor(); aOverColor = rFont.GetOverColor(); - nToxCnt = nRefCnt = 0; + nToxCnt = 0; + nRefCnt = 0; + m_nMetaCount = 0; bFntChg = rFont.bFntChg; bOrgChg = rFont.bOrgChg; bPaintBlank = rFont.bPaintBlank; @@ -461,7 +463,9 @@ SwFont::SwFont( const SwAttrSet* pAttrSet, const IDocumentSettingAccess* pIDocumentSettingAccess ) { nActual = SW_LATIN; - nToxCnt = nRefCnt = 0; + nToxCnt = 0; + nRefCnt = 0; + m_nMetaCount = 0; bPaintBlank = FALSE; bPaintWrong = FALSE; bURL = FALSE; @@ -590,7 +594,9 @@ SwFont& SwFont::operator=( const SwFont &rFont ) pBackColor = rFont.pBackColor ? new Color( *rFont.pBackColor ) : NULL; aUnderColor = rFont.GetUnderColor(); aOverColor = rFont.GetOverColor(); - nToxCnt = nRefCnt = 0; + nToxCnt = 0; + nRefCnt = 0; + m_nMetaCount = 0; bFntChg = rFont.bFntChg; bOrgChg = rFont.bOrgChg; bPaintBlank = rFont.bPaintBlank; diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 1b5fc81d366f..12f8e210e7c5 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -65,6 +65,7 @@ #include <frmfmt.hxx> #include <ftnidx.hxx> #include <fmtruby.hxx> +#include <fmtmeta.hxx> #include <breakit.hxx> #include <doc.hxx> #include <errhdl.hxx> @@ -107,142 +108,497 @@ SwpHints::SwpHints() { } +struct TxtAttrDeleter +{ + SwAttrPool & m_rPool; + TxtAttrDeleter( SwDoc & rDoc ) : m_rPool( rDoc.GetAttrPool() ) { } + void operator() (SwTxtAttr * const pAttr) + { + SwTxtAttr::Destroy( pAttr, m_rPool ); + } +}; -// This function takes care for the following text attribute: -// RES_TXTATR_CHARFMT, RES_TXTATR_INETFMT, RES_TXTATR_AUTOFMT, and -// RES_TXTATR_CJK_RUBY. These attributes have to be handled in a -// special way (Portion building). -// 1. New attribute is RES_TXTATR_AUTOFMT or RES_TXTATR_CHARFMT: -// The new attribute will be split by any existing RES_TXTATR_AUTOFMT, -// RES_TXTATR_CHARFMT or RES_TXTATR_INETFMT. The new attribute itself will -// split any existing RES_TXTATR_AUTOFMT or RES_TXTATR_CHARFMT. -// 2. New attribute is RES_TXTATR_INETFMT: -// The new attribute will split any existing RES_TXTATR_AUTOFMT or RES_TXTATR_CHARFMT. -// The new attribute will suppress any existing RES_TXTATR_INETFMT. -// 3. New attribute is RES_TXTATR_CJK_RUBY: -// The new attribute will suppress any existing RES_TXTATR_CJK_RUBY. +struct TxtAttrContains +{ + xub_StrLen m_nPos; + TxtAttrContains( const xub_StrLen nPos ) : m_nPos( nPos ) { } + bool operator() (SwTxtAttrEnd * const pAttr) + { + return (*pAttr->GetStart() < m_nPos) && (m_nPos < *pAttr->GetEnd()); + } +}; -void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMode ) +// a: |-----| +// b: +// |---| => valid: b before a +// |-----| => valid: start == end; b before a +// |---------| => invalid: overlap (1) +// |-----------| => valid: same end; b around a +// |-----------------| => valid: b around a +// |---| => valid; same start; b within a +// |-----| => valid; same start and end; b around or within a? +// |-----------| => valid: same start: b around a +// |-| => valid: b within a +// |---| => valid: same end; b within a +// |---------| => invalid: overlap (2) +// |-----| => valid: end == start; b after a +// |---| => valid: b after a +// ===> 2 invalid overlap cases +static +bool isOverlap(const xub_StrLen nStart1, const xub_StrLen nEnd1, + const xub_StrLen nStart2, const xub_StrLen nEnd2) { - ASSERT( RES_TXTATR_CHARFMT == rNewHint.Which() || - RES_TXTATR_INETFMT == rNewHint.Which() || - RES_TXTATR_AUTOFMT == rNewHint.Which() || - RES_TXTATR_CJK_RUBY == rNewHint.Which(), - "Expecting CHARFMT or AUTOFMT or INETFMT or RUBY" ) + return + ((nStart1 > nStart2) && (nStart1 < nEnd2) && (nEnd1 > nEnd2)) // (1) + || ((nStart1 < nStart2) && (nStart2 < nEnd1) && (nEnd1 < nEnd2)); // (2) +} - const USHORT nWhich = rNewHint.Which(); +static +bool isNestedAny(const xub_StrLen nStart1, const xub_StrLen nEnd1, + const xub_StrLen nStart2, const xub_StrLen nEnd2) +{ + return (nStart1 == nStart2) // in this case ends do not matter + || ((nStart1 < nStart2) ? (nEnd1 >= nEnd2) : (nEnd1 <= nEnd2)); +} - const xub_StrLen nThisStart = *rNewHint.GetStart(); - const xub_StrLen nThisEnd = *rNewHint.GetEnd(); - const bool bNoLengthAttribute = nThisStart == nThisEnd; +static +bool isSelfNestable(const USHORT nWhich) +{ + if ((RES_TXTATR_INETFMT == nWhich) || + (RES_TXTATR_CJK_RUBY == nWhich)) + return false; + ASSERT((RES_TXTATR_META == nWhich) || + (RES_TXTATR_METAFIELD == nWhich), "???"); + return true; +} - std::vector<SwTxtAttr*> aInsDelHints; - std::vector<SwTxtAttr*>::iterator aIter; +static +bool isSplittable(const USHORT nWhich) +{ + if ((RES_TXTATR_INETFMT == nWhich) || + (RES_TXTATR_CJK_RUBY == nWhich)) + return true; + ASSERT((RES_TXTATR_META == nWhich) || + (RES_TXTATR_METAFIELD == nWhich), "???"); + return false; +} - // - // 1. Some attributes are not allowed to overlap. - // They should displace attributes of the same kind. - // This is a special case for RES_TXTATR_INETFMT and - // RES_TXTATR_CJK_RUBY. - // - if ( RES_TXTATR_INETFMT == nWhich || RES_TXTATR_CJK_RUBY == nWhich ) +enum Split_t { FAIL, SPLIT_NEW, SPLIT_OTHER }; +/** + Calculate splitting policy for overlapping hints, based on what kind of + hint is inserted, and what kind of existing hint overlaps. + */ +static Split_t +splitPolicy(const USHORT nWhichNew, const USHORT nWhichOther) +{ + if (!isSplittable(nWhichOther)) { - for ( USHORT i = 0; i < Count(); ++i ) + if (!isSplittable(nWhichNew)) + return FAIL; + else + return SPLIT_NEW; + } + else + { + if ((RES_TXTATR_INETFMT == nWhichNew) && + (RES_TXTATR_CJK_RUBY == nWhichOther)) + return SPLIT_NEW; + else + return SPLIT_OTHER; + } +} + +static void +lcl_InitINetFmt(SwTxtNode & rNode, SwTxtINetFmt * pNew) +{ + pNew->ChgTxtNode(&rNode); + SwCharFmt * const pFmt( + rNode.GetDoc()->GetCharFmtFromPool(RES_POOLCHR_INET_NORMAL) ); + pFmt->Add( pNew ); +} + +static void +lcl_InitRuby(SwTxtNode & rNode, SwTxtRuby * pNew) +{ + pNew->ChgTxtNode(&rNode); + SwCharFmt * const pFmt( + rNode.GetDoc()->GetCharFmtFromPool(RES_POOLCHR_RUBYTEXT) ); + pFmt->Add( pNew ); +} + +/** + Create a new nesting text hint. + */ +static SwTxtAttrNesting * +MakeTxtAttrNesting(SwTxtNode & rNode, SwTxtAttrNesting & rNesting, + const xub_StrLen nStart, const xub_StrLen nEnd) +{ + SwTxtAttr * const pNew( MakeTxtAttr( + *rNode.GetDoc(), rNesting.GetAttr(), nStart, nEnd ) ); + switch (pNew->Which()) + { + case RES_TXTATR_INETFMT: { - SwTxtAttr* pOther = GetTextHint(i); + lcl_InitINetFmt(rNode, static_cast<SwTxtINetFmt*>(pNew)); + break; + } + case RES_TXTATR_CJK_RUBY: + { + lcl_InitRuby(rNode, static_cast<SwTxtRuby*>(pNew)); + break; + } + default: + ASSERT(false, "MakeTxtAttrNesting: what the hell is that?"); + break; + } + return static_cast<SwTxtAttrNesting*>(pNew); +} - if ( nWhich == pOther->Which() ) - { - xub_StrLen nOtherStart = *pOther->GetStart(); - const xub_StrLen nOtherEnd = *pOther->GetEnd(); +typedef ::std::vector<SwTxtAttrNesting *> NestList_t; - // Check if start of new attribute overlaps with pOther. - // Split pOther if necessary: - if ( nOtherStart < nThisStart && nThisStart < nOtherEnd ) - { - SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), nOtherStart, nThisStart ); - aInsDelHints.push_back( pNewAttr ); +static void +lcl_DoSplitNew(NestList_t & rSplits, SwTxtNode & rNode, + const xub_StrLen nNewStart, + const xub_StrLen nOtherStart, const xub_StrLen nOtherEnd, bool bOtherDummy) +{ + const bool bSplitAtStart(nNewStart < nOtherStart); + const xub_StrLen nSplitPos( (bSplitAtStart) ? nOtherStart : nOtherEnd ); + // first find the portion that is split (not necessarily the last one!) + NestList_t::iterator const iter( + ::std::find_if( rSplits.begin(), rSplits.end(), + TxtAttrContains(nSplitPos) ) ); + if (iter != rSplits.end()) // already split here? + { + const xub_StrLen nStartPos( // skip other's dummy character! + (bSplitAtStart && bOtherDummy) ? nSplitPos + 1 : nSplitPos ); + SwTxtAttrNesting * const pNew( MakeTxtAttrNesting( + rNode, **iter, nStartPos, *(*iter)->GetEnd() ) ); + *(*iter)->GetEnd() = nSplitPos; + rSplits.insert(iter + 1, pNew); + } +} - NoteInHistory( pOther ); - *pOther->GetStart() = nThisStart; - NoteInHistory( pOther, true ); - nOtherStart = nThisStart; - } +/** + Insert nesting hint into the hints array. Also calls NoteInHistory. + @param rNewHint the hint to be inserted (must not overlap existing!) + */ +void SwpHints::InsertNesting(SwTxtAttrNesting & rNewHint) +{ + SwpHintsArray::Insert(& rNewHint); + NoteInHistory( & rNewHint, true ); +} - // Check if end of new attribute overlaps with pOther: - // Split pOther if necessary: - if ( nOtherStart < nThisEnd && nThisEnd < nOtherEnd ) - { - SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), - nOtherStart, nThisEnd ); - aInsDelHints.push_back( pNewAttr ); +/** + +The following hints correspond to well-formed XML elements in ODF: +RES_TXTATR_INETFMT, RES_TXTATR_CJK_RUBY, RES_TXTATR_META, RES_TXTATR_METAFIELD + +The writer core must ensure that these do not overlap; if they did, +the document would not be storable as ODF. + +Also, a Hyperlink must not be nested within another Hyperlink, +and a Ruby must not be nested within another Ruby. + +The ODF export in xmloff will only put a hyperlink into a ruby, never a ruby +into a hyperlink. + +Unfortunately the UNO API for Hyperlink and Ruby consists of the properties +Hyperlink* and Ruby* of the css.text.CharacterProperties service. In other +words, they are treated as formatting attributes, not as content entites. +Furthermore, for API users it is not possible to easily test whether a certain +range would be overlapping with other nested attributes, and most importantly, +<em>which ones</em>, so we can hardly refuse to insert these in cases of +overlap. + +It is possible to split Hyperlink and Ruby into multiple portions, such that +the result is properly nested. + +meta and meta-field must not be split, because they have xml:id. + +These constraints result in the following design: + +RES_TXTATR_INETFMT: + always succeeds + inserts n attributes split at RES_TXTATR_CJK_RUBY, RES_TXTATR_META, + RES_TXTATR_METAFIELD + may replace existing RES_TXTATR_INETFMT at overlap +RES_TXTATR_CJK_RUBY: + always succeeds + inserts n attributes split at RES_TXTATR_META, RES_TXTATR_METAFIELD + may replace existing RES_TXTATR_CJK_RUBY at overlap + may split existing overlapping RES_TXTATR_INETFMT +RES_TXTATR_META: + may fail if overlapping existing RES_TXTATR_META/RES_TXTATR_METAFIELD + may split existing overlapping RES_TXTATR_INETFMT or RES_TXTATR_CJK_RUBY + inserts 1 attribute +RES_TXTATR_METAFIELD: + may fail if overlapping existing RES_TXTATR_META/RES_TXTATR_METAFIELD + may split existing overlapping RES_TXTATR_INETFMT or RES_TXTATR_CJK_RUBY + inserts 1 attribute + +The nesting is expressed by the position of the hints. +RES_TXTATR_META and RES_TXTATR_METAFIELD have a CH_TXTATR, and there can +only be one such hint starting and ending at a given position. +Only RES_TXTATR_INETFMT and RES_TXTATR_CJK_RUBY lack a CH_TXTATR. +The interpretation given is that RES_TXTATR_CJK_RUBY is always around +a RES_TXTATR_INETFMT at the same start and end position (which corresponds +with the UNO API). +Both of these are always around a nesting hint with CH_TXTATR at the same +start and end position (if they should be inside, then the start should be +after the CH_TXTATR). +It would probably be a bad idea to add another nesting hint without +CH_TXTATR; on the other hand, it would be difficult adding a CH_TXTATR to +RES_TXTATR_INETFMT and RES_TXTATR_CJK_RUBY, due to the overwriting and +splitting of exising hints that is necessary for backward compatibility. + + @param rNode the text node + @param rHint the hint to be inserted + @returns true iff hint was successfully inserted +*/ +bool +SwpHints::TryInsertNesting( SwTxtNode & rNode, SwTxtAttrNesting & rNewHint ) +{ +// INVARIANT: the nestable hints in the array are properly nested + const USHORT nNewWhich( rNewHint.Which() ); + const xub_StrLen nNewStart( *rNewHint.GetStart() ); + const xub_StrLen nNewEnd ( *rNewHint.GetEnd() ); +//??? const bool bNoLengthAttribute( nNewStart == nNewEnd ); + const bool bNewSelfNestable( isSelfNestable(nNewWhich) ); + + ASSERT( (RES_TXTATR_INETFMT == nNewWhich) || + (RES_TXTATR_CJK_RUBY == nNewWhich) || + (RES_TXTATR_META == nNewWhich) || + (RES_TXTATR_METAFIELD == nNewWhich), + "TryInsertNesting: Expecting INETFMT or RUBY or META or METAFIELD" ); + + NestList_t OverlappingExisting; // existing hints to be split + NestList_t OverwrittenExisting; // existing hints to be replaced + NestList_t SplitNew; // new hints to be inserted + + SplitNew.push_back(& rNewHint); + + // pass 1: split the inserted hint into fragments if necessary + for ( USHORT i = 0; i < GetEndCount(); ++i ) + { + SwTxtAttr * const pOther = GetEnd(i); - NoteInHistory( pOther ); - *pOther->GetStart() = nThisEnd; - NoteInHistory( pOther, true ); + if (pOther->IsNesting()) + { + const USHORT nOtherWhich( pOther->Which() ); + const xub_StrLen nOtherStart( *(pOther)->GetStart() ); + const xub_StrLen nOtherEnd ( *(pOther)->GetEnd() ); + if (isOverlap(nNewStart, nNewEnd, nOtherStart, nOtherEnd )) + { + switch (splitPolicy(nNewWhich, nOtherWhich)) + { + case FAIL: + OSL_TRACE("cannot insert hint: overlap detected"); + ::std::for_each(SplitNew.begin(), SplitNew.end(), + TxtAttrDeleter(*rNode.GetDoc())); + return false; + case SPLIT_NEW: + lcl_DoSplitNew(SplitNew, rNode, nNewStart, + nOtherStart, nOtherEnd, pOther->HasDummyChar()); + break; + case SPLIT_OTHER: + OverlappingExisting.push_back( + static_cast<SwTxtAttrNesting*>(pOther)); + break; + default: + ASSERT(false, "bad code monkey"); + break; + } + } + else if (isNestedAny(nNewStart, nNewEnd, nOtherStart, nOtherEnd)) + { + if (!bNewSelfNestable && (nNewWhich == nOtherWhich)) + { + // ruby and hyperlink: if there is nesting, _overwrite_ + OverwrittenExisting.push_back( + static_cast<SwTxtAttrNesting*>(pOther)); + } + else if ((nNewStart == nOtherStart) && pOther->HasDummyChar()) + { + if (rNewHint.HasDummyChar()) + { + ASSERT(false, + "ERROR: inserting duplicate CH_TXTATR hint"); + return false; + } else if (nNewEnd < nOtherEnd) { + // other has dummy char, new is inside other, but + // new contains the other's dummy char? + // should be corrected because it may lead to problems + // in SwXMeta::createEnumeration + // SplitNew is sorted, so this is the first split + xub_StrLen *const pStart(SplitNew.front()->GetStart()); + ASSERT(*pStart == nNewStart, "how did that happen?"); + *pStart = nNewStart + 1; + } } } } + } - // Insert the newly created attributes: - const sal_uInt16 nCharFmtID = static_cast<sal_uInt16>( RES_TXTATR_INETFMT == nWhich ? - RES_POOLCHR_INET_NORMAL : - RES_POOLCHR_RUBYTEXT ); - SwCharFmt* pFmt = rNode.GetDoc()->GetCharFmtFromPool( nCharFmtID ); + ASSERT (isSplittable(nNewWhich) || SplitNew.size() == 1, + "splitting the unsplittable ???"); + + // pass 2: split existing hints that overlap/nest with new hint + // do not iterate over hints array, but over remembered set of overlapping + // hints, to keep things simple w.r.t. insertion/removal + // N.B: if there is a hint that splits the inserted hint, then + // that hint would also have already split any hint in OverlappingExisting + // so any hint in OverlappingExisting can be split at most by one hint + // in SplitNew, or even not at all (this is not true for existing hints + // that go _around_ new hint, which is the raison d'^etre for pass 4) + for (NestList_t::iterator itOther = OverlappingExisting.begin(); + itOther != OverlappingExisting.end(); ++itOther) + { + const xub_StrLen nOtherStart( *(*itOther)->GetStart() ); + const xub_StrLen nOtherEnd ( *(*itOther)->GetEnd() ); - for ( aIter = aInsDelHints.begin(); aIter != aInsDelHints.end(); ++aIter ) + for (NestList_t::iterator itNew = SplitNew.begin(); + itNew != SplitNew.end(); ++itNew) { - if ( RES_TXTATR_INETFMT == nWhich ) + const xub_StrLen nSplitNewStart( *(*itNew)->GetStart() ); + const xub_StrLen nSplitNewEnd ( *(*itNew)->GetEnd() ); + // 4 cases: within, around, overlap l, overlap r, (OTHER: no action) + const bool bRemoveOverlap( + !bNewSelfNestable && (nNewWhich == (*itOther)->Which()) ); + + switch (ComparePosition(nSplitNewStart, nSplitNewEnd, + nOtherStart, nOtherEnd)) { - SwTxtINetFmt* pInetAttr = static_cast<SwTxtINetFmt*>(*aIter); - pInetAttr->ChgTxtNode( &rNode ); - pFmt->Add( pInetAttr ); - + case POS_INSIDE: + { + ASSERT(!bRemoveOverlap, + "this one should be in OverwrittenExisting?"); + } + break; + case POS_OUTSIDE: + case POS_EQUAL: + { + ASSERT(false, "existing hint inside new hint: why?"); + } + break; + case POS_OVERLAP_BEFORE: + { + Delete( *itOther ); // this also does NoteInHistory! + *(*itOther)->GetStart() = nSplitNewEnd; + InsertNesting( **itOther ); + if (!bRemoveOverlap) + { + if ( USHRT_MAX == Count() ) + { + ASSERT(false, "hints array full :-("); + return false; + } + SwTxtAttrNesting * const pOtherLeft( + MakeTxtAttrNesting( rNode, **itOther, + nOtherStart, nSplitNewEnd ) ); + InsertNesting( *pOtherLeft ); + } + } + break; + case POS_OVERLAP_BEHIND: + { + Delete( *itOther ); // this also does NoteInHistory! + *(*itOther)->GetEnd() = nSplitNewStart; + InsertNesting( **itOther ); + if (!bRemoveOverlap) + { + if ( USHRT_MAX == Count() ) + { + ASSERT(false, "hints array full :-("); + return false; + } + SwTxtAttrNesting * const pOtherRight( + MakeTxtAttrNesting( rNode, **itOther, + nSplitNewStart, nOtherEnd ) ); + InsertNesting( *pOtherRight ); + } + } + break; + default: + break; // overlap resolved by splitting new: nothing to do } + } + } - else - { - SwTxtRuby* pRubyAttr = static_cast<SwTxtRuby*>(*aIter); - pRubyAttr->ChgTxtNode( &rNode ); - pFmt->Add( pRubyAttr ); - - } + if ( USHRT_MAX - SplitNew.size() <= Count() ) + { + ASSERT(false, "hints array full :-("); + return false; + } - SwpHintsArray::Insert( *aIter ); - NoteInHistory( *aIter, true ); - } + // pass 3: insert new hints + for (NestList_t::iterator iter = SplitNew.begin(); + iter != SplitNew.end(); ++iter) + { + InsertNesting(**iter); + } - aInsDelHints.clear(); + // pass 4: handle overwritten hints + // RES_TXTATR_INETFMT and RES_TXTATR_CJK_RUBY should displace attributes + // of the same kind. + for (NestList_t::iterator itOther = OverwrittenExisting.begin(); + itOther != OverwrittenExisting.end(); ++itOther) + { + const xub_StrLen nOtherStart( *(*itOther)->GetStart() ); + const xub_StrLen nOtherEnd ( *(*itOther)->GetEnd() ); - // Now delete all attributes of the same type as the new one - // which are fully covered by the new attribute: - for ( USHORT i = 0; i < Count(); ++i ) + // overwritten portion is given by start/end of inserted hint + if ((nNewStart <= nOtherStart) && (nOtherEnd <= nNewEnd)) { - SwTxtAttr* pOther = GetTextHint(i); - if ( nWhich == pOther->Which() ) - { - const xub_StrLen nOtherStart = *pOther->GetStart(); - const xub_StrLen nOtherEnd = *pOther->GetEnd(); - - if ( nOtherStart >= nThisStart && nOtherEnd <= nThisEnd ) - aInsDelHints.push_back( pOther ); - } + Delete(*itOther); + rNode.DestroyAttr( *itOther ); } - for ( aIter = aInsDelHints.begin(); aIter != aInsDelHints.end(); ++aIter ) + else { - Delete( *aIter ); - rNode.DestroyAttr( *aIter ); + ASSERT((nOtherStart < nNewStart) && (nNewEnd < nOtherEnd), "huh?"); + // scenario: there is a RUBY, and contained within that a META; + // now a RUBY is inserted within the META => the exising RUBY is split: + // here it is not possible to simply insert the left/right fragment + // of the existing RUBY because they <em>overlap</em> with the META! + Delete( *itOther ); // this also does NoteInHistory! + *(*itOther)->GetEnd() = nNewStart; + bool bSuccess( TryInsertNesting(rNode, **itOther) ); + ASSERT(bSuccess, "recursive call 1 failed?"); + SwTxtAttrNesting * const pOtherRight( + MakeTxtAttrNesting( + rNode, **itOther, nNewEnd, nOtherEnd ) ); + bSuccess = TryInsertNesting(rNode, *pOtherRight); + ASSERT(bSuccess, "recursive call 2 failed?"); } - SwpHintsArray::Insert( &rNewHint ); - NoteInHistory( &rNewHint, true ); - - return; } + return true; +} + + +// This function takes care for the following text attribute: +// RES_TXTATR_CHARFMT, RES_TXTATR_AUTOFMT +// These attributes have to be handled in a special way (Portion building). +// +// The new attribute will be split by any existing RES_TXTATR_AUTOFMT or +// RES_TXTATR_CHARFMT. The new attribute itself will +// split any existing RES_TXTATR_AUTOFMT or RES_TXTATR_CHARFMT. + +void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, + const SetAttrMode nMode ) +{ + const USHORT nWhich = rNewHint.Which(); + + const xub_StrLen nThisStart = *rNewHint.GetStart(); + const xub_StrLen nThisEnd = *rNewHint.GetEnd(); + const bool bNoLengthAttribute = nThisStart == nThisEnd; + + std::vector<SwTxtAttr*> aInsDelHints; + std::vector<SwTxtAttr*>::iterator aIter; + ASSERT( RES_TXTATR_CHARFMT == rNewHint.Which() || RES_TXTATR_AUTOFMT == rNewHint.Which(), - "Expecting CHARFMT or AUTOFMT" ) + "Expecting CHARFMT or AUTOFMT" ); // // 2. Find the hints which cover the start and end position @@ -265,7 +621,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Split pOther if necessary: if ( nOtherStart < nThisStart && nThisStart < nOtherEnd ) { - SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), nOtherStart, nThisStart ); + SwTxtAttr* pNewAttr = MakeTxtAttr( *rNode.GetDoc(), + pOther->GetAttr(), nOtherStart, nThisStart ); if ( RES_TXTATR_CHARFMT == pOther->Which() ) static_cast<SwTxtCharFmt*>(pNewAttr)->SetSortNumber( static_cast<SwTxtCharFmt*>(pOther)->GetSortNumber() ); aInsDelHints.push_back( pNewAttr ); @@ -281,7 +638,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Split pOther if necessary: if ( nOtherStart < nThisEnd && nThisEnd < nOtherEnd ) { - SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), nOtherStart, nThisEnd ); + SwTxtAttr* pNewAttr = MakeTxtAttr( *rNode.GetDoc(), + pOther->GetAttr(), nOtherStart, nThisEnd ); if ( RES_TXTATR_CHARFMT == pOther->Which() ) static_cast<SwTxtCharFmt*>(pNewAttr)->SetSortNumber( static_cast<SwTxtCharFmt*>(pOther)->GetSortNumber() ); aInsDelHints.push_back( pNewAttr ); @@ -433,8 +791,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Create new AutoStyle if ( aNewSet.Count() ) { - pNewAttr = rNode.MakeTxtAttr( aNewSet, - nPorStart, nPorEnd ); + pNewAttr = MakeTxtAttr( *rNode.GetDoc(), + aNewSet, nPorStart, nPorEnd ); SwpHintsArray::Insert( pNewAttr ); NoteInHistory( pNewAttr, true ); } @@ -453,7 +811,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod } else { - pNewAttr = rNode.MakeTxtAttr( rNewHint.GetAttr(), nPorStart, nPorEnd ); + pNewAttr = MakeTxtAttr( *rNode.GetDoc(), rNewHint.GetAttr(), + nPorStart, nPorEnd ); static_cast<SwTxtCharFmt*>(pNewAttr)->SetSortNumber( nCharStyleCount ); } } @@ -510,7 +869,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Create new AutoStyle if ( aNewSet.Count() ) - pNewAttr = rNode.MakeTxtAttr( aNewSet, nPorStart, nPorEnd ); + pNewAttr = MakeTxtAttr( *rNode.GetDoc(), aNewSet, + nPorStart, nPorEnd ); } else { @@ -568,7 +928,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod } else if ( pNewStyle.get() ) { - pNewAttr = rNode.MakeTxtAttr( *pNewStyle, nPorStart, nPorEnd ); + pNewAttr = MakeTxtAttr( *rNode.GetDoc(), *pNewStyle, + nPorStart, nPorEnd ); } } } @@ -597,35 +958,66 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod * SwTxtNode::MakeTxtAttr() *************************************************************************/ -// create new text attribute -SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnd, bool bRedlineAttr ) +SwTxtAttr* MakeRedlineTxtAttr( SwDoc & rDoc, SfxPoolItem & rAttr ) { - SwDoc* pDoc = GetDoc(); + // this is intended _only_ for special-purpose redline attributes! + switch (rAttr.Which()) + { + case RES_CHRATR_COLOR: + case RES_CHRATR_WEIGHT: + case RES_CHRATR_CJK_WEIGHT: + case RES_CHRATR_CTL_WEIGHT: + case RES_CHRATR_POSTURE: + case RES_CHRATR_CJK_POSTURE: + case RES_CHRATR_CTL_POSTURE: + case RES_CHRATR_UNDERLINE: + case RES_CHRATR_CROSSEDOUT: + case RES_CHRATR_CASEMAP: + case RES_CHRATR_BACKGROUND: + break; + default: + ASSERT(false, "unsupported redline attribute"); + break; + } + + // Put new attribute into pool + // FIXME: this const_cast is evil! + SfxPoolItem& rNew = + const_cast<SfxPoolItem&>( rDoc.GetAttrPool().Put( rAttr ) ); + return new SwTxtAttrEnd( rNew, 0, 0 ); +} - if ( !bRedlineAttr && isCHRATR(rAttr.Which()) ) +// create new text attribute +SwTxtAttr* MakeTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr, + xub_StrLen nStt, xub_StrLen nEnd ) +{ + if ( isCHRATR(rAttr.Which()) ) { - // Somebody wants to build a SwTxtAttr for a character attribute (and - // this attribute is not meant for redlining). Sorry, this is not allowed - // any longer. You'll get a brand new autostyle attribute: - SfxItemSet aItemSet( pDoc->GetAttrPool(), RES_CHRATR_BEGIN, RES_CHRATR_END ); + // Somebody wants to build a SwTxtAttr for a character attribute. + // Sorry, this is not allowed any longer. + // You'll get a brand new autostyle attribute: + SfxItemSet aItemSet( rDoc.GetAttrPool(), + RES_CHRATR_BEGIN, RES_CHRATR_END ); aItemSet.Put( rAttr ); - return MakeTxtAttr( aItemSet, nStt, nEnd ); + return MakeTxtAttr( rDoc, aItemSet, nStt, nEnd ); } else if ( RES_TXTATR_AUTOFMT == rAttr.Which() && - static_cast<const SwFmtAutoFmt&>(rAttr).GetStyleHandle()->GetPool() != &pDoc->GetAttrPool() ) + static_cast<const SwFmtAutoFmt&>(rAttr).GetStyleHandle()-> + GetPool() != &rDoc.GetAttrPool() ) { - // If the attribut is an autostyle which referes to a pool that is different from - // pDoc's pool, we have to correct this: + // If the attribute is an auto-style which refers to a pool that is + // different from rDoc's pool, we have to correct this: const StylePool::SfxItemSet_Pointer_t pAutoStyle = static_cast<const SwFmtAutoFmt&>(rAttr).GetStyleHandle(); - const SfxItemSet* pNewSet = pAutoStyle->SfxItemSet::Clone( TRUE, &pDoc->GetAttrPool() ); - SwTxtAttr* pNew = MakeTxtAttr( *pNewSet, nStt, nEnd ); - delete pNewSet; + ::std::auto_ptr<const SfxItemSet> pNewSet( + pAutoStyle->SfxItemSet::Clone( TRUE, &rDoc.GetAttrPool() )); + SwTxtAttr* pNew = MakeTxtAttr( rDoc, *pNewSet, nStt, nEnd ); return pNew; } - // Put new attribute into pool unless we are asked to build a redline attribute - const SfxPoolItem& rNew = !bRedlineAttr ? GetDoc()->GetAttrPool().Put( rAttr ) : rAttr; + // Put new attribute into pool + // FIXME: this const_cast is evil! + SfxPoolItem& rNew = + const_cast<SfxPoolItem&>( rDoc.GetAttrPool().Put( rAttr ) ); SwTxtAttr* pNew = 0; switch( rNew.Which() ) @@ -634,7 +1026,9 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, { SwFmtCharFmt &rFmtCharFmt = (SwFmtCharFmt&) rNew; if( !rFmtCharFmt.GetCharFmt() ) - rFmtCharFmt.SetCharFmt( GetDoc()->GetDfltCharFmt() ); + { + rFmtCharFmt.SetCharFmt( rDoc.GetDfltCharFmt() ); + } pNew = new SwTxtCharFmt( rFmtCharFmt, nStt, nEnd ); } @@ -650,9 +1044,11 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, // erst hier wird das Frame-Format kopiert (mit Inhalt) !! pNew = new SwTxtFlyCnt( (SwFmtFlyCnt&)rNew, nStt ); // Kopie von einem Text-Attribut - if( ((SwFmtFlyCnt&)rAttr).GetTxtFlyCnt() ) - // dann muss das Format Kopiert werden - ((SwTxtFlyCnt*)pNew)->CopyFlyFmt( GetDoc() ); + if ( static_cast<const SwFmtFlyCnt &>(rAttr).GetTxtFlyCnt() ) + { + // then the format must be copied + static_cast<SwTxtFlyCnt *>(pNew)->CopyFlyFmt( &rDoc ); + } } break; case RES_TXTATR_FTN: @@ -661,12 +1057,6 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, if( ((SwFmtFtn&)rAttr).GetTxtFtn() ) ((SwTxtFtn*)pNew)->SetSeqNo( ((SwFmtFtn&)rAttr).GetTxtFtn()->GetSeqRefNo() ); break; - case RES_TXTATR_HARDBLANK: - pNew = new SwTxtHardBlank( (SwFmtHardBlank&)rNew, nStt ); - break; - case RES_CHRATR_TWO_LINES: - pNew = new SwTxt2Lines( (SvxTwoLinesItem&)rNew, nStt, nEnd ); - break; case RES_TXTATR_REFMARK: pNew = nStt == nEnd ? new SwTxtRefMark( (SwFmtRefMark&)rNew, nStt ) @@ -683,7 +1073,12 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, case RES_TXTATR_CJK_RUBY: pNew = new SwTxtRuby( (SwFmtRuby&)rNew, nStt, nEnd ); break; + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + pNew = new SwTxtMeta( static_cast<SwFmtMeta&>(rNew), nStt, nEnd ); + break; default: + ASSERT(RES_TXTATR_AUTOFMT == rNew.Which(), "unknown attribute"); pNew = new SwTxtAttrEnd( rNew, nStt, nEnd ); break; } @@ -691,13 +1086,14 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, return pNew; } -SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd ) +SwTxtAttr* MakeTxtAttr( SwDoc & rDoc, const SfxItemSet& rSet, + xub_StrLen nStt, xub_StrLen nEnd ) { - IStyleAccess& rStyleAccess = getIDocumentStyleAccess(); + IStyleAccess& rStyleAccess = rDoc.GetIStyleAccess(); const StylePool::SfxItemSet_Pointer_t pAutoStyle = rStyleAccess.getAutomaticStyle( rSet, IStyleAccess::AUTO_STYLE_CHAR ); SwFmtAutoFmt aNewAutoFmt; aNewAutoFmt.SetStyleHandle( pAutoStyle ); - SwTxtAttr* pNew = MakeTxtAttr( aNewAutoFmt, nStt, nEnd ); + SwTxtAttr* pNew = MakeTxtAttr( rDoc, aNewAutoFmt, nStt, nEnd ); return pNew; } @@ -781,6 +1177,14 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) case RES_TXTATR_REFMARK: nDelMsg = RES_REFMARK_DELETED; break; + + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + static_cast<SwFmtMeta&>(pAttr->GetAttr()).NotifyRemoval(); + break; + + default: + break; } if( nDelMsg && !pDoc->IsInDtor() && GetNodes().IsDocNodes() ) @@ -789,8 +1193,7 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) pDoc->GetUnoCallBack()->Modify( &aMsgHint, &aMsgHint ); } - pAttr->RemoveFromPool( pDoc->GetAttrPool() ); - delete pAttr; + SwTxtAttr::Destroy( pAttr, pDoc->GetAttrPool() ); } } @@ -798,30 +1201,52 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) * SwTxtNode::Insert() *************************************************************************/ -// lege ein neues TextAttribut an und fuege es ins SwpHints-Array ein -SwTxtAttr* SwTxtNode::InsertItem( const SfxPoolItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnd, USHORT nMode ) +SwTxtAttr* +SwTxtNode::InsertItem( SfxPoolItem& rAttr, + const xub_StrLen nStart, const xub_StrLen nEnd, const SetAttrMode nMode ) { // character attributes will be inserted as automatic styles: ASSERT( !isCHRATR(rAttr.Which()), "AUTOSTYLES - " "SwTxtNode::InsertItem should not be called with character attributes"); - SwTxtAttr* pNew = MakeTxtAttr( rAttr, nStt, nEnd ); + SwTxtAttr* const pNew = MakeTxtAttr( *GetDoc(), rAttr, nStart, nEnd ); if ( pNew ) - Insert( pNew, nMode ); + { + const bool bSuccess( InsertHint( pNew, nMode ) ); + // N.B.: also check that the hint is actually in the hints array, + // because hints of certain types may be merged after succesful + // insertion, and thus destroyed! + if (!bSuccess || ( USHRT_MAX == m_pSwpHints->GetPos( pNew ) )) + { + return 0; + } + } return pNew; } -// uebernehme den Pointer auf das Text-Attribut -BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) +// take ownership of pAttr; if insertion fails, delete pAttr +bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) { BOOL bHiddenPara = FALSE; - ASSERT( pAttr && *pAttr->GetStart() <= Len(), "StartIdx hinter Len!" ); - - if( !pAttr->GetEnd() ) + ASSERT( pAttr && *pAttr->GetStart() <= Len(), "StartIdx out of bounds!" ); + ASSERT( !pAttr->GetEnd() || (*pAttr->GetEnd() <= Len()), + "EndIdx out of bounds!" ); + + // translate from SetAttrMode to InsertMode (for hints with CH_TXTATR) + const enum IDocumentContentOperations::InsertFlags nInsertFlags = + (nMode & nsSetAttrMode::SETATTR_FORCEHINTEXPAND) + ? static_cast<IDocumentContentOperations::InsertFlags>( + IDocumentContentOperations::INS_FORCEHINTEXPAND | + IDocumentContentOperations::INS_EMPTYEXPAND) + : IDocumentContentOperations::INS_EMPTYEXPAND; + + // need this after TryInsertHint, when pAttr may be deleted + const xub_StrLen nStart( *pAttr->GetStart() ); + const bool bDummyChar( pAttr->HasDummyChar() ); + if (bDummyChar) { USHORT nInsMode = nMode; switch( pAttr->Which() ) @@ -843,7 +1268,8 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) (const SfxPoolItem**)&pAnchor ); SwIndex aIdx( this, *pAttr->GetStart() ); - Insert( GetCharOfTxtAttr(*pAttr), aIdx ); + const sal_Unicode c = GetCharOfTxtAttr(*pAttr); + InsertText( c, aIdx, nInsertFlags ); nInsMode |= nsSetAttrMode::SETATTR_NOTXTATRCHR; if( pAnchor && FLY_IN_CNTNT == pAnchor->GetAnchorId() && @@ -892,7 +1318,7 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) pDoc->DoUndo( FALSE ); DestroyAttr( pAttr ); pDoc->DoUndo( bUndo ); - return FALSE; + return false; } } break; @@ -926,7 +1352,7 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) Update( aTmpIdx, 1, TRUE ); } DestroyAttr( pAttr ); - return FALSE; + return false; } // wird eine neue Fussnote eingefuegt ?? @@ -957,7 +1383,8 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) // entstehen koennen und das Attribut im _SortArr_ am // Dokument nicht eingetrage wird. SwIndex aNdIdx( this, *pAttr->GetStart() ); - Insert( GetCharOfTxtAttr(*pAttr), aNdIdx ); + const sal_Unicode c = GetCharOfTxtAttr(*pAttr); + InsertText( c, aNdIdx, nInsertFlags ); nInsMode |= nsSetAttrMode::SETATTR_NOTXTATRCHR; } @@ -1020,92 +1447,105 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) if( !(nsSetAttrMode::SETATTR_NOTXTATRCHR & nInsMode) ) { SwIndex aIdx( this, *pAttr->GetStart() ); - Insert( GetCharOfTxtAttr(*pAttr), aIdx ); + InsertText( GetCharOfTxtAttr(*pAttr), aIdx, nInsertFlags ); + + // adjust end of hint to account for inserted CH_TXTATR + xub_StrLen * const pEnd(pAttr->GetEnd()); + if (pEnd) + { + *pEnd = *pEnd + 1; + } } } - else { - ASSERT( *pAttr->GetEnd() <= Len(), "EndIdx hinter Len!" ); - } GetOrCreateSwpHints(); // 4263: AttrInsert durch TextInsert => kein Adjust - m_pSwpHints->Insert( pAttr, *this, nMode ); + const bool bRet = m_pSwpHints->TryInsertHint( pAttr, *this, nMode ); - // 47375: In pSwpHints->Insert wird u.a. Merge gerufen und das Hints-Array - // von ueberfluessigen Hints befreit, dies kann u.U. sogar der frisch - // eingefuegte Hint pAttr sein, der dann zerstoert wird!! - if ( USHRT_MAX == m_pSwpHints->GetPos( pAttr ) ) + if (!bRet && bDummyChar) { - return FALSE; + // undo insertion of dummy character + // N.B. cannot insert the dummy character after inserting the hint, + // because if the hint has no extent it will be moved in InsertText, + // resulting in infinite recursion + if ( !(nsSetAttrMode::SETATTR_NOTXTATRCHR & nMode) ) + { + ASSERT( ( CH_TXTATR_BREAKWORD == m_Text.GetChar(nStart) || + CH_TXTATR_INWORD == m_Text.GetChar(nStart) ), + "where is my attribute character?" ); + SwIndex aIdx( this, nStart ); + EraseText( aIdx, 1 ); + } } - if( bHiddenPara ) + if ( bHiddenPara ) + { SetCalcHiddenParaField(); + } - return TRUE; + return bRet; } /************************************************************************* - * SwTxtNode::Delete() + * SwTxtNode::DeleteAttribute() *************************************************************************/ -void SwTxtNode::Delete( SwTxtAttr *pAttr, BOOL bThisOnly ) +void SwTxtNode::DeleteAttribute( SwTxtAttr * const pAttr ) { if ( !HasHints() ) + { + ASSERT(false, "DeleteAttribute called, but text node without hints?"); return; + } - if( bThisOnly ) + if ( pAttr->HasDummyChar() ) { - xub_StrLen* pEndIdx = pAttr->GetEnd(); - if( !pEndIdx ) - { - // hat es kein Ende kann es nur das sein, was hier steht! - // Unbedingt Copy-konstruieren! - const SwIndex aIdx( this, *pAttr->GetStart() ); - Erase( aIdx, 1 ); - } - else - { - // den MsgHint jetzt fuettern, weil gleich sind - // Start und End weg. - SwUpdateAttr aHint( *pAttr->GetStart(), *pEndIdx, pAttr->Which() ); - m_pSwpHints->Delete( pAttr ); - pAttr->RemoveFromPool( GetDoc()->GetAttrPool() ); - delete pAttr; - SwModify::Modify( 0, &aHint ); // die Frames benachrichtigen - - TryDeleteSwpHints(); - } - - return; + // Unbedingt Copy-konstruieren! + const SwIndex aIdx( this, *pAttr->GetStart() ); + // erase the CH_TXTATR, which will also delete pAttr + EraseText( aIdx, 1 ); + } + else + { + // create MsgHint before start/end become invalid + SwUpdateAttr aHint( + *pAttr->GetStart(), *pAttr->GetEnd(), pAttr->Which() ); + m_pSwpHints->Delete( pAttr ); + SwTxtAttr::Destroy( pAttr, GetDoc()->GetAttrPool() ); + SwModify::Modify( 0, &aHint ); // notify Frames + + TryDeleteSwpHints(); } - Delete( pAttr->Which(), *pAttr->GetStart(), *pAttr->GetAnyEnd() ); } /************************************************************************* - * SwTxtNode::Delete() + * SwTxtNode::DeleteAttributes() *************************************************************************/ -void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) +//FIXME: this does NOT respect SORT NUMBER (for CHARFMT)! +void SwTxtNode::DeleteAttributes( const USHORT nWhich, + const xub_StrLen nStart, const xub_StrLen nEnd ) { if ( !HasHints() ) return; - const xub_StrLen *pEndIdx; - const xub_StrLen *pSttIdx; - SwTxtAttr* pTxtHt; - for ( USHORT nPos = 0; m_pSwpHints && nPos < m_pSwpHints->Count(); nPos++ ) { - pTxtHt = m_pSwpHints->GetTextHint( nPos ); - const USHORT nWhich = pTxtHt->Which(); - if( nWhich == nTxtWhich && - *( pSttIdx = pTxtHt->GetStart()) == nStt ) + SwTxtAttr * const pTxtHt = m_pSwpHints->GetTextHint( nPos ); + const xub_StrLen nHintStart = *(pTxtHt->GetStart()); + if (nStart < nHintStart) + { + break; // sorted by start + } + else if ( (nStart == nHintStart) && (nWhich == pTxtHt->Which()) ) { if ( nWhich == RES_CHRATR_HIDDEN ) + { + ASSERT(false, "hey, that's a CHRATR! how did that get in?"); SetCalcHiddenCharFlags(); + } else if ( nWhich == RES_TXTATR_CHARFMT ) { // Check if character format contains hidden attribute: @@ -1124,16 +1564,14 @@ void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) } // <-- - pEndIdx = pTxtHt->GetEnd(); + xub_StrLen const * const pEndIdx = pTxtHt->GetEnd(); - // Text-Attribute sind voellig dynamisch, so dass diese nur - // mit ihrer Start-Position verglichen werden. - if( !pEndIdx ) + if ( pTxtHt->HasDummyChar() ) { // Unbedingt Copy-konstruieren! - const SwIndex aIdx( this, *pSttIdx ); - Erase( aIdx, 1 ); - break; + const SwIndex aIdx( this, nStart ); + // erase the CH_TXTATR, which will also delete pTxtHt + EraseText( aIdx, 1 ); } else if( *pEndIdx == nEnd ) { @@ -1141,12 +1579,10 @@ void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) // Start und End weg. // Das CalcVisibleFlag bei HiddenParaFields entfaellt, // da dies das Feld im Dtor selbst erledigt. - SwUpdateAttr aHint( *pSttIdx, *pEndIdx, nTxtWhich ); + SwUpdateAttr aHint( nStart, *pEndIdx, nWhich ); m_pSwpHints->DeleteAtPos( nPos ); // gefunden, loeschen, - pTxtHt->RemoveFromPool( GetDoc()->GetAttrPool() ); - delete pTxtHt; + SwTxtAttr::Destroy( pTxtHt, GetDoc()->GetAttrPool() ); SwModify::Modify( 0, &aHint ); // die Frames benachrichtigen - break; } } } @@ -1165,7 +1601,7 @@ void SwTxtNode::DelSoftHyph( const xub_StrLen nStt, const xub_StrLen nEnd ) nFndPos < nEndPos ) { const SwIndex aIdx( this, nFndPos ); - Erase( aIdx, 1 ); + EraseText( aIdx, 1 ); --nEndPos; } } @@ -1173,7 +1609,7 @@ void SwTxtNode::DelSoftHyph( const xub_StrLen nStt, const xub_StrLen nEnd ) // setze diese Attribute am TextNode. Wird der gesamte Bereich umspannt, // dann setze sie nur im AutoAttrSet (SwCntntNode:: SetAttr) BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, - xub_StrLen nEnd, USHORT nMode ) + xub_StrLen nEnd, const SetAttrMode nMode ) { if( !rSet.Count() ) return FALSE; @@ -1262,7 +1698,8 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, } else { - pNew = MakeTxtAttr( *pItem, nStt, nEnd ); + pNew = MakeTxtAttr( *GetDoc(), + const_cast<SfxPoolItem&>(*pItem), nStt, nEnd ); if ( pNew ) { if ( nEnd != nStt && !pNew->GetEnd() ) @@ -1271,7 +1708,7 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, "Attribut without end, but area marked"); DestroyAttr( pNew ); // do not insert } - else if ( Insert( pNew, nMode ) ) + else if ( InsertHint( pNew, nMode ) ) { ++nCount; } @@ -1287,9 +1724,11 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, if ( aCharSet.Count() ) { - SwTxtAttr* pTmpNew = MakeTxtAttr( aCharSet, nStt, nEnd ); - if ( Insert( pTmpNew, nMode ) ) + SwTxtAttr* pTmpNew = MakeTxtAttr( *GetDoc(), aCharSet, nStt, nEnd ); + if ( InsertHint( pTmpNew, nMode ) ) + { ++nCount; + } } TryDeleteSwpHints(); @@ -1669,7 +2108,9 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) if (lcl_IsNewAttrInSet( *m_pSwpHints, *pItem, GetTxt().Len() )) { m_pSwpHints->SwpHintsArray::Insert( - MakeTxtAttr( *pItem, 0, GetTxt().Len() ) ); + MakeTxtAttr( *GetDoc(), + const_cast<SfxPoolItem&>(*pItem), + 0, GetTxt().Len() ) ); aClearWhichIds.push_back( pItem->Which() ); } @@ -1701,8 +2142,9 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) &pNdItem ) || *pItem != *pNdItem ) && lcl_IsNewAttrInSet( *m_pSwpHints, *pItem, GetTxt().Len() ) ) { - m_pSwpHints->SwpHintsArray::Insert( - MakeTxtAttr( *pItem, 0, GetTxt().Len() ) ); + m_pSwpHints->SwpHintsArray::Insert( MakeTxtAttr( *GetDoc(), + const_cast<SfxPoolItem&>(*pItem), + 0, GetTxt().Len() ) ); aClearWhichIds.push_back( pItem->Which() ); } aNdSet.ClearItem( pItem->Which() ); @@ -1726,7 +2168,9 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) pNd->GetTxt().Len() ) ) { pNd->m_pSwpHints->SwpHintsArray::Insert( - pNd->MakeTxtAttr( *pItem, 0, pNd->GetTxt().Len() ) ); + MakeTxtAttr( *pNd->GetDoc(), + const_cast<SfxPoolItem&>(*pItem), + 0, pNd->GetTxt().Len() ) ); } aClearWhichIds.push_back( pItem->Which() ); @@ -1979,18 +2423,20 @@ void lcl_CheckSortNumber( const SwpHints& rHints, SwTxtCharFmt& rNewCharFmt ) *************************************************************************/ /* - * Insert: Der neue Hint wird immer eingefuegt. Wenn dabei ein - * ueberlappender oder gleicher Hintbereich mit gleichem Attribut - * und Wert gefunden, wird der neue Hint entsprechend veraendert - * und der alte herausgenommen (und zerstoert: - * SwpHints::Destroy()). + * Try to insert the new hint. + * Depending on the type of the hint, this either always succeeds, or may fail. + * Depending on the type of the hint, other hints may be deleted or + * overwritten. + * The return value indicates successful insertion. */ - -void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) +bool SwpHints::TryInsertHint( SwTxtAttr* const pHint, SwTxtNode &rNode, + const SetAttrMode nMode ) { - // Irgendwann ist immer Schluss - if( USHRT_MAX == Count() ) - return; + if ( USHRT_MAX == Count() ) // we're sorry, this flight is overbooked... + { + ASSERT(false, "hints array full :-("); + return false; + } // Felder bilden eine Ausnahme: // 1) Sie koennen nie ueberlappen @@ -2025,11 +2471,7 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) } // <-- case RES_TXTATR_INETFMT: - { - ((SwTxtINetFmt*)pHint)->ChgTxtNode( &rNode ); - SwCharFmt* pFmt = rNode.GetDoc()->GetCharFmtFromPool( RES_POOLCHR_INET_NORMAL ); - pFmt->Add( (SwTxtINetFmt*)pHint ); - } + lcl_InitINetFmt(rNode, static_cast<SwTxtINetFmt*>(pHint)); break; case RES_TXTATR_FIELD: { @@ -2163,12 +2605,12 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) break; case RES_TXTATR_CJK_RUBY: - { - ((SwTxtRuby*)pHint)->ChgTxtNode( &rNode ); - SwCharFmt* pFmt = rNode.GetDoc()->GetCharFmtFromPool( - RES_POOLCHR_RUBYTEXT ); - pFmt->Add( (SwTxtRuby*)pHint ); - } + lcl_InitRuby(rNode, static_cast<SwTxtRuby*>(pHint)); + break; + + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + static_cast<SwTxtMeta *>(pHint)->ChgTxtNode( &rNode ); break; case RES_CHRATR_HIDDEN: @@ -2198,7 +2640,7 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) SwUpdateAttr aHint( nHtStart, nHtStart, nWhich ); rNode.Modify( 0, &aHint ); } - return; + return true; } // ---------------------------------------------------------------- @@ -2219,18 +2661,24 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) const xub_StrLen nHintEnd = *pHtEnd; const bool bNoHintAdjustMode = (nsSetAttrMode::SETATTR_NOHINTADJUST & nMode); + // handle nesting attributes: inserting may fail due to overlap! + if (pHint->IsNesting()) + { + const bool bRet( + TryInsertNesting(rNode, *static_cast<SwTxtAttrNesting*>(pHint))); + if (!bRet) return false; + } // Currently REFMARK and TOXMARK have OverlapAllowed set to true. // These attributes may be inserted directly. // Also attributes without length may be inserted directly. // SETATTR_NOHINTADJUST is set e.g., during undo. // Portion building in not necessary during XML import. + else if ( !bNoHintAdjustMode && !pHint->IsOverlapAllowedAttr() && !rNode.GetDoc()->IsInXMLImport() && ( RES_TXTATR_AUTOFMT == nWhich || - RES_TXTATR_INETFMT == nWhich || - RES_TXTATR_CHARFMT == nWhich || - RES_TXTATR_CJK_RUBY == nWhich ) ) + RES_TXTATR_CHARFMT == nWhich ) ) { ASSERT( nWhich != RES_TXTATR_AUTOFMT || static_cast<const SwFmtAutoFmt&>(pHint->GetAttr()).GetStyleHandle()->GetPool() == @@ -2252,10 +2700,10 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) // multiple times // FME 2007-11-08 #i82989# in NOHINTADJUST mode, we want to insert // character attributes directly - if ( ( RES_TXTATR_CHARFMT == nWhich && !bNoHintAdjustMode ) || - RES_TXTATR_CJK_RUBY == nWhich || - RES_TXTATR_INETFMT == nWhich ) + if ( ( RES_TXTATR_CHARFMT == nWhich && !bNoHintAdjustMode ) ) + { BuildPortions( rNode, *pHint, nMode ); + } else { // --> FME 2007-11-08 #i82989# Check sort numbers in NoHintAdjustMode @@ -2280,7 +2728,7 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) CHECK; #endif - return; + return true; } /************************************************************************* @@ -2348,7 +2796,6 @@ void SwTxtNode::ClearSwpHintsArr( bool bDelFields ) break; case RES_TXTATR_FIELD: - case RES_TXTATR_HARDBLANK: if( bDelFields ) bDel = true; break; @@ -2435,20 +2882,22 @@ sal_Unicode GetCharOfTxtAttr( const SwTxtAttr& rAttr ) sal_Unicode cRet = CH_TXTATR_BREAKWORD; switch ( rAttr.Which() ) { - case RES_TXTATR_REFMARK: - case RES_TXTATR_TOXMARK: - -// case RES_TXTATR_FIELD: ?????? -// case RES_TXTATR_FLYCNT, // 29 + case RES_TXTATR_FTN: + case RES_TXTATR_REFMARK: + case RES_TXTATR_TOXMARK: + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + cRet = CH_TXTATR_INWORD; + break; - case RES_TXTATR_FTN: - cRet = CH_TXTATR_INWORD; - break; + case RES_TXTATR_FIELD: + case RES_TXTATR_FLYCNT: + cRet = CH_TXTATR_BREAKWORD; + break; - // depends on the character ?? -// case RES_TXTATR_HARDBLANK: -// cRet = CH_TXTATR_INWORD; -// break; + default: + ASSERT(false, "GetCharOfTxtAttr: unknown attr"); + break; } return cRet; } diff --git a/sw/source/core/txtnode/txatbase.cxx b/sw/source/core/txtnode/txatbase.cxx index 17c94a9e20c9..0ce234483f40 100644 --- a/sw/source/core/txtnode/txatbase.cxx +++ b/sw/source/core/txtnode/txatbase.cxx @@ -37,17 +37,18 @@ #include <fmtfld.hxx> #include <docufld.hxx> -SwTxtAttr::SwTxtAttr( const SfxPoolItem& rAttr, xub_StrLen nStart ) +SwTxtAttr::SwTxtAttr( SfxPoolItem& rAttr, xub_StrLen nStart ) : m_pAttr( &rAttr ) , m_nStart( nStart ) , m_bDontExpand( false ) , m_bLockExpandFlag( false ) - , m_bDontMergeAttr( false ) , m_bDontMoveAttr( false ) , m_bCharFmtAttr( false ) , m_bOverlapAllowedAttr( false ) , m_bPriorityAttr( false ) , m_bDontExpandStart( false ) + , m_bNesting( false ) + , m_bHasDummyChar( false ) { } @@ -60,11 +61,12 @@ xub_StrLen* SwTxtAttr::GetEnd() return 0; } -// RemoveFromPool must be called before destructor! -void SwTxtAttr::RemoveFromPool( SfxItemPool& rPool ) +void SwTxtAttr::Destroy( SwTxtAttr * pToDestroy, SfxItemPool& rPool ) { - rPool.Remove( GetAttr() ); - m_pAttr = 0; + if (!pToDestroy) return; + SfxPoolItem * const pAttr = pToDestroy->m_pAttr; + delete pToDestroy; + rPool.Remove( *pAttr ); } int SwTxtAttr::operator==( const SwTxtAttr& rAttr ) const @@ -72,7 +74,7 @@ int SwTxtAttr::operator==( const SwTxtAttr& rAttr ) const return GetAttr() == rAttr.GetAttr(); } -SwTxtAttrEnd::SwTxtAttrEnd( const SfxPoolItem& rAttr, +SwTxtAttrEnd::SwTxtAttrEnd( SfxPoolItem& rAttr, xub_StrLen nStart, xub_StrLen nEnd ) : SwTxtAttr( rAttr, nStart ), m_nEnd( nEnd ) { diff --git a/sw/source/core/txtnode/txtatr2.cxx b/sw/source/core/txtnode/txtatr2.cxx index eca88502f771..18db65d13dc8 100644 --- a/sw/source/core/txtnode/txtatr2.cxx +++ b/sw/source/core/txtnode/txtatr2.cxx @@ -46,24 +46,19 @@ #include <poolfmt.hxx> // RES_POOLCHR_INET_... #include <doc.hxx> // SwDoc #include <fmtruby.hxx> -#include <fmthbsh.hxx> +#include <fmtmeta.hxx> + TYPEINIT1(SwTxtINetFmt,SwClient); TYPEINIT1(SwTxtRuby,SwClient); -/************************************************************************* - * class SwTxtHardBlank - *************************************************************************/ - -SwTxtHardBlank::SwTxtHardBlank( const SwFmtHardBlank& rAttr, xub_StrLen nStt ) - : SwTxtAttr( rAttr, nStt ) - , m_Char( rAttr.GetChar() ) -{ - ASSERT( ' ' != m_Char && '-' != m_Char, - "Invalid character for the HardBlank attribute - " - "must be a normal unicode character" ); -} +// ATT_XMLCONTAINERITEM ****************************** +SwTxtXMLAttrContainer::SwTxtXMLAttrContainer( + SvXMLAttrContainerItem& rAttr, + xub_StrLen nStt, xub_StrLen nEnde ) + : SwTxtAttrEnd( rAttr, nStt, nEnde ) +{} /************************************************************************* * class SwTxtCharFmt @@ -110,20 +105,42 @@ BOOL SwTxtCharFmt::GetInfo( SfxPoolItem& rInfo ) const return FALSE; } + +/************************************************************************* + * class SwTxtAttrNesting + *************************************************************************/ + +SwTxtAttrNesting::SwTxtAttrNesting( SfxPoolItem & i_rAttr, + const xub_StrLen i_nStart, const xub_StrLen i_nEnd ) + : SwTxtAttrEnd( i_rAttr, i_nStart, i_nEnd ) +{ + SetDontExpand( true ); // never expand this attribute + // lock the expand flag: simple guarantee that nesting will not be + // invalidated by expand operations + SetLockExpandFlag( true ); + SetDontExpandStartAttr( true ); + SetNesting( true ); +} + +SwTxtAttrNesting::~SwTxtAttrNesting() +{ +} + + /************************************************************************* * class SwTxtINetFmt *************************************************************************/ SwTxtINetFmt::SwTxtINetFmt( SwFmtINetFmt& rAttr, - xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ) + xub_StrLen nStart, xub_StrLen nEnd ) + : SwTxtAttrNesting( rAttr, nStart, nEnd ) , SwClient( 0 ) , m_pTxtNode( 0 ) , m_bVisited( false ) , m_bVisitedValid( false ) { rAttr.pTxtAttr = this; - SetCharFmtAttr( TRUE ); + SetCharFmtAttr( true ); } SwTxtINetFmt::~SwTxtINetFmt( ) @@ -212,30 +229,17 @@ BOOL SwTxtINetFmt::IsProtect( ) const return m_pTxtNode && m_pTxtNode->IsProtect(); } -// ATT_XNLCONTAINERITEM ****************************** - -SwTxtXMLAttrContainer::SwTxtXMLAttrContainer( - const SvXMLAttrContainerItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ) -{} - - /************************************************************************* * class SwTxtRuby *************************************************************************/ SwTxtRuby::SwTxtRuby( SwFmtRuby& rAttr, xub_StrLen nStart, xub_StrLen nEnd ) - : SwTxtAttrEnd( rAttr, nStart, nEnd ) + : SwTxtAttrNesting( rAttr, nStart, nEnd ) , SwClient( 0 ) , m_pTxtNode( 0 ) { rAttr.pTxtAttr = this; - SetDontExpand( true ); // never expand this attribute - SetLockExpandFlag( true ); - SetDontMergeAttr( true ); - SetDontExpandStartAttr( true ); } SwTxtRuby::~SwTxtRuby() @@ -310,11 +314,26 @@ SwCharFmt* SwTxtRuby::GetCharFmt() return pRet; } -// ****************************** -SwTxt2Lines::SwTxt2Lines( const SvxTwoLinesItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ) +/************************************************************************* + * class SwTxtMeta + *************************************************************************/ + +SwTxtMeta::SwTxtMeta( SwFmtMeta & i_rAttr, + const xub_StrLen i_nStart, const xub_StrLen i_nEnd ) + : SwTxtAttrNesting( i_rAttr, i_nStart, i_nEnd ) + , m_pTxtNode( 0 ) { + i_rAttr.SetTxtAttr( this ); + SetHasDummyChar(true); +} + +SwTxtMeta::~SwTxtMeta() +{ + SwFmtMeta & rFmtMeta( static_cast<SwFmtMeta &>(GetAttr()) ); + if (rFmtMeta.GetTxtAttr() == this) + { + rFmtMeta.SetTxtAttr(0); + } } diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 4080dc823a1e..b34d013f3264 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -368,56 +368,6 @@ static bool lcl_HaveCommonAttributes( IStyleAccess& rStyleAccess, return bRet; } -/* - * Ein Zeichen wurde eingefuegt. - */ - -SwTxtNode& SwTxtNode::Insert( xub_Unicode c, const SwIndex &rIdx ) -{ - xub_StrLen nOrigLen = m_Text.Len(); - - ASSERT( rIdx <= nOrigLen, "SwTxtNode::Insert: invalid index." ); - ASSERT( nOrigLen < STRING_LEN, - "SwTxtNode::Insert: node text with insertion > STRING_LEN." ); - - if ( nOrigLen == m_Text.Insert( c, rIdx.GetIndex() ).Len() ) - return *this; - - Update(rIdx,1); - - // leere Hints und Feldattribute an rIdx.GetIndex suchen - if ( HasHints() ) - { - USHORT* pEndIdx; - for ( USHORT i=0; i < m_pSwpHints->Count() && - rIdx >= *(*m_pSwpHints)[i]->GetStart(); ++i) - { - SwTxtAttr *pHt = m_pSwpHints->GetTextHint(i); - pEndIdx = pHt->GetEnd(); - if ( pEndIdx ) - { - // leere Hints an rIdx.GetIndex ? - BOOL bEmpty = *pEndIdx == *pHt->GetStart() - && rIdx == *pHt->GetStart(); - - if( bEmpty ) - { - m_pSwpHints->DeleteAtPos(i); - if( bEmpty ) - *pHt->GetStart() -= 1; - else - *pEndIdx -= 1; - Insert(pHt); - } - } - } - TryDeleteSwpHints(); - } - // den Frames Bescheid sagen - SwInsChr aHint( rIdx.GetIndex()-1 ); - SwModify::Modify( 0, &aHint ); - return *this; -} inline BOOL InRange(xub_StrLen nIdx, xub_StrLen nStart, xub_StrLen nEnd) { return ((nIdx >=nStart) && (nIdx <= nEnd)); @@ -454,7 +404,6 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, USHORT i = 0; xub_StrLen nStt = rIdx.GetIndex(); xub_StrLen nEnd = nStt + nLen; - xub_StrLen *pAttrEnd; xub_StrLen nAttrStart; SwTxtAttr *pHt; @@ -479,8 +428,8 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, pHt = m_pSwpHints->GetTextHint(i); // attributes without end stay in! - pAttrEnd = pHt->GetEnd(); - if ( !pAttrEnd ) + xub_StrLen * const pAttrEnd = pHt->GetEnd(); + if ( !pAttrEnd /*|| pHt->HasDummyChar()*/ ) // see bInclRefToxMark { i++; continue; @@ -514,8 +463,12 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, else if ( !bInclRefToxMark ) { // 3. case: Reset all attributes except from ref/toxmarks: - bSkipAttr = RES_TXTATR_REFMARK == pHt->Which() || - RES_TXTATR_TOXMARK == pHt->Which(); + // skip hints with CH_TXTATR here + // (deleting those is ONLY allowed for UNDO!) + bSkipAttr = RES_TXTATR_REFMARK == pHt->Which() + || RES_TXTATR_TOXMARK == pHt->Which() + || RES_TXTATR_META == pHt->Which() + || RES_TXTATR_METAFIELD == pHt->Which(); } if ( bSkipAttr ) @@ -547,8 +500,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, if ( pStyleHandle.get() ) { - SwTxtAttr* pNew = MakeTxtAttr( *pStyleHandle, nAttrStart, nAttrEnd ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + *pStyleHandle, nAttrStart, nAttrEnd ); + InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); } // if the last attribute is a Field, the HintsArray is @@ -574,8 +528,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, if ( pStyleHandle.get() && nAttrStart < nEnd ) { - SwTxtAttr* pNew = MakeTxtAttr( *pStyleHandle, nAttrStart, nEnd ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + *pStyleHandle, nAttrStart, nEnd ); + InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); } bChanged = TRUE; @@ -601,8 +556,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, if ( pStyleHandle.get() ) { - SwTxtAttr* pNew = MakeTxtAttr( *pStyleHandle, nStt, nAttrEnd ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + *pStyleHandle, nStt, nAttrEnd ); + InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); } } else if( nLen ) // Fall: 4 @@ -620,20 +576,23 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, if ( pStyleHandle.get() && nStt < nEnd ) { - SwTxtAttr* pNew = MakeTxtAttr( *pStyleHandle, nStt, nEnd ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + *pStyleHandle, nStt, nEnd ); + InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); } if( nEnd < nTmpEnd ) { - SwTxtAttr* pNew = MakeTxtAttr( pHt->GetAttr(), nEnd, nTmpEnd ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + pHt->GetAttr(), nEnd, nTmpEnd ); if ( pNew ) { SwTxtCharFmt* pCharFmt = dynamic_cast<SwTxtCharFmt*>(pHt); if ( pCharFmt ) static_cast<SwTxtCharFmt*>(pNew)->SetSortNumber( pCharFmt->GetSortNumber() ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + InsertHint( pNew, + nsSetAttrMode::SETATTR_NOHINTADJUST ); } @@ -1003,7 +962,7 @@ void SwTxtNode::SetLanguageAndFont( const SwPaM &rPaM, aSet.Put( aFontItem ); } - GetDoc()->Insert( rPaM, aSet, 0 ); + GetDoc()->InsertItemSet( rPaM, aSet, 0 ); // SetAttr( aSet ); <- Does not set language attribute of empty paragraphs correctly, // <- because since there is no selection the flag to garbage // <- collect all attributes is set, and therefore attributes spanned diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index ec62ab78de79..ffc831fe16e5 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -352,7 +352,7 @@ void SwHistorySetRefMark::SetInDoc( SwDoc* pDoc, bool ) // if a reference mark without an end already exists here: must not insert! if ( m_nStart != m_nEnd || - !pTxtNd->GetTxtAttr( m_nStart, RES_TXTATR_REFMARK ) ) + !pTxtNd->GetTxtAttrForCharAt( m_nStart, RES_TXTATR_REFMARK ) ) { pTxtNd->InsertItem( aRefMark, m_nStart, m_nEnd, nsSetAttrMode::SETATTR_NOTXTATRCHR ); @@ -433,7 +433,7 @@ void SwHistoryResetTxt::SetInDoc( SwDoc* pDoc, bool ) ASSERT( pTxtNd, "SwHistoryResetTxt: no TextNode" ); if ( pTxtNd ) { - pTxtNd->Delete( m_nAttr, m_nStart, m_nEnd ); + pTxtNd->DeleteAttributes( m_nAttr, m_nStart, m_nEnd ); } } @@ -514,12 +514,13 @@ void SwHistorySetFootnote::SetInDoc( SwDoc* pDoc, bool ) m_pUndo->GetHistory()->Rollback( pDoc ); } - pTxtNd->Insert( pTxtFtn ); + pTxtNd->InsertHint( pTxtFtn ); } else { - SwTxtFtn *pFtn = const_cast<SwTxtFtn*>( - static_cast<const SwTxtFtn*>(pTxtNd->GetTxtAttr( m_nStart ))); + SwTxtFtn * const pFtn = + const_cast<SwTxtFtn*>( static_cast<const SwTxtFtn*>( + pTxtNd->GetTxtAttrForCharAt( m_nStart ))); SwFmtFtn &rFtn = const_cast<SwFmtFtn&>(pFtn->GetFtn()); rFtn.SetNumStr( m_FootnoteNumber ); if ( rFtn.IsEndNote() != m_bEndNote ) @@ -615,6 +616,14 @@ SwHistoryBookmark::SwHistoryBookmark( { m_aKeycode = pBookmark->GetKeyCode(); m_aShortName = pBookmark->GetShortName(); + + ::sfx2::Metadatable * const pMetadatable( + const_cast< ::sfx2::Metadatable * >( // CreateUndo should be const? + dynamic_cast< ::sfx2::Metadatable const* >(pBookmark))); + if (pMetadatable) + { + m_pMetadataUndo = pMetadatable->CreateUndo(); + } } } @@ -681,6 +690,16 @@ void SwHistoryBookmark::SetInDoc( SwDoc* pDoc, bool ) { pBookmark->SetKeyCode(m_aKeycode); pBookmark->SetShortName(m_aShortName); + if (m_pMetadataUndo) + { + ::sfx2::Metadatable * const pMeta( + dynamic_cast< ::sfx2::Metadatable* >(pBookmark)); + OSL_ENSURE(pMeta, "metadata undo, but not metadatable?"); + if (pMeta) + { + pMeta->RestoreMetadata(m_pMetadataUndo); + } + } } } pDoc->DoUndo(bDoesUndo); @@ -819,6 +838,25 @@ SwHistoryResetAttrSet::SwHistoryResetAttrSet( const SfxItemSet& rSet, while( TRUE ) { const USHORT nWhich = aIter.GetCurItem()->Which(); + +#ifndef PRODUCT + switch (nWhich) + { + case RES_TXTATR_REFMARK: + case RES_TXTATR_TOXMARK: + if (m_nStart != m_nEnd) break; // else: fall through! + case RES_TXTATR_FIELD: + case RES_TXTATR_FLYCNT: + case RES_TXTATR_FTN: + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + ASSERT(rSet.Count() == 1, + "text attribute with CH_TXTATR, but not the only one:" + "\nnot such a good idea"); + break; + } +#endif + // Character attribute cannot be inserted into the hints array // anymore. Therefore we have to treat them as one RES_TXTATR_AUTOFMT: if (isCHRATR(nWhich)) @@ -868,7 +906,7 @@ void SwHistoryResetAttrSet::SetInDoc( SwDoc* pDoc, bool ) for ( USHORT n = m_Array.Count(); n; --n, ++pArr ) { static_cast<SwTxtNode*>(pCntntNd)-> - Delete( *pArr, m_nStart, m_nEnd ); + DeleteAttributes( *pArr, m_nStart, m_nEnd ); } } } @@ -1292,7 +1330,6 @@ void SwHistory::CopyAttr( SwpHints* pHts, ULONG nNodeIdx, switch( pHt->Which() ) { case RES_TXTATR_FIELD: - case RES_TXTATR_HARDBLANK: // keine Felder, .. kopieren ?? if( !bFields ) bNextAttr = TRUE; @@ -1397,40 +1434,45 @@ void SwRegHistory::AddHint( SwTxtAttr* pHt, const bool bNew ) } -SwRegHistory::SwRegHistory( SwTxtNode* pTxtNode, const SfxItemSet& rSet, - xub_StrLen nStart, xub_StrLen nEnd, USHORT nFlags, - SwHistory* pHst ) - : SwClient( pTxtNode ) - , m_pHistory( pHst ) - , m_nNodeIndex( pTxtNode->GetIndex() ) +bool SwRegHistory::InsertItems( const SfxItemSet& rSet, + xub_StrLen const nStart, xub_StrLen const nEnd, SetAttrMode const nFlags ) { if( !rSet.Count() ) - return; + return false; - BOOL bInsert; + SwTxtNode * const pTxtNode = + dynamic_cast<SwTxtNode *>(const_cast<SwModify *>(GetRegisteredIn())); - if( pTxtNode->GetpSwpHints() && pHst ) + ASSERT(pTxtNode, "SwRegHistory not registered at text node?"); + if (!pTxtNode) + return false; + + if ( pTxtNode->GetpSwpHints() && m_pHistory ) { pTxtNode->GetpSwpHints()->Register( this ); - bInsert = pTxtNode->SetAttr( rSet, nStart, nEnd, nFlags ); + } + + const bool bInserted = pTxtNode->SetAttr( rSet, nStart, nEnd, nFlags ); + // Achtung: Durch das Einfuegen eines Attributs kann das Array // geloescht werden!!! Wenn das einzufuegende zunaechst ein vorhandenes // loescht, selbst aber nicht eingefuegt werden braucht, weil die // Absatzattribute identisch sind( -> bForgetAttr in SwpHints::Insert ) - if ( pTxtNode->GetpSwpHints() ) - pTxtNode->GetpSwpHints()->DeRegister(); + if ( pTxtNode->GetpSwpHints() && m_pHistory ) + { + pTxtNode->GetpSwpHints()->DeRegister(); } - else - bInsert = pTxtNode->SetAttr( rSet, nStart, nEnd, nFlags ); - if( pHst && bInsert ) + if ( m_pHistory && bInserted ) { SwHistoryHint* pNewHstr = new SwHistoryResetAttrSet( rSet, pTxtNode->GetIndex(), nStart, nEnd ); // der NodeIndex kann verschoben sein !! - pHst->m_SwpHstry.Insert( pNewHstr, pHst->Count() ); + m_pHistory->m_SwpHstry.Insert( pNewHstr, m_pHistory->Count() ); } + + return bInserted; } void SwRegHistory::RegisterInModify( SwModify* pRegIn, const SwNode& rNd ) diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index 7177a622e21b..e5312b3cefdd 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -560,18 +560,17 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) SwTxtNode *pTxtNode = (SwTxtNode*)&pPos->nNode.GetNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); -#ifndef PRODUCT + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( nIdx, RES_TXTATR_FLYCNT ); ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFrmFmt, "Wrong TxtFlyCnt-Hint." ); -#endif const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); //Die Verbindung ist geloest, jetzt muss noch das Attribut vernichtet //werden. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx ); } { @@ -618,8 +617,9 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) { const SwPosition* pPos = aNewAnchor.GetCntntAnchor(); SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); - ASSERT( pTxtNd, "Kein Textnode an dieser Position" ); - pTxtNd->InsertItem( SwFmtFlyCnt( pFrmFmt ), pPos->nContent.GetIndex(), 0 ); + ASSERT( pTxtNd, "no Text Node at position." ); + SwFmtFlyCnt aFmt( pFrmFmt ); + pTxtNd->InsertItem( aFmt, pPos->nContent.GetIndex(), 0 ); } @@ -767,7 +767,9 @@ void SwUndoResetAttr::Redo( SwUndoIter& rUndoIter ) } // gefunden, also loeschen if( nCnt-- ) - rDoc.Delete( aArr[ nCnt ] ); + { + rDoc.DeleteTOXMark( aArr[ nCnt ] ); + } } } break; @@ -815,7 +817,7 @@ void SwUndoResetAttr::SetAttrs( const SvUShortsSort& rArr ) SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxPoolItem& rAttr, - USHORT nFlags ) + const SetAttrMode nFlags ) : SwUndo( UNDO_INSATTR ), SwUndRng( rRange ) , m_AttrSet( rRange.GetDoc()->GetAttrPool(), rAttr.Which(), rAttr.Which() ) , m_pHistory( new SwHistory ) @@ -828,7 +830,7 @@ SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxPoolItem& rAttr, } SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxItemSet& rSet, - USHORT nFlags ) + const SetAttrMode nFlags ) : SwUndo( UNDO_INSATTR ), SwUndRng( rRange ) , m_AttrSet( rSet ) , m_pHistory( new SwHistory ) @@ -899,7 +901,7 @@ void SwUndoAttr::Undo( SwUndoIter& rUndoIter ) const bool bToLast = (1 == m_AttrSet.Count()) && (RES_TXTATR_FIELD <= *m_AttrSet.GetRanges()) - && (*m_AttrSet.GetRanges() <= RES_TXTATR_HARDBLANK); + && (*m_AttrSet.GetRanges() <= RES_TXTATR_FTN); // restore old values m_pHistory->TmpRollback( pDoc, 0, !bToLast ); @@ -948,15 +950,15 @@ void SwUndoAttr::Repeat( SwUndoIter& rUndoIter ) // RefMarks are not repeat capable if ( SFX_ITEM_SET != m_AttrSet.GetItemState( RES_TXTATR_REFMARK, FALSE ) ) { - rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, - m_AttrSet, m_nInsertFlags ); + rUndoIter.GetDoc().InsertItemSet( *rUndoIter.pAktPam, + m_AttrSet, m_nInsertFlags ); } else if ( 1 < m_AttrSet.Count() ) { SfxItemSet aTmpSet( m_AttrSet ); aTmpSet.ClearItem( RES_TXTATR_REFMARK ); - rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, - aTmpSet, m_nInsertFlags ); + rUndoIter.GetDoc().InsertItemSet( *rUndoIter.pAktPam, + aTmpSet, m_nInsertFlags ); } rUndoIter.pLastUndoObj = this; } @@ -974,7 +976,7 @@ void SwUndoAttr::Redo( SwUndoIter& rUndoIter ) RedlineMode_t eOld = rDoc.GetRedlineMode(); rDoc.SetRedlineMode_intern(static_cast<RedlineMode_t>( eOld & ~nsRedlineMode_t::REDLINE_IGNORE)); - rDoc.Insert( rPam, m_AttrSet, m_nInsertFlags ); + rDoc.InsertItemSet( rPam, m_AttrSet, m_nInsertFlags ); if ( ULONG_MAX != m_nNodeIndex ) { @@ -995,7 +997,7 @@ void SwUndoAttr::Redo( SwUndoIter& rUndoIter ) } else { - rDoc.Insert( rPam, m_AttrSet, m_nInsertFlags ); + rDoc.InsertItemSet( rPam, m_AttrSet, m_nInsertFlags ); } rUndoIter.pLastUndoObj = 0; diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 0ed447d8204f..d9a2e6e8486c 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -386,7 +386,7 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, // loesche jetzt noch den Text (alle Attribut-Aenderungen kommen in // die Undo-History pSttStr = (String*)new String( pSttTxtNd->GetTxt().Copy( nSttCntnt, nLen )); - pSttTxtNd->Erase( pStt->nContent, nLen ); + pSttTxtNd->EraseText( pStt->nContent, nLen ); if( pSttTxtNd->GetpSwpHints() ) pSttTxtNd->GetpSwpHints()->DeRegister(); @@ -422,7 +422,7 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, // die Undo-History pEndStr = (String*)new String( pEndTxtNd->GetTxt().Copy( 0, pEnd->nContent.GetIndex() )); - pEndTxtNd->Erase( aEndIdx, pEnd->nContent.GetIndex() ); + pEndTxtNd->EraseText( aEndIdx, pEnd->nContent.GetIndex() ); if( pEndTxtNd->GetpSwpHints() ) pEndTxtNd->GetpSwpHints()->DeRegister(); @@ -511,7 +511,7 @@ BOOL SwUndoDelete::CanGrouping( SwDoc* pDoc, const SwPaM& rDelPam ) nUChrPos++; } pSttStr->Insert( cDelChar, nUChrPos ); - pDelTxtNd->Erase( pStt->nContent, 1 ); + pDelTxtNd->EraseText( pStt->nContent, 1 ); bGroup = TRUE; return TRUE; @@ -711,7 +711,8 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) } if( pTxtNd ) { - pTxtNd->Insert( *pEndStr, aPos.nContent, INS_NOHINTEXPAND ); + pTxtNd->InsertText( *pEndStr, aPos.nContent, + IDocumentContentOperations::INS_NOHINTEXPAND ); // METADATA: restore pTxtNd->RestoreMetadata(m_pMetadataUndoEnd); } @@ -804,7 +805,8 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) // SectionNode-Modus und von oben nach unten selektiert: // -> im StartNode steht noch der Rest vom Join => loeschen aPos.nContent.Assign( pTxtNd, nSttCntnt ); - pTxtNd->Insert( *pSttStr, aPos.nContent, INS_NOHINTEXPAND ); + pTxtNd->InsertText( *pSttStr, aPos.nContent, + IDocumentContentOperations::INS_NOHINTEXPAND ); // METADATA: restore pTxtNd->RestoreMetadata(m_pMetadataUndoStart); } diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index d84b12ba5bda..87522d4d59f8 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -330,7 +330,7 @@ void SwUndoSaveCntnt::MoveToUndoNds( SwPaM& rPaM, SwNodeIndex* pNodeIdx, } else { - rDoc.GetNodes().Move( rPaM, aPos, rNds, FALSE ); + rDoc.GetNodes().MoveRange( rPaM, aPos, rNds ); SwTxtNode* pTxtNd = aPos.nNode.GetNode().GetTxtNode(); if( pTxtNd ) // fuege einen Trenner fuer die Attribute ein ! @@ -350,7 +350,10 @@ void SwUndoSaveCntnt::MoveToUndoNds( SwPaM& rPaM, SwNodeIndex* pNodeIdx, ++aPos.nContent; } else - pTxtNd->Insert( ' ', aPos.nContent, INS_NOHINTEXPAND); + { + pTxtNd->InsertText( sal_Unicode(' '), aPos.nContent, + IDocumentContentOperations::INS_NOHINTEXPAND ); + } } } if( pEndNdIdx ) @@ -404,7 +407,7 @@ void SwUndoSaveCntnt::MoveFromUndoNds( SwDoc& rDoc, ULONG nNodeIdx, if( pTxtNd->GetTxt().Len() ) { GoInCntnt( aPaM, fnMoveBackward ); - pTxtNd->Erase( aPaM.GetPoint()->nContent, 1 ); + pTxtNd->EraseText( aPaM.GetPoint()->nContent, 1 ); } aPaM.SetMark(); @@ -413,7 +416,7 @@ void SwUndoSaveCntnt::MoveFromUndoNds( SwDoc& rDoc, ULONG nNodeIdx, _SaveRedlEndPosForRestore aRedlRest( rInsPos.nNode, rInsPos.nContent.GetIndex() ); - rNds.Move( aPaM, rInsPos, rDoc.GetNodes() ); + rNds.MoveRange( aPaM, rInsPos, rDoc.GetNodes() ); // noch den letzen Node loeschen. if( !aPaM.GetPoint()->nContent.GetIndex() || @@ -537,11 +540,12 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, SwTxtNode* pTxtNd = (SwTxtNode*)pFtnNd; if( !pHistory ) pHistory = new SwHistory; - SwTxtAttr* pFtnHnt = pTxtNd->GetTxtAttr( nFtnSttIdx ); + SwTxtAttr* const pFtnHnt = + pTxtNd->GetTxtAttrForCharAt( nFtnSttIdx ); ASSERT( pFtnHnt, "kein FtnAttribut" ); SwIndex aIdx( pTxtNd, nFtnSttIdx ); pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), false ); - pTxtNd->Erase( aIdx, 1 ); + pTxtNd->EraseText( aIdx, 1 ); } while( nPos-- && ( pFtnNd = &( pSrch = rFtnArr[ nPos ] )-> @@ -560,11 +564,12 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, SwTxtNode* pTxtNd = (SwTxtNode*)pFtnNd; if( !pHistory ) pHistory = new SwHistory; - SwTxtAttr* pFtnHnt = pTxtNd->GetTxtAttr( nFtnSttIdx ); + SwTxtAttr* const pFtnHnt = + pTxtNd->GetTxtAttrForCharAt( nFtnSttIdx ); ASSERT( pFtnHnt, "kein FtnAttribut" ); SwIndex aIdx( pTxtNd, nFtnSttIdx ); pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), false ); - pTxtNd->Erase( aIdx, 1 ); + pTxtNd->EraseText( aIdx, 1 ); } } } @@ -598,7 +603,8 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, if( !pHistory ) pHistory = new SwHistory; SwTxtNode* pTxtNd = pDoc->GetNodes()[ pAPos->nNode]->GetTxtNode(); - SwTxtAttr* pFlyHnt = pTxtNd->GetTxtAttr( pAPos->nContent.GetIndex()); + SwTxtAttr* const pFlyHnt = pTxtNd->GetTxtAttrForCharAt( + pAPos->nContent.GetIndex()); ASSERT( pFlyHnt, "kein FlyAttribut" ); pHistory->Add( pFlyHnt, 0, false ); // n wieder zurueck, damit nicht ein Format uebesprungen wird ! diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index baff3c0d5ce6..dd261282e5c7 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -123,9 +123,9 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) { // es muss mindestens das Attribut im TextNode stehen SwCntntNode* pCNd = aAnchor.GetCntntAnchor()->nNode.GetNode().GetCntntNode(); - ASSERT( pCNd->IsTxtNode(), "Kein Textnode an dieser Position" ); - ((SwTxtNode*)pCNd)->InsertItem( SwFmtFlyCnt( - (SwFlyFrmFmt*)pFrmFmt ), nCntPos, nCntPos ); + ASSERT( pCNd->IsTxtNode(), "no Text Node at position." ); + SwFmtFlyCnt aFmt( pFrmFmt ); + static_cast<SwTxtNode*>(pCNd)->InsertItem( aFmt, nCntPos, nCntPos ); } pFrmFmt->MakeFrms(); @@ -199,14 +199,15 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc ) nCntPos = pPos->nContent.GetIndex(); SwTxtNode *pTxtNd = pDoc->GetNodes()[ pPos->nNode ]->GetTxtNode(); ASSERT( pTxtNd, "Kein Textnode gefunden" ); - SwTxtFlyCnt* pAttr = (SwTxtFlyCnt*)pTxtNd->GetTxtAttr( nCntPos ); + SwTxtFlyCnt* const pAttr = static_cast<SwTxtFlyCnt*>( + pTxtNd->GetTxtAttrForCharAt( nCntPos, RES_TXTATR_FLYCNT ) ); // Attribut steht noch im TextNode, loeschen if( pAttr && pAttr->GetFlyCnt().GetFrmFmt() == pFrmFmt ) { // Pointer auf 0, nicht loeschen ((SwFmtFlyCnt&)pAttr->GetFlyCnt()).SetFlyFmt(); SwIndex aIdx( pPos->nContent ); - pTxtNd->Erase( aIdx, 1 ); + pTxtNd->EraseText( aIdx, 1 ); } } else if( FLY_AUTO_CNTNT == nRndId ) @@ -558,18 +559,17 @@ void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter ) SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); -#ifndef PRODUCT + SwTxtAttr * pHnt = pTxtNode->GetTxtAttrForCharAt( + nIdx, RES_TXTATR_FLYCNT ); ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFrmFmt, "Wrong TxtFlyCnt-Hint." ); -#endif - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); // Die Verbindung ist geloest, jetzt muss noch das Attribut // vernichtet werden. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx ); } // Anker umsetzen @@ -580,8 +580,9 @@ void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter ) if( FLY_IN_CNTNT == aNewAnchor.GetAnchorId() ) { SwPosition* pPos = (SwPosition*)aNewAnchor.GetCntntAnchor(); - pPos->nNode.GetNode().GetTxtNode()->InsertItem( - SwFmtFlyCnt( (SwFlyFrmFmt*)pFrmFmt ), nOldCntnt, 0 ); + SwFmtFlyCnt aFmt( pFrmFmt ); + pPos->nNode.GetNode().GetTxtNode()->InsertItem( aFmt, + nOldCntnt, 0 ); } pFrmFmt->MakeFrms(); diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index cdfc9c1142ee..54ed7ea8421d 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -157,14 +157,15 @@ void lcl_SaveAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) // TextAttribut zerstoeren SwTxtNode *pTxtNd = pFmt->GetDoc()->GetNodes()[ rNodePos ]->GetTxtNode(); ASSERT( pTxtNd, "Kein Textnode gefunden" ); - SwTxtFlyCnt* pAttr = (SwTxtFlyCnt*)pTxtNd->GetTxtAttr( nCntntPos ); + SwTxtFlyCnt* pAttr = static_cast<SwTxtFlyCnt*>( + pTxtNd->GetTxtAttrForCharAt( nCntntPos, RES_TXTATR_FLYCNT )); // Attribut steht noch im TextNode, loeschen if( pAttr && pAttr->GetFlyCnt().GetFrmFmt() == pFmt ) { // Pointer auf 0, nicht loeschen ((SwFmtFlyCnt&)pAttr->GetFlyCnt()).SetFlyFmt(); SwIndex aIdx( pTxtNd, nCntntPos ); - pTxtNd->Erase( aIdx, 1 ); + pTxtNd->EraseText( aIdx, 1 ); } } else if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) @@ -198,9 +199,9 @@ void lcl_RestoreAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) { SwTxtNode *pTxtNd = aIdx.GetNode().GetTxtNode(); - ASSERT( pTxtNd, "Kein Textnode gefunden" ); - pTxtNd->InsertItem( SwFmtFlyCnt( (SwFrmFmt*)pFmt ), - nCntntPos, nCntntPos ); + ASSERT( pTxtNd, "no Text Node" ); + SwFmtFlyCnt aFmt( pFmt ); + pTxtNd->InsertItem( aFmt, nCntntPos, nCntntPos ); } } } diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index 1335844c7ff9..85db90c85701 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -142,10 +142,13 @@ void SwUndoInsert::Init(const SwNodeIndex & rNd) // #111827# SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd, xub_StrLen nCnt, - xub_StrLen nL, BOOL bWDelim ) + xub_StrLen nL, + const IDocumentContentOperations::InsertFlags nInsertFlags, + BOOL bWDelim ) : SwUndo(UNDO_TYPING), pPos( 0 ), pTxt( 0 ), pRedlData( 0 ), nNode( rNd.GetIndex() ), nCntnt(nCnt), nLen(nL), bIsWordDelim( bWDelim ), bIsAppend( FALSE ) + , m_nInsertFlags(nInsertFlags) { Init(rNd); } @@ -155,6 +158,7 @@ SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd ) : SwUndo(UNDO_SPLITNODE), pPos( 0 ), pTxt( 0 ), pRedlData( 0 ), nNode( rNd.GetIndex() ), nCntnt(0), nLen(1), bIsWordDelim( FALSE ), bIsAppend( TRUE ) + , m_nInsertFlags(IDocumentContentOperations::INS_EMPTYEXPAND) { Init(rNd); } @@ -247,7 +251,7 @@ SwUndoInsert::~SwUndoInsert() { SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNd, "kein TextNode, aus dem geloescht werden soll" ); - pTxtNd->Erase( pPos->nContent ); + pTxtNd->EraseText( pPos->nContent ); pPos->nNode++; } pPos->nContent.Assign( 0, 0 ); @@ -295,15 +299,15 @@ void SwUndoInsert::Undo( SwUndoIter& rUndoIter ) aPaM.SetMark(); - if( pCNd->IsTxtNode() ) // Text !! + SwTxtNode * const pTxtNode( pCNd->GetTxtNode() ); + if ( pTxtNode ) { aPaM.GetPoint()->nContent -= nLen; if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() )) pTmpDoc->DeleteRedline( aPaM, true, USHRT_MAX ); RemoveIdxFromRange( aPaM, FALSE ); - pTxt = new String( ((SwTxtNode*)pCNd)->GetTxt().Copy( - nCntnt-nLen, nLen ) ); - ((SwTxtNode*)pCNd)->Erase( aPaM.GetPoint()->nContent, nLen ); + pTxt = new String( pTxtNode->GetTxt().Copy(nCntnt-nLen, nLen) ); + pTxtNode->EraseText( aPaM.GetPoint()->nContent, nLen ); } else // ansonsten Grafik/OLE/Text/... { @@ -379,9 +383,10 @@ void SwUndoInsert::Redo( SwUndoIter& rUndoIter ) if( pTxt ) { - ASSERT( pCNd->IsTxtNode(), "wo ist mein Textnode ??" ); - ((SwTxtNode*)pCNd)->Insert( *pTxt, pPam->GetMark()->nContent, - INS_EMPTYEXPAND ); + SwTxtNode *const pTxtNode = pCNd->GetTxtNode(); + ASSERT( pTxtNode, "where is my textnode ?" ); + pTxtNode->InsertText( *pTxt, pPam->GetMark()->nContent, + m_nInsertFlags ); DELETEZ( pTxt ); } else @@ -445,7 +450,8 @@ void SwUndoInsert::Repeat( SwUndoIter& rUndoIter ) String aTxt( ((SwTxtNode*)pCNd)->GetTxt() ); BOOL bGroupUndo = rDoc.DoesGroupUndo(); rDoc.DoGroupUndo( FALSE ); - rDoc.Insert( *rUndoIter.pAktPam, aTxt.Copy( nCntnt - nLen, nLen ), true); + rDoc.InsertString( *rUndoIter.pAktPam, + aTxt.Copy( nCntnt - nLen, nLen ) ); rDoc.DoGroupUndo( bGroupUndo ); } break; @@ -712,7 +718,7 @@ void _UnReplaceData::Undo( SwUndoIter& rIter ) SwIndex aIdx( pNd, m_nSttCnt ); if( m_nSttNd == m_nEndNd ) { - pNd->Erase( aIdx, m_sIns.Len() ); + pNd->EraseText( aIdx, m_sIns.Len() ); } else { @@ -741,7 +747,9 @@ void _UnReplaceData::Undo( SwUndoIter& rIter ) } if( m_sOld.Len() ) - pNd->Insert( m_sOld, aIdx ); + { + pNd->InsertText( m_sOld, aIdx ); + } if( pHistory ) { @@ -813,7 +821,7 @@ void _UnReplaceData::Redo( SwUndoIter& rIter ) delete pHistory, pHistory = 0; } - rDoc.Replace( rPam, m_sIns, m_bRegExp ); + rDoc.ReplaceRange( rPam, m_sIns, m_bRegExp ); rPam.DeleteMark(); rDoc.DoUndo( bUndo ); } diff --git a/sw/source/core/undo/unmove.cxx b/sw/source/core/undo/unmove.cxx index 269f8de3cd63..ac318b2aab6d 100644 --- a/sw/source/core/undo/unmove.cxx +++ b/sw/source/core/undo/unmove.cxx @@ -207,7 +207,9 @@ void SwUndoMove::Undo( SwUndoIter& rUndoIter ) SwNodeRange aRg( aIdx, aIdx ); aRg.aEnd = nDestEndNode; aIdx = nInsPosNode; - if( !pDoc->Move( aRg, aIdx, IDocumentContentOperations::DOC_MOVEDEFAULT ) ) + bool bSuccess = pDoc->MoveNodeRange( aRg, aIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT ); + if (!bSuccess) break; } else @@ -231,7 +233,10 @@ void SwUndoMove::Undo( SwUndoIter& rUndoIter ) ((SwTxtNode*)pCNd)->ClearSwpHintsArr( false ); // an der InsertPos erstmal alle Attribute entfernen, - if( !pDoc->Move( aPam, aPos, ( bMoveRedlines ? IDocumentContentOperations::DOC_MOVEREDLINES : IDocumentContentOperations::DOC_MOVEDEFAULT ) ) ) + const bool bSuccess = pDoc->MoveRange( aPam, aPos, (bMoveRedlines) + ? IDocumentContentOperations::DOC_MOVEREDLINES + : IDocumentContentOperations::DOC_MOVEDEFAULT ); + if (!bSuccess) break; aPam.Exchange(); @@ -294,7 +299,9 @@ void SwUndoMove::Redo( SwUndoIter& rUndoIter ) { // nur ein Move mit SwRange SwNodeRange aRg( rNds, nSttNode, rNds, nEndNode ); - rDoc.Move( aRg, aIdx, ( bMoveRedlines ? IDocumentContentOperations::DOC_MOVEREDLINES : IDocumentContentOperations::DOC_MOVEDEFAULT ) ); + rDoc.MoveNodeRange( aRg, aIdx, (bMoveRedlines) + ? IDocumentContentOperations::DOC_MOVEREDLINES + : IDocumentContentOperations::DOC_MOVEDEFAULT ); } else { @@ -310,7 +317,8 @@ void SwUndoMove::Redo( SwUndoIter& rUndoIter ) BOOL bJoinTxt = aIdx.GetNode().IsTxtNode(); aIdx--; - rDoc.Move( aPam, aMvPos, IDocumentContentOperations::DOC_MOVEDEFAULT ); + rDoc.MoveRange( aPam, aMvPos, + IDocumentContentOperations::DOC_MOVEDEFAULT ); if( nSttNode != nEndNode && bJoinTxt ) { diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx index e01c2debaf56..54997a43a15b 100644 --- a/sw/source/core/undo/unovwr.cxx +++ b/sw/source/core/undo/unovwr.cxx @@ -105,13 +105,14 @@ SwUndoOverwrite::SwUndoOverwrite( SwDoc* pDoc, SwPosition& rPos, BOOL bOldExpFlg = pTxtNd->IsIgnoreDontExpand(); pTxtNd->SetIgnoreDontExpand( TRUE ); - pTxtNd->Insert( cIns, rPos.nContent ); + pTxtNd->InsertText( cIns, rPos.nContent, + IDocumentContentOperations::INS_EMPTYEXPAND ); aInsStr.Insert( cIns ); if( !bInsChar ) { const SwIndex aTmpIndex( rPos.nContent, -2 ); - pTxtNd->Erase( aTmpIndex, 1 ); + pTxtNd->EraseText( aTmpIndex, 1 ); } pTxtNd->SetIgnoreDontExpand( bOldExpFlg ); @@ -143,7 +144,7 @@ BOOL SwUndoOverwrite::CanGrouping( SwDoc* pDoc, SwPosition& rPos, CharClass& rCC = GetAppCharClass(); // befrage das einzufuegende Charakter - if( ( CH_TXTATR_BREAKWORD == cIns && CH_TXTATR_INWORD == cIns ) || + if (( CH_TXTATR_BREAKWORD == cIns || CH_TXTATR_INWORD == cIns ) || rCC.isLetterNumeric( String( cIns ), 0 ) != rCC.isLetterNumeric( aInsStr, aInsStr.Len()-1 ) ) return FALSE; @@ -183,13 +184,14 @@ BOOL SwUndoOverwrite::CanGrouping( SwDoc* pDoc, SwPosition& rPos, BOOL bOldExpFlg = pDelTxtNd->IsIgnoreDontExpand(); pDelTxtNd->SetIgnoreDontExpand( TRUE ); - pDelTxtNd->Insert( cIns, rPos.nContent ); + pDelTxtNd->InsertText( cIns, rPos.nContent, + IDocumentContentOperations::INS_EMPTYEXPAND ); aInsStr.Insert( cIns ); if( !bInsChar ) { const SwIndex aTmpIndex( rPos.nContent, -2 ); - pDelTxtNd->Erase( aTmpIndex, 1 ); + pDelTxtNd->EraseText( aTmpIndex, 1 ); } pDelTxtNd->SetIgnoreDontExpand( bOldExpFlg ); @@ -225,7 +227,7 @@ void SwUndoOverwrite::Undo( SwUndoIter& rUndoIter ) if( aInsStr.Len() > aDelStr.Len() ) { rIdx += aDelStr.Len(); - pTxtNd->Erase( rIdx, aInsStr.Len() - aDelStr.Len() ); + pTxtNd->EraseText( rIdx, aInsStr.Len() - aDelStr.Len() ); rIdx = nSttCntnt; } @@ -242,9 +244,9 @@ void SwUndoOverwrite::Undo( SwUndoIter& rUndoIter ) { // einzeln, damit die Attribute stehen bleiben !!! *pTmpStr = aDelStr.GetChar( n ); - pTxtNd->Insert( aTmpStr, rIdx /*???, SETATTR_NOTXTATRCHR*/ ); + pTxtNd->InsertText( aTmpStr, rIdx /*???, SETATTR_NOTXTATRCHR*/ ); rIdx -= 2; - pTxtNd->Erase( rIdx, 1 ); + pTxtNd->EraseText( rIdx, 1 ); rIdx += 2; } pTxtNd->SetIgnoreDontExpand( bOldExpFlg ); @@ -312,11 +314,12 @@ void SwUndoOverwrite::Redo( SwUndoIter& rUndoIter ) for( xub_StrLen n = 0; n < aInsStr.Len(); n++ ) { // einzeln, damit die Attribute stehen bleiben !!! - pTxtNd->Insert( aInsStr.GetChar( n ), rIdx ); + pTxtNd->InsertText( aInsStr.GetChar( n ), rIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); if( n < aDelStr.Len() ) { rIdx -= 2; - pTxtNd->Erase( rIdx, 1 ); + pTxtNd->EraseText( rIdx, 1 ); rIdx += n+1 < aDelStr.Len() ? 2 : 1; } } diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx index f26643a09352..e688cb7dea68 100644 --- a/sw/source/core/undo/unsect.cxx +++ b/sw/source/core/undo/unsect.cxx @@ -192,7 +192,9 @@ void SwUndoInsSection::Redo( SwUndoIter& rUndoIter ) rBase, pAttr, TRUE ); } else - rDoc.Insert( *rUndoIter.pAktPam, *pSection, pAttr, TRUE ); + { + rDoc.InsertSwSection( *rUndoIter.pAktPam, *pSection, pAttr, true ); + } if( pHistory ) pHistory->SetTmpEnd( pHistory->Count() ); @@ -236,7 +238,10 @@ void SwUndoInsSection::Repeat( SwUndoIter& rUndoIter ) rBase, pAttr, TRUE ); } else - rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, *pSection, pAttr ); + { + rUndoIter.GetDoc().InsertSwSection( *rUndoIter.pAktPam, + *pSection, pAttr ); + } } @@ -255,7 +260,7 @@ void SwUndoInsSection::Join( SwDoc& rDoc, ULONG nNode ) if( pHistory ) { SwIndex aCntIdx( pTxtNd, 0 ); - pTxtNd->RstAttr( aCntIdx, pTxtNd->GetTxt().Len() ); + pTxtNd->RstAttr( aCntIdx, pTxtNd->Len(), 0, 0, true ); } } diff --git a/sw/source/core/undo/unsort.cxx b/sw/source/core/undo/unsort.cxx index cd257d6453bc..71902ec81611 100644 --- a/sw/source/core/undo/unsort.cxx +++ b/sw/source/core/undo/unsort.cxx @@ -166,7 +166,8 @@ void SwUndoSort::Undo( SwUndoIter& rIter) { SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i ); SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 ); - rDoc.Move(aRg, aIdx, IDocumentContentOperations::DOC_MOVEDEFAULT); + rDoc.MoveNodeRange(aRg, aIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT); } // Indixes loeschen aIdxList.DeleteAndDestroy(0, aIdxList.Count()); @@ -238,7 +239,8 @@ void SwUndoSort::Redo( SwUndoIter& rIter) { SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i); SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 ); - rDoc.Move(aRg, aIdx, IDocumentContentOperations::DOC_MOVEDEFAULT); + rDoc.MoveNodeRange(aRg, aIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT); } // Indixes loeschen aIdxList.DeleteAndDestroy(0, aIdxList.Count()); diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 93f6daf2c445..3d5dbd429e49 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -591,7 +591,7 @@ SwTableNode* SwNodes::UndoTableToText( ULONG nSttNd, ULONG nEndNd, ASSERT( pTxtNd, "Wo ist der TextNode geblieben?" ); SwIndex aCntPos( pTxtNd, pSave->m_nCntnt - 1 ); - pTxtNd->Erase( aCntPos, 1 ); + pTxtNd->EraseText( aCntPos, 1 ); SwCntntNode* pNewNd = pTxtNd->SplitCntntNode( SwPosition( aSttIdx, aCntPos )); if( aBkmkArr.Count() ) @@ -2121,7 +2121,7 @@ CHECKTABLE(pTblNd->GetTable()) pTxtNd->RstAttr( aTmpIdx, pTxtNd->GetTxt().Len() - nDelPos + 1 ); // das Trennzeichen loeschen - pTxtNd->Erase( aTmpIdx, 1 ); + pTxtNd->EraseText( aTmpIdx, 1 ); } // delete pUndo; DUMPDOC( &rDoc, String( "d:\\tmp\\tab_") + String( aNewSttNds.Count() - i ) + @@ -2198,7 +2198,7 @@ void SwUndoTblMerge::MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& r SwUndoMove* pUndo = new SwUndoMove( pDoc, rRg, rPos ); sal_Bool bDoesUndo = pDoc->DoesUndo(); pDoc->DoUndo( sal_False ); - pDoc->Move( rRg, rPos, pSaveTbl->IsNewModel() ? + pDoc->MoveNodeRange( rRg, rPos, (pSaveTbl->IsNewModel()) ? IDocumentContentOperations::DOC_NO_DELFRMS : IDocumentContentOperations::DOC_MOVEDEFAULT ); if( bDoesUndo ) @@ -2349,8 +2349,9 @@ void SwUndoTblNumFmt::Undo( SwUndoIter& rIter ) SwIndex aIdx( pTxtNd, 0 ); if( aStr.Len() ) { - pTxtNd->Erase( aIdx ); - pTxtNd->Insert( aStr, aIdx, INS_NOHINTEXPAND ); + pTxtNd->EraseText( aIdx ); + pTxtNd->InsertText( aStr, aIdx, + IDocumentContentOperations::INS_NOHINTEXPAND ); } } diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index 581e2185907e..1c076a05dcce 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -158,7 +158,9 @@ SwUndoInserts::~SwUndoInserts() SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNd, "kein TextNode, aus dem geloescht werden soll" ); if( pTxtNd ) // Robust - pTxtNd->Erase( pPos->nContent ); + { + pTxtNd->EraseText( pPos->nContent ); + } pPos->nNode++; } pPos->nContent.Assign( 0, 0 ); @@ -247,7 +249,6 @@ void SwUndoInserts::Undo( SwUndoIter& rUndoIter ) } else { - pDoc->RstTxtAttrs( *pPam, TRUE ); if( bJoinNext && pTxtNode->CanJoinNext()) { { @@ -256,6 +257,9 @@ void SwUndoInserts::Undo( SwUndoIter& rUndoIter ) } pTxtNode->JoinNext(); } + // reset all text attributes in the paragraph! + pTxtNode->RstAttr( SwIndex(pTxtNode, 0), pTxtNode->Len(), + 0, 0, true ); // setze alle Attribute im Node zurueck pTxtNode->ResetAllAttr(); @@ -288,7 +292,6 @@ void SwUndoInserts::Redo( SwUndoIter& rUndoIter ) pSavTxtFmtColl = ((SwTxtNode*)pCNd)->GetTxtColl(); pHistory->SetTmpEnd( nSetPos ); - pHistory->TmpRollback( pDoc, 0, false ); // alte Anfangs-Position fuers Rollback zurueckholen if( ( nSttNode != nEndNode || nSttCntnt != nEndCntnt ) && pPos ) @@ -346,7 +349,7 @@ void SwUndoInserts::Repeat( SwUndoIter& rUndoIter ) SwPaM aPam( *rUndoIter.pAktPam->GetPoint() ); SetPaM( aPam ); - aPam.GetDoc()->Copy( aPam, *rUndoIter.pAktPam->GetPoint(), false ); + aPam.GetDoc()->CopyRange( aPam, *rUndoIter.pAktPam->GetPoint(), false ); rUndoIter.pLastUndoObj = this; } diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index a922c5334f3e..0a9528823689 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -46,6 +46,8 @@ #include <comcore.hrc> #endif #include <undobj.hxx> +#include <docsh.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::lang; @@ -280,6 +282,23 @@ void SwXBookmark::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) } } +// MetadatableMixin +::sfx2::Metadatable* SwXBookmark::GetCoreObject() +{ + return dynamic_cast< ::sfx2::Metadatable* >( GetBookmark() ); +} + +uno::Reference<frame::XModel> SwXBookmark::GetModel() +{ + if (GetDoc()) + { + SwDocShell const * const pShell( GetDoc()->GetDocShell() ); + return (pShell) ? pShell->GetModel() : 0; + } + return 0; +} + + uno::Reference< beans::XPropertySetInfo > SwXBookmark::getPropertySetInfo(void) throw( uno::RuntimeException ) { diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 4890f8c62920..7743ea61e43d 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -76,8 +76,10 @@ #include <slist> #include <iterator> +#include "unometa.hxx" #include "docsh.hxx" + using ::rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::document; @@ -174,11 +176,11 @@ const ProvNamesId_Type __FAR_DATA aProvNamesId[] = { "com.sun.star.text.TextField.Bibliography", SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY }, { "com.sun.star.text.TextField.CombinedCharacters", SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS }, { "com.sun.star.text.TextField.DropDown", SW_SERVICE_FIELDTYPE_DROPDOWN }, + { "com.sun.star.text.textfield.MetadataField", SW_SERVICE_FIELDTYPE_METAFIELD }, { "", SW_SERVICE_FIELDTYPE_DUMMY_4 }, { "", SW_SERVICE_FIELDTYPE_DUMMY_5 }, { "", SW_SERVICE_FIELDTYPE_DUMMY_6 }, { "", SW_SERVICE_FIELDTYPE_DUMMY_7 }, - { "", SW_SERVICE_FIELDTYPE_DUMMY_8 }, { "com.sun.star.text.FieldMaster.User", SW_SERVICE_FIELDMASTER_USER }, { "com.sun.star.text.FieldMaster.DDE", SW_SERVICE_FIELDMASTER_DDE }, { "com.sun.star.text.FieldMaster.SetExpression", SW_SERVICE_FIELDMASTER_SET_EXP }, @@ -207,6 +209,7 @@ const ProvNamesId_Type __FAR_DATA aProvNamesId[] = { "com.sun.star.chart2.data.DataProvider", SW_SERVICE_CHART2_DATA_PROVIDER }, { "com.sun.star.text.Fieldmark", SW_SERVICE_TYPE_FIELDMARK }, { "com.sun.star.text.FormFieldmark", SW_SERVICE_TYPE_FORMFIELDMARK }, + { "com.sun.star.text.InContentMetadata", SW_SERVICE_TYPE_META }, // case-correct versions of the service names (see #i67811) { CSS_TEXT_TEXTFIELD_DATE_TIME, SW_SERVICE_FIELDTYPE_DATETIME }, @@ -604,6 +607,12 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 if( pDoc->GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) xRet = (cppu::OWeakObject*) pDoc->GetChartDataProvider( true /* create - if not yet available */ ); break; + case SW_SERVICE_TYPE_META: + xRet = static_cast< ::cppu::OWeakObject* >( new SwXMeta(pDoc) ); + break; + case SW_SERVICE_FIELDTYPE_METAFIELD: + xRet = static_cast< ::cppu::OWeakObject* >(new SwXMetaField(pDoc)); + break; default: throw uno::RuntimeException(); } diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 0db5039f6a31..8c84dce7948a 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -343,20 +343,9 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry { if( pAny ) { - const SwFmtFld& rFld = pTxtAttr->GetFld(); - SwClientIter aIter(*rFld.GetFld()->GetTyp()); - SwXTextField* pFld = 0; - SwXTextField* pTemp = (SwXTextField*)aIter.First(TYPE(SwXTextField)); - while(pTemp && !pFld) - { - if(pTemp->GetFldFmt() == &rFld) - pFld = pTemp; - pTemp = (SwXTextField*)aIter.Next(); - } - if(!pFld) - pFld = new SwXTextField( rFld, rPam.GetDoc()); - uno::Reference< XTextField > xRet = pFld; - pAny->setValue(&xRet, ::getCppuType((uno::Reference<XTextField>*)0)); + SwXTextField* pField = CreateSwXTextField(*rPam.GetDoc(), + pTxtAttr->GetFld()); + *pAny <<= uno::Reference< XTextField >( pField ); } } else @@ -943,25 +932,37 @@ void InsertFile(SwUnoCrsr* pUnoCrsr, // paragraph breaks at those positions by calling SplitNode sal_Bool DocInsertStringSplitCR( SwDoc &rDoc, - const SwPaM &rNewCursor, const String &rText ) + const SwPaM &rNewCursor, const String &rText, + const bool bForceExpandHints ) { sal_Bool bOK = sal_True; + const enum IDocumentContentOperations::InsertFlags nInsertFlags = + (bForceExpandHints) + ? static_cast<IDocumentContentOperations::InsertFlags>( + IDocumentContentOperations::INS_FORCEHINTEXPAND | + IDocumentContentOperations::INS_EMPTYEXPAND) + : IDocumentContentOperations::INS_EMPTYEXPAND; + OUString aTxt; xub_StrLen nStartIdx = 0; - xub_StrLen nMaxLength = STRING_LEN; - SwTxtNode* pTxtNd = rNewCursor.GetPoint()->nNode.GetNode().GetTxtNode(); - if( pTxtNd ) - nMaxLength = STRING_LEN - pTxtNd->GetTxt().Len(); + SwTxtNode* const pTxtNd = + rNewCursor.GetPoint()->nNode.GetNode().GetTxtNode(); + const xub_StrLen nMaxLength = ( pTxtNd ) + ? STRING_LEN - pTxtNd->GetTxt().Len() + : STRING_LEN; xub_StrLen nIdx = rText.Search( '\r', nStartIdx ); if( ( nIdx == STRING_NOTFOUND && nMaxLength < rText.Len() ) || ( nIdx != STRING_NOTFOUND && nMaxLength < nIdx ) ) + { nIdx = nMaxLength; + } while (nIdx != STRING_NOTFOUND ) { DBG_ASSERT( nIdx - nStartIdx >= 0, "index negative!" ); aTxt = rText.Copy( nStartIdx, nIdx - nStartIdx ); - if (aTxt.getLength() && !rDoc.Insert( rNewCursor, aTxt, true )) + if (aTxt.getLength() && + !rDoc.InsertString( rNewCursor, aTxt, nInsertFlags )) { DBG_ERROR( "Doc->Insert(Str) failed." ); bOK = sal_False; @@ -975,7 +976,8 @@ sal_Bool DocInsertStringSplitCR( nIdx = rText.Search( '\r', nStartIdx ); } aTxt = rText.Copy( nStartIdx ); - if (aTxt.getLength() && !rDoc.Insert( rNewCursor, aTxt, true )) + if (aTxt.getLength() && + !rDoc.InsertString( rNewCursor, aTxt, nInsertFlags )) { DBG_ERROR( "Doc->Insert(Str) failed." ); bOK = sal_False; diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 1989c74df6ed..11b3eae5a16a 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -1297,20 +1297,25 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( + nIdx, RES_TXTATR_FLYCNT ); DBG_ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); DBG_ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFmt, "Wrong TxtFlyCnt-Hint." ); - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()) + .SetFlyFmt(); //The connection is removed now the attribute can be deleted. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( + RES_TXTATR_FLYCNT, nIdx ); //create a new one SwTxtNode *pNd = pInternalPam->GetNode()->GetTxtNode(); - DBG_ASSERT( pNd, "Crsr steht nicht auf TxtNode." ); - pNd->InsertItem( SwFmtFlyCnt( pFmt ), - pInternalPam->GetPoint()->nContent.GetIndex(), 0 ); + DBG_ASSERT( pNd, "Cursor not at TxtNode." ); + SwFmtFlyCnt aFmt( pFmt ); + pNd->InsertItem(aFmt, pInternalPam->GetPoint() + ->nContent.GetIndex(), 0 ); } else { @@ -1379,15 +1384,18 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( + nIdx, RES_TXTATR_FLYCNT ); DBG_ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); DBG_ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFlyFmt, "Wrong TxtFlyCnt-Hint." ); - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()) + .SetFlyFmt(); //The connection is removed now the attribute can be deleted. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes(RES_TXTATR_FLYCNT, nIdx); } else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor && FLY_PAGE == eOldAnchorId ) @@ -1418,8 +1426,9 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A //the RES_TXTATR_FLYCNT needs to be added now SwTxtNode *pNd = aPam.GetNode()->GetTxtNode(); DBG_ASSERT( pNd, "Crsr is not in a TxtNode." ); - pNd->InsertItem( SwFmtFlyCnt( pFlyFmt ), - aPam.GetPoint()->nContent.GetIndex(), 0 ); + SwFmtFlyCnt aFmt( pFlyFmt ); + pNd->InsertItem(aFmt, + aPam.GetPoint()->nContent.GetIndex(), 0 ); //aPam.GetPoint()->nContent--; } @@ -2124,8 +2133,10 @@ void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange) pDoc = pText->GetDoc(); else if (!pDoc && pCursor) pDoc = pCursor->GetDoc(); - else if ( !pDoc && pPortion && pPortion->GetCrsr() ) - pDoc = pPortion->GetCrsr()->GetDoc(); + else if ( !pDoc && pPortion && pPortion->GetCursor() ) + { + pDoc = pPortion->GetCursor()->GetDoc(); + } } @@ -2213,7 +2224,7 @@ void SwXShape::dispose(void) throw( uno::RuntimeException ) const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode(); const xub_StrLen nIdx = rPos.nContent.GetIndex(); - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx ); } else pFmt->GetDoc()->DelLayoutFmt( pFmt ); diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 1a14b5441eb6..f8de0eb39691 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -94,6 +94,7 @@ #include <textapi.hxx> #include <svx/outliner.hxx> #include <docsh.hxx> +#include <fmtmeta.hxx> // MetaFieldManager using ::rtl::OUString; using namespace ::com::sun::star; @@ -371,7 +372,7 @@ USHORT lcl_GetPropertyMapOfService( USHORT nServiceId ) case SW_SERVICE_FIELDTYPE_DUMMY_5: case SW_SERVICE_FIELDTYPE_DUMMY_6: case SW_SERVICE_FIELDTYPE_DUMMY_7: - case SW_SERVICE_FIELDTYPE_DUMMY_8: nRet = PROPERTY_MAP_FLDTYP_DUMMY_0; break; + nRet = PROPERTY_MAP_FLDTYP_DUMMY_0; break; case SW_SERVICE_FIELDMASTER_USER: nRet = PROPERTY_MAP_FLDMSTR_USER; break; case SW_SERVICE_FIELDMASTER_DDE: nRet = PROPERTY_MAP_FLDMSTR_DDE; break; case SW_SERVICE_FIELDMASTER_SET_EXP: nRet = PROPERTY_MAP_FLDMSTR_SET_EXP; break; @@ -784,24 +785,12 @@ uno::Any SwXFieldMaster::getPropertyValue(const OUString& rPropertyName) } uno::Sequence<uno::Reference <text::XDependentTextField> > aRetSeq(aFldArr.Count()); uno::Reference<text::XDependentTextField>* pRetSeq = aRetSeq.getArray(); - SwXTextField* pInsert = 0; for(USHORT i = 0; i < aFldArr.Count(); i++) { pFld = aFldArr.GetObject(i); - SwXTextField* pTemp = (SwXTextField*)aIter.First(TYPE(SwXTextField)); - while(pTemp) - { - if(pTemp->GetFldFmt() == pFld) - { - pInsert = pTemp; - break; - } - pTemp = (SwXTextField*)aIter.Next(); - } - if(!pInsert) - pInsert = new SwXTextField( *pFld, GetDoc()); + SwXTextField * pInsert = CreateSwXTextField(*GetDoc(), *pFld); + pRetSeq[i] = uno::Reference<text::XDependentTextField>(pInsert); - pInsert = 0; } aRet <<= aRetSeq; } @@ -1079,6 +1068,26 @@ OUString SwXFieldMaster::LocalizeFormula( } return rFormula; } + + +SwXTextField * CreateSwXTextField(SwDoc & rDoc, SwFmtFld const& rFmt) +{ + SwClientIter aIter(*rFmt.GetFld()->GetTyp()); + SwXTextField * pField = 0; + SwXTextField * pTemp = + static_cast<SwXTextField*>(aIter.First( TYPE(SwXTextField) )); + while (pTemp) + { + if (pTemp->GetFldFmt() == &rFmt) + { + pField = pTemp; + break; + } + pTemp = static_cast<SwXTextField*>(aIter.Next()); + } + return pField ? pField : new SwXTextField( rFmt, &rDoc ); +} + /****************************************************************** * ******************************************************************/ @@ -1809,8 +1818,18 @@ void SwXTextField::attachToRange( SwTxtAttr* pTxtAttr = 0; if(aPam.HasMark()) pDoc->DeleteAndJoin(aPam); - pDoc->Insert(aPam, aFmt, 10000); - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( + + 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; + + pDoc->InsertPoolItem(aPam, aFmt, nInsertFlags); + + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FIELD); // was passiert mit dem Update der Felder ? (siehe fldmgr.cxx) @@ -2915,6 +2934,22 @@ SwXFieldEnumeration::SwXFieldEnumeration(SwDoc* pDc) : } } } + // now handle meta-fields, which are not SwFields + const ::std::vector< uno::Reference<text::XTextField> > MetaFields( + pDc->GetMetaFieldManager().getMetaFields() ); + for (size_t i = 0; i < MetaFields.size(); ++i) + { + pItems[ nFillPos ] = MetaFields[i]; + nFillPos++; + + //FIXME UGLY + // enlarge sequence if necessary + if (aItems.getLength() == nFillPos) + { + aItems.realloc( 2 * aItems.getLength() ); + pItems = aItems.getArray(); + } + } // resize sequence to actual used size aItems.realloc( nFillPos ); } diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index fcfb8eb135fd..ae773f389f30 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -228,7 +228,7 @@ void SAL_CALL SwXFlatParagraph::changeText(::sal_Int32 nPos, ::sal_Int32 nLen, c mpTxtNode = pOldTxtNode; // setPropertyValue() modifies this. We restore the old state. IDocumentContentOperations* pIDCO = mpTxtNode->getIDocumentContentOperations(); - pIDCO->Replace( aPaM, aNewText, false ); + pIDCO->ReplaceRange( aPaM, aNewText, false ); mpTxtNode = 0; } diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 7237cb59ed02..09066c447546 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2028,7 +2028,7 @@ void SwXFrame::dispose(void) throw( uno::RuntimeException ) const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode(); const xub_StrLen nIdx = rPos.nContent.GetIndex(); - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx ); } else pFmt->GetDoc()->DelLayoutFmt(pFmt); diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index aea52396f366..98ee87c2ae33 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -254,11 +254,18 @@ void SwXFootnote::attachToRange(const uno::Reference< text::XTextRange > & xText SwFmtFtn aFootNote(m_bIsEndnote); if(m_sLabel.Len()) aFootNote.SetNumStr(m_sLabel); - SfxItemSet aSet(pNewDoc->GetAttrPool(), RES_TXTATR_FTN, RES_TXTATR_FTN, 0L); - aSet.Put(aFootNote); - SwXTextCursor::SetCrsrAttr(aPam, aSet, 0); - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( + 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) diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 5fbec1e277a1..5633ca1f0661 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -1369,7 +1369,7 @@ void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno: aPam.GetPoint()->nContent++; //die alte Marke loeschen - m_pDoc->Delete(m_pTOXMark); + m_pDoc->DeleteTOXMark(m_pTOXMark); m_pTOXMark = 0; SwTxtAttr* pTxtAttr = 0; @@ -1379,13 +1379,14 @@ void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno: if( bInsAtPos ) { SwPaM aTmp( *pStt ); - m_pDoc->Insert( aTmp, aMark, 0 ); - pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( + 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->Insert( aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND ); + m_pDoc->InsertPoolItem( aPam, aMark, + nsSetAttrMode::SETATTR_DONTEXPAND ); pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( pStt->nContent, RES_TXTATR_TOXMARK); } @@ -1501,7 +1502,17 @@ void SwXDocumentIndexMark::attachToRange(const uno::Reference< text::XTextRange // deshalb hier ein Leerzeichen - ob das die ideale Loesung ist? if(!bMark && !aMark.GetAlternativeText().Len()) aMark.SetAlternativeText( String(' ') ); - pDoc->Insert(aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND); + + 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(); @@ -1510,8 +1521,10 @@ void SwXDocumentIndexMark::attachToRange(const uno::Reference< text::XTextRange pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( aPam.GetPoint()->nContent, RES_TXTATR_TOXMARK ); else - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( + { + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_TOXMARK ); + } if(pTxtAttr) { @@ -1571,7 +1584,7 @@ void SwXDocumentIndexMark::dispose(void) throw( uno::RuntimeException ) SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); if(pType && m_pTOXMark) { - m_pDoc->Delete(m_pTOXMark); + m_pDoc->DeleteTOXMark(m_pTOXMark); } else throw uno::RuntimeException(); @@ -1681,7 +1694,7 @@ void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, aPam.GetPoint()->nContent++; //delete the old mark - pLocalDoc->Delete(m_pTOXMark); + pLocalDoc->DeleteTOXMark(m_pTOXMark); m_pTOXMark = 0; sal_Bool bInsAtPos = aMark.IsAlternativeText(); @@ -1692,13 +1705,14 @@ void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, if( bInsAtPos ) { SwPaM aTmp( *pStt ); - pLocalDoc->Insert( aTmp, aMark, 0 ); - pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( + pLocalDoc->InsertPoolItem( aTmp, aMark, 0 ); + pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttrForCharAt( pStt->nContent.GetIndex()-1, RES_TXTATR_TOXMARK ); } else if( *pEnd != *pStt ) { - pLocalDoc->Insert( aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND ); + pLocalDoc->InsertPoolItem( aPam, aMark, + nsSetAttrMode::SETATTR_DONTEXPAND ); pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( pStt->nContent, RES_TXTATR_TOXMARK ); } diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index 3730da041f90..f2f48e382508 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -1649,6 +1649,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s {SW_PROP_NMID(UNO_NAME_IS_START), FN_UNO_IS_START, CPPU_E2T(CPPUTYPE_BOOLEAN), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0 }, //_REDLINE_PROPERTIES {SW_PROP_NMID(UNO_NAME_TEXT_PORTION_TYPE), FN_UNO_TEXT_PORTION_TYPE, CPPU_E2T(CPPUTYPE_OUSTRING), PropertyAttribute::READONLY, 0}, + {SW_PROP_NMID(UNO_NAME_META), FN_UNO_META, CPPU_E2T(CPPUTYPE_REFTEXTCNTNT), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0 }, {0,0,0,0,0,0} }; aMapEntriesArr[nPropertyId] = aTextPortionExtensionMap_Impl; @@ -2484,6 +2485,19 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s aMapEntriesArr[nPropertyId] = aChart2DataSequenceMap; } break; + case PROPERTY_MAP_METAFIELD: + { + static SfxItemPropertyMapEntry aMetaFieldMap[] = + { + { SW_PROP_NMID(UNO_NAME_NUMBER_FORMAT), 0, + CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE, 0 }, + { SW_PROP_NMID(UNO_NAME_IS_FIXED_LANGUAGE), 0, + CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, 0 }, + {0,0,0,0,0,0} + }; + aMapEntriesArr[nPropertyId] = aMetaFieldMap; + } + break; default: DBG_ERROR( "unexpected property map ID" ); @@ -3091,6 +3105,12 @@ const SfxItemPropertySet* SwUnoPropertyMapProvider::GetPropertySet( sal_uInt16 aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM; } break; + case PROPERTY_MAP_METAFIELD: + { + static SfxItemPropertySet aPROPERTY_MAP_METAFIELD(pEntries); + aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_METAFIELD; + } + break; } } return aPropertySetArr[nPropertyId]; diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 9b2bebb67977..70d9560eef17 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -59,7 +59,6 @@ #include <swerror.h> #include <swtblfmt.hxx> #include <fmtruby.hxx> -#include <fmthbsh.hxx> #include <docsh.hxx> #include <docstyle.hxx> #include <charfmt.hxx> @@ -92,6 +91,7 @@ #include <unocoll.hxx> #include <unostyle.hxx> #include <unofield.hxx> +#include <unometa.hxx> #include <fmtanchr.hxx> #include <svx/flstitem.hxx> #include <svtools/ctrltool.hxx> @@ -118,11 +118,10 @@ #include <dcontact.hxx> #include <SwStyleNameMapper.hxx> #include <crsskip.hxx> -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif #include <memory> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -378,9 +377,11 @@ void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) SwTxtFmtColl *pLocal = pStyle->GetCollection(); UnoActionContext aAction(pDoc); pDoc->StartUndo( UNDO_START, NULL ); - FOREACHUNOPAM_START(&rPaM) - pDoc->SetTxtFmtColl(*PUNOPAM, pLocal); - FOREACHUNOPAM_END() + SwPaM *pTmpCrsr = &rPaM; + do { + pDoc->SetTxtFmtColl(*pTmpCrsr, pLocal); + pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != &rPaM ); pDoc->EndUndo( UNDO_END, NULL ); } else @@ -653,7 +654,7 @@ return bRet; /* -----------------30.06.98 08:39------------------- * * --------------------------------------------------*/ -SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional) +SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) { static const sal_uInt16 nMaxLookup = 1000; SwFmtColl *pFmt = 0; @@ -661,12 +662,13 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional) // if ( GetCrsrCnt() > nMaxLookup ) // return 0; sal_Bool bError = sal_False; - FOREACHUNOPAM_START(&rPam) + SwPaM *pTmpCrsr = &rPaM; + do { - ULONG nSttNd = PUNOPAM->GetMark()->nNode.GetIndex(), - nEndNd = PUNOPAM->GetPoint()->nNode.GetIndex(); - xub_StrLen nSttCnt = PUNOPAM->GetMark()->nContent.GetIndex(), - nEndCnt = PUNOPAM->GetPoint()->nContent.GetIndex(); + 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 )) { @@ -680,7 +682,7 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional) break; } - const SwNodes& rNds = rPam.GetDoc()->GetNodes(); + const SwNodes& rNds = rPaM.GetDoc()->GetNodes(); for( ULONG n = nSttNd; n <= nEndNd; ++n ) { const SwTxtNode* pNd = rNds[ n ]->GetTxtNode(); @@ -699,7 +701,9 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional) } if(bError) break; - FOREACHUNOPAM_END() + + pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != &rPaM ); return bError ? 0 : pFmt; } @@ -851,7 +855,8 @@ SwXTextCursor::~SwXTextCursor() /*-- 09.12.98 14:19:18--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::DeleteAndInsert(const String& rText) +void SwXTextCursor::DeleteAndInsert(const String& rText, + const bool bForceExpandHints) { SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) @@ -870,10 +875,12 @@ void SwXTextCursor::DeleteAndInsert(const String& rText) } if(nTxtLen) { - if( !SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *_pStartCrsr, rText ) ) - { - DBG_ASSERT( sal_False, "Doc->Insert(Str) failed." ); - } + const bool bSuccess( + SwUnoCursorHelper::DocInsertStringSplitCR( + *pDoc, *_pStartCrsr, 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); } @@ -881,6 +888,82 @@ void SwXTextCursor::DeleteAndInsert(const String& rText) pDoc->EndUndo(UNDO_INSERT, NULL); } } + + +enum ForceIntoMetaMode { META_CHECK_BOTH, META_INIT_START, META_INIT_END }; + +sal_Bool lcl_ForceIntoMeta(SwPaM & rCursor, + uno::Reference<text::XText> const & xParentText, + const enum ForceIntoMetaMode eMode) +{ + sal_Bool bRet( sal_True ); // means not forced in META_CHECK_BOTH + SwXMeta const * const pXMeta( dynamic_cast<SwXMeta*>(xParentText.get()) ); + ASSERT(pXMeta, "no parent?"); + if (!pXMeta) + throw uno::RuntimeException(); + SwTxtNode * pTxtNode; + xub_StrLen nStart; + xub_StrLen nEnd; + const bool bSuccess( pXMeta->SetContentRange(pTxtNode, nStart, nEnd) ); + ASSERT(bSuccess, "no pam?"); + if (!bSuccess) + throw uno::RuntimeException(); + // force the cursor back into the meta if it has moved outside + SwPosition start(*pTxtNode, nStart); + SwPosition end(*pTxtNode, nEnd); + switch (eMode) + { + case META_INIT_START: + *rCursor.GetPoint() = start; + break; + case META_INIT_END: + *rCursor.GetPoint() = end; + break; + case META_CHECK_BOTH: + if (*rCursor.Start() < start) + { + *rCursor.Start() = start; + bRet = sal_False; + } + if (*rCursor.End() > end) + { + *rCursor.End() = end; + bRet = sal_False; + } + break; + } + return bRet; +} + +bool SwXTextCursor::IsAtEndOfMeta() const +{ + if (CURSOR_META == eType) + { + SwUnoCrsr const * const pCursor( GetCrsr() ); + SwXMeta const*const pXMeta( dynamic_cast<SwXMeta*>(xParentText.get()) ); + ASSERT(pXMeta, "no meta?"); + if (pCursor && pXMeta) + { + SwTxtNode * pTxtNode; + xub_StrLen nStart; + xub_StrLen nEnd; + const bool bSuccess( + pXMeta->SetContentRange(pTxtNode, nStart, nEnd) ); + ASSERT(bSuccess, "no pam?"); + if (bSuccess) + { + const SwPosition end(*pTxtNode, nEnd); + if ( (*pCursor->GetPoint() == end) + || (*pCursor->GetMark() == end)) + { + return true; + } + } + } + } + return false; +} + /* -----------------------------10.03.00 18:02-------------------------------- ---------------------------------------------------------------------------*/ @@ -972,6 +1055,11 @@ sal_Bool SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand) throw( uno::Ru { 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 { @@ -991,6 +1079,11 @@ sal_Bool SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand) throw( uno::R { 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 { @@ -1044,6 +1137,10 @@ void SwXTextCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException ) { pUnoCrsr->MoveSection( fnSectionCurr, fnSectionStart); } + else if (CURSOR_META == eType) + { + lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_INIT_START); + } } else { @@ -1061,7 +1158,9 @@ void SwXTextCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException ) { SwXTextCursor::SelectPam(*pUnoCrsr, Expand); if(eType == CURSOR_BODY) + { pUnoCrsr->Move( fnMoveForward, fnGoDoc ); + } else if(eType == CURSOR_FRAME || eType == CURSOR_TBLTEXT || eType == CURSOR_HEADER || @@ -1071,6 +1170,10 @@ void SwXTextCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException ) { pUnoCrsr->MoveSection( fnSectionCurr, fnSectionEnd); } + else if (CURSOR_META == eType) + { + lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_INIT_END); + } } else { @@ -1099,6 +1202,11 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); } + if (!pRange && !pCursor) + { + throw uno::RuntimeException(); + } + SwStartNodeType eSearchNodeType = SwNormalStartNode; switch(eType) { @@ -1141,6 +1249,27 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B throw uno::RuntimeException(); } + if (CURSOR_META == 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) ); + if (!bNotForced) + { + throw uno::RuntimeException( + C2U("gotoRange: parameter range not contained in nesting" + " text content for which this cursor was created"), + static_cast<text::XWordCursor*>(this)); + } + } + //jetzt muss die Selektion erweitert werden if(bExpand) { @@ -1277,7 +1406,9 @@ sal_Bool SwXTextCursor::gotoNextWord(sal_Bool Expand) throw( uno::RuntimeExcepti //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 ); @@ -1289,6 +1420,10 @@ sal_Bool SwXTextCursor::gotoNextWord(sal_Bool Expand) throw( uno::RuntimeExcepti // return true if cursor has moved bRet = &pPoint->nNode.GetNode() != pOldNode || pPoint->nContent.GetIndex() != nOldIndex; + if (bRet && (CURSOR_META == eType)) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + } } else { @@ -1316,7 +1451,9 @@ sal_Bool SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw( uno::RuntimeExc SwXTextCursor::SelectPam(*pUnoCrsr, Expand); //Absatzanfang ? if(pPoint->nContent == 0) + { pUnoCrsr->Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); + } else { pUnoCrsr->GoPrevWordWT( i18n::WordType::DICTIONARY_WORD ); @@ -1327,6 +1464,10 @@ sal_Bool SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw( uno::RuntimeExc // return true if cursor has moved bRet = &pPoint->nNode.GetNode() != pOldNode || pPoint->nContent.GetIndex() != nOldIndex; + if (bRet && (CURSOR_META == eType)) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + } } else { @@ -1363,6 +1504,10 @@ sal_Bool SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw( uno::RuntimeExcept pPoint->nNode = rOldNode; pPoint->nContent = nOldIndex; } + else if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + } } else { @@ -1399,6 +1544,10 @@ sal_Bool SwXTextCursor::gotoStartOfWord(sal_Bool Expand) throw( uno::RuntimeExce pPoint->nNode = rOldNode; pPoint->nContent = nOldIndex; } + else if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + } } else { @@ -1489,6 +1638,11 @@ sal_Bool SwXTextCursor::gotoNextSentence(sal_Bool Expand) throw( uno::RuntimeExc if (bWasEOS && !bNextWord) bRet = sal_False; } + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else throw uno::RuntimeException(); @@ -1516,6 +1670,11 @@ sal_Bool SwXTextCursor::gotoPreviousSentence(sal_Bool Expand) throw( uno::Runtim pUnoCrsr->GoSentence(SwCursor::PREV_SENT); } } + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else throw uno::RuntimeException(); @@ -1538,6 +1697,11 @@ sal_Bool SwXTextCursor::gotoStartOfSentence(sal_Bool Expand) throw( uno::Runtime 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; + } } else throw uno::RuntimeException(); @@ -1561,7 +1725,11 @@ sal_Bool SwXTextCursor::gotoEndOfSentence(sal_Bool Expand) throw( uno::RuntimeEx bRet = !bAlreadyParaEnd && (pUnoCrsr->GoSentence(SwCursor::END_SENT) || pUnoCrsr->MovePara(fnParaCurr, fnParaEnd)); - + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else throw uno::RuntimeException(); @@ -1603,6 +1771,8 @@ sal_Bool SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) throw( uno::Runtim { vos::OGuard aGuard(Application::GetSolarMutex()); sal_Bool bRet = sal_False; + if (CURSOR_META == eType) + return bRet; SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr ) { @@ -1627,6 +1797,8 @@ sal_Bool SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw( uno::RuntimeE { vos::OGuard aGuard(Application::GetSolarMutex()); sal_Bool bRet = sal_False; + if (CURSOR_META == eType) + return bRet; SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { @@ -1651,6 +1823,8 @@ sal_Bool SwXTextCursor::gotoNextParagraph(sal_Bool Expand) throw( uno::RuntimeEx { vos::OGuard aGuard(Application::GetSolarMutex()); sal_Bool bRet = sal_False; + if (CURSOR_META == eType) + return bRet; SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { @@ -1668,6 +1842,8 @@ sal_Bool SwXTextCursor::gotoPreviousParagraph(sal_Bool Expand) throw( uno::Runti { vos::OGuard aGuard(Application::GetSolarMutex()); sal_Bool bRet = sal_False; + if (CURSOR_META == eType) + return bRet; SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { @@ -1697,7 +1873,19 @@ uno::Reference< XTextRange > SwXTextCursor::getStart(void) throw( uno::RuntimeE { SwPaM aPam(*pUnoCrsr->Start()); uno::Reference< XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); + 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); + } } else throw uno::RuntimeException(); @@ -1715,7 +1903,19 @@ uno::Reference< XTextRange > SwXTextCursor::getEnd(void) throw( uno::RuntimeExc { SwPaM aPam(*pUnoCrsr->End()); uno::Reference< XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); + 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); + } } else throw uno::RuntimeException(); @@ -1762,7 +1962,11 @@ void SwXTextCursor::setString(const OUString& aString) throw( uno::RuntimeExcept if(!pUnoCrsr) throw uno::RuntimeException(); - DeleteAndInsert(aString); + const bool bForceExpandHints( (CURSOR_META != eType) + ? false + : dynamic_cast<SwXMeta*>(xParentText.get())->CheckForOwnMemberMeta( + 0, GetPaM(), true) ); + DeleteAndInsert(aString, bForceExpandHints); } /* -----------------------------03.05.00 12:56-------------------------------- diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 7a27bd597eb0..b7764778d31c 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -57,7 +57,6 @@ #include <shellio.hxx> #include <swerror.h> #include <swtblfmt.hxx> -#include <fmthbsh.hxx> #include <docsh.hxx> #include <docstyle.hxx> #include <charfmt.hxx> @@ -124,6 +123,11 @@ // OD 2004-05-24 #i28701# #include <sortedobjs.hxx> +#include <algorithm> +#include <iterator> +#include <boost/bind.hpp> + + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -135,9 +139,20 @@ using namespace ::com::sun::star::drawing; using ::rtl::OUString; + +struct FrameDependSortListLess +{ + bool operator() (FrameDependSortListEntry const& r1, + FrameDependSortListEntry const& r2) + { + return (r1.nIndex < r2.nIndex) + || ((r1.nIndex == r2.nIndex) && (r1.nOrder < r2.nOrder)); + } +}; + // OD 2004-05-07 #i28701# - adjust 4th parameter void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, - SwDependArr& rFrameArr, + FrameDependSortList_t & rFrames, const bool _bAtCharAnchoredObjs ) { // _bAtCharAnchoredObjs: @@ -163,21 +178,21 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt(); if ( rFmt.GetAnchor().GetAnchorId() == nChkType ) { - //jetzt einen SwDepend anlegen und in das Array einfuegen + // create SwDepend and insert into array SwDepend* pNewDepend = new SwDepend( &rClnt, &rFmt ); + xub_StrLen idx = + rFmt.GetAnchor().GetCntntAnchor()->nContent.GetIndex(); + sal_uInt32 nOrder = rFmt.GetAnchor().GetOrder(); // OD 2004-05-07 #i28701# - sorting no longer needed, // because list <SwSortedObjs> is already sorted. - rFrameArr.C40_INSERT( SwDepend, pNewDepend, rFrameArr.Count() ); + FrameDependSortListEntry entry(idx, nOrder, pNewDepend); + rFrames.push_back(entry); } } } else { - // OD 2004-05-07 #i28701# - helper list to get <rFrameArr> sorted - std::vector< std::pair< xub_StrLen, sal_uInt32 > > aSortLst; - typedef std::vector< std::pair< xub_StrLen, sal_uInt32 > >::iterator tSortLstIter; - const SwSpzFrmFmts& rFmts = *pDoc->GetSpzFrmFmts(); USHORT nSize = rFmts.Count(); for ( USHORT i = 0; i < nSize; i++) @@ -194,32 +209,14 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, // OD 2004-05-07 #i28701# - determine insert position for // sorted <rFrameArr> - USHORT nInsPos = rFrameArr.Count(); - { - xub_StrLen nCntIndex = pAnchorPos->nContent.GetIndex(); - sal_uInt32 nAnchorOrder = rAnchor.GetOrder(); + xub_StrLen nIndex = pAnchorPos->nContent.GetIndex(); + sal_uInt32 nOrder = rAnchor.GetOrder(); - tSortLstIter aInsIter = aSortLst.end(); - for ( tSortLstIter aIter = aSortLst.begin(); - aIter != aSortLst.end(); - ++aIter ) - { - if ( (*aIter).first > nCntIndex || - ( (*aIter).first == nCntIndex && - (*aIter).second > nAnchorOrder ) ) - { - nInsPos = sal::static_int_cast< USHORT >(aIter - aSortLst.begin()); - aInsIter = aIter; - break; - } - } - std::pair< xub_StrLen, sal_uInt32 > aEntry( nCntIndex, - nAnchorOrder ); - aSortLst.insert( aInsIter, aEntry ); - } - rFrameArr.C40_INSERT( SwDepend, pNewDepend, nInsPos ); + FrameDependSortListEntry entry(nIndex, nOrder, pNewDepend); + rFrames.push_back(entry); } } + ::std::sort(rFrames.begin(), rFrames.end(), FrameDependSortListLess()); } } @@ -769,7 +766,9 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt { if( _pStartCrsr->HasMark() && ( (CRSR_ATTR_MODE_TABLE & nAttrMode) || *_pStartCrsr->GetPoint() != *_pStartCrsr->GetMark() )) - pDoc->Insert(*_pStartCrsr, rSet, nFlags ); + { + pDoc->InsertItemSet(*_pStartCrsr, rSet, nFlags); + } } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != &rPam ); pDoc->EndUndo(UNDO_INSATTR, NULL); @@ -778,7 +777,7 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt { // if( !HasSelection() ) // UpdateAttr(); - pDoc->Insert( *pCrsr, rSet, nFlags ); + pDoc->InsertItemSet( *pCrsr, rSet, nFlags ); } //#outline level,add by zhaojianwei if( rSet.GetItemState( RES_PARATR_OUTLINELEVEL, false ) >= SFX_ITEM_AVAILABLE ) @@ -1214,9 +1213,16 @@ void SwXTextRange::_CreateNewBookmark(SwPaM& rPam) pMark->Add(this); } -void SwXTextRange::DeleteAndInsert(const String& rText) +void SwXTextRange::DeleteAndInsert( + const String& rText, const bool bForceExpandHints) throw(uno::RuntimeException) { + if (RANGE_IS_TABLE == eRangePosition) + { + // setString on table not allowed + throw uno::RuntimeException(); + } + ::sw::mark::IMark const * const pBkmk = GetBookmark(); if(pBkmk) { @@ -1231,11 +1237,14 @@ void SwXTextRange::DeleteAndInsert(const String& rText) UnoActionContext aAction(pDoc); pDoc->StartUndo(UNDO_INSERT, NULL); if(aNewCrsr.HasMark()) + { pDoc->DeleteAndJoin(aNewCrsr); + } if(rText.Len()) { - SwUnoCursorHelper::DocInsertStringSplitCR(*pDoc, aNewCrsr, rText); + SwUnoCursorHelper::DocInsertStringSplitCR( + *pDoc, aNewCrsr, rText, bForceExpandHints); SwXTextCursor::SelectPam(aNewCrsr, sal_True); aNewCrsr.Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); @@ -1335,13 +1344,7 @@ void SwXTextRange::setString(const OUString& aString) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(RANGE_IS_TABLE == eRangePosition) - { - //setString in Tabellen kann nicht erlaubt werden - throw uno::RuntimeException(); - } - else - DeleteAndInsert(aString); + DeleteAndInsert(aString, false); } void SwXTextRange::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) @@ -1438,12 +1441,10 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, } else { - const SwPaM* pUnoCrsr = 0; - SwDoc* pDoc = pCursor ? pCursor->GetDoc() : NULL; - - if ( !pDoc ) - pDoc = pPortion ? pPortion->GetCrsr()->GetDoc() : NULL; - pUnoCrsr = pCursor ? pCursor->GetPaM() : pPortion ? pPortion->GetCrsr() : 0; + SwDoc* const pDoc = (pCursor) ? pCursor->GetDoc() + : ((pPortion) ? pPortion->GetCursor()->GetDoc() : 0); + const SwPaM* const pUnoCrsr = (pCursor) ? pCursor->GetPaM() + : ((pPortion) ? pPortion->GetCursor() : 0); if (pUnoCrsr && pDoc == rToFill.GetDoc()) { DBG_ASSERT((SwPaM*)pUnoCrsr->GetNext() == pUnoCrsr, "was machen wir mit Ringen?" ); @@ -1907,9 +1908,11 @@ sal_Int32 SwXTextRanges::getCount(void) throw( uno::RuntimeException ) SwUnoCrsr* pCrsr = GetCrsr(); if(pCrsr) { - FOREACHUNOPAM_START(pCrsr) + SwPaM *pTmpCrsr = pCrsr; + do { nRet++; - FOREACHUNOPAM_END() + pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != pCrsr ); } else if(pRangeArr) nRet = pRangeArr->Count(); @@ -1958,15 +1961,20 @@ XTextRangeArr* SwXTextRanges::GetRangesArray() if(!pRangeArr && pCrsr) { pRangeArr = new XTextRangeArr(); - FOREACHUNOPAM_START(pCrsr) + SwPaM *pTmpCrsr = pCrsr; + do { uno::Reference< XTextRange >* pPtr = - new uno::Reference<XTextRange>( SwXTextRange::CreateTextRangeFromPosition(PUNOPAM->GetDoc(), - *PUNOPAM->GetPoint(), PUNOPAM->GetMark())); -// new uno::Reference<XTextRange>( SwXTextRange::createTextRangeFromPaM(*PUNOPAM, xParentText)); + 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()); - FOREACHUNOPAM_END() + + pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != pCrsr ); pCrsr->Remove( this ); } return pRangeArr; @@ -1994,37 +2002,107 @@ void SwXTextCursor::SetString(SwCursor& rCrsr, const OUString& rString) pDoc->DeleteAndJoin(rCrsr); if(nTxtLen) { - if( !SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, rCrsr, aText ) ) - { - DBG_ASSERT( sal_False, "DocInsertStringSplitCR" ); - } + const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR( + *pDoc, rCrsr, aText, false ) ); + DBG_ASSERT( bSuccess, "DocInsertStringSplitCR" ); + (void) bSuccess; SwXTextCursor::SelectPam(rCrsr, sal_True); rCrsr.Left(nTxtLen, CRSR_SKIP_CHARS, FALSE, FALSE); } pDoc->EndUndo(UNDO_INSERT, NULL); } + /****************************************************************** * SwXParaFrameEnumeration ******************************************************************/ -SV_IMPL_PTRARR(SwDependArr, SwDepend*); + +/* -----------------23.03.99 13:38------------------- + * + * --------------------------------------------------*/ +static sal_Bool +lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr, + uno::Reference<text::XTextContent> & o_rNextObject, + FrameDependList_t & i_rFrames) +{ + if (!i_rFrames.size()) + return sal_False; + + SwFrmFmt* pFormat = static_cast<SwFrmFmt*>(const_cast<SwModify*>( + i_rFrames.front()->GetRegisteredIn())); + i_rFrames.pop_front(); + // the format should be valid here, otherwise the client + // would have been removed in ::Modify + // check for a shape first + SwClientIter aIter(*pFormat); + SwDrawContact * const pContact = + static_cast<SwDrawContact*>( aIter.First(TYPE(SwDrawContact)) ); + if (pContact) + { + SdrObject * const pSdr = pContact->GetMaster(); + if (pSdr) + { + o_rNextObject.set(pSdr->getUnoShape(), uno::UNO_QUERY); + } + } + else + { + const SwNodeIndex* pIdx = pFormat->GetCntnt().GetCntntIdx(); + DBG_ASSERT(pIdx, "where is the index?"); + const SwNode* pNd = + i_rUnoCrsr.GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ]; + + const FlyCntType eType = (!pNd->IsNoTxtNode()) ? FLYCNTTYPE_FRM + : ( (pNd->IsGrfNode()) ? FLYCNTTYPE_GRF : FLYCNTTYPE_OLE ); + + const uno::Reference< container::XNamed > xFrame = + SwXFrames::GetObject(*pFormat, eType); + o_rNextObject.set(xFrame, uno::UNO_QUERY); + } + + return o_rNextObject.is(); +} + +/* -----------------------------03.04.00 10:15-------------------------------- + Description: Search for a FLYCNT text attribute at the cursor point + and fill the frame into the array + ---------------------------------------------------------------------------*/ +static void +lcl_FillFrame(SwXParaFrameEnumeration & rEnum, SwUnoCrsr& rUnoCrsr, + FrameDependList_t & rFrames) +{ + // search for objects at the cursor - anchored at/as char + const SwTxtAttr * pTxtAttr = rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttr( + rUnoCrsr.GetPoint()->nContent, RES_TXTATR_FLYCNT); + if (pTxtAttr) + { + const SwFmtFlyCnt& rFlyCnt = pTxtAttr->GetFlyCnt(); + SwFrmFmt * const pFrmFmt = rFlyCnt.GetFrmFmt(); + SwDepend * const pNewDepend = new SwDepend(&rEnum, pFrmFmt); + rFrames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) ); + } +} + /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXParaFrameEnumeration::getImplementationName(void) throw( RuntimeException ) +OUString SwXParaFrameEnumeration::getImplementationName() +throw( RuntimeException ) { return C2U("SwXParaFrameEnumeration"); } /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXParaFrameEnumeration::supportsService(const OUString& rServiceName) throw( RuntimeException ) +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(void) throw( RuntimeException ) +Sequence< OUString > SwXParaFrameEnumeration::getSupportedServiceNames() +throw( RuntimeException ) { Sequence< OUString > aRet(1); OUString* pArray = aRet.getArray(); @@ -2049,14 +2127,17 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, if (PARAFRAME_PORTION_PARAGRAPH == nParaFrameMode) { - ::CollectFrameAtNode( *this, rPaM.GetPoint()->nNode, - aFrameArr, FALSE ); + FrameDependSortList_t frames; + ::CollectFrameAtNode( *this, rPaM.GetPoint()->nNode, frames, false ); + ::std::transform(frames.begin(), frames.end(), + ::std::back_inserter(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); - aFrameArr.C40_INSERT(SwDepend, pNewDepend, aFrameArr.Count()); + m_Frames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) ); } else if((PARAFRAME_PORTION_CHAR == nParaFrameMode) || (PARAFRAME_PORTION_TEXTRANGE == nParaFrameMode)) @@ -2072,7 +2153,7 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, SwFrmFmt* pFrmFmt = (SwFrmFmt*)&pPosFly->GetFmt(); //jetzt einen SwDepend anlegen und in das Array einfuegen SwDepend* pNewDepend = new SwDepend(this, pFrmFmt); - aFrameArr.C40_INSERT(SwDepend, pNewDepend, aFrameArr.Count()); + m_Frames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) ); } //created from any text range if(pUnoCrsr->HasMark()) @@ -2081,13 +2162,13 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, pUnoCrsr->Exchange(); do { - FillFrame(*pUnoCrsr); + lcl_FillFrame(*this, *pUnoCrsr, m_Frames); pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); } while(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()); } } - FillFrame(*pUnoCrsr); + lcl_FillFrame(*this, *pUnoCrsr, m_Frames); } } /*-- 23.03.99 13:22:30--------------------------------------------------- @@ -2096,102 +2177,53 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, SwXParaFrameEnumeration::~SwXParaFrameEnumeration() { vos::OGuard aGuard(Application::GetSolarMutex()); - aFrameArr.DeleteAndDestroy(0, aFrameArr.Count()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + + SwUnoCrsr* pUnoCrsr = GetCursor(); delete pUnoCrsr; } -/* -----------------------------03.04.00 10:15-------------------------------- - Description: Search for a FLYCNT text attribute at the cursor point - and fill the frame into the array - ---------------------------------------------------------------------------*/ -void SwXParaFrameEnumeration::FillFrame(SwUnoCrsr& rUnoCrsr) -{ - // search for objects at the cursor - anchored at/as char - SwTxtAttr* pTxtAttr = rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttr( - rUnoCrsr.GetPoint()->nContent, RES_TXTATR_FLYCNT); - if(pTxtAttr) - { - const SwFmtFlyCnt& rFlyCnt = pTxtAttr->GetFlyCnt(); - SwFrmFmt* pFrmFmt = rFlyCnt.GetFrmFmt(); - //jetzt einen SwDepend anlegen und in das Array einfuegen - SwDepend* pNewDepend = new SwDepend(this, pFrmFmt); - aFrameArr.C40_INSERT(SwDepend, pNewDepend, aFrameArr.Count()); - } -} + /*-- 23.03.99 13:22:32--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXParaFrameEnumeration::hasMoreElements(void) throw( uno::RuntimeException ) +sal_Bool SwXParaFrameEnumeration::hasMoreElements() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetCrsr()) + + if (!GetCursor()) throw uno::RuntimeException(); - return xNextObject.is() ? sal_True : CreateNextObject(); + + return m_xNextObject.is() ? sal_True : + lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames); } /*-- 23.03.99 13:22:33--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParaFrameEnumeration::nextElement(void) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SwXParaFrameEnumeration::nextElement() + throw( container::NoSuchElementException, + lang::WrappedTargetException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetCrsr()) + + if (!GetCursor()) throw uno::RuntimeException(); - if(!xNextObject.is() && aFrameArr.Count()) + + if (!m_xNextObject.is() && m_Frames.size()) { - CreateNextObject(); + lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames); } - if(!xNextObject.is()) + if(!m_xNextObject.is()) throw container::NoSuchElementException(); - uno::Any aRet(&xNextObject, ::getCppuType((uno::Reference<XTextContent>*)0)); - xNextObject = 0; + uno::Any aRet(&m_xNextObject, + ::getCppuType((uno::Reference<XTextContent>*)0)); + m_xNextObject = 0; return aRet; } -/* -----------------23.03.99 13:38------------------- - * - * --------------------------------------------------*/ -sal_Bool SwXParaFrameEnumeration::CreateNextObject() -{ - if(!aFrameArr.Count()) - return sal_False; - SwDepend* pDepend = aFrameArr.GetObject(0); - aFrameArr.Remove(0); - SwFrmFmt* pFormat = (SwFrmFmt*)pDepend->GetRegisteredIn(); - delete pDepend; - // the format should be valid her otherwise the client - // would have been removed in ::Modify - // check for a shape first - SwClientIter aIter(*pFormat); - SwDrawContact* pContact = (SwDrawContact*) - aIter.First(TYPE(SwDrawContact)); - if(pContact) - { - SdrObject* pSdr = pContact->GetMaster(); - if(pSdr) - { - xNextObject = uno::Reference< XTextContent >(pSdr->getUnoShape(), uno::UNO_QUERY); - } - } - else - { - const SwNodeIndex* pIdx = pFormat->GetCntnt().GetCntntIdx(); - DBG_ASSERT(pIdx, "where is the index?"); - const SwNode* pNd = GetCrsr()->GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ]; - FlyCntType eType; - if(!pNd->IsNoTxtNode()) - eType = FLYCNTTYPE_FRM; - else if(pNd->IsGrfNode()) - eType = FLYCNTTYPE_GRF; - else - eType = FLYCNTTYPE_OLE; - - uno::Reference< container::XNamed > xFrame = SwXFrames::GetObject(*pFormat, eType); - xNextObject = uno::Reference< XTextContent >(xFrame, uno::UNO_QUERY); - } - - return xNextObject.is(); -} +struct InvalidFrameDepend { + bool operator() (::boost::shared_ptr<SwDepend> const & rEntry) + { return !rEntry->GetRegisteredIn(); } +}; /*-- 23.03.99 13:22:37--------------------------------------------------- @@ -2215,21 +2247,16 @@ void SwXParaFrameEnumeration::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) } if(!GetRegisteredIn()) { - aFrameArr.DeleteAndDestroy(0, aFrameArr.Count()); - xNextObject = 0; + m_Frames.clear(); + m_xNextObject = 0; } else { - //dann war es vielleicht ein Frame am Absatz? - for(sal_uInt16 i = aFrameArr.Count(); i; i--) - { - SwDepend* pDepend = aFrameArr.GetObject(i-1); - if(!pDepend->GetRegisteredIn()) - { - delete pDepend; - aFrameArr.Remove(i-1); - } - } + // 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()); } } // ----------------------------------------------------------------------------- diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index d21439ff120e..227b8cf58e42 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -35,6 +35,7 @@ #include <cmdid.h> #include <unomid.h> #include <unoobj.hxx> +#include <unoport.hxx> #include <unomap.hxx> #include <unocrsr.hxx> #include <unoprnms.hxx> diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index e2db326202d9..04d073a09df3 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -41,20 +41,20 @@ #include <unoobj.hxx> #include <unomap.hxx> #include <unoprnms.hxx> -#ifndef _UNOMID_H #include <unomid.h> -#endif #include <txtatr.hxx> #include <txtfld.hxx> #include <ndtxt.hxx> #include <doc.hxx> #include <fmtflcnt.hxx> #include <fmtfld.hxx> + #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp> #include <com/sun/star/beans/GetPropertyTolerantResult.hpp> #include <com/sun/star/beans/TolerantPropertySetResultType.hpp> + using namespace ::com::sun::star; using ::rtl::OUString; @@ -63,88 +63,95 @@ using ::rtl::OUString; * SwXTextPortion ******************************************************************/ -/*-- 11.12.98 09:56:52--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwFmtFld* SwXTextPortion::GetFldFmt(sal_Bool bInit) +static void init(SwXTextPortion & rPortion, const SwUnoCrsr* pPortionCursor) { - SwFmtFld* pRet = 0; - // initial wird es immer gesucht, danach nur noch, wenn es bereits existierte - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr && (bInit || pFmtFld)) + SwUnoCrsr* pUnoCursor = + pPortionCursor->GetDoc()->CreateUnoCrsr(*pPortionCursor->GetPoint()); + if (pPortionCursor->HasMark()) { - SwTxtNode *pNode = pUnoCrsr->GetPoint()->nNode.GetNode().GetTxtNode(); - SwTxtFld *pTxtFld = 0; - if( pNode ) - pTxtFld = pNode->GetTxtFld( pUnoCrsr->Start()->nContent ); - if(pTxtFld) - pFmtFld = pRet = (SwFmtFld*)&pTxtFld->GetFld(); + pUnoCursor->SetMark(); + *pUnoCursor->GetMark() = *pPortionCursor->GetMark(); } - return pRet; + pUnoCursor->Add(& rPortion); } + /*-- 11.12.98 09:56:55--------------------------------------------------- -----------------------------------------------------------------------*/ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, uno::Reference< text::XText > const& rParent, - SwTextPortionType eType) : - aLstnrCntnr( (text::XTextRange*)this), - m_pPropSet(aSwMapProvider.GetPropertySet( - (PORTION_REDLINE_START == eType || - PORTION_REDLINE_END == eType) ? - PROPERTY_MAP_REDLINE_PORTION : PROPERTY_MAP_TEXTPORTION_EXTENSIONS)), - xParentText(rParent), - pRubyText(0), - pRubyStyle(0), - pRubyAdjust(0), - pRubyIsAbove(0), - pFmtFld(0), - aFrameDepend(this, 0), - pFrameFmt(0), - ePortionType(eType), - nControlChar(0), - bIsCollapsed(FALSE) + SwTextPortionType eType) + : m_ListenerContainer( static_cast<text::XTextRange*>(this) ) + , m_pPropSet(aSwMapProvider.GetPropertySet( + (PORTION_REDLINE_START == eType || + PORTION_REDLINE_END == eType) + ? PROPERTY_MAP_REDLINE_PORTION + : PROPERTY_MAP_TEXTPORTION_EXTENSIONS)) + , m_xParentText(rParent) + , m_pRubyText(0) + , m_pRubyStyle(0) + , m_pRubyAdjust(0) + , m_pRubyIsAbove(0) + , m_FrameDepend(this, 0) + , m_pFrameFmt(0) + , m_ePortionType(eType) + , m_bIsCollapsed(false) { - SwUnoCrsr* pUnoCrsr = pPortionCrsr->GetDoc()->CreateUnoCrsr(*pPortionCrsr->GetPoint()); - if(pPortionCrsr->HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pPortionCrsr->GetMark(); - } - pUnoCrsr->Add(this); - // erst nach ->Add() - if(ePortionType == PORTION_FIELD) - GetFldFmt(sal_True); -// else if(ePortionType == PORTION_FRAME) -// ...; + init(*this, pPortionCrsr); } + /* -----------------24.03.99 16:30------------------- * * --------------------------------------------------*/ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, uno::Reference< text::XText > const& rParent, - SwFrmFmt& rFmt ) : - aLstnrCntnr( (text::XTextRange*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXTPORTION_EXTENSIONS)), - xParentText(rParent), - pRubyText(0), - pRubyStyle(0), - pRubyAdjust(0), - pRubyIsAbove(0), - pFmtFld(0), - aFrameDepend(this, &rFmt), - pFrameFmt(&rFmt), - ePortionType(PORTION_FRAME), - nControlChar(0), - bIsCollapsed(FALSE) + SwFrmFmt& rFmt ) + : m_ListenerContainer( static_cast<text::XTextRange*>(this) ) + , m_pPropSet(aSwMapProvider.GetPropertySet( + PROPERTY_MAP_TEXTPORTION_EXTENSIONS)) + , m_xParentText(rParent) + , m_pRubyText(0) + , m_pRubyStyle(0) + , m_pRubyAdjust(0) + , m_pRubyIsAbove(0) + , m_FrameDepend(this, &rFmt) + , m_pFrameFmt(&rFmt) + , m_ePortionType(PORTION_FRAME) + , m_bIsCollapsed(false) { - SwUnoCrsr* pUnoCrsr = pPortionCrsr->GetDoc()->CreateUnoCrsr(*pPortionCrsr->GetPoint()); - if(pPortionCrsr->HasMark()) + init(*this, pPortionCrsr); +} + +/* -----------------------------19.02.01 10:52-------------------------------- + + ---------------------------------------------------------------------------*/ +SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, + SwTxtRuby const& rAttr, + uno::Reference< text::XText > const& xParent, + sal_Bool bIsEnd ) + : m_ListenerContainer( static_cast<text::XTextRange*>(this) ) + , m_pPropSet(aSwMapProvider.GetPropertySet( + PROPERTY_MAP_TEXTPORTION_EXTENSIONS)) + , m_xParentText(xParent) + , m_pRubyText ( bIsEnd ? 0 : new uno::Any ) + , m_pRubyStyle ( bIsEnd ? 0 : new uno::Any ) + , m_pRubyAdjust ( bIsEnd ? 0 : new uno::Any ) + , m_pRubyIsAbove( bIsEnd ? 0 : new uno::Any ) + , m_FrameDepend(this, 0) + , m_pFrameFmt(0) + , m_ePortionType( bIsEnd ? PORTION_RUBY_END : PORTION_RUBY_START ) + , m_bIsCollapsed(false) +{ + init(*this, pPortionCrsr); + + if (!bIsEnd) { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pPortionCrsr->GetMark(); + const SfxPoolItem& rItem = rAttr.GetAttr(); + rItem.QueryValue(*m_pRubyText, MID_RUBY_TEXT); + rItem.QueryValue(*m_pRubyStyle, MID_RUBY_CHARSTYLE); + rItem.QueryValue(*m_pRubyAdjust, MID_RUBY_ADJUST); + rItem.QueryValue(*m_pRubyIsAbove, MID_RUBY_ABOVE); } - pUnoCrsr->Add(this); } /*-- 11.12.98 09:56:55--------------------------------------------------- @@ -153,77 +160,71 @@ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, SwXTextPortion::~SwXTextPortion() { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); delete pUnoCrsr; - delete pRubyText; - delete pRubyStyle; - delete pRubyAdjust; - delete pRubyIsAbove; } /*-- 11.12.98 09:56:56--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XText > SwXTextPortion::getText(void) throw( uno::RuntimeException ) +uno::Reference< text::XText > SwXTextPortion::getText() +throw( uno::RuntimeException ) { - return xParentText; + return m_xParentText; } /*-- 11.12.98 09:56:56--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXTextPortion::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SwXTextPortion::getStart() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - SwPaM aPam(*pUnoCrsr->Start()); - uno::Reference< text::XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwPaM aPam(*pUnoCrsr->Start()); + uno::Reference< text::XText > xParent = getText(); + xRet = new SwXTextRange(aPam, xParent); return xRet; } /*-- 11.12.98 09:56:57--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXTextPortion::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SwXTextPortion::getEnd() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - SwPaM aPam(*pUnoCrsr->End()); - uno::Reference< text::XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwPaM aPam(*pUnoCrsr->End()); + uno::Reference< text::XText > xParent = getText(); + xRet = new SwXTextRange(aPam, xParent); return xRet; } /*-- 11.12.98 09:56:57--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXTextPortion::getString(void) throw( uno::RuntimeException ) +OUString SwXTextPortion::getString() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - String aTxt; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) + OUString aTxt; + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) + throw uno::RuntimeException(); + + // TextPortions are always within a paragraph + SwTxtNode* pTxtNd = pUnoCrsr->GetNode()->GetTxtNode(); + if ( pTxtNd ) { - //TextPortions liegen immer innerhalb eines Absatzes - SwTxtNode* pTxtNd = pUnoCrsr->GetNode()->GetTxtNode(); - if( pTxtNd ) - { - xub_StrLen nStt = pUnoCrsr->Start()->nContent.GetIndex(); - aTxt = pTxtNd->GetExpandTxt( nStt, - pUnoCrsr->End()->nContent.GetIndex() - nStt ); - } + xub_StrLen nStt = pUnoCrsr->Start()->nContent.GetIndex(); + aTxt = pTxtNd->GetExpandTxt( nStt, + pUnoCrsr->End()->nContent.GetIndex() - nStt ); } - else - throw uno::RuntimeException(); return aTxt; } /*-- 11.12.98 09:56:57--------------------------------------------------- @@ -232,17 +233,19 @@ OUString SwXTextPortion::getString(void) throw( uno::RuntimeException ) void SwXTextPortion::setString(const OUString& aString) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - SwXTextCursor::SetString(*pUnoCrsr, aString); - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwXTextCursor::SetString(*pUnoCrsr, aString); } /*-- 11.12.98 09:56:57--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXTextPortion::getPropertySetInfo(void) throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SwXTextPortion::getPropertySetInfo() +throw( uno::RuntimeException ) { + vos::OGuard aGuard(Application::GetSolarMutex()); //! PropertySetInfo for text portion extensions static uno::Reference< beans::XPropertySetInfo > xTxtPorExtRef = aSwMapProvider.GetPropertySet( @@ -252,8 +255,8 @@ uno::Reference< beans::XPropertySetInfo > SwXTextPortion::getPropertySetInfo(vo xRedlPorRef = aSwMapProvider.GetPropertySet( PROPERTY_MAP_REDLINE_PORTION)->getPropertySetInfo(); - return (PORTION_REDLINE_START == ePortionType || - PORTION_REDLINE_END == ePortionType) ? xRedlPorRef : xTxtPorExtRef; + return (PORTION_REDLINE_START == m_ePortionType || + PORTION_REDLINE_END == m_ePortionType) ? xRedlPorRef : xTxtPorExtRef; } /*-- 11.12.98 09:56:57--------------------------------------------------- @@ -264,13 +267,12 @@ void SwXTextPortion::setPropertyValue(const OUString& rPropertyName, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - SwXTextCursor::SetPropertyValue(*pUnoCrsr, *m_pPropSet, rPropertyName, aValue); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwXTextCursor::SetPropertyValue(*pUnoCrsr, *m_pPropSet, + rPropertyName, aValue); } /*-- 04.11.03 09:56:58--------------------------------------------------- @@ -291,13 +293,12 @@ void SwXTextPortion::GetPropertyValue( case FN_UNO_TEXT_PORTION_TYPE: { const char* pRet; - switch (ePortionType) + switch (m_ePortionType) { case PORTION_TEXT: pRet = "Text";break; case PORTION_FIELD: pRet = "TextField";break; case PORTION_FRAME: pRet = "Frame";break; case PORTION_FOOTNOTE: pRet = "Footnote";break; - case PORTION_CONTROL_CHAR: pRet = "ControlCharacter";break; case PORTION_REFMARK_START: case PORTION_REFMARK_END: pRet = SW_PROP_NAME_STR(UNO_NAME_REFERENCE_MARK);break; case PORTION_TOXMARK_START: @@ -309,6 +310,7 @@ void SwXTextPortion::GetPropertyValue( case PORTION_RUBY_START: case PORTION_RUBY_END: pRet = "Ruby";break; case PORTION_SOFT_PAGEBREAK:pRet = "SoftPageBreak";break; + case PORTION_META: pRet = SW_PROP_NAME_STR(UNO_NAME_META); break; case PORTION_FIELD_START:pRet = "TextFieldStart";break; case PORTION_FIELD_END:pRet = "TextFieldEnd";break; case PORTION_FIELD_START_END:pRet = "TextFieldStartEnd";break; @@ -322,28 +324,29 @@ void SwXTextPortion::GetPropertyValue( rVal <<= sRet; } break; - case FN_UNO_CONTROL_CHARACTER: - { - if(PORTION_CONTROL_CHAR == ePortionType) - rVal <<= (sal_Int16) nControlChar; - } + case FN_UNO_CONTROL_CHARACTER: // obsolete! break; case FN_UNO_DOCUMENT_INDEX_MARK: - rVal <<= xTOXMark; + rVal <<= m_xTOXMark; break; case FN_UNO_REFERENCE_MARK: - rVal <<= xRefMark; + rVal <<= m_xRefMark; break; case FN_UNO_BOOKMARK: - rVal <<= xBookmark; + rVal <<= m_xBookmark; break; case FN_UNO_FOOTNOTE: - rVal <<= xFootnote; + rVal <<= m_xFootnote; + break; + case FN_UNO_TEXT_FIELD: + rVal <<= m_xTextField; + break; + case FN_UNO_META: + rVal <<= m_xMeta; break; case FN_UNO_IS_COLLAPSED: { - BOOL bPut = TRUE; - switch (ePortionType) + switch (m_ePortionType) { case PORTION_REFMARK_START: case PORTION_BOOKMARK_START : @@ -357,17 +360,17 @@ void SwXTextPortion::GetPropertyValue( case PORTION_RUBY_END: case PORTION_FIELD_START: case PORTION_FIELD_END: - rVal.setValue(&bIsCollapsed, ::getBooleanCppuType()); + rVal.setValue(&m_bIsCollapsed, ::getBooleanCppuType()); break; default: - bPut = FALSE; + break; } } break; case FN_UNO_IS_START: { BOOL bStart = TRUE, bPut = TRUE; - switch (ePortionType) + switch (m_ePortionType) { case PORTION_REFMARK_START: case PORTION_BOOKMARK_START: @@ -394,13 +397,13 @@ void SwXTextPortion::GetPropertyValue( break; case RES_TXTATR_CJK_RUBY: { - uno::Any* pToSet = 0; + const uno::Any* pToSet = 0; switch(rEntry.nMemberId) { - case MID_RUBY_TEXT : pToSet = pRubyText; break; - case MID_RUBY_ADJUST : pToSet = pRubyAdjust; break; - case MID_RUBY_CHARSTYLE:pToSet = pRubyStyle; break; - case MID_RUBY_ABOVE : pToSet = pRubyIsAbove; break; + case MID_RUBY_TEXT : pToSet = m_pRubyText.get(); break; + case MID_RUBY_ADJUST : pToSet = m_pRubyAdjust.get(); break; + case MID_RUBY_CHARSTYLE:pToSet = m_pRubyStyle.get(); break; + case MID_RUBY_ABOVE : pToSet = m_pRubyIsAbove.get();break; } if(pToSet) rVal = *pToSet; @@ -436,8 +439,10 @@ uno::Sequence< uno::Any > SAL_CALL SwXTextPortion::GetPropertyValues_Impl( const OUString *pPropertyNames = rPropertyNames.getConstArray(); uno::Sequence< uno::Any > aValues(rPropertyNames.getLength()); uno::Any *pValues = aValues.getArray(); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) + throw uno::RuntimeException(); + { SfxItemSet *pSet = 0; // get startting pount fo the look-up, either the provided one or else @@ -455,8 +460,6 @@ uno::Sequence< uno::Any > SAL_CALL SwXTextPortion::GetPropertyValues_Impl( } delete pSet; } - else - throw uno::RuntimeException(); return aValues; } /*-- 11.12.98 09:56:58--------------------------------------------------- @@ -480,8 +483,10 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl( throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) + throw uno::RuntimeException(); + { const OUString* pPropertyNames = rPropertyNames.getConstArray(); const uno::Any* pValues = rValues.getConstArray(); @@ -494,11 +499,10 @@ 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, pPropertyNames[nProp], pValues[nProp]); + SwXTextCursor::SetPropertyValue( *pUnoCrsr, *m_pPropSet, + pPropertyNames[nProp], pValues[nProp]); } } - else - throw uno::RuntimeException(); } void SwXTextPortion::setPropertyValues( @@ -564,7 +568,7 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXTextPortion::setPr if (rPropertyNames.getLength() != rValues.getLength()) throw lang::IllegalArgumentException(); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); + SwUnoCrsr* pUnoCrsr = this->GetCursor(); if (!pUnoCrsr) throw uno::RuntimeException(); @@ -664,7 +668,7 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion: { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); + SwUnoCrsr* pUnoCrsr = this->GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); @@ -703,8 +707,10 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion: aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE; //#i104499# ruby portion attributes need special handling: if( pEntry->nWID == RES_TXTATR_CJK_RUBY && - ePortionType == PORTION_RUBY_START ) + m_ePortionType == PORTION_RUBY_START ) + { aResult.State = beans::PropertyState_DIRECT_VALUE; + } if (!bDirectValuesOnly || beans::PropertyState_DIRECT_VALUE == aResult.State) { // get property value @@ -815,17 +821,20 @@ beans::PropertyState SwXTextPortion::getPropertyState(const OUString& rPropertyN { vos::OGuard aGuard(Application::GetSolarMutex()); beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) + throw uno::RuntimeException(); + + if (GetTextPortionType() == PORTION_RUBY_START && + !rPropertyName.compareToAscii( RTL_CONSTASCII_STRINGPARAM("Ruby") )) { - if(GetTextPortionType() == PORTION_RUBY_START && - !rPropertyName.compareToAscii( RTL_CONSTASCII_STRINGPARAM("Ruby") )) - eRet = beans::PropertyState_DIRECT_VALUE; - else - eRet = SwXTextCursor::GetPropertyState(*pUnoCrsr, *m_pPropSet, rPropertyName); + eRet = beans::PropertyState_DIRECT_VALUE; } else - throw uno::RuntimeException(); + { + eRet = SwXTextCursor::GetPropertyState(*pUnoCrsr, *m_pPropSet, + rPropertyName); + } return eRet; } /*-- 08.03.99 09:41:47--------------------------------------------------- @@ -836,10 +845,13 @@ uno::Sequence< beans::PropertyState > SwXTextPortion::getPropertyStates( throw( beans::UnknownPropertyException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); - uno::Sequence< beans::PropertyState > aRet = SwXTextCursor::GetPropertyStates(*pUnoCrsr, *m_pPropSet, rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION); + + uno::Sequence< beans::PropertyState > aRet = + SwXTextCursor::GetPropertyStates(*pUnoCrsr, *m_pPropSet, + rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION); if(GetTextPortionType() == PORTION_RUBY_START) { @@ -860,13 +872,11 @@ void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName) throw( beans::UnknownPropertyException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwXTextCursor::SetPropertyToDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwXTextCursor::SetPropertyToDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); } /*-- 08.03.99 09:41:48--------------------------------------------------- @@ -874,33 +884,17 @@ void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName) uno::Any SwXTextPortion::getPropertyDefault(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) { + vos::OGuard aGuard(Application::GetSolarMutex()); uno::Any aRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - aRet = SwXTextCursor::GetPropertyDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + aRet = SwXTextCursor::GetPropertyDefault(*pUnoCrsr, *m_pPropSet, + rPropertyName); return aRet; } -/*-- 11.12.98 09:56:59--------------------------------------------------- - -----------------------------------------------------------------------*/ -OUString SwXTextPortion::getPresentation(sal_Bool /*bShowCommand*/) throw( uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - String sRet; - SwFmtFld* pFmt = 0; - if(pUnoCrsr && 0 != (pFmt = GetFldFmt())) - { - const SwField* pField = pFmt->GetFld(); - DBG_ERROR("bShowCommand auswerten!"); - sRet = pField->Expand(); - } - return sRet; -} /*-- 11.12.98 09:56:59--------------------------------------------------- -----------------------------------------------------------------------*/ @@ -915,31 +909,31 @@ void SwXTextPortion::attach(const uno::Reference< text::XTextRange > & /*xTextRa /*-- 11.12.98 09:57:00--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXTextPortion::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SwXTextPortion::getAnchor() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > aRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - aRet = new SwXTextRange(*pUnoCrsr, xParentText); - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + aRet = new SwXTextRange(*pUnoCrsr, m_xParentText); return aRet; } /*-- 11.12.98 09:57:00--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextPortion::dispose(void) throw( uno::RuntimeException ) +void SwXTextPortion::dispose() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - setString(aEmptyStr); - pUnoCrsr->Remove(this); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + setString(aEmptyStr); + pUnoCrsr->Remove(this); } /*-- 11.12.98 09:57:00--------------------------------------------------- @@ -949,7 +943,8 @@ void SwXTextPortion::addEventListener(const uno::Reference< lang::XEventListener vos::OGuard aGuard(Application::GetSolarMutex()); if(!GetRegisteredIn()) throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + + m_ListenerContainer.AddListener(aListener); } /*-- 11.12.98 09:57:01--------------------------------------------------- @@ -957,7 +952,7 @@ void SwXTextPortion::addEventListener(const uno::Reference< lang::XEventListener void SwXTextPortion::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + if (!GetRegisteredIn() || !m_ListenerContainer.RemoveListener(aListener)) throw uno::RuntimeException(); } /* -----------------24.03.99 13:30------------------- @@ -967,10 +962,13 @@ uno::Reference< container::XEnumeration > SwXTextPortion::createContentEnumerat throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); - uno::Reference< container::XEnumeration > xRet = new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_CHAR, pFrameFmt); + + uno::Reference< container::XEnumeration > xRet = + new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_CHAR, + m_pFrameFmt); return xRet; } @@ -999,7 +997,8 @@ sal_Int64 SwXTextPortion::getSomething( const uno::Sequence< sal_Int8 >& rId ) /* -----------------24.03.99 13:30------------------- * * --------------------------------------------------*/ -uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames(void) throw( uno::RuntimeException ) +uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Sequence< OUString > aRet(1); @@ -1010,7 +1009,8 @@ uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames(void) throw( /* -----------------25.03.99 10:30------------------- * * --------------------------------------------------*/ -OUString SwXTextPortion::getImplementationName(void) throw( uno::RuntimeException ) +OUString SwXTextPortion::getImplementationName() +throw( uno::RuntimeException ) { return C2U("SwXTextPortion"); } @@ -1020,7 +1020,7 @@ OUString SwXTextPortion::getImplementationName(void) throw( uno::RuntimeExceptio sal_Bool SwXTextPortion::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); @@ -1032,25 +1032,24 @@ sal_Bool SwXTextPortion::supportsService(const OUString& rServiceName) throw( un !rServiceName.compareToAscii("com.sun.star.style.ParagraphProperties") || !rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesAsian") || !rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesComplex")) + { bRet = sal_True; - else if(COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextField")) - bRet = 0 != GetFldFmt(); + } return bRet; } /* --------------------------------------------------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames(void) - throw( uno::RuntimeException ) +uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(!pUnoCrsr) + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); - sal_Bool bField = 0 != GetFldFmt(); - sal_uInt16 nCount = bField ? 8 : 7; - uno::Sequence< OUString > aRet(nCount); + + uno::Sequence< OUString > aRet(7); OUString* pArray = aRet.getArray(); pArray[0] = C2U("com.sun.star.text.TextPortion"); pArray[1] = C2U("com.sun.star.style.CharacterProperties"); @@ -1059,8 +1058,6 @@ uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames(void) pArray[4] = C2U("com.sun.star.style.ParagraphProperties"); pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian"); pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex"); - if(bField) - pArray[7] = C2U("com.sun.star.text.TextField"); return aRet; } /*-- 11.12.98 09:57:01--------------------------------------------------- @@ -1069,34 +1066,9 @@ uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames(void) void SwXTextPortion::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) { ClientModify(this, pOld, pNew); - if(!aFrameDepend.GetRegisteredIn()) - pFrameFmt = 0; -} -/* -----------------------------19.02.01 10:52-------------------------------- - - ---------------------------------------------------------------------------*/ -SwXRubyPortion::SwXRubyPortion(const SwUnoCrsr* pPortionCrsr, - SwTxtRuby& rAttr, - uno::Reference< text::XText > const& rParent, - sal_Bool bEnd ) : - SwXTextPortion(pPortionCrsr, rParent, bEnd ? PORTION_RUBY_END : PORTION_RUBY_START ) -{ - if(!bEnd) + if (!m_FrameDepend.GetRegisteredIn()) { - const SfxPoolItem& rItem = rAttr.GetAttr(); - pRubyText = new uno::Any; - pRubyStyle = new uno::Any; - pRubyAdjust = new uno::Any; - pRubyIsAbove = new uno::Any; - rItem.QueryValue(*pRubyText, MID_RUBY_TEXT); - rItem.QueryValue(*pRubyStyle, MID_RUBY_CHARSTYLE); - rItem.QueryValue(*pRubyAdjust, MID_RUBY_ADJUST); - rItem.QueryValue(*pRubyIsAbove, MID_RUBY_ABOVE); + m_pFrameFmt = 0; } } -/* -----------------------------19.02.01 10:52-------------------------------- - ---------------------------------------------------------------------------*/ -SwXRubyPortion::~SwXRubyPortion() -{ -} diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index d972329b0f52..b49816d9c9e3 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -32,30 +32,37 @@ #include "precompiled_sw.hxx" +#include <unoport.hxx> #include <IMark.hxx> // --> OD 2007-10-23 #i81002# #include <crossrefbookmark.hxx> // <-- #include <doc.hxx> #include <txatbase.hxx> +#include <txtatr.hxx> #include <ndhints.hxx> #include <ndtxt.hxx> #include <unocrsr.hxx> #include <docary.hxx> -#include <fmthbsh.hxx> #include <tox.hxx> #include <unoclbck.hxx> #include <unoobj.hxx> #include <unoredline.hxx> +#include <unofield.hxx> +#include <unometa.hxx> #include <fmtanchr.hxx> +#include <fmtrfmrk.hxx> #include <unoidx.hxx> #include <redline.hxx> #include <crsskip.hxx> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> #include <set> + #include <boost/shared_ptr.hpp> #include <boost/bind.hpp> +#include <algorithm> +#include <stack> using namespace ::com::sun::star; @@ -64,6 +71,16 @@ using namespace ::com::sun::star::text; using ::rtl::OUString; using namespace ::std; +typedef ::std::pair< TextRangeList_t * const, SwTxtAttr const * const > PortionList_t; +typedef ::std::stack< PortionList_t > PortionStack_t; + +static void lcl_CreatePortions( + TextRangeList_t & i_rPortions, + uno::Reference< text::XText > const& i_xParentText, + SwUnoCrsr* pUnoCrsr, + FrameDependSortList_t & i_rFrames, + const sal_Int32 i_nStartPos, const sal_Int32 i_nEndPos ); + namespace { @@ -182,8 +199,9 @@ const uno::Sequence< sal_Int8 > & SwXTextPortionEnumeration::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXTextPortionEnumeration::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL SwXTextPortionEnumeration::getSomething( + const uno::Sequence< sal_Int8 >& rId ) +throw(uno::RuntimeException) { if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), @@ -196,167 +214,286 @@ sal_Int64 SAL_CALL SwXTextPortionEnumeration::getSomething( const uno::Sequence< /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXTextPortionEnumeration::getImplementationName(void) throw( RuntimeException ) +OUString SwXTextPortionEnumeration::getImplementationName() +throw( RuntimeException ) { return C2U("SwXTextPortionEnumeration"); } /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXTextPortionEnumeration::supportsService(const OUString& rServiceName) throw( RuntimeException ) +sal_Bool +SwXTextPortionEnumeration::supportsService(const OUString& rServiceName) +throw( RuntimeException ) { return C2U("com.sun.star.text.TextPortionEnumeration") == rServiceName; } /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -Sequence< OUString > SwXTextPortionEnumeration::getSupportedServiceNames(void) throw( RuntimeException ) +Sequence< OUString > SwXTextPortionEnumeration::getSupportedServiceNames() +throw( RuntimeException ) { Sequence< OUString > aRet(1); OUString* pArray = aRet.getArray(); pArray[0] = C2U("com.sun.star.text.TextPortionEnumeration"); return aRet; } + /*-- 27.01.99 10:44:43--------------------------------------------------- -----------------------------------------------------------------------*/ SwXTextPortionEnumeration::SwXTextPortionEnumeration( - SwPaM& rParaCrsr, - uno::Reference< XText > xParentText, - sal_Int32 nStart, - sal_Int32 nEnd - ) : - xParent(xParentText), - bAtEnd(sal_False), - bFirstPortion(sal_True), - nStartPos(nStart), - nEndPos(nEnd) + SwPaM& rParaCrsr, + uno::Reference< XText > const & xParentText, + const sal_Int32 nStart, + const sal_Int32 nEnd ) + : m_Portions() { - SwUnoCrsr* pUnoCrsr = rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), sal_False); + SwUnoCrsr* pUnoCrsr = + rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), sal_False); pUnoCrsr->Add(this); DBG_ASSERT(nEnd == -1 || (nStart <= nEnd && nEnd <= pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()->GetTxt().Len()), "start or end value invalid!"); - //alle Rahmen, Grafiken und OLEs suchen, die an diesem Absatz - // AM ZEICHEN gebunden sind - ::CollectFrameAtNode( *this, pUnoCrsr->GetPoint()->nNode, - aFrameArr, TRUE ); - CreatePortions(); + + // find all frames, graphics and OLEs that are bound AT character in para + FrameDependSortList_t frames; + ::CollectFrameAtNode(*this, pUnoCrsr->GetPoint()->nNode, frames, true); + lcl_CreatePortions(m_Portions, xParentText, pUnoCrsr, frames, nStart, nEnd); +} + +SwXTextPortionEnumeration::SwXTextPortionEnumeration( + SwPaM& rParaCrsr, + TextRangeList_t const & rPortions ) + : m_Portions( rPortions ) +{ + SwUnoCrsr* const pUnoCrsr = + rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), sal_False); + pUnoCrsr->Add(this); } + /*-- 27.01.99 10:44:44--------------------------------------------------- -----------------------------------------------------------------------*/ SwXTextPortionEnumeration::~SwXTextPortionEnumeration() { vos::OGuard aGuard(Application::GetSolarMutex()); - for(sal_uInt16 nFrame = aFrameArr.Count(); nFrame; ) - delete aFrameArr.GetObject( --nFrame ); - aFrameArr.Remove(0, aFrameArr.Count()); - - if( aPortionArr.Count() ) - aPortionArr.DeleteAndDestroy(0, aPortionArr.Count() ); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); delete pUnoCrsr; } /*-- 27.01.99 10:44:44--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextPortionEnumeration::hasMoreElements(void) throw( uno::RuntimeException ) +sal_Bool SwXTextPortionEnumeration::hasMoreElements() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - return aPortionArr.Count() > 0; + + return (m_Portions.size() > 0) ? sal_True : sal_False; } /*-- 27.01.99 10:44:45--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXTextPortionEnumeration::nextElement(void) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SwXTextPortionEnumeration::nextElement() +throw( container::NoSuchElementException, lang::WrappedTargetException, + uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!aPortionArr.Count()) + + if (!m_Portions.size()) throw container::NoSuchElementException(); - XTextRangeRefPtr pPortion = aPortionArr.GetObject(0); - Any aRet(pPortion, ::getCppuType((uno::Reference<XTextRange>*)0)); - aPortionArr.Remove(0); - delete pPortion; - return aRet; + + Any any; + any <<= m_Portions.front(); + m_Portions.pop_front(); + return any; +} + +//====================================================================== + +typedef ::std::deque< xub_StrLen > FieldMarks_t; + +static void +lcl_FillFieldMarkArray(FieldMarks_t & rFieldMarks, SwUnoCrsr const & rUnoCrsr, + const sal_Int32 i_nStartPos) +{ + const SwTxtNode * const pTxtNode = + rUnoCrsr.GetPoint()->nNode.GetNode().GetTxtNode(); + if (!pTxtNode) return; + + const sal_Unicode fld[] = { + CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDEND, CH_TXT_ATR_FORMELEMENT, 0 }; + xub_StrLen pos = ::std::max(static_cast<const sal_Int32>(0), i_nStartPos); + while ((pos = pTxtNode->GetTxt().SearchChar(fld, pos)) != STRING_NOTFOUND) + { + rFieldMarks.push_back(pos); + ++pos; + } } + +static uno::Reference<text::XTextRange> +lcl_ExportFieldMark( + uno::Reference< text::XText > const & i_xParentText, + SwUnoCrsr * const pUnoCrsr, + const SwTxtNode * const pTxtNode ) +{ + uno::Reference<text::XTextRange> xRef; + SwDoc* pDoc = pUnoCrsr->GetDoc(); + //flr: maybe its a good idea to add a special hint to the hints array and rely on the hint segmentation.... + const xub_StrLen start = pUnoCrsr->Start()->nContent.GetIndex(); + ASSERT(pUnoCrsr->End()->nContent.GetIndex() == start, + "hmm --- why is this different"); + + pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); + if ( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) + { + ASSERT(false, "cannot move cursor?"); + return 0; + } + + const sal_Unicode Char = pTxtNode->GetTxt().GetChar(start); + if (CH_TXT_ATR_FIELDSTART == Char) + { + ::sw::mark::IFieldmark* pFieldmark = NULL; + if (pDoc) + { + pFieldmark = pDoc->getIDocumentMarkAccess()-> + getFieldmarkFor(*pUnoCrsr->GetMark()); + } + SwXTextPortion* pPortion = new SwXTextPortion( + pUnoCrsr, i_xParentText, PORTION_FIELD_START); + xRef = pPortion; + if (pPortion && pFieldmark && pDoc) + pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc)); + } + else if (CH_TXT_ATR_FIELDEND == Char) + { + ::sw::mark::IFieldmark* pFieldmark = NULL; + if (pDoc) + { + pFieldmark = pDoc->getIDocumentMarkAccess()-> + getFieldmarkFor(*pUnoCrsr->GetMark()); + } + SwXTextPortion* pPortion = new SwXTextPortion( + pUnoCrsr, i_xParentText, PORTION_FIELD_END); + xRef = pPortion; + if (pPortion && pFieldmark && pDoc) + pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc)); + } + else if (CH_TXT_ATR_FORMELEMENT == Char) + { + ::sw::mark::IFieldmark* pFieldmark = NULL; + if (pDoc) + { + pFieldmark = pDoc->getIDocumentMarkAccess()-> + getFieldmarkFor(*pUnoCrsr->GetMark()); + } + SwXTextPortion* pPortion = new SwXTextPortion( + pUnoCrsr, i_xParentText, PORTION_FIELD_START_END); + xRef = pPortion; + if (pPortion && pFieldmark && pDoc) + pPortion->SetBookmark(new SwXFieldmark(true, pFieldmark, pDoc)); + } + else + { + ASSERT(false, "no fieldmark found?"); + } + return xRef; +} + /* -----------------------------31.08.00 14:28-------------------------------- ---------------------------------------------------------------------------*/ -void lcl_InsertRefMarkPortion( - XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, - Reference<XText> const& rParent, SwTxtAttr* pAttr, BOOL bEnd) +static Reference<XTextRange> +lcl_CreateRefMarkPortion( + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + const SwTxtAttr & rAttr, const bool bEnd) { SwDoc* pDoc = pUnoCrsr->GetDoc(); - SwFmtRefMark& rRefMark = ((SwFmtRefMark&)pAttr->GetAttr()); - Reference<XTextContent> xContent = ((SwUnoCallBack*)pDoc->GetUnoCallBack())->GetRefMark(rRefMark); - if(!xContent.is()) + const SwFmtRefMark& rRefMark = + static_cast<const SwFmtRefMark&>(rAttr.GetAttr()); + Reference<XTextContent> xContent = + static_cast<SwUnoCallBack*>(pDoc->GetUnoCallBack()) + ->GetRefMark(rRefMark); + if (!xContent.is()) + { xContent = new SwXReferenceMark(pDoc, &rRefMark); + } SwXTextPortion* pPortion = 0; - if(!bEnd) + if (!bEnd) { - rArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_REFMARK_START)), - rArr.Count()); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_REFMARK_START); pPortion->SetRefMark(xContent); - pPortion->SetCollapsed(pAttr->GetEnd() ? FALSE : TRUE); + pPortion->SetCollapsed(rAttr.GetEnd() ? false : true); } else { - rArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_REFMARK_END)), - rArr.Count()); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_REFMARK_END); pPortion->SetRefMark(xContent); } + return pPortion; } + //----------------------------------------------------------------------------- -void lcl_InsertRubyPortion( XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, - Reference<XText> const& rParent, SwTxtAttr* pAttr, BOOL bEnd) +static void +lcl_InsertRubyPortion( + TextRangeList_t & rPortions, + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + const SwTxtAttr & rAttr, const sal_Bool bEnd) { - SwXRubyPortion* pPortion = - new SwXRubyPortion(pUnoCrsr, *(SwTxtRuby*)pAttr, rParent, bEnd); - rArr.Insert( new Reference< XTextRange >(pPortion), rArr.Count() ); - pPortion->SetCollapsed(pAttr->GetEnd() ? FALSE : TRUE); + SwXTextPortion* pPortion = new SwXTextPortion(pUnoCrsr, + static_cast<const SwTxtRuby&>(rAttr), xParent, bEnd); + rPortions.push_back(pPortion); + pPortion->SetCollapsed(rAttr.GetEnd() ? false : true); } + //----------------------------------------------------------------------------- -void lcl_InsertTOXMarkPortion( - XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, Reference<XText> const& rParent, - SwTxtAttr* pAttr, BOOL bEnd) +static Reference<XTextRange> +lcl_CreateTOXMarkPortion( + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + const SwTxtAttr & rAttr, const bool bEnd) { SwDoc* pDoc = pUnoCrsr->GetDoc(); - SwTOXMark& rTOXMark = ((SwTOXMark&)pAttr->GetAttr()); + const SwTOXMark& rTOXMark = static_cast<const SwTOXMark&>(rAttr.GetAttr()); Reference<XTextContent> xContent = - ((SwUnoCallBack*)pDoc->GetUnoCallBack())->GetTOXMark(rTOXMark); - if(!xContent.is()) - xContent = new SwXDocumentIndexMark(rTOXMark.GetTOXType(), &rTOXMark, pDoc); + static_cast<SwUnoCallBack*>(pDoc->GetUnoCallBack()) + ->GetTOXMark(rTOXMark); + if (!xContent.is()) + { + xContent = new SwXDocumentIndexMark(rTOXMark.GetTOXType(), + &rTOXMark, pDoc); + } SwXTextPortion* pPortion = 0; - if(!bEnd) + if (!bEnd) { - rArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_TOXMARK_START)), - rArr.Count()); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_TOXMARK_START); pPortion->SetTOXMark(xContent); - pPortion->SetCollapsed(pAttr->GetEnd() ? FALSE : TRUE); + pPortion->SetCollapsed(rAttr.GetEnd() ? false : true); } - if(bEnd) + else { - rArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_TOXMARK_END)), - rArr.Count()); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_TOXMARK_END); pPortion->SetTOXMark(xContent); } + return pPortion; } //----------------------------------------------------------------------------- -void lcl_ExportBookmark( - SwXBookmarkPortion_ImplList& rBkmArr, ULONG nIndex, - SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr) +static void +lcl_ExportBookmark( + TextRangeList_t & rPortions, + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + SwXBookmarkPortion_ImplList& rBkmArr, const ULONG nIndex) { for ( SwXBookmarkPortion_ImplList::iterator aIter = rBkmArr.begin(), aEnd = rBkmArr.end(); aIter != aEnd; ) @@ -371,31 +508,37 @@ void lcl_ExportBookmark( break; SwXTextPortion* pPortion = 0; - if(BKM_TYPE_START == pPtr->nBkmType || BKM_TYPE_START_END == pPtr->nBkmType) + if ((BKM_TYPE_START == pPtr->nBkmType) || + (BKM_TYPE_START_END == pPtr->nBkmType)) { - rPortionArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_BOOKMARK_START)), - rPortionArr.Count()); + pPortion = + new SwXTextPortion(pUnoCrsr, xParent, PORTION_BOOKMARK_START); + rPortions.push_back(pPortion); pPortion->SetBookmark(pPtr->xBookmark); - pPortion->SetCollapsed(BKM_TYPE_START_END == pPtr->nBkmType ? TRUE : FALSE); + pPortion->SetCollapsed( (BKM_TYPE_START_END == pPtr->nBkmType) + ? true : false); } - if(BKM_TYPE_END == pPtr->nBkmType) + if (BKM_TYPE_END == pPtr->nBkmType) { - rPortionArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_BOOKMARK_END)), - rPortionArr.Count()); + pPortion = + new SwXTextPortion(pUnoCrsr, xParent, PORTION_BOOKMARK_END); + rPortions.push_back(pPortion); pPortion->SetBookmark(pPtr->xBookmark); } rBkmArr.erase( aIter++ ); } } -void lcl_ExportSoftPageBreak( - SwSoftPageBreakList& rBreakArr, ULONG nIndex, - SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr) +static void +lcl_ExportSoftPageBreak( + TextRangeList_t & rPortions, + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + SwSoftPageBreakList& rBreakArr, const ULONG nIndex) { - for ( SwSoftPageBreakList::iterator aIter = rBreakArr.begin(), aEnd = rBreakArr.end(); + for ( SwSoftPageBreakList::iterator aIter = rBreakArr.begin(), + aEnd = rBreakArr.end(); aIter != aEnd; ) { if ( nIndex > *aIter ) @@ -406,9 +549,8 @@ void lcl_ExportSoftPageBreak( if ( nIndex < *aIter ) break; - rPortionArr.Insert( - new Reference< XTextRange >(new SwXTextPortion(pUnoCrsr, rParent, PORTION_SOFT_PAGEBREAK)), - rPortionArr.Count()); + rPortions.push_back( + new SwXTextPortion(pUnoCrsr, xParent, PORTION_SOFT_PAGEBREAK) ); rBreakArr.erase( aIter++ ); } } @@ -426,49 +568,60 @@ void lcl_ExportSoftPageBreak( struct SwXRedlinePortion_Impl { - const SwRedline* pRedline; - sal_Bool bStart; + const SwRedline* m_pRedline; + const bool m_bStart; - SwXRedlinePortion_Impl ( const SwRedline* pRed, sal_Bool bIsStart ) - : pRedline(pRed) - , bStart(bIsStart) + SwXRedlinePortion_Impl ( const SwRedline* pRed, const bool bIsStart ) + : m_pRedline(pRed) + , m_bStart(bIsStart) { } + ULONG getRealIndex () { - return bStart ? pRedline->Start()->nContent.GetIndex() : - pRedline->End() ->nContent.GetIndex(); + return m_bStart ? m_pRedline->Start()->nContent.GetIndex() + : m_pRedline->End() ->nContent.GetIndex(); } }; -typedef boost::shared_ptr < SwXRedlinePortion_Impl > SwXRedlinePortion_ImplSharedPtr; +typedef boost::shared_ptr < SwXRedlinePortion_Impl > + SwXRedlinePortion_ImplSharedPtr; + struct RedlineCompareStruct { const SwPosition& getPosition ( const SwXRedlinePortion_ImplSharedPtr &r ) { - return *(r->bStart ? r->pRedline->Start() : r->pRedline->End()); + return *(r->m_bStart ? r->m_pRedline->Start() : r->m_pRedline->End()); } + bool operator () ( const SwXRedlinePortion_ImplSharedPtr &r1, const SwXRedlinePortion_ImplSharedPtr &r2 ) { return getPosition ( r1 ) < getPosition ( r2 ); } }; -typedef std::multiset < SwXRedlinePortion_ImplSharedPtr, RedlineCompareStruct > SwXRedlinePortion_ImplList; + +typedef std::multiset < SwXRedlinePortion_ImplSharedPtr, RedlineCompareStruct > +SwXRedlinePortion_ImplList; //----------------------------------------------------------------------------- -Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, - XTextRangeArr& rPortionArr, - SwUnoCrsr* pUnoCrsr, - const Reference<XText> & rParent, +static Reference<XTextRange> +lcl_ExportHints( + PortionStack_t & rPortionStack, + const Reference<XText> & xParent, + SwUnoCrsr * const pUnoCrsr, + SwpHints * const pHints, + const sal_Int32 i_nStartPos, + const sal_Int32 i_nEndPos, const xub_StrLen nCurrentIndex, - SwTextPortionType & rePortionType, - bool & io_rbRightMoveForbidden, + const bool bRightMoveForbidden, + bool & o_rbCursorMoved, sal_Int32 & o_rNextAttrPosition ) { + // if the attribute has a dummy character, then xRef is set (except META) + // otherwise, the portion for the attribute is inserted into rPortions! Reference<XTextRange> xRef; SwDoc* pDoc = pUnoCrsr->GetDoc(); - bool bAlreadyMoved = false; //search for special text attributes - first some ends sal_uInt16 nEndIndex = 0; sal_uInt16 nNextEnd = 0; @@ -478,35 +631,88 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, { if(pHints->GetEnd(nEndIndex)->GetEnd()) { - SwTxtAttr* pAttr = pHints->GetEnd(nEndIndex); - USHORT nAttrWhich = pAttr->Which(); - if(nNextEnd == nCurrentIndex && - ( RES_TXTATR_TOXMARK == nAttrWhich || - RES_TXTATR_REFMARK == nAttrWhich || - RES_TXTATR_CJK_RUBY == nAttrWhich)) + SwTxtAttr * const pAttr = pHints->GetEnd(nEndIndex); + if (nNextEnd == nCurrentIndex) { - switch( nAttrWhich ) + const USHORT nWhich( pAttr->Which() ); + switch (nWhich) { case RES_TXTATR_TOXMARK: - lcl_InsertTOXMarkPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - rePortionType = PORTION_TEXT; + { + Reference<XTextRange> xTmp = lcl_CreateTOXMarkPortion( + xParent, pUnoCrsr, *pAttr, true); + rPortionStack.top().first->push_back(xTmp); + } break; case RES_TXTATR_REFMARK: - lcl_InsertRefMarkPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - rePortionType = PORTION_TEXT; + { + Reference<XTextRange> xTmp = lcl_CreateRefMarkPortion( + xParent, pUnoCrsr, *pAttr, true); + rPortionStack.top().first->push_back(xTmp); + } break; case RES_TXTATR_CJK_RUBY: //#i91534# GetEnd() == 0 mixes the order of ruby start/end if( *pAttr->GetEnd() == *pAttr->GetStart()) { - lcl_InsertRubyPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, sal_False); + lcl_InsertRubyPortion( *rPortionStack.top().first, + xParent, pUnoCrsr, *pAttr, sal_False); } - lcl_InsertRubyPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - rePortionType = PORTION_TEXT; + lcl_InsertRubyPortion( *rPortionStack.top().first, + xParent, pUnoCrsr, *pAttr, sal_True); + break; + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + { + ASSERT(*pAttr->GetStart() != *pAttr->GetEnd(), + "empty meta?"); + if ((i_nStartPos > 0) && + (*pAttr->GetStart() < i_nStartPos)) + { + // force skip pAttr and rest of attribute ends + // at nCurrentIndex + // because they are not contained in the meta pAttr + // and the meta pAttr itself is outside selection! + // (necessary for SwXMeta::createEnumeration) + if (*pAttr->GetStart() + 1 == i_nStartPos) + { + nEndIndex = pHints->GetEndCount() - 1; + } + break; + } + PortionList_t Top = rPortionStack.top(); + if (Top.second != pAttr) + { + ASSERT(false, "ExportHints: stack error" ); + } + else + { + TextRangeList_t *const 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); + } + } break; } } @@ -520,128 +726,126 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, while(nStartIndex < pHints->GetStartCount() && nCurrentIndex >= (nNextStart = (*pHints->GetStart(nStartIndex)->GetStart()))) { - SwTxtAttr* pAttr = pHints->GetStart(nStartIndex); + const SwTxtAttr * const pAttr = pHints->GetStart(nStartIndex); USHORT nAttrWhich = pAttr->Which(); - if(nNextStart == nCurrentIndex && - (!pAttr->GetEnd() || - RES_TXTATR_TOXMARK == nAttrWhich || - RES_TXTATR_REFMARK == nAttrWhich|| - RES_TXTATR_CJK_RUBY == nAttrWhich)) + if (nNextStart == nCurrentIndex) { switch( nAttrWhich ) { case RES_TXTATR_FIELD: - if(!io_rbRightMoveForbidden) + if(!bRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) break; - bAlreadyMoved = true; - rePortionType = PORTION_FIELD; + SwXTextPortion* pPortion; + xRef = pPortion = new SwXTextPortion( + pUnoCrsr, xParent, PORTION_FIELD); + Reference<XTextField> xField = + CreateSwXTextField(*pDoc, pAttr->GetFld()); + pPortion->SetTextField(xField); } break; case RES_TXTATR_FLYCNT : - if(!io_rbRightMoveForbidden) + if(!bRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) break; // Robust #i81708 content in covered cells pUnoCrsr->Exchange(); - bAlreadyMoved = true; - rePortionType = PORTION_FRAME; + xRef = new SwXTextPortion( + pUnoCrsr, xParent, PORTION_FRAME); } break; case RES_TXTATR_FTN : { - if(!io_rbRightMoveForbidden) + if(!bRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) break; SwXTextPortion* pPortion; - xRef = pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_FOOTNOTE); - Reference<XTextContent> xContent = - Reference<XTextContent>( - SwXFootnotes::GetObject(*pDoc, pAttr->SwTxtAttr::GetFtn()), - UNO_QUERY); + xRef = pPortion = new SwXTextPortion( + pUnoCrsr, xParent, PORTION_FOOTNOTE); + Reference<XFootnote> xContent = + SwXFootnotes::GetObject(*pDoc, pAttr->GetFtn()); pPortion->SetFootnote(xContent); - bAlreadyMoved = true; - rePortionType = PORTION_TEXT; } } break; - case RES_TXTATR_SOFTHYPH : - { - SwXTextPortion* pPortion = 0; - rPortionArr.Insert( - new Reference< XTextRange >( - pPortion = new SwXTextPortion( - pUnoCrsr, rParent, PORTION_CONTROL_CHAR)), - rPortionArr.Count()); - pPortion->SetControlChar(3); - rePortionType = PORTION_TEXT; - } - break; - case RES_TXTATR_HARDBLANK: - { - rePortionType = PORTION_CONTROL_CHAR; - SwXTextPortion* pPortion = 0; - rPortionArr.Insert( - new Reference< XTextRange >( - pPortion = new SwXTextPortion( - pUnoCrsr, rParent, PORTION_CONTROL_CHAR)), - rPortionArr.Count()); - const SwFmtHardBlank& rFmt = pAttr->GetHardBlank(); - if(rFmt.GetChar() == '-') - pPortion->SetControlChar(2);//HARD_HYPHEN - else - pPortion->SetControlChar(4);//HARD_SPACE - rePortionType = PORTION_TEXT; - } - break; case RES_TXTATR_TOXMARK: - lcl_InsertTOXMarkPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - rePortionType = PORTION_TEXT; - break; case RES_TXTATR_REFMARK: - - if(!io_rbRightMoveForbidden || pAttr->GetEnd()) + { + bool bIsPoint = !(pAttr->GetEnd()); + if (!bRightMoveForbidden || !bIsPoint) { - if(!pAttr->GetEnd()) + if (bIsPoint) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); - bAlreadyMoved = true; } - lcl_InsertRefMarkPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - rePortionType = PORTION_TEXT; - if(!pAttr->GetEnd()) + Reference<XTextRange> xTmp = + (RES_TXTATR_REFMARK == nAttrWhich) + ? lcl_CreateRefMarkPortion( + xParent, pUnoCrsr, *pAttr, false) + : lcl_CreateTOXMarkPortion( + xParent, pUnoCrsr, *pAttr, false); + if (bIsPoint) // consume CH_TXTATR! { - if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); + pUnoCrsr->Normalize(FALSE); pUnoCrsr->DeleteMark(); + xRef = xTmp; + } + else // just insert it + { + rPortionStack.top().first->push_back(xTmp); } } + } break; case RES_TXTATR_CJK_RUBY: //#i91534# GetEnd() == 0 mixes the order of ruby start/end if(pAttr->GetEnd() && (*pAttr->GetEnd() != *pAttr->GetStart())) { - lcl_InsertRubyPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - rePortionType = PORTION_TEXT; + lcl_InsertRubyPortion( *rPortionStack.top().first, + xParent, pUnoCrsr, *pAttr, sal_False); } break; + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + if (*pAttr->GetStart() != *pAttr->GetEnd()) + { + if (!bRightMoveForbidden) + { + pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); + o_rbCursorMoved = true; + // only if the end is included in selection! + if ((i_nEndPos < 0) || + (*pAttr->GetEnd() <= i_nEndPos)) + { + rPortionStack.push( ::std::make_pair( + new TextRangeList_t, pAttr )); + } + } + } + break; + case RES_TXTATR_AUTOFMT: + case RES_TXTATR_INETFMT: + case RES_TXTATR_CHARFMT: + case RES_TXTATR_UNKNOWN_CONTAINER: + break; // these are handled as properties of a "Text" portion default: - DBG_ERROR("was fuer ein Attribut?"); + DBG_ERROR("unknown attribute"); + break; } - } nStartIndex++; } - if (!bAlreadyMoved) + if (xRef.is()) // implies that we have moved the cursor + { + o_rbCursorMoved = true; + } + if (!o_rbCursorMoved) { // search for attribute changes behind the current cursor position // break up at frames, bookmarks, redlines @@ -666,17 +870,15 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, o_rNextAttrPosition = nNextPos; } } - else - { - io_rbRightMoveForbidden = true; - } return xRef; } -void lcl_MoveCursor( SwUnoCrsr* pUnoCrsr, +//----------------------------------------------------------------------------- +void lcl_MoveCursor( SwUnoCrsr * const pUnoCrsr, const xub_StrLen nCurrentIndex, const sal_Int32 nNextFrameIndex, const sal_Int32 nNextPortionIndex, - const sal_Int32 nNextAttrIndex, const sal_Int32 nEndPos ) + const sal_Int32 nNextAttrIndex, const sal_Int32 nNextFieldMarkIndex, + const sal_Int32 nEndPos ) { sal_Int32 nMovePos = pUnoCrsr->GetCntntNode()->Len(); @@ -700,26 +902,22 @@ void lcl_MoveCursor( SwUnoCrsr* pUnoCrsr, nMovePos = nNextAttrIndex; } + if ((nNextFieldMarkIndex >= 0) && (nNextFieldMarkIndex < nMovePos)) + { + nMovePos = nNextFieldMarkIndex; + } + if (nMovePos > nCurrentIndex) { // pUnoCrsr->Right(nMovePos - nCurrentIndex); pUnoCrsr->GetPoint()->nContent = static_cast<USHORT>(nMovePos); } - else if(nEndPos < 0 || nCurrentIndex < nEndPos) - { - // ensure proper exit: move to paragraph end - // (this should not be necessary any more; we assert it only - // happens when the above would move to the end of the - // paragraph anyway) - DBG_ASSERT(nMovePos == pUnoCrsr->GetCntntNode()->Len()|| - (nEndPos > 0 && nMovePos == nEndPos), - "may only happen at paragraph end"); - pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); - } } //----------------------------------------------------------------------------- -void lcl_FillRedlineArray(SwDoc& rDoc,SwUnoCrsr& rUnoCrsr, SwXRedlinePortion_ImplList& rRedArr ) +static void +lcl_FillRedlineArray(SwDoc const & rDoc, SwUnoCrsr const & rUnoCrsr, + SwXRedlinePortion_ImplList& rRedArr ) { const SwRedlineTbl& rRedTbl = rDoc.GetRedlineTbl(); USHORT nRedTblCount = rRedTbl.Count(); @@ -736,18 +934,21 @@ void lcl_FillRedlineArray(SwDoc& rDoc,SwUnoCrsr& rUnoCrsr, SwXRedlinePortion_Imp const SwNodeIndex nRedNode = pRedStart->nNode; if ( nOwnNode == nRedNode ) rRedArr.insert( SwXRedlinePortion_ImplSharedPtr ( - new SwXRedlinePortion_Impl ( pRedline, TRUE) ) ); + new SwXRedlinePortion_Impl ( pRedline, true ) ) ); if( pRedline->HasMark() && pRedline->End()->nNode == nOwnNode ) rRedArr.insert( SwXRedlinePortion_ImplSharedPtr ( - new SwXRedlinePortion_Impl ( pRedline, FALSE) ) ); + new SwXRedlinePortion_Impl ( pRedline, false) ) ); } } } //----------------------------------------------------------------------------- -void lcl_FillSoftPageBreakArray( SwUnoCrsr& rUnoCrsr, SwSoftPageBreakList& rBreakArr ) +static void +lcl_FillSoftPageBreakArray( + SwUnoCrsr const & rUnoCrsr, SwSoftPageBreakList& rBreakArr ) { - const SwTxtNode *pTxtNode = rUnoCrsr.GetPoint()->nNode.GetNode().GetTxtNode(); + const SwTxtNode *pTxtNode = + rUnoCrsr.GetPoint()->nNode.GetNode().GetTxtNode(); if( pTxtNode ) pTxtNode->fillSoftPageBreakList( rBreakArr ); } @@ -755,9 +956,12 @@ void lcl_FillSoftPageBreakArray( SwUnoCrsr& rUnoCrsr, SwSoftPageBreakList& rBrea /* -----------------------------19.12.00 12:25-------------------------------- ---------------------------------------------------------------------------*/ -void lcl_ExportRedline( - SwXRedlinePortion_ImplList& rRedlineArr, ULONG nIndex, - SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr) +static void +lcl_ExportRedline( + TextRangeList_t & rPortions, + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + SwXRedlinePortion_ImplList& rRedlineArr, const ULONG nIndex) { // MTG: 23/11/05: We want this loop to iterate over all red lines in this @@ -773,10 +977,8 @@ void lcl_ExportRedline( // MTG: 23/11/05: If the elements match, and them to the list else if ( nIndex == nRealIndex ) { - rPortionArr.Insert( - new Reference< XTextRange >( new SwXRedlinePortion( - pPtr->pRedline, pUnoCrsr, rParent, pPtr->bStart)), - rPortionArr.Count()); + rPortions.push_back( new SwXRedlinePortion( + pPtr->m_pRedline, pUnoCrsr, xParent, pPtr->m_bStart) ); rRedlineArr.erase ( aIter++ ); } // MTG: 23/11/05: If we've iterated past nIndex, exit the loop @@ -784,29 +986,63 @@ void lcl_ExportRedline( break; } } + /* -----------------------------19.12.00 13:09-------------------------------- ---------------------------------------------------------------------------*/ -void lcl_ExportBkmAndRedline( +static void +lcl_ExportBkmAndRedline( + TextRangeList_t & rPortions, + Reference<XText> const & xParent, + const SwUnoCrsr * const pUnoCrsr, SwXBookmarkPortion_ImplList& rBkmArr, SwXRedlinePortion_ImplList& rRedlineArr, SwSoftPageBreakList& rBreakArr, - ULONG nIndex, - SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr) + const ULONG nIndex) { if (rBkmArr.size()) - lcl_ExportBookmark(rBkmArr, nIndex, pUnoCrsr, rParent, rPortionArr); + lcl_ExportBookmark(rPortions, xParent, pUnoCrsr, rBkmArr, nIndex); if (rRedlineArr.size()) - lcl_ExportRedline(rRedlineArr, nIndex, pUnoCrsr, rParent, rPortionArr); + lcl_ExportRedline(rPortions, xParent, pUnoCrsr, rRedlineArr, nIndex); if (rBreakArr.size()) - lcl_ExportSoftPageBreak(rBreakArr, nIndex, pUnoCrsr, rParent, rPortionArr); + lcl_ExportSoftPageBreak(rPortions, xParent, pUnoCrsr, rBreakArr, nIndex); } + //----------------------------------------------------------------------------- -sal_Int32 lcl_GetNextIndex(SwXBookmarkPortion_ImplList& rBkmArr, - SwXRedlinePortion_ImplList& rRedlineArr, - SwSoftPageBreakList& rBreakArr ) +static sal_Int32 +lcl_ExportFrames( + TextRangeList_t & rPortions, + Reference<XText> const & i_xParent, + SwUnoCrsr * const i_pUnoCrsr, + FrameDependSortList_t & i_rFrames, + xub_StrLen const i_nCurrentIndex) +{ + // find first Frame in (sorted) i_rFrames at current position + while (i_rFrames.size() && (i_rFrames.front().nIndex == i_nCurrentIndex)) + // do not check for i_nEnd here; this is done implicity by lcl_MoveCursor + { + const SwModify * const pFrame = + i_rFrames.front().pFrameDepend->GetRegisteredIn(); + if (pFrame) // Frame could be disposed + { + SwXTextPortion* pPortion = new SwXTextPortion(i_pUnoCrsr, i_xParent, + *static_cast<SwFrmFmt*>( const_cast<SwModify*>( pFrame ) ) ); + rPortions.push_back(pPortion); + } + i_rFrames.pop_front(); + } + + return i_rFrames.size() ? i_rFrames.front().nIndex : -1; +} + +//----------------------------------------------------------------------------- +static sal_Int32 +lcl_GetNextIndex( + SwXBookmarkPortion_ImplList const & rBkmArr, + SwXRedlinePortion_ImplList const & rRedlineArr, + SwSoftPageBreakList const & rBreakArr ) { sal_Int32 nRet = -1; if(rBkmArr.size()) @@ -828,284 +1064,146 @@ sal_Int32 lcl_GetNextIndex(SwXBookmarkPortion_ImplList& rBkmArr, } return nRet; }; + //----------------------------------------------------------------------------- -void SwXTextPortionEnumeration::CreatePortions() +static void +lcl_CreatePortions( + TextRangeList_t & i_rPortions, + uno::Reference< text::XText > const & i_xParentText, + SwUnoCrsr * const pUnoCrsr, + FrameDependSortList_t & i_rFrames, + const sal_Int32 i_nStartPos, + const sal_Int32 i_nEndPos ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); + if (!pUnoCrsr) + return; + // set the start if a selection should be exported - if(nStartPos > 0 && pUnoCrsr->Start()->nContent.GetIndex() != nStartPos) + if ((i_nStartPos > 0) && + (pUnoCrsr->Start()->nContent.GetIndex() != i_nStartPos)) { - if(pUnoCrsr->HasMark()) - pUnoCrsr->DeleteMark(); + pUnoCrsr->DeleteMark(); DBG_ASSERT(pUnoCrsr->Start()->nNode.GetNode().GetTxtNode() && - nStartPos <= pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()->GetTxt().Len(), - "Incorrect start position" ); - // ??? should this be nStartPos - current position ? - pUnoCrsr->Right((xub_StrLen)nStartPos,CRSR_SKIP_CHARS,FALSE,FALSE); + (i_nStartPos <= pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()-> + GetTxt().Len()), "Incorrect start position" ); + // ??? should this be i_nStartPos - current position ? + pUnoCrsr->Right(static_cast<xub_StrLen>(i_nStartPos), + CRSR_SKIP_CHARS, FALSE, FALSE); } - if(pUnoCrsr /*&& !bAtEnd*/) + + FieldMarks_t FieldMarks; + SwXBookmarkPortion_ImplList Bookmarks; + SwXRedlinePortion_ImplList Redlines; + SwSoftPageBreakList SoftPageBreaks; + + SwDoc * const pDoc = pUnoCrsr->GetDoc(); + lcl_FillFieldMarkArray(FieldMarks, *pUnoCrsr, i_nStartPos); + lcl_FillBookmarkArray(*pDoc, *pUnoCrsr, Bookmarks); + lcl_FillRedlineArray(*pDoc, *pUnoCrsr, Redlines); + lcl_FillSoftPageBreakArray(*pUnoCrsr, SoftPageBreaks); + + PortionStack_t PortionStack; + PortionStack.push( PortionList_t(&i_rPortions, 0) ); + + bool bAtEnd( false ); + while (!bAtEnd) // every iteration consumes at least current character! { - SwXBookmarkPortion_ImplList aBkmArr; - SwXRedlinePortion_ImplList aRedArr; - SwSoftPageBreakList aBreakArr; - - SwDoc* pDoc = pUnoCrsr->GetDoc(); - lcl_FillRedlineArray(*pDoc, *pUnoCrsr, aRedArr); - lcl_FillBookmarkArray(*pDoc, *pUnoCrsr, aBkmArr ); - lcl_FillSoftPageBreakArray( *pUnoCrsr, aBreakArr ); -#if OSL_DEBUG_LEVEL > 1 - for (SwXBookmarkPortion_ImplList::const_iterator aIter = aBkmArr.begin(), aEnd = aBkmArr.end(); - aIter != aEnd; - ++aIter ) + if (pUnoCrsr->HasMark()) { - SwXBookmarkPortion_ImplSharedPtr pPtr = (*aIter); + pUnoCrsr->Normalize(FALSE); + pUnoCrsr->DeleteMark(); } -#endif - while(!bAtEnd) + SwTxtNode * const pTxtNode = pUnoCrsr->GetNode()->GetTxtNode(); + if (!pTxtNode) { - if(pUnoCrsr->HasMark()) + DBG_ERROR("lcl_CreatePortions: no TextNode - what now ?"); + return; + } + + SwpHints * const pHints = pTxtNode->GetpSwpHints(); + const xub_StrLen nCurrentIndex = + pUnoCrsr->GetPoint()->nContent.GetIndex(); + // this contains the portion which consumes the character in the + // text at nCurrentIndex; i.e. it must be set _once_ per iteration + uno::Reference< XTextRange > xRef; + + SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); // set mark + + const sal_Int32 nFirstFrameIndex = + lcl_ExportFrames( *PortionStack.top().first, + i_xParentText, pUnoCrsr, i_rFrames, nCurrentIndex); + + lcl_ExportBkmAndRedline( *PortionStack.top().first, i_xParentText, + pUnoCrsr, Bookmarks, Redlines, SoftPageBreaks, nCurrentIndex ); + + bool bCursorMoved( false ); + sal_Int32 nNextAttrIndex = -1; + // #111716# the cursor must not move right at the + // end position of a selection! + bAtEnd = ((i_nEndPos >= 0) && (nCurrentIndex >= i_nEndPos)) + || (nCurrentIndex >= pTxtNode->Len()); + if (pHints) + { + // N.B.: side-effects nNextAttrIndex, bCursorMoved; may move cursor + xRef = lcl_ExportHints(PortionStack, i_xParentText, pUnoCrsr, + pHints, i_nStartPos, i_nEndPos, nCurrentIndex, bAtEnd, + bCursorMoved, nNextAttrIndex); + if (PortionStack.empty()) { - if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); - pUnoCrsr->DeleteMark(); + ASSERT(false, "CreatePortions: stack underflow"); + return; } - SwNode* pNode = pUnoCrsr->GetNode(); - SwCntntNode *pCNd = pNode->GetCntntNode(); - if(!bFirstPortion && pCNd && - pUnoCrsr->GetPoint()->nContent == pCNd->Len()) + } + + if (!xRef.is() && !bCursorMoved) + { + if (!bAtEnd && + FieldMarks.size() && (FieldMarks.front() == nCurrentIndex)) { - //hier sollte man nie ankommen! - bAtEnd = sal_True; + // moves cursor + xRef = lcl_ExportFieldMark(i_xParentText, pUnoCrsr, pTxtNode); + FieldMarks.pop_front(); } - else - { - if(ND_TEXTNODE == pNode->GetNodeType()) - { - SwTxtNode* pTxtNode = (SwTxtNode*)pNode; - SwpHints* pHints = pTxtNode->GetpSwpHints(); - SwTextPortionType ePortionType = PORTION_TEXT; - xub_StrLen nCurrentIndex = pUnoCrsr->GetPoint()->nContent.GetIndex(); - xub_StrLen nFirstFrameIndex = STRING_MAXLEN; - uno::Reference< XTextRange > xRef; - if(!pCNd->Len()) - { - lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr, 0, pUnoCrsr, xParent, aPortionArr); - // the paragraph is empty - xRef = new SwXTextPortion(pUnoCrsr, xParent, ePortionType); - // are there any frames? - while(aFrameArr.Count()) - { - SwDepend* pCurDepend = aFrameArr.GetObject(0); - if(pCurDepend->GetRegisteredIn()) - { - //the previously created portion has to be inserted here - aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count()); - xRef = new SwXTextPortion(pUnoCrsr, xParent, - *(SwFrmFmt*)pCurDepend->GetRegisteredIn()); - } - delete pCurDepend; - aFrameArr.Remove(0); - } - } - else - { - //falls schon Rahmen entsorgt wurden, dann raus hier - for(sal_uInt16 nFrame = aFrameArr.Count(); nFrame; nFrame--) - { - SwDepend* pCurDepend = aFrameArr.GetObject(nFrame - 1); - if(!pCurDepend->GetRegisteredIn()) - { - delete pCurDepend; - aFrameArr.Remove(nFrame - 1); - } - } + } + else + { + ASSERT(!FieldMarks.size() || + (FieldMarks.front() != nCurrentIndex), + "fieldmark and hint with CH_TXTATR at same pos?"); + } - //zunaechst den ersten Frame im aFrameArr finden (bezogen auf die Position im Absatz) - SwDepend* pFirstFrameDepend = 0; - //Eintraege im aFrameArr sind sortiert! - if(aFrameArr.Count()) - { - SwDepend* pCurDepend = aFrameArr.GetObject(0); - SwFrmFmt* pFormat = (SwFrmFmt*)pCurDepend->GetRegisteredIn(); - const SwFmtAnchor& rAnchor = pFormat->GetAnchor(); - const SwPosition* pAnchorPos = rAnchor.GetCntntAnchor(); - pFirstFrameDepend = pCurDepend; - nFirstFrameIndex = pAnchorPos->nContent.GetIndex(); - if(nEndPos >= 0 && nFirstFrameIndex >= nEndPos) - nFirstFrameIndex = USHRT_MAX; - } + if (!bAtEnd && !xRef.is() && !bCursorMoved) + { + const sal_Int32 nNextPortionIndex = + lcl_GetNextIndex(Bookmarks, Redlines, SoftPageBreaks); + const sal_Int32 nNextFieldMarkIndex( + FieldMarks.size() ? FieldMarks.front() : -1); - SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); + lcl_MoveCursor(pUnoCrsr, nCurrentIndex, + nFirstFrameIndex, nNextPortionIndex, nNextAttrIndex, + nNextFieldMarkIndex, + i_nEndPos); - //ist hier schon ein Rahmen faellig? - if(nCurrentIndex == nFirstFrameIndex) - { - xRef = new SwXTextPortion(pUnoCrsr, xParent, - *(SwFrmFmt*)pFirstFrameDepend->GetRegisteredIn()); - SwDepend* pCurDepend = aFrameArr.GetObject(0); - delete pCurDepend; - aFrameArr.Remove(0); - } - } - if(!xRef.is()) - { - lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr, - nCurrentIndex, pUnoCrsr, xParent, aPortionArr); - sal_Int32 nNextAttrIndex = -1; - sal_Int32 nNextPortionIndex = - lcl_GetNextIndex(aBkmArr, aRedArr, aBreakArr); - // #111716# the cursor must not move right at the - // end position of a selection! - bool bRightMoveForbidden = - ((nEndPos > 0) && (nCurrentIndex >= nEndPos)); - if (pHints) - { - // N.B.: side-effects bRightMoveForbidden - // and nNextAttrIndex - xRef = lcl_ExportHints(pHints, aPortionArr, - pUnoCrsr, xParent, nCurrentIndex, ePortionType, - bRightMoveForbidden, nNextAttrIndex); - } - if (!bRightMoveForbidden) - { - lcl_MoveCursor(pUnoCrsr, nCurrentIndex, - nFirstFrameIndex, nNextPortionIndex, - nNextAttrIndex, nEndPos); - } - } - if(!xRef.is() && pUnoCrsr->HasMark() ) { - //flr: maybe its a good idea to add a special hint to the hints array and rely on the hint segmentation.... - xub_StrLen start=pUnoCrsr->Start()->nContent.GetIndex(); - xub_StrLen end=pUnoCrsr->End()->nContent.GetIndex(); - ASSERT(start<=end, "hmm --- why is this different"); - xub_StrLen startMarkerPos=pTxtNode->GetTxt().Search(CH_TXT_ATR_FIELDSTART, start); - xub_StrLen endMarkerPos=pTxtNode->GetTxt().Search(CH_TXT_ATR_FIELDEND, start); - xub_StrLen formMarkerPos=pTxtNode->GetTxt().Search(CH_TXT_ATR_FORMELEMENT, start); - xub_StrLen markerPos=STRING_LEN; - if (startMarkerPos>=start && startMarkerPos<end) - { - markerPos=startMarkerPos; - } - if (endMarkerPos>=start && endMarkerPos<end) - { - if (endMarkerPos<markerPos) - markerPos=endMarkerPos; - } - if (formMarkerPos>=start && formMarkerPos<end) - { - if (formMarkerPos<markerPos) - markerPos=formMarkerPos; - } - if (markerPos<end) - { - if (start==markerPos) - end = markerPos+1; - else - end = markerPos; - bAtEnd = sal_False; - pUnoCrsr->GetPoint()->nContent = end; - } - if (start+1==end && pTxtNode->GetTxt().GetChar(start)==CH_TXT_ATR_FIELDSTART) - { - ::sw::mark::IFieldmark* pFieldmark = NULL; - if (pDoc && pUnoCrsr->GetPoint()) - pFieldmark = pDoc->getIDocumentMarkAccess()->getFieldmarkFor(*pUnoCrsr->GetPoint()); - SwXTextPortion* pPortion = NULL; - xRef = (pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD_START)); - if (pPortion && pFieldmark && pDoc) - pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc)); - } - else if (start+1==end && pTxtNode->GetTxt().GetChar(start)==CH_TXT_ATR_FIELDEND) - { - ::sw::mark::IFieldmark* pFieldmark = NULL; - if (pDoc && pUnoCrsr->GetPoint()) - { - SwPosition aPos(*pUnoCrsr->GetPoint()); - aPos.nContent = markerPos; - pFieldmark = pDoc->getIDocumentMarkAccess()->getFieldmarkFor(aPos); - } - SwXTextPortion* pPortion = NULL; - xRef = (pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD_END)); - if (pPortion && pFieldmark && pDoc) - pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc)); - } - else if (start+1==end && pTxtNode->GetTxt().GetChar(start)==CH_TXT_ATR_FORMELEMENT) - { - ::sw::mark::IFieldmark* pFieldmark = NULL; - if (pDoc && pUnoCrsr->GetPoint()) - { - SwPosition aPos(*pUnoCrsr->GetPoint()); - aPos.nContent=markerPos; - pFieldmark = pDoc->getIDocumentMarkAccess()->getFieldmarkFor(aPos); - } - SwXTextPortion* pPortion=NULL; - xRef = (pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD_START_END)); - if(pPortion && pFieldmark && pDoc) - pPortion->SetBookmark(new SwXFieldmark(true, pFieldmark, pDoc)); - } - else - { - xRef = new SwXTextPortion(pUnoCrsr, xParent, ePortionType); - } - } - if(xRef.is()) - aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count()); - } - else - { - DBG_ERROR("kein TextNode - was nun?"); - } - } - if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); - - // Absatzende ? - pNode = pUnoCrsr->GetNode(); - pCNd = pNode->GetCntntNode(); - sal_Int32 nLocalEnd = nEndPos >= 0 ? nEndPos : pCNd->Len(); - if( pCNd && pUnoCrsr->GetPoint()->nContent >= (xub_StrLen)nLocalEnd) - { - bAtEnd = sal_True; - lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr, nLocalEnd, - pUnoCrsr, xParent, aPortionArr); - if(ND_TEXTNODE == pNode->GetNodeType()) - { - SwTxtNode* pTxtNode = (SwTxtNode*)pNode; - SwpHints* pHints = pTxtNode->GetpSwpHints(); - if(pHints) - { - SwTextPortionType ePortionType = PORTION_TEXT; - bool bDummy = false; - sal_Int32 nDummy = -1; - Reference<XTextRange> xRef = lcl_ExportHints(pHints, - aPortionArr, - pUnoCrsr, - xParent, - static_cast< xub_StrLen >(nLocalEnd), - ePortionType, - bDummy, nDummy); - if(xRef.is()) - aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count()); - } - } - while(aFrameArr.Count()) - { - SwDepend* pCurDepend = aFrameArr.GetObject(0); - if(pCurDepend->GetRegisteredIn()) - { - Reference<XTextRange> xRef = new SwXTextPortion(pUnoCrsr, xParent, - *(SwFrmFmt*)pCurDepend->GetRegisteredIn()); - aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count()); - } - delete pCurDepend; - aFrameArr.Remove(0); - } + xRef = new SwXTextPortion(pUnoCrsr, i_xParentText, PORTION_TEXT); + } + else if (bAtEnd && !xRef.is() && !pTxtNode->Len()) + { + // special case: for an empty paragraph, we better put out a + // text portion because there may be a hyperlink attribute + xRef = new SwXTextPortion(pUnoCrsr, i_xParentText, PORTION_TEXT); + } - } + if (xRef.is()) + { + PortionStack.top().first->push_back(xRef); } } + + ASSERT((PortionStack.size() == 1) && !PortionStack.top().second, + "CreatePortions: stack error" ); } + /*-- 27.01.99 10:44:45--------------------------------------------------- -----------------------------------------------------------------------*/ diff --git a/sw/source/core/unocore/unoprnms.cxx b/sw/source/core/unocore/unoprnms.cxx index 7b58a4120de7..edd0721d5b63 100644 --- a/sw/source/core/unocore/unoprnms.cxx +++ b/sw/source/core/unocore/unoprnms.cxx @@ -779,7 +779,8 @@ const SwPropNameTab aPropNameTab = { /* 0734 CHAR_OVERLINE_COLOR */ {MAP_CHAR_LEN("CharOverlineColor")}, /* 0735 CHAR_OVERLINE_HAS_COLOR */ {MAP_CHAR_LEN("CharOverlineHasColor")}, /* 0736 UNO_NAME_OUTLINE_LEVEL */ {MAP_CHAR_LEN("OutlineLevel")},//#outline level,add<-zhaojianwei Outlinelevel -/* 0737 UNO_NAME_DESCRIPTION */ {MAP_CHAR_LEN("Description")} +/* 0737 UNO_NAME_DESCRIPTION */ {MAP_CHAR_LEN("Description")}, +/* 0738 UNO_NAME_META */ {MAP_CHAR_LEN("InContentMetadata")}, }; const SwPropNameLen& SwGetPropName( USHORT nId ) diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index b04b8f0fdeaf..b04a7fea1fae 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -295,7 +295,7 @@ uno::Any SwXRedlinePortion::getPropertyValue( const OUString& rPropertyName ) { if ( 1 < ( pNodeIdx->GetNode().EndOfSectionIndex() - pNodeIdx->GetNode().GetIndex() ) ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); uno::Reference<text::XText> xRet = new SwXRedlineText(pUnoCrsr->GetDoc(), *pNodeIdx); aRet <<= xRet; } @@ -318,7 +318,7 @@ uno::Any SwXRedlinePortion::getPropertyValue( const OUString& rPropertyName ) ---------------------------------------------------------------------------*/ void SwXRedlinePortion::Validate() throw( uno::RuntimeException ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); //search for the redline diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index f0cbd754e02a..6fc3873db49c 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -124,7 +124,7 @@ SwXReferenceMark::~SwXReferenceMark() /* -----------------03.11.99 14:14------------------- --------------------------------------------------*/ -void SwXReferenceMark::InsertRefMark( SwPaM& rPam ) +void SwXReferenceMark::InsertRefMark(SwPaM& rPam, SwXTextCursor * 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 @@ -134,10 +134,19 @@ void SwXReferenceMark::InsertRefMark( SwPaM& rPam ) UnoActionContext aCont(pDoc2); SwTxtAttr* pTxtAttr = 0; SwFmtRefMark aRefMark(sMarkName); - SfxItemSet aSet(pDoc2->GetAttrPool(), RES_TXTATR_REFMARK, RES_TXTATR_REFMARK, 0L); - aSet.Put(aRefMark); +// SfxItemSet aSet(pDoc2->GetAttrPool(), RES_TXTATR_REFMARK, RES_TXTATR_REFMARK, 0L); +// aSet.Put(aRefMark); sal_Bool bMark = *rPam.GetPoint() != *rPam.GetMark(); - SwXTextCursor::SetCrsrAttr(rPam, aSet, 0); +// SwXTextCursor::SetCrsrAttr(rPam, aSet, 0); + + const bool bForceExpandHints( (!bMark && pCursor) + ? pCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND + | nsSetAttrMode::SETATTR_DONTEXPAND) + : nsSetAttrMode::SETATTR_DONTEXPAND; + + pDoc2->InsertPoolItem( rPam, aRefMark, nInsertFlags ); if( bMark && *rPam.GetPoint() > *rPam.GetMark()) rPam.Exchange(); @@ -146,8 +155,10 @@ void SwXReferenceMark::InsertRefMark( SwPaM& rPam ) pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttr( rPam.GetPoint()->nContent, RES_TXTATR_REFMARK ); else - pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttr( + { + pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( rPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_REFMARK ); + } if(pTxtAttr) pMark = &pTxtAttr->GetRefMark(); @@ -179,7 +190,7 @@ void SwXReferenceMark::attachToRange(const uno::Reference< text::XTextRange > & SwUnoInternalPaM aPam(*pDocument); //das muss jetzt sal_True liefern SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); - InsertRefMark(aPam); + InsertRefMark(aPam, dynamic_cast<SwXTextCursor*>(pCursor)); m_bIsDescriptor = sal_False; pDoc = pDocument; pDoc->GetUnoCallBack()->Add(this); @@ -318,7 +329,7 @@ void SwXReferenceMark::setName(const OUString& Name_) throw( uno::RuntimeExcepti sMarkName = sNewName; //create a new one - InsertRefMark( aPam ); + InsertRefMark( aPam, 0 ); pDoc = aPam.GetDoc(); } } @@ -424,3 +435,1056 @@ void SwXReferenceMark::removeVetoableChangeListener( { } +#include <com/sun/star/lang/DisposedException.hpp> +#include <unometa.hxx> +#include <unoport.hxx> +#include <txtatr.hxx> +#include <fmtmeta.hxx> +#include <docsh.hxx> + +//============================================================================= + +/****************************************************************** + * SwXMetaText + ******************************************************************/ + +class SwXMetaText + : public SwXText +{ +private: + SwXMeta & m_rMeta; + + virtual void PrepareForAttach(uno::Reference< text::XTextRange > & xRange, + const SwXTextRange* const pRange, const SwPaM * const pPam); + + virtual 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 const SwStartNode *GetStartNode() const; + virtual uno::Reference< text::XTextCursor > + createCursor() throw (uno::RuntimeException); + +public: + SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta); + + // XInterface + virtual void SAL_CALL acquire() throw() + { OSL_ENSURE(false, "ERROR: SwXMetaText::acquire"); } + virtual void SAL_CALL release() throw() + { OSL_ENSURE(false, "ERROR: SwXMetaText::release"); } + + // XTypeProvider + virtual uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() throw (uno::RuntimeException); + + // XText + virtual uno::Reference< text::XTextCursor > SAL_CALL + createTextCursor() throw (uno::RuntimeException); + virtual uno::Reference< text::XTextCursor > SAL_CALL + createTextCursorByRange( + const uno::Reference< text::XTextRange > & xTextPosition) + throw (uno::RuntimeException); + +}; + +SwXMetaText::SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta) + : SwXText(&rDoc, CURSOR_META) + , m_rMeta(rMeta) +{ +} + +const SwStartNode *SwXMetaText::GetStartNode() const +{ + SwXText const * const pParent( + dynamic_cast<SwXText*>(m_rMeta.GetParentText().get())); + return (pParent) ? pParent->GetStartNode() : 0; +} + +void SwXMetaText::PrepareForAttach( uno::Reference<text::XTextRange> & xRange, + const SwXTextRange* const pRange, const SwPaM * const pPam) +{ + 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)); + } +} + +bool SwXMetaText::CheckForOwnMemberMeta(const SwXTextRange* const pRange, + const SwPaM* const pPam, bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) +{ + return m_rMeta.CheckForOwnMemberMeta(pRange, pPam, bAbsorb); +} + +uno::Reference< text::XTextCursor > SwXMetaText::createCursor() +throw (uno::RuntimeException) +{ + uno::Reference< text::XTextCursor > xRet; + if (IsValid()) + { + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess( + m_rMeta.SetContentRange(pTxtNode, nMetaStart, nMetaEnd) ); + if (bSuccess) + { + SwPosition aPos(*pTxtNode, nMetaStart); + xRet = static_cast<text::XWordCursor*>( + new SwXTextCursor(&m_rMeta, aPos, CURSOR_META, GetDoc())); + } + } + return xRet; +} + +uno::Sequence<sal_Int8> SAL_CALL +SwXMetaText::getImplementationId() throw (uno::RuntimeException) +{ + return m_rMeta.getImplementationId(); +} + +// XText +uno::Reference< text::XTextCursor > SAL_CALL +SwXMetaText::createTextCursor() throw (uno::RuntimeException) +{ + return createCursor(); +} + +uno::Reference< text::XTextCursor > SAL_CALL +SwXMetaText::createTextCursorByRange( + const uno::Reference<text::XTextRange> & xTextPosition) + throw (uno::RuntimeException) +{ + const uno::Reference<text::XTextCursor> xCursor( createCursor() ); + xCursor->gotoRange(xTextPosition, sal_False); + return xCursor; +} + +/****************************************************************** + * SwXMeta + ******************************************************************/ + +// the Meta has a cached list of text portions for its contents +// this list is created by SwXTextPortionEnumeration +// the Meta listens at the SwTxtNode and throws away the cache when it changes + +struct SwXMeta::Impl +{ + SwEventListenerContainer m_ListenerContainer; + ::std::auto_ptr<const TextRangeList_t> m_pTextPortions; + // 3 possible states: not attached, attached, disposed + bool m_bIsDisposed; + bool m_bIsDescriptor; + uno::Reference<text::XText> m_xParentText; + SwXMetaText m_Text; + + Impl(SwXMeta & rThis, SwDoc & rDoc, + uno::Reference<text::XText> const& xParentText, + TextRangeList_t const * const pPortions, + SwTxtMeta const * const pHint) + : m_ListenerContainer( + static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_pTextPortions( pPortions ) + , m_bIsDisposed( false ) + , m_bIsDescriptor( 0 == pHint ) + , m_xParentText(xParentText) + , m_Text(rDoc, rThis) + { + } +}; + +TYPEINIT1(SwXMeta, SwClient); + +inline const ::sw::Meta * SwXMeta::GetMeta() const +{ + return static_cast< const ::sw::Meta * >(GetRegisteredIn()); +} + +uno::Reference<text::XText> SwXMeta::GetParentText() const +{ + return m_pImpl->m_xParentText; +} + +bool SwXMeta::SetContentRange( + SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd ) const +{ + ::sw::Meta const * const pMeta( GetMeta() ); + if (pMeta) + { + SwTxtMeta const * const pTxtAttr( pMeta->GetTxtAttr() ); + if (pTxtAttr) + { + rpNode = pTxtAttr->GetTxtNode(); + if (rpNode) + { + // rStart points at the first position _within_ the meta! + rStart = *pTxtAttr->GetStart() + 1; + rEnd = *pTxtAttr->GetEnd(); + return true; + } + } + } + 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) + throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + ASSERT((pPam && !pRange) || (!pPam && pRange), "ERROR: pam xor range"); + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess( SetContentRange(pTxtNode, nMetaStart, nMetaEnd) ); + ASSERT(bSuccess, "no pam?"); + if (!bSuccess) + throw lang::DisposedException(); + SwPosition const * const pStartPos( (pPam) + ? pPam->Start() + : &pRange->GetBookmark()->GetMarkStart() ); + if (&pStartPos->nNode.GetNode() != pTxtNode) + { + throw lang::IllegalArgumentException( + C2U("trying to insert into a nesting text content, but start " + "of text range not in same paragraph as text content"), + 0, 0); + } + bool bForceExpandHints(false); + const xub_StrLen nStartPos(pStartPos->nContent.GetIndex()); + // not <= but < because nMetaStart is behind dummy char! + // not >= but > because == means insert at end! + if ((nStartPos < nMetaStart) || (nStartPos > nMetaEnd)) + { + throw lang::IllegalArgumentException( + C2U("trying to insert into a nesting text content, but start " + "of text range not inside text content"), + 0, 0); + } + else if (nStartPos == nMetaEnd) + { + bForceExpandHints = true; + } + const bool bHasEnd( (pPam) + ? pPam->HasMark() + : pRange->GetBookmark()->IsExpanded()); + if (bHasEnd && bAbsorb) + { + SwPosition const * const pEndPos( (pPam) + ? pPam->End() + : &pRange->GetBookmark()->GetMarkEnd() ); + if (&pEndPos->nNode.GetNode() != pTxtNode) + { + throw lang::IllegalArgumentException( + C2U("trying to insert into a nesting text content, but end " + "of text range not in same paragraph as text content"), + 0, 0); + } + const xub_StrLen nEndPos(pEndPos->nContent.GetIndex()); + // not <= but < because nMetaStart is behind dummy char! + // not >= but > because == means insert at end! + if ((nEndPos < nMetaStart) || (nEndPos > nMetaEnd)) + { + throw lang::IllegalArgumentException( + C2U("trying to insert into a nesting text content, but end " + "of text range not inside text content"), + 0, 0); + } + else if (nEndPos == nMetaEnd) + { + bForceExpandHints = true; + } + } + 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() ); + return aSeq; +} + +// XUnoTunnel +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; +} + +// XServiceInfo +::rtl::OUString SAL_CALL +SwXMeta::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXMeta"); +} + +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"); +} + +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; +} + + +// XComponent +void SAL_CALL +SwXMeta::addEventListener( + uno::Reference< lang::XEventListener> const & xListener ) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + m_pImpl->m_ListenerContainer.AddListener(xListener); + if (m_pImpl->m_bIsDisposed) + { + m_pImpl->m_ListenerContainer.Disposing(); + } +} + +void SAL_CALL +SwXMeta::removeEventListener( + uno::Reference< lang::XEventListener> const & xListener ) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->m_bIsDisposed) + { + m_pImpl->m_ListenerContainer.RemoveListener(xListener); + } +} + +void SAL_CALL +SwXMeta::dispose() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_pTextPortions.reset(); + m_pImpl->m_ListenerContainer.Disposing(); + m_pImpl->m_bIsDisposed = true; + m_pImpl->m_Text.Invalidate(); + } + else if (!m_pImpl->m_bIsDisposed) + { + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess(SetContentRange(pTxtNode, nMetaStart, nMetaEnd)); + ASSERT(bSuccess, "no pam?"); + if (bSuccess) + { + // -1 because of CH_TXTATR + SwPaM aPam( *pTxtNode, nMetaStart - 1, *pTxtNode, nMetaEnd ); + SwDoc * const pDoc( pTxtNode->GetDoc() ); + pDoc->DeleteAndJoin( aPam ); + + // removal should call Modify and do the dispose + OSL_ENSURE(m_pImpl->m_bIsDisposed, "zombie meta"); + } + } +} + + +void SAL_CALL +SwXMeta::AttachImpl(const uno::Reference< text::XTextRange > & i_xTextRange, + const USHORT i_nWhich) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (m_pImpl->m_bIsDisposed) + { + throw lang::DisposedException(); + } + if (!m_pImpl->m_bIsDescriptor) + { + throw uno::RuntimeException( + C2S("SwXMeta::attach(): already attached"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + uno::Reference<lang::XUnoTunnel> xRangeTunnel(i_xTextRange, uno::UNO_QUERY); + if (!xRangeTunnel.is()) + { + throw lang::IllegalArgumentException( + 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() ))) ); + if (!pRange && !pCursor) + { + throw lang::IllegalArgumentException( + C2S("SwXMeta::attach(): argument not supported type"), + static_cast< ::cppu::OWeakObject* >(this), 0); + } + + SwDoc * const pDoc( + pRange ? pRange->GetDoc() : pCursor ? pCursor->GetDoc() : 0 ); + if (!pDoc) + { + throw lang::IllegalArgumentException( + C2S("SwXMeta::attach(): argument has no SwDoc"), + static_cast< ::cppu::OWeakObject* >(this), 0); + } + + SwUnoInternalPaM aPam(*pDoc); + SwXTextRange::XTextRangeToSwPaM(aPam, i_xTextRange); + + UnoActionContext aContext(pDoc); + + SwXTextCursor const*const pTextCursor( + dynamic_cast<SwXTextCursor*>(pCursor)); + const bool bForceExpandHints((pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false); + const SetAttrMode nInsertFlags( (bForceExpandHints) + ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND + | nsSetAttrMode::SETATTR_DONTEXPAND) + : nsSetAttrMode::SETATTR_DONTEXPAND ); + + const ::boost::shared_ptr< ::sw::Meta> pMeta( (RES_TXTATR_META == i_nWhich) + ? ::boost::shared_ptr< ::sw::Meta>( new ::sw::Meta() ) + : ::boost::shared_ptr< ::sw::Meta>( + pDoc->GetMetaFieldManager().makeMetaField()) ); + SwFmtMeta meta(pMeta, i_nWhich); // this is cloned by Insert! + const bool bSuccess( pDoc->InsertPoolItem( aPam, meta, nInsertFlags ) ); + SwTxtAttr * const pTxtAttr( pMeta->GetTxtAttr() ); + if (!bSuccess) + { + throw lang::IllegalArgumentException( + C2S("SwXMeta::attach(): cannot create meta: range invalid?"), + static_cast< ::cppu::OWeakObject* >(this), 1); + } + if (!pTxtAttr) + { + ASSERT(false, "meta inserted, but has no text attribute?"); + throw uno::RuntimeException( + C2S("SwXMeta::attach(): cannot create meta"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + pMeta->Add(this); + + m_pImpl->m_xParentText = + SwXTextRange::CreateParentXText(pDoc, *aPam.GetPoint()); + + m_pImpl->m_bIsDescriptor = false; +} + +// XTextContent +void SAL_CALL +SwXMeta::attach(const uno::Reference< text::XTextRange > & i_xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + return SwXMeta::AttachImpl(i_xTextRange, RES_TXTATR_META); +} + +uno::Reference< text::XTextRange > SAL_CALL +SwXMeta::getAnchor() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (m_pImpl->m_bIsDisposed) + { + throw lang::DisposedException(); + } + if (m_pImpl->m_bIsDescriptor) + { + throw uno::RuntimeException( + C2S("SwXMeta::getAnchor(): not inserted"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess(SetContentRange(pTxtNode, nMetaStart, nMetaEnd)); + ASSERT(bSuccess, "no pam?"); + if (!bSuccess) + { + throw lang::DisposedException( + C2S("SwXMeta::getAnchor(): not attached"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + const SwPosition start(*pTxtNode, nMetaStart - 1); // -1 due to CH_TXTATR + const SwPosition end(*pTxtNode, nMetaEnd); + return SwXTextRange::CreateTextRangeFromPosition( + pTxtNode->GetDoc(), start, &end); +} + +// XTextRange +uno::Reference< text::XText > SAL_CALL +SwXMeta::getText() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + //TODO probably this should return outer meta in case there is nesting, + // but currently that is not done; would need to change at least + // SwXTextPortionEnumeration and SwXMeta::attach and other places where + // SwXMeta is constructed + return GetParentText(); +} + +uno::Reference< text::XTextRange > SAL_CALL +SwXMeta::getStart() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.getStart(); +} + +uno::Reference< text::XTextRange > SAL_CALL +SwXMeta::getEnd() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.getEnd(); +} + +rtl::OUString SAL_CALL +SwXMeta::getString() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.getString(); +} + +void SAL_CALL +SwXMeta::setString(const rtl::OUString& rString) throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.setString(rString); +} + +// XSimpleText +uno::Reference< text::XTextCursor > SAL_CALL +SwXMeta::createTextCursor() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.createTextCursor(); +} + +uno::Reference< text::XTextCursor > SAL_CALL +SwXMeta::createTextCursorByRange( + const uno::Reference<text::XTextRange> & xTextPosition) + throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.createTextCursorByRange(xTextPosition); +} + +void SAL_CALL +SwXMeta::insertString(const uno::Reference<text::XTextRange> & xRange, + const rtl::OUString& rString, sal_Bool bAbsorb) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.insertString(xRange, rString, bAbsorb); +} + +void SAL_CALL +SwXMeta::insertControlCharacter(const uno::Reference<text::XTextRange> & xRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.insertControlCharacter(xRange, nControlCharacter, + bAbsorb); +} + +// XText +void SAL_CALL +SwXMeta::insertTextContent( const uno::Reference<text::XTextRange> & xRange, + const uno::Reference<text::XTextContent> & xContent, sal_Bool bAbsorb) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.insertTextContent(xRange, xContent, bAbsorb); +} + +void SAL_CALL +SwXMeta::removeTextContent( + const uno::Reference< text::XTextContent > & xContent) + throw (container::NoSuchElementException, uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.removeTextContent(xContent); +} + +// XElementAccess +uno::Type SAL_CALL +SwXMeta::getElementType() throw (uno::RuntimeException) +{ + return text::XTextRange::static_type(); +} + +sal_Bool SAL_CALL +SwXMeta::hasElements() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + return GetRegisteredIn() ? sal_True : sal_False; +} + +// XEnumerationAccess +uno::Reference< container::XEnumeration > SAL_CALL +SwXMeta::createEnumeration() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (m_pImpl->m_bIsDisposed) + { + throw lang::DisposedException(); + } + if (m_pImpl->m_bIsDescriptor) + { + throw uno::RuntimeException( + C2S("getAnchor(): not inserted"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess(SetContentRange(pTxtNode, nMetaStart, nMetaEnd)); + ASSERT(bSuccess, "no pam?"); + if (!bSuccess) + throw lang::DisposedException(); + + SwPaM aPam(*pTxtNode, nMetaStart); + + if (!m_pImpl->m_pTextPortions.get()) + { + return new SwXTextPortionEnumeration( + aPam, GetParentText(), nMetaStart, nMetaEnd); + } + else // cached! + { + return new SwXTextPortionEnumeration(aPam, *m_pImpl->m_pTextPortions); + } +} + + +// MetadatableMixin +::sfx2::Metadatable* SwXMeta::GetCoreObject() +{ + return const_cast< ::sw::Meta * >(GetMeta()); +} + +uno::Reference<frame::XModel> SwXMeta::GetModel() +{ + ::sw::Meta const * const pMeta( GetMeta() ); + if (pMeta) + { + SwTxtNode const * const pTxtNode( pMeta->GetTxtNode() ); + if (pTxtNode) + { + SwDocShell const * const pShell(pTxtNode->GetDoc()->GetDocShell()); + return (pShell) ? pShell->GetModel() : 0; + } + } + 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 +{ + return static_cast< const ::sw::MetaField * >(GetRegisteredIn()); +} + +SwXMetaField::SwXMetaField(SwDoc *const pDoc, + uno::Reference<text::XText> const& xParentText, + TextRangeList_t * const pPortions, SwTxtMeta * const pHint) + : SwXMetaFieldBaseClass(pDoc, xParentText, pPortions, pHint) +{ + ASSERT(!pHint || RES_TXTATR_METAFIELD == pHint->Which(), + "SwXMetaField created for wrong hint!"); +} + +SwXMetaField::SwXMetaField(SwDoc *const pDoc) + : SwXMetaFieldBaseClass(pDoc) +{ +} + +SwXMetaField::~SwXMetaField() +{ +} + +// XServiceInfo +::rtl::OUString SAL_CALL +SwXMetaField::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXMetaField"); +} + +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"); +} + +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; +} + +// XComponent +void SAL_CALL +SwXMetaField::addEventListener( + uno::Reference< lang::XEventListener> const & xListener ) +throw (uno::RuntimeException) +{ + return SwXMeta::addEventListener(xListener); +} + +void SAL_CALL +SwXMetaField::removeEventListener( + uno::Reference< lang::XEventListener> const & xListener ) +throw (uno::RuntimeException) +{ + return SwXMeta::removeEventListener(xListener); +} + +void SAL_CALL +SwXMetaField::dispose() throw (uno::RuntimeException) +{ + return SwXMeta::dispose(); +} + +// XTextContent +void SAL_CALL +SwXMetaField::attach(const uno::Reference< text::XTextRange > & i_xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + return SwXMeta::AttachImpl(i_xTextRange, RES_TXTATR_METAFIELD); +} + +uno::Reference< text::XTextRange > SAL_CALL +SwXMetaField::getAnchor() throw (uno::RuntimeException) +{ + return SwXMeta::getAnchor(); +} + +// XPropertySet +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXMetaField::getPropertySetInfo() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + static uno::Reference< beans::XPropertySetInfo > xRef( + aSwMapProvider.GetPropertySet(PROPERTY_MAP_METAFIELD) + ->getPropertySetInfo() ); + return xRef; +} + +void SAL_CALL +SwXMetaField::setPropertyValue( + const ::rtl::OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + ::sw::MetaField * const pMeta( + const_cast< ::sw::MetaField * >(GetMetaField()) ); + if (!pMeta) + throw lang::DisposedException(); + + if (rPropertyName.equalsAscii("NumberFormat")) + { + sal_Int32 nNumberFormat(0); + if (rValue >>= nNumberFormat) + { + pMeta->SetNumberFormat(static_cast<sal_uInt32>(nNumberFormat)); + } + } + else if (rPropertyName.equalsAscii("IsFixedLanguage")) + { + bool b(false); + if (rValue >>= b) + { + pMeta->SetIsFixedLanguage(b); + } + } + else + { + throw beans::UnknownPropertyException(); + } +} + +uno::Any SAL_CALL +SwXMetaField::getPropertyValue(const ::rtl::OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + ::sw::MetaField const * const pMeta( GetMetaField() ); + if (!pMeta) + throw lang::DisposedException(); + + uno::Any any; + + if (rPropertyName.equalsAscii("NumberFormat")) + { + const ::rtl::OUString text( getPresentation(sal_False) ); + any <<= static_cast<sal_Int32>(pMeta->GetNumberFormat(text)); + } + else if (rPropertyName.equalsAscii("IsFixedLanguage")) + { + any <<= pMeta->IsFixedLanguage(); + } + else + { + throw beans::UnknownPropertyException(); + } + + return any; +} + +void SAL_CALL +SwXMetaField::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXMetaField::addPropertyChangeListener(): not implemented"); +} + +void SAL_CALL +SwXMetaField::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXMetaField::removePropertyChangeListener(): not implemented"); +} + +void SAL_CALL +SwXMetaField::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXMetaField::addVetoableChangeListener(): not implemented"); +} + +void SAL_CALL +SwXMetaField::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXMetaField::removeVetoableChangeListener(): not implemented"); +} + +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> +#include <com/sun/star/rdf/Statement.hpp> +#include <com/sun/star/rdf/URI.hpp> +#include <com/sun/star/rdf/URIs.hpp> +#include <com/sun/star/rdf/XLiteral.hpp> +#include <com/sun/star/rdf/XRepositorySupplier.hpp> +#include <comphelper/processfactory.hxx> + +static uno::Reference<rdf::XURI> const& +lcl_getURI(const bool bPrefix) +{ + static uno::Reference< uno::XComponentContext > xContext( + ::comphelper::getProcessComponentContext()); + static uno::Reference< rdf::XURI > xOdfPrefix( + rdf::URI::createKnown(xContext, rdf::URIs::ODF_PREFIX), + uno::UNO_SET_THROW); + static uno::Reference< rdf::XURI > xOdfSuffix( + rdf::URI::createKnown(xContext, rdf::URIs::ODF_SUFFIX), + uno::UNO_SET_THROW); + return (bPrefix) ? xOdfPrefix : xOdfSuffix; +} + +static ::rtl::OUString +lcl_getPrefixOrSuffix( + uno::Reference<rdf::XRepository> const & xRepository, + uno::Reference<rdf::XResource> const & xMetaField, + uno::Reference<rdf::XURI> const & xPredicate) +{ + const uno::Reference<container::XEnumeration> xEnum( + xRepository->getStatements(xMetaField, xPredicate, 0), + uno::UNO_SET_THROW); + while (xEnum->hasMoreElements()) { + rdf::Statement stmt; + if (!(xEnum->nextElement() >>= stmt)) { + throw uno::RuntimeException(); + } + const uno::Reference<rdf::XLiteral> xObject(stmt.Object, + uno::UNO_QUERY); + if (!xObject.is()) continue; + if (xEnum->hasMoreElements()) { + OSL_TRACE("ignoring other odf:Prefix/odf:Suffix statements"); + } + return xObject->getValue(); + } + return ::rtl::OUString(); +} + +void +getPrefixAndSuffix( + const uno::Reference<frame::XModel>& xModel, + const uno::Reference<rdf::XMetadatable>& xMetaField, + ::rtl::OUString *const o_pPrefix, ::rtl::OUString *const o_pSuffix) +{ + try { + const uno::Reference<rdf::XRepositorySupplier> xRS( + xModel, uno::UNO_QUERY_THROW); + const uno::Reference<rdf::XRepository> xRepo( + xRS->getRDFRepository(), uno::UNO_SET_THROW); + const uno::Reference<rdf::XResource> xMeta( + xMetaField, uno::UNO_QUERY_THROW); + if (o_pPrefix) + { + *o_pPrefix = lcl_getPrefixOrSuffix(xRepo, xMeta, lcl_getURI(true)); + } + if (o_pSuffix) + { + *o_pSuffix = lcl_getPrefixOrSuffix(xRepo, xMeta, lcl_getURI(false)); + } + } catch (uno::RuntimeException &) { + throw; + } catch (uno::Exception & e) { + throw lang::WrappedTargetRuntimeException( + ::rtl::OUString::createFromAscii("getPrefixAndSuffix: exception"), + 0, uno::makeAny(e)); + } +} + +// XTextField +::rtl::OUString SAL_CALL +SwXMetaField::getPresentation(sal_Bool bShowCommand) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (bShowCommand) + { +//FIXME ? + return ::rtl::OUString(); + } + else + { + // getString should check if this is invalid + const ::rtl::OUString content( this->getString() ); + ::rtl::OUString prefix; + ::rtl::OUString suffix; + getPrefixAndSuffix(GetModel(), this, &prefix, &suffix); + return prefix + content + suffix; + } +} + diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 529f36294fca..1308c6ad7d3e 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -461,7 +461,7 @@ void SwXTextSection::attachToRange(const uno::Reference< text::XTextRange > & xT if (pProps->aPassword.getLength() > 0) aSect.SetPasswd(pProps->aPassword); - pRet = pDoc->Insert( aPam, aSect, aSet.Count() ? &aSet : 0 ); + 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 diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index c00c21f5494e..56e3cbacd822 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -45,6 +45,7 @@ #include <unoidx.hxx> #include <unoframe.hxx> #include <unofield.hxx> +#include <unometa.hxx> #include <unodraw.hxx> #include <unoredline.hxx> #include <unomap.hxx> @@ -58,7 +59,6 @@ #include <swundo.hxx> #include <section.hxx> #include <IMark.hxx> -#include <fmthbsh.hxx> #include <fmtanchr.hxx> #include <crsskip.hxx> #include <ndtxt.hxx> @@ -77,6 +77,21 @@ const sal_Char cInvalidObject[] = "this object is invalid"; -----------------------------------------------------------------------*/ +void SwXText::PrepareForAttach( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > &, + const SwXTextRange* const, const SwPaM * const) +{ +} + +bool SwXText::CheckForOwnMemberMeta(const SwXTextRange* const, + const SwPaM* const, bool) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) +{ + ASSERT(CURSOR_META != eCrsrType, "should not be called!"); + return false; +} + const SwStartNode *SwXText::GetStartNode() const { return GetDoc()->GetNodes().GetEndOfContent().StartOfSectionNode(); @@ -85,12 +100,12 @@ const SwStartNode *SwXText::GetStartNode() const uno::Reference< text::XTextCursor > SwXText::createCursor() throw (uno::RuntimeException) { uno::Reference< text::XTextCursor > xRet; - OUString sRet; if(IsValid()) { SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); SwPosition aPos(rNode); - xRet = (text::XWordCursor*)new SwXTextCursor(this, aPos, GetTextType(), GetDoc()); + xRet = static_cast<text::XWordCursor*>( + new SwXTextCursor(this, aPos, GetTextType(), GetDoc())); xRet->gotoStart(sal_False); } return xRet; @@ -278,12 +293,41 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, 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) { //!! scan for CR characters and inserting the paragraph breaks //!! has to be done in the called function. //!! Implemented in SwXTextRange::DeleteAndInsert - xTextRange->setString(aString); + if (pCursor) + { + SwXTextCursor * const pTextCursor( dynamic_cast<SwXTextCursor*>(pCursor) ); + if (pTextCursor) + { + pTextCursor->DeleteAndInsert(aString, bForceExpandHints); + } + else + { + xTextRange->setString(aString); + } + } + else + { + pRange->DeleteAndInsert(aString, bForceExpandHints); + } } else { @@ -294,10 +338,11 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, ? pCursor->GetPaM()->Start() : &pRange->GetBookmark()->GetMarkStart(); SwPaM aInsertPam(*pPos); - sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); + const sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); GetDoc()->DoGroupUndo(sal_False); - SwUnoCursorHelper::DocInsertStringSplitCR(*GetDoc(), aInsertPam, aString); + SwUnoCursorHelper::DocInsertStringSplitCR( + *GetDoc(), aInsertPam, aString, bForceExpandHints ); GetDoc()->DoGroupUndo(bGroupUndo); } } @@ -316,15 +361,29 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & throw( lang::IllegalArgumentException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(GetDoc() && xTextRange.is()) + if (!xTextRange.is()) + throw lang::IllegalArgumentException(); + if (GetDoc()) { SwUnoInternalPaM aPam(*GetDoc()); if(SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange)) { + 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()) + { pDoc->DeleteAndJoin(aPam); + } sal_Unicode cIns = 0; switch( nControlCharacter ) @@ -367,7 +426,9 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & case text::ControlCharacter::HARD_SPACE: cIns = CHAR_HARDBLANK; break; } if( cIns ) - pDoc->Insert( aTmp, cIns ); + { + pDoc->InsertString( aTmp, cIns, nInsertFlags ); + } if(bAbsorb) { @@ -476,9 +537,9 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); pSrcNode = &pBkmk->GetMarkPos().nNode.GetNode(); } - else if (pPortion && pPortion->GetCrsr()) + else if (pPortion && pPortion->GetCursor()) { - pSrcNode = pPortion->GetCrsr()->GetNode(); + pSrcNode = pPortion->GetCursor()->GetNode(); } else if (pText) { @@ -511,9 +572,12 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang aRunException.Message = C2U("text interface and cursor not related"); throw aRunException; } + + const bool bForceExpandHints( CheckForOwnMemberMeta( + pRange, (pCursor) ? pCursor->GetPaM() : 0, bAbsorb) ); + // Sonderbehandlung fuer Contents, die den Range nicht ersetzen, sonder darueber gelegt werden // Bookmarks, IndexEntry - sal_Bool bAttribute = sal_False; uno::Reference<lang::XUnoTunnel> xContentTunnel( xContent, uno::UNO_QUERY); if(!xContentTunnel.is()) { @@ -529,8 +593,12 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang 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()))); - bAttribute = pBookmark || pDocumentIndexMark || pSection || pReferenceMark; + const bool bAttribute = pBookmark || pDocumentIndexMark + || pSection || pReferenceMark || pMeta; if(bAbsorb && !bAttribute) { @@ -542,6 +610,12 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang 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 @@ -582,7 +656,7 @@ void SwXText::insertTextContentBefore( if(!pPara || !pPara->IsDescriptor() || !xSuccessor.is()) throw lang::IllegalArgumentException(); - sal_Bool bRet = FALSE; + sal_Bool bRet = sal_False; SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xSuccessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; @@ -636,7 +710,7 @@ void SwXText::insertTextContentAfter( SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; - sal_Bool bRet = FALSE; + sal_Bool bRet = sal_False; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { SwTable* pTable = SwTable::FindTable( pTableFmt ); @@ -680,7 +754,7 @@ void SwXText::removeTextContentBefore( throw aRuntime; } - sal_Bool bRet = FALSE; + sal_Bool bRet = sal_False; SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation( xSuccessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; @@ -727,7 +801,7 @@ void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>& throw aRuntime; } - sal_Bool bRet = FALSE; + sal_Bool bRet = sal_False; SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; @@ -818,10 +892,8 @@ uno::Reference< text::XTextRange > SwXText::getEnd(void) throw( uno::RuntimeExc aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - else - xRef->gotoEnd(sal_False); - uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY);; - + xRef->gotoEnd(sal_False); + uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); return xRet; } /*-- 09.12.98 12:43:29--------------------------------------------------- @@ -856,6 +928,7 @@ void SwXText::setString(const OUString& aString) 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) { SwPosition aStartPos(*pStartNode); const SwEndNode* pEnd = pStartNode->EndOfSectionNode(); @@ -903,6 +976,7 @@ void SwXText::setString(const OUString& aString) throw( uno::RuntimeException ) 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( @@ -1361,7 +1435,8 @@ uno::Reference< text::XTextRange > SwXText::appendTextPortion( if(rText.getLength()) { xub_StrLen nContentPos = pCursor->GetPoint()->nContent.GetIndex(); - SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *pCursor, rText ); + SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *pCursor, rText, + false ); SwXTextCursor::SelectPam(*pCursor, sal_True); pCursor->GetPoint()->nContent = nContentPos; } diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 4a021e03c3b4..cf72af66d0a8 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -356,7 +356,7 @@ void lcl_FormatPostIt( IDocumentContentOperations* pIDCO, SwPaM& aPam, SwPostItF aStr += pField->GetPar1(); aStr += ' '; aStr += SvtSysLocale().GetLocaleData().getDate( pField->GetDate() ); - pIDCO->Insert( aPam, aStr, true ); + pIDCO->InsertString( aPam, aStr ); pIDCO->SplitNode( *aPam.GetPoint(), false ); aStr = pField->GetPar2(); @@ -364,7 +364,7 @@ void lcl_FormatPostIt( IDocumentContentOperations* pIDCO, SwPaM& aPam, SwPostItF // Bei Windows und Co alle CR rausschmeissen aStr.EraseAllChars( '\r' ); #endif - pIDCO->Insert( aPam, aStr, true ); + pIDCO->InsertString( aPam, aStr ); pIDCO->SplitNode( *aPam.GetPoint(), false ); pIDCO->SplitNode( *aPam.GetPoint(), false ); } @@ -455,7 +455,7 @@ void lcl_PrintPostItsEndDoc( ViewShell* pPrtShell, aPam.Move( fnMoveBackward, fnGoDoc ); aPam.SetMark(); aPam.Move( fnMoveForward, fnGoDoc ); - pPrtDoc->Delete( aPam ); + pPrtDoc->DeleteRange( aPam ); for( USHORT i = 0, nVirtPg, nLineNo; i < nPostIts; ++i ) { @@ -504,7 +504,7 @@ void lcl_PrintPostItsEndPage( ViewShell* pPrtShell, aPam.Move( fnMoveBackward, fnGoDoc ); aPam.SetMark(); aPam.Move( fnMoveForward, fnGoDoc ); - pPrtDoc->Delete( aPam ); + pPrtDoc->DeleteRange( aPam ); while( i < nPostIts ) { diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx index f59ca89a8ce8..22957c9434af 100644 --- a/sw/source/filter/ascii/ascatr.cxx +++ b/sw/source/filter/ascii/ascatr.cxx @@ -88,20 +88,16 @@ xub_StrLen SwASC_AttrIter::SearchNext( xub_StrLen nStartPos ) const SwpHints* pTxtAttrs = rNd.GetpSwpHints(); if( pTxtAttrs ) { - USHORT i; - xub_StrLen nPos; - const xub_StrLen * pPos; - // kann noch optimiert werden, wenn ausgenutzt wird, dass die TxtAttrs // nach der Anfangsposition geordnet sind. Dann muessten // allerdings noch 2 Indices gemerkt werden - for( i = 0; i < pTxtAttrs->Count(); i++ ) + for ( USHORT i = 0; i < pTxtAttrs->Count(); i++ ) { const SwTxtAttr* pHt = (*pTxtAttrs)[i]; - nPos = *pHt->GetStart(); // gibt erstes Attr-Zeichen - pPos = pHt->GetEnd(); - if( !pPos ) + if (pHt->HasDummyChar()) { + xub_StrLen nPos = *pHt->GetStart(); + if( nPos >= nStartPos && nPos <= nMinPos ) nMinPos = nPos; @@ -124,8 +120,7 @@ BOOL SwASC_AttrIter::OutAttr( xub_StrLen nSwPos ) for( i = 0; i < pTxtAttrs->Count(); i++ ) { const SwTxtAttr* pHt = (*pTxtAttrs)[i]; - const xub_StrLen * pEnd = pHt->GetEnd(); - if( !pEnd && nSwPos == *pHt->GetStart() ) + if ( pHt->HasDummyChar() && nSwPos == *pHt->GetStart() ) { bRet = TRUE; String sOut; @@ -135,10 +130,6 @@ BOOL SwASC_AttrIter::OutAttr( xub_StrLen nSwPos ) sOut = ((SwTxtFld*)pHt)->GetFld().GetFld()->Expand(); break; - case RES_TXTATR_HARDBLANK: - sOut = ((SwTxtHardBlank*)pHt)->GetChar(); - break; - case RES_TXTATR_FTN: { const SwFmtFtn& rFtn = pHt->GetFtn(); diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx index 24aa81837d62..50ba611b12e5 100644 --- a/sw/source/filter/ascii/parasc.cxx +++ b/sw/source/filter/ascii/parasc.cxx @@ -261,7 +261,7 @@ ULONG SwASCIIParser::CallParser() // !!!!! ASSERT( !this, "Have to change - hard attr. to para. style" ); - pDoc->Insert( *pInsPam, *pItemSet, 0 ); + pDoc->InsertItemSet( *pInsPam, *pItemSet, 0 ); } } delete pItemSet, pItemSet = 0; @@ -467,7 +467,7 @@ ULONG SwASCIIParser::ReadChars() InsertText( String( pLastStt )); } pDoc->SplitNode( *pPam->GetPoint(), false ); - pDoc->Insert( *pPam, SvxFmtBreakItem( + pDoc->InsertPoolItem( *pPam, SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0); pLastStt = pStt; nLineLen = 0; @@ -528,7 +528,7 @@ ULONG SwASCIIParser::ReadChars() void SwASCIIParser::InsertText( const String& rStr ) { - pDoc->Insert( *pPam, rStr, true ); + pDoc->InsertString( *pPam, rStr ); if( pItemSet && pBreakIt && nScript != ( SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX ) ) diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx index 05b1bb4eb97a..cb31050b02d3 100644 --- a/sw/source/filter/basflt/fltini.cxx +++ b/sw/source/filter/basflt/fltini.cxx @@ -670,13 +670,13 @@ void CalculateFlySize(SfxItemSet& rFlySet, const SwNodeIndex& rAnchor, // if the first node dont contained any content, then // insert one char in it calc again and delete once again SwIndex aNdIdx( pFirstTxtNd ); - pFirstTxtNd->Insert( String::CreateFromAscii( + pFirstTxtNd->InsertText( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "MM" )), aNdIdx ); ULONG nAbsMinCnts; pFirstTxtNd->GetMinMaxSize( pFirstTxtNd->GetIndex(), nMinFrm, nMaxFrm, nAbsMinCnts ); aNdIdx -= 2; - pFirstTxtNd->Erase( aNdIdx, 2 ); + pFirstTxtNd->EraseText( aNdIdx, 2 ); } // Umrandung und Abstand zum Inhalt beachten diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index b6a5143e13d3..0012d5dc0664 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -81,7 +81,6 @@ #include <txatbase.hxx> #include <frmatr.hxx> #include <charfmt.hxx> -#include <fmthbsh.hxx> #include <fmtfld.hxx> #include <doc.hxx> #include <pam.hxx> @@ -2495,7 +2494,7 @@ Writer& OutHTML_SwTxtNode( Writer& rWrt, const SwCntntNode& rNode ) if( RES_TXTATR_FIELD == pHt->Which() ) // Felder nicht continue; // ausgeben - if( pHt->GetEnd() ) + if ( pHt->GetEnd() && !pHt->HasDummyChar() ) { xub_StrLen nHtEnd = *pHt->GetEnd(), nHtStt = *pHt->GetStart(); @@ -2555,7 +2554,7 @@ Writer& OutHTML_SwTxtNode( Writer& rWrt, const SwCntntNode& rNode ) && nStrPos != nEnde ) { do { - if( pHt->GetEnd() ) + if ( pHt->GetEnd() && !pHt->HasDummyChar() ) { if( RES_CHRATR_KERNING == pHt->Which() && rHTMLWrt.IsHTMLMode(HTMLMODE_FIRSTLINE) && @@ -3041,15 +3040,6 @@ static Writer& OutHTML_SwFlyCnt( Writer& rWrt, const SfxPoolItem& rHt ) return rWrt; } -static Writer& OutHTML_SwHardBlank( Writer& rWrt, const SfxPoolItem& rHt ) -{ - HTMLOutContext aContext ( ((SwHTMLWriter&)rWrt).eDestEnc ); - HTMLOutFuncs::Out_Char( rWrt.Strm(), ((SwFmtHardBlank&)rHt).GetChar(), - aContext, - &((SwHTMLWriter&)rWrt).aNonConvertableCharacters); - HTMLOutFuncs::FlushToAscii( rWrt.Strm(), aContext ); - return rWrt; -} // Das ist jetzt unser Blink-Item. Blinkend wird eingeschaltet, indem man // das Item auf TRUE setzt! @@ -3416,7 +3406,7 @@ SwAttrFnTab aHTMLAttrFnTab = { /* RES_TXTATR_FLYCNT */ OutHTML_SwFlyCnt, /* RES_TXTATR_FTN */ OutHTML_SwFmtFtn, /* RES_TXTATR_SOFTHYPH */ 0, -/* RES_TXTATR_HARDBLANK*/ OutHTML_SwHardBlank, +/* RES_TXTATR_HARDBLANK*/ 0, /* RES_TXTATR_DUMMY1 */ 0, // Dummy: /* RES_TXTATR_DUMMY2 */ 0, // Dummy: diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx index 7e3e088eb7d9..c9930c3ca8ef 100644 --- a/sw/source/filter/html/htmlfld.cxx +++ b/sw/source/filter/html/htmlfld.cxx @@ -547,7 +547,7 @@ void SwHTMLParser::NewField() } else { - pDoc->Insert( *pPam, SwFmtFld(*pFld), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld(*pFld), 0 ); delete pFld; } bInField = TRUE; @@ -585,7 +585,7 @@ void SwHTMLParser::EndField() break; } - pDoc->Insert( *pPam, SwFmtFld(*pField), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld(*pField), 0 ); delete pField; pField = 0; } diff --git a/sw/source/filter/html/htmlftn.cxx b/sw/source/filter/html/htmlftn.cxx index 9e35f8e78768..343939bd38d1 100644 --- a/sw/source/filter/html/htmlftn.cxx +++ b/sw/source/filter/html/htmlftn.cxx @@ -228,11 +228,10 @@ void SwHTMLParser::FinishFootEndNote() if( pFootEndNoteImpl->bFixed ) aFtn.SetNumStr( pFootEndNoteImpl->sContent ); - pDoc->Insert( *pPam, aFtn, 0 ); - SwTxtFtn *pTxtFtn = - (SwTxtFtn *)pPam->GetNode()->GetTxtNode()->GetTxtAttr( - pPam->GetPoint()->nContent.GetIndex() - 1, - RES_TXTATR_FTN ); + pDoc->InsertPoolItem( *pPam, aFtn, 0 ); + SwTxtFtn * const pTxtFtn = static_cast<SwTxtFtn *>( + pPam->GetNode()->GetTxtNode()->GetTxtAttrForCharAt( + pPam->GetPoint()->nContent.GetIndex() - 1, RES_TXTATR_FTN ) ); // In Kopf- und Fusszeilen duerfen keine Fussnoten eingefuegt werden. if( pTxtFtn ) { diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index 904648f75bd2..b6ad8bc1d4cb 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -1374,7 +1374,7 @@ void SwHTMLParser::StripTrailingPara() if( pPrvNd ) { SwIndex aSrc( pCNd, 0 ); - pCNd->GetTxtNode()->Cut( pPrvNd, aSrc, pCNd->Len() ); + pCNd->GetTxtNode()->CutText( pPrvNd, aSrc, pCNd->Len() ); } } @@ -1436,9 +1436,10 @@ void SwHTMLParser::StripTrailingPara() xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex(); while( bSetSmallFont && nPos>0 ) { - bSetSmallFont = CH_TXTATR_BREAKWORD == - pTxtNd->GetTxt().GetChar( --nPos ) && - 0 != pTxtNd->GetTxtAttr( nPos, RES_TXTATR_FLYCNT ); + --nPos; + bSetSmallFont = + (CH_TXTATR_BREAKWORD == pTxtNd->GetTxt().GetChar( nPos )) && + (0 != pTxtNd->GetTxtAttrForCharAt( nPos, RES_TXTATR_FLYCNT )); } } diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx index f1eb32d730a6..a4fb7f70ff66 100644 --- a/sw/source/filter/html/htmlsect.cxx +++ b/sw/source/filter/html/htmlsect.cxx @@ -351,7 +351,7 @@ void SwHTMLParser::NewDivision( int nToken ) aItemSet.ClearItem( RES_FRAMEDIR ); } - pDoc->Insert( *pPam, aSection, &aFrmItemSet, sal_False ); + pDoc->InsertSwSection( *pPam, aSection, &aFrmItemSet, false ); // ggfs. einen Bereich anspringen if( JUMPTO_REGION == eJumpTo && aName == sJmpMark ) @@ -746,7 +746,7 @@ void SwHTMLParser::NewMultiCol() aFrmItemSet.Put( *pItem ); aItemSet.ClearItem( RES_FRAMEDIR ); } - pDoc->Insert( *pPam, aSection, &aFrmItemSet, sal_False ); + pDoc->InsertSwSection( *pPam, aSection, &aFrmItemSet, false ); // Jump to section, if this is requested. if( JUMPTO_REGION == eJumpTo && aName == sJmpMark ) diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index cc83cbcd8605..3b02546494f8 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -3030,7 +3030,7 @@ xub_StrLen SwHTMLParser::StripTrailingLF() nPos = nLen - nLFCount; SwIndex nIdx( pTxtNd, nPos ); - pTxtNd->Erase( nIdx, nLFCount ); + pTxtNd->EraseText( nIdx, nLFCount ); nStripped = nLFCount; } } @@ -5495,7 +5495,8 @@ HTMLTable *SwHTMLParser::BuildTable( SvxAdjust eParentAdjust, pNd = pTblStNd->EndOfSectionNode(); SwNodeIndex aDstIdx( *pNd, bTop ? 0 : 1 ); - pDoc->Move( aSrcRg, aDstIdx, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveNodeRange( aSrcRg, aDstIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT ); // Wenn die Caption vor der Tabelle eingefuegt wurde muss // eine an der Tabelle gestzte Seitenvorlage noch in den diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 2e93323b66b1..551ebf937be2 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -79,7 +79,6 @@ #include <charatr.hxx> #include <fmtfld.hxx> #include <fmtpdsc.hxx> -#include <fmthbsh.hxx> #include <txtfld.hxx> #include <fmtanchr.hxx> #include <fmtsrnd.hxx> @@ -235,7 +234,7 @@ ULONG HTMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPam, const // sonst ist sie schon gesetzt. if( !rDoc.get(IDocumentSettingAccess::HTML_MODE) ) { - rDoc.Insert( rPam, SwFmtPageDesc( + rDoc.InsertPoolItem( rPam, SwFmtPageDesc( rDoc.GetPageDescFromPool( RES_POOLPAGE_HTML, false )), 0 ); } } @@ -1282,7 +1281,9 @@ void __EXPORT SwHTMLParser::NextToken( int nToken ) pPageDesc = pCSS1Parser->GetRightPageDesc(); if( pPageDesc ) - pDoc->Insert( *pPam, SwFmtPageDesc( pPageDesc ), 0 ); + { + pDoc->InsertPoolItem( *pPam, SwFmtPageDesc( pPageDesc ), 0 ); + } } break; @@ -1436,11 +1437,11 @@ void __EXPORT SwHTMLParser::NextToken( int nToken ) break; case HTML_NONBREAKSPACE: - pDoc->Insert( *pPam, CHAR_HARDBLANK ); + pDoc->InsertString( *pPam, CHAR_HARDBLANK ); break; case HTML_SOFTHYPH: - pDoc->Insert( *pPam, CHAR_SOFTHYPHEN ); + pDoc->InsertString( *pPam, CHAR_SOFTHYPHEN ); break; case HTML_LINEFEEDCHAR: @@ -1482,7 +1483,7 @@ void __EXPORT SwHTMLParser::NextToken( int nToken ) { if( !bDocInitalized ) DocumentDetected(); - pDoc->Insert( *pPam, aToken, true ); + pDoc->InsertString( *pPam, aToken ); // wenn es noch vorlaefige Absatz-Attribute gibt, der Absatz aber // nicht leer ist, dann sind die Absatz-Attribute entgueltig. @@ -2336,7 +2337,7 @@ BOOL SwHTMLParser::AppendTxtNode( SwHTMLAppendMode eMode, BOOL bUpdateNum ) // also delete the SwpHints!!! To avoid any trouble // we leave the loop immediately if this is the last // hint. - pTxtNd->Delete( pHt, sal_True ); + pTxtNd->DeleteAttribute( pHt ); if( 1 == nCntAttr ) break; i--; @@ -2821,7 +2822,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, eJumpTo = JUMPTO_NONE; } - pDoc->Insert( *pAttrPam, *pAttr->pItem, nsSetAttrMode::SETATTR_DONTREPLACE ); + pDoc->InsertPoolItem( *pAttrPam, *pAttr->pItem, nsSetAttrMode::SETATTR_DONTREPLACE ); } pAttrPam->DeleteMark(); @@ -2903,7 +2904,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, pAttrPam->Move( fnMoveBackward ); } - pDoc->Insert( *pAttrPam, *pAttr->pItem, 0 ); + pDoc->InsertPoolItem( *pAttrPam, *pAttr->pItem, 0 ); aFields.Remove( 0, 1 ); delete pAttr; @@ -4941,7 +4942,7 @@ void SwHTMLParser::InsertSpacer() { NewAttr( &aAttrTab.pKerning, SvxKerningItem( (short)nSize, RES_CHRATR_KERNING ) ); String aTmp( ' ' ); - pDoc->Insert( *pPam, aTmp /*, CHARSET_ANSI*/, true ); + pDoc->InsertString( *pPam, aTmp ); EndAttr( aAttrTab.pKerning ); } } @@ -5149,7 +5150,7 @@ void SwHTMLParser::InsertLineBreak() // wenn kein CLEAR ausgefuehrt werden sollte oder konnte, wird // ein Zeilenumbruch eingef?gt String sTmp( (sal_Unicode)0x0a ); // make the Mac happy :-) - pDoc->Insert( *pPam, sTmp, true ); + pDoc->InsertString( *pPam, sTmp ); } else if( pPam->GetPoint()->nContent.GetIndex() ) { diff --git a/sw/source/filter/rtf/rtfatr.cxx b/sw/source/filter/rtf/rtfatr.cxx index ddb25947f2a1..6b033fe73e52 100644 --- a/sw/source/filter/rtf/rtfatr.cxx +++ b/sw/source/filter/rtf/rtfatr.cxx @@ -102,7 +102,6 @@ #include <fmtfld.hxx> #include <fmtflcnt.hxx> #include <fmtftn.hxx> -#include <fmthbsh.hxx> #include <fchrfmt.hxx> #include <fmtautofmt.hxx> #include <fmtcntnt.hxx> @@ -3048,14 +3047,6 @@ static Writer& OutRTF_SwFtn( Writer& rWrt, const SfxPoolItem& rHt ) return rWrt; } -static Writer& OutRTF_SwHardBlank( Writer& rWrt, const SfxPoolItem& rHt) -{ - RTFOutFuncs::Out_String(rWrt.Strm(), - String(((SwFmtHardBlank&)rHt).GetChar()), ((SwRTFWriter&)rWrt).eDefaultEncoding, - ((SwRTFWriter&)rWrt).bWriteHelpFmt); - return rWrt; -} - static Writer& OutRTF_SwTxtCharFmt( Writer& rWrt, const SfxPoolItem& rHt ) { const SwFmtCharFmt& rChrFmt = (const SwFmtCharFmt&)rHt; @@ -4275,7 +4266,7 @@ SwAttrFnTab aRTFAttrFnTab = { /* RES_TXTATR_FLYCNT */ OutRTF_SwFlyCntnt, /* RES_TXTATR_FTN */ OutRTF_SwFtn, /* RES_TXTATR_SOFTHYPH */ 0, // old attr. - coded now by character -/* RES_TXTATR_HARDBLANK*/ OutRTF_SwHardBlank, +/* RES_TXTATR_HARDBLANK*/ 0, /* RES_TXTATR_DUMMY1 */ 0, // Dummy: /* RES_TXTATR_DUMMY2 */ 0, // Dummy: diff --git a/sw/source/filter/rtf/rtffld.cxx b/sw/source/filter/rtf/rtffld.cxx index 23d0da5a90fa..8985d58429c3 100644 --- a/sw/source/filter/rtf/rtffld.cxx +++ b/sw/source/filter/rtf/rtffld.cxx @@ -450,7 +450,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) // steht jetzt geanu auf dem Format-Namen aFld.ChangeFormat( CheckNumberFmtStr( aSaveStr )); } - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 ); SkipGroup(); } break; @@ -469,7 +469,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) // steht jetzt geanu auf dem Format-Namen aPF.ChangeFormat( CheckNumberFmtStr( aSaveStr )); } - pDoc->Insert( *pPam, SwFmtFld( aPF ), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aPF ), 0 ); SkipGroup(); // ueberlese den Rest } break; @@ -480,8 +480,8 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) { // es fehlt die Format - Angabe: defaulten auf Datum pFldType = pDoc->GetSysFldType( RES_DATETIMEFLD ); - pDoc->Insert( *pPam, SwFmtFld( SwDateTimeField( - (SwDateTimeFieldType*)pFldType, DATEFLD )), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( SwDateTimeField( + static_cast<SwDateTimeFieldType*>(pFldType), DATEFLD)), 0); } else { @@ -524,7 +524,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) if( pFld ) { - pDoc->Insert( *pPam, SwFmtFld( *pFld ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( *pFld ), 0); delete pFld; } } @@ -553,8 +553,8 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) if( bField ) { pFldType = pDoc->GetSysFldType( RES_DBNAMEFLD ); - pDoc->Insert( *pPam, SwFmtFld( SwDBNameField( - (SwDBNameFieldType*)pFldType, SwDBData() ) ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( SwDBNameField( + static_cast<SwDBNameFieldType*>(pFldType), SwDBData())), 0); } else pDoc->ChgDBData( aData ); // MS: Keine DBInfo verwenden @@ -569,7 +569,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) SwDBField aDBFld( (SwDBFieldType*)pDoc->InsertFldType( aTmp )); aDBFld.ChangeFormat( UF_STRING ); - pDoc->Insert( *pPam, SwFmtFld( aDBFld ), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld( aDBFld ), 0); SkipGroup(); // ueberlese den Rest } break; @@ -598,7 +598,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) sal_Unicode nChar = (sal_Unicode)sParam.ToInt32(); if( nChar ) { - pDoc->Insert( *pPam, nChar ); + pDoc->InsertString( *pPam, nChar ); bCharIns = TRUE; } } @@ -763,10 +763,11 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) aRuby.SetAdjustment( (USHORT)aData.nJustificationCode ); // im FieldStr steht der anzuzeigenden Text, im - pDoc->Insert( *pPam, aData.sText, true ); + pDoc->InsertString( *pPam, aData.sText ); pPam->SetMark(); pPam->GetMark()->nContent -= aData.sText.Len(); - pDoc->Insert( *pPam, aRuby, nsSetAttrMode::SETATTR_DONTEXPAND ); + pDoc->InsertPoolItem( *pPam, aRuby, + nsSetAttrMode::SETATTR_DONTEXPAND ); pPam->DeleteMark(); } // or a combined character field? @@ -778,7 +779,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) sFld += aData.sDown; SwCombinedCharField aFld((SwCombinedCharFieldType*)pDoc-> GetSysFldType( RES_COMBINED_CHARS ), sFld ); - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0); } SkipGroup(); // ueberlese den Rest @@ -808,7 +809,9 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) sOrigBkmName,REF_BOOKMARK,0,REF_PAGE); if(!bNestedField) - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0 ); + { + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 ); + } else bNestedField = false; } @@ -850,14 +853,14 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) SwGetRefField aFld( (SwGetRefFieldType*)pDoc->GetSysFldType( RES_GETREFFLD ), sOrigBkmName,REF_BOOKMARK,0,REF_CHAPTER); - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 ); } else { SwGetRefField aFld( (SwGetRefFieldType*)pDoc->GetSysFldType( RES_GETREFFLD ), sOrigBkmName,REF_BOOKMARK,0,REF_CONTENT); - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 ); } } @@ -866,7 +869,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) SwGetRefField aFld( (SwGetRefFieldType*) pDoc->GetSysFldType( RES_GETREFFLD ), sOrigBkmName, REF_BOOKMARK, 0, REF_UPDOWN ); - pDoc->Insert(*pPam, SwFmtFld(aFld), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld(aFld), 0); } } break; @@ -882,7 +885,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) SwUserFieldType aTmp( pDoc, aSaveStr ); SwUserField aUFld( (SwUserFieldType*)pDoc->InsertFldType( aTmp )); aUFld.ChangeFormat( UF_STRING ); - pDoc->Insert( *pPam, SwFmtFld( aUFld ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aUFld ), 0); nRet = RTFFLD_UNKNOWN; } break; @@ -1045,7 +1048,8 @@ void SwRTFParser::ReadField() // FieldResult wurde eingelesen if (SwTxtNode* pTxtNd = pPam->GetPoint()->nNode.GetNode().GetTxtNode()) { - SwTxtAttr* pFldAttr = pTxtNd->GetTxtAttr( + SwTxtAttr* const pFldAttr = + pTxtNd->GetTxtAttrForCharAt( pPam->GetPoint()->nContent.GetIndex()-1 ); if (pFldAttr) @@ -1078,7 +1082,7 @@ void SwRTFParser::ReadField() sNestedFieldStr.Erase(); // im FieldStr steht der anzuzeigenden Text, im - pDoc->Insert( *pPam, sFieldStr, true ); + pDoc->InsertString( *pPam, sFieldStr ); String sTarget( sFieldNm.GetToken( 1, '\1' )); if( sTarget.Len() ) @@ -1087,7 +1091,7 @@ void SwRTFParser::ReadField() // oder ueber den Stack setzen?? pPam->SetMark(); pPam->GetMark()->nContent -= sFieldStr.Len(); - pDoc->Insert( *pPam, + pDoc->InsertPoolItem( *pPam, SwFmtINetFmt( sFieldNm, sTarget ), nsSetAttrMode::SETATTR_DONTEXPAND ); pPam->DeleteMark(); diff --git a/sw/source/filter/rtf/rtffly.cxx b/sw/source/filter/rtf/rtffly.cxx index e4f1adc8850c..e4043f2e8529 100644 --- a/sw/source/filter/rtf/rtffly.cxx +++ b/sw/source/filter/rtf/rtffly.cxx @@ -396,7 +396,8 @@ void SwRTFParser::SetFlysInDoc() } } aTmpIdx = *pSttNd->EndOfSectionNode(); - pDoc->Move( aRg, aTmpIdx, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveNodeRange( aRg, aTmpIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT ); } // patch from cmc for #i52542# @@ -1174,7 +1175,7 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) { SwTxtNode* pTxtNd = pFlySave->nSttNd.GetNode().GetTxtNode(); - SwTxtFlyCnt* pFlyCnt; + SwTxtFlyCnt* pFlyCnt = 0; if( 1 == pTxtNd->GetTxt().Len() && 0 != ( pFlyCnt = (SwTxtFlyCnt*)pTxtNd->GetTxtAttr( 0, RES_TXTATR_FLYCNT )) && @@ -1232,7 +1233,8 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() ); SwNodeIndex aTmp( pFlySave->nSttNd, +1 ); - pDoc->Move( aRg, aTmp, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveNodeRange( aRg, aTmp, + IDocumentContentOperations::DOC_MOVEDEFAULT ); // now delete the redundant txtnode pDoc->GetNodes().Delete( pFlySave->nSttNd, 1 ); diff --git a/sw/source/filter/rtf/rtftbl.cxx b/sw/source/filter/rtf/rtftbl.cxx index 736bbf3d750b..4fd06a26925f 100644 --- a/sw/source/filter/rtf/rtftbl.cxx +++ b/sw/source/filter/rtf/rtftbl.cxx @@ -851,7 +851,8 @@ void SwRTFParser::ReadTable( int nToken ) //table aRg.SetMark(); aRg.GetMark()->nContent.Assign(aRg.GetCntntNode(), 0); - pDoc->Move(aRg, *pPam->GetPoint(), IDocumentContentOperations::DOC_MOVEDEFAULT); + pDoc->MoveRange(aRg, *pPam->GetPoint(), + IDocumentContentOperations::DOC_MOVEDEFAULT); } //Update the attribute stack entries to reflect that the properties diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 74020ab39e4a..9b5b90a01641 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -55,7 +55,6 @@ #include <svx/hyznitem.hxx> #include <fmtpdsc.hxx> #include <fmtfld.hxx> -#include <fmthbsh.hxx> #include <fmthdft.hxx> #include <fmtcntnt.hxx> #include <txtftn.hxx> @@ -851,7 +850,8 @@ SwSectionFmt *rtfSections::InsertSection(SwPaM& rMyPaM, rtfSection &rSection) aSet.Put(SvxFrameDirectionItem( nRTLPgn ? FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR)); - rSection.mpSection = mrReader.pDoc->Insert( rMyPaM, aSection, &aSet ); + rSection.mpSection = + mrReader.pDoc->InsertSwSection( rMyPaM, aSection, &aSet ); ASSERT(rSection.mpSection, "section not inserted!"); if (!rSection.mpSection) return 0; @@ -1002,7 +1002,7 @@ void rtfSections::InsertSegments(bool bNewDoc) aIter->maStart.GetNode().GetCntntNode(), 0); SwPaM aPage(aPamStart); - mrReader.pDoc->Insert(aPage, aPgDesc, 0); + mrReader.pDoc->InsertPoolItem(aPage, aPgDesc, 0); } ++nDesc; } @@ -1823,7 +1823,8 @@ void SwRTFParser::NextToken( int nToken ) if (lcl_UsedPara(*pPam)) InsertPara(); CheckInsNewTblLine(); - pDoc->Insert(*pPam, SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); + pDoc->InsertPoolItem(*pPam, + SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); } break; @@ -1975,12 +1976,13 @@ void SwRTFParser::NextToken( int nToken ) &const_cast<const SwDoc *>(pDoc) ->GetPageDesc( USHORT(nTokenValue) ); CheckInsNewTblLine(); - pDoc->Insert( *pPam, SwFmtPageDesc( pPgDsc ), 0); + pDoc->InsertPoolItem(*pPam, SwFmtPageDesc( pPgDsc ), 0); } break; case RTF_COLUM: - pDoc->Insert( *pPam, SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE, RES_BREAK ), 0); + pDoc->InsertPoolItem(*pPam, + SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE, RES_BREAK ), 0); break; case RTF_DXFRTEXT: // werden nur im Zusammenhang mit Flys ausgewertet @@ -2000,7 +2002,7 @@ SETCHDATEFIELD: SwDateTimeField aDateFld( (SwDateTimeFieldType*) pDoc->GetSysFldType( RES_DATETIMEFLD ), DATEFLD, nFormat); CheckInsNewTblLine(); - pDoc->Insert( *pPam, SwFmtFld( aDateFld ), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld( aDateFld ), 0); } break; @@ -2012,7 +2014,7 @@ SETCHDATEFIELD: SwDateTimeField aTimeFld( (SwDateTimeFieldType*) pDoc->GetSysFldType( RES_DATETIMEFLD ), TIMEFLD, nFormat); CheckInsNewTblLine(); - pDoc->Insert( *pPam, SwFmtFld( aTimeFld ), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld( aTimeFld ), 0); } break; @@ -2022,7 +2024,7 @@ SETCHDATEFIELD: pDoc->GetSysFldType( RES_PAGENUMBERFLD ), PG_RANDOM, SVX_NUM_ARABIC ); CheckInsNewTblLine(); - pDoc->Insert( *pPam, SwFmtFld( aPageFld), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld(aPageFld), 0); } break; @@ -2052,7 +2054,7 @@ SETCHDATEFIELD: CheckInsNewTblLine(); if( nTokenValue ) aToken = (sal_Unicode )nTokenValue; - pDoc->Insert( *pPam, aToken, true ); + pDoc->InsertString( *pPam, aToken ); } break; @@ -2118,7 +2120,7 @@ void SwRTFParser::InsertText() if(pRedlineDelete) mpRedlineStack->open(*pPam->GetPoint(), *pRedlineDelete); - pDoc->Insert( *pPam, aToken, true ); + pDoc->InsertString( *pPam, aToken ); if(pRedlineDelete) { @@ -2282,14 +2284,15 @@ void SwRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) } } while( 0 != (pStyle = GetStyleTbl().Next()) ); - pDoc->Insert(aPam, *pCharFmt, 0); + pDoc->InsertPoolItem(aPam, *pCharFmt, 0); rSet.GetAttrSet().ClearItem(RES_TXTATR_CHARFMT); //test hack } if (rSet.GetAttrSet().Count()) { // dann setze ueber diesen Bereich die Attrbiute SetSwgValues(rSet.GetAttrSet()); - pDoc->Insert(aPam, rSet.GetAttrSet(), nsSetAttrMode::SETATTR_DONTCHGNUMRULE); + pDoc->InsertItemSet(aPam, rSet.GetAttrSet(), + nsSetAttrMode::SETATTR_DONTCHGNUMRULE); } } @@ -2451,7 +2454,7 @@ void SwRTFParser::SetPageInformationAsDefault(const DocPageInformation &rInfo) { SwFmtPageDesc aPgDsc( &rPg ); aPgDsc.SetNumOffset( nPgStart ); - pDoc->Insert( *pPam, aPgDsc, 0 ); + pDoc->InsertPoolItem( *pPam, aPgDsc, 0 ); } } } @@ -3710,7 +3713,7 @@ void SwRTFParser::ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc ) aSet.Put( SwFmtAnchor( FLY_IN_CNTNT )); pHdFtFmt = pDoc->MakeFlySection( FLY_IN_CNTNT, pPam->GetPoint(), &aSet ); - pTxtAttr = pPam->GetNode()->GetTxtNode()->GetTxtAttr( + pTxtAttr = pPam->GetNode()->GetTxtNode()->GetTxtAttrForCharAt( nPos, RES_TXTATR_FLYCNT ); ASSERT( pTxtAttr, "konnte den Fly nicht einfuegen/finden" ); @@ -4296,7 +4299,7 @@ void SwRTFParser::UnknownAttrToken( int nToken, SfxItemSet* pSet ) { const SwPageDesc* pPgDsc = &const_cast<const SwDoc *>(pDoc) ->GetPageDesc( (USHORT)nTokenValue ); - pDoc->Insert( *pPam, SwFmtPageDesc( pPgDsc ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtPageDesc( pPgDsc ), 0); } break; case RTF_CS: diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx index a25d1b39f705..822091cec765 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/ww1/fltshell.cxx @@ -492,7 +492,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* { // XRefs und Bookmarks sind bereits geUpcased MakeBookRegionOrPoint(pEntry, pDoc, aRegion, TRUE); - pDoc->Insert(aRegion, SwFmtRefMark(rName), 0); + pDoc->InsertPoolItem(aRegion, SwFmtRefMark(rName), 0); } else if( !pB->IsOnlyRef() ) { @@ -506,7 +506,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* pB->GetValSys()); aFld.SetSubType( nsSwExtendedSubType::SUB_INVISIBLE ); MakePoint(pEntry, pDoc, aRegion); - pDoc->Insert(aRegion, SwFmtFld(aFld), 0); + pDoc->InsertPoolItem(aRegion, SwFmtFld(aFld), 0); MoveAttrs( *(aRegion.GetPoint()) ); } } @@ -564,8 +564,9 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* break; case RES_FLTR_SECTION: MakePoint(pEntry, pDoc, aRegion); // bislang immer Point==Mark - pDoc->Insert(aRegion, *((SwFltSection*)pEntry->pAttr)->GetSection(), - 0, FALSE); + pDoc->InsertSwSection(aRegion, + *(static_cast<SwFltSection*>(pEntry->pAttr))->GetSection(), + 0, false); delete(((SwFltSection*)pEntry->pAttr)->GetSection()); break; case RES_FLTR_REDLINE: @@ -602,7 +603,9 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* break; default: if (pEntry->MakeRegion(pDoc, aRegion, FALSE)) - pDoc->Insert(aRegion, *pEntry->pAttr, 0); + { + pDoc->InsertPoolItem(aRegion, *pEntry->pAttr, 0); + } break; } } @@ -1006,7 +1009,7 @@ SwFltShell::~SwFltShell() SwFltShell& SwFltShell::operator << ( const String& rStr ) { ASSERT(eSubMode != Style, "char insert while in style-mode"); - GetDoc().Insert( *pPaM, rStr, true ); + GetDoc().InsertString( *pPaM, rStr ); return *this; } @@ -1043,7 +1046,7 @@ String SwFltShell::QuoteStr( const String& rIn ) SwFltShell& SwFltShell::operator << ( const sal_Unicode c ) { ASSERT( eSubMode != Style, "char insert while in style-mode"); - GetDoc().Insert( *pPaM, c ); + GetDoc().InsertString( *pPaM, c ); return *this; } @@ -1060,7 +1063,7 @@ SwFltShell& SwFltShell::AddError( const sal_Char* pErr ) SwSetExpField aFld( (SwSetExpFieldType*)pFT, String::CreateFromAscii( pErr )); //, VVF_INVISIBLE - GetDoc().Insert(*pPaM, SwFmtFld(aFld), 0); + GetDoc().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return *this; } @@ -1079,7 +1082,8 @@ void SwFltShell::NextParagraph() void SwFltShell::NextPage() { NextParagraph(); - GetDoc().Insert(*pPaM, SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); + GetDoc().InsertPoolItem(*pPaM, + SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); } SwFltShell& SwFltShell::AddGraphic( const String& rPicName ) @@ -1170,7 +1174,7 @@ SwFltShell& SwFltShell::EndItem( USHORT nAttrId ) SwFltShell& SwFltShell::operator << (const SwField& rField) { - GetDoc().Insert(*pPaM, SwFmtFld(rField), 0); + GetDoc().InsertPoolItem(*pPaM, SwFmtFld(rField), 0); return *this; } @@ -1931,7 +1935,7 @@ void SwFltShell::BeginFootnote() // Fussnoten im PMW uebernommen werden SwFmtFtn aFtn; - GetDoc().Insert(*pPaM, aFtn, 0); + GetDoc().InsertPoolItem(*pPaM, aFtn, 0); ASSERT(pSavedPos == NULL, "SwFltShell"); pSavedPos = new SwPosition(*pPaM->GetPoint()); pPaM->Move(fnMoveBackward, fnGoCntnt); @@ -2031,7 +2035,9 @@ SwPageDesc* SwFltShell::MakePageDesc(SwPageDesc* pFirstPageDesc) pNewPD->SetFollow(pNewPD); } else - GetDoc().Insert( *pPaM, SwFmtPageDesc( pNewPD ), 0 ); + { + GetDoc().InsertPoolItem( *pPaM, SwFmtPageDesc( pNewPD ), 0 ); + } pNewPD->WriteUseOn( // alle Seiten (UseOnPage)(nsUseOnPage::PD_ALL | nsUseOnPage::PD_HEADERSHARE | nsUseOnPage::PD_FOOTERSHARE)); return pNewPD; diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx index 98f2f6074349..499cc59e132a 100644 --- a/sw/source/filter/ww8/attributeoutputbase.hxx +++ b/sw/source/filter/ww8/attributeoutputbase.hxx @@ -449,9 +449,6 @@ protected: /// Sfx item RES_TXTATR_FTN virtual void TextFootnote_Impl( const SwFmtFtn& ) = 0; - /// Sfx item RES_TXTATR_HARDBLANK - virtual void TextHardBlank( const SwFmtHardBlank& ) = 0; - /// Sfx item RES_PARATR_LINESPACING void ParaLineSpacing( const SvxLineSpacingItem& ); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 537a881f76ad..0eb0284a701e 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2776,13 +2776,6 @@ void DocxAttributeOutput::FootnotesEndnotes( bool bFootnotes ) } -void DocxAttributeOutput::TextHardBlank( const SwFmtHardBlank& ) -{ -#if OSL_DEBUG_LEVEL > 0 - fprintf( stderr, "TODO DocxAttributeOutput::TextHardBlank()\n" ); -#endif -} - void DocxAttributeOutput::ParaLineSpacing_Impl( short nSpace, short /*nMulti*/ ) { if ( !m_pSpacingAttrList ) diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 71b1a452f440..a84c0f40284c 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -434,9 +434,6 @@ protected: /// Output the footnote/endnote reference (if there's one to output). void FootnoteEndnoteReference(); - /// Sfx item RES_TXTATR_HARDBLANK - virtual void TextHardBlank( const SwFmtHardBlank& ); - /// Sfx item RES_PARATR_LINESPACING virtual void ParaLineSpacing_Impl( short nSpace, short nMulti ); diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 8b8e153e49fd..2cbbb7943f37 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -344,9 +344,9 @@ xub_StrLen SwAttrIter::SearchNext( xub_StrLen nStartPos ) if( nPos >= nStartPos && nPos <= nMinPos ) nMinPos = nPos; } - else + if (pHt->HasDummyChar()) { - // Attr ohne Ende Laenge 1 wegen CH_TXTATR im Text + // pos + 1 because of CH_TXTATR in Text nPos = *pHt->GetStart() + 1; if( nPos >= nStartPos && nPos <= nMinPos ) nMinPos = nPos; @@ -545,13 +545,13 @@ void SwAttrIter::OutFlys(xub_StrLen nSwPos) bool SwAttrIter::IsTxtAttr( xub_StrLen nSwPos ) { - // search for attrs without end position + // search for attrs with CH_TXTATR if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints()) { for (USHORT i = 0; i < pTxtAttrs->Count(); ++i) { const SwTxtAttr* pHt = (*pTxtAttrs)[i]; - if( !pHt->GetEnd() && *pHt->GetStart() == nSwPos ) + if ( pHt->HasDummyChar() && (*pHt->GetStart() == nSwPos) ) return true; } } diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 8249c5d9b9c2..ebc6f1cb8a4d 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -109,7 +109,6 @@ #include <pagedesc.hxx> // for SwPageDesc #include <flddat.hxx> // for Date fields #include <ndtxt.hxx> // for Numrules -#include <fmthbsh.hxx> #include <swrect.hxx> #include <reffld.hxx> #include <ftninfo.hxx> @@ -3140,10 +3139,6 @@ void WW8AttributeOutput::ParaVerticalAlign( const SvxParaVertAlignItem& rAlign ) // NoHyphen: ich habe keine Entsprechung in der SW-UI und WW-UI gefunden -void WW8AttributeOutput::TextHardBlank( const SwFmtHardBlank& rHardBlank ) -{ - m_rWW8Export.WriteChar( rHardBlank.GetChar() ); -} // RefMark, NoLineBreakHere fehlen noch @@ -5155,9 +5150,6 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt ) case RES_TXTATR_FTN: TextFootnote( static_cast< const SwFmtFtn& >( rHt ) ); break; - case RES_TXTATR_HARDBLANK: - TextHardBlank( static_cast< const SwFmtHardBlank& >( rHt ) ); - break; case RES_PARATR_LINESPACING: ParaLineSpacing( static_cast< const SvxLineSpacingItem& >( rHt ) ); diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx index cff22353d60c..4968d88887dc 100644 --- a/sw/source/filter/ww8/ww8attributeoutput.hxx +++ b/sw/source/filter/ww8/ww8attributeoutput.hxx @@ -323,9 +323,6 @@ protected: /// Sfx item RES_TXTATR_FTN virtual void TextFootnote_Impl( const SwFmtFtn& ); - /// Sfx item RES_TXTATR_HARDBLANK - virtual void TextHardBlank( const SwFmtHardBlank& ); - /// Sfx item RES_PARATR_LINESPACING virtual void ParaLineSpacing_Impl( short nSpace, short nMulti ); diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx index 81d605457e9c..b0dabff56b2f 100644 --- a/sw/source/filter/ww8/ww8glsy.cxx +++ b/sw/source/filter/ww8/ww8glsy.cxx @@ -187,7 +187,7 @@ bool WW8Glossary::MakeEntries(SwDoc *pD, SwTextBlocks &rBlocks, -1 ); pCNd = aIdx.GetNode().GetCntntNode(); SwPosition aPos( aIdx, SwIndex( pCNd, pCNd->Len() )); - pD->Copy( aPam, aPos, false ); + pD->CopyRange( aPam, aPos, false ); rBlocks.PutDoc(); } } diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index af28c6c66704..241e339003d2 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -81,7 +81,6 @@ #include <fmtcntnt.hxx> #include <fmtcnct.hxx> #include <fmtpdsc.hxx> -#include <fmthbsh.hxx> #include <ftninfo.hxx> #include <fmtftn.hxx> #include <txtftn.hxx> @@ -954,7 +953,9 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, pFrm->SetFmtAttr(aURL); } else - pDoc->Insert(aRegion, *pEntry->pAttr, 0); + { + pDoc->InsertPoolItem(aRegion, *pEntry->pAttr, 0); + } } } break; @@ -1072,7 +1073,7 @@ void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos, SwTxtNode* pTxt = rBkMrkPos.nNode.GetNode().GetTxtNode(); if( pTxt && rBkMrkPos.nContent.GetIndex() ) { - SwTxtAttr* pFtn = pTxt->GetTxtAttr( + SwTxtAttr* const pFtn = pTxt->GetTxtAttrForCharAt( rBkMrkPos.nContent.GetIndex()-1, RES_TXTATR_FTN ); if( pFtn ) { @@ -1087,7 +1088,7 @@ void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos, } } - pDoc->Insert(aPaM, *pEntry->pAttr, 0); + pDoc->InsertPoolItem(aPaM, *pEntry->pAttr, 0); MoveAttrs(*aPaM.GetPoint()); } break; @@ -1627,7 +1628,7 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes) sTxt, aDate ); aPostIt.SetTextObject(pOutliner); - rDoc.Insert(*pPaM, SwFmtFld(aPostIt), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aPostIt), 0); return 0; } @@ -2516,7 +2517,7 @@ bool SwWW8ImplReader::AddTextToParagraph(const String& rAddString) */ if ((pNd->GetTxt().Len() + rAddString.Len()) < STRING_MAXLEN -1) { - rDoc.Insert (*pPaM, rAddString, true); + rDoc.InsertString(*pPaM, rAddString); } else { @@ -2525,16 +2526,16 @@ bool SwWW8ImplReader::AddTextToParagraph(const String& rAddString) { String sTempStr (rAddString,0, STRING_MAXLEN - pNd->GetTxt().Len() -1); - rDoc.Insert (*pPaM, sTempStr, true); + rDoc.InsertString(*pPaM, sTempStr); sTempStr = rAddString.Copy(sTempStr.Len(), rAddString.Len() - sTempStr.Len()); AppendTxtNode(*pPaM->GetPoint()); - rDoc.Insert (*pPaM,sTempStr, true ); + rDoc.InsertString(*pPaM, sTempStr); } else { AppendTxtNode(*pPaM->GetPoint()); - rDoc.Insert (*pPaM, rAddString, true); + rDoc.InsertString(*pPaM, rAddString); } } @@ -2555,7 +2556,9 @@ bool SwWW8ImplReader::ReadChars(WW8_CP& rPos, WW8_CP nNextAttr, long nTextEnd, if( bSymbol ) // Spezialzeichen einfuegen { for(USHORT nCh = 0; nCh < nEnd - rPos; ++nCh) - rDoc.Insert( *pPaM, cSymbol ); + { + rDoc.InsertString( *pPaM, cSymbol ); + } pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_FONT ); } pStrm->SeekRel( nEnd- rPos ); @@ -2636,7 +2639,7 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs) SwPageNumberField aFld( (SwPageNumberFieldType*)rDoc.GetSysFldType( RES_PAGENUMBERFLD ), PG_RANDOM, SVX_NUM_ARABIC); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); } break; case 0xe: @@ -2648,7 +2651,8 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs) { // Always insert a txtnode for a column break, e.g. ## AppendTxtNode(*pPaM->GetPoint()); - rDoc.Insert(*pPaM, SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK), 0); + rDoc.InsertPoolItem(*pPaM, + SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK), 0); } break; case 0x7: @@ -2699,14 +2703,14 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs) case 0xc: bRet = HandlePageBreakChar(); break; - case 0x1e: - rDoc.Insert( *pPaM, CHAR_HARDHYPHEN); // Non-breaking hyphen + case 0x1e: // Non-breaking hyphen + rDoc.InsertString( *pPaM, CHAR_HARDHYPHEN ); break; - case 0x1f: - rDoc.Insert( *pPaM, CHAR_SOFTHYPHEN); // Non-required hyphens + case 0x1f: // Non-required hyphens + rDoc.InsertString( *pPaM, CHAR_SOFTHYPHEN ); break; - case 0xa0: - rDoc.Insert( *pPaM, CHAR_HARDBLANK); // Non-breaking spaces + case 0xa0: // Non-breaking spaces + rDoc.InsertString( *pPaM, CHAR_HARDBLANK ); break; case 0x1: /* @@ -3164,7 +3168,8 @@ bool SwWW8ImplReader::ReadText(long nStartCp, long nTextLen, ManTypes nType) AppendTxtNode(*pPaM->GetPoint()); } // <-- - rDoc.Insert(*pPaM, SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); + rDoc.InsertPoolItem(*pPaM, + SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); bPgSecBreak = false; } } @@ -3398,7 +3403,7 @@ void GiveNodePageDesc(SwNodeIndex &rIdx, const SwFmtPageDesc &rPgDesc, rIdx.GetNode().GetCntntNode(), 0); SwPaM aPage(aPamStart); - rDoc.Insert(aPage, rPgDesc, 0); + rDoc.InsertPoolItem(aPage, rPgDesc, 0); } } diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index e578de63ca9b..7342843e6b9a 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -381,7 +381,7 @@ sal_uInt16 SwWW8ImplReader::End_Ftn() sChar.Append(pTxt->GetTxt().GetChar(--nPos)); pPaM->SetMark(); pPaM->GetMark()->nContent--; - rDoc.Delete( *pPaM ); + rDoc.DeleteRange( *pPaM ); pPaM->DeleteMark(); SwFmtFtn aFtn(rDesc.meType == MAN_EDN); pFN = pTxt->InsertItem(aFtn, nPos, nPos); @@ -435,7 +435,7 @@ sal_uInt16 SwWW8ImplReader::End_Ftn() pPaM->GetMark()->nContent++; pPaM->GetMark()->nContent++; pReffingStck->Delete(*pPaM); - rDoc.Delete( *pPaM ); + rDoc.DeleteRange( *pPaM ); pPaM->DeleteMark(); } } diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index de912778c17a..aa2737da1fa4 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -207,7 +207,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormTextBox( WW8FieldDesc* pF, String& rStr ) aFld.SetHelp(aFormula.sHelp); aFld.SetToolTip(aFormula.sToolTip); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } else { WW8PLCFx_Book* pB = pPlcxMan->GetBook(); @@ -321,7 +321,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormListBox( WW8FieldDesc* pF, String& rStr) aFld.SetSelectedItem(aFormula.maListEntries[nIndex]); } - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index b21fb17bcd02..f5f82d879aac 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -61,7 +61,6 @@ #include <svx/fhgtitem.hxx> #include <svx/langitem.hxx> #include <fmtfld.hxx> -#include <fmthbsh.hxx> #include <fmtanchr.hxx> #include <pam.hxx> // fuer SwPam #include <doc.hxx> @@ -1062,7 +1061,8 @@ void SwWW8ImplReader::InsertTagField( const USHORT nId, const String& rTagText ) if( SwFltGetFlag(nFieldFlags, SwFltControlStack::TAGS_IN_TEXT)) { aName += rTagText; // als Txt taggen - rDoc.Insert(*pPaM, aName, false); + rDoc.InsertString(*pPaM, aName, + IDocumentContentOperations::INS_NOHINTEXPAND); } else { // normal tagggen @@ -1073,7 +1073,7 @@ void SwWW8ImplReader::InsertTagField( const USHORT nId, const String& rTagText ) USHORT nSubType = ( SwFltGetFlag( nFieldFlags, SwFltControlStack::TAGS_VISIBLE ) ) ? 0 : nsSwExtendedSubType::SUB_INVISIBLE; aFld.SetSubType(nSubType | nsSwGetSetExpType::GSE_STRING); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); } } @@ -1133,7 +1133,7 @@ eF_ResT SwWW8ImplReader::Read_F_Input( WW8FieldDesc* pF, String& rStr ) SwInputField aFld( (SwInputFieldType*)rDoc.GetSysFldType( RES_INPUTFLD ), aDef, aQ, INP_TXT, 0 ); // sichtbar ( geht z.Zt. nicht anders ) - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1335,7 +1335,7 @@ eF_ResT SwWW8ImplReader::Read_F_InputVar( WW8FieldDesc* pF, String& rStr ) aFld.SetInputFlag(true); aFld.SetPromptText( aQ ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); pReffedStck->SetAttr(*pPaM->GetPoint(), RES_FLTR_BOOKMARK, true, nNo); return FLD_OK; @@ -1351,7 +1351,7 @@ eF_ResT SwWW8ImplReader::Read_F_ANumber( WW8FieldDesc*, String& rStr ) SwSetExpField aFld( (SwSetExpFieldType*)pNumFldType, aEmptyStr, GetNumberPara( rStr ) ); aFld.SetValue( ++nFldNum ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1427,7 +1427,7 @@ eF_ResT SwWW8ImplReader::Read_F_Seq( WW8FieldDesc*, String& rStr ) else if (!bCountOn) aFld.SetFormula(aSequenceName); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } @@ -1552,7 +1552,7 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, String& rStr ) */ SwDocInfoField aFld( (SwDocInfoFieldType*) rDoc.GetSysFldType( RES_DOCINFOFLD ), DI_CUSTOM|nReg, aDocProperty, GetFieldResult( pF ) ); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } @@ -1632,7 +1632,7 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, String& rStr ) rDoc.GetSysFldType( RES_DOCINFOFLD ), nSub|nReg, String(), nFormat ); if (bDateTime) ForceFieldLanguage(aFld, nLang); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } @@ -1645,7 +1645,7 @@ eF_ResT SwWW8ImplReader::Read_F_Author( WW8FieldDesc*, String& ) SwDocInfoField aFld( (SwDocInfoFieldType*) rDoc.GetSysFldType( RES_DOCINFOFLD ), DI_CREATE|DI_SUB_AUTHOR, String() ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1653,7 +1653,7 @@ eF_ResT SwWW8ImplReader::Read_F_TemplName( WW8FieldDesc*, String& ) { SwTemplNameField aFld( (SwTemplNameFieldType*) rDoc.GetSysFldType( RES_TEMPLNAMEFLD ), FF_NAME ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1708,14 +1708,14 @@ eF_ResT SwWW8ImplReader::Read_F_DateTime( WW8FieldDesc*pF, String& rStr ) SwDateTimeField aFld((SwDateTimeFieldType*) rDoc.GetSysFldType(RES_DATETIMEFLD ), DATEFLD, nFormat); ForceFieldLanguage(aFld, nLang); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); } else if (nDT == NUMBERFORMAT_TIME) { SwDateTimeField aFld((SwDateTimeFieldType*) rDoc.GetSysFldType(RES_DATETIMEFLD), TIMEFLD, nFormat); ForceFieldLanguage(aFld, nLang); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); } return FLD_OK; @@ -1745,7 +1745,7 @@ eF_ResT SwWW8ImplReader::Read_F_FileName(WW8FieldDesc*, String &rStr) SwFileNameField aFld( (SwFileNameFieldType*)rDoc.GetSysFldType(RES_FILENAMEFLD), eType); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } @@ -1759,7 +1759,7 @@ eF_ResT SwWW8ImplReader::Read_F_Anz( WW8FieldDesc* pF, String& rStr ) SwDocStatField aFld( (SwDocStatFieldType*) rDoc.GetSysFldType( RES_DOCSTATFLD ), nSub, GetNumberPara( rStr ) ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1771,7 +1771,7 @@ eF_ResT SwWW8ImplReader::Read_F_CurPage( WW8FieldDesc*, String& rStr ) SwChapterField aFld( (SwChapterFieldType*) rDoc.GetSysFldType( RES_CHAPTERFLD ), CF_NUMBER ); aFld.SetLevel( nPgChpLevel ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); static const sal_Char aDelim[] = "-.:\x97\x96"; BYTE nDelim = nPgChpDelim; @@ -1781,9 +1781,13 @@ eF_ResT SwWW8ImplReader::Read_F_CurPage( WW8FieldDesc*, String& rStr ) sal_Unicode c = ByteString::ConvertToUnicode( aDelim[ nDelim ], RTL_TEXTENCODING_MS_1252 ); if( '-' == c ) - rDoc.Insert( *pPaM, CHAR_HARDHYPHEN ); + { + rDoc.InsertString( *pPaM, CHAR_HARDHYPHEN ); + } else - rDoc.Insert( *pPaM, SwFmtHardBlank( c ), 0); + { + rDoc.InsertString( *pPaM, c ); // maybe insert ZWNBSP? + } } // Seitennummer @@ -1791,7 +1795,7 @@ eF_ResT SwWW8ImplReader::Read_F_CurPage( WW8FieldDesc*, String& rStr ) rDoc.GetSysFldType( RES_PAGENUMBERFLD ), PG_RANDOM, GetNumberPara(rStr, true)); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1850,7 +1854,7 @@ eF_ResT SwWW8ImplReader::Read_F_Symbol( WW8FieldDesc*, String& rStr ) NewAttr(aSz); } - rDoc.Insert(*pPaM, cChar); + rDoc.InsertString(*pPaM, cChar); if (nSize > 0) pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_CHRATR_FONTSIZE); @@ -1859,7 +1863,7 @@ eF_ResT SwWW8ImplReader::Read_F_Symbol( WW8FieldDesc*, String& rStr ) } else { - rDoc.Insert(*pPaM, CREATE_CONST_ASC("###"), true); + rDoc.InsertString(*pPaM, CREATE_CONST_ASC("###")); } return FLD_OK; @@ -1920,7 +1924,7 @@ eF_ResT SwWW8ImplReader::Read_F_Set( WW8FieldDesc* pF, String& rStr ) SwSetExpField aFld( (SwSetExpFieldType*)pFT, sVal, ULONG_MAX ); aFld.SetSubType(nsSwExtendedSubType::SUB_INVISIBLE | nsSwGetSetExpType::GSE_STRING); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); pReffedStck->SetAttr(*pPaM->GetPoint(), RES_FLTR_BOOKMARK, true, nNo); @@ -1970,7 +1974,7 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr ) SwGetRefField aFld( (SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ), sBkmName,REF_BOOKMARK,0,REF_CHAPTER); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); } else { @@ -1993,7 +1997,7 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr ) SwGetRefField aFld( (SwGetRefFieldType*) rDoc.GetSysFldType( RES_GETREFFLD ), sBkmName, REF_BOOKMARK, 0, REF_UPDOWN ); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); } return FLD_OK; } @@ -2070,7 +2074,7 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, String& rStr ) (SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ), sName, REF_BOOKMARK, 0, REF_PAGE ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -2119,7 +2123,7 @@ eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, String& rStr) SwMacroField aFld( (SwMacroFieldType*) rDoc.GetSysFldType( RES_MACROFLD ), aName, aVText ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); WW8_CP nOldCp = pPlcxMan->Where(); @@ -2280,7 +2284,7 @@ eF_ResT SwWW8ImplReader::Read_F_IncludeText( WW8FieldDesc* /*pF*/, String& rStr aSection.SetLinkFileName( aPara ); aSection.SetProtect(true); - SwSection* pSection = rDoc.Insert(*pPaM, aSection, 0 ,false); + SwSection*const pSection = rDoc.InsertSwSection(*pPaM, aSection, 0, false); ASSERT(pSection, "no section inserted"); if (!pSection) return FLD_TEXT; @@ -2327,7 +2331,7 @@ eF_ResT SwWW8ImplReader::Read_F_DBField( WW8FieldDesc* pF, String& rStr ) aFld.InitContent(aResult); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld( aFld ), 0); return FLD_OK; } @@ -2339,7 +2343,7 @@ eF_ResT SwWW8ImplReader::Read_F_DBNext( WW8FieldDesc*, String& ) SwFieldType* pFT = rDoc.InsertFldType( aN ); SwDBNextSetField aFld( (SwDBNextSetFieldType*)pFT, aEmptyStr, aEmptyStr, SwDBData() ); // Datenbank: Nichts - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -2350,7 +2354,7 @@ eF_ResT SwWW8ImplReader::Read_F_DBNum( WW8FieldDesc*, String& ) SwFieldType* pFT = rDoc.InsertFldType( aN ); SwDBSetNumberField aFld( (SwDBSetNumberFieldType*)pFT, SwDBData() ); // Datenbank: Nichts - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -2415,7 +2419,7 @@ void SwWW8ImplReader::Read_SubF_Combined( _ReadFieldParams& rReadParam) { SwCombinedCharField aFld((SwCombinedCharFieldType*) rDoc.GetSysFldType(RES_COMBINED_CHARS),sCombinedCharacters); - rDoc.Insert(*pPaM,SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); } } @@ -2573,7 +2577,7 @@ void SwWW8ImplReader::Read_SubF_Ruby( _ReadFieldParams& rReadParam) aRuby.SetAdjustment(nJustificationCode); NewAttr(aRuby); - rDoc.Insert( *pPaM, sText, true ); + rDoc.InsertString( *pPaM, sText ); pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_TXTATR_CJK_RUBY ); } } @@ -3423,7 +3427,7 @@ void lcl_ImportTox(SwDoc &rDoc, SwPaM &rPaM, const String &rStr, bool bIdx) if (sFldTxt.Len()) { aM.SetAlternativeText( sFldTxt ); - rDoc.Insert( rPaM, aM, 0 ); + rDoc.InsertPoolItem( rPaM, aM, 0 ); } } diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index c01991b51343..978834f3345e 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -698,7 +698,8 @@ SwSectionFmt *wwSectionManager::InsertSection( aSection.SetProtect(SectionIsProtected(rSection)); - rSection.mpSection = mrReader.rDoc.Insert( rMyPaM, aSection, &aSet ); + rSection.mpSection = + mrReader.rDoc.InsertSwSection( rMyPaM, aSection, &aSet ); ASSERT(rSection.mpSection, "section not inserted!"); if (!rSection.mpSection) return 0; @@ -851,7 +852,7 @@ void wwSectionManager::CreateSep(const long nTxtPos, bool /*bMustHaveBreak*/) aSection.SetProtect(true); // --> CMC, OD 2004-06-18 #i19922# improvement: // return value of method <Insert> not used. - mrReader.rDoc.Insert(*mrReader.pPaM, aSection, 0 ,false); + mrReader.rDoc.InsertSwSection(*mrReader.pPaM, aSection, 0, false); } wwSection aLastSection(*mrReader.pPaM->GetPoint()); @@ -3217,7 +3218,7 @@ SwFrmFmt *SwWW8ImplReader::ContainsSingleInlineGraphic(const SwPaM &rRegion) if ( aBegin == aEnd && nBegin == nEnd - 1 && 0 != (pTNd = aBegin.GetNode().GetTxtNode()) && - 0 != (pTFlyAttr = pTNd->GetTxtAttr(nBegin, RES_TXTATR_FLYCNT)) + 0 != (pTFlyAttr = pTNd->GetTxtAttrForCharAt(nBegin, RES_TXTATR_FLYCNT)) ) { const SwFmtFlyCnt& rFly = pTFlyAttr->GetFlyCnt(); diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index 2cb78f0bae4c..7e3187a4a948 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -646,7 +646,7 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo) // delete 'deleted' redlines and forget about the whole thing if (nsRedlineType_t::REDLINE_DELETE == pRedlineInfo->eType) { - pDoc->Delete(aPaM); + pDoc->DeleteRange(aPaM); // And what about the "deleted nodes"? // They have to be deleted as well (#i80689)! if( bIgnoreRedlines && pRedlineInfo->pContentIndex != NULL ) @@ -657,7 +657,7 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo) { SwNodeIndex aEnd( *pEnd, 1 ); SwPaM aDel( aIdx, aEnd ); - pDoc->Delete(aDel); + pDoc->DeleteRange(aDel); } } } diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index abe69df298d6..2060b3833e47 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -873,35 +873,39 @@ ULONG XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const S // <-- sal_uInt32 nWarnRDF = 0; - // RDF metadata - must be read before styles/content - // N.B.: embedded documents have their own manifest.rdf! - try - { - const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(xModelComp, - uno::UNO_QUERY_THROW); - const uno::Reference<rdf::XURI> xBaseURI( ::sfx2::createBaseURI( - aContext.getUNOContext(), xStorage, aBaseURL, StreamPath) ); - const uno::Reference<task::XInteractionHandler> xHandler( - pDocSh->GetMedium()->GetInteractionHandler() ); - xDMA->loadMetadataFromStorage(xStorage, xBaseURI, xHandler); - } - catch (lang::WrappedTargetException & e) + if ( !(IsOrganizerMode() || IsBlockMode() || aOpt.IsFmtsOnly() || + bInsertMode) ) { - ucb::InteractiveAugmentedIOException iaioe; - if (e.TargetException >>= iaioe) + // RDF metadata - must be read before styles/content + // N.B.: embedded documents have their own manifest.rdf! + try { - // import error that was not ignored by InteractionHandler! - nWarnRDF = ERR_SWG_READ_ERROR; + const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(xModelComp, + uno::UNO_QUERY_THROW); + const uno::Reference<rdf::XURI> xBaseURI( ::sfx2::createBaseURI( + aContext.getUNOContext(), xStorage, aBaseURL, StreamPath) ); + const uno::Reference<task::XInteractionHandler> xHandler( + pDocSh->GetMedium()->GetInteractionHandler() ); + xDMA->loadMetadataFromStorage(xStorage, xBaseURI, xHandler); } - else + catch (lang::WrappedTargetException & e) + { + ucb::InteractiveAugmentedIOException iaioe; + if (e.TargetException >>= iaioe) + { + // import error that was not ignored by InteractionHandler! + nWarnRDF = ERR_SWG_READ_ERROR; + } + else + { + nWarnRDF = WARN_SWG_FEATURES_LOST; // uhh... something wrong? + } + } + catch (uno::Exception &) { nWarnRDF = WARN_SWG_FEATURES_LOST; // uhh... something went wrong? } } - catch (uno::Exception &) - { - nWarnRDF = WARN_SWG_FEATURES_LOST; // uhh... something went wrong? - } sal_uInt32 nWarn = 0; sal_uInt32 nWarn2 = 0; diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index a25bfbb45659..b71812df6774 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -699,7 +699,7 @@ void SwXMLTableCellContext_Impl::EndElement() SwPaM aSrcPaM( *pSrcPaM->GetPoint(), *pSrcPaM->GetMark() ); SwPosition aDstPos( *pDstTxtCrsr->GetPaM()->GetPoint() ); - pDoc->Copy( aSrcPaM, aDstPos, false ); + pDoc->CopyRange( aSrcPaM, aDstPos, false ); nColRepeat--; } diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index 07e9b0a0eec0..cb815a93f1a6 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -1131,7 +1131,9 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, for( n = 0; n < nCols; ++n ) { if( aRbHeadlColnms.IsChecked() ) - rSh.SwEditShell::Insert( aColFlds[ n ]->sColumn ); + { + rSh.SwEditShell::Insert2( aColFlds[ n ]->sColumn ); + } rSh.GoNextCell(); } } @@ -1227,7 +1229,9 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, { rtl::OUString sVal = xColumn->getString(); if(!xColumn->wasNull()) - rSh.SwEditShell::Insert( sVal ); + { + rSh.SwEditShell::Insert2( sVal ); + } } } catch(Exception& diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index af339ac79181..202df0a8e027 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -701,7 +701,7 @@ void SwNewDBMgr::ImportDBEntry(SwWrtShell* pSh) if (i < nLength - 1) sStr += '\t'; } - pSh->SwEditShell::Insert(sStr); + pSh->SwEditShell::Insert2(sStr); pSh->SwFEShell::SplitNode(); // Zeilenvorschub } } diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx index ea6ab45f4ec1..f3dc55f26f4d 100644 --- a/sw/source/ui/dochdl/swdtflvr.cxx +++ b/sw/source/ui/dochdl/swdtflvr.cxx @@ -3778,6 +3778,7 @@ BOOL SwTrnsfrDdeLink::WriteData( SvStream& rStrm ) // remove mark pServerObject->SetNoServer(); // this removes the connection between SwServerObject and mark + // N.B. ppMark was not loaded from file and cannot have xml:id pMarkAccess->deleteMark(ppMark); // recreate as Bookmark diff --git a/sw/source/ui/docvw/postit.cxx b/sw/source/ui/docvw/postit.cxx index a3e33ebda7da..e693f87e7a35 100644 --- a/sw/source/ui/docvw/postit.cxx +++ b/sw/source/ui/docvw/postit.cxx @@ -1667,7 +1667,8 @@ bool SwPostIt::CalcFollow() SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld(); SwPosition aPosition( pTxtFld->GetTxtNode() ); aPosition.nContent = *pTxtFld->GetStart(); - SwTxtAttr* pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttr( aPosition.nContent.GetIndex()-1,RES_TXTATR_FIELD ); + SwTxtAttr * const pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt( + aPosition.nContent.GetIndex() - 1, RES_TXTATR_FIELD ); const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0; return pFld && (pFld->Which()== RES_POSTITFLD); } @@ -1680,12 +1681,14 @@ sal_uInt32 SwPostIt::CountFollowing() SwPosition aPosition( pTxtFld->GetTxtNode() ); aPosition.nContent = *pTxtFld->GetStart(); - SwTxtAttr* pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttr( aPosition.nContent.GetIndex()+1,RES_TXTATR_FIELD ); + SwTxtAttr * pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt( + aPosition.nContent.GetIndex() + 1, RES_TXTATR_FIELD ); SwField* pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0; while (pFld && (pFld->Which()== RES_POSTITFLD)) { aCount++; - pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttr( aPosition.nContent.GetIndex() + aCount,RES_TXTATR_FIELD ); + pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt( + aPosition.nContent.GetIndex() + aCount, RES_TXTATR_FIELD ); pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0; } return aCount - 1; diff --git a/sw/source/ui/ribbar/inputwin.cxx b/sw/source/ui/ribbar/inputwin.cxx index c8422f665b7d..07745f3c01bb 100644 --- a/sw/source/ui/ribbar/inputwin.cxx +++ b/sw/source/ui/ribbar/inputwin.cxx @@ -461,8 +461,8 @@ IMPL_LINK( SwInputWindow, SelTblCellsNotify, SwWrtShell *, pCaller ) aPam.Move( fnMoveForward, fnGoSection ); IDocumentContentOperations* pIDCO = pWrtShell->getIDocumentContentOperations(); - pIDCO->Delete( aPam ); - pIDCO->Insert( aPam, sNew, true ); + pIDCO->DeleteRange( aPam ); + pIDCO->InsertString( aPam, sNew ); pWrtShell->EndAllAction(); sOldFml = sNew; } @@ -499,7 +499,7 @@ IMPL_LINK( SwInputWindow, ModifyHdl, InputEdit*, EMPTYARG ) sNew += CH_LRE; sNew += aEdit.GetText(); sNew += CH_PDF; - pWrtShell->SwEditShell::Insert( sNew ); + pWrtShell->SwEditShell::Insert2( sNew ); pWrtShell->EndAllAction(); sOldFml = sNew; } diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index 0c67e24b8d10..2b302245f53b 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -416,7 +416,8 @@ sal_Bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextR if(pxCursor) { SwPaM* pUnoCrsr = pxCursor->GetPaM(); - bRet |= (true == pxCursor->GetDoc()->Copy( *pUnoCrsr, aPos, false )); + bRet = pxCursor->GetDoc()->CopyRange( *pUnoCrsr, aPos, false ) + || bRet; } else { @@ -424,7 +425,8 @@ sal_Bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextR if(pBkmk && pBkmk->IsExpanded()) { SwPaM aTmp(pBkmk->GetOtherMarkPos(), pBkmk->GetMarkPos()); - bRet |= (true == pxRange->GetDoc()->Copy(aTmp, aPos, false)); + bRet = pxRange->GetDoc()->CopyRange(aTmp, aPos, false) + || bRet; } } } diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx index 84785802c2c3..cd6bb82739ca 100644 --- a/sw/source/ui/wrtsh/wrtsh1.cxx +++ b/sw/source/ui/wrtsh/wrtsh1.cxx @@ -70,7 +70,6 @@ #include <svx/extrusionbar.hxx> #include <svx/fontworkbar.hxx> #include <fmtftn.hxx> -#include <fmthbsh.hxx> #include <fmtpdsc.hxx> #ifndef _WDOCSH_HXX #include <wdocsh.hxx> @@ -245,6 +244,7 @@ void SwWrtShell::Insert( const String &rStr ) BOOL bStarted = FALSE, bHasSel = HasSelection(), bCallIns = bIns /*|| bHasSel*/; + bool bDeleted = false; if( bHasSel || ( !bIns && SelectHiddenRange() ) ) { @@ -268,7 +268,7 @@ void SwWrtShell::Insert( const String &rStr ) StartUndo(UNDO_REPLACE, &aRewriter); bStarted = TRUE; - DelRight(); + bDeleted = DelRight() != 0; } /* @@ -283,7 +283,8 @@ JP 21.01.98: Ueberschreiben ueberschreibt nur die Selektion, nicht das } else */ - bCallIns ? SwEditShell::Insert( rStr ) : SwEditShell::Overwrite( rStr ); + bCallIns ? + SwEditShell::Insert2( rStr, bDeleted ) : SwEditShell::Overwrite( rStr ); if( bStarted ) diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx index 42cfb1c3d64d..9141279f141b 100644 --- a/sw/source/ui/wrtsh/wrtsh2.cxx +++ b/sw/source/ui/wrtsh/wrtsh2.cxx @@ -93,10 +93,13 @@ void SwWrtShell::Insert(SwField &rFld) StartUndo(UNDO_INSERT, &aRewriter); + bool bDeleted = false; if( HasSelection() ) - DelRight(); + { + bDeleted = DelRight() != 0; + } - SwEditShell::Insert(rFld); + SwEditShell::Insert2(rFld, bDeleted); EndUndo(UNDO_INSERT); EndAllAction(); } |