diff options
268 files changed, 7003 insertions, 5440 deletions
diff --git a/starmath/prj/build.lst b/starmath/prj/build.lst index 1f9be53b5b2e..cb6fd9358454 100644 --- a/starmath/prj/build.lst +++ b/starmath/prj/build.lst @@ -1,4 +1,4 @@ -sm starmath : svx NULL +sm starmath : l10n svx NULL sm starmath usr1 - all sm_mkout NULL sm starmath\inc nmake - all sm_inc NULL sm starmath\prj get - all sm_prj NULL diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index 7e8e97340919..33fa49bdb4ef 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -815,7 +815,7 @@ BOOL SmDocShell::Load( SfxMedium& rMedium ) BOOL bRet = FALSE; if( SfxObjectShell::Load( rMedium )) { - uno::Reference < embed::XStorage > xStorage = pMedium->GetStorage(); + uno::Reference < embed::XStorage > xStorage = GetMedium()->GetStorage(); uno::Reference < container::XNameAccess > xAccess (xStorage, uno::UNO_QUERY); if ( ( @@ -833,7 +833,7 @@ BOOL SmDocShell::Load( SfxMedium& rMedium ) SmXMLImportWrapper aEquation(xModel); ULONG nError = aEquation.Import(rMedium); bRet = 0 == nError; - SetError( nError ); + SetError( nError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); } } diff --git a/starmath/source/smdetect.cxx b/starmath/source/smdetect.cxx index b9c6bc2e913e..66746afea728 100644 --- a/starmath/source/smdetect.cxx +++ b/starmath/source/smdetect.cxx @@ -226,7 +226,7 @@ SmFilterDetect::~SmFilterDetect() // error during storage creation means _here_ that the medium // is broken, but we can not handle it in medium since unpossibility // to create a storage does not _always_ means that the medium is broken - aMedium.SetError( aMedium.GetLastStorageCreationState() ); + aMedium.SetError( aMedium.GetLastStorageCreationState(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); if ( xInteraction.is() ) { OUString empty; diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx index 0bf2b7ed47dd..ed6e5b6bd23f 100644 --- a/starmath/source/unomodel.cxx +++ b/starmath/source/unomodel.cxx @@ -862,30 +862,6 @@ sal_Int32 SAL_CALL SmModel::getRendererCount( return 1; } - -static Size lcl_GuessPaperSize() -{ - Size aRes; - Reference< XMultiServiceFactory > xMgr( getProcessServiceFactory() ); - LocaleDataWrapper aLocWrp( xMgr, AllSettings().GetLocale() ); - if( MEASURE_METRIC == aLocWrp.getMeasurementSystemEnum() ) - { - // in Twip - aRes.Width() = lA4Width; - aRes.Height() = lA4Height; - } - else - { - // in Twip - aRes.Width() = lLetterWidth; - aRes.Height() = lLetterHeight; - } - aRes = OutputDevice::LogicToLogic( aRes, MapMode(MAP_TWIP), - MapMode(MAP_100TH_MM) ); - return aRes; -} - - uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer( sal_Int32 nRenderer, const uno::Any& /*rSelection*/, @@ -909,7 +885,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer( // if paper size is 0 (usually if no 'real' printer is found), // guess the paper size if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0) - aPrtPaperSize = lcl_GuessPaperSize(); + aPrtPaperSize = SvxPaperInfo::GetDefaultPaperSize(MAP_100TH_MM); awt::Size aPageSize( aPrtPaperSize.Width(), aPrtPaperSize.Height() ); uno::Sequence< beans::PropertyValue > aRenderer(1); @@ -978,7 +954,7 @@ void SAL_CALL SmModel::render( // no real printer ?? if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0) { - aPrtPaperSize = lcl_GuessPaperSize(); + aPrtPaperSize = SvxPaperInfo::GetDefaultPaperSize(MAP_100TH_MM); // factors from Windows DIN A4 aOutputSize = Size( (long)(aPrtPaperSize.Width() * 0.941), (long)(aPrtPaperSize.Height() * 0.961)); diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx index 40f96985d6aa..55a0ca4082f1 100644 --- a/sw/inc/IDocumentContentOperations.hxx +++ b/sw/inc/IDocumentContentOperations.hxx @@ -71,7 +71,7 @@ /** Kopieren eines Bereiches im oder in ein anderes Dokument ! Die Position kann auch im Bereich liegen !! */ - virtual bool Copy(SwPaM&, SwPosition&) const = 0; + virtual bool Copy(SwPaM&, SwPosition&, bool bCopyAll ) const = 0; /** Loesche die Section, in der der Node steht. */ diff --git a/sw/inc/authfld.hxx b/sw/inc/authfld.hxx index 516958cefa23..1b209ac0b47c 100644 --- a/sw/inc/authfld.hxx +++ b/sw/inc/authfld.hxx @@ -118,7 +118,7 @@ public: void GetAllEntryIdentifiers( SvStringsDtor& rToFill )const; const SwAuthEntry* GetEntryByIdentifier(const String& rIdentifier)const; - void ChangeEntryContent(const SwAuthEntry* pNewEntry); + bool ChangeEntryContent(const SwAuthEntry* pNewEntry); // import interface USHORT AppendField(const SwAuthEntry& rInsert); long GetHandle(USHORT nPos); diff --git a/sw/inc/authratr.hxx b/sw/inc/authratr.hxx index ab9abbb4756f..84fb0d6fbb5b 100644 --- a/sw/inc/authratr.hxx +++ b/sw/inc/authratr.hxx @@ -42,7 +42,7 @@ class SW_DLLPUBLIC AuthorCharAttr public: USHORT nItemId; USHORT nAttr; - ULONG nColor; + ColorData nColor; AuthorCharAttr(); diff --git a/sw/inc/bookmrk.hxx b/sw/inc/bookmrk.hxx new file mode 100644 index 000000000000..3b459f61c081 --- /dev/null +++ b/sw/inc/bookmrk.hxx @@ -0,0 +1,218 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: bookmrk.hxx,v $ + * $Revision: 1.11 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _BOOKMRK_HXX +#define _BOOKMRK_HXX + +#include "hintids.hxx" //die Ids der Attribute, vor macitem damit die + //die Attribut richtig angezogen werden. +#include <svtools/macitem.hxx> + +#ifndef _KEYCOD_HXX //autogen +#include <vcl/keycod.hxx> +#endif +#ifndef _TOOLS_REF_HXX +#include <tools/ref.hxx> +#endif +#include <IDocumentBookmarkAccess.hxx> +#include <calbck.hxx> +#include <pam.hxx> + +#ifndef SW_DECL_SWSERVEROBJECT_DEFINED +#define SW_DECL_SWSERVEROBJECT_DEFINED +SV_DECL_REF( SwServerObject ) +#endif + + +struct SwPosition; // fwd Decl. wg. UI + +class SwBookmark : public SwModify +{ + SwPosition *pPos1, *pPos2; // wird im CTOR gesetzt, im DTOR geloescht + // pPos1 is always != 0, pPos2 may be 0 + SwServerObjectRef refObj; // falls DataServer -> Pointer gesetzt + +protected: + String aName; + String aShortName; + KeyCode aCode; + IDocumentBookmarkAccess::BookmarkType eMarkType; + + SwBookmark( const SwPosition& aPos, + const KeyCode& rCode, + const String& rName, const String& rShortName); + +public: + TYPEINFO(); + + SwBookmark( const SwPosition& aPos ); + // --> OD 2007-09-26 #i81002# + SwBookmark( const SwPaM& aPaM, + const KeyCode& rCode, + const String& rName, const String& rShortName); + // <-- + + // Beim Loeschen von Text werden Bookmarks mitgeloescht! + virtual ~SwBookmark(); + + // --> OD 2007-10-10 #i81002# + // made virtual and thus no longer inline + virtual const SwPosition& GetBookmarkPos() const; + virtual const SwPosition* GetOtherBookmarkPos() const; + // <-- + + // nicht undofaehig + const String& GetName() const { return aName; } + // nicht undofaehig + const String& GetShortName() const { return aShortName; } + // nicht undofaehig + const KeyCode& GetKeyCode() const { return aCode; } + + // Vergleiche auf Basis der Dokumentposition + BOOL operator < (const SwBookmark &) const; + BOOL operator ==(const SwBookmark &) const; + // falls man wirklich auf gleiche Position abfragen will. + BOOL IsEqualPos( const SwBookmark &rBM ) const; + + BOOL IsFormFieldMark() const { return IDocumentBookmarkAccess::FORM_FIELDMARK_TEXT == eMarkType || IDocumentBookmarkAccess::FORM_FIELDMARK_NO_TEXT == eMarkType; } + BOOL IsBookMark() const { return IDocumentBookmarkAccess::BOOKMARK == eMarkType || IDocumentBookmarkAccess::FORM_FIELDMARK_TEXT == eMarkType || IDocumentBookmarkAccess::FORM_FIELDMARK_NO_TEXT == eMarkType; } +// // --> OD 2007-10-17 #TESTING# +// BOOL IsBookMark() const +// { +// return IDocumentBookmarkAccess::BOOKMARK == eMarkType || +// IsCrossRefMark(); +// } +// // <-- + BOOL IsMark() const { return IDocumentBookmarkAccess::MARK == eMarkType; } + BOOL IsUNOMark() const { return IDocumentBookmarkAccess::UNO_BOOKMARK == eMarkType; } + // --> OD 2007-10-11 #i81002# - bookmark type for cross-references + BOOL IsCrossRefMark() const { return IDocumentBookmarkAccess::CROSSREF_BOOKMARK == eMarkType; } + // <-- + void SetType( IDocumentBookmarkAccess::BookmarkType eNewType ) { eMarkType = eNewType; } + IDocumentBookmarkAccess::BookmarkType GetType() const { return eMarkType; } + + // Daten Server-Methoden + void SetRefObject( SwServerObject* pObj ); + const SwServerObject* GetObject() const { return &refObj; } + SwServerObject* GetObject() { return &refObj; } + BOOL IsServer() const { return refObj.Is(); } + + // --> OD 2007-10-10 #i81002# + // made virtual and thus no longer inline + // to access start and end of a bookmark. + // start and end may be the same + virtual const SwPosition* BookmarkStart() const; + virtual const SwPosition* BookmarkEnd() const; + // <-- + + // --> OD 2007-09-26 #i81002# + virtual void SetBookmarkPos( const SwPosition* pNewPos1 ); + virtual void SetOtherBookmarkPos( const SwPosition* pNewPos2 ); + // <-- + +private: + // fuer METWARE: + // es wird (vorerst) nicht kopiert und nicht zugewiesen + SwBookmark(const SwBookmark &); + SwBookmark &operator=(const SwBookmark &); +}; + +class SwMark: public SwBookmark +{ +public: + SwMark( const SwPosition& aPos, + const KeyCode& rCode, + const String& rName, const String& rShortName); +}; + +class SW_DLLPUBLIC SwFieldBookmark : public SwBookmark +{ +private: + int fftype; // Type: 0 = Text, 1 = Check Box, 2 = List + int ffres; + bool ffprot; + bool ffsize; // 0 = Auto, 1=Exact (see ffhps) + int fftypetxt; // Type of text field: 0 = Regular text, 1 = Number, 2 = Date, 3 = Current date, 4 = Current time, 5 = Calculation + bool ffrecalc; + int ffmaxlen; // Number of characters for text field. Zero means unlimited. + int ffhps; // Check box size (half-point sizes). + + String ffname; + String ffhelptext; + +public: + SwFieldBookmark(const SwPosition& aPos, + const KeyCode& rCode, + const String& rName, const String& rShortName, + IDocumentBookmarkAccess::BookmarkType eMark); + + void SetFieldType(int fftype); + int GetFieldType(); + + void SetChecked(bool checked); + bool IsChecked(); + + void SetFFName(String aNewName) { + this->ffname=aNewName; + } + + String GetFFName() + { + return ffname; + } + + int GetFFRes() { + return ffres; + } + + void SetFFRes(int nNew) { + this->ffres=nNew; + } + + void SetFFHelpText(String newffhelptext) { + this->ffhelptext=newffhelptext; + } + + String GetFFHelpText() { + return ffhelptext; + } +}; + +class SwUNOMark: public SwBookmark +{ +public: + // --> OD 2007-09-26 #i81002# + SwUNOMark( const SwPaM& aPaM, + const KeyCode& rCode, + const String& rName, const String& rShortName); + // <-- +}; + + +#endif diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index ac64dcb85510..1fab6f1d15d4 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -155,7 +155,6 @@ Achtung: Ab sofort sind in diesem File keine C++-Kommentare (//) mehr #define FN_PASTE (FN_EDIT + 13) /* Einfuegen */ #define FN_PASTESPECIAL (FN_EDIT + 14) /* Verknuepfung einfuegen */ #define FN_PASTESPECIAL_DLG (FN_EDIT + 15) /* Verknuepfung einfuegen */ - #define FN_NUMBER_BULLETS (FN_EDIT + 21) /* Bullets */ #define FN_REPEAT (FN_EDIT + 22) /* Letzten Befehl wiederholen */ #define FN_EDIT_IDX_ENTRY_DLG (FN_EDIT + 23) /* Index-Entry bearbeiten */ diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx index be39d837e97b..e1f20183deca 100644 --- a/sw/inc/dcontact.hxx +++ b/sw/inc/dcontact.hxx @@ -346,7 +346,6 @@ class SwDrawVirtObj : public SdrVirtObj // #108784# // All overloaded methods which need to use the offset virtual void RecalcBoundRect(); - virtual SdrObject* CheckHit(const Point& rPnt, USHORT nTol, const SetOfByte* pVisiLayer) const; virtual ::basegfx::B2DPolyPolygon TakeXorPoly() const; virtual ::basegfx::B2DPolyPolygon TakeContour() const; virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const; diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index a82ea0235359..9784f43dfe94 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -32,45 +32,23 @@ /** SwDoc interfaces */ -#ifndef IINTERFACE_HXX_INCLUDED #include <IInterface.hxx> -#endif #include <IDocumentSettingAccess.hxx> -#ifndef IDOCUMENTDEVICEACCESS_HXX_INCLUDED #include <IDocumentDeviceAccess.hxx> -#endif #include <IDocumentMarkAccess.hxx> -#ifndef IREDLINEACCESS_HXX_INCLUDED #include <IDocumentRedlineAccess.hxx> -#endif #include <IDocumentUndoRedo.hxx> #include <IDocumentLinksAdministration.hxx> #include <IDocumentFieldsAccess.hxx> -#ifndef IDOCUMENTCONTENTOPERATIONS_HXX_INCLUDED #include <IDocumentContentOperations.hxx> -#endif -#ifndef IDOCUMENTSTYLEPOOLACCESS_HXX_INCLUDED #include <IDocumentStylePoolAccess.hxx> -#endif -#ifndef IDOCUMENTLINENUMBERACCESS_HXX_INCLUDED #include <IDocumentLineNumberAccess.hxx> -#endif -#ifndef IDOCUMENTSTATISTICS_HXX_INCLUDED #include <IDocumentStatistics.hxx> -#endif -#ifndef IDOCUMENTSTATE_HXX_INCLUDED #include <IDocumentState.hxx> -#endif -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include <IDocumentDrawModelAccess.hxx> -#endif #include <IDocumentLayoutAccess.hxx> -#ifndef IDOCUMENTTIMERACCESS_HXX_INCLUDED #include <IDocumentTimerAccess.hxx> -#endif -#ifndef IDOCUMENTCHARTDATAPROVIDER_HXX_INCLUDED #include <IDocumentChartDataProviderAccess.hxx> -#endif // --> OD 2007-10-26 #i83479# #include <IDocumentOutlineNodes.hxx> #include <IDocumentListItems.hxx> @@ -92,15 +70,11 @@ class SwList; #include <toxe.hxx> // enums #include <flyenum.hxx> #include <itabenum.hxx> -#ifndef _SWDBDATA_HXXnLinkCt #include <swdbdata.hxx> -#endif #include <chcmprse.hxx> #include <com/sun/star/linguistic2/XSpellChecker1.hpp> #include <com/sun/star/linguistic2/XHyphenatedWord.hpp> -#ifndef _VOS_REF_HXX #include <vos/ref.hxx> -#endif #include <svx/svdtypes.hxx> #include <svtools/style.hxx> #include <svx/numitem.hxx> @@ -113,6 +87,7 @@ class SwList; #include <svtools/embedhlp.hxx> #include <vector> +#include <memory> #include <boost/scoped_ptr.hpp> @@ -258,6 +233,7 @@ namespace container { namespace sfx2 { class SvLinkSource; + class IXmlIdRegistry; } //PageDescriptor-Schnittstelle, Array hier wegen inlines. @@ -433,6 +409,8 @@ private: tImplSortedNodeNumList* mpListItemsList; // <-- + ::std::auto_ptr< ::sfx2::IXmlIdRegistry > m_pXmlIdRegistry; + // ------------------------------------------------------------------- // sonstige sal_uInt16 nUndoPos; // akt. Undo-InsertPosition (fuers Redo!) @@ -502,7 +480,6 @@ private: bool mbPurgeOLE : 1; // TRUE: Purge OLE-Objects bool mbKernAsianPunctuation : 1; // TRUE: kerning also for ASIAN punctuation bool mbReadlineChecked : 1; // TRUE: if the query was already shown - bool mbWinEncryption : 1; // imported document password encrypted? bool mbLinksUpdated : 1; // OD 2005-02-11 #i38810# // flag indicating, that the links have been updated. bool mbClipBoard : 1; // true: this document represents the clipboard @@ -638,7 +615,7 @@ private: // 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, SwPaM* pCpyRng = 0 ) const; // in ndcopy.cxx + sal_Bool MakeNewFrms /*= sal_True*/, bool bCopyAll, SwPaM* pCpyRng /*= 0*/ ) const; // in ndcopy.cxx SwFlyFrmFmt* _MakeFlySection( const SwPosition& rAnchPos, const SwCntntNode& rNode, RndStdIds eRequestId, @@ -650,7 +627,8 @@ private: const SfxItemSet* pGrfAttrSet, SwFrmFmt* = 0 ); - void _CopyFlyInFly( const SwNodeRange& rRg, const SwNodeIndex& rSttIdx, + void _CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, + const SwNodeIndex& rSttIdx, sal_Bool bCopyFlyAtFly = sal_False ) const; // steht im ndcopy.cxx sal_Int8 SetFlyFrmAnchor( SwFrmFmt& rFlyFmt, SfxItemSet& rSet, sal_Bool bNewFrms ); @@ -722,6 +700,8 @@ private: SwFmt *_MakeFrmFmt(const String &, SwFmt *, BOOL, BOOL ); SwFmt *_MakeTxtFmtColl(const String &, SwFmt *, BOOL, BOOL ); + void InitTOXTypes(); + void Paste( const SwDoc& ); public: /** Life cycle @@ -898,7 +878,7 @@ public: /** IDocumentContentOperations */ - virtual bool Copy(SwPaM&, SwPosition&) const; + virtual bool Copy(SwPaM&, SwPosition&, bool bCopyAll) const; virtual void DeleteSection(SwNode* pNode); virtual bool Delete(SwPaM&); virtual bool DelFullPara(SwPaM&); @@ -1101,6 +1081,7 @@ public: SwFrmFmt *pParent = 0 ); void CopyWithFlyInFly( const SwNodeRange& rRg, + const xub_StrLen nEndContentIndex, const SwNodeIndex& rInsPos, sal_Bool bMakeNewFrms = sal_True, sal_Bool bDelRedlines = sal_True, @@ -1121,9 +1102,9 @@ public: void SetEndNoteInfo(const SwEndNoteInfo& rInfo); SwFtnIdxs& GetFtnIdxs() { return *pFtnIdxs; } const SwFtnIdxs& GetFtnIdxs() const { return *pFtnIdxs; } - // Fussnoten im Bereich aendern - sal_Bool SetCurFtn( const SwPaM& rPam, const String& rNumStr, - sal_uInt16 nNumber, sal_Bool bIsEndNote ); + // change footnotes in area + bool SetCurFtn( const SwPaM& rPam, const String& rNumStr, + sal_uInt16 nNumber, bool bIsEndNote ); /** Operations on the content of the document e.g. spell-checking/hyphenating/word-counting @@ -1437,6 +1418,7 @@ public: void SetInReading( bool bNew ) { mbInReading = bNew; } bool IsClipBoard() const { return mbClipBoard; } + // N.B.: must be called right after constructor! (@see GetXmlIdRegistry) void SetClipBoard( bool bNew ) { mbClipBoard = bNew; } bool IsColumnSelection() const { return mbColumnSelection; } @@ -1975,9 +1957,6 @@ public: USHORT SetRubyList( const SwPaM& rPam, const SwRubyList& rList, USHORT nMode ); - inline void SetWinEncryption(const bool bImportWinEncryption) {mbWinEncryption = bImportWinEncryption; } - inline bool IsWinEncrypted() const { return mbWinEncryption; } - void ReadLayoutCache( SvStream& rStream ); void WriteLayoutCache( SvStream& rStream ); SwLayoutCache* GetLayoutCache() const { return pLayoutCache; } @@ -2100,6 +2079,9 @@ public: { return n32DummyCompatabilityOptions2; } + + ::sfx2::IXmlIdRegistry& GetXmlIdRegistry(); + SwDoc* CreateCopy() const; }; diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx index 8f5a04658e6c..6bfd5437a20e 100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -299,10 +299,12 @@ public: GetController(); SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef ); + + virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const; }; class Graphic; //implemented in source/ui/docvw/romenu.cxx -String ExportGraphic( const Graphic &rGraphic, const String &rGrfName, const String &rName ); +String ExportGraphic( const Graphic &rGraphic, const String &rGrfName ); #endif diff --git a/sw/inc/edimp.hxx b/sw/inc/edimp.hxx index 16d841d5774a..8cfa04648cf7 100644 --- a/sw/inc/edimp.hxx +++ b/sw/inc/edimp.hxx @@ -52,15 +52,6 @@ class SwNodeIndex; } -#define FOREACHCURSOR_START(pCURSH) \ - {\ - SwShellCrsr *_pStartCrsr = *(pCURSH)->GetSwCrsr(), *__pStartCrsr = _pStartCrsr; \ - do { - -#define FOREACHCURSOR_END() \ - } while( (_pStartCrsr=*(SwCursor*)_pStartCrsr->GetNext()) != __pStartCrsr ); \ - } - struct SwPamRange { diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index 4e1eba53115b..83b0e5242a9e 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -801,11 +801,11 @@ public: // erfrage und setze den Fussnoten-Text/Nummer. Set.. auf akt. SSelection! BOOL GetCurFtn( SwFmtFtn* pToFillFtn = 0 ); - BOOL SetCurFtn( const SwFmtFtn& rFillFtn ); - BOOL HasFtns( BOOL bEndNotes = FALSE ) const; + bool SetCurFtn( const SwFmtFtn& rFillFtn ); + bool HasFtns( bool bEndNotes = false ) const; //z.Zt nicht benoetigt USHORT GetFtnCnt( BOOL bEndNotes = FALSE ) const; // gebe Liste aller Fussnoten und deren Anfangstexte - USHORT GetSeqFtnList( SwSeqFldList& rList, BOOL bEndNotes = FALSE ); + USHORT GetSeqFtnList( SwSeqFldList& rList, bool bEndNotes = false ); // SS fuer Bereiche const SwSection* InsertSection( const SwSection& rNew, diff --git a/sw/inc/fmtftn.hxx b/sw/inc/fmtftn.hxx index 5afdfadc8b46..e31001ced75f 100644 --- a/sw/inc/fmtftn.hxx +++ b/sw/inc/fmtftn.hxx @@ -45,14 +45,14 @@ class SW_DLLPUBLIC SwFmtFtn: public SfxPoolItem SwTxtFtn* pTxtAttr; //mein TextAttribut String aNumber; //Benutzerdefinierte 'Nummer' USHORT nNumber; //Automatische Nummerierung - BOOL bEndNote; //Ist es eine Endnote? + bool m_bEndNote; // is it an End note? // geschuetzter CopyCtor SwFmtFtn& operator=(const SwFmtFtn& rFtn); SwFmtFtn( const SwFmtFtn& ); public: - SwFmtFtn( BOOL bEndNote = FALSE ); + SwFmtFtn( bool bEndNote = false ); virtual ~SwFmtFtn(); // "pure virtual Methoden" vom SfxPoolItem @@ -61,11 +61,11 @@ public: const String &GetNumStr() const { return aNumber; } const USHORT &GetNumber() const { return nNumber; } - BOOL IsEndNote() const { return bEndNote;} + bool IsEndNote() const { return m_bEndNote;} void SetNumStr( const String& rStr ) { aNumber = rStr; } void SetNumber( USHORT nNo ) { nNumber = nNo; } - void SetEndNote( BOOL b ); + void SetEndNote( bool b ); void SetNumber( const SwFmtFtn& rFtn ) { nNumber = rFtn.nNumber; aNumber = rFtn.aNumber; } diff --git a/sw/inc/ftninfo.hxx b/sw/inc/ftninfo.hxx index 4ab9e53c6b27..6e84f3ead81b 100644 --- a/sw/inc/ftninfo.hxx +++ b/sw/inc/ftninfo.hxx @@ -50,7 +50,7 @@ class SW_DLLPUBLIC SwEndNoteInfo : public SwClient String sPrefix; String sSuffix; protected: - BOOL bEndNote; + bool m_bEndNote; public: SvxNumberType aFmt; USHORT nFtnOffset; diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index 53fcb75910f5..9e847064eaaf 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -375,6 +375,53 @@ RES_FLTRATTR_END #define RES_WHICHHINT_END HINT_END +inline bool isATR(const USHORT nWhich) +{ + return (RES_CHRATR_BEGIN <= nWhich) && (RES_UNKNOWNATR_END > nWhich); +} +inline bool isCHRATR(const USHORT nWhich) +{ + return (RES_CHRATR_BEGIN <= nWhich) && (RES_CHRATR_END > nWhich); +} +inline bool isTXTATR_WITHEND(const USHORT nWhich) +{ + return (RES_TXTATR_WITHEND_BEGIN <= nWhich) + && (RES_TXTATR_WITHEND_END > nWhich); +} +inline bool isTXTATR_NOEND(const USHORT nWhich) +{ + return (RES_TXTATR_NOEND_BEGIN <= nWhich) + && (RES_TXTATR_NOEND_END > nWhich); +} +inline bool isTXTATR(const USHORT nWhich) +{ + return (RES_TXTATR_BEGIN <= nWhich) && (RES_TXTATR_END > nWhich); +} +inline bool isPARATR(const USHORT nWhich) +{ + return (RES_PARATR_BEGIN <= nWhich) && (RES_PARATR_END > nWhich); +} +inline bool isPARATR_LIST(const USHORT nWhich) +{ + return (RES_PARATR_LIST_BEGIN <= nWhich) && (RES_PARATR_LIST_END > nWhich); } +inline bool isFRMATR(const USHORT nWhich) +{ + return (RES_FRMATR_BEGIN <= nWhich) && (RES_FRMATR_END > nWhich); +} +inline bool isGRFATR(const USHORT nWhich) +{ + return (RES_GRFATR_BEGIN <= nWhich) && (RES_GRFATR_END > nWhich); +} +inline bool isBOXATR(const USHORT nWhich) +{ + return (RES_BOXATR_BEGIN <= nWhich) && (RES_BOXATR_END > nWhich); +} +inline bool isUNKNOWNATR(const USHORT nWhich) +{ + return (RES_UNKNOWNATR_BEGIN <= nWhich) && (RES_UNKNOWNATR_END > nWhich); +} + + /* * hole aus der statischen Default-Attribut Tabelle ueber den Which-Wert * das entsprechende default Attribut. diff --git a/sw/inc/ndhints.hxx b/sw/inc/ndhints.hxx index ad4403d9f7e3..04bf3a7914b3 100644 --- a/sw/inc/ndhints.hxx +++ b/sw/inc/ndhints.hxx @@ -61,41 +61,45 @@ SV_DECL_PTRARR_SORT(SwpHtEnd,SwTxtAttr*,1,1) * class SwpHintsArr *************************************************************************/ -// Das neue Hintsarray: -class SwpHintsArr : private SwpHtStart +/// the Hints array +class SwpHintsArray { protected: - SwpHtEnd aHtEnd; + SwpHtStart m_HintStarts; + SwpHtEnd m_HintEnds; + //FIXME: why are the non-const methods public? public: void Insert( const SwTxtAttr *pHt ); void DeleteAtPos( const USHORT nPosInStart ); - BOOL Resort(); - SwTxtAttr *Cut( const USHORT nPosInStart ); - - inline const SwTxtAttr *GetStart( const USHORT nPos ) const { return (*this)[nPos]; } - inline const SwTxtAttr *GetEnd( const USHORT nPos ) const { return aHtEnd[nPos]; } - inline SwTxtAttr *GetStart( const USHORT nPos ) { return GetHt(nPos); } - inline SwTxtAttr *GetEnd( const USHORT nPos ) { return aHtEnd[nPos]; } - inline USHORT GetEndCount() const { return aHtEnd.Count(); } - inline USHORT GetStartCount() const { return Count(); } + bool Resort(); + SwTxtAttr * Cut( const USHORT nPosInStart ); + + inline const SwTxtAttr * GetStart( const USHORT nPos ) const + { return m_HintStarts[nPos]; } + inline const SwTxtAttr * GetEnd ( const USHORT nPos ) const + { return m_HintEnds [nPos]; } + inline SwTxtAttr * GetStart( const USHORT nPos ) + { return m_HintStarts[nPos]; } + inline SwTxtAttr * GetEnd ( const USHORT nPos ) + { return m_HintEnds [nPos]; } + + inline USHORT GetEndCount() const { return m_HintEnds .Count(); } + inline USHORT GetStartCount() const { return m_HintStarts.Count(); } + inline USHORT GetStartOf( const SwTxtAttr *pHt ) const; inline USHORT GetPos( const SwTxtAttr *pHt ) const -// OS: in svmem.hxx wird fuer TCPP GetPos ohne const gerufen -#ifdef TCPP - { return SwpHtStart::GetPos( (SwTxtAttr *)pHt ); } -#else - { return SwpHtStart::GetPos( pHt ); } -#endif + { return m_HintStarts.GetPos( pHt ); } - inline SwTxtAttr *GetHt( const USHORT nIdx ) { return SwpHtStart::operator[](nIdx); } - inline const SwTxtAttr *operator[]( const USHORT nIdx )const - { return SwpHtStart::operator[](nIdx); } - inline USHORT Count() const { return SwpHtStart::Count(); } + inline SwTxtAttr * GetTextHint( const USHORT nIdx ) + { return GetStart(nIdx); } + inline const SwTxtAttr * operator[]( const USHORT nIdx ) const + { return m_HintStarts[nIdx]; } + inline USHORT Count() const { return m_HintStarts.Count(); } #ifndef PRODUCT - BOOL Check() const; + bool Check() const; #endif }; @@ -103,67 +107,68 @@ public: * class SwpHints *************************************************************************/ -// Die public-Schnittstelle zum Node hin -class SwpHints: public SwpHintsArr +// public interface +class SwpHints : public SwpHintsArray { private: - SwRegHistory* pHistory; - // Numerierung - BOOL bHasHiddenParaField :1; // HiddenParaFld - BOOL bFntChg :1; // Fontwechsel - BOOL bFtn :1; // Fussnoten - BOOL bInSplitNode: 1; // TRUE: der Node ist im Split und die Frames - // werden verschoben! - BOOL bDDEFlds : 1; // es sind DDE-Felder am TextNode vorhanden - BOOL bCalcHiddenParaField : 1; // bHasHiddenParaField ist invalid, CalcHiddenParaField() rufen - - // Haelt ein neues Attribut in pHistory fest. - void NoteInHistory( SwTxtAttr *pAttr, const BOOL bNew = FALSE ); + SwRegHistory* m_pHistory; // for Undo + + bool m_bFontChange : 1; // font change + // true: the Node is in Split and Frames are moved + bool m_bInSplitNode : 1; + // m_bHasHiddenParaField is invalid, call CalcHiddenParaField() + bool m_bCalcHiddenParaField : 1; + bool m_bHasHiddenParaField : 1; // HiddenParaFld + bool m_bFootnote : 1; // footnotes + bool m_bDDEFields : 1; // the TextNode has DDE fields + + // records a new attibute in m_pHistory. + void NoteInHistory( SwTxtAttr *pAttr, const bool bNew = false ); void CalcFlags( ); - // die Delete Methoden duerfen nur vom TextNode gerufen werden !! - // Dieser sorgt dafuer, das bei Attributen ohne Ende auch das - // entsp. Zeichen entfernt wird !! + // Delete methods may only be called by the TextNode! + // Because the TextNode also guarantees removal of the Character for + // attributes without an end. friend class SwTxtNode; void DeleteAtPos( const USHORT nPos ); - // Ist der Hint schon bekannt, dann suche die Position und loesche ihn. - // Ist er nicht im Array, so gibt es ein ASSERT !! + // Delete the given Hint. The Hint must actually be in the array! void Delete( SwTxtAttr* pTxtHt ); - inline void SetCalcHiddenParaField(){ bCalcHiddenParaField = TRUE; } - inline void SetHiddenParaField( const BOOL bNew ) { bHasHiddenParaField = bNew; } - inline BOOL HasHiddenParaField() const - { if( bCalcHiddenParaField ) ((SwpHints*)this)->CalcHiddenParaField(); return bHasHiddenParaField; } + inline void SetInSplitNode(bool bInSplit) { m_bInSplitNode = bInSplit; } + inline void SetCalcHiddenParaField() { m_bCalcHiddenParaField = true; } + inline void SetHiddenParaField( const bool bNew ) + { m_bHasHiddenParaField = bNew; } + inline bool HasHiddenParaField() const + { + if ( m_bCalcHiddenParaField ) + { + (const_cast<SwpHints*>(this))->CalcHiddenParaField(); + } + return m_bHasHiddenParaField; + } void BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMode ); bool MergePortions( SwTxtNode& rNode ); public: - inline BOOL CanBeDeleted() const { return !Count(); } + SwpHints(); + + inline bool CanBeDeleted() const { return !Count(); } - // damit das SwDoc::Undo ueber alle Attributaenderungen informiert - // wird, gibt es hier einen Pointer auf die History. Nur wenn dieser - // != 0 ist, muessen alle Attributaenderungen "gemeldet" werden. - void Register( SwRegHistory* pHist ) { pHistory = pHist; } + // register a History, which receives all attribute changes (for Undo) + void Register( SwRegHistory* pHist ) { m_pHistory = pHist; } + // deregister the currently registered History void DeRegister() { Register(0); } - SwRegHistory* getHistory() const { return pHistory; } + SwRegHistory* GetHistory() const { return m_pHistory; } - void Insert( SwTxtAttr* pHt, SwTxtNode &rNode, USHORT nMode = 0 ); + void Insert( SwTxtAttr* pHt, SwTxtNode &rNode, USHORT nMode = 0 ); - inline BOOL HasFtn() const { return bFtn; } - inline BOOL IsInSplitNode() const { return bInSplitNode; } + inline bool HasFtn() const { return m_bFootnote; } + inline bool IsInSplitNode() const { return m_bInSplitNode; } - // Konstruktor (wird im nur einmal benutzt!) - SwpHints() - { - pHistory = 0; - bFntChg = TRUE; - bDDEFlds = bFtn = bInSplitNode = bCalcHiddenParaField = bHasHiddenParaField = FALSE; - } - - // Berechnung von bHasHiddenParaField, return-Wert TRUE bei Aenderung - BOOL CalcHiddenParaField(); + // calc current value of m_bHasHiddenParaField, returns true iff changed + bool CalcHiddenParaField(); DECL_FIXEDMEMPOOL_NEWDEL(SwpHints) }; @@ -172,20 +177,22 @@ public: SvStream &operator<<(SvStream &aS, const SwpHints &rHints); //$ ostream /************************************************************************* - * Inline-Implementationen + * Inline Implementations *************************************************************************/ -inline USHORT SwpHintsArr::GetStartOf( const SwTxtAttr *pHt ) const +inline USHORT SwpHintsArray::GetStartOf( const SwTxtAttr *pHt ) const { USHORT nPos; - if( !Seek_Entry( pHt, &nPos ) ) + if ( !m_HintStarts.Seek_Entry( pHt, &nPos ) ) + { nPos = USHRT_MAX; + } return nPos; } -inline SwTxtAttr *SwpHintsArr::Cut( const USHORT nPosInStart ) +inline SwTxtAttr *SwpHintsArray::Cut( const USHORT nPosInStart ) { - SwTxtAttr *pHt = GetHt(nPosInStart); + SwTxtAttr *pHt = GetTextHint(nPosInStart); DeleteAtPos( nPosInStart ); return pHt; } diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 33fd760ab108..df21f6cb8aa8 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -38,6 +38,13 @@ #include <errhdl.hxx> #include <modeltoviewhelper.hxx> #include <SwNumberTreeTypes.hxx> + +#include <sfx2/Metadatable.hxx> + +#include <vector> +#include <set> + + class SwNumRule; class SwNodeNum; // --> OD 2008-05-06 #refactorlists# @@ -47,9 +54,6 @@ class SwList; class SvxLRSpaceItem; // <-- -#include <vector> -#include <set> - namespace utl { class TransliterationWrapper; } @@ -85,7 +89,7 @@ typedef std::set< xub_StrLen > SwSoftPageBreakList; // -------------------- // SwTxtNode // -------------------- -class SW_DLLPUBLIC SwTxtNode: public SwCntntNode +class SW_DLLPUBLIC SwTxtNode: public SwCntntNode, public ::sfx2::Metadatable { // fuer das Erzeugen des ersten TextNode @@ -98,25 +102,25 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode //Kann 0 sein, nur dann nicht 0 wenn harte Attribute drin stehen. //Also niemals direkt zugreifen! - SwpHints *pSwpHints; + SwpHints *m_pSwpHints; // --> OD 2005-11-02 #i51089 - TUNING# mutable SwNodeNum* mpNodeNum; // Numerierung fuer diesen Absatz // <-- - XubString aText; + XubString m_Text; - SwParaIdleData_Impl* pParaIdleData_Impl; + SwParaIdleData_Impl* m_pParaIdleData_Impl; // Some of the chars this para are hidden. Paragraph has to be reformatted // on changing the view to print preview. - mutable BOOL bContainsHiddenChars : 1; + mutable bool m_bContainsHiddenChars : 1; // The whole paragraph is hidden because of the hidden text attribute - mutable BOOL bHiddenCharsHidePara : 1; + mutable bool m_bHiddenCharsHidePara : 1; // The last two flags have to be recalculated if this flag is set: - mutable BOOL bRecalcHiddenCharFlags : 1; + mutable bool m_bRecalcHiddenCharFlags : 1; - bool bNotifiable; - mutable BOOL bLastOutlineState : 1; + mutable bool m_bLastOutlineState : 1; + bool m_bNotifiable; // BYTE nOutlineLevel; //#outline level, removed by zhaojianwei. // --> OD 2008-11-19 #i70748# @@ -134,6 +138,7 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode SwList* mpList; // <-- + SW_DLLPRIVATE SwTxtNode( const SwNodeIndex &rWhere, SwTxtFmtColl *pTxtColl, const SfxItemSet* pAutoAttr = 0 ); @@ -160,12 +165,13 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode // Optimization: Asking for information about hidden characters at SwScriptInfo // updates these flags. - inline bool IsCalcHiddenCharFlags() const { return bRecalcHiddenCharFlags; } + inline bool IsCalcHiddenCharFlags() const + { return m_bRecalcHiddenCharFlags; } inline void SetHiddenCharAttribute( bool bNewHiddenCharsHidePara, bool bNewContainsHiddenChars ) const { - bHiddenCharsHidePara = bNewHiddenCharsHidePara; - bContainsHiddenChars = bNewContainsHiddenChars; - bRecalcHiddenCharFlags = false; + m_bHiddenCharsHidePara = bNewHiddenCharsHidePara; + m_bContainsHiddenChars = bNewContainsHiddenChars; + m_bRecalcHiddenCharFlags = false; } SW_DLLPRIVATE void CalcHiddenCharFlags() const; @@ -194,6 +200,8 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode */ SwNodeNum* CreateNum() const; + inline void TryDeleteSwpHints(); + public: bool IsWordCountDirty() const; bool IsWrongDirty() const; @@ -223,14 +231,14 @@ public: public: using SwCntntNode::GetAttr; - const String& GetTxt() const { return aText; } + const String& GetTxt() const { return m_Text; } - // Zugriff auf SwpHints + // getters for SwpHints inline SwpHints &GetSwpHints(); inline const SwpHints &GetSwpHints() const; - inline SwpHints *GetpSwpHints() { return pSwpHints; } - inline const SwpHints *GetpSwpHints() const { return pSwpHints; } - inline BOOL HasHints() const { return pSwpHints ? TRUE : FALSE; } + inline SwpHints *GetpSwpHints() { return m_pSwpHints; } + inline const SwpHints *GetpSwpHints() const { return m_pSwpHints; } + inline bool HasHints() const { return m_pSwpHints ? true : false; } inline SwpHints &GetOrCreateSwpHints(); virtual ~SwTxtNode(); @@ -341,7 +349,7 @@ public: SwCntntNode *AppendNode( const SwPosition & ); // setze ggf. das DontExpand-Flag an INet bzw. Zeichenvorlagen - BOOL DontExpandFmt( const SwIndex& rIdx, BOOL bFlag = TRUE, + BOOL DontExpandFmt( const SwIndex& rIdx, bool bFlag = true, BOOL bFmtToTxtAttributes = TRUE ); // gebe das vorgegebene Attribut, welches an der TextPosition (rIdx) @@ -400,12 +408,12 @@ public: /** Returns if this text node is an outline. - @retval TRUE this text node is an outline - @retval FALSE else + @retval true this text node is an outline + @retval false else */ - BOOL IsOutline() const; + bool IsOutline() const; - BOOL IsOutlineStateChanged() const; + bool IsOutlineStateChanged() const; void UpdateOutlineState(); @@ -712,29 +720,29 @@ public: // Passes back info needed on the dropcap dimensions bool GetDropSize(int& rFontHeight, int& rDropHeight, int& rDropDescent) const; - - // // Hidden Paragraph Field: - // - inline BOOL CalcHiddenParaField() - { if(pSwpHints) return pSwpHints->CalcHiddenParaField(); return FALSE; } - // Setzen des CalcVisible-Flags - inline void SetCalcHiddenParaField(){ if(pSwpHints) pSwpHints->SetCalcHiddenParaField(); } + inline bool CalcHiddenParaField() + { return m_pSwpHints ? m_pSwpHints->CalcHiddenParaField() : false; } + // set CalcVisible flags + inline void SetCalcHiddenParaField() + { if (m_pSwpHints) m_pSwpHints->SetCalcHiddenParaField(); } - // Ist der Absatz sichtbar - inline BOOL HasHiddenParaField() const - { return pSwpHints ? pSwpHints->HasHiddenParaField() : FALSE; } + // is the paragraph visible? + inline bool HasHiddenParaField() const + { return m_pSwpHints ? m_pSwpHints->HasHiddenParaField() : false; } // // Hidden Paragraph Field: // inline bool HasHiddenCharAttribute( bool bWholePara ) const { - if ( bRecalcHiddenCharFlags ) + if ( m_bRecalcHiddenCharFlags ) CalcHiddenCharFlags(); - return bWholePara ? bHiddenCharsHidePara : bContainsHiddenChars; + return bWholePara ? m_bHiddenCharsHidePara : m_bContainsHiddenChars; } - inline void SetCalcHiddenCharFlags() const { bRecalcHiddenCharFlags = TRUE; } + + inline void SetCalcHiddenCharFlags() const + { m_bRecalcHiddenCharFlags = true; } // --> FME 2004-06-08 #i12836# enhanced pdf // @@ -808,32 +816,50 @@ public: USHORT GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd ) const; + // 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(); + DECL_FIXEDMEMPOOL_NEWDEL(SwTxtNode) }; //----------------------------------------------------------------------------- -inline SwpHints &SwTxtNode::GetSwpHints() +inline SwpHints & SwTxtNode::GetSwpHints() { - ASSERT_ID( pSwpHints, ERR_NOHINTS); - return *pSwpHints; + ASSERT_ID( m_pSwpHints, ERR_NOHINTS); + return *m_pSwpHints; } inline const SwpHints &SwTxtNode::GetSwpHints() const { - ASSERT_ID( pSwpHints, ERR_NOHINTS); - return *pSwpHints; + ASSERT_ID( m_pSwpHints, ERR_NOHINTS); + return *m_pSwpHints; } inline SwpHints& SwTxtNode::GetOrCreateSwpHints() { - if( !pSwpHints ) - pSwpHints = new SwpHints; - return *pSwpHints; + if ( !m_pSwpHints ) + { + m_pSwpHints = new SwpHints; + } + return *m_pSwpHints; +} + +inline void SwTxtNode::TryDeleteSwpHints() +{ + if ( m_pSwpHints && m_pSwpHints->CanBeDeleted() ) + { + DELETEZ( m_pSwpHints ); + } } inline SwTxtFmtColl* SwTxtNode::GetTxtColl() const { - return (SwTxtFmtColl*)GetRegisteredIn(); + return static_cast<SwTxtFmtColl*>(const_cast<SwModify*>(GetRegisteredIn())); } // fuer den IBM-Compiler nicht inlinen wg. 42876 @@ -841,11 +867,11 @@ inline SwTxtFmtColl* SwTxtNode::GetTxtColl() const // Inline Metoden aus Node.hxx - erst hier ist der TxtNode bekannt !! inline SwTxtNode *SwNode::GetTxtNode() { - return ND_TEXTNODE == nNodeType ? (SwTxtNode*)this : 0; + return ND_TEXTNODE == nNodeType ? static_cast<SwTxtNode*>(this) : 0; } inline const SwTxtNode *SwNode::GetTxtNode() const { - return ND_TEXTNODE == nNodeType ? (const SwTxtNode*)this : 0; + return ND_TEXTNODE == nNodeType ? static_cast<const SwTxtNode*>(this) : 0; } #endif diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx index 8b5af17f820c..18579f1a918b 100644 --- a/sw/inc/pam.hxx +++ b/sw/inc/pam.hxx @@ -60,13 +60,10 @@ struct SW_DLLPUBLIC SwPosition SwNodeIndex nNode; SwIndex nContent; - SwPosition( const SwNode& rNode ); - SwPosition( const SwNodeIndex &rNode ); SwPosition( const SwNodeIndex &rNode, const SwIndex &rCntnt ); - /* @@@MAINTAINABILITY-HORROR@@@ - SwPosition desperately needs a constructor - SwPosition( const SwNode& rNode, xub_StrLen nOffset ); - */ + explicit SwPosition( const SwNodeIndex &rNode ); + explicit SwPosition( const SwNode& rNode ); + explicit SwPosition( SwCntntNode& rNode, const xub_StrLen nOffset = 0 ); SwPosition( const SwPosition & ); SwPosition &operator=(const SwPosition &); @@ -128,11 +125,11 @@ void _InitPam(); class SW_DLLPUBLIC SwPaM : public Ring { - SwPosition aBound1; - SwPosition aBound2; - SwPosition *pPoint; - SwPosition *pMark; - BOOL bIsInFrontOfLabel; + SwPosition m_Bound1; + SwPosition m_Bound2; + SwPosition * m_pPoint; // points at either m_Bound1 or m_Bound2 + SwPosition * m_pMark; // points at either m_Bound1 or m_Bound2 + bool m_bIsInFrontOfLabel; SwPaM* MakeRegion( SwMoveFn fnMove, const SwPaM * pOrigRg = 0 ); @@ -180,54 +177,66 @@ public: SwMoveFn fnMove, BOOL bSrchForward, BOOL bRegSearch, BOOL bChkEmptyPara, BOOL bChkParaEnd, xub_StrLen &nStart, xub_StrLen &nEnde,xub_StrLen nTxtLen,SwNode* pNode, SwPaM* pPam); - inline BOOL IsInFrontOfLabel() const { return bIsInFrontOfLabel; } - inline void _SetInFrontOfLabel( BOOL bNew ) { bIsInFrontOfLabel = bNew; } + inline bool IsInFrontOfLabel() const { return m_bIsInFrontOfLabel; } + inline void _SetInFrontOfLabel( bool bNew ) { m_bIsInFrontOfLabel = bNew; } virtual void SetMark(); - void DeleteMark() { pMark = pPoint; } + + void DeleteMark() + { + if (m_pMark != m_pPoint) + { + // clear the mark position; this helps if mark's SwIndex is + // registered at some node, and that node is then deleted + *m_pMark = SwPosition( SwNodeIndex( GetNode()->GetNodes() ) ); + m_pMark = m_pPoint; + } + } + #ifdef PRODUCT void Exchange() { - if(pPoint != pMark) + if (m_pPoint != m_pMark) { - SwPosition *pTmp = pPoint; - pPoint = pMark; - pMark = pTmp; + SwPosition *pTmp = m_pPoint; + m_pPoint = m_pMark; + m_pMark = pTmp; } } #else void Exchange(); #endif - /* - * Undocumented Feature: Liefert zurueck, ob das Pam ueber - * eine Selektion verfuegt oder nicht. Definition einer - * Selektion: Point und Mark zeigen auf unterschiedliche - * Puffer. + + /** A PaM marks a selection if Point and Mark are distinct positions. + @return true iff the PaM spans a selection */ - BOOL HasMark() const { return pPoint == pMark? FALSE : TRUE; } + bool HasMark() const { return m_pPoint == m_pMark ? false : true; } - const SwPosition *GetPoint() const { return pPoint; } - SwPosition *GetPoint() { return pPoint; } - const SwPosition *GetMark() const { return pMark; } - SwPosition *GetMark() { return pMark; } + const SwPosition *GetPoint() const { return m_pPoint; } + SwPosition *GetPoint() { return m_pPoint; } + const SwPosition *GetMark() const { return m_pMark; } + SwPosition *GetMark() { return m_pMark; } const SwPosition *Start() const - { return (*pPoint) <= (*pMark)? pPoint: pMark; } + { return (*m_pPoint) <= (*m_pMark) ? m_pPoint : m_pMark; } SwPosition *Start() - { return (*pPoint) <= (*pMark)? pPoint: pMark; } + { return (*m_pPoint) <= (*m_pMark) ? m_pPoint : m_pMark; } + const SwPosition *End() const - { return (*pPoint) > (*pMark)? pPoint: pMark; } + { return (*m_pPoint) > (*m_pMark) ? m_pPoint : m_pMark; } SwPosition *End() - { return (*pPoint) > (*pMark)? pPoint: pMark; } + { return (*m_pPoint) > (*m_pMark) ? m_pPoint : m_pMark; } - // erfrage vom SwPaM den aktuellen Node/ContentNode am SPoint / Mark - SwNode* GetNode( BOOL bPoint = TRUE ) const + /// @return current Node at Point/Mark + SwNode * GetNode ( bool bPoint = true ) const { - return &( bPoint ? pPoint->nNode : pMark->nNode ).GetNode(); + return &( bPoint ? m_pPoint->nNode : m_pMark->nNode ).GetNode(); } - SwCntntNode* GetCntntNode( BOOL bPoint = TRUE ) const + + /// @return current ContentNode at Point/Mark + SwCntntNode* GetCntntNode( bool bPoint = true ) const { - return ( bPoint ? pPoint->nNode : pMark->nNode ).GetNode().GetCntntNode(); + return GetNode(bPoint)->GetCntntNode(); } /** @@ -238,12 +247,13 @@ public: */ SwPaM & Normalize(BOOL bPointFirst = TRUE); - // erfrage vom SwPaM das Dokument, in dem er angemeldet ist - SwDoc* GetDoc() const { return pPoint->nNode.GetNode().GetDoc(); } - SwPosition& GetBound( BOOL bOne = TRUE ) - { return bOne ? aBound1 : aBound2; } - const SwPosition& GetBound( BOOL bOne = TRUE ) const - { return bOne ? aBound1 : aBound2; } + /// @return the document (SwDoc) at which the PaM is registered + SwDoc* GetDoc() const { return m_pPoint->nNode.GetNode().GetDoc(); } + + SwPosition& GetBound( bool bOne = true ) + { return bOne ? m_Bound1 : m_Bound2; } + const SwPosition& GetBound( bool bOne = true ) const + { return bOne ? m_Bound1 : m_Bound2; } // erfrage die Seitennummer auf der der Cursor steht USHORT GetPageNum( BOOL bAtPoint = TRUE, const Point* pLayPos = 0 ); diff --git a/sw/inc/postit.hxx b/sw/inc/postit.hxx index f5f511ec18ba..4930ac67c9bf 100644 --- a/sw/inc/postit.hxx +++ b/sw/inc/postit.hxx @@ -85,23 +85,21 @@ class SwPostItAnkor: public sdr::overlay::OverlayObjectWithBasePosition void implEnsureGeometry(); void implResetGeometry(); - // helpers to paint geometry - void implDrawGeometry(OutputDevice& rOutputDevice, Color aColor, double fOffX, double fOffY); - Color implBlendColor(const Color aOriginal, sal_Int16 nChange); - - virtual void drawGeometry(OutputDevice& rOutputDevice); - virtual void createBaseRange(OutputDevice& rOutputDevice); + // geometry creation for OverlayObject + virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence(); private: // object's geometry basegfx::B2DPolygon maTriangle; basegfx::B2DPolygon maLine; basegfx::B2DPolygon maLineTop; - LineInfo mLineInfo; unsigned long mHeight; - bool mbShadowedEffect; AnkorState mAnkorState; + // bitfield + unsigned mbShadowedEffect : 1; + unsigned mbLineSolid : 1; + public: SwPostItAnkor(const basegfx::B2DPoint& rBasePos, const basegfx::B2DPoint& rSecondPos, @@ -111,8 +109,8 @@ class SwPostItAnkor: public sdr::overlay::OverlayObjectWithBasePosition const basegfx::B2DPoint& rSixthPos, const basegfx::B2DPoint& rSeventhPos, Color aBaseColor, - const LineInfo &aLineInfo, - bool bShadowedEffect); + bool bShadowedEffect, + bool bLineSolid); virtual ~SwPostItAnkor(); const basegfx::B2DPoint& GetSecondPosition() const { return maSecondPosition; } @@ -129,7 +127,8 @@ class SwPostItAnkor: public sdr::overlay::OverlayObjectWithBasePosition void SetSixthPosition(const basegfx::B2DPoint& rNew); void SetSeventhPosition(const basegfx::B2DPoint& rNew); - void SetLineInfo(const LineInfo &aLineInfo); + bool getLineSolid() const { return mbLineSolid; } + void setLineSolid(bool bNew); void SetHeight(const unsigned long aHeight) {mHeight = aHeight;}; @@ -137,12 +136,6 @@ class SwPostItAnkor: public sdr::overlay::OverlayObjectWithBasePosition void SetAnkorState(AnkorState aState); AnkorState GetAnkorState() const {return mAnkorState;} - virtual void Trigger(sal_uInt32 nTime); - - //sal_Bool isHit(const basegfx::B2DPoint& rPos, double fTol) const; - // transform object coordinates. Transforms maBasePosition - // and invalidates on change - virtual void transform(const basegfx::B2DHomMatrix& rMatrix); }; enum ShadowState {SS_NORMAL, SS_VIEW, SS_EDIT}; @@ -150,8 +143,8 @@ enum ShadowState {SS_NORMAL, SS_VIEW, SS_EDIT}; class SwPostItShadow: public sdr::overlay::OverlayObjectWithBasePosition { protected: - virtual void drawGeometry(OutputDevice& rOutputDevice); - virtual void createBaseRange(OutputDevice& rOutputDevice); + // geometry creation for OverlayObject + virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence(); private: basegfx::B2DPoint maSecondPosition; @@ -167,9 +160,6 @@ class SwPostItShadow: public sdr::overlay::OverlayObjectWithBasePosition const basegfx::B2DPoint& GetSecondPosition() const { return maSecondPosition; } void SetSecondPosition(const basegfx::B2DPoint& rNew); void SetPosition(const basegfx::B2DPoint& rPoint1,const basegfx::B2DPoint& rPoint2); - - virtual void Trigger(sal_uInt32 nTime); - virtual void transform(const basegfx::B2DHomMatrix& rMatrix); }; class PostItTxt : public Window diff --git a/sw/inc/rolbck.hxx b/sw/inc/rolbck.hxx index f137b8b73e6c..6dd6a90ad640 100644 --- a/sw/inc/rolbck.hxx +++ b/sw/inc/rolbck.hxx @@ -43,7 +43,7 @@ class SwDoc; class SwFmt; class SwFmtColl; -class SwHstryHint; +class SwHistoryHint; class SwTxtAttr; class SfxPoolItem; class SwTxtNode; @@ -72,10 +72,13 @@ class SwCharFmt; #include <IDocumentMarkAccess.hxx> // <-- +#include <memory> + + #ifndef PRODUCT class Writer; -#define OUT_HSTR_HINT( name ) \ - friend Writer& OutUndo_Hstr_ ## name( Writer&, const SwHstryHint& ); +#define OUT_HSTR_HINT( name ) \ + friend Writer& OutUndo_Hstr_ ## name( Writer&, const SwHistoryHint& ); #else #define OUT_HSTR_HINT( name ) #endif @@ -99,169 +102,187 @@ enum HISTORY_HINT { HSTRY_CHGCHARFMT, // #i27615# HSTRY_END }; -class SwHstryHint + +class SwHistoryHint { - HISTORY_HINT eWhichId; + const HISTORY_HINT m_eWhichId; + public: - SwHstryHint( HISTORY_HINT eWh ) : eWhichId( eWh ) {} - virtual ~SwHstryHint() {} // jetzt inline - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ) = 0; - HISTORY_HINT Which() const { return eWhichId; } + SwHistoryHint( HISTORY_HINT eWhich ) : m_eWhichId( eWhich ) {} + virtual ~SwHistoryHint() {} + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) = 0; + HISTORY_HINT Which() const { return m_eWhichId; } virtual String GetDescription() const; }; -class SwSetFmtHint : public SwHstryHint +class SwHistorySetFmt : public SwHistoryHint { - SfxPoolItem* pAttr; - ULONG nNode; + ::std::auto_ptr<SfxPoolItem> m_pAttr; + const ULONG m_nNodeIndex; + public: - SwSetFmtHint( const SfxPoolItem* pFmtHt, ULONG nNode ); - virtual ~SwSetFmtHint(); - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); + SwHistorySetFmt( const SfxPoolItem* pFmtHt, ULONG nNode ); + virtual ~SwHistorySetFmt(); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); virtual String GetDescription() const; OUT_HSTR_HINT(SetFmtHnt) }; -class SwResetFmtHint : public SwHstryHint +class SwHistoryResetFmt : public SwHistoryHint { - ULONG nNode; - USHORT nWhich; + const ULONG m_nNodeIndex; + const USHORT m_nWhich; + public: // --> OD 2008-02-27 #refactorlists# - removed <rDoc> - SwResetFmtHint( const SfxPoolItem* pFmtHt, ULONG nNodeIdx ); + SwHistoryResetFmt( const SfxPoolItem* pFmtHt, ULONG nNodeIdx ); // <-- - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); + OUT_HSTR_HINT(ResetFmtHnt) }; -class SwSetTxtHint : public SwHstryHint +class SwHistorySetTxt : public SwHistoryHint { - SfxPoolItem *pAttr; - ULONG nNode; - xub_StrLen nStart, nEnd; + ::std::auto_ptr<SfxPoolItem> m_pAttr; + const ULONG m_nNodeIndex; + const xub_StrLen m_nStart; + const xub_StrLen m_nEnd; + public: - SwSetTxtHint( /*const*/ SwTxtAttr* pTxtHt, ULONG nNode ); - virtual ~SwSetTxtHint(); - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); + SwHistorySetTxt( SwTxtAttr* pTxtHt, ULONG nNode ); + virtual ~SwHistorySetTxt(); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); OUT_HSTR_HINT(SetTxtHnt) }; -class SwSetTxtFldHint : public SwHstryHint +class SwHistorySetTxtFld : public SwHistoryHint { - SwFmtFld* pFld; - SwFieldType* pFldType; - ULONG nNode; - xub_StrLen nPos; - USHORT nFldWhich; + const ::std::auto_ptr<SwFmtFld> m_pFld; + ::std::auto_ptr<SwFieldType> m_pFldType; + ULONG m_nNodeIndex; + xub_StrLen m_nPos; + USHORT m_nFldWhich; + public: - SwSetTxtFldHint( SwTxtFld* pTxtFld, ULONG nNode ); - virtual ~SwSetTxtFldHint(); - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); + SwHistorySetTxtFld( SwTxtFld* pTxtFld, ULONG nNode ); + virtual ~SwHistorySetTxtFld(); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); virtual String GetDescription() const; OUT_HSTR_HINT(SetTxtFldHnt) }; -class SwSetRefMarkHint : public SwHstryHint +class SwHistorySetRefMark : public SwHistoryHint { - String aRefName; - ULONG nNode; - xub_StrLen nStart, nEnd; + const String m_RefName; + const ULONG m_nNodeIndex; + const xub_StrLen m_nStart; + const xub_StrLen m_nEnd; + public: - SwSetRefMarkHint( SwTxtRefMark* pTxtHt, ULONG nNode ); - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); + SwHistorySetRefMark( SwTxtRefMark* pTxtHt, ULONG nNode ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); + OUT_HSTR_HINT(SetRefMarkHnt) }; -class SwSetTOXMarkHint : public SwHstryHint +class SwHistorySetTOXMark : public SwHistoryHint { - String aTOXName; - TOXTypes eTOXTypes; - SwTOXMark aTOXMark; - ULONG nNode; - xub_StrLen nStart, nEnd; + SwTOXMark m_TOXMark; + const String m_TOXName; + const TOXTypes m_eTOXTypes; + const ULONG m_nNodeIndex; + const xub_StrLen m_nStart; + const xub_StrLen m_nEnd; + public: - SwSetTOXMarkHint( SwTxtTOXMark* pTxtHt, ULONG nNode ); - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); + SwHistorySetTOXMark( SwTxtTOXMark* pTxtHt, ULONG nNode ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); int IsEqual( const SwTOXMark& rCmp ) const; + OUT_HSTR_HINT(SetToxMarkHnt) }; -class SwResetTxtHint : public SwHstryHint +class SwHistoryResetTxt : public SwHistoryHint { - ULONG nNode; - xub_StrLen nStart, nEnd; - USHORT nAttr; + const ULONG m_nNodeIndex; + const xub_StrLen m_nStart; + const xub_StrLen m_nEnd; + const USHORT m_nAttr; + public: - SwResetTxtHint( USHORT nWhich, xub_StrLen nStt, xub_StrLen nEnd, ULONG nNode ); - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); + SwHistoryResetTxt( USHORT nWhich, xub_StrLen nStt, xub_StrLen nEnd, + ULONG nNode ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); + + USHORT GetWhich() const { return m_nAttr; } + ULONG GetNode() const { return m_nNodeIndex; } + xub_StrLen GetCntnt() const { return m_nStart; } - USHORT GetWhich() const { return nAttr; } - ULONG GetNode() const { return nNode; } - xub_StrLen GetCntnt() const { return nStart; } OUT_HSTR_HINT(ResetTxtHnt) }; -class SwSetFtnHint : public SwHstryHint +class SwHistorySetFootnote : public SwHistoryHint { - String aFtnStr; - SwUndoSaveSection* pUndo; - ULONG nNode; - xub_StrLen nStart; - BOOL bEndNote; + const ::std::auto_ptr<SwUndoSaveSection> m_pUndo; + const String m_FootnoteNumber; + ULONG m_nNodeIndex; + const xub_StrLen m_nStart; + const bool m_bEndNote; + public: - SwSetFtnHint( SwTxtFtn* pTxtFtn, ULONG nNode ); - SwSetFtnHint( const SwTxtFtn& ); - ~SwSetFtnHint(); - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); + SwHistorySetFootnote( SwTxtFtn* pTxtFtn, ULONG nNode ); + SwHistorySetFootnote( const SwTxtFtn& ); + virtual ~SwHistorySetFootnote(); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); virtual String GetDescription() const; OUT_HSTR_HINT(SetFtnHnt) }; -class SwChgFmtColl : public SwHstryHint +class SwHistoryChangeFmtColl : public SwHistoryHint { - const SwFmtColl* pColl; - ULONG nNode; - BYTE nNdWhich; - // --> OD 2007-07-09 #i77372# - // adjust (naming and type) and extend (add <mbIsCounted>) numbering attributes - int mnNumLvl; - bool mbIsRestart; - SwNumberTree::tSwNumTreeNumber mnRestartVal; - bool mbIsCounted; - // <-- + SwFmtColl * const m_pColl; + const ULONG m_nNodeIndex; + const BYTE m_nNodeType; + public: - SwChgFmtColl( const SwFmtColl* pColl, ULONG nNode, BYTE nNodeWhich ); - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); - OUT_HSTR_HINT(ChgFmtColl) + SwHistoryChangeFmtColl( SwFmtColl* pColl, ULONG nNode, BYTE nNodeWhich ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); + + OUT_HSTR_HINT(ChangeFmtColl) }; -class SwHstryTxtFlyCnt : public SwHstryHint +class SwHistoryTxtFlyCnt : public SwHistoryHint { - SwUndoDelLayFmt* pUndo; + ::std::auto_ptr<SwUndoDelLayFmt> m_pUndo; + public: - SwHstryTxtFlyCnt( SwTxtFlyCnt* pTxtFly ); // fuer Zeichengebundene - SwHstryTxtFlyCnt( SwFlyFrmFmt* pFlyFmt ); // fuer Absatzgebundene - ~SwHstryTxtFlyCnt(); - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); - SwUndoDelLayFmt* GetUDelLFmt() { return pUndo; } + SwHistoryTxtFlyCnt( SwFrmFmt* const pFlyFmt ); + virtual ~SwHistoryTxtFlyCnt(); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); + SwUndoDelLayFmt* GetUDelLFmt() { return m_pUndo.get(); } + OUT_HSTR_HINT(FlyCnt) }; -class SwHstryBookmark : public SwHstryHint +class SwHistoryBookmark : public SwHistoryHint { public: - SwHstryBookmark(const ::sw::mark::IMark& rBkmk, bool bSavePos, bool bSaveOtherPos); - virtual void SetInDoc(SwDoc * pDoc, BOOL); - OUT_HSTR_HINT(Bookmark) + SwHistoryBookmark(const ::sw::mark::IMark& rBkmk, + bool bSavePos, bool bSaveOtherPos); + virtual void SetInDoc(SwDoc * pDoc, bool); - BOOL IsEqualBookmark(const ::sw::mark::IMark& rBkmk); + bool IsEqualBookmark(const ::sw::mark::IMark& rBkmk); const ::rtl::OUString& GetName() const; + + OUT_HSTR_HINT(Bookmark) + private: const ::rtl::OUString m_aName; ::rtl::OUString m_aShortName; @@ -276,129 +297,135 @@ class SwHstryBookmark : public SwHstryHint const IDocumentMarkAccess::MarkType m_eBkmkType; }; -class SwHstrySetAttrSet : public SwHstryHint +class SwHistorySetAttrSet : public SwHistoryHint { - SfxItemSet aOldSet; - SvUShorts aResetArr; - ULONG nNode; - // --> OD 2007-07-09 #i77372# - // adjust (naming and type) and extend (add <mbIsCounted>) numbering attributes - int mnNumLvl; - bool mbIsRestart; - SwNumberTree::tSwNumTreeNumber mnRestartVal; - bool mbIsCounted; - // <-- + SfxItemSet m_OldSet; + SvUShorts m_ResetArray; + const ULONG m_nNodeIndex; + public: - SwHstrySetAttrSet( const SfxItemSet& rSet, ULONG nNode, - const SvUShortsSort& rSetArr ); - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); + SwHistorySetAttrSet( const SfxItemSet& rSet, ULONG nNode, + const SvUShortsSort& rSetArr ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); + OUT_HSTR_HINT(SetAttrSet) }; -class SwHstryResetAttrSet : public SwHstryHint +class SwHistoryResetAttrSet : public SwHistoryHint { - ULONG nNode; - xub_StrLen nStart, nEnd; - SvUShorts aArr; + const ULONG m_nNodeIndex; + const xub_StrLen m_nStart; + const xub_StrLen m_nEnd; + SvUShorts m_Array; + public: - SwHstryResetAttrSet( const SfxItemSet& rSet, ULONG nNode, + SwHistoryResetAttrSet( const SfxItemSet& rSet, ULONG nNode, xub_StrLen nStt = STRING_MAXLEN, xub_StrLen nEnd = STRING_MAXLEN ); - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); + + const SvUShorts& GetArr() const { return m_Array; } + ULONG GetNode() const { return m_nNodeIndex; } + xub_StrLen GetCntnt() const { return m_nStart; } - const SvUShorts& GetArr() const { return aArr; } - ULONG GetNode() const { return nNode; } - xub_StrLen GetCntnt() const { return nStart; } OUT_HSTR_HINT(ResetAttrSet) }; -class SwHstryChgFlyAnchor : public SwHstryHint +class SwHistoryChangeFlyAnchor : public SwHistoryHint { - SwFrmFmt* pFmt; - ULONG nOldPos; - xub_StrLen nOldCnt; + SwFrmFmt & m_rFmt; + const ULONG m_nOldNodeIndex; + const xub_StrLen m_nOldContentIndex; + public: - SwHstryChgFlyAnchor( const SwFrmFmt& rFmt ); - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); + SwHistoryChangeFlyAnchor( SwFrmFmt& rFmt ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); }; -class SwHstryChgFlyChain : public SwHstryHint +class SwHistoryChangeFlyChain : public SwHistoryHint { - SwFlyFrmFmt *pPrevFmt, *pNextFmt, *pFlyFmt; + SwFlyFrmFmt * const m_pPrevFmt; + SwFlyFrmFmt * const m_pNextFmt; + SwFlyFrmFmt * const m_pFlyFmt; + public: - SwHstryChgFlyChain( const SwFlyFrmFmt& rFmt, const SwFmtChain& rAttr ); - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); + SwHistoryChangeFlyChain( SwFlyFrmFmt& rFmt, const SwFmtChain& rAttr ); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); }; // #i27615# -class SwHstryChgCharFmt : public SwHstryHint +class SwHistoryChangeCharFmt : public SwHistoryHint { - SfxItemSet aOldSet; - String sFmt; + const SfxItemSet m_OldSet; + const String m_Fmt; + public: - SwHstryChgCharFmt( const SfxItemSet& rSet, const String & sFmt); - virtual void SetInDoc( SwDoc* pDoc, BOOL bTmpSet ); + SwHistoryChangeCharFmt( const SfxItemSet& rSet, const String & sFmt); + virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ); + OUT_HSTR_HINT(SetAttrSet) }; #endif -typedef SwHstryHint* SwHstryHintPtr; -SV_DECL_PTRARR_DEL( SwpHstry, SwHstryHintPtr, 0, 2 ) +typedef SwHistoryHint* SwHistoryHintPtr; +SV_DECL_PTRARR_DEL( SwpHstry, SwHistoryHintPtr, 0, 2 ) -class SwHistory : private SwpHstry +class SwHistory { - friend class SwDoc; // eig. darf nur SwDoc::DelUndoObj zugreifen - friend class SwUndoWriter; // fuer den Undo/Redo-Writer - friend class SwRegHistory; // fuer Insert, von Histoy-Attributen + friend class SwDoc; // actually only SwDoc::DelUndoObj may access + friend class SwUndoWriter; // for Undo/Redo Writer + friend class SwRegHistory; // for inserting History attributes + + SwpHstry m_SwpHstry; + USHORT m_nEndDiff; - USHORT nEndDiff; public: SwHistory( USHORT nInitSz = 0, USHORT nGrowSz = 2 ); ~SwHistory(); - // loesche die History ab Start bis zum Ende + + // delete History from nStart to array end void Delete( USHORT nStart = 0 ); - // alle Objecte zwischen nStart und Array-Ende aufrufen und loeschen - BOOL Rollback( SwDoc* pDoc, USHORT nStart = 0 ); - // alle Objecte zwischen nStart und temporaeren Ende aufrufen und - // den Start als temporaeres Ende speichern - BOOL TmpRollback( SwDoc* pDoc, USHORT nStart, BOOL ToFirst = TRUE ); + // call and delete all objects between nStart and array end + bool Rollback( SwDoc* pDoc, USHORT nStart = 0 ); + // call all objects between nStart and TmpEnd; store nStart as TmpEnd + bool TmpRollback( SwDoc* pDoc, USHORT nStart, bool ToFirst = true ); // --> OD 2008-02-27 #refactorlists# - removed <rDoc> void Add( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue, ULONG nNodeIdx ); // <-- - void Add( const SwTxtAttr* pTxtHt, ULONG nNodeIdx, - BOOL bNewAttr = TRUE ); - void Add( const SwFmtColl*, ULONG nNodeIdx, BYTE nWhichNd ); + void Add( SwTxtAttr* pTxtHt, ULONG nNodeIdx, bool bNewAttr = true ); + void Add( SwFmtColl*, ULONG nNodeIdx, BYTE nWhichNd ); void Add( const ::sw::mark::IMark&, bool bSavePos, bool bSaveOtherPos ); - void Add( const SwFrmFmt& rFmt ); - void Add( const SwFlyFrmFmt&, USHORT& rSetPos ); + void Add( SwFrmFmt& rFmt ); + void Add( SwFlyFrmFmt&, USHORT& rSetPos ); void Add( const SwTxtFtn& ); void Add( const SfxItemSet & rSet, const SwCharFmt & rCharFmt); // #i27615# - USHORT Count() const { return SwpHstry::Count(); } - USHORT GetTmpEnd() const { return SwpHstry::Count() - nEndDiff; } - USHORT SetTmpEnd( USHORT nTmpEnd ); // returne alten Wert - SwHstryHint* operator[]( USHORT nPos ) const { return SwpHstry::operator[](nPos); } + USHORT Count() const { return m_SwpHstry.Count(); } + USHORT GetTmpEnd() const { return m_SwpHstry.Count() - m_nEndDiff; } + USHORT SetTmpEnd( USHORT nTmpEnd ); // return previous value + SwHistoryHint * operator[]( USHORT nPos ) { return m_SwpHstry[nPos]; } + SwHistoryHint const* operator[]( USHORT nPos ) const + { return m_SwpHstry[nPos]; } - // fuer SwUndoDelete::Undo/Redo + // for SwUndoDelete::Undo/Redo void Move( USHORT nPos, SwHistory *pIns, - USHORT nStart = 0, USHORT nEnd = USHRT_MAX ) + USHORT nStart = 0, USHORT nEnd = USHRT_MAX ) { - SwpHstry::Insert( pIns, nPos, nStart, nEnd ); - SwpHstry* pDel = pIns; - pDel->Remove( nStart, nEnd == USHRT_MAX - ? pDel->Count() - nStart - : nEnd ); + m_SwpHstry.Insert( &pIns->m_SwpHstry, nPos, nStart, nEnd ); + pIns->m_SwpHstry.Remove( nStart, (nEnd == USHRT_MAX) + ? pIns->Count() - nStart + : nEnd ); } - // Hilfs-Methoden zum Sichern von Attributen in der History. - // Wird von UndoKlasse benutzt (Delete/Overwrite/Inserts) - void CopyAttr( const SwpHints* pHts, ULONG nNodeIdx, xub_StrLen nStt, - xub_StrLen nEnd, BOOL bFields ); + // helper methods for recording attribute in History + // used by Undo classes (Delete/Overwrite/Inserts) + void CopyAttr( SwpHints* pHts, ULONG nNodeIdx, xub_StrLen nStart, + xub_StrLen nEnd, bool bFields ); // --> OD 2008-02-27 #refactorlists# - removed <rDoc> void CopyFmtAttr( const SfxItemSet& rSet, ULONG nNodeIdx ); // <-- @@ -408,11 +435,13 @@ public: class SwRegHistory : public SwClient { - SvUShortsSort aSetWhichIds; - SwHistory* pHstry; - ULONG nNodeIdx; +private: + SvUShortsSort m_WhichIdSet; + SwHistory * const m_pHistory; + ULONG m_nNodeIndex; void _MakeSetWhichIds(); + public: // --> OD 2008-02-27 #refactorlists# - removed <rDoc> SwRegHistory( SwHistory* pHst ); @@ -424,10 +453,10 @@ public: SwRegHistory( SwModify* pRegIn, const SwNode& rNd, SwHistory* pHst ); virtual void Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ); - void Add( SwTxtAttr* pHt, const BOOL bNew = FALSE ); + void AddHint( SwTxtAttr* pHt, const bool bNew = false ); void RegisterInModify( SwModify* pRegIn, const SwNode& rNd ); - void ChangeNodeIndex( ULONG nNew ) { nNodeIdx = nNew; } + void ChangeNodeIndex( ULONG nNew ) { m_nNodeIndex = nNew; } }; #endif diff --git a/sw/inc/segdefs.hxx b/sw/inc/segdefs.hxx deleted file mode 100644 index 3ef806270595..000000000000 --- a/sw/inc/segdefs.hxx +++ /dev/null @@ -1,30 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: segdefs.hxx,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "segdefs_.hxx" diff --git a/sw/inc/segdefs_.hxx b/sw/inc/segdefs_.hxx deleted file mode 100644 index 7e4b36c657f4..000000000000 --- a/sw/inc/segdefs_.hxx +++ /dev/null @@ -1,29 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: segdefs_.hxx,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ diff --git a/sw/source/ui/inc/itemdef.hxx b/sw/inc/sw_primitivetypes2d.hxx index c73a429e0fee..1a2a9dadbe70 100644 --- a/sw/source/ui/inc/itemdef.hxx +++ b/sw/inc/sw_primitivetypes2d.hxx @@ -6,8 +6,9 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: itemdef.hxx,v $ - * $Revision: 1.3 $ + * $RCSfile: sd_primitivetypes2d.hxx,v $ + * + * $Revision: 1.2 $ * * This file is part of OpenOffice.org. * @@ -27,14 +28,23 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef ITEMDEF_HXX -#define ITEMDEF_HXX +#ifndef INCLUDED_SW_PRIMITIVETYPES2D_HXX +#define INCLUDED_SW_PRIMITIVETYPES2D_HXX -#include <sfx2/msg.hxx> +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PRIMITIVETYPES2D_HXX +#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> +#endif -SFX_DECL_TYPE(10); //SwElemItem -SFX_DECL_TYPE(13); //SwAddPrinterItem -SFX_DECL_TYPE(16); //SwDocDisplayItem +////////////////////////////////////////////////////////////////////////////// -#endif +#define PRIMITIVE2D_ID_SWVIRTFLYDRAWOBJPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_SW| 0) +#define PRIMITIVE2D_ID_SWPOSTITANKORPRIMITIVE (PRIMITIVE2D_ID_RANGE_SW| 1) +#define PRIMITIVE2D_ID_SWPOSTITSHADOWPRIMITIVE (PRIMITIVE2D_ID_RANGE_SW| 2) + +////////////////////////////////////////////////////////////////////////////// + +#endif // INCLUDED_SW_PRIMITIVETYPES2D_HXX + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/sw/inc/swcrsr.hxx b/sw/inc/swcrsr.hxx index 8dd654c4034a..42597cb62559 100644 --- a/sw/inc/swcrsr.hxx +++ b/sw/inc/swcrsr.hxx @@ -35,11 +35,6 @@ #include <cshtyp.hxx> -class SwShellCrsr; -class SwShellTableCrsr; -class SwTableCursor; -class SwUnoCrsr; -class SwUnoTableCrsr; struct _SwCursor_SavePos; namespace com { namespace sun { namespace star { namespace util { @@ -89,6 +84,11 @@ protected: const _SwCursor_SavePos* GetSavePos() const { return pSavePos; } + virtual const SwCntntFrm* DoSetBidiLevelLeftRight( + BOOL & io_rbLeft, BOOL bVisualAllowed, BOOL bInsertCrsr); + virtual void DoSetBidiLevelUpDown(); + virtual bool IsSelOvrCheck(int eFlags); + public: // single argument ctors shall be explicit. SwCursor( const SwPosition &rPos, SwPaM* pRing, bool bColumnSel ); @@ -105,18 +105,6 @@ public: virtual SwCursor* Create( SwPaM* pRing = 0 ) const; - virtual operator SwShellCrsr* (); - virtual operator SwShellTableCrsr* (); - virtual operator SwTableCursor* (); - virtual operator SwUnoCrsr* (); - virtual operator SwUnoTableCrsr* (); - - inline operator const SwShellCrsr* () const; - inline operator const SwShellTableCrsr* () const; - inline operator const SwTableCursor* () const; - inline operator const SwUnoCrsr* () const; - inline operator const SwUnoTableCrsr* () const; - virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 ); @@ -178,8 +166,8 @@ public: BOOL GoPrevSentence(){return GoSentence(PREV_SENT);} BOOL GoStartSentence(){return GoSentence(START_SENT);} - BOOL LeftRight( BOOL bLeft, USHORT nCnt, USHORT nMode, BOOL bAllowVisual, BOOL bSkipHidden, - BOOL bInsertCrsr ); + virtual BOOL LeftRight( BOOL bLeft, USHORT nCnt, USHORT nMode, + BOOL bAllowVisual, BOOL bSkipHidden, BOOL bInsertCrsr ); BOOL UpDown( BOOL bUp, USHORT nCnt, Point* pPt, long nUpDownX ); BOOL LeftRightMargin( BOOL bLeftMargin, BOOL bAPI = FALSE ); BOOL IsAtLeftRightMargin( BOOL bLeftMargin, BOOL bAPI = FALSE ) const; @@ -192,7 +180,7 @@ public: { return LeftRight( FALSE, nCnt, nMode, bAllowVisual, bSkipHidden, FALSE ); } BOOL GoNextCell( USHORT nCnt = 1 ) { return GoPrevNextCell( TRUE, nCnt ); } BOOL GoPrevCell( USHORT nCnt = 1 ) { return GoPrevNextCell( FALSE, nCnt ); } - BOOL GotoTable( const String& rName ); + virtual BOOL GotoTable( const String& rName ); BOOL GotoTblBox( const String& rName ); BOOL GotoRegion( const String& rName ); BOOL GotoFtnAnchor(); @@ -224,7 +212,10 @@ public: virtual BOOL IsAtValidPos( BOOL bPoint = TRUE ) const; // darf der Cursor in ReadOnlyBereiche? - BOOL IsReadOnlyAvailable() const; + virtual bool IsReadOnlyAvailable() const; + + virtual BOOL IsSkipOverProtectSections() const; + virtual BOOL IsSkipOverHiddenSections() const; BYTE GetCrsrBidiLevel() const { return nCursorBidiLevel; } void SetCrsrBidiLevel( BYTE nNewLevel ) { nCursorBidiLevel = nNewLevel; } @@ -275,12 +266,16 @@ protected: BOOL bChg : 1; BOOL bParked : 1; // Tabellen-Cursor wurde geparkt + virtual bool IsSelOvrCheck(int eFlags); + public: SwTableCursor( const SwPosition &rPos, SwPaM* pRing = 0 ); SwTableCursor( SwTableCursor& ); virtual ~SwTableCursor(); - virtual operator SwTableCursor* (); + virtual BOOL LeftRight( BOOL bLeft, USHORT nCnt, USHORT nMode, + BOOL bAllowVisual, BOOL bSkipHidden, BOOL bInsertCrsr ); + virtual BOOL GotoTable( const String& rName ); void InsertBox( const SwTableBox& rTblBox ); void DeleteBox( USHORT nPos ) { aSelBoxes.Remove( nPos ); bChg = TRUE; } @@ -313,34 +308,5 @@ public: void ActualizeSelection( const SwSelBoxes &rBoxes ); }; - -// --------------------------- inline Methoden ---------------------- - -inline SwCursor::operator const SwShellCrsr* () const -{ - return (SwShellCrsr*)*((SwCursor*)this); -} - -inline SwCursor::operator const SwShellTableCrsr* () const -{ - return (SwShellTableCrsr*)*((SwCursor*)this); -} - -inline SwCursor::operator const SwTableCursor* () const -{ - return (SwTableCursor*)*((SwCursor*)this); -} - -inline SwCursor::operator const SwUnoCrsr* () const -{ - return (SwUnoCrsr*)*((SwCursor*)this); -} - -inline SwCursor::operator const SwUnoTableCrsr* () const -{ - return (SwUnoTableCrsr*)*((SwCursor*)this); -} - - #endif diff --git a/sw/inc/txatbase.hxx b/sw/inc/txatbase.hxx index 45bacf92eb5c..90602a7b941c 100644 --- a/sw/inc/txatbase.hxx +++ b/sw/inc/txatbase.hxx @@ -29,11 +29,15 @@ ************************************************************************/ #ifndef _TXATBASE_HXX #define _TXATBASE_HXX + #include <tools/solar.h> #include <svtools/poolitem.hxx> #include <hintids.hxx> #include <errhdl.hxx> +#include <boost/utility.hpp> + + class SfxItemPool; class SvxBrushItem; class SvxFontItem; @@ -76,28 +80,29 @@ class SwFmtFlyCnt; class SwTOXMark; class SwFmtRefMark; -class SwTxtAttr +class SwTxtAttr : private boost::noncopyable { - const SfxPoolItem* pAttr; - xub_StrLen nStart; - BOOL bDontExpand : 1; - BOOL bLockExpandFlag : 1; + const SfxPoolItem* 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 bDontMergeAttr : 1; // refmarks, toxmarks, ruby - BOOL bDontMoveAttr : 1; // refmarks, toxmarks - BOOL bCharFmtAttr : 1; // charfmt, inet - BOOL bOverlapAllowedAttr : 1; // refmarks, toxmarks - BOOL bPriorityAttr : 1; // attribute has priority (redlining) - BOOL bDontExpandStart : 1; // don't expand start at paragraph start (ruby) protected: SwTxtAttr( const SfxPoolItem& rAttr, xub_StrLen nStart ); - void SetLockExpandFlag( BOOL bFlag ) { bLockExpandFlag = bFlag; } - void SetDontMergeAttr( BOOL bFlag ) { bDontMergeAttr = bFlag; } - void SetDontMoveAttr( BOOL bFlag ) { bDontMoveAttr = bFlag; } - void SetCharFmtAttr( BOOL bFlag ) { bCharFmtAttr = bFlag; } - void SetOverlapAllowedAttr( BOOL bFlag ){ bOverlapAllowedAttr = bFlag; } - void SetDontExpandStartAttr(BOOL bFlag) { bDontExpandStart = bFlag; } + 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; } public: virtual ~SwTxtAttr(); @@ -105,25 +110,26 @@ public: // RemoveFromPool muss immer vorm DTOR Aufruf erfolgen!! void RemoveFromPool( SfxItemPool& rPool ); - // Start Position erfragen - xub_StrLen* GetStart() { return &nStart; } - const xub_StrLen* GetStart() const { return &nStart; } + /// start position + xub_StrLen* GetStart() { return & m_nStart; } + const xub_StrLen* GetStart() const { return & m_nStart; } - // End Position erfragen + /// end position virtual xub_StrLen* GetEnd(); inline const xub_StrLen* GetEnd() const; + /// end (if available), else start inline const xub_StrLen* GetAnyEnd() const; - inline void SetDontExpand( BOOL bNew ); - BOOL DontExpand() const { return bDontExpand; } - BOOL IsLockExpandFlag() const { return bLockExpandFlag; } - BOOL IsDontMergeAttr() const { return bDontMergeAttr; } - BOOL IsDontMoveAttr() const { return bDontMoveAttr; } - BOOL IsCharFmtAttr() const { return bCharFmtAttr; } - BOOL IsOverlapAllowedAttr() const { return bOverlapAllowedAttr; } - BOOL IsPriorityAttr() const { return bPriorityAttr; } - void SetPriorityAttr( BOOL bFlag ) { bPriorityAttr = bFlag; } - BOOL IsDontExpandStartAttr() const { return bDontExpandStart; } + 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; } inline const SfxPoolItem& GetAttr() const; inline USHORT Which() const { return GetAttr().Which(); } @@ -170,9 +176,6 @@ public: inline const SvxCharReliefItem &GetCharRelief() const; inline const SvxCharHiddenItem &GetCharHidden() const; -private: - SwTxtAttr( const SwTxtAttr& ); - SwTxtAttr& operator=( const SwTxtAttr& ); }; class SwTxtAttrEnd : public SwTxtAttr @@ -180,7 +183,7 @@ class SwTxtAttrEnd : public SwTxtAttr using SwTxtAttr::GetEnd; protected: - xub_StrLen nEnd; + xub_StrLen m_nEnd; public: SwTxtAttrEnd( const SfxPoolItem& rAttr, USHORT nStart, USHORT nEnd ); @@ -193,258 +196,297 @@ public: inline const xub_StrLen* SwTxtAttr::GetEnd() const { - return ((SwTxtAttr*)this)->GetEnd(); + return const_cast<SwTxtAttr * >(this)->GetEnd(); } inline const xub_StrLen* SwTxtAttr::GetAnyEnd() const { const xub_StrLen* pEnd = GetEnd(); - return pEnd ? pEnd : &nStart; + return pEnd ? pEnd : GetStart(); } inline const SfxPoolItem& SwTxtAttr::GetAttr() const { - ASSERT( pAttr, "wo ist mein Attribut?" ); - return *pAttr; + ASSERT( m_pAttr, "SwTxtAttr: where is my attribute?" ); + return *m_pAttr; } -inline void SwTxtAttr::SetDontExpand( BOOL bNew ) +inline void SwTxtAttr::SetDontExpand( bool bDontExpand ) { - if( !bLockExpandFlag ) - bDontExpand = bNew; + if ( !m_bLockExpandFlag ) + { + m_bDontExpand = bDontExpand; + } } inline const SvxFontItem& SwTxtAttr::GetFont() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_FONT, "Falsche Abfrage" ); - return (const SvxFontItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_FONT, "Wrong attribute" ); + return (const SvxFontItem&)(*m_pAttr); } inline const SvxPostureItem& SwTxtAttr::GetPosture() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_POSTURE, "Falsche Abfrage" ); - return (const SvxPostureItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_POSTURE, + "Wrong attribute" ); + return (const SvxPostureItem&)(*m_pAttr); } inline const SvxWeightItem& SwTxtAttr::GetWeight() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_WEIGHT, "Falsche Abfrage" ); - return (const SvxWeightItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_WEIGHT, + "Wrong attribute" ); + return (const SvxWeightItem&)(*m_pAttr); } inline const SvxUnderlineItem& SwTxtAttr::GetUnderline() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_UNDERLINE, "Falsche Abfrage" ); - return (const SvxUnderlineItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_UNDERLINE, + "Wrong attribute" ); + return (const SvxUnderlineItem&)(*m_pAttr); } inline const SvxOverlineItem& SwTxtAttr::GetOverline() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_OVERLINE, "Falsche Abfrage" ); - return (const SvxOverlineItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_OVERLINE, + "Wrong attribute" ); + return (const SvxOverlineItem&)(*m_pAttr); } inline const SvxFontHeightItem& SwTxtAttr::GetFontSize() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_FONTSIZE, "Falsche Abfrage" ); - return (const SvxFontHeightItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_FONTSIZE, + "Wrong attribute" ); + return (const SvxFontHeightItem&)(*m_pAttr); } inline const SvxPropSizeItem& SwTxtAttr::GetPropSize() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_PROPORTIONALFONTSIZE, "Falsche Abfrage" ); - return (const SvxPropSizeItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_PROPORTIONALFONTSIZE, + "Wrong attribute" ); + return (const SvxPropSizeItem&)(*m_pAttr); } inline const SvxShadowedItem& SwTxtAttr::GetShadowed() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_SHADOWED, "Falsche Abfrage" ); - return (const SvxShadowedItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_SHADOWED, + "Wrong attribute" ); + return (const SvxShadowedItem&)(*m_pAttr); } inline const SvxAutoKernItem& SwTxtAttr::GetAutoKern() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_AUTOKERN, "Falsche Abfrage" ); - return (const SvxAutoKernItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_AUTOKERN, + "Wrong attribute" ); + return (const SvxAutoKernItem&)(*m_pAttr); } inline const SvxWordLineModeItem& SwTxtAttr::GetWordLineMode() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_WORDLINEMODE, "Falsche Abfrage" ); - return (const SvxWordLineModeItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_WORDLINEMODE, + "Wrong attribute" ); + return (const SvxWordLineModeItem&)(*m_pAttr); } inline const SvxContourItem& SwTxtAttr::GetContour() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_CONTOUR, "Falsche Abfrage" ); - return (const SvxContourItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CONTOUR, + "Wrong attribute" ); + return (const SvxContourItem&)(*m_pAttr); } inline const SvxCrossedOutItem& SwTxtAttr::GetCrossedOut() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_CROSSEDOUT, "Falsche Abfrage" ); - return (const SvxCrossedOutItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CROSSEDOUT, + "Wrong attribute" ); + return (const SvxCrossedOutItem&)(*m_pAttr); } inline const SvxColorItem& SwTxtAttr::GetColor() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_COLOR, "Falsche Abfrage" ); - return (const SvxColorItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_COLOR, + "Wrong attribute" ); + return (const SvxColorItem&)(*m_pAttr); } inline const SvxCharSetColorItem& SwTxtAttr::GetCharSetColor() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_CHARSETCOLOR, "Falsche Abfrage" ); - return (const SvxCharSetColorItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CHARSETCOLOR, + "Wrong attribute" ); + return (const SvxCharSetColorItem&)(*m_pAttr); } inline const SwFmtCharFmt& SwTxtAttr::GetCharFmt() const { - ASSERT( pAttr && pAttr->Which() == RES_TXTATR_CHARFMT, "Falsche Abfrage" ); - return (const SwFmtCharFmt&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_CHARFMT, + "Wrong attribute" ); + return (const SwFmtCharFmt&)(*m_pAttr); } inline const SwFmtAutoFmt& SwTxtAttr::GetAutoFmt() const { - ASSERT( pAttr && pAttr->Which() == RES_TXTATR_AUTOFMT, "Wrong request" ); - return (const SwFmtAutoFmt&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_AUTOFMT, + "Wrong attribute" ); + return (const SwFmtAutoFmt&)(*m_pAttr); } inline const SvxKerningItem& SwTxtAttr::GetKerning() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_KERNING, "Falsche Abfrage" ); - return (const SvxKerningItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_KERNING, + "Wrong attribute" ); + return (const SvxKerningItem&)(*m_pAttr); } inline const SvxCaseMapItem& SwTxtAttr::GetCaseMap() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_CASEMAP, "Falsche Abfrage" ); - return (const SvxCaseMapItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CASEMAP, + "Wrong attribute" ); + return (const SvxCaseMapItem&)(*m_pAttr); } inline const SvxLanguageItem& SwTxtAttr::GetLanguage() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_LANGUAGE, "Falsche Abfrage" ); - return (const SvxLanguageItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_LANGUAGE, + "Wrong attribute" ); + return (const SvxLanguageItem&)(*m_pAttr); } inline const SvxEscapementItem& SwTxtAttr::GetEscapement() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_ESCAPEMENT, "Falsche Abfrage" ); - return (const SvxEscapementItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_ESCAPEMENT, + "Wrong attribute" ); + return (const SvxEscapementItem&)(*m_pAttr); } inline const SvxBlinkItem& SwTxtAttr::GetBlink() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_BLINK, "Falsche Abfrage" ); - return (const SvxBlinkItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_BLINK, + "Wrong attribute" ); + return (const SvxBlinkItem&)(*m_pAttr); } inline const SvxBrushItem& SwTxtAttr::GetChrBackground() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_BACKGROUND, "Falsche Abfrage" ); - return (const SvxBrushItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_BACKGROUND, + "Wrong attribute" ); + return (const SvxBrushItem&)(*m_pAttr); } inline const SvxNoHyphenItem& SwTxtAttr::GetNoHyphenHere() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_NOHYPHEN, "Falsche Abfrage" ); - return (const SvxNoHyphenItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_NOHYPHEN, + "Wrong attribute" ); + return (const SvxNoHyphenItem&)(*m_pAttr); } inline const SwFmtSoftHyph& SwTxtAttr::GetSoftHyph() const { - ASSERT( pAttr && pAttr->Which() == RES_TXTATR_SOFTHYPH, "Falsche Abfrage" ); - return (const SwFmtSoftHyph&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_SOFTHYPH, + "Wrong attribute" ); + return (const SwFmtSoftHyph&)(*m_pAttr); } inline const SwFmtHardBlank& SwTxtAttr::GetHardBlank() const { - ASSERT( pAttr && pAttr->Which() == RES_TXTATR_HARDBLANK, "Falsche Abfrage" ); - return (const SwFmtHardBlank&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_HARDBLANK, + "Wrong attribute" ); + return (const SwFmtHardBlank&)(*m_pAttr); } inline const SwFmtFld& SwTxtAttr::GetFld() const { - ASSERT( pAttr && pAttr->Which() == RES_TXTATR_FIELD, "Falsche Abfrage" ); - return (const SwFmtFld&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_FIELD, + "Wrong attribute" ); + return (const SwFmtFld&)(*m_pAttr); } inline const SwFmtFtn& SwTxtAttr::GetFtn() const { - ASSERT( pAttr && pAttr->Which() == RES_TXTATR_FTN, "Falsche Abfrage" ); - return (const SwFmtFtn&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_FTN, "Wrong attribute" ); + return (const SwFmtFtn&)(*m_pAttr); } inline const SwFmtFlyCnt& SwTxtAttr::GetFlyCnt() const { - ASSERT( pAttr && pAttr->Which() == RES_TXTATR_FLYCNT, "Falsche Abfrage" ); - return (const SwFmtFlyCnt&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_FLYCNT, + "Wrong attribute" ); + return (const SwFmtFlyCnt&)(*m_pAttr); } inline const SwTOXMark& SwTxtAttr::GetTOXMark() const { - ASSERT( pAttr && pAttr->Which() == RES_TXTATR_TOXMARK, "Falsche Abfrage" ); - return (const SwTOXMark&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_TOXMARK, + "Wrong attribute" ); + return (const SwTOXMark&)(*m_pAttr); } inline const SwFmtRefMark& SwTxtAttr::GetRefMark() const { - ASSERT( pAttr && pAttr->Which() == RES_TXTATR_REFMARK, "Falsche Abfrage" ); - return (const SwFmtRefMark&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_REFMARK, + "Wrong attribute" ); + return (const SwFmtRefMark&)(*m_pAttr); } inline const SwFmtINetFmt& SwTxtAttr::GetINetFmt() const { - ASSERT( pAttr && pAttr->Which() == RES_TXTATR_INETFMT, "Falsche Abfrage" ); - return (const SwFmtINetFmt&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_INETFMT, + "Wrong attribute" ); + return (const SwFmtINetFmt&)(*m_pAttr); } inline const SvXMLAttrContainerItem& SwTxtAttr::GetXMLAttrContainer() const { - ASSERT( pAttr && pAttr->Which() == RES_UNKNOWNATR_CONTAINER, "Falsche Abfrage" ); - return (const SvXMLAttrContainerItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_UNKNOWNATR_CONTAINER, + "Wrong attribute" ); + return (const SvXMLAttrContainerItem&)(*m_pAttr); } inline const SwFmtRuby& SwTxtAttr::GetRuby() const { - ASSERT( pAttr && pAttr->Which() == RES_TXTATR_CJK_RUBY, "Falsche Abfrage" ); - return (const SwFmtRuby&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_CJK_RUBY, + "Wrong attribute" ); + return (const SwFmtRuby&)(*m_pAttr); } inline const SvxTwoLinesItem& SwTxtAttr::Get2Lines() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_TWO_LINES, "Falsche Abfrage" ); - return (const SvxTwoLinesItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_TWO_LINES, + "Wrong attribute" ); + return (const SvxTwoLinesItem&)(*m_pAttr); } inline const SvxEmphasisMarkItem& SwTxtAttr::GetEmphasisMark() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_EMPHASIS_MARK, "Falsche Abfrage" ); - return (const SvxEmphasisMarkItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_EMPHASIS_MARK, + "Wrong attribute" ); + return (const SvxEmphasisMarkItem&)(*m_pAttr); } inline const SvxCharScaleWidthItem& SwTxtAttr::GetCharScaleW() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_SCALEW, "Falsche Abfrage" ); - return (const SvxCharScaleWidthItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_SCALEW, + "Wrong attribute" ); + return (const SvxCharScaleWidthItem&)(*m_pAttr); } -inline const SvxCharRotateItem& SwTxtAttr::GetCharRotate() const +inline const SvxCharRotateItem& SwTxtAttr::GetCharRotate() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_ROTATE, "Falsche Abfrage" ); - return (const SvxCharRotateItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_ROTATE, + "Wrong attribute" ); + return (const SvxCharRotateItem&)(*m_pAttr); } inline const SvxCharReliefItem& SwTxtAttr::GetCharRelief() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_RELIEF, "Falsche Abfrage" ); - return (const SvxCharReliefItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_RELIEF, + "Wrong attribute" ); + return (const SvxCharReliefItem&)(*m_pAttr); } inline const SvxCharHiddenItem& SwTxtAttr::GetCharHidden() const { - ASSERT( pAttr && pAttr->Which() == RES_CHRATR_HIDDEN, "Falsche Abfrage" ); - return (const SvxCharHiddenItem&)*pAttr; + ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_HIDDEN, + "Wrong attribute" ); + return (const SvxCharHiddenItem&)(*m_pAttr); } #endif diff --git a/sw/inc/txtatr.hxx b/sw/inc/txtatr.hxx index 50914169d6fc..3b03173e17ed 100644 --- a/sw/inc/txtatr.hxx +++ b/sw/inc/txtatr.hxx @@ -42,32 +42,33 @@ class SvxTwoLinesItem; class SwTxtCharFmt : public SwTxtAttrEnd { - SwTxtNode* pMyTxtNd; - USHORT mnSortNumber; + SwTxtNode * m_pTxtNode; + USHORT m_nSortNumber; public: - SwTxtCharFmt( const SwFmtCharFmt& rAttr, xub_StrLen nStart, xub_StrLen nEnd ); - ~SwTxtCharFmt( ); + SwTxtCharFmt( SwFmtCharFmt& rAttr, xub_StrLen nStart, xub_StrLen nEnd ); + virtual ~SwTxtCharFmt( ); // werden vom SwFmtCharFmt hierher weitergeleitet virtual void Modify( SfxPoolItem*, SfxPoolItem* ); // SwClient virtual BOOL GetInfo( SfxPoolItem& rInfo ) const; - // erfrage und setze den TxtNode Pointer - void ChgTxtNode( const SwTxtNode* pNew ) { pMyTxtNd = (SwTxtNode*)pNew; } + // get and set TxtNode pointer + void ChgTxtNode( SwTxtNode* pNew ) { m_pTxtNode = pNew; } - void SetSortNumber( USHORT nSortNumber ) { mnSortNumber = nSortNumber; } - USHORT GetSortNumber() const { return mnSortNumber; } + void SetSortNumber( USHORT nSortNumber ) { m_nSortNumber = nSortNumber; } + USHORT GetSortNumber() const { return m_nSortNumber; } }; // ATT_HARDBLANK ****************************** class SwTxtHardBlank : public SwTxtAttr { - sal_Unicode cChar; + sal_Unicode m_Char; + public: SwTxtHardBlank( const SwFmtHardBlank& rAttr, xub_StrLen nStart ); - inline sal_Unicode GetChar() const { return cChar; } + inline sal_Unicode GetChar() const { return m_Char; } }; // ATT_XNLCONTAINERITEM ****************************** @@ -83,20 +84,20 @@ public: class SW_DLLPUBLIC SwTxtRuby : public SwTxtAttrEnd, public SwClient { - SwTxtNode* pMyTxtNd; + SwTxtNode* m_pTxtNode; public: - SwTxtRuby( const SwFmtRuby& rAttr, xub_StrLen nStart, xub_StrLen nEnd ); + SwTxtRuby( SwFmtRuby& rAttr, xub_StrLen nStart, xub_StrLen nEnd ); virtual ~SwTxtRuby(); TYPEINFO(); virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); virtual BOOL GetInfo( SfxPoolItem& rInfo ) const; - // erfrage und setze den TxtNode Pointer - const SwTxtNode* GetpTxtNode() const { return pMyTxtNd; } + /// get and set TxtNode pointer + const SwTxtNode* GetpTxtNode() const { return m_pTxtNode; } inline const SwTxtNode& GetTxtNode() const; - void ChgTxtNode( const SwTxtNode* pNew ) { pMyTxtNd = (SwTxtNode*)pNew; } + void ChgTxtNode( SwTxtNode* pNew ) { m_pTxtNode = pNew; } SwCharFmt* GetCharFmt(); const SwCharFmt* GetCharFmt() const @@ -116,8 +117,8 @@ public: inline const SwTxtNode& SwTxtRuby::GetTxtNode() const { - ASSERT( pMyTxtNd, "SwTxtRuby:: wo ist mein TextNode?" ); - return *pMyTxtNd; + ASSERT( m_pTxtNode, "SwTxtRuby: where is my TxtNode?" ); + return *m_pTxtNode; } #endif diff --git a/sw/inc/txtflcnt.hxx b/sw/inc/txtflcnt.hxx index ca8fbbf4f2ea..e88fbb55bee5 100644 --- a/sw/inc/txtflcnt.hxx +++ b/sw/inc/txtflcnt.hxx @@ -45,7 +45,7 @@ class SwTxtFlyCnt : public SwTxtAttr SwFlyInCntFrm *_GetFlyFrm( const SwFrm *pCurrFrm ); public: - SwTxtFlyCnt( const SwFmtFlyCnt& rAttr, xub_StrLen nStart ); + SwTxtFlyCnt( SwFmtFlyCnt& rAttr, xub_StrLen nStart ); // Setzt den Anker im pFmt und void SetAnchor( const SwTxtNode *pNode ); @@ -64,7 +64,7 @@ inline SwFlyInCntFrm *SwTxtFlyCnt::GetFlyFrm( const SwFrm *pCurrFrm ) inline const SwFlyInCntFrm *SwTxtFlyCnt::GetFlyFrm( const SwFrm *pCurrFrm ) const { - return ((SwTxtFlyCnt*)this)->_GetFlyFrm( pCurrFrm ); + return (const_cast<SwTxtFlyCnt*>(this))->_GetFlyFrm( pCurrFrm ); } #endif diff --git a/sw/inc/txtfld.hxx b/sw/inc/txtfld.hxx index 85af7e3f1046..d290b16dd710 100644 --- a/sw/inc/txtfld.hxx +++ b/sw/inc/txtfld.hxx @@ -40,20 +40,21 @@ class SwTxtNode; class SwTxtFld : public SwTxtAttr { - mutable String aExpand; - SwTxtNode *pMyTxtNd; + mutable String m_aExpand; + SwTxtNode * m_pTxtNode; + public: - SwTxtFld( const SwFmtFld& rAttr, xub_StrLen nStart ); - ~SwTxtFld(); + SwTxtFld( SwFmtFld& rAttr, xub_StrLen nStart ); + virtual ~SwTxtFld(); void CopyFld( SwTxtFld *pDest ) const; void Expand() const; inline void ExpandAlways(); - // erfrage und setze den TxtNode Pointer - SwTxtNode* GetpTxtNode() const { return pMyTxtNd; } + // get and set TxtNode pointer + SwTxtNode* GetpTxtNode() const { return m_pTxtNode; } inline SwTxtNode& GetTxtNode() const; - void ChgTxtNode( const SwTxtNode* pNew ) { pMyTxtNd = (SwTxtNode*)pNew; } + void ChgTxtNode( SwTxtNode* pNew ) { m_pTxtNode = pNew; } // enable notification that field content has changed and needs reformatting void NotifyContentChange(SwFmtFld& rFmtFld); @@ -68,13 +69,13 @@ public: inline SwTxtNode& SwTxtFld::GetTxtNode() const { - ASSERT( pMyTxtNd, "SwTxtFld:: wo ist mein TextNode?" ); - return *pMyTxtNd; + ASSERT( m_pTxtNode, "SwTxtFld:: where is my TxtNode?" ); + return *m_pTxtNode; } inline void SwTxtFld::ExpandAlways() { - aExpand += ' '; + m_aExpand += ' '; Expand(); } diff --git a/sw/inc/txtftn.hxx b/sw/inc/txtftn.hxx index c2011babf8a9..6ed95e05ba06 100644 --- a/sw/inc/txtftn.hxx +++ b/sw/inc/txtftn.hxx @@ -41,26 +41,22 @@ class SwDoc; class SW_DLLPUBLIC SwTxtFtn : public SwTxtAttr { - SwNodeIndex *pStartNode; - SwTxtNode* pMyTxtNd; - USHORT nSeqNo; - - // Zuweisung und Copy-Ctor sind nicht erlaubt. - SwTxtFtn& operator=( const SwTxtFtn &rTxtFtn ); - SwTxtFtn( const SwTxtFtn &rTxtFtn ); + SwNodeIndex * m_pStartNode; + SwTxtNode * m_pTxtNode; + USHORT m_nSeqNo; public: - SwTxtFtn( const SwFmtFtn& rAttr, xub_StrLen nStart ); - ~SwTxtFtn(); + SwTxtFtn( SwFmtFtn& rAttr, xub_StrLen nStart ); + virtual ~SwTxtFtn(); - inline SwNodeIndex *GetStartNode() const { return pStartNode; } + 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 ); - // erfrage und setze den TxtNode Pointer + // get and set TxtNode pointer inline const SwTxtNode& GetTxtNode() const; - void ChgTxtNode( const SwTxtNode* pNew ) { pMyTxtNd = (SwTxtNode*)pNew; } + void ChgTxtNode( SwTxtNode* pNew ) { m_pTxtNode = pNew; } // lege eine neue leere TextSection fuer diese Fussnote an void MakeNewTextSection( SwNodes& rNodes ); @@ -72,16 +68,16 @@ public: // fuer die Querverweise auf Fussnoten USHORT SetSeqRefNo(); - void SetSeqNo( USHORT n ) { nSeqNo = n; } // fuer die Reader - USHORT GetSeqRefNo() const { return nSeqNo; } + void SetSeqNo( USHORT n ) { m_nSeqNo = n; } // for Readers + USHORT GetSeqRefNo() const { return m_nSeqNo; } static void SetUniqueSeqRefNo( SwDoc& rDoc ); }; inline const SwTxtNode& SwTxtFtn::GetTxtNode() const { - ASSERT( pMyTxtNd, "SwTxtFtn:: wo ist mein TextNode?" ); - return *pMyTxtNd; + ASSERT( m_pTxtNode, "SwTxtFtn: where is my TxtNode?" ); + return *m_pTxtNode; } #endif diff --git a/sw/inc/txtinet.hxx b/sw/inc/txtinet.hxx index ef55bf69d5c9..e37a18a3f823 100644 --- a/sw/inc/txtinet.hxx +++ b/sw/inc/txtinet.hxx @@ -29,54 +29,54 @@ ************************************************************************/ #ifndef _TXTINET_HXX #define _TXTINET_HXX + #include <txatbase.hxx> #include <calbck.hxx> class SwTxtNode; class SwCharFmt; -class Color; // ATT_INETFMT ********************************************* class SW_DLLPUBLIC SwTxtINetFmt : public SwTxtAttrEnd, public SwClient { - SwTxtNode* pMyTxtNd; - BOOL bVisited : 1; // Besuchter Link? - BOOL bValidVis : 1; // Ist das bVisited-Flag gueltig? - BOOL bColor : 1; + SwTxtNode * m_pTxtNode; + bool m_bVisited : 1; // visited link? + bool m_bVisitedValid : 1; // is m_bVisited valid? // forbidden and not implemented. SwTxtINetFmt(); public: - SwTxtINetFmt( const SwFmtINetFmt& rAttr, xub_StrLen nStart, xub_StrLen nEnd ); + SwTxtINetFmt( SwFmtINetFmt& rAttr, xub_StrLen nStart, xub_StrLen nEnd ); virtual ~SwTxtINetFmt(); TYPEINFO(); virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); virtual BOOL GetInfo( SfxPoolItem& rInfo ) const; - // erfrage und setze den TxtNode Pointer - const SwTxtNode* GetpTxtNode() const { return pMyTxtNd; } + // get and set TxtNode pointer + const SwTxtNode* GetpTxtNode() const { return m_pTxtNode; } inline const SwTxtNode& GetTxtNode() const; - void ChgTxtNode( const SwTxtNode* pNew ) { pMyTxtNd = (SwTxtNode*)pNew; } + void ChgTxtNode( SwTxtNode* pNew ) { m_pTxtNode = pNew; } SwCharFmt* GetCharFmt(); const SwCharFmt* GetCharFmt() const - { return ((SwTxtINetFmt*)this)->GetCharFmt(); } + { return const_cast<SwTxtINetFmt*>(this)->GetCharFmt(); } - BOOL IsVisited() const { return bVisited; } - void SetVisited( BOOL bNew ) { bVisited = bNew; } + bool IsVisited() const { return m_bVisited; } + void SetVisited( bool bNew ) { m_bVisited = bNew; } - BOOL IsValidVis() const { return bValidVis; } - void SetValidVis( BOOL bNew ) { bValidVis = bNew; } + bool IsVisitedValid() const { return m_bVisitedValid; } + void SetVisitedValid( bool bNew ) { m_bVisitedValid = bNew; } BOOL IsProtect() const; }; + inline const SwTxtNode& SwTxtINetFmt::GetTxtNode() const { - ASSERT( pMyTxtNd, "SwTxtINetFmt:: wo ist mein TextNode?" ); - return *pMyTxtNd; + ASSERT( m_pTxtNode, "SwTxtINetFmt: where is my TxtNode?" ); + return *m_pTxtNode; } #endif diff --git a/sw/inc/txtrfmrk.hxx b/sw/inc/txtrfmrk.hxx index 0496e9706e21..73319fd6a209 100644 --- a/sw/inc/txtrfmrk.hxx +++ b/sw/inc/txtrfmrk.hxx @@ -39,23 +39,25 @@ class SwTxtNode; class SwTxtRefMark : public SwTxtAttrEnd { - SwTxtNode* pMyTxtNd; - USHORT* pEnd; // fuer InhaltsReferenz / PositionRef. ohne Ende + SwTxtNode * m_pTxtNode; + xub_StrLen * m_pEnd; // end is optional (point reference) + public: - SwTxtRefMark( const SwFmtRefMark& rAttr, - xub_StrLen nStart, xub_StrLen * pEnd = 0 ); + SwTxtRefMark( SwFmtRefMark& rAttr, + xub_StrLen nStart, xub_StrLen * pEnd = 0 ); - virtual xub_StrLen *GetEnd(); // SwTxtAttr - inline const xub_StrLen* GetEnd() const { return pEnd; } + virtual xub_StrLen * GetEnd(); // SwTxtAttr + inline const xub_StrLen * GetEnd() const { return m_pEnd; } - // erfrage und setze den TxtNode Pointer + // get and set TxtNode pointer inline const SwTxtNode& GetTxtNode() const; - void ChgTxtNode( const SwTxtNode* pNew ) { pMyTxtNd = (SwTxtNode*)pNew; } + void ChgTxtNode( SwTxtNode* pNew ) { m_pTxtNode = pNew; } }; + inline const SwTxtNode& SwTxtRefMark::GetTxtNode() const { - ASSERT( pMyTxtNd, "SwTxtRefMark:: wo ist mein TextNode?" ); - return *pMyTxtNd; + ASSERT( m_pTxtNode, "SwTxtRefMark: where is my TxtNode?" ); + return *m_pTxtNode; } #endif diff --git a/sw/inc/txttxmrk.hxx b/sw/inc/txttxmrk.hxx index 98096d620c2d..fe9e37775b17 100644 --- a/sw/inc/txttxmrk.hxx +++ b/sw/inc/txttxmrk.hxx @@ -40,28 +40,28 @@ class SwDoc; class SwTxtTOXMark : public SwTxtAttrEnd { - xub_StrLen* pEnd; // wenn AlternativText vom SwTOXMark dann 0 !! - SwTxtNode* pMyTxtNd; + SwTxtNode * m_pTxtNode; + xub_StrLen * m_pEnd; // 0 if SwTOXMark without AlternativeText + public: - SwTxtTOXMark( const SwTOXMark& rAttr, - xub_StrLen nStart, xub_StrLen * pEnd = 0 ); + SwTxtTOXMark( SwTOXMark& rAttr, xub_StrLen nStart, xub_StrLen * pEnd = 0 ); virtual ~SwTxtTOXMark(); - virtual xub_StrLen *GetEnd(); // SwTxtAttr - inline const xub_StrLen* GetEnd() const { return pEnd; } + virtual xub_StrLen *GetEnd(); // SwTxtAttr + inline const xub_StrLen* GetEnd() const { return m_pEnd; } void CopyTOXMark( SwDoc* pDestDoc ); - // erfrage und setze den TxtNode Pointer - inline const SwTxtNode* GetpTxtNd() const { return pMyTxtNd; } + // get and set TxtNode pointer + inline const SwTxtNode* GetpTxtNd() const { return m_pTxtNode; } inline const SwTxtNode& GetTxtNode() const; - void ChgTxtNode( const SwTxtNode* pNew ) { pMyTxtNd = (SwTxtNode*)pNew; } + void ChgTxtNode( SwTxtNode* pNew ) { m_pTxtNode = pNew; } }; inline const SwTxtNode& SwTxtTOXMark::GetTxtNode() const { - ASSERT( pMyTxtNd, "SwTxtTOXMark:: wo ist mein TextNode?" ); - return *pMyTxtNd; + ASSERT( m_pTxtNode, "SwTxtTOXMark: where is my TxtNode?" ); + return *m_pTxtNode; } #endif diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx index 00053210553a..2c7282778053 100644 --- a/sw/inc/undobj.hxx +++ b/sw/inc/undobj.hxx @@ -53,6 +53,10 @@ #include <vector> // <-- +#include <boost/shared_ptr.hpp> +#include <memory> + + class SwUndoIter; class SwHistory; class SwIndex; @@ -68,7 +72,7 @@ class SwTable; class SwTableBox; struct SwSortOptions; class SwFrmFmt; -class SwHstryBookmark; +class SwHistoryBookmark; class SwSection; class SwSectionFmt; class SvxTabStopItem; @@ -102,6 +106,10 @@ class SwRedlineSaveData; class SwRedline; struct SwSaveRowSpan; +namespace sfx2 { + class MetadatableUndo; +} + namespace utl { class TransliterationWrapper; } @@ -400,6 +408,8 @@ class SwUndoDelete: public SwUndo, private SwUndRng, private SwUndoSaveCntnt String *pSttStr, *pEndStr; SwRedlineData* pRedlData; SwRedlineSaveDatas* pRedlSaveData; + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart; + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd; String sTableName; @@ -557,14 +567,15 @@ public: class SwUndoAttr : public SwUndo, private SwUndRng { - SfxItemSet aSet; // Attribute fuers Redo - SwHistory* pHistory; // History fuers Undo - SwRedlineData* pRedlData; // Redlining - SwRedlineSaveDatas* pRedlSaveData; - ULONG nNdIdx; // fuers Redlining - Offset - USHORT nInsFlags; // Einfuege Flags + SfxItemSet m_AttrSet; // attributes for Redo + const ::std::auto_ptr<SwHistory> m_pHistory; // History for Undo + ::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 void RemoveIdx( SwDoc& rDoc ); + public: SwUndoAttr( const SwPaM&, const SfxItemSet&, USHORT nFlags = 0 ); SwUndoAttr( const SwPaM&, const SfxPoolItem&, USHORT nFlags = 0 ); @@ -572,40 +583,44 @@ public: virtual void Undo( SwUndoIter& ); virtual void Redo( SwUndoIter& ); virtual void Repeat( SwUndoIter& ); - SwHistory* GetHistory() { return pHistory; } void SaveRedlineData( const SwPaM& rPam, BOOL bInsCntnt ); + SwHistory& GetHistory() { return *m_pHistory; } + OUT_UNDOBJ( InsAttr ) }; -class SwUndoRstAttr : public SwUndo, private SwUndRng +class SwUndoResetAttr : public SwUndo, private SwUndRng { - SwHistory* pHistory; - SvUShortsSort aIds; - USHORT nFmtId; // Format-Id fuer das Redo + const ::std::auto_ptr<SwHistory> m_pHistory; + SvUShortsSort m_Ids; + const USHORT m_nFormatId; // Format-Id for Redo + public: - SwUndoRstAttr( const SwPaM&, USHORT nFmtId ); - SwUndoRstAttr( const SwDoc&, const SwPosition&, USHORT nWhichId ); - virtual ~SwUndoRstAttr(); + SwUndoResetAttr( const SwPaM&, USHORT nFmtId ); + SwUndoResetAttr( const SwPosition&, USHORT nFmtId ); + virtual ~SwUndoResetAttr(); virtual void Undo( SwUndoIter& ); virtual void Redo( SwUndoIter& ); virtual void Repeat( SwUndoIter& ); void SetAttrs( const SvUShortsSort& rArr ); - SwHistory* GetHistory() { return pHistory; } + + SwHistory& GetHistory() { return *m_pHistory; } + OUT_UNDOBJ( ResetAttr ) }; class SwUndoFmtAttr : public SwUndo { friend class SwUndoDefaultAttr; - SwFmt* pFmt; - SfxItemSet* pOldSet; // die alten Attribute - ULONG nNode; - const USHORT nFmtWhich; - const BOOL bSaveDrawPt; - - int IsFmtInDoc( SwDoc* ); // ist das Attribut-Format noch im Doc ? - void SaveFlyAnchor( BOOL bSaveDrawPt = FALSE ); + SwFmt * m_pFmt; + ::std::auto_ptr<SfxItemSet> m_pOldSet; // old attributes + ULONG m_nNodeIndex; + const USHORT m_nFmtWhich; + const bool m_bSaveDrawPt; + + bool IsFmtInDoc( SwDoc* ); //is the attribute format still in the Doc? + void SaveFlyAnchor( bool bSaveDrawPt = false ); // --> OD 2004-10-26 #i35443# - Add return value, type <bool>. // Return value indicates, if anchor attribute is restored. // Notes: - If anchor attribute is restored, all other existing attributes @@ -621,15 +636,15 @@ class SwUndoFmtAttr : public SwUndo // <-- public: - // meldet sich im Format an und sichert sich die alten Attribute + // register at the Format and save old attributes // --> OD 2008-02-27 #refactorlists# - removed <rNewSet> SwUndoFmtAttr( const SfxItemSet& rOldSet, SwFmt& rFmt, - BOOL bSaveDrawPt = TRUE ); + bool bSaveDrawPt = true ); // <-- SwUndoFmtAttr( const SfxPoolItem& rItem, SwFmt& rFmt, - BOOL bSaveDrawPt = TRUE ); + bool bSaveDrawPt = true ); virtual ~SwUndoFmtAttr(); virtual void Undo( SwUndoIter& ); // --> OD 2004-10-26 #i35443# - <Redo(..)> calls <Undo(..)> - nothing else @@ -641,7 +656,7 @@ public: OUT_UNDOBJ( InsFmtAttr ) void PutAttr( const SfxPoolItem& rItem ); - SwFmt* GetFmt( SwDoc& rDoc ); // prueft, ob es noch im Doc ist! + SwFmt* GetFmt( SwDoc& rDoc ); // checks if it is still in the Doc! }; // --> OD 2008-02-12 #newlistlevelattrs# @@ -657,18 +672,19 @@ class SwUndoFmtResetAttr : public SwUndo private: // format at which a certain attribute is reset. - SwFmt* mpChangedFormat; + SwFmt * const m_pChangedFormat; // which ID of the reset attribute - USHORT mnWhichId; + const USHORT m_nWhichId; // old attribute which has been reset - needed for undo. - SfxPoolItem* mpOldItem; + ::std::auto_ptr<SfxPoolItem> m_pOldItem; }; // <-- class SwUndoDontExpandFmt : public SwUndo { - ULONG nNode; - xub_StrLen nCntnt; + const ULONG m_nNodeIndex; + const xub_StrLen m_nContentIndex; + public: SwUndoDontExpandFmt( const SwPosition& rPos ); virtual void Undo( SwUndoIter& ); @@ -676,14 +692,20 @@ public: virtual void Repeat( SwUndoIter& ); }; -// Hilfs-Klasse, um die geaenderten Sets zu "empfangen" -struct _UndoFmtAttr : public SwClient +// helper class to receive changed attribute sets +class SwUndoFmtAttrHelper : public SwClient { - SwUndoFmtAttr* pUndo; - BOOL bSaveDrawPt; + ::std::auto_ptr<SwUndoFmtAttr> m_pUndo; + const bool m_bSaveDrawPt; + +public: + SwUndoFmtAttrHelper( SwFmt& rFmt, bool bSaveDrawPt = true ); - _UndoFmtAttr( SwFmt& rFmt, BOOL bSaveDrawPt = TRUE ); virtual void Modify( SfxPoolItem*, SfxPoolItem* ); + + SwUndoFmtAttr* GetUndo() const { return m_pUndo.get(); } + // release the undo object (so it is not deleted here), and return it + SwUndoFmtAttr* ReleaseUndo() { return m_pUndo.release(); } }; @@ -735,15 +757,18 @@ public: class SwUndoMoveLeftMargin : public SwUndo, private SwUndRng { - SwHistory* pHistory; - BOOL bModulus; + const ::std::auto_ptr<SwHistory> m_pHistory; + const bool m_bModulus; + public: SwUndoMoveLeftMargin( const SwPaM&, BOOL bRight, BOOL bModulus ); virtual ~SwUndoMoveLeftMargin(); virtual void Undo( SwUndoIter& ); virtual void Redo( SwUndoIter& ); virtual void Repeat( SwUndoIter& ); - SwHistory* GetHistory() { return pHistory; } + + SwHistory& GetHistory() { return *m_pHistory; } + OUT_UNDOBJ( MoveLeftMargin ) }; @@ -1081,7 +1106,8 @@ public: class SwUndoBookmark : public SwUndo { - SwHstryBookmark* pHBookmark; + const ::std::auto_ptr<SwHistoryBookmark> m_pHistoryBookmark; + protected: SwUndoBookmark( SwUndoId nUndoId, const ::sw::mark::IMark& ); @@ -1417,10 +1443,11 @@ public: class SwUndoDefaultAttr : public SwUndo { - SfxItemSet* pOldSet; // die alten Attribute - SvxTabStopItem* pTabStop; + ::std::auto_ptr<SfxItemSet> m_pOldSet; // the old attributes + ::std::auto_ptr<SvxTabStopItem> m_pTabStop; + public: - // meldet sich im Format an und sichert sich die alten Attribute + // registers at the format and saves old attributes SwUndoDefaultAttr( const SfxItemSet& rOldSet ); virtual ~SwUndoDefaultAttr(); virtual void Undo( SwUndoIter& ); @@ -1716,31 +1743,32 @@ public: //-------------------------------------------------------------------- -class SwUndoChgFtn : public SwUndo, private SwUndRng +class SwUndoChangeFootNote : public SwUndo, private SwUndRng { - SwHistory* pHistory; - String sTxt; - USHORT nNo; - BOOL bEndNote; + const ::std::auto_ptr<SwHistory> m_pHistory; + const String m_Text; + const USHORT m_nNumber; + const bool m_bEndNote; + public: - SwUndoChgFtn( const SwPaM& rRange, const String& rTxt, - USHORT nNum, BOOL bIsEndNote ); - virtual ~SwUndoChgFtn(); + SwUndoChangeFootNote( const SwPaM& rRange, const String& rTxt, + USHORT nNum, bool bIsEndNote ); + virtual ~SwUndoChangeFootNote(); virtual void Undo( SwUndoIter& ); virtual void Redo( SwUndoIter& ); virtual void Repeat( SwUndoIter& ); - SwHistory* GetHistory() { return pHistory; } + SwHistory& GetHistory() { return *m_pHistory; } }; -class SwUndoFtnInfo : public SwUndo +class SwUndoFootNoteInfo : public SwUndo { - SwFtnInfo *pFtnInfo; + ::std::auto_ptr<SwFtnInfo> m_pFootNoteInfo; public: - SwUndoFtnInfo( const SwFtnInfo &rInfo ); - virtual ~SwUndoFtnInfo(); + SwUndoFootNoteInfo( const SwFtnInfo &rInfo ); + virtual ~SwUndoFootNoteInfo(); virtual void Undo( SwUndoIter& ); virtual void Redo( SwUndoIter& ); @@ -1748,7 +1776,7 @@ public: class SwUndoEndNoteInfo : public SwUndo { - SwEndNoteInfo *pEndNoteInfo; + ::std::auto_ptr<SwEndNoteInfo> m_pEndNoteInfo; public: SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo ); @@ -1776,7 +1804,7 @@ public: virtual void Redo( SwUndoIter& rUndoIter ); virtual void Repeat( SwUndoIter& rUndoIter ); - void AddChanges( const SwTxtNode& rTNd, xub_StrLen nStart, xub_StrLen nLen, + void AddChanges( SwTxtNode& rTNd, xub_StrLen nStart, xub_StrLen nLen, ::com::sun::star::uno::Sequence <sal_Int32>& rOffsets ); BOOL HasData() const {return 0 != pData; } }; diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx index 99a089f1194e..f728c51293e9 100644 --- a/sw/inc/unocoll.hxx +++ b/sw/inc/unocoll.hxx @@ -518,7 +518,8 @@ SwSimpleIndexAccessBaseClass; class SwXFootnotes : public SwSimpleIndexAccessBaseClass, public SwUnoCollection { - sal_Bool bEndnote; + const bool m_bEndnote; + protected: virtual ~SwXFootnotes(); public: diff --git a/sw/inc/unocrsr.hxx b/sw/inc/unocrsr.hxx index f3c1bb8ebef9..f58bc92fa3a3 100644 --- a/sw/inc/unocrsr.hxx +++ b/sw/inc/unocrsr.hxx @@ -49,9 +49,14 @@ private: // forbidden and not implemented. //SwUnoCrsr( const SwUnoCrsr& ); SwUnoCrsr & operator= ( const SwUnoCrsr& ); -public: - virtual operator SwUnoCrsr* (); +protected: + + virtual const SwCntntFrm* DoSetBidiLevelLeftRight( + BOOL & io_rbLeft, BOOL bVisualAllowed, BOOL bInsertCrsr); + virtual void DoSetBidiLevelUpDown(); + +public: // virtual SwCursor* Create( SwPaM* pRing = 0 ) const; @@ -62,21 +67,23 @@ public: nsSwCursorSelOverFlags::SELOVER_TOGGLE | nsSwCursorSelOverFlags::SELOVER_CHANGEPOS )); + virtual bool IsReadOnlyAvailable() const; + BOOL IsRemainInSection() const { return bRemainInSection; } void SetRemainInSection( BOOL bFlag ) { bRemainInSection = bFlag; } - BOOL IsSkipOverProtectSections() const + virtual BOOL IsSkipOverProtectSections() const { return bSkipOverProtectSections; } void SetSkipOverProtectSections( BOOL bFlag ) { bSkipOverProtectSections = bFlag; } - BOOL IsSkipOverHiddenSections() const + virtual BOOL IsSkipOverHiddenSections() const { return bSkipOverHiddenSections; } void SetSkipOverHiddenSections( BOOL bFlag ) { bSkipOverHiddenSections = bFlag; } // make copy of cursor - SwUnoCrsr * Clone() const; + virtual SwUnoCrsr * Clone() const; DECL_FIXEDMEMPOOL_NEWDEL( SwUnoCrsr ) }; @@ -98,10 +105,6 @@ public: // virtual SwCursor* Create( SwPaM* pRing = 0 ) const; - virtual operator SwUnoCrsr* (); - virtual operator SwUnoTableCrsr* (); - virtual operator SwTableCursor* (); - // gibt es eine Selection vom Content in die Tabelle // Return Wert gibt an, ob der Crsr auf der alten Position verbleibt virtual BOOL IsSelOvr( int eFlags = @@ -109,6 +112,8 @@ public: nsSwCursorSelOverFlags::SELOVER_TOGGLE | nsSwCursorSelOverFlags::SELOVER_CHANGEPOS )); + virtual SwUnoTableCrsr * Clone() const; + void MakeBoxSels(); SwCursor& GetSelRing() { return aTblSel; } diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index 74a67295d23e..dc0bd7dfafc3 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -90,22 +90,14 @@ #include <tools/link.hxx> #include <IDocumentMarkAccess.hxx> +#include <sfx2/Metadatable.hxx> + class SwUnoCrsr; class SwCursor; class SwFmtFtn; class SwFmtRefMark; class GetCurTxtFmtColl; -/* -----------------------------01.12.00 18:09-------------------------------- - - ---------------------------------------------------------------------------*/ -class SwParaSelection -{ - SwUnoCrsr* pUnoCrsr; -public: - SwParaSelection(SwUnoCrsr* pCrsr); - ~SwParaSelection(); -}; /* -----------------29.04.98 07:35------------------- * @@ -751,14 +743,12 @@ class SW_DLLPUBLIC SwXTextRange : public cppu::WeakImplHelper8 void DeleteAndInsert(const String& rText) throw( ::com::sun::star::uno::RuntimeException ); protected: virtual ~SwXTextRange(); + public: - SwXTextRange(SwPaM& rPam, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > & rxParent); - SwXTextRange(SwFrmFmt& rFmt, SwPaM& rPam); - SwXTextRange(SwFrmFmt& rTblFmt, SwTableBox& rTblBox, SwPaM& rPam); - SwXTextRange(SwFrmFmt& rTblFmt, const SwStartNode& rStartNode, SwPaM& rPam); + SwXTextRange(SwPaM& rPam, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > & rxParent, enum RangePosition eRange = RANGE_IN_TEXT); + // only for RANGE_IS_TABLE SwXTextRange(SwFrmFmt& rTblFmt); - TYPEINFO(); static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); @@ -822,6 +812,8 @@ public: static ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > CreateTextRangeFromPosition( SwDoc* pDoc, const SwPosition& rPos, const SwPosition* pMark); + static ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > CreateParentXText(SwDoc* pDoc, + const SwPosition& rPos); }; /* -----------------15.05.98 08:29------------------- @@ -1146,8 +1138,9 @@ public: /*-----------------07.04.98 08:15------------------- --------------------------------------------------*/ -class SwXParagraph : public cppu::WeakImplHelper10 +class SwXParagraph : public cppu::ImplInheritanceHelper10 < + ::sfx2::MetadatableMixin, ::com::sun::star::beans::XTolerantMultiPropertySet, ::com::sun::star::beans::XMultiPropertySet, ::com::sun::star::text::XTextRange, @@ -1181,8 +1174,9 @@ protected: virtual ~SwXParagraph(); public: SwXParagraph(); - SwXParagraph(SwXText* pParent, SwUnoCrsr* pCrsr, sal_Int32 nSelStart = -1, sal_Int32 nSelEnd = - 1); + SwXParagraph(::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const & i_xParent, SwTxtNode * i_pTxtNode, sal_Int32 nSelStart = -1, sal_Int32 nSelEnd = - 1); + TYPEINFO(); static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); @@ -1249,12 +1243,18 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException ); virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); + //MetadatableMixin + virtual ::sfx2::Metadatable* GetCoreObject(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + GetModel(); + //SwClient virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); BOOL IsDescriptor() const {return m_bIsDescriptor;} - SwUnoCrsr* GetCrsr(){return (SwUnoCrsr*)GetRegisteredIn();} + const SwTxtNode * GetTxtNode() const; + SwTxtNode * GetTxtNode(); static BOOL getDefaultTextContentValue(::com::sun::star::uno::Any& rAny, const rtl::OUString& rPropertyName, USHORT nWID = 0); @@ -1283,8 +1283,10 @@ class SwXParaFrameEnumeration : public cppu::WeakImplHelper2 SwUnoCrsr* GetCrsr(){return (SwUnoCrsr*)GetRegisteredIn();} BOOL CreateNextObject(); void FillFrame(SwUnoCrsr& rUnoCrsr); + public: - SwXParaFrameEnumeration(const SwUnoCrsr& rUnoCrsr, sal_uInt8 nParaFrameMode, SwFrmFmt* pFmt = 0); + SwXParaFrameEnumeration(const SwPaM& rPaM, + sal_uInt8 nParaFrameMode, SwFrmFmt* pFmt = 0); ~SwXParaFrameEnumeration(); //XEnumeration diff --git a/sw/inc/unoport.hxx b/sw/inc/unoport.hxx index ed29a995dfe3..889442d47a21 100644 --- a/sw/inc/unoport.hxx +++ b/sw/inc/unoport.hxx @@ -141,8 +141,8 @@ protected: virtual ~SwXTextPortion(); public: - SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > & rParent, SwTextPortionType eType ); - SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > & rParent, SwFrmFmt& rFmt ); + 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 ); //XTextRange @@ -237,7 +237,7 @@ class SwXRubyPortion : public SwXTextPortion public: SwXRubyPortion(const SwUnoCrsr* pPortionCrsr, SwTxtRuby& rAttr, - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > & rParent, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, sal_Bool bEnd ); ~SwXRubyPortion(); }; diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index d2f251bcf295..62b83c0ed5a9 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -68,9 +68,8 @@ #include <com/sun/star/xforms/XFormsSupplier.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/text/XFlatParagraphIteratorProvider.hpp> -#ifndef _COM_SUN_STAR_DOCUMENT_XDOCUMENTLANGUAGES_HPP #include <com/sun/star/document/XDocumentLanguages.hpp> -#endif +#include <com/sun/star/util/XCloneable.hpp> #include <svtools/itemprop.hxx> #include <svx/fmdmod.hxx> #include <svx/UnoForbiddenCharsTable.hxx> @@ -79,22 +78,22 @@ #include <cppuhelper/implbase4.hxx> // helper for implementations #include <RefreshListenerContainer.hxx> -#define __IFC31 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, Ifc14, Ifc15, Ifc16, \ -Ifc17, Ifc18, Ifc19, Ifc20, Ifc21, Ifc22, Ifc23, Ifc24, Ifc25, Ifc26, Ifc27, Ifc28, Ifc29, Ifc30, Ifc31 +#define __IFC32 Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, Ifc14, Ifc15, Ifc16, \ +Ifc17, Ifc18, Ifc19, Ifc20, Ifc21, Ifc22, Ifc23, Ifc24, Ifc25, Ifc26, Ifc27, Ifc28, Ifc29, Ifc30, Ifc31, Ifc32 -#define __CLASS_IFC31 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, \ +#define __CLASS_IFC32 class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, \ class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12, class Ifc13, class Ifc14, class Ifc15, class Ifc16, \ class Ifc17, class Ifc18, class Ifc19, class Ifc20, class Ifc21, class Ifc22, class Ifc23, class Ifc24,\ -class Ifc25, class Ifc26, class Ifc27, class Ifc28, class Ifc29, class Ifc30, class Ifc31 +class Ifc25, class Ifc26, class Ifc27, class Ifc28, class Ifc29, class Ifc30, class Ifc31 , class Ifc32 -#define __PUBLIC_IFC31 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, \ +#define __PUBLIC_IFC32 public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12, \ public Ifc13, public Ifc14, public Ifc15, public Ifc16, public Ifc17, public Ifc18, \ public Ifc19, public Ifc20, public Ifc21, public Ifc22, public Ifc23, public Ifc24, \ public Ifc25, public Ifc26, public Ifc27, public Ifc28, public Ifc29, public Ifc30, \ -public Ifc31 +public Ifc31, public Ifc32 #include <cppuhelper/implbase_ex.hxx> #include <cppuhelper/implbase_ex_pre.hxx> -#define __IFC_EX_TYPE_INIT31( class_cast ) \ +#define __IFC_EX_TYPE_INIT32( class_cast ) \ __IFC_EX_TYPE_INIT( class_cast, 1 ), __IFC_EX_TYPE_INIT( class_cast, 2 ), \ __IFC_EX_TYPE_INIT( class_cast, 3 ), __IFC_EX_TYPE_INIT( class_cast, 4 ), \ __IFC_EX_TYPE_INIT( class_cast, 5 ), __IFC_EX_TYPE_INIT( class_cast, 6 ), \ @@ -110,10 +109,10 @@ public Ifc31 __IFC_EX_TYPE_INIT( class_cast, 25 ), __IFC_EX_TYPE_INIT( class_cast, 26 ), \ __IFC_EX_TYPE_INIT( class_cast, 27 ), __IFC_EX_TYPE_INIT( class_cast, 28 ), \ __IFC_EX_TYPE_INIT( class_cast, 29 ), __IFC_EX_TYPE_INIT( class_cast, 30 ), \ - __IFC_EX_TYPE_INIT( class_cast, 31) + __IFC_EX_TYPE_INIT( class_cast, 31 ), __IFC_EX_TYPE_INIT( class_cast, 32) #include <cppuhelper/implbase_ex_post.hxx> -__DEF_IMPLHELPER_EX( 31 ) +__DEF_IMPLHELPER_EX( 32 ) class SwDoc; class SwDocShell; @@ -132,7 +131,7 @@ SV_DECL_PTRARR(ActionContextArr, UnoActionContextPtr, 4, 4) ******************************************************************************/ -typedef cppu::WeakImplHelper31 +typedef cppu::WeakImplHelper32 < ::com::sun::star::text::XTextDocument, ::com::sun::star::text::XLineNumberingProperties, @@ -164,7 +163,8 @@ typedef cppu::WeakImplHelper31 ::com::sun::star::view::XRenderable, ::com::sun::star::xforms::XFormsSupplier, ::com::sun::star::text::XFlatParagraphIteratorProvider, - ::com::sun::star::document::XDocumentLanguages + ::com::sun::star::document::XDocumentLanguages, + ::com::sun::star::util::XCloneable > SwXTextDocumentBaseClass; @@ -402,6 +402,10 @@ public: // ::com::sun::star::text::XFlatParagraphIteratorProvider: virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XFlatParagraphIterator > SAL_CALL getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic ) throw (::com::sun::star::uno::RuntimeException); + // ::com::sun::star::util::XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + + // void Invalidate(); void Reactivate(SwDocShell* pNewDocShell); diff --git a/sw/inc/viscrs.hxx b/sw/inc/viscrs.hxx index 3f898a7a1718..a240e166d197 100644 --- a/sw/inc/viscrs.hxx +++ b/sw/inc/viscrs.hxx @@ -29,9 +29,8 @@ ************************************************************************/ #ifndef _VISCRS_HXX #define _VISCRS_HXX -#ifndef _CURSOR_HXX //autogen + #include <vcl/cursor.hxx> -#endif #include "swcrsr.hxx" #include "swrect.hxx" #include "swregion.hxx" @@ -145,8 +144,6 @@ public: SwShellCrsr( SwShellCrsr& ); virtual ~SwShellCrsr(); - virtual operator SwShellCrsr* (); - void Show(); // Update und zeige alle Selektionen an void Hide(); // verstecke alle Selektionen void Invalidate( const SwRect& rRect ); @@ -181,6 +178,8 @@ public: nsSwCursorSelOverFlags::SELOVER_CHANGEPOS )); #endif + virtual bool IsReadOnlyAvailable() const; + DECL_FIXEDMEMPOOL_NEWDEL( SwShellCrsr ) }; @@ -200,8 +199,6 @@ public: const SwPosition &rPtPos, const Point& rPtPt ); virtual ~SwShellTableCrsr(); - virtual operator SwShellTableCrsr* (); - virtual void FillRects(); // fuer Table- und normalen Crsr // Pruefe, ob sich der SPoint innerhalb der Tabellen-SSelection befindet @@ -209,8 +206,7 @@ public: virtual void SetMark(); virtual SwCursor* Create( SwPaM* pRing = 0 ) const; - virtual operator SwShellCrsr* (); - virtual operator SwTableCursor* (); + virtual short MaxReplaceArived(); //returns RET_YES/RET_CANCEL/RET_NO virtual void SaveTblBoxCntnt( const SwPosition* pPos = 0 ); diff --git a/sw/prj/build.lst b/sw/prj/build.lst index 12bb80082e8a..1ea52fbe5880 100644 --- a/sw/prj/build.lst +++ b/sw/prj/build.lst @@ -1,4 +1,4 @@ -sw sw : connectivity OOo:writerperfect svx stoc uui NULL +sw sw : l10n connectivity OOo:writerperfect svx stoc uui NULL sw sw usr1 - all sw_mkout NULL sw sw\inc nmake - all sw_inc NULL sw sw\uiconfig\layout nmake - all sw_layout NULL diff --git a/sw/qa/unoapi/sw.sce b/sw/qa/unoapi/sw.sce index e9739711ae42..6d8c2b30d56d 100644 --- a/sw/qa/unoapi/sw.sce +++ b/sw/qa/unoapi/sw.sce @@ -41,7 +41,7 @@ #i85640 -o sw.SwXMailMerge -o sw.SwXModule -o sw.SwXNumberingRules --o sw.SwXParagraph +#i103696 -o sw.SwXParagraph -o sw.SwXParagraphEnumeration -o sw.SwXPrintSettings -o sw.SwXPropertySet @@ -67,7 +67,7 @@ -o sw.SwXTextFrameText -o sw.SwXTextGraphicObject -o sw.SwXTextGraphicObjects --o sw.SwXTextPortion +#i103696 -o sw.SwXTextPortion -o sw.SwXTextPortionEnumeration -o sw.SwXTextRange -o sw.SwXTextRanges diff --git a/sw/sdi/_basesh.sdi b/sw/sdi/_basesh.sdi index 51d7e14341af..50b85eddfab6 100644 --- a/sw/sdi/_basesh.sdi +++ b/sw/sdi/_basesh.sdi @@ -120,6 +120,13 @@ interface BaseTextSelection DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] + SID_PASTE_UNFORMATTED // status(final|play) + [ + ExecMethod = ExecClpbrd ; + StateMethod = StateClpbrd ; + DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; + ] + FN_PASTESPECIAL // status(final|play) [ ExecMethod = ExecClpbrd ; diff --git a/sw/sdi/swslots.src b/sw/sdi/swslots.src index 1dfdec6d05e8..d62d1da6b35b 100644 --- a/sw/sdi/swslots.src +++ b/sw/sdi/swslots.src @@ -850,6 +850,10 @@ SfxSlotInfo FN_PASTESPECIAL { Slotname [ en-US ] = "Paste Special"; }; +SfxSlotInfo FN_PASTEUNFORMATTED +{ + Slotname [ en-US ] = "Paste Unformatted Text"; +}; SfxSlotInfo FN_POSTIT { Slotname [ en-US ] = "Insert Note"; diff --git a/sw/source/core/access/acchyperlink.cxx b/sw/source/core/access/acchyperlink.cxx index 6a9ff9738165..ece5bbb614c5 100644 --- a/sw/source/core/access/acchyperlink.cxx +++ b/sw/source/core/access/acchyperlink.cxx @@ -101,8 +101,8 @@ sal_Bool SAL_CALL SwAccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex ) const SwTxtINetFmt* pTxtAttr2 = rINetFmt.GetTxtINetFmt(); if( pTxtAttr2 ) { - const_cast< SwTxtINetFmt* >( pTxtAttr2 )->SetVisited( sal_True ); - const_cast< SwTxtINetFmt* >( pTxtAttr2 )->SetValidVis( sal_True ); + const_cast<SwTxtINetFmt*>(pTxtAttr2)->SetVisited(true); + const_cast<SwTxtINetFmt*>(pTxtAttr2)->SetVisitedValid(true); } bRet = sal_True; } diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx index 03b82378df53..e4410c26e8bb 100644 --- a/sw/source/core/attr/calbck.cxx +++ b/sw/source/core/attr/calbck.cxx @@ -386,8 +386,10 @@ SwClient *SwModify::_Remove(SwClient * pDepend) void SwModify::CheckCaching( const USHORT nWhich ) { - if( RES_CHRATR_BEGIN <= nWhich && RES_CHRATR_END > nWhich ) + if (isCHRATR(nWhich)) + { SetInSwFntCache( FALSE ); + } else switch ( nWhich ) { diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx index d8b6ccadc65d..63b4f56b1cbd 100644 --- a/sw/source/core/bastyp/index.cxx +++ b/sw/source/core/bastyp/index.cxx @@ -302,7 +302,7 @@ SwIndex& SwIndex::Assign( SwIndexReg* pArr, xub_StrLen nIdx ) pArr->pFirst = pArr->pLast = this; nIndex = nIdx; } - else if( nIdx > ((pArr->pLast->nIndex - pArr->pFirst->nIndex) / 2) ) + else if( pArr->pLast && (nIdx > ((pArr->pLast->nIndex - pArr->pFirst->nIndex) / 2)) ) ChgValue( *pArr->pLast, nIdx ); else ChgValue( *pArr->pFirst, nIdx ); diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 8b54e9647be3..6652cd86dab4 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -59,9 +59,7 @@ #include <callnk.hxx> #include <viscrs.hxx> #include <section.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <scriptinfo.hxx> #include <globdoc.hxx> #include <pamtyp.hxx> @@ -173,7 +171,7 @@ BOOL SwCrsrShell::DestroyCrsr() SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, SwCursor* pNextCrsr = (SwCursor*)pCurCrsr->GetNext(); delete pCurCrsr; - pCurCrsr = (SwShellCrsr*)*pNextCrsr; + pCurCrsr = dynamic_cast<SwShellCrsr*>(pNextCrsr); UpdateCrsr(); return TRUE; } @@ -201,9 +199,8 @@ SwPaM* SwCrsrShell::GetCrsr( BOOL bMakeTblCrsr ) const if( pTblCrsr->IsChgd() ) { - SwCrsrShell* pThis = (SwCrsrShell*)this; - pThis->pCurCrsr = (SwShellCrsr*) - *pTblCrsr->MakeBoxSels( pThis->pCurCrsr ); + const_cast<SwCrsrShell*>(this)->pCurCrsr = + dynamic_cast<SwShellCrsr*>(pTblCrsr->MakeBoxSels( pCurCrsr )); } } return pCurCrsr; @@ -539,7 +536,7 @@ BOOL SwCrsrShell::SttEndDoc( BOOL bStt ) { SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen - SwShellCrsr* pTmpCrsr = pBlockCrsr ? pBlockCrsr->getShellCrsr() : pCurCrsr; + SwShellCrsr* pTmpCrsr = pBlockCrsr ? &pBlockCrsr->getShellCrsr() : pCurCrsr; BOOL bRet = pTmpCrsr->SttEndDoc( bStt ); if( bRet ) { @@ -920,7 +917,8 @@ BOOL SwCrsrShell::ChgCurrPam( const Point & rPt, UpdateCrsr(); // Cursor steht schon richtig return TRUE; } - } while( pCurCrsr != ( pCmp = (SwShellCrsr*)*((SwCursor*)pCmp->GetNext()) ) ); + } while( pCurCrsr != + ( pCmp = dynamic_cast<SwShellCrsr*>(pCmp->GetNext()) ) ); return FALSE; } @@ -1124,7 +1122,7 @@ BOOL SwCrsrShell::GoNextCrsr() SET_CURR_SHELL( this ); SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen - pCurCrsr = (SwShellCrsr*)*((SwCursor*)pCurCrsr->GetNext()); + pCurCrsr = dynamic_cast<SwShellCrsr*>(pCurCrsr->GetNext()); // Bug 24086: auch alle anderen anzeigen if( !ActionPend() ) @@ -1146,7 +1144,7 @@ BOOL SwCrsrShell::GoPrevCrsr() SET_CURR_SHELL( this ); SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen - pCurCrsr = (SwShellCrsr*)*((SwCursor*)pCurCrsr->GetPrev()); + pCurCrsr = dynamic_cast<SwShellCrsr*>(pCurCrsr->GetPrev()); // Bug 24086: auch alle anderen anzeigen if( !ActionPend() ) @@ -1957,7 +1955,9 @@ BOOL SwCrsrShell::Pop( BOOL bOldCrsr ) // der Nachfolger wird der Aktuelle if( pCrsrStk->GetNext() != pCrsrStk ) - pTmp = (SwShellCrsr*)*((SwCursor*)pCrsrStk->GetNext()); + { + pTmp = dynamic_cast<SwShellCrsr*>(pCrsrStk->GetNext()); + } if( bOldCrsr ) // loesche vom Stack delete pCrsrStk; // @@ -2029,7 +2029,9 @@ void SwCrsrShell::Combine() SwShellCrsr * pTmp = 0; if( pCrsrStk->GetNext() != pCrsrStk ) - pTmp = (SwShellCrsr*)*((SwCursor*)pCrsrStk->GetNext()); + { + pTmp = dynamic_cast<SwShellCrsr*>(pCrsrStk->GetNext()); + } delete pCrsrStk; pCrsrStk = pTmp; if( !pCurCrsr->IsInProtectTable( TRUE ) && @@ -3041,16 +3043,6 @@ BOOL SwCrsrShell::HasReadonlySel() const return bRet; } -// SwCursor - Methode !!!! -BOOL SwCursor::IsReadOnlyAvailable() const -{ - const SwShellCrsr* pShCrsr = *this; - const SwUnoCrsr* pUnoCrsr = *this; - return pShCrsr ? pShCrsr->GetShell()->IsReadOnlyAvailable() : - pUnoCrsr ? TRUE : FALSE; -} - - BOOL SwCrsrShell::IsSelFullPara() const { BOOL bRet = FALSE; diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx index 61aa9f95ffd7..4a98c1ce558e 100644 --- a/sw/source/core/crsr/findattr.cxx +++ b/sw/source/core/crsr/findattr.cxx @@ -888,7 +888,7 @@ BOOL SwPaM::Find( const SfxPoolItem& rAttr, BOOL bValue, SwMoveFn fnMove, { // stelle fest welches Attribut gesucht wird: USHORT nWhich = rAttr.Which(); - int bCharAttr = RES_CHRATR_BEGIN <= nWhich && nWhich < RES_TXTATR_END; + int bCharAttr = isCHRATR(nWhich) || isTXTATR(nWhich); SwPaM* pPam = MakeRegion( fnMove, pRegion ); @@ -931,7 +931,7 @@ BOOL SwPaM::Find( const SfxPoolItem& rAttr, BOOL bValue, SwMoveFn fnMove, bFound = TRUE; break; } - else if( RES_TXTATR_BEGIN < nWhich ) // TextAttribut + else if (isTXTATR(nWhich)) continue; // --> also weiter } diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx index 90680b7a1d22..89686a3673bc 100644 --- a/sw/source/core/crsr/findtxt.cxx +++ b/sw/source/core/crsr/findtxt.cxx @@ -623,7 +623,7 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove, p->MoveTo( (Ring*)pRegion ); } while( p != pPrev ); } - rSttCntIdx = nSttCnt; + pCrsr->Start()->nContent = nSttCnt; return FIND_NO_RING; } return bFnd ? FIND_FOUND : FIND_NOT_FOUND; diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index 860117babcc0..6ca8a6de62c2 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -74,24 +74,29 @@ inline xub_StrLen GetSttOrEnd( BOOL bCondition, const SwCntntNode& rNd ) *************************************************************************/ -SwPosition::SwPosition( const SwNodeIndex &rNode, const SwIndex &rCntnt ) - : nNode( rNode ),nContent( rCntnt ) +SwPosition::SwPosition( const SwNodeIndex & rNodeIndex, const SwIndex & rCntnt ) + : nNode( rNodeIndex ), nContent( rCntnt ) { } -SwPosition::SwPosition( const SwNodeIndex &rNode ) - : nNode( rNode ), nContent( 0 ) +SwPosition::SwPosition( const SwNodeIndex & rNodeIndex ) + : nNode( rNodeIndex ), nContent( nNode.GetNode().GetCntntNode() ) { } SwPosition::SwPosition( const SwNode& rNode ) - : nNode( rNode ), nContent( 0 ) + : nNode( rNode ), nContent( nNode.GetNode().GetCntntNode() ) { } +SwPosition::SwPosition( SwCntntNode & rNode, const xub_StrLen nOffset ) + : nNode( rNode ), nContent( &rNode, nOffset ) +{ +} -SwPosition::SwPosition(const SwPosition &rPos) - : nNode(rPos.nNode),nContent(rPos.nContent) + +SwPosition::SwPosition( const SwPosition & rPos ) + : nNode( rPos.nNode ), nContent( rPos.nContent ) { } @@ -380,129 +385,170 @@ SwCntntNode* GoPreviousNds( SwNodeIndex * pIdx, BOOL bChk ) *************************************************************************/ SwPaM::SwPaM( const SwPosition& rPos, SwPaM* pRing ) - : Ring( pRing ), aBound1( rPos ), aBound2( rPos ), bIsInFrontOfLabel(FALSE) + : Ring( pRing ) + , m_Bound1( rPos ) + , m_Bound2( rPos.nNode.GetNode().GetNodes() ) // default initialize + , m_pPoint( &m_Bound1 ) + , m_pMark( m_pPoint ) + , m_bIsInFrontOfLabel( false ) { - pPoint = pMark = &aBound1; } -SwPaM::SwPaM( const SwPosition& rMk, const SwPosition& rPt, SwPaM* pRing ) - : Ring( pRing ), aBound1( rMk ), aBound2( rPt ), bIsInFrontOfLabel(FALSE) +SwPaM::SwPaM( const SwPosition& rMark, const SwPosition& rPoint, SwPaM* pRing ) + : Ring( pRing ) + , m_Bound1( rMark ) + , m_Bound2( rPoint ) + , m_pPoint( &m_Bound2 ) + , m_pMark( &m_Bound1 ) + , m_bIsInFrontOfLabel( false ) { - pMark = &aBound1; - pPoint = &aBound2; } -SwPaM::SwPaM( const SwNodeIndex& rMk, const SwNodeIndex& rPt, - long nMkOffset, long nPtOffset, SwPaM* pRing ) - : Ring( pRing ), aBound1( rMk ), aBound2( rPt ), bIsInFrontOfLabel(FALSE) +SwPaM::SwPaM( const SwNodeIndex& rMark, const SwNodeIndex& rPoint, + long nMarkOffset, long nPointOffset, SwPaM* pRing ) + : Ring( pRing ) + , m_Bound1( rMark ) + , m_Bound2( rPoint ) + , m_pPoint( &m_Bound2 ) + , m_pMark( &m_Bound1 ) + , m_bIsInFrontOfLabel( false ) { - if( nMkOffset ) - aBound1.nNode += nMkOffset; - if( nPtOffset ) - aBound2.nNode += nPtOffset; - - aBound1.nContent.Assign( aBound1.nNode.GetNode().GetCntntNode(), 0 ); - aBound2.nContent.Assign( aBound2.nNode.GetNode().GetCntntNode(), 0 ); - pMark = &aBound1; - pPoint = &aBound2; + if ( nMarkOffset ) + { + m_pMark->nNode += nMarkOffset; + } + if ( nPointOffset ) + { + m_pPoint->nNode += nPointOffset; + } + + m_Bound1.nContent.Assign( m_Bound1.nNode.GetNode().GetCntntNode(), 0 ); + m_Bound2.nContent.Assign( m_Bound2.nNode.GetNode().GetCntntNode(), 0 ); } -SwPaM::SwPaM( const SwNode& rMk, const SwNode& rPt, - long nMkOffset, long nPtOffset, SwPaM* pRing ) - : Ring( pRing ), aBound1( rMk ), aBound2( rPt ), bIsInFrontOfLabel(FALSE) +SwPaM::SwPaM( const SwNode& rMark, const SwNode& rPoint, + long nMarkOffset, long nPointOffset, SwPaM* pRing ) + : Ring( pRing ) + , m_Bound1( rMark ) + , m_Bound2( rPoint ) + , m_pPoint( &m_Bound2 ) + , m_pMark( &m_Bound1 ) + , m_bIsInFrontOfLabel( false ) { - if( nMkOffset ) - aBound1.nNode += nMkOffset; - if( nPtOffset ) - aBound2.nNode += nPtOffset; - - aBound1.nContent.Assign( aBound1.nNode.GetNode().GetCntntNode(), 0 ); - aBound2.nContent.Assign( aBound2.nNode.GetNode().GetCntntNode(), 0 ); - pMark = &aBound1; - pPoint = &aBound2; + if ( nMarkOffset ) + { + m_pMark->nNode += nMarkOffset; + } + if ( nPointOffset ) + { + m_pPoint->nNode += nPointOffset; + } + + m_Bound1.nContent.Assign( m_Bound1.nNode.GetNode().GetCntntNode(), 0 ); + m_Bound2.nContent.Assign( m_Bound2.nNode.GetNode().GetCntntNode(), 0 ); } -SwPaM::SwPaM( const SwNodeIndex& rMk, xub_StrLen nMkCntnt, - const SwNodeIndex& rPt, xub_StrLen nPtCntnt, SwPaM* pRing ) - : Ring( pRing ), aBound1( rMk ), aBound2( rPt ), bIsInFrontOfLabel(FALSE) +SwPaM::SwPaM( const SwNodeIndex& rMark , xub_StrLen nMarkCntnt, + const SwNodeIndex& rPoint, xub_StrLen nPointCntnt, SwPaM* pRing ) + : Ring( pRing ) + , m_Bound1( rMark ) + , m_Bound2( rPoint ) + , m_pPoint( &m_Bound2 ) + , m_pMark( &m_Bound1 ) + , m_bIsInFrontOfLabel( false ) { - aBound1.nContent.Assign( rMk.GetNode().GetCntntNode(), nMkCntnt ); - aBound2.nContent.Assign( rPt.GetNode().GetCntntNode(), nPtCntnt ); - pMark = &aBound1; - pPoint = &aBound2; + m_pPoint->nContent.Assign( rPoint.GetNode().GetCntntNode(), nPointCntnt); + m_pMark ->nContent.Assign( rMark .GetNode().GetCntntNode(), nMarkCntnt ); } -SwPaM::SwPaM( const SwNode& rMk, xub_StrLen nMkCntnt, - const SwNode& rPt, xub_StrLen nPtCntnt, SwPaM* pRing ) - : Ring( pRing ), aBound1( rMk ), aBound2( rPt ), bIsInFrontOfLabel(FALSE) +SwPaM::SwPaM( const SwNode& rMark , xub_StrLen nMarkCntnt, + const SwNode& rPoint, xub_StrLen nPointCntnt, SwPaM* pRing ) + : Ring( pRing ) + , m_Bound1( rMark ) + , m_Bound2( rPoint ) + , m_pPoint( &m_Bound2 ) + , m_pMark( &m_Bound1 ) + , m_bIsInFrontOfLabel( false ) { - aBound1.nContent.Assign( aBound1.nNode.GetNode().GetCntntNode(), nMkCntnt ); - aBound2.nContent.Assign( aBound2.nNode.GetNode().GetCntntNode(), nPtCntnt ); - pMark = &aBound1; - pPoint = &aBound2; + m_pPoint->nContent.Assign( m_pPoint->nNode.GetNode().GetCntntNode(), + nPointCntnt); + m_pMark ->nContent.Assign( m_pMark ->nNode.GetNode().GetCntntNode(), + nMarkCntnt ); } -SwPaM::SwPaM( const SwNode& rNd, xub_StrLen nCntnt, SwPaM* pRing ) - : Ring( pRing ), aBound1( rNd ), aBound2( rNd ), bIsInFrontOfLabel(FALSE) +SwPaM::SwPaM( const SwNode& rNode, xub_StrLen nCntnt, SwPaM* pRing ) + : Ring( pRing ) + , m_Bound1( rNode ) + , m_Bound2( m_Bound1.nNode.GetNode().GetNodes() ) // default initialize + , m_pPoint( &m_Bound1 ) + , m_pMark( &m_Bound1 ) + , m_bIsInFrontOfLabel( false ) { - aBound1.nContent.Assign( aBound1.nNode.GetNode().GetCntntNode(), nCntnt ); - aBound2.nContent = aBound1.nContent; - pPoint = pMark = &aBound1; + m_pPoint->nContent.Assign( m_pPoint->nNode.GetNode().GetCntntNode(), + nCntnt ); } -SwPaM::SwPaM( const SwNodeIndex& rNd, xub_StrLen nCntnt, SwPaM* pRing ) - : Ring( pRing ), aBound1( rNd ), aBound2( rNd ), bIsInFrontOfLabel(FALSE) +SwPaM::SwPaM( const SwNodeIndex& rNodeIdx, xub_StrLen nCntnt, SwPaM* pRing ) + : Ring( pRing ) + , m_Bound1( rNodeIdx ) + , m_Bound2( rNodeIdx.GetNode().GetNodes() ) // default initialize + , m_pPoint( &m_Bound1 ) + , m_pMark( &m_Bound1 ) + , m_bIsInFrontOfLabel( false ) { - aBound1.nContent.Assign( rNd.GetNode().GetCntntNode(), nCntnt ); - aBound2.nContent = aBound1.nContent; - pPoint = pMark = &aBound1; + m_pPoint->nContent.Assign( rNodeIdx.GetNode().GetCntntNode(), nCntnt ); } SwPaM::~SwPaM() {} // @@@ semantic: no copy ctor. SwPaM::SwPaM( SwPaM &rPam ) - : Ring( &rPam ), - aBound1( *(rPam.pPoint) ), - aBound2( *(rPam.pMark) ), - bIsInFrontOfLabel(FALSE) + : Ring( &rPam ) + , m_Bound1( *(rPam.m_pPoint) ) + , m_Bound2( *(rPam.m_pMark) ) + , m_pPoint( &m_Bound1 ), m_pMark( rPam.HasMark() ? &m_Bound2 : m_pPoint ) + , m_bIsInFrontOfLabel( false ) { - pPoint = &aBound1; - pMark = rPam.HasMark() ? &aBound2 : pPoint; } // @@@ semantic: no copy assignment for super class Ring. SwPaM &SwPaM::operator=( const SwPaM &rPam ) { - *pPoint = *( rPam.pPoint ); - if( rPam.HasMark() ) + *m_pPoint = *( rPam.m_pPoint ); + if ( rPam.HasMark() ) { SetMark(); - *pMark = *( rPam.pMark ); + *m_pMark = *( rPam.m_pMark ); } else + { DeleteMark(); + } return *this; } void SwPaM::SetMark() { - if(pPoint == &aBound1) - pMark = &aBound2; + if (m_pPoint == &m_Bound1) + { + m_pMark = &m_Bound2; + } else - pMark = &aBound1; - (*pMark) = (*pPoint); + { + m_pMark = &m_Bound1; + } + (*m_pMark) = (*m_pPoint); } #ifndef PRODUCT void SwPaM::Exchange() { - if(pPoint != pMark) + if (m_pPoint != m_pMark) { - SwPosition *pTmp = pPoint; - pPoint = pMark; - pMark = pTmp; + SwPosition *pTmp = m_pPoint; + m_pPoint = m_pMark; + m_pMark = pTmp; } } #endif @@ -514,7 +560,7 @@ BOOL SwPaM::Move( SwMoveFn fnMove, SwGoInDoc fnGo ) { BOOL bRet = (*fnGo)( *this, fnMove ); - bIsInFrontOfLabel = FALSE; + m_bIsInFrontOfLabel = false; return bRet; } @@ -545,7 +591,7 @@ SwPaM* SwPaM::MakeRegion( SwMoveFn fnMove, const SwPaM * pOrigRg ) SwPaM* pPam; if( pOrigRg == 0 ) { - pPam = new SwPaM( *pPoint ); + pPam = new SwPaM( *m_pPoint ); pPam->SetMark(); // setze Anfang fest pPam->Move( fnMove, fnGoSection); // an Anfang / Ende vom Node @@ -567,9 +613,11 @@ SwPaM* SwPaM::MakeRegion( SwMoveFn fnMove, const SwPaM * pOrigRg ) SwPaM & SwPaM::Normalize(BOOL bPointFirst) { if (HasMark()) - if ((bPointFirst && *pPoint > *pMark) || - (! bPointFirst && *pPoint < *pMark)) + if ( ( bPointFirst && *m_pPoint > *m_pMark) || + (!bPointFirst && *m_pPoint < *m_pMark) ) + { Exchange(); + } return *this; } @@ -581,7 +629,7 @@ USHORT SwPaM::GetPageNum( BOOL bAtPoint, const Point* pLayPos ) const SwCntntFrm* pCFrm; const SwPageFrm *pPg; const SwCntntNode *pNd ; - const SwPosition* pPos = bAtPoint ? pPoint : pMark; + const SwPosition* pPos = bAtPoint ? m_pPoint : m_pMark; if( 0 != ( pNd = pPos->nNode.GetNode().GetCntntNode() ) && 0 != ( pCFrm = pNd->GetFrm( pLayPos, pPos, FALSE )) && @@ -803,13 +851,22 @@ SwCntntNode* GetNode( SwPaM & rPam, BOOL& rbFirst, SwMoveFn fnMove, { rbFirst = FALSE; pNd = rPam.GetCntntNode(); - if( pNd && - ( 0 == ( pFrm = pNd->GetFrm()) || - ( !bInReadOnly && pFrm->IsProtected() ) || - (pFrm->IsTxtFrm() && ((SwTxtFrm*)pFrm)->IsHiddenNow()) ) || - ( !bInReadOnly && pNd->FindSectionNode() && - pNd->FindSectionNode()->GetSection().IsProtect() )) - pNd = 0; + if( pNd ) + { + if( + ( + 0 == ( pFrm = pNd->GetFrm()) || + ( !bInReadOnly && pFrm->IsProtected() ) || + (pFrm->IsTxtFrm() && ((SwTxtFrm*)pFrm)->IsHiddenNow()) + ) || + ( !bInReadOnly && pNd->FindSectionNode() && + pNd->FindSectionNode()->GetSection().IsProtect() + ) + ) + { + pNd = 0; + } + } } if( !pNd ) // steht Cursor auf keinem ContentNode ? diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index 197bc62c08ba..b7a336b5929c 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -35,13 +35,8 @@ #include <hintids.hxx> #include <svx/protitem.hxx> -#ifndef _COM_SUN_STAR_I18N_WORDTYPE_HDL #include <com/sun/star/i18n/WordType.hdl> -#endif -#ifndef _COM_SUN_STAR_I18N_CHARTYPE_HDL #include <com/sun/star/i18n/CharType.hdl> -#endif - #include <unotools/charclass.hxx> #include <svtools/ctloptions.hxx> @@ -60,9 +55,7 @@ #include <txtfrm.hxx> #include <scriptinfo.hxx> #include <crstate.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <frmatr.hxx> #include <breakit.hxx> #include <crsskip.hxx> @@ -73,8 +66,10 @@ #endif #include <redline.hxx> // SwRedline + using namespace ::com::sun::star::i18n; + static const USHORT coSrchRplcThreshold = 60000; struct _PercentHdl @@ -162,11 +157,20 @@ SwCursor* SwCursor::Create( SwPaM* pRing ) const return new SwCursor( *GetPoint(), pRing, false ); } -SwCursor::operator SwTableCursor* () { return 0; } -SwCursor::operator SwShellCrsr* () { return 0; } -SwCursor::operator SwShellTableCrsr* () { return 0; } -SwCursor::operator SwUnoCrsr* () { return 0; } -SwCursor::operator SwUnoTableCrsr* () { return 0; } +bool SwCursor::IsReadOnlyAvailable() const +{ + return false; +} + +BOOL SwCursor::IsSkipOverHiddenSections() const +{ + return TRUE; +} + +BOOL SwCursor::IsSkipOverProtectSections() const +{ + return !IsReadOnlyAvailable(); +} // Sicher die aktuelle Position, damit ggfs. auf diese zurueck @@ -206,36 +210,41 @@ BOOL SwCursor::IsNoCntnt() const GetDoc()->GetNodes().GetEndOfExtras().GetIndex(); } +bool SwCursor::IsSelOvrCheck(int) +{ + return false; +} + +// extracted from IsSelOvr() +bool SwTableCursor::IsSelOvrCheck(int eFlags) +{ + SwNodes& rNds = GetDoc()->GetNodes(); + // check sections of nodes array + if( (nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION & eFlags) + && HasMark() ) + { + SwNodeIndex aOldPos( rNds, GetSavePos()->nNode ); + if( !CheckNodesRange( aOldPos, GetPoint()->nNode, TRUE )) + { + GetPoint()->nNode = aOldPos; + GetPoint()->nContent.Assign( GetCntntNode(), GetSavePos()->nCntnt ); + return true; + } + } + return SwCursor::IsSelOvrCheck(eFlags); +} BOOL SwCursor::IsSelOvr( int eFlags ) { - SwTableCursor* pTblCrsr = *this; SwDoc* pDoc = GetDoc(); SwNodes& rNds = pDoc->GetNodes(); - BOOL bSkipOverHiddenSections, bSkipOverProtectSections; - SwUnoCrsr* pUnoCrsr = *this; - if( pUnoCrsr ) - { - bSkipOverHiddenSections = pUnoCrsr->IsSkipOverHiddenSections(); - bSkipOverProtectSections = pUnoCrsr->IsSkipOverProtectSections(); - } - else - { - bSkipOverHiddenSections = TRUE; - bSkipOverProtectSections = !IsReadOnlyAvailable(); - } + BOOL bSkipOverHiddenSections = IsSkipOverHiddenSections(); + BOOL bSkipOverProtectSections = IsSkipOverProtectSections(); - // Bereiche vom Nodes-Array ueberpruefen - if( (nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION & eFlags) && pTblCrsr && HasMark() ) + if ( IsSelOvrCheck( eFlags ) ) { - SwNodeIndex aOldPos( rNds, pSavePos->nNode ); - if( !CheckNodesRange( aOldPos, GetPoint()->nNode, TRUE )) - { - GetPoint()->nNode = aOldPos; - GetPoint()->nContent.Assign( GetCntntNode(), pSavePos->nCntnt ); - return TRUE; - } + return TRUE; } // neu: Bereiche ueberpruefen @@ -343,7 +352,7 @@ BOOL SwCursor::IsSelOvr( int eFlags ) // neu: Bereiche ueberpruefen const SwNode* pNd = &GetPoint()->nNode.GetNode(); - if( pNd->IsCntntNode() && 0 == (SwUnoCrsr*)*this ) + if( pNd->IsCntntNode() && !dynamic_cast<SwUnoCrsr*>(this) ) { const SwCntntFrm* pFrm = ((SwCntntNode*)pNd)->GetFrm(); if( pFrm && pFrm->IsValid() && 0 == pFrm->Frm().Height() && @@ -419,7 +428,7 @@ BOOL SwCursor::IsSelOvr( int eFlags ) const SwTableNode* pPtNd = pNd->FindTableNode(); if( (pNd = &GetMark()->nNode.GetNode())->IsCntntNode() && - !((SwCntntNode*)pNd)->GetFrm() && 0 == (SwUnoCrsr*)*this ) + !((SwCntntNode*)pNd)->GetFrm() && !dynamic_cast<SwUnoCrsr*>(this) ) { DeleteMark(); RestoreSavePos(); @@ -691,8 +700,10 @@ BOOL SwCursor::IsAtValidPos( BOOL bPoint ) const const SwNode* pNd = &pPos->nNode.GetNode(); if( pNd->IsCntntNode() && !((SwCntntNode*)pNd)->GetFrm() && - 0 == (const SwUnoCrsr*)*this ) + !dynamic_cast<const SwUnoCrsr*>(this) ) + { return FALSE; + } //JP 28.10.97: Bug 45129 - im UI-ReadOnly ist alles erlaubt if( !pDoc->GetDocShell() || !pDoc->GetDocShell()->IsReadOnlyUI() ) @@ -741,8 +752,8 @@ ULONG lcl_FindSelection( SwFindParas& rParas, SwCursor* pCurCrsr, int bSrchBkwrd = fnMove == fnMoveBackward, bEnde = FALSE; SwPaM *pTmpCrsr = pCurCrsr, *pSaveCrsr = pCurCrsr; - // nur beim ShellCrsr einen Prgogressbar erzeugen - BOOL bIsUnoCrsr = 0 != (SwUnoCrsr*)*pCurCrsr; + // only create progress-bar for ShellCrsr + bool bIsUnoCrsr = 0 != dynamic_cast<SwUnoCrsr*>(pCurCrsr); _PercentHdl* pPHdl = 0; USHORT nCrsrCnt = 0; if( FND_IN_SEL & eFndRngs ) @@ -829,16 +840,20 @@ ULONG lcl_FindSelection( SwFindParas& rParas, SwCursor* pCurCrsr, if( *pSttPos == *pEndPos ) // im Bereich, aber am Ende break; // fertig - if( !nCrsrCnt && !bIsUnoCrsr ) + if( !nCrsrCnt && pPHdl ) + { pPHdl->NextPos( *aRegion.GetMark() ); + } } if( bEnde || !( eFndRngs & ( FND_IN_SELALL | FND_IN_SEL )) ) break; pTmpCrsr = ((SwPaM*)pTmpCrsr->GetNext()); - if( nCrsrCnt && !bIsUnoCrsr ) + if( nCrsrCnt && pPHdl ) + { pPHdl->NextPos( ++pPHdl->nActPos ); + } } while( pTmpCrsr != pSaveCrsr ); @@ -1472,60 +1487,71 @@ BOOL SwCursor::GoSentence( SentenceMoveType eMoveType ) return bRet; } -BOOL SwCursor::LeftRight( BOOL bLeft, USHORT nCnt, USHORT nMode, - BOOL bVisualAllowed,BOOL bSkipHidden, BOOL bInsertCrsr ) +BOOL SwTableCursor::LeftRight( BOOL bLeft, USHORT nCnt, USHORT /*nMode*/, + BOOL /*bVisualAllowed*/, BOOL /*bSkipHidden*/, BOOL /*bInsertCrsr*/ ) { - SwTableCursor* pTblCrsr = (SwTableCursor*)*this; - if( pTblCrsr ) - return bLeft ? pTblCrsr->GoPrevCell( nCnt ) - : pTblCrsr->GoNextCell( nCnt ); + return bLeft ? GoPrevCell( nCnt ) + : GoNextCell( nCnt ); +} + +// calculate cursor bidi level: extracted from LeftRight() +const SwCntntFrm* +SwCursor::DoSetBidiLevelLeftRight( + BOOL & io_rbLeft, BOOL bVisualAllowed, BOOL bInsertCrsr) +{ // calculate cursor bidi level const SwCntntFrm* pSttFrm = NULL; SwNode& rNode = GetPoint()->nNode.GetNode(); - const BOOL bDoNotSetBidiLevel = 0 != (SwUnoCrsr*)*this; - if ( !bDoNotSetBidiLevel ) + if( rNode.IsTxtNode() ) { - if( rNode.IsTxtNode() ) + const SwTxtNode& rTNd = *rNode.GetTxtNode(); + SwIndex& rIdx = GetPoint()->nContent; + xub_StrLen nPos = rIdx.GetIndex(); + + const SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions(); + if ( bVisualAllowed && rCTLOptions.IsCTLFontEnabled() && + SvtCTLOptions::MOVEMENT_VISUAL == + rCTLOptions.GetCTLCursorMovement() ) { - const SwTxtNode& rTNd = *rNode.GetTxtNode(); - SwIndex& rIdx = GetPoint()->nContent; - xub_StrLen nPos = rIdx.GetIndex(); - - const SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions(); - if ( bVisualAllowed && rCTLOptions.IsCTLFontEnabled() && - SvtCTLOptions::MOVEMENT_VISUAL == - rCTLOptions.GetCTLCursorMovement() ) + // for visual cursor travelling (used in bidi layout) + // we first have to convert the logic to a visual position + Point aPt; + pSttFrm = rTNd.GetFrm( &aPt, GetPoint() ); + if( pSttFrm ) { - // for visual cursor travelling (used in bidi layout) - // we first have to convert the logic to a visual position - Point aPt; - pSttFrm = rTNd.GetFrm( &aPt, GetPoint() ); - if( pSttFrm ) - { - BYTE nCrsrLevel = GetCrsrBidiLevel(); - sal_Bool bForward = ! bLeft; - ((SwTxtFrm*)pSttFrm)->PrepareVisualMove( nPos, nCrsrLevel, - bForward, bInsertCrsr ); - rIdx = nPos; - SetCrsrBidiLevel( nCrsrLevel ); - bLeft = ! bForward; - } + BYTE nCrsrLevel = GetCrsrBidiLevel(); + sal_Bool bForward = ! io_rbLeft; + ((SwTxtFrm*)pSttFrm)->PrepareVisualMove( nPos, nCrsrLevel, + bForward, bInsertCrsr ); + rIdx = nPos; + SetCrsrBidiLevel( nCrsrLevel ); + io_rbLeft = ! bForward; } - else + } + else + { + const SwScriptInfo* pSI = SwScriptInfo::GetScriptInfo( rTNd ); + if ( pSI ) { - const SwScriptInfo* pSI = SwScriptInfo::GetScriptInfo( rTNd ); - if ( pSI ) - { - const xub_StrLen nMoveOverPos = bLeft ? - ( nPos ? nPos - 1 : 0 ) : - nPos; - SetCrsrBidiLevel( pSI->DirType( nMoveOverPos ) ); - } + const xub_StrLen nMoveOverPos = io_rbLeft ? + ( nPos ? nPos - 1 : 0 ) : + nPos; + SetCrsrBidiLevel( pSI->DirType( nMoveOverPos ) ); } } } + return pSttFrm; +} + +BOOL SwCursor::LeftRight( BOOL bLeft, USHORT nCnt, USHORT nMode, + BOOL bVisualAllowed,BOOL bSkipHidden, BOOL bInsertCrsr ) +{ + // calculate cursor bidi level + SwNode& rNode = GetPoint()->nNode.GetNode(); + const SwCntntFrm* pSttFrm = // may side-effect bLeft! + DoSetBidiLevelLeftRight(bLeft, bVisualAllowed, bInsertCrsr); // kann der Cursor n-mal weiterverschoben werden ? SwCrsrSaveState aSave( *this ); @@ -1650,10 +1676,40 @@ BOOL SwCursor::LeftRight( BOOL bLeft, USHORT nCnt, USHORT nMode, nsSwCursorSelOverFlags::SELOVER_CHANGEPOS ); } +// calculate cursor bidi level: extracted from UpDown() +void SwCursor::DoSetBidiLevelUpDown() +{ + SwNode& rNode = GetPoint()->nNode.GetNode(); + if ( rNode.IsTxtNode() ) + { + const SwScriptInfo* pSI = + SwScriptInfo::GetScriptInfo( (SwTxtNode&)rNode ); + if ( pSI ) + { + SwIndex& rIdx = GetPoint()->nContent; + xub_StrLen nPos = rIdx.GetIndex(); + + if( nPos && nPos < ((SwTxtNode&)rNode).GetTxt().Len() ) + { + const BYTE nCurrLevel = pSI->DirType( nPos ); + const BYTE nPrevLevel = pSI->DirType( nPos - 1 ); + + if ( nCurrLevel % 2 != nPrevLevel % 2 ) + { + // set cursor level to the lower of the two levels + SetCrsrBidiLevel( Min( nCurrLevel, nPrevLevel ) ); + } + else + SetCrsrBidiLevel( nCurrLevel ); + } + } + } +} + BOOL SwCursor::UpDown( BOOL bUp, USHORT nCnt, Point* pPt, long nUpDownX ) { - SwTableCursor* pTblCrsr = (SwTableCursor*)*this; + SwTableCursor* pTblCrsr = dynamic_cast<SwTableCursor*>(this); sal_Bool bAdjustTableCrsr = sal_False; // vom Tabellen Crsr Point/Mark in der gleichen Box ?? @@ -1752,36 +1808,7 @@ BOOL SwCursor::UpDown( BOOL bUp, USHORT nCnt, else *GetPoint() = aOldPos; - // calculate cursor bidi level - const BOOL bDoNotSetBidiLevel = 0 != (SwUnoCrsr*)*this; - - if ( ! bDoNotSetBidiLevel ) - { - SwNode& rNode = GetPoint()->nNode.GetNode(); - if ( rNode.IsTxtNode() ) - { - const SwScriptInfo* pSI = SwScriptInfo::GetScriptInfo( (SwTxtNode&)rNode ); - if ( pSI ) - { - SwIndex& rIdx = GetPoint()->nContent; - xub_StrLen nPos = rIdx.GetIndex(); - - if( nPos && nPos < ((SwTxtNode&)rNode).GetTxt().Len() ) - { - const BYTE nCurrLevel = pSI->DirType( nPos ); - const BYTE nPrevLevel = pSI->DirType( nPos - 1 ); - - if ( nCurrLevel % 2 != nPrevLevel % 2 ) - { - // set cursor level to the lower of the two levels - SetCrsrBidiLevel( Min( nCurrLevel, nPrevLevel ) ); - } - else - SetCrsrBidiLevel( nCurrLevel ); - } - } - } - } + DoSetBidiLevelUpDown(); // calculate cursor bidi level } return bRet; @@ -1895,12 +1922,15 @@ BOOL SwCursor::GoPrevNextCell( BOOL bNext, USHORT nCnt ) return !IsInProtectTable( TRUE ); } +BOOL SwTableCursor::GotoTable( const String& /*rName*/ ) +{ + return FALSE; // invalid action +} + BOOL SwCursor::GotoTable( const String& rName ) { BOOL bRet = FALSE; - // Tabellenselektion oder ueberhaupt Selection ? - // Das ist eine ungueltige Action ! - if( !(SwTableCursor*)*this && !HasMark() ) + if ( !HasMark() ) { SwTable* pTmpTbl = SwTable::FindTable( GetDoc()->FindTblFmtByName( rName ) ); if( pTmpTbl ) @@ -2017,7 +2047,6 @@ SwTableCursor::SwTableCursor( const SwPosition &rPos, SwPaM* pRing ) SwTableCursor::~SwTableCursor() {} -SwTableCursor::operator SwTableCursor* () { return this; } BOOL lcl_SeekEntry( const SwSelBoxes& rTmp, const SwStartNode* pSrch, USHORT& rFndPos ) { diff --git a/sw/source/core/crsr/trvlreg.cxx b/sw/source/core/crsr/trvlreg.cxx index 77387be91fc4..017ea9811f91 100644 --- a/sw/source/core/crsr/trvlreg.cxx +++ b/sw/source/core/crsr/trvlreg.cxx @@ -238,7 +238,7 @@ BOOL GotoCurrRegionAndSkip( SwPaM& rCurCrsr, SwPosRegion fnPosRegion, BOOL SwCursor::MoveRegion( SwWhichRegion fnWhichRegion, SwPosRegion fnPosRegion ) { SwCrsrSaveState aSaveState( *this ); - return !(SwTableCursor*)*this && + return !dynamic_cast<SwTableCursor*>(this) && (*fnWhichRegion)( *this, fnPosRegion, IsReadOnlyAvailable() ) && !IsSelOvr() && ( GetPoint()->nNode.GetIndex() != pSavePos->nNode || diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx index 2599d785d9c2..4546a108b2ec 100644 --- a/sw/source/core/crsr/trvltbl.cxx +++ b/sw/source/core/crsr/trvltbl.cxx @@ -32,9 +32,7 @@ #include "precompiled_sw.hxx" #include <hintids.hxx> -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif #include <svx/protitem.hxx> #include <crsrsh.hxx> #include <doc.hxx> @@ -54,6 +52,7 @@ #include <cellfrm.hxx> #include <rowfrm.hxx> + // setze Crsr in die naechsten/vorherigen Celle BOOL SwCrsrShell::GoNextCell( BOOL bAppendLine ) { @@ -653,7 +652,7 @@ BOOL GotoCurrTable( SwPaM& rCurCrsr, SwPosTable fnPosTbl, BOOL SwCursor::MoveTable( SwWhichTable fnWhichTbl, SwPosTable fnPosTbl ) { BOOL bRet = FALSE; - SwTableCursor* pTblCrsr = (SwTableCursor*)*this; + SwTableCursor* pTblCrsr = dynamic_cast<SwTableCursor*>(this); if( pTblCrsr || !HasMark() ) // nur wenn kein Mark oder ein TblCrsr { diff --git a/sw/source/core/crsr/unocrsr.cxx b/sw/source/core/crsr/unocrsr.cxx index bfc179db489e..aa52f61c8317 100644 --- a/sw/source/core/crsr/unocrsr.cxx +++ b/sw/source/core/crsr/unocrsr.cxx @@ -85,14 +85,21 @@ SwUnoCrsr::~SwUnoCrsr() SwUnoCrsr * SwUnoCrsr::Clone() const { - SwUnoCrsr * pNewCrsr = 0; - - // check if the cursor is a SwUnoTableCrsr, if so clone that type - const SwUnoTableCrsr * pUnoTableCrsr = *this; - if (pUnoTableCrsr) - pNewCrsr = GetDoc()->CreateUnoCrsr( *GetPoint(), sal_True /* create SwUnoTableCrsr */ ); - else - pNewCrsr = GetDoc()->CreateUnoCrsr( *GetPoint() ); + SwUnoCrsr * pNewCrsr = GetDoc()->CreateUnoCrsr( *GetPoint() ); + if (HasMark()) + { + pNewCrsr->SetMark(); + *pNewCrsr->GetMark() = *GetMark(); + } + return pNewCrsr; +} + +SwUnoTableCrsr * SwUnoTableCrsr::Clone() const +{ + SwUnoTableCrsr * pNewCrsr = dynamic_cast<SwUnoTableCrsr*>( + GetDoc()->CreateUnoCrsr( + *GetPoint(), sal_True /* create SwUnoTableCrsr */ ) ); + OSL_ENSURE(pNewCrsr, "Clone: cannot create SwUnoTableCrsr?"); if (HasMark()) { pNewCrsr->SetMark(); @@ -101,8 +108,22 @@ SwUnoCrsr * SwUnoCrsr::Clone() const return pNewCrsr; } -SwUnoCrsr::operator SwUnoCrsr* () { return this; } +bool SwUnoCrsr::IsReadOnlyAvailable() const +{ + return true; +} + +const SwCntntFrm* +SwUnoCrsr::DoSetBidiLevelLeftRight( BOOL &, BOOL, BOOL ) +{ + return 0; // not for uno cursor +} + +void SwUnoCrsr::DoSetBidiLevelUpDown() +{ + return; // not for uno cursor +} BOOL SwUnoCrsr::IsSelOvr( int eFlags ) { @@ -208,9 +229,6 @@ SwUnoTableCrsr::~SwUnoTableCrsr() delete aTblSel.GetNext(); // und loeschen } -SwUnoTableCrsr::operator SwUnoCrsr* () { return this; } -SwUnoTableCrsr::operator SwTableCursor* () { return this; } -SwUnoTableCrsr::operator SwUnoTableCrsr* () { return this; } /* SwCursor* SwUnoTableCrsr::Create( SwPaM* pRing ) const diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index c1e095f38dd9..fd135e1fe7ff 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -37,15 +37,9 @@ #include <svtools/svstdarr.hxx> #endif -#ifndef _DIALOG_HXX //autogen #include <vcl/dialog.hxx> -#endif -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <viewopt.hxx> #include <frmtool.hxx> #include <viscrs.hxx> @@ -74,6 +68,11 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <vcl/hatch.hxx> +#include <drawinglayer/primitive2d/invertprimitive2d.hxx> +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#include <drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> + extern void SwCalcPixStatics( OutputDevice *pOut ); //Damit beim ShowCrsr nicht immer wieder die gleiche Size teuer ermittelt @@ -537,11 +536,8 @@ namespace sdr std::vector< basegfx::B2DRange > maRanges; SwOverlayType mePaintType; - // Draw geometry - virtual void drawGeometry(OutputDevice& rOutputDevice); - - // Create the BaseRange. This method needs to calculate maBaseRange. - virtual void createBaseRange(OutputDevice& rOutputDevice); + // geometry creation for OverlayObject + virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence(); public: OverlaySwSelPaintRects(Color aBaseColor, const std::vector< basegfx::B2DRange >& rRanges, SwOverlayType eType); @@ -550,105 +546,53 @@ namespace sdr // data access const std::vector< basegfx::B2DRange >& getB2DRanges() const { return maRanges; } void setB2DRanges(const std::vector< basegfx::B2DRange >& rNew); - - // Hittest with logical coordinates - virtual sal_Bool isHit(const basegfx::B2DPoint& rPos, double fTol) const; - - // transform object coordinates. Needs to transform maSecondPosition - // and maThirdPosition. - virtual void transform(const basegfx::B2DHomMatrix& rMatrix); }; - void OverlaySwSelPaintRects::drawGeometry(OutputDevice& rOutputDevice) + drawinglayer::primitive2d::Primitive2DSequence OverlaySwSelPaintRects::createOverlayObjectPrimitive2DSequence() { - // safe original AA and switch off for selection - const sal_uInt16 nOriginalAA(rOutputDevice.GetAntialiasing()); - rOutputDevice.SetAntialiasing(0); - - rOutputDevice.SetLineColor(); - rOutputDevice.SetFillColor(getBaseColor()); - - if ( mePaintType == SW_OVERLAY_INVERT ) - { - rOutputDevice.Push(); - rOutputDevice.SetRasterOp( ROP_XOR ); - rOutputDevice.SetFillColor( COL_WHITE ); - } + drawinglayer::primitive2d::Primitive2DSequence aRetval; + const sal_uInt32 nCount(maRanges.size()); - for(sal_uInt32 a(0); a < maRanges.size(); a++) + if(nCount) { - const basegfx::B2DRange& rRange(maRanges[a]); + const basegfx::BColor aRGBColor(getBaseColor().getBColor()); + aRetval.realloc(nCount); - switch(mePaintType) + // create primitives for all ranges + for(sal_uInt32 a(0); a < nCount; a++) { - default: // SW_OVERLAY_INVERT - { - const Rectangle aRectangle( - basegfx::fround(rRange.getMinX()), basegfx::fround(rRange.getMinY()), - basegfx::fround(rRange.getMaxX()) - 1, basegfx::fround(rRange.getMaxY()) - 1); - Rectangle aPntRect(aRectangle); - - // avoid single-pixel overlaps - Rectangle aCalcRect( aPntRect ); - bool bChange(false); - - ++aCalcRect.Bottom(); - ++aCalcRect.Right(); - - aPntRect = rOutputDevice.LogicToPixel( aPntRect ); - aCalcRect = rOutputDevice.LogicToPixel( aCalcRect ); - - if(aPntRect.Bottom() == aCalcRect.Bottom()) - { - --aPntRect.Bottom(); - bChange = true; - } - - if(aPntRect.Right() == aCalcRect.Right()) - { - --aPntRect.Right(); - bChange = true; - } - - if(bChange) - { - aPntRect = rOutputDevice.PixelToLogic(aPntRect); - } - else - { - aPntRect = aRectangle; - } - - rOutputDevice.DrawRect(aPntRect); - break; - } - case SW_OVERLAY_TRANSPARENT : - { - const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(rRange)); - rOutputDevice.DrawTransparent(basegfx::B2DPolyPolygon(aPolygon), 0.5); - break; - } + const basegfx::B2DRange& rRange(maRanges[a]); + const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(rRange)); + + aRetval[a] = drawinglayer::primitive2d::Primitive2DReference( + new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( + basegfx::B2DPolyPolygon(aPolygon), + aRGBColor)); } - } - if(mePaintType == SW_OVERLAY_INVERT) - { - rOutputDevice.Pop(); - } - // restore original AA - rOutputDevice.SetAntialiasing(nOriginalAA); - } + if( mePaintType == SW_OVERLAY_TRANSPARENT) + { + // embed in 50% transparent paint + const drawinglayer::primitive2d::Primitive2DReference aUnifiedAlpha( + new drawinglayer::primitive2d::UnifiedAlphaPrimitive2D( + aRetval, + 0.5)); - void OverlaySwSelPaintRects::createBaseRange(OutputDevice& /*rOutputDevice*/) - { - maBaseRange.reset(); + aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedAlpha, 1); + } + else // SW_OVERLAY_INVERT + { + // embed in invert primitive + const drawinglayer::primitive2d::Primitive2DReference aInvert( + new drawinglayer::primitive2d::InvertPrimitive2D( + aRetval)); - for(sal_uInt32 a(0); a < maRanges.size(); a++) - { - const basegfx::B2DRange& rCandidate = maRanges[a]; - maBaseRange.expand(rCandidate); + aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aInvert, 1); + } } + + return aRetval; } OverlaySwSelPaintRects::OverlaySwSelPaintRects(Color aBaseColor, const std::vector< basegfx::B2DRange >& rRanges, SwOverlayType eType) @@ -656,6 +600,8 @@ namespace sdr maRanges(rRanges), mePaintType(eType) { + // no AA for selection overlays + allowAntiAliase(false); } OverlaySwSelPaintRects::~OverlaySwSelPaintRects() @@ -674,39 +620,6 @@ namespace sdr objectChange(); } } - - sal_Bool OverlaySwSelPaintRects::isHit(const basegfx::B2DPoint& rPos, double /*fTol*/) const - { - if(isHittable()) - { - for(sal_uInt32 a(0); a < maRanges.size(); a++) - { - const basegfx::B2DRange& rCandidate = maRanges[a]; - - if(rCandidate.isInside(rPos)) - { - return true; - } - } - } - - return sal_False; - } - - void OverlaySwSelPaintRects::transform(const basegfx::B2DHomMatrix& rMatrix) - { - if(!rMatrix.isIdentity()) - { - for(sal_uInt32 a(0); a < maRanges.size(); a++) - { - basegfx::B2DRange& rCandidate = maRanges[a]; - rCandidate.transform(rMatrix); - } - - // register change (after change) - objectChange(); - } - } } // end of namespace overlay } // end of namespace sdr @@ -907,7 +820,11 @@ SwShellCrsr::SwShellCrsr( SwShellCrsr& rICrsr ) SwShellCrsr::~SwShellCrsr() {} -SwShellCrsr::operator SwShellCrsr* () { return this; } + +bool SwShellCrsr::IsReadOnlyAvailable() const +{ + return GetShell()->IsReadOnlyAvailable(); +} void SwShellCrsr::SetMark() { @@ -936,7 +853,7 @@ void SwShellCrsr::Show() SwShellCrsr * pTmp = this; do { pTmp->SwSelPaintRects::Show(); - } while( this != ( pTmp = (SwShellCrsr*)*(SwCursor*)(pTmp->GetNext() ))); + } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) ); SHOWBOOKMARKS1( 1 ) SHOWREDLINES1( 1 ) @@ -948,7 +865,6 @@ void SwShellCrsr::Show() void SwShellCrsr::Invalidate( const SwRect& rRect ) { SwShellCrsr * pTmp = this; - SwCursor* pTmpCrsr; do { @@ -963,9 +879,7 @@ void SwShellCrsr::Invalidate( const SwRect& rRect ) do { pTmpRing = pTmpRing->GetNext(); - pTmpCrsr = dynamic_cast<SwCursor*>(pTmpRing); - if ( pTmpCrsr ) - pTmp = (SwShellCrsr*)*pTmpCrsr; + pTmp = dynamic_cast<SwShellCrsr*>(pTmpRing); } while ( !pTmp ); } @@ -981,7 +895,7 @@ void SwShellCrsr::Hide() SwShellCrsr * pTmp = this; do { pTmp->SwSelPaintRects::Hide(); - } while( this != ( pTmp = (SwShellCrsr*)*(SwCursor*)(pTmp->GetNext() ))); + } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) ); SHOWBOOKMARKS1( 2 ) SHOWREDLINES1( 2 ) @@ -1086,9 +1000,6 @@ SwShellTableCrsr::SwShellTableCrsr( const SwCrsrShell& rCrsrSh, SwShellTableCrsr::~SwShellTableCrsr() {} void SwShellTableCrsr::SetMark() { SwShellCrsr::SetMark(); } -SwShellTableCrsr::operator SwShellCrsr* () { return this; } -SwShellTableCrsr::operator SwTableCursor* () { return this; } -SwShellTableCrsr::operator SwShellTableCrsr* () { return this; } SwCursor* SwShellTableCrsr::Create( SwPaM* pRing ) const { diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index ae48966e31b8..926a555c8a4e 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -1710,11 +1710,13 @@ BOOL SwDoc::ConvertFieldsToText() sText.Erase(); //now remove the field and insert the string - SwPaM aPam(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); - aPam.SetMark(); - aPam.Move(); - DeleteAndJoin(aPam); - Insert( aPam, sText, true ); + SwPaM aPam1(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); + aPam1.Move(); + Insert( aPam1, sText, true );//insert first to keep the field's attributes + SwPaM aPam2(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); + aPam2.SetMark(); + aPam2.Move(); + DeleteAndJoin(aPam2);//remove the field } } ++aBegin; diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index f4c3d3017972..cd0e3e4f93bf 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1332,7 +1332,8 @@ void _SaveCntntIdx(SwDoc* pDoc, aSave.IncCount(); FOREACHPAM_END() - SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ n ]; + SwUnoTableCrsr* pUnoTblCrsr = + dynamic_cast<SwUnoTableCrsr*>(rTbl[ n ]); if( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) @@ -1474,8 +1475,9 @@ void _RestoreCntntIdx(SwDoc* pDoc, if( pPos ) break; - SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ i ]; - if( pUnoTblCrsr ) + SwUnoTableCrsr* pUnoTblCrsr = + dynamic_cast<SwUnoTableCrsr*>(rTbl[ i ]); + if ( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) if( aSave.GetCount() == nCnt ) @@ -1487,7 +1489,7 @@ void _RestoreCntntIdx(SwDoc* pDoc, ++nCnt; FOREACHPAM_END() } - if( pPos ) + if ( pPos ) break; } } @@ -1629,8 +1631,9 @@ void _RestoreCntntIdx(SvULongs& rSaveArr, if( pPos ) break; - SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ i ]; - if( pUnoTblCrsr ) + SwUnoTableCrsr* pUnoTblCrsr = + dynamic_cast<SwUnoTableCrsr*>(rTbl[ i ]); + if ( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) if( aSave.GetCount() == nCnt ) @@ -1642,7 +1645,7 @@ void _RestoreCntntIdx(SvULongs& rSaveArr, ++nCnt; FOREACHPAM_END() } - if( pPos ) + if ( pPos ) break; } } diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index fe513d51e4da..fb94d433d14f 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -1196,7 +1196,7 @@ BOOL SwCompareLine::ChangesInLine( const SwCompareLine& rLine, SwPaM aCpyPam( rSrcNd, nStt ); aCpyPam.SetMark(); aCpyPam.GetPoint()->nContent = nSEnd; - aCpyPam.GetDoc()->Copy( aCpyPam, *aPam.GetPoint() ); + aCpyPam.GetDoc()->Copy( aCpyPam, *aPam.GetPoint(), false ); pDoc->DoUndo( bUndo ); } @@ -1367,7 +1367,7 @@ void SwCompareData::ShowDelete( const CompareData& rData, ULONG nStt, SwNodeIndex aInsPos( *pLineNd, nOffset ); SwNodeIndex aSavePos( aInsPos, -1 ); - ((SwCompareData&)rData).rDoc.CopyWithFlyInFly( aRg, aInsPos ); + ((SwCompareData&)rData).rDoc.CopyWithFlyInFly( aRg, 0, aInsPos ); rDoc.SetModified(); aSavePos++; @@ -1624,7 +1624,7 @@ 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() ); + pSrcRedl->GetDoc()->Copy( *(SwPaM*)pSrcRedl, *pDestRedl->GetPoint(), false ); pDoc->SetRedlineMode_intern( eOld ); pDoc->DoUndo( bUndo ); diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx index c7c3e4e69031..8e45afd37247 100644 --- a/sw/source/core/doc/doccorr.cxx +++ b/sw/source/core/doc/doccorr.cxx @@ -183,7 +183,8 @@ void PaMCorrAbs( const SwNodeIndex &rOldNode, lcl_PaMCorrAbs1( PCURCRSR, pOldNode, aNewPos, nOffset ); FOREACHPAM_END() - SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ n ]; + SwUnoTableCrsr* pUnoTblCrsr = + dynamic_cast<SwUnoTableCrsr*>(rTbl[ n ]); if( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) @@ -245,7 +246,8 @@ void PaMCorrAbs( const SwNodeIndex &rStartNode, bChange |= lcl_PaMCorrAbs2(PCURCRSR, aNewPos, nSttNode, nEndNode); FOREACHPAM_END() - SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*pUnoCursor; + SwUnoTableCrsr* pUnoTblCrsr = + dynamic_cast<SwUnoTableCrsr*>(pUnoCursor); if( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) @@ -303,7 +305,8 @@ void PaMCorrAbs( const SwPaM& rRange, lcl_PaMCorrAbs3( PCURCRSR, aStart, aEnd, aNewPos ); FOREACHPAM_END() - SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ n ]; + SwUnoTableCrsr* pUnoTblCrsr = + dynamic_cast<SwUnoTableCrsr*>(rTbl[ n ]); if( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) @@ -402,7 +405,8 @@ void PaMCorrRel( const SwNodeIndex &rOldNode, lcl_PaMCorrRel1( PCURCRSR, pOldNode, aNewPos, nCntIdx ); FOREACHPAM_END() - SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ n ]; + SwUnoTableCrsr* pUnoTblCrsr = + dynamic_cast<SwUnoTableCrsr*>(rTbl[ n ]); if( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) diff --git a/sw/source/core/doc/docdde.cxx b/sw/source/core/doc/docdde.cxx index a7c042f51d88..f03ca5b5d352 100644 --- a/sw/source/core/doc/docdde.cxx +++ b/sw/source/core/doc/docdde.cxx @@ -62,7 +62,7 @@ using namespace ::com::sun::star; namespace { - static ::sw::mark::DdeBookmark* const lcl_FindDdeBookmark(const IDocumentMarkAccess& rMarkAccess, const String& rName) + static ::sw::mark::DdeBookmark* lcl_FindDdeBookmark(const IDocumentMarkAccess& rMarkAccess, const String& rName) { //Iterating over all bookmarks, checking DdeBookmarks const String sNameLc = GetAppCharClass().lower(rName); diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx index 736447dad6b2..d19a7bbbc09e 100644 --- a/sw/source/core/doc/docdesc.cxx +++ b/sw/source/core/doc/docdesc.cxx @@ -92,9 +92,7 @@ static void lcl_DefaultPageFmt( sal_uInt16 nPoolFmtId, // <-- SwFmtFrmSize aFrmSize( ATT_FIX_SIZE ); - SvxPaper ePaper = SvxPaperInfo::GetDefaultSvxPaper( - static_cast<LanguageType>( GetAppLanguage() ) ); - const Size aPhysSize = SvxPaperInfo::GetPaperSize( ePaper ); + const Size aPhysSize = SvxPaperInfo::GetDefaultPaperSize(); aFrmSize.SetSize( aPhysSize ); //Auf Default-Raender vorbereiten. diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 8b4ebe172b6f..8db7bdfcb4e6 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -34,16 +34,12 @@ #include <string.h> // fuer strchr() #include <hintids.hxx> -#ifndef _SOUND_HXX //autogen #include <vcl/sound.hxx> -#endif #include <svx/cscoitem.hxx> #include <svx/brkitem.hxx> #include <linguistic/lngprops.hxx> #include <com/sun/star/beans/XPropertySet.hpp> -#ifndef _COM_SUN_STAR_I18N_WORDTYPE_HDL #include <com/sun/star/i18n/WordType.hdl> -#endif #include <unotools/charclass.hxx> #include <fmtanchr.hxx> #include <fmtcntnt.hxx> @@ -477,16 +473,19 @@ bool lcl_SaveFtn( const SwNodeIndex& rSttNd, const SwNodeIndex& rEndNd, SwNode* pNode = &aIdx.GetNode(); if( pNode->IsTxtNode() ) // Looking for text nodes... { - SwpHints *pHints = ((SwTxtNode*)pNode)->GetpSwpHints(); + SwpHints *pHints = + static_cast<SwTxtNode*>(pNode)->GetpSwpHints(); if( pHints && pHints->HasFtn() ) //...with footnotes { bUpdateFtn = sal_True; // Heureka USHORT nCount = pHints->Count(); for( USHORT i = 0; i < nCount; ++i ) { - SwTxtAttr *pAttr = pHints->GetHt( i ); - if( pAttr->Which() == RES_TXTATR_FTN ) - rSaveArr.Insert( (SwTxtFtn*)pAttr ); + SwTxtAttr *pAttr = pHints->GetTextHint( i ); + if ( pAttr->Which() == RES_TXTATR_FTN ) + { + rSaveArr.Insert( static_cast<SwTxtFtn*>(pAttr) ); + } } } } @@ -1475,7 +1474,12 @@ void lcl_GetJoinFlags( SwPaM& rPam, sal_Bool& rJoinTxt, sal_Bool& rJoinPrev ) bExchange = !bExchange; if( bExchange ) rPam.Exchange(); - rJoinPrev = rJoinTxt && rPam.GetPoint() == pStt; + rJoinPrev = rPam.GetPoint() == pStt; + ASSERT( !pStt->nContent.GetIndex() && + pEndNd->GetTxt().Len() != pEnd->nContent.GetIndex() + ? rPam.GetPoint()->nNode < rPam.GetMark()->nNode + : rPam.GetPoint()->nNode > rPam.GetMark()->nNode, + "lcl_GetJoinFlags"); } } } @@ -1493,6 +1497,9 @@ void lcl_JoinText( SwPaM& rPam, sal_Bool bJoinPrev ) SwDoc* pDoc = rPam.GetDoc(); if( bJoinPrev ) { + // N.B.: we do not need to handle xmlids in this case, because + // it is only invoked if one paragraph is completely empty + // (see lcl_GetJoinFlags) { // falls PageBreaks geloescht / gesetzt werden, darf das // nicht in die Undo-History aufgenommen werden !! @@ -1753,7 +1760,8 @@ bool SwDoc::Delete( SwPaM & rPam ) do { // middle checked loop! if( pCNd ) { - if( pCNd->GetTxtNode() ) + SwTxtNode * pStartTxtNode( pCNd->GetTxtNode() ); + if ( pStartTxtNode ) { // verschiebe jetzt noch den Inhalt in den neuen Node sal_Bool bOneNd = pStt->nNode == pEnd->nNode; @@ -1763,7 +1771,15 @@ bool SwDoc::Delete( SwPaM & rPam ) // falls schon leer, dann nicht noch aufrufen if( nLen ) - ((SwTxtNode*)pCNd)->Erase( pStt->nContent, nLen ); + { + pStartTxtNode->Erase( pStt->nContent, nLen ); + + if( !pStartTxtNode->Len() ) + { + // METADATA: remove reference if empty (consider node deleted) + pStartTxtNode->RemoveMetadataReference(); + } + } if( bOneNd ) // das wars schon break; @@ -1781,13 +1797,20 @@ bool SwDoc::Delete( SwPaM & rPam ) pCNd = pEnd->nNode.GetNode().GetCntntNode(); if( pCNd ) { - if( pCNd->GetTxtNode() ) + SwTxtNode * pEndTxtNode( pCNd->GetTxtNode() ); + if( pEndTxtNode ) { // falls schon leer, dann nicht noch aufrufen if( pEnd->nContent.GetIndex() ) { SwIndex aIdx( pCNd, 0 ); - ((SwTxtNode*)pCNd)->Erase( aIdx, pEnd->nContent.GetIndex() ); + pEndTxtNode->Erase( aIdx, pEnd->nContent.GetIndex() ); + + if( !pEndTxtNode->Len() ) + { + // METADATA: remove reference if empty (consider node deleted) + pEndTxtNode->RemoveMetadataReference(); + } } } else @@ -2202,6 +2225,8 @@ sal_Bool lcl_GetTokenToParaBreak( String& rStr, String& rRet, sal_Bool bRegExpRp 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 ) { if( !rPam.HasMark() || *rPam.GetPoint() == *rPam.GetMark() ) diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index ace606ae86ac..8bee61c1da37 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -392,13 +392,13 @@ BOOL SwDoc::SetFlyFrmAttr( SwFrmFmt& rFlyFmt, SfxItemSet& rSet ) if( !rSet.Count() ) return FALSE; - _UndoFmtAttr* pSaveUndo = 0; + ::std::auto_ptr<SwUndoFmtAttrHelper> pSaveUndo; const bool bDoesUndo = DoesUndo(); if( DoesUndo() ) { ClearRedo(); - pSaveUndo = new _UndoFmtAttr( rFlyFmt ); + pSaveUndo.reset( new SwUndoFmtAttrHelper( rFlyFmt ) ); // --> FME 2004-10-13 #i32968# // Inserting columns in the frame causes MakeFrmFmt to put two // objects of type SwUndoFrmFmt on the undo stack. We don't want them. @@ -452,15 +452,16 @@ BOOL SwDoc::SetFlyFrmAttr( SwFrmFmt& rFlyFmt, SfxItemSet& rSet ) if( MAKEFRMS == nMakeFrms ) rFlyFmt.MakeFrms(); - if( pSaveUndo ) + if ( pSaveUndo.get() ) { // --> FME 2004-10-13 #i32968# DoUndo( bDoesUndo ); // <-- - if( pSaveUndo->pUndo ) - AppendUndo( pSaveUndo->pUndo ); - delete pSaveUndo; + if ( pSaveUndo->GetUndo() ) + { + AppendUndo( pSaveUndo->ReleaseUndo() ); + } } SetModified(); diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index caa4987c6f04..9db1c98685f3 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -40,9 +40,7 @@ #include <svtools/itemiter.hxx> #include <sfx2/app.hxx> #include <svtools/misccfg.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/eeitem.hxx> #include <svx/langitem.hxx> #include <svx/lrspitem.hxx> @@ -53,9 +51,7 @@ #include <svtools/zforlist.hxx> #endif #include <comphelper/processfactory.hxx> -#ifndef _COM_SUN_STAR_I18N_WORDTYPE_HDL #include <com/sun/star/i18n/WordType.hdl> -#endif #include <fmtpdsc.hxx> #include <fmthdft.hxx> #include <fmtcntnt.hxx> @@ -367,8 +363,8 @@ void SwDoc::RstTxtAttrs(const SwPaM &rRg, BOOL bInclRefToxMark ) if( DoesUndo() ) { ClearRedo(); - SwUndoRstAttr* pUndo = new SwUndoRstAttr( rRg, RES_CHRFMT ); - pHst = pUndo->GetHistory(); + SwUndoResetAttr* pUndo = new SwUndoResetAttr( rRg, RES_CHRFMT ); + pHst = &pUndo->GetHistory(); AppendUndo( pUndo ); } const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End(); @@ -452,11 +448,13 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, if( DoesUndo() ) { ClearRedo(); - SwUndoRstAttr* pUndo = new SwUndoRstAttr( rRg, + SwUndoResetAttr* pUndo = new SwUndoResetAttr( rRg, static_cast<USHORT>(bTxtAttr ? RES_CONDTXTFMTCOLL : RES_TXTFMTCOLL )); if( pAttrs && pAttrs->Count() ) + { pUndo->SetAttrs( *pAttrs ); - pHst = pUndo->GetHistory(); + } + pHst = &pUndo->GetHistory(); AppendUndo( pUndo ); } @@ -505,9 +503,7 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, { if( IsInRange( aCharFmtSetRange, pItem->Which() )) { - - if( !pTNd->pSwpHints ) - pTNd->pSwpHints = new SwpHints; + pTNd->GetOrCreateSwpHints(); aCharSet.Put( *pItem ); @@ -556,14 +552,13 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, { SwTxtAttr* pTAttr = pTNd->MakeTxtAttr( *pItem, 0, pTNd->GetTxt().Len() ); - if( !pTNd->pSwpHints ) - pTNd->pSwpHints = new SwpHints; - pTNd->pSwpHints->SwpHintsArr::Insert( pTAttr ); + SwpHints & rHints = pTNd->GetOrCreateSwpHints(); + rHints.SwpHintsArray::Insert( pTAttr ); if( pHst ) { SwRegHistory aRegH( pTNd, *pTNd, pHst ); pTNd->ResetAttr( pItem->Which() ); - pHst->Add( pTAttr, aTmpEnd.GetIndex(), TRUE ); + pHst->Add( pTAttr, aTmpEnd.GetIndex(), true ); } else pTNd->ResetAttr( pItem->Which() ); @@ -619,22 +614,22 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, const SfxPoolItem* pItem = aIter.FirstItem(); const USHORT nWhich = pItem->Which(); - if ( (RES_CHRATR_BEGIN <= nWhich && nWhich < RES_CHRATR_END) || - RES_TXTATR_CHARFMT == nWhich || - RES_TXTATR_INETFMT == nWhich || - RES_TXTATR_AUTOFMT == nWhich || - (RES_UNKNOWNATR_BEGIN <= nWhich && nWhich < RES_UNKNOWNATR_END) ) + if ( isCHRATR(nWhich) || + (RES_TXTATR_CHARFMT == nWhich) || + (RES_TXTATR_INETFMT == nWhich) || + (RES_TXTATR_AUTOFMT == nWhich) || + isUNKNOWNATR(nWhich) ) { pCharSet = &rChgSet; bCharAttr = true; } - if ( (RES_PARATR_BEGIN <= nWhich && nWhich < RES_PARATR_END) || + if ( isPARATR(nWhich) // --> OD 2008-02-25 #refactorlists# - (RES_PARATR_LIST_BEGIN <= nWhich && nWhich < RES_PARATR_LIST_END) || + || isPARATR_LIST(nWhich) // <-- - (RES_FRMATR_BEGIN <= nWhich && nWhich < RES_FRMATR_END) || - (RES_GRFATR_BEGIN <= nWhich && nWhich < RES_GRFATR_END) ) + || isFRMATR(nWhich) + || isGRFATR(nWhich) ) { pOtherSet = &rChgSet; bOtherAttr = true; @@ -672,7 +667,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, bDelete = true; } - SwHistory* pHistory = pUndo ? pUndo->GetHistory() : 0; + SwHistory* pHistory = pUndo ? &pUndo->GetHistory() : 0; BOOL bRet = FALSE; const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End(); SwCntntNode* pNode = pStt->nNode.GetNode().GetCntntNode(); @@ -1183,13 +1178,17 @@ void SwDoc::SetAttr( const SfxItemSet& rSet, SwFmt& rFmt ) if( DoesUndo() ) { ClearRedo(); - _UndoFmtAttr aTmp( rFmt ); + SwUndoFmtAttrHelper aTmp( rFmt ); rFmt.SetFmtAttr( rSet ); - if( aTmp.pUndo ) - AppendUndo( aTmp.pUndo ); + if ( aTmp.GetUndo() ) + { + AppendUndo( aTmp.ReleaseUndo() ); + } } else + { rFmt.SetFmtAttr( rSet ); + } SetModified(); } @@ -1271,30 +1270,34 @@ void SwDoc::SetDefault( const SfxItemSet& rSet ) GetAttrPool().SetPoolDefaultItem( *pItem ); aNew.Put( GetAttrPool().GetDefaultItem( nWhich ) ); - if( RES_CHRATR_BEGIN <= nWhich && RES_TXTATR_END > nWhich ) + if (isCHRATR(nWhich) || isTXTATR(nWhich)) { aCallMod.Add( pDfltTxtFmtColl ); aCallMod.Add( pDfltCharFmt ); bCheckSdrDflt = 0 != pSdrPool; } - else if ( ( RES_PARATR_BEGIN <= nWhich && RES_PARATR_END > nWhich ) || + else if ( isPARATR(nWhich) || // --> OD 2008-02-25 #refactorlists# - ( RES_PARATR_LIST_BEGIN <= nWhich && nWhich < RES_PARATR_LIST_END ) ) + isPARATR_LIST(nWhich) ) // <-- { aCallMod.Add( pDfltTxtFmtColl ); bCheckSdrDflt = 0 != pSdrPool; } - else if( RES_GRFATR_BEGIN <= nWhich && RES_GRFATR_END > nWhich ) + else if (isGRFATR(nWhich)) + { aCallMod.Add( pDfltGrfFmtColl ); - else if( RES_FRMATR_BEGIN <= nWhich && RES_FRMATR_END > nWhich ) + } + else if (isFRMATR(nWhich)) { aCallMod.Add( pDfltGrfFmtColl ); aCallMod.Add( pDfltTxtFmtColl ); aCallMod.Add( pDfltFrmFmt ); } - else if( RES_BOXATR_BEGIN <= nWhich && RES_BOXATR_END > nWhich ) + else if (isBOXATR(nWhich)) + { aCallMod.Add( pDfltFrmFmt ); + } // copy also the defaults if( bCheckSdrDflt ) @@ -2136,7 +2139,7 @@ void SwDoc::_CopyPageDescHeaderFooter( BOOL bCpyHeader, aTmpIdx = *pSttNd->EndOfSectionNode(); rSrcNds._Copy( aRg, aTmpIdx ); aTmpIdx = *pSttNd; - rSrcFmt.GetDoc()->_CopyFlyInFly( aRg, aTmpIdx ); + rSrcFmt.GetDoc()->_CopyFlyInFly( aRg, 0, aTmpIdx ); pNewFmt->SetFmtAttr( SwFmtCntnt( pSttNd )); } else @@ -2332,7 +2335,7 @@ void SwDoc::MoveLeftMargin( const SwPaM& rPam, BOOL bRight, BOOL bModulus ) ClearRedo(); SwUndoMoveLeftMargin* pUndo = new SwUndoMoveLeftMargin( rPam, bRight, bModulus ); - pHistory = pUndo->GetHistory(); + pHistory = &pUndo->GetHistory(); AppendUndo( pUndo ); } diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx index d11d846f0856..d9e711bd5fcf 100644 --- a/sw/source/core/doc/docftn.cxx +++ b/sw/source/core/doc/docftn.cxx @@ -74,7 +74,7 @@ SwEndNoteInfo& SwEndNoteInfo::operator=(const SwEndNoteInfo& rInfo) aFmt = rInfo.aFmt; nFtnOffset = rInfo.nFtnOffset; - bEndNote = rInfo.bEndNote; + m_bEndNote = rInfo.m_bEndNote; sPrefix = rInfo.sPrefix; sSuffix = rInfo.sSuffix; return *this; @@ -92,7 +92,7 @@ BOOL SwEndNoteInfo::operator==( const SwEndNoteInfo& rInfo ) const GetFtnTxtColl() == rInfo.GetFtnTxtColl() && aFmt.GetNumberingType() == rInfo.aFmt.GetNumberingType() && nFtnOffset == rInfo.nFtnOffset && - bEndNote == rInfo.bEndNote && + m_bEndNote == rInfo.m_bEndNote && sPrefix == rInfo.sPrefix && sSuffix == rInfo.sSuffix; } @@ -105,7 +105,7 @@ SwEndNoteInfo::SwEndNoteInfo(const SwEndNoteInfo& rInfo) : aAnchorCharFmtDep( this, 0 ), sPrefix( rInfo.sPrefix ), sSuffix( rInfo.sSuffix ), - bEndNote( TRUE ), + m_bEndNote( true ), aFmt( rInfo.aFmt ), nFtnOffset( rInfo.nFtnOffset ) { @@ -125,7 +125,7 @@ SwEndNoteInfo::SwEndNoteInfo(SwTxtFmtColl *pFmt) : aPageDescDep( this, 0 ), aCharFmtDep( this, 0 ), aAnchorCharFmtDep( this, 0 ), - bEndNote( TRUE ), + m_bEndNote( true ), nFtnOffset( 0 ) { aFmt.SetNumberingType(SVX_NUM_ROMAN_LOWER); @@ -136,7 +136,7 @@ SwPageDesc *SwEndNoteInfo::GetPageDesc( SwDoc &rDoc ) const if ( !aPageDescDep.GetRegisteredIn() ) { SwPageDesc *pDesc = rDoc.GetPageDescFromPool( static_cast<sal_uInt16>( - bEndNote ? RES_POOLPAGE_ENDNOTE : RES_POOLPAGE_FOOTNOTE ) ); + m_bEndNote ? RES_POOLPAGE_ENDNOTE : RES_POOLPAGE_FOOTNOTE ) ); pDesc->Add( &((SwClient&)aPageDescDep) ); } return (SwPageDesc*)aPageDescDep.GetRegisteredIn(); @@ -157,7 +157,7 @@ SwCharFmt* SwEndNoteInfo::GetCharFmt(SwDoc &rDoc) const if ( !aCharFmtDep.GetRegisteredIn() ) { SwCharFmt* pFmt = rDoc.GetCharFmtFromPool( static_cast<sal_uInt16>( - bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE ) ); + m_bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE ) ); pFmt->Add( &((SwClient&)aCharFmtDep) ); } return (SwCharFmt*)aCharFmtDep.GetRegisteredIn(); @@ -174,7 +174,7 @@ SwCharFmt* SwEndNoteInfo::GetAnchorCharFmt(SwDoc &rDoc) const if( !aAnchorCharFmtDep.GetRegisteredIn() ) { SwCharFmt* pFmt = rDoc.GetCharFmtFromPool( static_cast<sal_uInt16>( - bEndNote ? RES_POOLCHR_ENDNOTE_ANCHOR : RES_POOLCHR_FOOTNOTE_ANCHOR ) ); + m_bEndNote ? RES_POOLCHR_ENDNOTE_ANCHOR : RES_POOLCHR_FOOTNOTE_ANCHOR ) ); pFmt->Add( &((SwClient&)aAnchorCharFmtDep) ); } return (SwCharFmt*)aAnchorCharFmtDep.GetRegisteredIn(); @@ -203,8 +203,10 @@ void SwEndNoteInfo::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) { SwTxtFtn *pTxtFtn = rFtnIdxs[ nPos ]; const SwFmtFtn &rFtn = pTxtFtn->GetFtn(); - if ( rFtn.IsEndNote() == bEndNote) + if ( rFtn.IsEndNote() == m_bEndNote ) + { pTxtFtn->SetNumber( rFtn.GetNumber(), &rFtn.GetNumStr()); + } } } else @@ -239,7 +241,7 @@ SwFtnInfo::SwFtnInfo(const SwFtnInfo& rInfo) : ePos( rInfo.ePos ), eNum( rInfo.eNum ) { - bEndNote = FALSE; + m_bEndNote = false; } SwFtnInfo::SwFtnInfo(SwTxtFmtColl *pFmt) : @@ -248,7 +250,7 @@ SwFtnInfo::SwFtnInfo(SwTxtFmtColl *pFmt) : eNum( FTNNUM_DOC ) { aFmt.SetNumberingType(SVX_NUM_ARABIC); - bEndNote = FALSE; + m_bEndNote = false; } /*********************** SwDoc ***************************/ @@ -263,7 +265,7 @@ void SwDoc::SetFtnInfo(const SwFtnInfo& rInfo) if( DoesUndo() ) { ClearRedo(); - AppendUndo( new SwUndoFtnInfo( rOld ) ); + AppendUndo( new SwUndoFootNoteInfo( rOld ) ); } BOOL bFtnPos = rInfo.ePos != rOld.ePos; @@ -384,8 +386,8 @@ void SwDoc::SetEndNoteInfo(const SwEndNoteInfo& rInfo) } -BOOL SwDoc::SetCurFtn( const SwPaM& rPam, const String& rNumStr, - USHORT nNumber, BOOL bIsEndNote ) +bool SwDoc::SetCurFtn( const SwPaM& rPam, const String& rNumStr, + sal_uInt16 nNumber, bool bIsEndNote ) { SwFtnIdxs& rFtnArr = GetFtnIdxs(); @@ -398,11 +400,11 @@ BOOL SwDoc::SetCurFtn( const SwPaM& rPam, const String& rNumStr, USHORT nPos; rFtnArr.SeekEntry( pStt->nNode, &nPos ); - SwUndoChgFtn* pUndo = 0; + SwUndoChangeFootNote* pUndo = 0; if( DoesUndo() ) { ClearRedo(); - pUndo = new SwUndoChgFtn( rPam, rNumStr, nNumber, bIsEndNote ); + pUndo = new SwUndoChangeFootNote( rPam, rNumStr, nNumber, bIsEndNote ); } SwTxtFtn* pTxtFtn; @@ -423,8 +425,10 @@ BOOL SwDoc::SetCurFtn( const SwPaM& rPam, const String& rNumStr, rFtn.IsEndNote() != bIsEndNote ) { bChg = TRUE; - if( pUndo ) - pUndo->GetHistory()->Add( *pTxtFtn ); + if ( pUndo ) + { + pUndo->GetHistory().Add( *pTxtFtn ); + } pTxtFtn->SetNumber( nNumber, &rNumStr ); if( rFtn.IsEndNote() != bIsEndNote ) @@ -453,8 +457,10 @@ BOOL SwDoc::SetCurFtn( const SwPaM& rPam, const String& rNumStr, rFtn.IsEndNote() != bIsEndNote ) { bChg = TRUE; - if( pUndo ) - pUndo->GetHistory()->Add( *pTxtFtn ); + if ( pUndo ) + { + pUndo->GetHistory().Add( *pTxtFtn ); + } pTxtFtn->SetNumber( nNumber, &rNumStr ); if( rFtn.IsEndNote() != bIsEndNote ) diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index a4bfb749174c..b340b1ce45fb 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, aIdx ); + _CopyFlyInFly( 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, aIdx ); + _CopyFlyInFly( aRg, 0, aIdx ); // und noch alle Bookmarks diff --git a/sw/source/core/doc/docglos.cxx b/sw/source/core/doc/docglos.cxx index 4dac390ece46..2f3f58e76f3b 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 ); + pGDoc->Copy( 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 29258f9de72e..77df07dcb2d3 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -507,7 +507,7 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource, // sorge dafuer das auch Fly's in Fly's kopiert werden aIdx = *pSttNd->EndOfSectionNode(); - pSrcDoc->CopyWithFlyInFly( aRg, aIdx, sal_False, sal_True, sal_True ); + pSrcDoc->CopyWithFlyInFly( aRg, 0, aIdx, sal_False, sal_True, sal_True ); } else { @@ -885,7 +885,7 @@ if( DoesUndo() ) // werden erstmal alle Undo - Objecte geloescht. do { if( pTmp->HasMark() && *pTmp->GetPoint() != *pTmp->GetMark() ) - Copy( *pTmp, aPos ); + Copy( *pTmp, aPos, false ); } while( &rPam != ( pTmp = (SwPaM*)pTmp->GetNext() ) ); mbCopyIsMove = bOldFlag; mbUndo = bOldUndo; diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index a0348d84b352..67c64e27b9d0 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -32,6 +32,7 @@ #include "precompiled_sw.hxx" #define ROLBCK_HISTORY_ONLY // Der Kampf gegen die CLOOK's #include <doc.hxx> +#include <dcontact.hxx> #include <com/sun/star/document/PrinterIndependentLayout.hpp> #include <com/sun/star/document/UpdateDocMode.hpp> #include <com/sun/star/text/XTextDocument.hpp> @@ -46,12 +47,9 @@ #include <sfx2/docfile.hxx> #include <sfx2/frame.hxx> -#ifndef _SFXMACITEM_HXX //autogen - #include <svtools/macitem.hxx> -#endif -#ifndef _SVX_SVXIDS_HRC +#include <svtools/macitem.hxx> #include <svx/svxids.hrc> -#endif +#include <svx/svdogrp.hxx> #include <svx/linkmgr.hxx> #include <svx/forbiddencharacterstable.hxx> #include <svtools/zforlist.hxx> @@ -79,18 +77,12 @@ #include <frmfmt.hxx> #include <rolbck.hxx> // Undo-Attr, SwHistory #include <poolfmt.hxx> // fuer die Pool-Vorlage -#ifndef _DBMGR_HXX #include <dbmgr.hxx> -#endif -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <acorrect.hxx> // fuer die autom. Aufnahme von Ausnahmen #include <visiturl.hxx> // fuer die URL-Change Benachrichtigung #include <docary.hxx> -#ifndef _LINEINFO_HXX #include <lineinfo.hxx> -#endif #include <drawdoc.hxx> #include <linkenum.hxx> #include <fldupde.hxx> @@ -105,13 +97,11 @@ #include <istyleaccess.hxx> #include <swstylemanager.hxx> #include <IGrammarContact.hxx> +#include <tblsel.hxx> #include <MarkManager.hxx> - #include <unochart.hxx> -#ifndef _CMDID_H #include <cmdid.h> // fuer den dflt - Printer in SetJob -#endif // --> OD 2006-04-19 #b6375613# @@ -119,7 +109,6 @@ #include <com/sun/star/beans/XPropertyContainer.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> -using namespace ::com::sun::star; // <-- // --> OD 2007-03-16 #i73788# @@ -133,6 +122,10 @@ using namespace ::com::sun::star; #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <sfx2/Metadatable.hxx> + + +using namespace ::com::sun::star; using namespace ::com::sun::star::document; const sal_Char __FAR_DATA sFrmFmtStr[] = "Frameformat"; @@ -271,6 +264,7 @@ SwDoc::SwDoc() : // --> OD 2007-10-31 #i83479# mpListItemsList( new tImplSortedNodeNumList() ), // <-- + m_pXmlIdRegistry(), nUndoPos( 0 ), nUndoSavePos( 0 ), nUndoCnt( 0 ), @@ -284,7 +278,6 @@ SwDoc::SwDoc() : mIdleBlockCount(0), nLockExpFld( 0 ), mbReadlineChecked(false), - mbWinEncryption(sal_False), // --> OD 2005-02-11 #i38810# mbLinksUpdated( sal_False ), mbClipBoard( false ), @@ -438,22 +431,7 @@ SwDoc::SwDoc() : pNewDBMgr = new SwNewDBMgr; // create TOXTypes - ShellResource* pShellRes = ViewShell::GetShellRes(); - - SwTOXType * pNew = new SwTOXType(TOX_CONTENT, pShellRes->aTOXContentName ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); - pNew = new SwTOXType(TOX_INDEX, pShellRes->aTOXIndexName ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); - pNew = new SwTOXType(TOX_USER, pShellRes->aTOXUserName ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); - pNew = new SwTOXType(TOX_ILLUSTRATIONS, pShellRes->aTOXIllustrationsName ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); - pNew = new SwTOXType(TOX_OBJECTS, pShellRes->aTOXObjectsName ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); - pNew = new SwTOXType(TOX_TABLES, pShellRes->aTOXTablesName ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); - pNew = new SwTOXType(TOX_AUTHORITIES, pShellRes->aTOXAuthoritiesName ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + InitTOXTypes(); // --> OD 2008-03-07 #refactorlists# // pass empty item set containing the paragraph's list attributes @@ -824,7 +802,7 @@ void SwDoc::ClearDoc() // in den BookMarks sind Indizies auf den Content. Diese muessen vorm // loesche der Nodes geloescht werden. pMarkManager->clearAllMarks(); - pTOXTypes->DeleteAndDestroy( 0, pTOXTypes->Count() ); + InitTOXTypes(); // create a dummy pagedesc for the layout sal_uInt16 nDummyPgDsc = MakePageDesc( String::CreateFromAscii( "?DUMMY?" )); @@ -1049,3 +1027,400 @@ void SwDoc::SetApplyWorkaroundForB6375613( bool p_bApplyWorkaroundForB6375613 ) } } // <-- + +::sfx2::IXmlIdRegistry& +SwDoc::GetXmlIdRegistry() +{ + // UGLY: this relies on SetClipBoard being called before GetXmlIdRegistry! + if (!m_pXmlIdRegistry.get()) + { + m_pXmlIdRegistry.reset( ::sfx2::createXmlIdRegistry( IsClipBoard() ) ); + } + return *m_pXmlIdRegistry; +} + +void SwDoc::InitTOXTypes() +{ + ShellResource* pShellRes = ViewShell::GetShellRes(); + SwTOXType * pNew = new SwTOXType(TOX_CONTENT, pShellRes->aTOXContentName ); + pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pNew = new SwTOXType(TOX_INDEX, pShellRes->aTOXIndexName ); + pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pNew = new SwTOXType(TOX_USER, pShellRes->aTOXUserName ); + pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pNew = new SwTOXType(TOX_ILLUSTRATIONS, pShellRes->aTOXIllustrationsName ); + pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pNew = new SwTOXType(TOX_OBJECTS, pShellRes->aTOXObjectsName ); + pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pNew = new SwTOXType(TOX_TABLES, pShellRes->aTOXTablesName ); + pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pNew = new SwTOXType(TOX_AUTHORITIES, pShellRes->aTOXAuthoritiesName ); + pTOXTypes->Insert( pNew, pTOXTypes->Count() ); +} + +/*-- 08.05.2009 10:07:57--------------------------------------------------- + + -----------------------------------------------------------------------*/ +SwDoc* SwDoc::CreateCopy() const +{ + SwDoc* pRet = new SwDoc; + //copy settings +/* + //aNodes( this ), + //aUndoNodes( this ), + mpAttrPool(new SwAttrPool(this)),*/ + USHORT __FAR_DATA aRangeOfDefaults[] = { + RES_FRMATR_BEGIN, RES_FRMATR_END-1, + RES_CHRATR_BEGIN, RES_CHRATR_END-1, + RES_PARATR_BEGIN, RES_PARATR_END-1, + // --> OD 2008-02-25 #refactorlists## + RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1, + // <-- + RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, + 0 + }; + + SfxItemSet aNewDefaults( pRet->GetAttrPool(), aRangeOfDefaults ); + + USHORT nWhich; + USHORT nRange = 0; + while( aRangeOfDefaults[nRange] != 0) + { + for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich ) + { + const SfxPoolItem& rSourceAttr = mpAttrPool->GetDefaultItem( nWhich ); + if( rSourceAttr != pRet->mpAttrPool->GetDefaultItem( nWhich ) ) + aNewDefaults.Put( rSourceAttr ); + } + nRange += 2; + } + if( aNewDefaults.Count() ) + pRet->SetDefault( aNewDefaults ); + + /* + pDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ), + pEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, pDfltFrmFmt ) ), + pColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, pDfltFrmFmt ) ), + pDfltCharFmt( new SwCharFmt( GetAttrPool(), sCharFmtStr, 0 ) ), + pDfltTxtFmtColl( new SwTxtFmtColl( GetAttrPool(), sTxtCollStr ) ), + pDfltGrfFmtColl( new SwGrfFmtColl( GetAttrPool(), sGrfCollStr ) ), + pFrmFmtTbl( new SwFrmFmts() ), + pCharFmtTbl( new SwCharFmts() ), + pSpzFrmFmtTbl( new SwSpzFrmFmts() ), + pSectionFmtTbl( new SwSectionFmts() ), + pTblFrmFmtTbl( new SwFrmFmts() ), + pTxtFmtCollTbl( new SwTxtFmtColls() ), + pGrfFmtCollTbl( new SwGrfFmtColls() ), + pBookmarkTbl( new SwBookmarks( 0, 16 ) ), + pTOXTypes( new SwTOXTypes() ), + pDefTOXBases( new SwDefTOXBase_Impl() ), + pLayout( 0 ), // Rootframe des spezifischen Layouts. + pDrawModel( 0 ), + pUndos( new SwUndos( 0, 20 ) ), + pUpdtFlds( new SwDocUpdtFld() ), + pFldTypes( new SwFldTypes() ), + pVirDev( 0 ), + pPrt( 0 ), + pPrtData( 0 ), + pGlossaryDoc( 0 ), + pOutlineRule( 0 ), + pFtnInfo( new SwFtnInfo ), + pEndNoteInfo( new SwEndNoteInfo ), + pLineNumberInfo( new SwLineNumberInfo ), + pFtnIdxs( new SwFtnIdxs ), + pDocStat( new SwDocStat ), + pDocShell( 0 ), + pDocShRef( 0 ), + pLinkMgr( new SvxLinkManager( 0 ) ), + pACEWord( 0 ), + pURLStateChgd( 0 ), + pNumberFormatter( 0 ), + pNumRuleTbl( new SwNumRuleTbl ), + // --> OD 2008-03-26 #refactorlists# + maLists(), + maListStyleLists(), + // <-- + pRedlineTbl( new SwRedlineTbl ), + pAutoFmtRedlnComment( 0 ), + pUnoCrsrTbl( new SwUnoCrsrTbl( 0, 16 ) ), + pPgPViewPrtData( 0 ), + pExtInputRing( 0 ), + pLayouter( 0 ), + // --> OD 2008-03-07 #refactorlists# + pStyleAccess( 0 ), + // <-- + pLayoutCache( 0 ), + pUnoCallBack(new SwUnoCallBack(0)), + mpGrammarContact( 0 ), + aChartDataProviderImplRef(), + pChartControllerHelper( 0 ), + // --> OD 2007-10-31 #i83479# + mpListItemsList( new tImplSortedNodeNumList() ), + // <-- + nUndoPos( 0 ), + nUndoSavePos( 0 ), + nUndoCnt( 0 ), + nUndoSttEnd( 0 ), + nAutoFmtRedlnCommentNo( 0 ), + nLinkUpdMode( GLOBALSETTING ), + eFldUpdMode( AUTOUPD_GLOBALSETTING ), + eRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)), + eChrCmprType( CHARCOMPRESS_NONE ), + mReferenceCount(0), + mIdleBlockCount(0), + nLockExpFld( 0 ), + mbReadlineChecked(false), + mbWinEncryption(sal_False), + // --> OD 2005-02-11 #i38810# + mbLinksUpdated( sal_False ), + mbClipBoard( false ), + mbColumnSelection( false ), + // i#78591# + mbProtectForm(false),*/ + pRet->n32DummyCompatabilityOptions1 = n32DummyCompatabilityOptions1; + pRet->n32DummyCompatabilityOptions2 = n32DummyCompatabilityOptions2; + /* + mbStartIdleTimer(sal_False) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDoc::SwDoc" ); + + mbGlossDoc = + mbModified = + mbDtor = + mbUndo = + mbPageNums = + mbLoaded = + mbUpdateExpFld = + mbNewDoc = + mbCopyIsMove = + mbNoDrawUndoObj = + mbBrowseMode = + mbInReading = + mbInXMLImport = + mbUpdateTOX = + mbInLoadAsynchron = + mbHTMLMode = + mbInCallModified = + mbIsGlobalDoc = + mbGlblDocSaveLinks = + mbIsLabelDoc = + mbIsAutoFmtRedline = + mbOLEPrtNotifyPending = + mbAllOLENotify = + mbIsRedlineMove = + mbInsOnlyTxtGlssry = + mbContains_MSVBasic = + mbKernAsianPunctuation = +#ifndef PRODUCT + mbXMLExport = +#endif + // --> OD 2006-03-21 #b6375613# + mbApplyWorkaroundForB6375613 = + // <-- + false; + + mbGroupUndo = + mbNewFldLst = + mbVisibleLinks = + mbPurgeOLE = + true; + + // + // COMPATIBILITY FLAGS START + // + + // Note: Any non-hidden compatibility flag should obtain its default + // by asking SvtCompatibilityOptions, see below. + // + const SvtCompatibilityOptions aOptions; + */ + pRet->mbParaSpaceMax = mbParaSpaceMax ; + pRet->mbParaSpaceMaxAtPages = mbParaSpaceMaxAtPages ; + pRet->mbTabCompat = mbTabCompat ; + pRet->mbUseVirtualDevice = mbUseVirtualDevice ; + pRet->mbAddExternalLeading = mbAddExternalLeading ; + pRet->mbOldLineSpacing = mbOldLineSpacing ; + pRet->mbAddParaSpacingToTableCells = mbAddParaSpacingToTableCells ; + pRet->mbUseFormerObjectPos = mbUseFormerObjectPos ; + pRet->mbUseFormerTextWrapping = mbUseFormerTextWrapping ; + pRet->mbConsiderWrapOnObjPos = mbConsiderWrapOnObjPos ; + pRet->mbAddFlyOffsets = mbAddFlyOffsets ; + pRet->mbOldNumbering = mbOldNumbering ; + pRet->mbUseHiResolutionVirtualDevice = mbUseHiResolutionVirtualDevice ; + pRet->mbIgnoreFirstLineIndentInNumbering = mbIgnoreFirstLineIndentInNumbering ; + pRet->mbDoNotJustifyLinesWithManualBreak = mbDoNotJustifyLinesWithManualBreak ; + pRet->mbDoNotResetParaAttrsForNumFont = mbDoNotResetParaAttrsForNumFont ; + pRet->mbOutlineLevelYieldsOutlineRule = mbOutlineLevelYieldsOutlineRule ; + pRet->mbTableRowKeep = mbTableRowKeep ; + pRet->mbIgnoreTabsAndBlanksForLineCalculation = mbIgnoreTabsAndBlanksForLineCalculation ; + pRet->mbDoNotCaptureDrawObjsOnPage = mbDoNotCaptureDrawObjsOnPage ; + pRet->mbClipAsCharacterAnchoredWriterFlyFrames= mbClipAsCharacterAnchoredWriterFlyFrames; + pRet->mbUnixForceZeroExtLeading = mbUnixForceZeroExtLeading ; + pRet->mbOldPrinterMetrics = mbOldPrinterMetrics ; + pRet->mbTabRelativeToIndent = mbTabRelativeToIndent ; + pRet->mbTabAtLeftIndentForParagraphsInList = mbTabAtLeftIndentForParagraphsInList ; + + // + // COMPATIBILITY FLAGS END + // + /* + pMacroTable = new SvxMacroTableDtor; + + mpGrammarContact = ::createGrammarContact(); + + // Formate + pFrmFmtTbl->Insert(pDfltFrmFmt, 0 ); + pCharFmtTbl->Insert(pDfltCharFmt, 0 ); + + // FmtColls + // TXT + pTxtFmtCollTbl->Insert(pDfltTxtFmtColl, 0 ); + // GRF + pGrfFmtCollTbl->Insert(pDfltGrfFmtColl, 0 ); + + // PageDesc, EmptyPageFmt und ColumnFmt anlegen + if ( !aPageDescs.Count() ) + GetPageDescFromPool( RES_POOLPAGE_STANDARD ); + + //Leere Seite Einstellen. + pEmptyPageFmt->SetFmtAttr( SwFmtFrmSize( ATT_FIX_SIZE ) ); + //BodyFmt fuer Spalten Einstellen. + pColumnContFmt->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ) ); + + _InitFieldTypes(); + + // lege (fuer die Filter) eine Default-OutlineNumRule an + // --> OD 2008-02-11 #newlistlevelattrs# + pOutlineRule = new SwNumRule( String::CreateFromAscii( SwNumRule::GetOutlineRuleName() ), + // --> OD 2008-06-06 #i89178# + numfunc::GetDefaultPositionAndSpaceMode(), + // <-- + OUTLINE_RULE ); + // <-- + // #115901# + AddNumRule(pOutlineRule); + // --> OD 2005-10-21 - counting of phantoms depends on <IsOldNumbering()> + pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) ); + // <-- + + new SwTxtNode( SwNodeIndex( aUndoNodes.GetEndOfContent() ), pDfltTxtFmtColl ); + new SwTxtNode( SwNodeIndex( aNodes.GetEndOfContent() ), + GetTxtCollFromPool( RES_POOLCOLL_STANDARD )); + + // den eigenen IdleTimer setzen + aIdleTimer.SetTimeout( 600 ); + aIdleTimer.SetTimeoutHdl( LINK(this, SwDoc, DoIdleJobs) ); + + aOLEModifiedTimer.SetTimeout( 1000 ); + aOLEModifiedTimer.SetTimeoutHdl( LINK( this, SwDoc, DoUpdateModifiedOLE )); + + // DBMgr anlegen + pNewDBMgr = new SwNewDBMgr; + + // create TOXTypes + ShellResource* pShellRes = ViewShell::GetShellRes(); + + SwTOXType * pNew = new SwTOXType(TOX_CONTENT, pShellRes->aTOXContentName ); + pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pNew = new SwTOXType(TOX_INDEX, pShellRes->aTOXIndexName ); + pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pNew = new SwTOXType(TOX_USER, pShellRes->aTOXUserName ); + pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pNew = new SwTOXType(TOX_ILLUSTRATIONS, pShellRes->aTOXIllustrationsName ); + pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pNew = new SwTOXType(TOX_OBJECTS, pShellRes->aTOXObjectsName ); + pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pNew = new SwTOXType(TOX_TABLES, pShellRes->aTOXTablesName ); + pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pNew = new SwTOXType(TOX_AUTHORITIES, pShellRes->aTOXAuthoritiesName ); + pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + + { + SfxItemSet aIgnorableParagraphItems( GetAttrPool(), + RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1, + 0 ); + pStyleAccess = createStyleManager( &aIgnorableParagraphItems ); + } + + ResetModified(); + +*/ + //copy content + pRet->Paste( *this ); + return pRet; +} +/*-- 08.05.2009 10:52:40--------------------------------------------------- + copy document content - code from SwFEShell::Paste( SwDoc* , BOOL ) + -----------------------------------------------------------------------*/ +void SwDoc::Paste( const SwDoc& rSource ) +{ +// this has to be empty const USHORT nStartPageNumber = GetPhyPageNum(); + // until the end of the NodesArray + SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 2 ); + SwPaM aCpyPam( aSourceIdx ); //DocStart + SwNodeIndex aTargetIdx( GetNodes().GetEndOfExtras(), 2 ); + SwPaM aInsertPam( aTargetIdx ); //replaces PCURCRSR from SwFEShell::Paste() + + + aCpyPam.SetMark(); + aCpyPam.Move( fnMoveForward, fnGoDoc ); + + this->StartUndo( UNDO_INSGLOSSARY, NULL ); + this->LockExpFlds(); + + { + SwPosition& rInsPos = *aInsertPam.GetPoint(); + //find out if the clipboard document starts with a table + bool bStartWithTable = 0 != aCpyPam.Start()->nNode.GetNode().FindTableNode(); + SwPosition aInsertPosition( rInsPos ); + + { + SwNodeIndex aIndexBefore(rInsPos.nNode); + + aIndexBefore--; + + rSource.Copy( aCpyPam, rInsPos, true ); + + { + aIndexBefore++; + SwPaM aPaM(SwPosition(aIndexBefore, 0), + SwPosition(rInsPos.nNode, 0)); + + MakeUniqueNumRules(aPaM); + } + } + + //TODO: Is this necessary here? SaveTblBoxCntnt( &rInsPos ); + if(/*bIncludingPageFrames && */bStartWithTable) + { + //remove the paragraph in front of the table + SwPaM aPara(aInsertPosition); + this->DelFullPara(aPara); + } + //additionally copy page bound frames + if( /*bIncludingPageFrames && */rSource.GetSpzFrmFmts()->Count() ) + { + for ( USHORT i = 0; i < rSource.GetSpzFrmFmts()->Count(); ++i ) + { + BOOL bInsWithFmt = TRUE; + const SwFrmFmt& rCpyFmt = *(*rSource.GetSpzFrmFmts())[i]; + if( bInsWithFmt ) + { + SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); + if( FLY_PAGE == aAnchor.GetAnchorId() ) + { + aAnchor.SetPageNum( aAnchor.GetPageNum() + /*nStartPageNumber - */1 ); + } + else + continue; + this->CopyLayoutFmt( rCpyFmt, aAnchor, true, true ); + } + } + } + } + + this->EndUndo( UNDO_INSGLOSSARY, NULL ); + + UnlockExpFlds(); + UpdateFlds(NULL, false); +} diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index cece34f7aa97..4720bcd6fef8 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -2094,6 +2094,10 @@ BOOL SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, BOOL bIsOutlMv ) } else { + //Impossible to move to negative index + if( ULONG(abs( nOffset )) > nStIdx) + return FALSE; + nInEndIdx = nStIdx - 1; nStIdx += nOffset; } @@ -2273,7 +2277,7 @@ BOOL SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, BOOL bIsOutlMv ) } } - Copy( aPam, aInsPos ); + Copy( aPam, aInsPos, false ); if( bDelLastPara ) { // dann muss der letzte leere Node wieder entfernt werden diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index e23f56bab386..a1dc2e7c7e9d 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -2678,7 +2678,8 @@ BOOL SwRedlineTbl::InsertWithValidRanges( SwRedlinePtr& p, USHORT* pInsPos ) { // but our Mark was outside the table => Correction do { - *pNew->GetPoint() = *pTab; // We want to be before the table + // We want to be before the table + *pNew->GetPoint() = SwPosition(*pTab); pC = GoPreviousNds( &pNew->GetPoint()->nNode, FALSE ); // here we are. if( pC ) pNew->GetPoint()->nContent.Assign( pC, 0 ); @@ -3418,7 +3419,7 @@ void SwRedline::CopyToSection() SwNodeIndex aNdIdx( *pSttNd, 1 ); SwTxtNode* pTxtNd = aNdIdx.GetNode().GetTxtNode(); SwPosition aPos( aNdIdx, SwIndex( pTxtNd )); - pDoc->Copy( *this, aPos ); + pDoc->Copy( *this, aPos, false ); // JP 08.10.98: die Vorlage vom EndNode ggfs. mit uebernehmen // - ist im Doc::Copy nicht erwuenscht @@ -3443,13 +3444,13 @@ void SwRedline::CopyToSection() if( pCEndNd ) { SwPosition aPos( *pSttNd->EndOfSectionNode() ); - pDoc->Copy( *this, aPos ); + pDoc->Copy( *this, aPos, false ); } else { SwNodeIndex aInsPos( *pSttNd->EndOfSectionNode() ); SwNodeRange aRg( pStt->nNode, 0, pEnd->nNode, 1 ); - pDoc->CopyWithFlyInFly( aRg, aInsPos ); + pDoc->CopyWithFlyInFly( aRg, 0, aInsPos ); } } pCntntSect = new SwNodeIndex( *pSttNd ); diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index ba65939c5a91..0d9607b290c6 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -195,12 +195,12 @@ void SwDoc::Delete( const SwTOXMark* pTOXMark ) { // fuers Undo die Attribute sichern ClearRedo(); - SwUndoRstAttr* pUndo = new SwUndoRstAttr( *this, SwPosition( rTxtNd, - SwIndex( &rTxtNd, *pTxtTOXMark->GetStart() ) ), - RES_TXTATR_TOXMARK ); + SwUndoResetAttr* pUndo = new SwUndoResetAttr( + SwPosition( rTxtNd, SwIndex( &rTxtNd, *pTxtTOXMark->GetStart() ) ), + RES_TXTATR_TOXMARK ); AppendUndo( pUndo ); - SwRegHistory aRHst( rTxtNd, pUndo->GetHistory() ); + SwRegHistory aRHst( rTxtNd, &pUndo->GetHistory() ); rTxtNd.GetpSwpHints()->Register( &aRHst ); rTxtNd.Delete( const_cast<SwTxtTOXMark*>( pTxtTOXMark ), TRUE ); if( rTxtNd.GetpSwpHints() ) diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 889cb7beb298..5b4831017fdf 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -788,7 +788,7 @@ void SwNoTxtFrm::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) break; default: - if( !pNew || RES_GRFATR_BEGIN > nWhich || nWhich >= RES_GRFATR_END ) + if ( !pNew || !isGRFATR(nWhich) ) return; } @@ -799,6 +799,34 @@ void SwNoTxtFrm::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) } } +void lcl_correctlyAlignRect( SwRect& rAlignedGrfArea, const SwRect& rInArea, OutputDevice* pOut ) +{ + if(!pOut) + return; + Rectangle aPxRect = pOut->LogicToPixel( rInArea.SVRect() );
+ Rectangle aNewPxRect( aPxRect );
+ while( aNewPxRect.Left() < aPxRect.Left() )
+ {
+ rAlignedGrfArea.Left( rAlignedGrfArea.Left()+1 );
+ aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
+ }
+ while( aNewPxRect.Top() < aPxRect.Top() )
+ {
+ rAlignedGrfArea.Top( rAlignedGrfArea.Top()+1 );
+ aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
+ }
+ while( aNewPxRect.Bottom() > aPxRect.Bottom() )
+ {
+ rAlignedGrfArea.Bottom( rAlignedGrfArea.Bottom()-1 );
+ aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
+ }
+ while( aNewPxRect.Right() > aPxRect.Right() )
+ {
+ rAlignedGrfArea.Right( rAlignedGrfArea.Right()-1 );
+ aNewPxRect = pOut->LogicToPixel( rAlignedGrfArea.SVRect() );
+ } +} + // Ausgabe der Grafik. Hier wird entweder eine QuickDraw-Bmp oder // eine Grafik vorausgesetzt. Ist nichts davon vorhanden, wird // eine Ersatzdarstellung ausgegeben. @@ -816,15 +844,30 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons const BOOL bPrn = pOut == rNoTNd.getIDocumentDeviceAccess()->getPrinter( false ) || pOut->GetConnectMetaFile(); + const bool bIsChart = pOLENd && ChartPrettyPainter::IsChart( pOLENd->GetOLEObj().GetObject() ); + /// OD 25.09.2002 #99739# - calculate aligned rectangle from parameter <rGrfArea>. /// Use aligned rectangle <aAlignedGrfArea> instead of <rGrfArea> in /// the following code. SwRect aAlignedGrfArea = rGrfArea; ::SwAlignRect( aAlignedGrfArea, pShell ); - /// OD 25.09.2002 #99739# - /// Because for drawing a graphic left-top-corner and size coordinations are - /// used, these coordinations have to be determined on pixel level. - ::SwAlignGrfRect( &aAlignedGrfArea, *pOut ); + + if( !bIsChart ) + { + /// OD 25.09.2002 #99739# + /// Because for drawing a graphic left-top-corner and size coordinations are + /// used, these coordinations have to be determined on pixel level. + ::SwAlignGrfRect( &aAlignedGrfArea, *pOut ); + } + else //if( bIsChart ) + {
+ //#i78025# charts own borders are not completely visible
+ //the above pixel correction is not correct - at least not for charts
+ //so a different pixel correction is choosen here
+ //this might be a good idea for all other OLE objects also,
+ //but as I cannot oversee the consequences I fix it only for charts for now
+ lcl_correctlyAlignRect( aAlignedGrfArea, rGrfArea, pOut );
+ } if( pGrfNd ) { @@ -946,9 +989,8 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons if( bForceSwap ) pGrfNd->SwapOut(); } - else if( pOLENd + else if( bIsChart //charts must be painted resolution dependent!! #i82893#, #i75867# - && ChartPrettyPainter::IsChart(pOLENd->GetOLEObj().GetObject()) && ChartPrettyPainter::ShouldPrettyPaintChartOnThisDevice( pOut ) && svt::EmbeddedObjectRef::TryRunningState( pOLENd->GetOLEObj().GetOleRef() ) && ChartPrettyPainter::DoPrettyPaintChart( uno::Reference< frame::XModel >( diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx index 62022147e57c..065d0085de64 100644 --- a/sw/source/core/doc/poolfmt.cxx +++ b/sw/source/core/doc/poolfmt.cxx @@ -1566,7 +1566,7 @@ SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage ) { aLR.SetLeft( 0 ); aLR.SetRight( 0 ); aUL.SetUpper( 0 ); aUL.SetLower( 0 ); - Size aPSize( SvxPaperInfo::GetPaperSize( SVX_PAPER_C65 ) ); + Size aPSize( SvxPaperInfo::GetPaperSize( PAPER_ENV_C65 ) ); LandscapeSwap( aPSize ); aSet.Put( SwFmtFrmSize( ATT_FIX_SIZE, aPSize.Width(), aPSize.Height() )); aSet.Put( aLR ); diff --git a/sw/source/core/doc/swserv.cxx b/sw/source/core/doc/swserv.cxx index 5df20bfa2a74..8e0469fe5d87 100644 --- a/sw/source/core/doc/swserv.cxx +++ b/sw/source/core/doc/swserv.cxx @@ -299,9 +299,12 @@ void SwServerObject::SetNoServer() if(eType == BOOKMARK_SERVER && CNTNT_TYPE.pBkmk) { ::sw::mark::DdeBookmark* const pDdeBookmark = dynamic_cast< ::sw::mark::DdeBookmark* >(CNTNT_TYPE.pBkmk); - if(pDdeBookmark) pDdeBookmark->SetRefObject(NULL); + if(pDdeBookmark) + { + CNTNT_TYPE.pBkmk = 0, eType = NONE_SERVER; + pDdeBookmark->SetRefObject(NULL); + } } - CNTNT_TYPE.pBkmk = 0, eType = NONE_SERVER; } void SwServerObject::SetDdeBookmark( ::sw::mark::IMark& rBookmark) diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index 741911c743b0..5eea4c33247c 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -567,7 +567,7 @@ void lcl_CpyBox( const SwTable& rCpyTbl, const SwTableBox* pCpyBox, SwNodeIndex aSavePos( aInsIdx, -1 ); if( pRg.get() ) - pCpyDoc->CopyWithFlyInFly( *pRg, aInsIdx, FALSE ); + pCpyDoc->CopyWithFlyInFly( *pRg, 0, aInsIdx, FALSE ); else pDoc->GetNodes().MakeTxtNode( aInsIdx, (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() ); aSavePos++; diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 7712bd125720..2d6738fd915f 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -2103,7 +2103,7 @@ BOOL lcl_CopyBoxToDoc( const _FndBox*& rpFndBox, void* pPara ) *rpFndBox->GetBox()->GetSttNd()->EndOfSectionNode() ); SwNodeIndex aInsIdx( *pBox->GetSttNd(), 1 ); - pFromDoc->CopyWithFlyInFly( aCpyRg, aInsIdx, FALSE ); + pFromDoc->CopyWithFlyInFly( aCpyRg, 0, aInsIdx, FALSE ); // den initialen TextNode loeschen pCpyPara->pDoc->GetNodes().Delete( aInsIdx, 1 ); } diff --git a/sw/source/core/doc/visiturl.cxx b/sw/source/core/doc/visiturl.cxx index 2a909ac3c32f..d5d0832c0a20 100644 --- a/sw/source/core/doc/visiturl.cxx +++ b/sw/source/core/doc/visiturl.cxx @@ -41,9 +41,7 @@ #include <hints.hxx> #include <ndtxt.hxx> #include <editsh.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif SwURLStateChanged::SwURLStateChanged( const SwDoc* pD ) @@ -92,7 +90,7 @@ void SwURLStateChanged::Notify( SfxBroadcaster& , const SfxHint& rHint ) bUnLockView = !pESh->IsViewLocked(); pESh->LockView( TRUE ); } - ((SwTxtINetFmt*)pTxtAttr)->SetValidVis( FALSE ); + const_cast<SwTxtINetFmt*>(pTxtAttr)->SetVisitedValid( false ); const SwTxtAttr* pAttr = pTxtAttr; SwUpdateAttr aUpdateAttr( *pAttr->GetStart(), *pAttr->GetEnd(), diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 3f8280070d37..2534dc6da659 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -247,6 +247,9 @@ SwCntntNode* SwTxtNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const SwTxtNode* pTxtNd = pDoc->GetNodes().MakeTxtNode( rIdx, pColl ); + // METADATA: register copy + pTxtNd->RegisterAsCopyOf(*pCpyTxtNd); + // kopiere Attribute/Text if( !pCpyAttrNd->HasSwAttrSet() ) // wurde ein AttrSet fuer die Numerierung angelegt, so loesche diesen! @@ -670,7 +673,7 @@ void lcl_DeleteRedlines( const SwNodeRange& rRg, SwNodeRange& rCpyRg ) // Kopieren eines Bereiches im oder in ein anderes Dokument ! -bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos ) const +bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const { const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End(); @@ -709,13 +712,13 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos ) const BOOL bRet = FALSE; if( pDoc != this ) - bRet = _Copy( rPam, rPos, TRUE, pRedlineRange ); // nur normales Kopieren + bRet = _Copy( rPam, rPos, TRUE, bCopyAll, pRedlineRange ); // nur normales Kopieren // 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, pRedlineRange ); // nur normales Kopieren + bRet = _Copy( rPam, rPos, TRUE, bCopyAll, pRedlineRange ); // nur normales Kopieren else { @@ -739,7 +742,7 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos ) const SwStartNode* pSttNd = pDoc->GetNodes().MakeEmptySection( SwNodeIndex( GetNodes().GetEndOfAutotext() )); aPam.GetPoint()->nNode = *pSttNd->EndOfSectionNode(); - pDoc->_Copy( rPam, *aPam.GetPoint(), FALSE ); // kopieren ohne Frames + pDoc->_Copy( rPam, *aPam.GetPoint(), FALSE, bCopyAll, 0 ); // kopieren ohne Frames aPam.GetPoint()->nNode = pDoc->GetNodes().GetEndOfAutotext(); aPam.SetMark(); @@ -814,7 +817,7 @@ BOOL lcl_MarksWholeNode(const SwPaM & rPam) } BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, - BOOL bMakeNewFrms, SwPaM* pCpyRange ) const + BOOL bMakeNewFrms, bool bCopyAll, SwPaM* pCpyRange ) const { SwDoc* pDoc = rPos.nNode.GetNode().GetDoc(); bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection(); @@ -1098,7 +1101,7 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, } } - if( aRg.aStart != aRg.aEnd ) + if( bCopyAll || aRg.aStart != aRg.aEnd ) { SfxItemSet aBrkSet( pDoc->GetAttrPool(), aBreakSetRange ); if( pSttNd && bCopyCollFmt && pDestNd->HasSwAttrSet() ) @@ -1113,13 +1116,13 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, if( aInsPos == pEnd->nNode ) { SwNodeIndex aSaveIdx( aInsPos, -1 ); - CopyWithFlyInFly( aRg, aInsPos, bMakeNewFrms, FALSE ); + CopyWithFlyInFly( aRg, 0,aInsPos, bMakeNewFrms, FALSE ); aSaveIdx++; pEnd->nNode = aSaveIdx; pEnd->nContent.Assign( aSaveIdx.GetNode().GetTxtNode(), 0 ); } else - CopyWithFlyInFly( aRg, aInsPos, bMakeNewFrms, FALSE ); + CopyWithFlyInFly( aRg, pEnd->nContent.GetIndex(), aInsPos, bMakeNewFrms, FALSE ); bCopyBookmarks = FALSE; @@ -1178,7 +1181,7 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, // ----- Copy-Methode vom SwDoc - "kopiere Fly's in Fly's" ------ -void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg, +void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, const SwNodeIndex& rInsPos, BOOL bMakeNewFrms, BOOL bDelRedlines, BOOL bCopyFlyAtFly ) const { @@ -1217,7 +1220,7 @@ void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg, // Undo abschalten BOOL bUndo = pDest->DoesUndo(); pDest->DoUndo( FALSE ); - _CopyFlyInFly( rRg, aSavePos, bCopyFlyAtFly ); + _CopyFlyInFly( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly ); pDest->DoUndo( bUndo ); SwNodeRange aCpyRange( aSavePos, rInsPos ); @@ -1253,7 +1256,7 @@ void lcl_ChainFmts( SwFlyFrmFmt *pSrc, SwFlyFrmFmt *pDest ) } } -void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const SwNodeIndex& rSttIdx, +void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, const SwNodeIndex& rSttIdx, BOOL bCopyFlyAtFly ) const { // Bug 22727: suche erst mal alle Flys zusammen, sortiere sie entsprechend @@ -1270,7 +1273,8 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const SwNodeIndex& rSttIdx, const SwFrmFmt* pFmt = (*GetSpzFrmFmts())[n]; const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); const SwPosition* pAPos; - if ( ( pAnchor->GetAnchorId() == FLY_AT_CNTNT || + bool bAtCntnt = pAnchor->GetAnchorId() == FLY_AT_CNTNT; + if ( ( bAtCntnt || pAnchor->GetAnchorId() == FLY_AT_FLY || pAnchor->GetAnchorId() == FLY_AUTO_CNTNT ) && 0 != ( pAPos = pAnchor->GetCntntAnchor()) && @@ -1279,9 +1283,53 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const SwNodeIndex& rSttIdx, : ( IsRedlineMove() ? rRg.aStart < pAPos->nNode : rRg.aStart <= pAPos->nNode )) && - pAPos->nNode < rRg.aEnd ) + pAPos->nNode <= rRg.aEnd ) { - aArr.Insert( _ZSortFly( pFmt, pAnchor, nArrLen + aArr.Count() )); + //frames at the last source node are not always copied: + //- if the node is empty and is the last node of the document or a table cell + // or a text frame then tey have to be copied + //- if the content index in this node is > 0 then paragph and frame bound objects are copied + //- to-character bound objects are copied if their index is <= nEndContentIndex + bool bAdd = false; + if( pAPos->nNode < rRg.aEnd ) + bAdd = true; + if( !bAdd ) + { + bool bEmptyNode = false; + bool bLastNode = false; + // is the node empty? + const SwNodes& rNodes = pAPos->nNode.GetNodes(); + SwTxtNode* pTxtNode; + if( 0 != ( pTxtNode = pAPos->nNode.GetNode().GetTxtNode() )) + { + bEmptyNode = !pTxtNode->GetTxt().Len(); + if( bEmptyNode ) + { + //last node information is only necessary to know for the last TextNode + SwNodeIndex aTmp( pAPos->nNode ); + ++aTmp;//goto next node + while( rNodes[aTmp ]->IsEndNode() ) + { + if( aTmp == rNodes.GetEndOfContent().GetIndex() ) + { + bLastNode = true; + break; + } + ++aTmp; + } + } + } + bAdd = bLastNode && bEmptyNode; + if( !bAdd ) + { + if( bAtCntnt ) + bAdd = nEndContentIndex > 0; + else + bAdd = pAPos->nContent <= nEndContentIndex; + } + } + if( bAdd ) + aArr.Insert( _ZSortFly( pFmt, pAnchor, nArrLen + aArr.Count() )); } } diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 1e1bcd55022a..a832c33ec958 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -50,9 +50,7 @@ #include <fmtfordr.hxx> #include <fmtpdsc.hxx> #include <fmtanchr.hxx> -#ifndef _FMTLSPLT_HXX #include <fmtlsplt.hxx> -#endif #include <frmatr.hxx> #include <charatr.hxx> #include <cellfrm.hxx> @@ -92,9 +90,7 @@ #ifndef _COMCORE_HRC #include <comcore.hrc> #endif -#ifndef _DOCSH_HXX #include "docsh.hxx" -#endif #ifdef LINUX #include <tabcol.hxx> #endif @@ -1549,8 +1545,8 @@ BOOL lcl_DelBox( const SwTableBox*& rpBox, void* pPara ) 0 != ( pCurTxtNd = aDelRg.aStart.GetNode().GetTxtNode() )) { // Join the current text node with the last from the previous box if possible - aDelRg.aStart--; ULONG nNdIdx = aDelRg.aStart.GetIndex(); + aDelRg.aStart--; if( pDelPara->pLastNd == &aDelRg.aStart.GetNode() ) { // Inserting the seperator @@ -1562,7 +1558,7 @@ BOOL lcl_DelBox( const SwTableBox*& rpBox, void* pPara ) SvULongs aBkmkArr( 4, 4 ); xub_StrLen nOldTxtLen = aCntIdx.GetIndex(); - _SaveCntntIdx( pDoc, nNdIdx + 1, pCurTxtNd->GetTxt().Len(), + _SaveCntntIdx( pDoc, nNdIdx, pCurTxtNd->GetTxt().Len(), aBkmkArr ); pDelPara->pLastNd->JoinNext(); @@ -1575,7 +1571,6 @@ BOOL lcl_DelBox( const SwTableBox*& rpBox, void* pPara ) else if( pDelPara->pUndo ) { aDelRg.aStart++; - nNdIdx = aDelRg.aStart.GetIndex(); pDelPara->pUndo->AddBoxPos( *pDoc, nNdIdx, aDelRg.aEnd.GetIndex() ); } } @@ -2544,7 +2539,7 @@ void SwDoc::GetTabCols( SwTabCols &rFill, const SwCursor* pCrsr, return ; Point aPt; - const SwShellCrsr *pShCrsr = *pCrsr; + const SwShellCrsr *pShCrsr = dynamic_cast<const SwShellCrsr*>(pCrsr); if( pShCrsr ) aPt = pShCrsr->GetPtPos(); @@ -2769,7 +2764,7 @@ void SwDoc::SetTabCols( const SwTabCols &rNew, BOOL bCurRowOnly, return ; Point aPt; - const SwShellCrsr *pShCrsr = *pCrsr; + const SwShellCrsr *pShCrsr = dynamic_cast<const SwShellCrsr*>(pCrsr); if( pShCrsr ) aPt = pShCrsr->GetPtPos(); diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index 1a107dbf3014..d6d04062b74f 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -117,7 +117,7 @@ void lcl_GetStartEndCell( const SwCursor& rCrsr, "Tabselection nicht auf Cnt." ); Point aPtPos, aMkPos; - const SwShellCrsr* pShCrsr = rCrsr; + const SwShellCrsr* pShCrsr = dynamic_cast<const SwShellCrsr*>(&rCrsr); if( pShCrsr ) { aPtPos = pShCrsr->GetPtPos(); @@ -138,7 +138,8 @@ void lcl_GetStartEndCell( const SwCursor& rCrsr, BOOL lcl_GetBoxSel( const SwCursor& rCursor, SwSelBoxes& rBoxes, BOOL bAllCrsr = FALSE ) { - const SwTableCursor* pTblCrsr = rCursor; + const SwTableCursor* pTblCrsr = + dynamic_cast<const SwTableCursor*>(&rCursor); if( pTblCrsr ) ::GetTblSelCrs( *pTblCrsr, rBoxes ); else diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 3ce045994b80..33cd325c669a 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -1414,7 +1414,7 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType, if( pSrcDoc != pDoc || pCpyPam->Start()->nNode > rInsPos || rInsPos >= pCpyPam->End()->nNode ) - pSrcDoc->Copy( *pCpyPam, *pPam->GetPoint() ); + pSrcDoc->Copy( *pCpyPam, *pPam->GetPoint(), false ); delete pCpyPam; } if( pCpyRg && pSrcDoc == pDoc && @@ -1443,7 +1443,7 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType, SwTblNumFmtMerge aTNFM( *pSrcDoc, *pDoc ); - pSrcDoc->CopyWithFlyInFly( *pCpyRg, rInsPos, bCreateFrm ); + pSrcDoc->CopyWithFlyInFly( *pCpyRg, 0, rInsPos, bCreateFrm ); aSave++; if( !bCreateFrm ) diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index e75670aa9525..99a984e8f2db 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -2321,6 +2321,15 @@ namespace sdr drawinglayer::primitive2d::Primitive2DSequence VOCOfDrawVirtObj::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const { +#ifdef DBG_UTIL + // #i101734# + static bool bCheckOtherThanTranslate(false); + static double fShearX(0.0); + static double fRotation(0.0); + static double fScaleX(0.0); + static double fScaleY(0.0); +#endif + const VCOfDrawVirtObj& rVC = static_cast< const VCOfDrawVirtObj& >(GetViewContact()); const SdrObject& rReferencedObject = rVC.GetSwDrawVirtObj().GetReferencedObj(); drawinglayer::primitive2d::Primitive2DSequence xRetval; @@ -2331,8 +2340,20 @@ namespace sdr if(aLocalOffset.X() || aLocalOffset.Y()) { +#ifdef DBG_UTIL + // #i101734# added debug code to check more complex transformations + // than just a translation + if(bCheckOtherThanTranslate) + { + aOffsetMatrix.scale(fScaleX, fScaleY); + aOffsetMatrix.shearX(tan(fShearX * F_PI180)); + aOffsetMatrix.rotate(fRotation * F_PI180); + } +#endif + aOffsetMatrix.set(0, 2, aLocalOffset.X()); aOffsetMatrix.set(1, 2, aLocalOffset.Y()); + } if(rReferencedObject.ISA(SdrObjGroup)) @@ -2576,16 +2597,6 @@ void SwDrawVirtObj::RecalcBoundRect() aOutRect = ReferencedObj().GetCurrentBoundRect() + aOffset; } -////////////////////////////////////////////////////////////////////////////// - -SdrObject* SwDrawVirtObj::CheckHit(const Point& rPnt, USHORT nTol, const SetOfByte* pVisiLayer) const -{ - Point aPnt(rPnt - GetOffset()); - BOOL bRet = rRefObj.CheckHit(aPnt, nTol, pVisiLayer) != NULL; - - return bRet ? (SdrObject*)this : NULL; -} - basegfx::B2DPolyPolygon SwDrawVirtObj::TakeXorPoly() const { basegfx::B2DPolyPolygon aRetval(rRefObj.TakeXorPoly()); diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx index 768cae90ce0a..15ca46ca2456 100644 --- a/sw/source/core/draw/dflyobj.cxx +++ b/sw/source/core/draw/dflyobj.cxx @@ -72,6 +72,9 @@ using namespace ::com::sun::star; #include <svx/sdr/contact/viewcontactofvirtobj.hxx> #include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> +#include <sw_primitivetypes2d.hxx> +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#include <drawinglayer/primitive2d/hittestprimitive2d.hxx> using namespace ::com::sun::star; @@ -189,10 +192,6 @@ UINT16 __EXPORT SwFlyDrawObj::GetObjVersion() const ////////////////////////////////////////////////////////////////////////////////////// // AW: Need own primitive to get the FlyFrame paint working -// Unique PrimitiveID. If more will be needed, create an own file in SW following -// the example in SD -#define PRIMITIVE2D_ID_SWVIRTFLYDRAWOBJPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_SW| 0) - namespace drawinglayer { namespace primitive2d @@ -201,15 +200,19 @@ namespace drawinglayer { private: const SwVirtFlyDrawObj& mrSwVirtFlyDrawObj; + const basegfx::B2DRange maOuterRange; protected: // method which is to be used to implement the local decomposition of a 2D primitive virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: - SwVirtFlyDrawObjPrimitive(const SwVirtFlyDrawObj& rSwVirtFlyDrawObj) + SwVirtFlyDrawObjPrimitive( + const SwVirtFlyDrawObj& rSwVirtFlyDrawObj, + const basegfx::B2DRange &rOuterRange) : BasePrimitive2D(), - mrSwVirtFlyDrawObj(rSwVirtFlyDrawObj) + mrSwVirtFlyDrawObj(rSwVirtFlyDrawObj), + maOuterRange(rOuterRange) { } @@ -219,6 +222,13 @@ namespace drawinglayer // get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; + // overloaded to allow callbacks to wrap_DoPaintObject + virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + // data read access + const SwVirtFlyDrawObj& getSwVirtFlyDrawObj() const { return mrSwVirtFlyDrawObj; } + const basegfx::B2DRange& getOuterRange() const { return maOuterRange; } + // provide unique ID DeclPrimitrive2DIDBlock() }; @@ -229,13 +239,42 @@ namespace drawinglayer { namespace primitive2d { + Primitive2DSequence SwVirtFlyDrawObjPrimitive::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + Primitive2DSequence aRetval; + + if(!getOuterRange().isEmpty()) + { + // currently this SW object has no primitive representation. As long as this is the case, + // create an invisible HitTestPrimitive to allow hitting the object. Use a filled primitive + // to get a HitTest which uses 'inside' as default object hit. The special cases from + // the old SwVirtFlyDrawObj::CheckHit implementation are handled now in SwDrawView::PickObj; + // this removed the 'hack' to get a view from inside model data or to react on noll-tolerance + // as it was done in the old implementation + const basegfx::B2DPolygon aOuterRangePolygon(basegfx::tools::createPolygonFromRect(getOuterRange())); + const basegfx::BColor aColor(0.0, 0.0, 0.0); + const Primitive2DReference aContentReference( + new PolyPolygonColorPrimitive2D( + basegfx::B2DPolyPolygon(aOuterRangePolygon), + aColor)); + const Primitive2DReference aHitTestReference( + new HitTestPrimitive2D( + Primitive2DSequence(&aContentReference, 1))); + + aRetval = Primitive2DSequence(&aHitTestReference, 1); + } + + return aRetval; + } + bool SwVirtFlyDrawObjPrimitive::operator==(const BasePrimitive2D& rPrimitive) const { if(BasePrimitive2D::operator==(rPrimitive)) { const SwVirtFlyDrawObjPrimitive& rCompare = (SwVirtFlyDrawObjPrimitive&)rPrimitive; - return (&mrSwVirtFlyDrawObj == &rCompare.mrSwVirtFlyDrawObj); + return (&getSwVirtFlyDrawObj() == &rCompare.getSwVirtFlyDrawObj() + && getOuterRange() == rCompare.getOuterRange()); } return false; @@ -243,23 +282,20 @@ namespace drawinglayer basegfx::B2DRange SwVirtFlyDrawObjPrimitive::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const { - // fallback on FlyFrame SnapRect - const Rectangle& rSnapRect = mrSwVirtFlyDrawObj.GetSnapRect(); - - return basegfx::B2DRange(rSnapRect.Left(), rSnapRect.Top(), rSnapRect.Right(), rSnapRect.Bottom()); + return getOuterRange(); } - Primitive2DSequence SwVirtFlyDrawObjPrimitive::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence SwVirtFlyDrawObjPrimitive::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { // This is the callback to keep the FlyFrame painting in SW alive as long as it // is not changed to primitives. This is the method which will be called by the processors // when they do not know this primitive (and they do not). Inside wrap_DoPaintObject // there needs to be a test that paint is only done during SW repaints (see there). // Using this mechanism guarantees the correct Z-Order of the VirtualObject-based FlyFrames. - mrSwVirtFlyDrawObj.wrap_DoPaintObject(); + getSwVirtFlyDrawObj().wrap_DoPaintObject(); // call parent - return BasePrimitive2D::createLocalDecomposition(rViewInformation); + return BasePrimitive2D::get2DDecomposition(rViewInformation); } // provide unique ID @@ -313,10 +349,19 @@ namespace sdr if(rReferencedObject.ISA(SwFlyDrawObj)) { - // create an own specialized primitive which is used as repaint callpoint (see primitive - // implementation above) - const drawinglayer::primitive2d::Primitive2DReference xPrimitive(new drawinglayer::primitive2d::SwVirtFlyDrawObjPrimitive(GetSwVirtFlyDrawObj())); - xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xPrimitive, 1); + // create an own specialized primitive which is used as repaint callpoint and HitTest + // for HitTest processor (see primitive implementation above) + const basegfx::B2DRange aOuterRange(GetSwVirtFlyDrawObj().getOuterBound()); + + if(!aOuterRange.isEmpty()) + { + const drawinglayer::primitive2d::Primitive2DReference xPrimitive( + new drawinglayer::primitive2d::SwVirtFlyDrawObjPrimitive( + GetSwVirtFlyDrawObj(), + aOuterRange)); + + xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xPrimitive, 1); + } } return xRetval; @@ -330,6 +375,58 @@ namespace sdr ////////////////////////////////////////////////////////////////////////////////////// +basegfx::B2DRange SwVirtFlyDrawObj::getOuterBound() const +{ + basegfx::B2DRange aOuterRange; + const SdrObject& rReferencedObject = GetReferencedObj(); + + if(rReferencedObject.ISA(SwFlyDrawObj)) + { + const SwFlyFrm* pFlyFrame = GetFlyFrm(); + + if(pFlyFrame) + { + const Rectangle aOuterRectangle(pFlyFrame->Frm().Pos(), pFlyFrame->Frm().SSize()); + + if(!aOuterRectangle.IsEmpty() + && RECT_EMPTY != aOuterRectangle.Right() + && RECT_EMPTY != aOuterRectangle.Bottom()) + { + aOuterRange.expand(basegfx::B2DTuple(aOuterRectangle.Left(), aOuterRectangle.Top())); + aOuterRange.expand(basegfx::B2DTuple(aOuterRectangle.Right(), aOuterRectangle.Bottom())); + } + } + } + + return aOuterRange; +} + +basegfx::B2DRange SwVirtFlyDrawObj::getInnerBound() const +{ + basegfx::B2DRange aInnerRange; + const SdrObject& rReferencedObject = GetReferencedObj(); + + if(rReferencedObject.ISA(SwFlyDrawObj)) + { + const SwFlyFrm* pFlyFrame = GetFlyFrm(); + + if(pFlyFrame) + { + const Rectangle aInnerRectangle(pFlyFrame->Frm().Pos() + pFlyFrame->Prt().Pos(), pFlyFrame->Prt().SSize()); + + if(!aInnerRectangle.IsEmpty() + && RECT_EMPTY != aInnerRectangle.Right() + && RECT_EMPTY != aInnerRectangle.Bottom()) + { + aInnerRange.expand(basegfx::B2DTuple(aInnerRectangle.Left(), aInnerRectangle.Top())); + aInnerRange.expand(basegfx::B2DTuple(aInnerRectangle.Right(), aInnerRectangle.Bottom())); + } + } + } + + return aInnerRange; +} + sdr::contact::ViewContact* SwVirtFlyDrawObj::CreateObjectSpecificViewContact() { // need an own ViewContact (VC) to allow creation of a specialized primitive @@ -425,74 +522,6 @@ void SwVirtFlyDrawObj::wrap_DoPaintObject() const /************************************************************************* |* -|* SwVirtFlyDrawObj::CheckHit() -|* Beschreibung Das Teil ist genau dann getroffen wenn -|* 1. der Point im Rand des Frm liegt. -|* 2. der Point im heissen Bereich liegt. -|* 3. der Point in der Flaeche liegt und es sich um -|* einen Rahmen mit NoTxtFrm handelt und dieser -|* keine URL traegt. -|* 3a nicht aber wenn ueber dem Fly noch ein Fly liegt, -|* und der Point in dessen Flaeche nicht steht. -|* 4. der Point in der Flaeche liegt und der Rahmen -|* selektiert ist. -|* Ersterstellung MA 08. Dec. 94 -|* Letzte Aenderung JP 25.03.96 -|* -*************************************************************************/ - -SdrObject* __EXPORT SwVirtFlyDrawObj::CheckHit( const Point& rPnt, USHORT nTol, - const SetOfByte* ) const -{ - Rectangle aHitRect( pFlyFrm->Frm().Pos(), pFlyFrm->Frm().SSize() ); - if ( nTol ) - { - Rectangle aExclude( aHitRect ); - aHitRect.Top() -= nTol; - aHitRect.Bottom() += nTol; - aHitRect.Left() -= nTol; - aHitRect.Right() += nTol; - if( aHitRect.IsInside( rPnt ) ) - { - if ( pFlyFrm->Lower() && pFlyFrm->Lower()->IsNoTxtFrm() ) - { - // #107513# - // This test needs to be done outside, since also drawing layer HitTest - // methods are called. Not all drawing objects are derived and the - // CheckHit() overloaded. That's an conceptual error here. - return (SdrObject*)this; - } - else - { - ViewShell *pShell = pFlyFrm->GetShell(); - - //4. Getroffen wenn das Objekt selektiert ist. - if ( pShell ) - { - const SdrMarkList &rMrkList = pShell-> - Imp()->GetDrawView()->GetMarkedObjectList(); - for ( USHORT i = 0; i < rMrkList.GetMarkCount(); ++i ) - if ( long(this) == long(rMrkList.GetMark(i)->GetMarkedSdrObj()) ) - return (SdrObject*)this; - } - - const Rectangle aPrtRect( pFlyFrm->Frm().Pos() + pFlyFrm->Prt().Pos(), - pFlyFrm->Prt().SSize() ); - aExclude.Top() += Max( long(nTol), aPrtRect.Top() - aHitRect.Top() ); - aExclude.Bottom() -= Max( long(nTol), aHitRect.Bottom()- aPrtRect.Bottom()); - aExclude.Left() += Max( long(nTol), aPrtRect.Left() - aHitRect.Left() ); - aExclude.Right() -= Max( long(nTol), aHitRect.Right() - aPrtRect.Right() ); - return aExclude.IsInside( rPnt ) ? 0 : (SdrObject*)this; - } - } - } - else - return aHitRect.IsInside( rPnt ) ? (SdrObject*)this : 0; - return 0; -} - -/************************************************************************* -|* |* SwVirtFlyDrawObj::TakeObjInfo() |* |* Ersterstellung MA 03. May. 95 diff --git a/sw/source/core/draw/dpage.cxx b/sw/source/core/draw/dpage.cxx index de6e43799d88..a5d8ccd24e61 100644 --- a/sw/source/core/draw/dpage.cxx +++ b/sw/source/core/draw/dpage.cxx @@ -203,8 +203,8 @@ BOOL SwDPage::RequestHelp( Window* pWindow, SdrView* pView, aPt -= pFly->Frm().Pos(); // ohne MapMode-Offset !!!!! // ohne MapMode-Offset, ohne Offset, o ... !!!!! - aPt = (Point&)(const Size&)pWindow->LogicToPixel( - (const Size&)aPt, MapMode( MAP_TWIP ) ); + aPt = pWindow->LogicToPixel( + aPt, MapMode( MAP_TWIP ) ); ((( sTxt += '?' ) += String::CreateFromInt32( aPt.X() )) += ',' ) += String::CreateFromInt32( aPt.Y() ); } diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx index 51ef762c63df..9843f8f8c34e 100644 --- a/sw/source/core/draw/dview.cxx +++ b/sw/source/core/draw/dview.cxx @@ -153,6 +153,81 @@ sal_Bool SwDrawView::IsAntiAliasing() const } // <-- +////////////////////////////////////////////////////////////////////////////// + +SdrObject* impLocalHitCorrection(SdrObject* pRetval, const Point& rPnt, USHORT nTol, const SdrMarkList &rMrkList) +{ + if(!nTol) + { + // the old method forced back to outer bounds test when nTol == 0, so + // do not try to correct when nTol is not set (used from HelpContent) + } + else + { + // rebuild logic from former SwVirtFlyDrawObj::CheckSdrObjectHit. This is needed since + // the SdrObject-specific CheckHit implementations are now replaced with primitives and + // 'tricks' like in the old implementation (e.g. using a view from a model-data class to + // detect if object is selected) are no longer valid. + // The standard primitive hit-test for SwVirtFlyDrawObj now is the outer bound. The old + // implementation reduced this excluding the inner bound when the object was not selected. + SwVirtFlyDrawObj* pSwVirtFlyDrawObj = dynamic_cast< SwVirtFlyDrawObj* >(pRetval); + + if(pSwVirtFlyDrawObj) + { + if(pSwVirtFlyDrawObj->GetFlyFrm()->Lower() && pSwVirtFlyDrawObj->GetFlyFrm()->Lower()->IsNoTxtFrm()) + { + // the old method used IsNoTxtFrm (should be for SW's own OLE and + // graphic's) to accept hit only based on outer bounds; nothing to do + } + else + { + // check if the object is selected in this view + const sal_uInt32 nMarkCount(rMrkList.GetMarkCount()); + bool bSelected(false); + + for(sal_uInt32 a(0); !bSelected && a < nMarkCount; a++) + { + if(pSwVirtFlyDrawObj == rMrkList.GetMark(a)->GetMarkedSdrObj()) + { + bSelected = true; + } + } + + if(!bSelected) + { + // when not selected, the object is not hit when hit position is inside + // inner range. Get and shrink inner range + basegfx::B2DRange aInnerBound(pSwVirtFlyDrawObj->getInnerBound()); + + aInnerBound.grow(-1.0 * nTol); + + if(aInnerBound.isInside(basegfx::B2DPoint(rPnt.X(), rPnt.Y()))) + { + // exclude this hit + pRetval = 0; + } + } + } + } + } + + return pRetval; +} + +SdrObject* SwDrawView::CheckSingleSdrObjectHit(const Point& rPnt, USHORT nTol, SdrObject* pObj, SdrPageView* pPV, ULONG nOptions, const SetOfByte* pMVisLay) const +{ + // call parent + SdrObject* pRetval = FmFormView::CheckSingleSdrObjectHit(rPnt, nTol, pObj, pPV, nOptions, pMVisLay); + + if(pRetval) + { + // overloaded to allow extra handling when picking SwVirtFlyDrawObj's + pRetval = impLocalHitCorrection(pRetval, rPnt, nTol, GetMarkedObjectList()); + } + + return pRetval; +} + /************************************************************************* |* |* SwDrawView::AddCustomHdl() diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx index dfe258def74d..3867d0a4a891 100644 --- a/sw/source/core/edit/acorrect.cxx +++ b/sw/source/core/edit/acorrect.cxx @@ -374,7 +374,7 @@ BOOL SwAutoCorrDoc::ChgAutoCorrWord( xub_StrLen & rSttPos, xub_StrLen nEndPos, SwDontExpandItem aExpItem; aExpItem.SaveDontExpandItems( *aPam.GetPoint() ); - pAutoDoc->Copy( aCpyPam, *aPam.GetPoint() ); + pAutoDoc->Copy( aCpyPam, *aPam.GetPoint(), false ); aExpItem.RestoreDontExpandItems( *aPam.GetPoint() ); @@ -491,7 +491,7 @@ void SwDontExpandItem::RestoreDontExpandItems( const SwPosition& rPos ) for( n = 0; n < nSize; ++n ) { - SwTxtAttr* pHt = pTxtNd->GetpSwpHints()->GetHt( n ); + SwTxtAttr* pHt = pTxtNd->GetpSwpHints()->GetTextHint( n ); nAttrStart = *pHt->GetStart(); if( nAttrStart > nStart ) // ueber den Bereich hinaus break; diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index b3dc625db9c2..2bf30449f33b 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -172,11 +172,6 @@ BOOL SwEditShell::GetCurAttr( SfxItemSet& rSet, if( aSet.Count() ) aSet.ClearItem(); - -#ifdef JP_NEWCORE - // vieleicht sollte man hier noch erfragen, ob schon alle Attribute - // "DontCare" sind. Dann kann man abbrechen! -#endif } pSet = &aSet; } @@ -251,9 +246,9 @@ BOOL SwEditShell::GetCurFtn( SwFmtFtn* pFillFtn ) } -BOOL SwEditShell::SetCurFtn( const SwFmtFtn& rFillFtn ) +bool SwEditShell::SetCurFtn( const SwFmtFtn& rFillFtn ) { - BOOL bChgd = FALSE; + bool bChgd = false; StartAllAction(); SwPaM* pCrsr = GetCrsr(), *pFirst = pCrsr; @@ -284,7 +279,7 @@ BOOL SwEditShell::SetCurFtn( const SwFmtFtn& rFillFtn ) } */ -BOOL SwEditShell::HasFtns( BOOL bEndNotes ) const +bool SwEditShell::HasFtns( bool bEndNotes ) const { const SwFtnIdxs &rIdxs = pDoc->GetFtnIdxs(); for ( USHORT i = 0; i < rIdxs.Count(); ++i ) @@ -298,7 +293,7 @@ BOOL SwEditShell::HasFtns( BOOL bEndNotes ) const // gebe Liste aller Fussnoten und deren Anfangstexte -USHORT SwEditShell::GetSeqFtnList( SwSeqFldList& rList, BOOL bEndNotes ) +USHORT SwEditShell::GetSeqFtnList( SwSeqFldList& rList, bool bEndNotes ) { if( rList.Count() ) rList.Remove( 0, rList.Count() ); diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx index 7d8eeccb3159..384aa414895a 100644 --- a/sw/source/core/edit/eddel.cxx +++ b/sw/source/core/edit/eddel.cxx @@ -42,12 +42,8 @@ #include <IMark.hxx> #include <docary.hxx> #include <SwRewriter.hxx> -#ifndef _UNOBJ_HXX #include <undobj.hxx> -#endif -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif #include <comcore.hrc> #include <list> @@ -253,10 +249,10 @@ long SwEditShell::Copy( SwEditShell* pDestShell ) bFirstMove = FALSE; } - if( !GetDoc()->Copy( *PCURCRSR, *pPos )) + if( !GetDoc()->Copy( *PCURCRSR, *pPos, false )) continue; - SwPaM aInsertPaM(*pPos, aSttNdIdx); + SwPaM aInsertPaM(*pPos, SwPosition(aSttNdIdx)); pDestShell->GetDoc()->MakeUniqueNumRules(aInsertPaM); bRet = TRUE; @@ -321,24 +317,6 @@ BOOL SwEditShell::Replace( const String& rNewStr, BOOL bRegExpRplc ) GetDoc()->StartUndo(UNDO_EMPTY, NULL); FOREACHPAM_START(this) - -//JP 02.12.97: muss das noch sein?? - // sollten mehrere Node selektiert sein, dann loesche diese - // erst, fuege ein Zeichen ein und ersetze dann dieses - if( PCURCRSR->GetPoint()->nNode != PCURCRSR->GetMark()->nNode ) - { - BOOL bForward = PCURCRSR->GetPoint()->nNode.GetIndex() > - PCURCRSR->GetMark()->nNode.GetIndex(); - DeleteSel( *PCURCRSR ); - pDoc->Insert( *PCURCRSR, ' ' ); - PCURCRSR->SetMark(); - if( bForward ) - PCURCRSR->GetMark()->nContent--; - else - PCURCRSR->GetPoint()->nContent--; - } -//JP 02.12.97: muss das noch sein?? - if( PCURCRSR->HasMark() && *PCURCRSR->GetMark() != *PCURCRSR->GetPoint() ) { bRet = GetDoc()->Replace( *PCURCRSR, rNewStr, bRegExpRplc ) || bRet; diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index f1d781e4080b..b408a1c33c81 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 ); + pMyDoc->Copy( aCpyPam, aInsPos, false ); nRet = rBlock.PutDoc(); } @@ -250,13 +250,13 @@ BOOL SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd ) { PCURCRSR->SetMark(); PCURCRSR->Move( fnMoveForward, fnGoCntnt ); - bRet = GetDoc()->Copy( *PCURCRSR, aPos ) || bRet; + bRet = GetDoc()->Copy( *PCURCRSR, aPos, false ) || bRet; PCURCRSR->Exchange(); PCURCRSR->DeleteMark(); } } else - bRet = GetDoc()->Copy( *PCURCRSR, aPos ) || bRet; + bRet = GetDoc()->Copy( *PCURCRSR, aPos, false ) || bRet; FOREACHPAM_END() } diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 0a866b3855fb..0035a8880ba9 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -68,9 +68,12 @@ #include <unochart.hxx> #include <numrule.hxx> #include <SwNodeNum.hxx> +#include <unocrsr.hxx> + using namespace com::sun::star; + SV_IMPL_PTRARR(SwGetINetAttrs, SwGetINetAttr*) /****************************************************************************** @@ -123,7 +126,7 @@ void SwEditShell::Insert(const String &rStr) // calculate cursor bidi level SwCursor* pTmpCrsr = _GetCrsr(); const BOOL bDoNotSetBidiLevel = ! pTmpCrsr || - ( 0 != (SwUnoCrsr*)*pTmpCrsr ); + ( 0 != dynamic_cast<SwUnoCrsr*>(pTmpCrsr) ); if ( ! bDoNotSetBidiLevel ) { diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx index 150bb8fc2a9c..5b6bda70ed4e 100644 --- a/sw/source/core/fields/authfld.cxx +++ b/sw/source/core/fields/authfld.cxx @@ -288,8 +288,9 @@ const SwAuthEntry* SwAuthorityFieldType::GetEntryByIdentifier( /* -----------------------------21.12.99 13:20-------------------------------- ---------------------------------------------------------------------------*/ -void SwAuthorityFieldType::ChangeEntryContent(const SwAuthEntry* pNewEntry) +bool SwAuthorityFieldType::ChangeEntryContent(const SwAuthEntry* pNewEntry) { + bool bChanged = false; for( USHORT j = 0; j < m_pDataArr->Count(); ++j ) { SwAuthEntry* pTemp = m_pDataArr->GetObject(j); @@ -299,9 +300,11 @@ void SwAuthorityFieldType::ChangeEntryContent(const SwAuthEntry* pNewEntry) for(USHORT i = 0; i < AUTH_FIELD_END; i++) pTemp->SetAuthorField((ToxAuthorityField) i, pNewEntry->GetAuthorField((ToxAuthorityField)i)); + bChanged = true; break; } } + return bChanged; } /*-- 11.10.99 08:49:22--------------------------------------------------- Description: appends a new entry (if new) and returns the array position diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx index 50962cb36bb4..029759a6c056 100644 --- a/sw/source/core/fields/cellfml.cxx +++ b/sw/source/core/fields/cellfml.cxx @@ -371,6 +371,7 @@ void SwTableFormula::_MakeFormel( const SwTable& rTbl, String& rNewStr, rNewStr += ')'; } else if( pSttBox && !pLastBox ) // nur die StartBox ? + { //JP 12.01.99: und keine EndBox in der Formel! // Berechne den Wert der Box if ( pSttBox->getRowSpan() >= 1 ) @@ -378,6 +379,7 @@ void SwTableFormula::_MakeFormel( const SwTable& rTbl, String& rNewStr, rNewStr += pCalcPara->rCalc.GetStrResult( pSttBox->GetValue( *pCalcPara ), FALSE ); } + } else pCalcPara->rCalc.SetCalcError( CALC_SYNTAX ); // Fehler setzen rNewStr += ' '; diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index 186174d28c9a..07c8a0911080 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -840,7 +840,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) { SwNodeIndex aIndexBefore(rInsPos.nNode); aIndexBefore--; - pClpDoc->Copy( rCopy, rInsPos ); + pClpDoc->Copy( rCopy, rInsPos, false ); { aIndexBefore++; SwPaM aPaM(SwPosition(aIndexBefore, 0), @@ -1069,7 +1069,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) aIndexBefore--; - pClpDoc->Copy( aCpyPam, rInsPos ); + pClpDoc->Copy( aCpyPam, rInsPos, false ); { aIndexBefore++; diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index 3b82b28c6090..b6cc1bf56fad 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -804,7 +804,9 @@ void SwFEShell::Insert( const String& rGrfName, const String& rFltName, SwFlyFrmFmt* pFmt = 0; SET_CURR_SHELL( this ); StartAllAction(); - FOREACHCURSOR_START( this ) + SwShellCrsr *pStartCursor = dynamic_cast<SwShellCrsr*>(this->GetSwCrsr()); + SwShellCrsr *pCursor = pStartCursor; + do { // Anker noch nicht oder unvollstaendig gesetzt ? if( pFlyAttrSet ) @@ -820,18 +822,22 @@ void SwFEShell::Insert( const String& rGrfName, const String& rFltName, case FLY_AUTO_CNTNT: // LAYER_IMPL case FLY_IN_CNTNT: if( !pAnchor->GetCntntAnchor() ) - pAnchor->SetAnchor( PCURCRSR->GetPoint() ); + { + pAnchor->SetAnchor( pCursor->GetPoint() ); + } break; case FLY_AT_FLY: if( !pAnchor->GetCntntAnchor() ) - lcl_SetNewFlyPos( *PCURCRSR->GetNode(), - *pAnchor, GetCrsrDocPos() ); + { + lcl_SetNewFlyPos( *pCursor->GetNode(), + *pAnchor, GetCrsrDocPos() ); + } break; case FLY_PAGE: if( !pAnchor->GetPageNum() ) { - pAnchor->SetPageNum( PCURCRSR->GetPageNum( - sal_True, &PCURCRSR->GetPtPos() ) ); + pAnchor->SetPageNum( pCursor->GetPageNum( + sal_True, &pCursor->GetPtPos() ) ); } break; default : @@ -839,13 +845,15 @@ void SwFEShell::Insert( const String& rGrfName, const String& rFltName, } } } - pFmt = GetDoc()->Insert(*PCURCRSR, rGrfName, + pFmt = GetDoc()->Insert(*pCursor, rGrfName, rFltName, pGraphic, pFlyAttrSet, pGrfAttrSet, pFrmFmt ); ASSERT( pFmt, "Doc->Insert(notxt) failed." ); - FOREACHCURSOR_END() + } while( (pCursor = dynamic_cast<SwShellCrsr*>(pCursor->GetNext())) + != pStartCursor ); + EndAllAction(); if( pFmt ) @@ -1603,7 +1611,7 @@ const SwFrmFmt* SwFEShell::IsURLGrfAtPos( const Point& rPt, String* pURL, sal_uInt16 nOld = pDView->GetHitTolerancePixel(); pDView->SetHitTolerancePixel( 2 ); - if( pDView->PickObj( rPt, pObj, pPV,SDRSEARCH_PICKMACRO ) && + if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPV,SDRSEARCH_PICKMACRO ) && pObj->ISA(SwVirtFlyDrawObj) ) { SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm(); @@ -1643,8 +1651,8 @@ const SwFrmFmt* SwFEShell::IsURLGrfAtPos( const Point& rPt, String* pURL, Point aPt( rPt ); aPt -= pFly->Frm().Pos(); // ohne MapMode-Offset, ohne Offset, o ... !!!!! - aPt = (Point&)(const Size&)GetOut()->LogicToPixel( - (const Size&)aPt, MapMode( MAP_TWIP ) ); + aPt = GetOut()->LogicToPixel( + aPt, MapMode( MAP_TWIP ) ); ((( *pURL += '?' ) += String::CreateFromInt32( aPt.X() )) += ',' ) += String::CreateFromInt32(aPt.Y() ); } @@ -1671,7 +1679,7 @@ const Graphic *SwFEShell::GetGrfAtPos( const Point &rPt, SdrPageView* pPV; SwDrawView *pDView = (SwDrawView*)Imp()->GetDrawView(); - if( pDView->PickObj( rPt, pObj, pPV ) && pObj->ISA(SwVirtFlyDrawObj) ) + if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPV ) && pObj->ISA(SwVirtFlyDrawObj) ) { SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm(); if ( pFly->Lower() && pFly->Lower()->IsNoTxtFrm() ) @@ -1715,7 +1723,7 @@ const SwFrmFmt* SwFEShell::GetFmtFromObj( const Point& rPt, SwRect** pRectToFill // Tattergrenze fuer Drawing-SS pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 ); - if( pDView->PickObj( rPt, pObj, pPView, SDRSEARCH_PICKMARKABLE ) ) + if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPView, SDRSEARCH_PICKMARKABLE ) ) { // dann teste mal was es ist: if ( pObj->ISA(SwVirtFlyDrawObj) ) @@ -1847,7 +1855,7 @@ ObjCntType SwFEShell::GetObjCntType( const Point &rPt, SdrObject *&rpObj ) const // Tattergrenze fuer Drawing-SS pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 ); - if( pDView->PickObj( rPt, pObj, pPView, SDRSEARCH_PICKMARKABLE ) ) + if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPView, SDRSEARCH_PICKMARKABLE ) ) eType = GetObjCntType( *(rpObj = pObj) ); pDView->SetHitTolerancePixel( nOld ); diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index f6539c26d16c..6d7059b3cf0e 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -1178,7 +1178,7 @@ bool SwFEShell::IsObjSelectable( const Point& rPt ) USHORT nOld = pDView->GetHitTolerancePixel(); pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 ); - bRet = 0 != pDView->PickObj( rPt, pObj, pPV, SDRSEARCH_PICKMARKABLE ); + bRet = 0 != pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMARKABLE ); pDView->SetHitTolerancePixel( nOld ); } return bRet; @@ -1202,7 +1202,7 @@ sal_Bool SwFEShell::ShouldObjectBeSelected(const Point& rPt) sal_uInt16 nOld(pDrawView->GetHitTolerancePixel()); pDrawView->SetHitTolerancePixel(pDrawView->GetMarkHdlSizePixel()/2); - bRet = pDrawView->PickObj(rPt, pObj, pPV, SDRSEARCH_PICKMARKABLE); + bRet = pDrawView->PickObj(rPt, pDrawView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMARKABLE); pDrawView->SetHitTolerancePixel(nOld); if(bRet && pObj) @@ -2724,7 +2724,7 @@ int SwFEShell::Chainable( SwRect &rRect, const SwFrmFmt &rSource, SwDrawView *pDView = (SwDrawView*)Imp()->GetDrawView(); const USHORT nOld = pDView->GetHitTolerancePixel(); pDView->SetHitTolerancePixel( 0 ); - if( pDView->PickObj( rPt, pObj, pPView, SDRSEARCH_PICKMARKABLE ) && + if( pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPView, SDRSEARCH_PICKMARKABLE ) && pObj->ISA(SwVirtFlyDrawObj) ) { SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm(); @@ -2759,7 +2759,7 @@ int SwFEShell::Chain( SwFrmFmt &rSource, const Point &rPt ) SwDrawView *pDView = (SwDrawView*)Imp()->GetDrawView(); const USHORT nOld = pDView->GetHitTolerancePixel(); pDView->SetHitTolerancePixel( 0 ); - pDView->PickObj( rPt, pObj, pPView, SDRSEARCH_PICKMARKABLE ); + pDView->PickObj( rPt, pDView->getHitTolLog(), pObj, pPView, SDRSEARCH_PICKMARKABLE ); pDView->SetHitTolerancePixel( nOld ); SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm(); diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 5375078a48e3..ec3ac828d528 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -34,12 +34,8 @@ #include <hintids.hxx> -#ifndef __RSC //autogen #include <tools/errinf.hxx> -#endif -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif #include <basegfx/vector/b2dvector.hxx> #ifndef _SVX_SVXIDS_HRC #include <svx/svxids.hrc> @@ -120,13 +116,6 @@ TblWait::TblWait( USHORT nCnt, SwFrm *pFrm, SwDocShell &rDocShell, USHORT nCnt2) pWait = new SwWait( rDocShell, TRUE ); } -inline const SwCursor& GetShellCursor( const SwCrsrShell& rShell ) -{ - const SwShellCrsr *pCrsr = rShell.GetTableCrsr(); - if( !pCrsr ) - pCrsr = (SwShellCrsr*)*rShell.GetSwCrsr( FALSE ); - return *pCrsr; -} void SwFEShell::ParkCursorInTab() { @@ -803,13 +792,13 @@ void SwFEShell::SetRowSplit( const SwFmtRowSplit& rNew ) { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetRowSplit( GetShellCursor( *this ), rNew ); + GetDoc()->SetRowSplit( *getShellCrsr( false ), rNew ); EndAllActionAndCall(); } void SwFEShell::GetRowSplit( SwFmtRowSplit*& rpSz ) const { - GetDoc()->GetRowSplit( GetShellCursor( *this ), rpSz ); + GetDoc()->GetRowSplit( *getShellCrsr( false ), rpSz ); } @@ -824,7 +813,7 @@ void SwFEShell::SetRowHeight( const SwFmtFrmSize &rNew ) { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetRowHeight( GetShellCursor( *this ), rNew ); + GetDoc()->SetRowHeight( *getShellCrsr( false ), rNew ); EndAllActionAndCall(); } @@ -833,7 +822,7 @@ void SwFEShell::SetRowHeight( const SwFmtFrmSize &rNew ) ******************************************************************************/ void SwFEShell::GetRowHeight( SwFmtFrmSize *& rpSz ) const { - GetDoc()->GetRowHeight( GetShellCursor( *this ), rpSz ); + GetDoc()->GetRowHeight( *getShellCrsr( false ), rpSz ); } BOOL SwFEShell::BalanceRowHeight( BOOL bTstOnly ) @@ -841,7 +830,7 @@ BOOL SwFEShell::BalanceRowHeight( BOOL bTstOnly ) SET_CURR_SHELL( this ); if( !bTstOnly ) StartAllAction(); - BOOL bRet = GetDoc()->BalanceRowHeight( GetShellCursor( *this ), bTstOnly ); + BOOL bRet = GetDoc()->BalanceRowHeight( *getShellCrsr( false ), bTstOnly ); if( !bTstOnly ) EndAllActionAndCall(); return bRet; @@ -854,7 +843,7 @@ void SwFEShell::SetRowBackground( const SvxBrushItem &rNew ) { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetRowBackground( GetShellCursor( *this ), rNew ); + GetDoc()->SetRowBackground( *getShellCrsr( false ), rNew ); EndAllActionAndCall(); } @@ -863,7 +852,7 @@ void SwFEShell::SetRowBackground( const SvxBrushItem &rNew ) ******************************************************************************/ BOOL SwFEShell::GetRowBackground( SvxBrushItem &rToFill ) const { - return GetDoc()->GetRowBackground( GetShellCursor( *this ), rToFill ); + return GetDoc()->GetRowBackground( *getShellCrsr( false ), rToFill ); } /*********************************************************************** @@ -877,7 +866,7 @@ void SwFEShell::SetTabBorders( const SfxItemSet& rSet ) { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetTabBorders( GetShellCursor( *this ), rSet ); + GetDoc()->SetTabBorders( *getShellCrsr( false ), rSet ); EndAllActionAndCall(); } @@ -886,14 +875,14 @@ void SwFEShell::SetTabLineStyle( const Color* pColor, BOOL bSetLine, { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetTabLineStyle( GetShellCursor( *this ), + GetDoc()->SetTabLineStyle( *getShellCrsr( false ), pColor, bSetLine, pBorderLine ); EndAllActionAndCall(); } void SwFEShell::GetTabBorders( SfxItemSet& rSet ) const { - GetDoc()->GetTabBorders( GetShellCursor( *this ), rSet ); + GetDoc()->GetTabBorders( *getShellCrsr( false ), rSet ); } @@ -907,13 +896,13 @@ void SwFEShell::SetBoxBackground( const SvxBrushItem &rNew ) { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetBoxAttr( GetShellCursor( *this ), rNew ); + GetDoc()->SetBoxAttr( *getShellCrsr( false ), rNew ); EndAllActionAndCall(); } BOOL SwFEShell::GetBoxBackground( SvxBrushItem &rToFill ) const { - return GetDoc()->GetBoxAttr( GetShellCursor( *this ), rToFill ); + return GetDoc()->GetBoxAttr( *getShellCrsr( false ), rToFill ); } /*********************************************************************** @@ -926,13 +915,13 @@ void SwFEShell::SetBoxDirection( const SvxFrameDirectionItem& rNew ) { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetBoxAttr( GetShellCursor( *this ), rNew ); + GetDoc()->SetBoxAttr( *getShellCrsr( false ), rNew ); EndAllActionAndCall(); } BOOL SwFEShell::GetBoxDirection( SvxFrameDirectionItem& rToFill ) const { - return GetDoc()->GetBoxAttr( GetShellCursor( *this ), rToFill ); + return GetDoc()->GetBoxAttr( *getShellCrsr( false ), rToFill ); } /*********************************************************************** @@ -945,13 +934,13 @@ void SwFEShell::SetBoxAlign( USHORT nAlign ) { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetBoxAlign( GetShellCursor( *this ), nAlign ); + GetDoc()->SetBoxAlign( *getShellCrsr( false ), nAlign ); EndAllActionAndCall(); } USHORT SwFEShell::GetBoxAlign() const { - return GetDoc()->GetBoxAlign( GetShellCursor( *this ) ); + return GetDoc()->GetBoxAlign( *getShellCrsr( false ) ); } /*********************************************************************** @@ -1063,7 +1052,7 @@ void SwFEShell::ProtectCells() SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetBoxAttr( GetShellCursor( *this ), aProt ); + GetDoc()->SetBoxAttr( *getShellCrsr( false ), aProt ); if( !IsCrsrReadonly() ) { @@ -1280,7 +1269,7 @@ void SwFEShell::AdjustCellWidth( BOOL bBalance ) //ermitteln laesst wieviel Inhalt betroffen ist. TblWait aWait( USHRT_MAX, 0, *GetDoc()->GetDocShell() ); - GetDoc()->AdjustCellWidth( GetShellCursor( *this ), bBalance ); + GetDoc()->AdjustCellWidth( *getShellCrsr( false ), bBalance ); EndAllActionAndCall(); } diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index f621e60fbc74..ba550304e04a 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -210,11 +210,7 @@ void GetTblSel( const SwCrsrShell& rShell, SwSelBoxes& rBoxes, if ( !rShell.IsTableMode() ) rShell.GetCrsr(); - const SwShellCrsr *pCrsr = rShell.GetTableCrsr(); - if( !pCrsr ) - pCrsr = (SwShellCrsr*)*rShell.GetSwCrsr( FALSE ); - - GetTblSel( *pCrsr, rBoxes, eSearchType ); + GetTblSel( *rShell.getShellCrsr(false), rBoxes, eSearchType ); } void GetTblSel( const SwCursor& rCrsr, SwSelBoxes& rBoxes, @@ -287,7 +283,7 @@ void GetTblSel( const SwCursor& rCrsr, SwSelBoxes& rBoxes, else { Point aPtPos, aMkPos; - const SwShellCrsr* pShCrsr = rCrsr; + const SwShellCrsr* pShCrsr = dynamic_cast<const SwShellCrsr*>(&rCrsr); if( pShCrsr ) { aPtPos = pShCrsr->GetPtPos(); @@ -2066,11 +2062,7 @@ BOOL CheckSplitCells( const SwCrsrShell& rShell, USHORT nDiv, if( !rShell.IsTableMode() ) rShell.GetCrsr(); - const SwShellCrsr *pCrsr = rShell.GetTableCrsr(); - if( !pCrsr ) - pCrsr = (SwShellCrsr*)*rShell.GetSwCrsr( FALSE ); - - return CheckSplitCells( *pCrsr, nDiv, eSearchType ); + return CheckSplitCells( *rShell.getShellCrsr(false), nDiv, eSearchType ); } BOOL CheckSplitCells( const SwCursor& rCrsr, USHORT nDiv, @@ -2083,7 +2075,7 @@ BOOL CheckSplitCells( const SwCursor& rCrsr, USHORT nDiv, //Start- und Endzelle besorgen und den naechsten fragen. Point aPtPos, aMkPos; - const SwShellCrsr* pShCrsr = rCrsr; + const SwShellCrsr* pShCrsr = dynamic_cast<const SwShellCrsr*>(&rCrsr); if( pShCrsr ) { aPtPos = pShCrsr->GetPtPos(); diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx index 3a3be7a60412..292be49df7b4 100644 --- a/sw/source/core/inc/dflyobj.hxx +++ b/sw/source/core/inc/dflyobj.hxx @@ -85,6 +85,10 @@ public: // for paints triggered form ExecutePrimitive void wrap_DoPaintObject() const; + // for simple access to inner and outer bounds + basegfx::B2DRange getOuterBound() const; + basegfx::B2DRange getInnerBound() const; + public: TYPEINFO(); @@ -92,7 +96,6 @@ public: ~SwVirtFlyDrawObj(); //Ueberladene Methoden der Basisklasse SdrVirtObj - virtual SdrObject* CheckHit(const Point& rPnt, USHORT nTol, const SetOfByte* pVisiLayer) const; virtual void TakeObjInfo( SdrObjTransformInfoRec& rInfo ) const; //Wir nehemen die Groessenbehandlung vollstaendig selbst in die Hand. diff --git a/sw/source/core/inc/dview.hxx b/sw/source/core/inc/dview.hxx index 8d1988903aa8..f5cb6cc40261 100644 --- a/sw/source/core/inc/dview.hxx +++ b/sw/source/core/inc/dview.hxx @@ -90,6 +90,10 @@ protected: // add custom handles (used by other apps, e.g. AnchorPos) virtual void AddCustomHdl(); + // overloaded to allow extra handling when picking SwVirtFlyDrawObj's + using FmFormView::CheckSingleSdrObjectHit; + virtual SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, USHORT nTol, SdrObject* pObj, SdrPageView* pPV, ULONG nOptions, const SetOfByte* pMVisLay) const; + public: SwDrawView( SwViewImp &rI, SdrModel *pMd, OutputDevice* pOutDev=NULL ); diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 76e877555fe9..b829d201ce03 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -2160,7 +2160,7 @@ BOOL SwFlowFrm::MoveBwd( BOOL &rbReformat ) // --> FME 2004-11-15 #i37084# FindLastCntnt does not necessarily // have to have a result != 0 SwFrm* pRef = 0; - const BOOL bEndnote = pFtn->GetAttr()->GetFtn().IsEndNote(); + const bool bEndnote = pFtn->GetAttr()->GetFtn().IsEndNote(); if( bEndnote && pFtn->IsInSct() ) { SwSectionFrm* pSect = pFtn->FindSctFrm(); diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx index b9663b1418d6..73fdfaabe570 100644 --- a/sw/source/core/layout/ftnfrm.cxx +++ b/sw/source/core/layout/ftnfrm.cxx @@ -852,7 +852,7 @@ SwLayoutFrm *SwFrm::GetPrevFtnLeaf( MakePageType eMakeFtn ) if ( !pRet ) { - BOOL bEndn = pFtn->GetAttr()->GetFtn().IsEndNote(); + bool bEndn = pFtn->GetAttr()->GetFtn().IsEndNote(); SwFrm* pTmpRef = NULL; if( bEndn && pFtn->IsInSct() ) { @@ -1442,7 +1442,7 @@ void SwFtnBossFrm::InsertFtn( SwFtnFrm* pNew ) if( IsInSct() ) { SwSectionFrm* pMySect = ImplFindSctFrm(); - BOOL bEndnt = pNew->GetAttr()->GetFtn().IsEndNote(); + bool bEndnt = pNew->GetAttr()->GetFtn().IsEndNote(); if( bEndnt ) { const SwSectionFmt* pEndFmt = pMySect->GetEndSectFmt(); diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx index 65bfff2ae4b1..ea73a56cd8ca 100644 --- a/sw/source/core/layout/pagedesc.cxx +++ b/sw/source/core/layout/pagedesc.cxx @@ -296,10 +296,11 @@ void SwPageDesc::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) const USHORT nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0; SwModify::Modify( pOld, pNew ); - if( RES_ATTRSET_CHG == nWhich || RES_FMT_CHG == nWhich || - ( nWhich >= RES_CHRATR_BEGIN && nWhich < RES_CHRATR_END ) || - nWhich == RES_PARATR_LINESPACING ) + if ( (RES_ATTRSET_CHG == nWhich) || (RES_FMT_CHG == nWhich) + || isCHRATR(nWhich) || (RES_PARATR_LINESPACING == nWhich) ) + { RegisterChange(); + } } static const SwFrm* lcl_GetFrmOfNode( const SwNode& rNd ) diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index dececa60560e..7dcbc4ef80a9 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -112,6 +112,9 @@ #include <EnhancedPDFExportHelper.hxx> // <-- +#include <ndole.hxx> +#include <svtools/chartprettypainter.hxx> + #include <PostItMgr.hxx> #include <tools/color.hxx> #define COL_NOTES_SIDEPANE RGB_COLORDATA(230,230,230) @@ -3512,6 +3515,19 @@ void SwFlyFrm::Paint( const SwRect& rRect ) const const SwNoTxtFrm *pNoTxt = Lower() && Lower()->IsNoTxtFrm() ? (SwNoTxtFrm*)Lower() : 0; + bool bIsChart = false; //#i102950# don't paint additional borders for charts + //check whether we have a chart + if(pNoTxt) + { + const SwNoTxtNode* pNoTNd = dynamic_cast<const SwNoTxtNode*>(pNoTxt->GetNode()); + if( pNoTNd ) + { + SwOLENode* pOLENd = const_cast<SwOLENode*>(pNoTNd->GetOLENode()); + if( pOLENd && ChartPrettyPainter::IsChart( pOLENd->GetOLEObj().GetObject() ) ) + bIsChart = true; + } + } + { bool bContour = GetFmt()->GetSurround().IsContour(); PolyPolygon aPoly; @@ -3641,7 +3657,8 @@ void SwFlyFrm::Paint( const SwRect& rRect ) const // OD 19.12.2002 #106318# - fly frame will paint it's subsidiary lines and // the subsidiary lines of its lowers on its own, due to overlapping with // other fly frames or other objects. - if( pGlobalShell->GetWin() ) + if( pGlobalShell->GetWin() + && !bIsChart ) //#i102950# don't paint additional borders for charts { bool bSubsLineRectsCreated; if ( pSubsLines ) diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index be31859c036d..0667add0e992 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -129,6 +129,7 @@ SwTabFrm::SwTabFrm( SwTable &rTab ): else delete pNew; } + ASSERT( Lower() && Lower()->IsRowFrm(), "SwTabFrm::SwTabFrm: No rows." ); } SwTabFrm::SwTabFrm( SwTabFrm &rTab ) : @@ -2145,7 +2146,9 @@ void SwTabFrm::MakeAll() if ( !bValidSize || !bValidPrtArea ) { - const BOOL bOptLower = (Frm().*fnRect->fnGetHeight)() == 0; + // HB #i101593# no optimization as it leeds to not layouting certain nested tables + // const BOOL bOptLower = (Frm().*fnRect->fnGetHeight)() == 0; + const BOOL bOptLower = FALSE; const long nOldPrtWidth = (Prt().*fnRect->fnGetWidth)(); const long nOldFrmWidth = (Frm().*fnRect->fnGetWidth)(); diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index 2074adea4df3..4cbb6ffaa7b8 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -961,7 +961,7 @@ USHORT SwRootFrm::SetCurrPage( SwCursor* pToSet, USHORT nPageNum ) pCNd->MakeStartIndex( (SwIndex*)&pToSet->GetPoint()->nContent ); pToSet->GetPoint()->nContent = ((SwTxtFrm*)pCntnt)->GetOfst(); - SwShellCrsr* pSCrsr = (SwShellCrsr*)*pToSet; + SwShellCrsr* pSCrsr = dynamic_cast<SwShellCrsr*>(pToSet); if( pSCrsr ) { Point &rPt = pSCrsr->GetPtPos(); @@ -1868,9 +1868,7 @@ bool SwRootFrm::MakeTblCrsrs( SwTableCursor& rTblCrsr ) Point aPtPt, aMkPt; { - SwShellCrsr* pShCrsr = rTblCrsr.operator SwShellCrsr*(); - // Aufgrund eines CompilerBugs von Linux muss - // der Zeigeroperator explizit gerufen werden + SwShellCrsr* pShCrsr = dynamic_cast<SwShellCrsr*>(&rTblCrsr); if( pShCrsr ) { diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx index eb4148264931..bd9a0b1418d3 100644 --- a/sw/source/core/text/atrstck.cxx +++ b/sw/source/core/text/atrstck.cxx @@ -35,9 +35,7 @@ #include <errhdl.hxx> // ASSERT #include <atrhndl.hxx> #include <svtools/itemiter.hxx> -#ifndef _OUTDEV_HXX //autogen #include <vcl/outdev.hxx> -#endif #include <svx/cmapitem.hxx> #include <svx/colritem.hxx> #include <svx/cntritem.hxx> @@ -56,9 +54,7 @@ #include <svx/akrnitem.hxx> #include <svx/blnkitem.hxx> #include <svx/charrotateitem.hxx> -#ifndef _SVX_EMPHITEM_HXX #include <svx/emphitem.hxx> -#endif #include <svx/charscaleitem.hxx> #include <svx/twolinesitem.hxx> #include <svx/charhiddenitem.hxx> @@ -250,12 +246,14 @@ bool lcl_ChgHyperLinkColor( const SwTxtAttr& rAttr, if ( pColor ) { // take color from character format 'unvisited link' - ((SwTxtINetFmt&)rAttr).SetVisited( FALSE ); + SwTxtINetFmt& rInetAttr( const_cast<SwTxtINetFmt&>( + static_cast<const SwTxtINetFmt&>(rAttr)) ); + rInetAttr.SetVisited( false ); const SwCharFmt* pTmpFmt = ((SwTxtINetFmt&)rAttr).GetCharFmt(); const SfxPoolItem* pItem; pTmpFmt->GetItemState( RES_CHRATR_COLOR, TRUE, &pItem ); *pColor = ((SvxColorItem*)pItem)->GetValue(); - ((SwTxtINetFmt&)rAttr).SetVisited( TRUE ); + rInetAttr.SetVisited( true ); } return true; } @@ -446,7 +444,7 @@ void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAS, while( TRUE ) { nWhich = pItem->Which(); - if( RES_CHRATR_BEGIN <= nWhich && RES_CHRATR_END > nWhich ) + if (isCHRATR(nWhich)) { pDefaultArray[ StackPos[ nWhich ] ] = pItem; FontChg( *pItem, rFnt, sal_True ); diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx index 8a39847705e2..b5a3dff475ae 100644 --- a/sw/source/core/text/frmform.cxx +++ b/sw/source/core/text/frmform.cxx @@ -644,7 +644,7 @@ SwCntntFrm *SwTxtFrm::JoinFrm() { SwFtnBossFrm *pFtnBoss = 0; SwFtnBossFrm *pEndBoss = 0; - for( MSHORT i = 0; i < pHints->Count(); ++i ) + for ( USHORT i = 0; i < pHints->Count(); ++i ) { const SwTxtAttr *pHt = (*pHints)[i]; if( RES_TXTATR_FTN==pHt->Which() && *pHt->GetStart()>=nStart ) @@ -744,7 +744,7 @@ SwCntntFrm *SwTxtFrm::SplitFrm( const xub_StrLen nTxtPos ) { SwFtnBossFrm *pFtnBoss = 0; SwFtnBossFrm *pEndBoss = 0; - for( MSHORT i = 0; i < pHints->Count(); ++i ) + for ( USHORT i = 0; i < pHints->Count(); ++i ) { const SwTxtAttr *pHt = (*pHints)[i]; if( RES_TXTATR_FTN==pHt->Which() && *pHt->GetStart()>=nTxtPos ) diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index c07ff50d57ea..82d88875090d 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -65,9 +65,7 @@ #include <itrtxt.hxx> #include <breakit.hxx> #include <com/sun/star/i18n/WordType.hpp> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif using namespace ::com::sun::star::i18n; using namespace ::com::sun::star; @@ -128,11 +126,11 @@ SwAttrIter::~SwAttrIter() SwTxtAttr *SwAttrIter::GetAttr( const xub_StrLen nPosition ) const { - if( pHints ) + if ( pHints ) { - for( MSHORT i = 0; i < pHints->Count(); ++i ) + for ( USHORT i = 0; i < pHints->Count(); ++i ) { - SwTxtAttr *pPos = pHints->GetHt(i); + SwTxtAttr *pPos = pHints->GetTextHint(i); xub_StrLen nStart = *pPos->GetStart(); if( nPosition < nStart ) return 0; @@ -669,7 +667,7 @@ void SwTxtNode::GetMinMaxSize( ULONG nIndex, ULONG& rMin, ULONG &rMax, SwAttrIter aIter( *(SwTxtNode*)this, aScriptInfo ); xub_StrLen nIdx = 0; aIter.SeekAndChgAttrIter( nIdx, pOut ); - xub_StrLen nLen = aText.Len(); + xub_StrLen nLen = m_Text.Len(); long nAktWidth = 0; MSHORT nAdd = 0; SwMinMaxArgs aArg( pOut, pSh, rMin, rMax, rAbsMin ); @@ -683,7 +681,7 @@ void SwTxtNode::GetMinMaxSize( ULONG nIndex, ULONG& rMin, ULONG &rMax, xub_Unicode cChar = CH_BLANK; nStop = nIdx; while( nStop < nLen && nStop < nNextChg && - CH_TAB != ( cChar = aText.GetChar( nStop ) ) && + CH_TAB != ( cChar = m_Text.GetChar( nStop ) ) && CH_BREAK != cChar && CHAR_HARDBLANK != cChar && CHAR_HARDHYPHEN != cChar && CHAR_SOFTHYPHEN != cChar && !pHint ) @@ -692,8 +690,10 @@ void SwTxtNode::GetMinMaxSize( ULONG nIndex, ULONG& rMin, ULONG &rMax, || ( 0 == ( pHint = aIter.GetAttr( nStop ) ) ) ) ++nStop; } - if( lcl_MinMaxString( aArg, aIter.GetFnt(), aText, nIdx, nStop ) ) + if ( lcl_MinMaxString( aArg, aIter.GetFnt(), m_Text, nIdx, nStop ) ) + { nAdd = 20; + } nIdx = nStop; aIter.SeekAndChgAttrIter( nIdx, pOut ); switch( cChar ) @@ -933,7 +933,7 @@ USHORT SwTxtNode::GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd ) // stop at special characters in [ nIdx, nNextChg ] while( nStop < nEnd && nStop < nNextChg ) { - cChar = aText.GetChar( nStop ); + cChar = m_Text.GetChar( nStop ); if( CH_TAB == cChar || CH_BREAK == cChar || CHAR_HARDBLANK == cChar || CHAR_HARDHYPHEN == cChar || CHAR_SOFTHYPHEN == cChar || diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx index 9b14d52256e7..dc789beb9235 100644 --- a/sw/source/core/text/itrtxt.cxx +++ b/sw/source/core/text/itrtxt.cxx @@ -450,7 +450,7 @@ void SwTxtIter::TruncLines( sal_Bool bNoteFollow ) // examine hints in range nEnd - (nEnd + nRangeChar) for( USHORT i = 0; i < pTmpHints->Count(); i++ ) { - const SwTxtAttr* pHt = pTmpHints->GetHt( i ); + const SwTxtAttr* pHt = pTmpHints->GetTextHint( i ); if( RES_TXTATR_FLYCNT == pHt->Which() ) { // check, if hint is in our range diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index 59788c6395ef..55c905b7e679 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -212,9 +212,9 @@ xub_StrLen SwTxtFrm::CalcFlyPos( SwFrmFmt* pSearch ) if( !pHints ) return STRING_LEN; SwTxtAttr* pFound = NULL; - for( MSHORT i = 0; i < pHints->Count(); i++) + for ( USHORT i = 0; i < pHints->Count(); i++) { - SwTxtAttr *pHt = pHints->GetHt( i ); + SwTxtAttr *pHt = pHints->GetTextHint( i ); if( RES_TXTATR_FLYCNT == pHt->Which() ) { SwFrmFmt* pFrmFmt = pHt->GetFlyCnt().GetFrmFmt(); diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index a9272d077170..0a0a99087fc9 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -45,15 +45,9 @@ #include <porrst.hxx> // SwHangingPortion #include <pormulti.hxx> // SwMultiPortion #include <breakit.hxx> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif -#ifndef _COM_SUN_STAR_I18N_CTLSCRIPTTYPE_HDL_ #include <com/sun/star/i18n/CTLScriptType.hdl> -#endif -#ifndef _COM_SUN_STAR_I18N_WORDTYPE_HDL #include <com/sun/star/i18n/WordType.hdl> -#endif #include <paratr.hxx> #include <svx/adjitem.hxx> #include <svx/scripttypeitem.hxx> @@ -1113,7 +1107,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) // we search for connecting opportunities (kashida) else if ( bAdjustBlock && i18n::ScriptType::COMPLEX == nScript ) { - SwScanner aScanner( rNode, rNode.aText, 0, 0, + SwScanner aScanner( rNode, rNode.GetTxt(), 0, 0, i18n::WordType::DICTIONARY_WORD, nLastKashida, nChg ); diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx index 70d094e53597..c6b100f1b746 100644 --- a/sw/source/core/text/txtdrop.cxx +++ b/sw/source/core/text/txtdrop.cxx @@ -155,7 +155,7 @@ sal_Bool SwTxtSizeInfo::_HasHint( const SwTxtNode* pTxtNode, xub_StrLen nPos ) const SwpHints *pHints = pTxtNode->GetpSwpHints(); if( !pHints ) return sal_False; - for( MSHORT i = 0; i < pHints->Count(); ++i ) + for ( USHORT i = 0; i < pHints->Count(); ++i ) { const SwTxtAttr *pPos = (*pHints)[i]; xub_StrLen nStart = *pPos->GetStart(); diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index 2fe945ef58b4..0e50f7d269e4 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -500,18 +500,4 @@ SwNumberPortion *SwTxtFormatter::NewNumberPortion( SwTxtFormatInfo &rInf ) const } return pRet; } -/* -----------------26.06.2003 13:54----------------- - --------------------------------------------------*/ -void SwTxtFld::NotifyContentChange(SwFmtFld& rFmtFld) -{ - //if not in undo section notify the change - if(pMyTxtNd && pMyTxtNd->GetNodes().IsDocNodes()) - pMyTxtNd->Modify(0, &rFmtFld); -} - -// #111840# -SwPosition * SwTxtFld::GetPosition() const -{ - return GetTxtNode().GetPosition(this); -} diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index e7f0fcd88fb1..7295acf3440a 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -451,9 +451,9 @@ void SwTxtFrm::HideFootnotes( xub_StrLen nStart, xub_StrLen nEnd ) const SwpHints *pHints = GetTxtNode()->GetpSwpHints(); if( pHints ) { - const MSHORT nSize = pHints->Count(); + const USHORT nSize = pHints->Count(); SwPageFrm *pPage = 0; - for( MSHORT i = 0; i < nSize; ++i ) + for ( USHORT i = 0; i < nSize; ++i ) { const SwTxtAttr *pHt = (*pHints)[i]; if ( pHt->Which() == RES_TXTATR_FTN ) @@ -505,9 +505,9 @@ bool lcl_HideObj( const SwTxtFrm& _rFrm, const SwTxtAttr* pHint( 0 ); if( pHints ) { - for( MSHORT i = 0; i < pHints->Count(); ++i ) + for ( USHORT i = 0; i < pHints->Count(); ++i ) { - SwTxtAttr* pPos = pHints->GetHt(i); + SwTxtAttr* pPos = pHints->GetTextHint(i); xub_StrLen nStart = *pPos->GetStart(); if ( _nObjAnchorPos < nStart ) break; @@ -1654,10 +1654,10 @@ void SwTxtFrm::Prepare( const PrepareHint ePrep, const void* pVoid, SwpHints *pHints = GetTxtNode()->GetpSwpHints(); if( pHints ) { - const MSHORT nSize = pHints->Count(); + const USHORT nSize = pHints->Count(); const xub_StrLen nEnd = GetFollow() ? GetFollow()->GetOfst() : STRING_LEN; - for( MSHORT i = 0; i < nSize; ++i ) + for ( USHORT i = 0; i < nSize; ++i ) { const SwTxtAttr *pHt = (*pHints)[i]; const xub_StrLen nStart = *pHt->GetStart(); diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx index b5ce2df1dc75..6981ca472419 100644 --- a/sw/source/core/text/txtftn.cxx +++ b/sw/source/core/text/txtftn.cxx @@ -118,7 +118,7 @@ void SwTxtFrm::CalcFtnFlag( xub_StrLen nStop )//Fuer den Test von SplitFrm if( !pHints ) return; - const MSHORT nSize = pHints->Count(); + const USHORT nSize = pHints->Count(); #ifdef PRODUCT const xub_StrLen nEnd = GetFollow() ? GetFollow()->GetOfst() : STRING_LEN; @@ -127,7 +127,7 @@ void SwTxtFrm::CalcFtnFlag( xub_StrLen nStop )//Fuer den Test von SplitFrm : GetFollow() ? GetFollow()->GetOfst() : STRING_LEN; #endif - for( MSHORT i = 0; i < nSize; ++i ) + for ( USHORT i = 0; i < nSize; ++i ) { const SwTxtAttr *pHt = (*pHints)[i]; if ( pHt->Which() == RES_TXTATR_FTN ) @@ -452,7 +452,7 @@ void SwTxtFrm::RemoveFtn( const xub_StrLen nStart, const xub_StrLen nLen ) return; sal_Bool bRollBack = nLen != STRING_LEN; - MSHORT nSize = pHints->Count(); + USHORT nSize = pHints->Count(); xub_StrLen nEnd; SwTxtFrm* pSource; if( bRollBack ) @@ -476,9 +476,9 @@ void SwTxtFrm::RemoveFtn( const xub_StrLen nStart, const xub_StrLen nLen ) SwFtnBossFrm *pEndBoss = 0; sal_Bool bFtnEndDoc = FTNPOS_CHAPTER == GetNode()->GetDoc()->GetFtnInfo().ePos; - for( MSHORT i = nSize; i; ) + for ( USHORT i = nSize; i; ) { - SwTxtAttr *pHt = pHints->GetHt(--i); + SwTxtAttr *pHt = pHints->GetTextHint(--i); if ( RES_TXTATR_FTN != pHt->Which() ) continue; diff --git a/sw/source/core/text/txtio.cxx b/sw/source/core/text/txtio.cxx index 0df7da5f8494..854d252afed8 100644 --- a/sw/source/core/text/txtio.cxx +++ b/sw/source/core/text/txtio.cxx @@ -276,49 +276,8 @@ void LayOutPut( const SwFrm* pFrm ) SvStream &operator<<( SvStream &rOs, const SwpHints & ) //$ ostream { rOs << " {HINTS:"; -#ifdef JP_NEWCORE - for( MSHORT i = 0; i < rHints.GetSize(); ++i) - { - SwTxtHint *pHint = (SwTxtHint*) rHints[i]; - - if(0 != GetCharWidth(pHint)) - rOs << "CHARWIDTH" << ' '; // << GetCharWidth(pHint)->frCPI; - else if(0 != GetColor(pHint)) - rOs << "COLOR" << ' ' ; // << GetColor(pHint)->aColor; - else if(0 != GetCrossedOut(pHint)) - rOs << "CROSSEDOUT" << ' ' << (MSHORT)(GetCrossedOut(pHint)->nState); - else if(0 != GetAttrFont(pHint)) - rOs << "ATTRFONT" << ' ' << - (const char *)(GetAttrFont(pHint)->sFamilyName) << ',' << - ((MSHORT) GetAttrFont(pHint)->eFamily); - else if(0 != GetPosture(pHint)) - rOs << "POSTURE" << ' ' << GetPosture(pHint)->nPosture; - else if(0 != GetFontSize(pHint)) - rOs << "FONTSIZE" << ' ' << GetFontSize(pHint)->nSize; - else if(0 != GetUnderline(pHint)) - rOs << "UNDERLINE" << ' ' << (MSHORT)(GetUnderline(pHint)->nState); - else if(0 != GetOverline(pHint)) - rOs << "OVERLINE" << ' ' << (MSHORT)(GetOverline(pHint)->nState); - else if(0 != GetWeight(pHint)) - rOs << "WEIGHT" << ' ' << GetWeight(pHint)->nWeight; - else if(0 != GetContour(pHint)) - rOs << "CONTOUR" << ' ' << GetContour(pHint)->nState; - else if(0 != GetShadowed(pHint)) - rOs << "SHADOWED" << ' ' << GetShadowed(pHint)->nState; - else if(0 != GetAutoKern(pHint)) - rOs << "AUTOKERN" << ' ' << GetAutoKern(pHint)->nState; - else if(0 != GetWordLineMode(pHint)) - rOs << "WORDLINEMODE" << ' ' << GetWordLineMode(pHint)->nState; - else - rOs << pHint->Which(); - rOs << ',' << pHint->GetStart()->GetIndex() - << '-' - << (pHint->GetEnd() ? pHint->GetEnd()->GetIndex() : STRING_LEN) - << "\n"; - } -#endif - // JP_NEWCORE +// REMOVED rOs << '}'; return rOs; diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx index 56b8ec9afdf4..64bb8be5fc12 100644 --- a/sw/source/core/text/txttab.cxx +++ b/sw/source/core/text/txttab.cxx @@ -254,8 +254,14 @@ SwTabPortion *SwTxtFormatter::NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto ) // <-- ( ( bRTL && nCurrentAbsPos > nTabLeft - nForced ) || ( !bRTL && nCurrentAbsPos < nTabLeft + nForced ) ) && - nNextPos > nForced ) - // <-- + // --> OD 2009-07-21 #i103685# + // adjust condition: + // - back to pre OOo 3.0 condition, if tab stops are relative to indent + // - further checks needed, if tab stops are not relative to indent + ( nNextPos > 0 && + ( bTabsRelativeToIndent || + ( !pTabStop || nNextPos > nForced ) ) ) ) + // <-- { eAdj = SVX_TAB_ADJUST_DEFAULT; cFill = 0; diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 14ac562f64d9..612a2e11b4d0 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -255,12 +255,12 @@ BOOL SwFmtFld::IsProtect() const |* *************************************************************************/ -SwTxtFld::SwTxtFld( const SwFmtFld& rAttr, xub_StrLen nStartPos ) - : SwTxtAttr( rAttr, nStartPos ), - aExpand( rAttr.GetFld()->Expand() ), - pMyTxtNd( 0 ) +SwTxtFld::SwTxtFld( SwFmtFld& rAttr, xub_StrLen nStartPos ) + : SwTxtAttr( rAttr, nStartPos ) + , m_aExpand( rAttr.GetFld()->Expand() ) + , m_pTxtNode( 0 ) { - ((SwFmtFld&)rAttr).pTxtAttr = this; + rAttr.pTxtAttr = this; } SwTxtFld::~SwTxtFld( ) @@ -280,12 +280,12 @@ SwTxtFld::~SwTxtFld( ) void SwTxtFld::Expand() const { // Wenn das expandierte Feld sich nicht veraendert hat, wird returnt - ASSERT( pMyTxtNd, "wo ist denn mein Node?" ); + ASSERT( m_pTxtNode, "SwTxtFld: where is my TxtNode?" ); const SwField* pFld = GetFld().GetFld(); XubString aNewExpand( pFld->Expand() ); - if( aNewExpand == aExpand ) + if( aNewExpand == m_aExpand ) { // Bei Seitennummernfeldern const USHORT nWhich = pFld->GetTyp()->Which(); @@ -301,16 +301,18 @@ void SwTxtFld::Expand() const // BP: das muesste man noch optimieren! //JP 12.06.97: stimmt, man sollte auf jedenfall eine Status- // aenderung an die Frames posten - if( pMyTxtNd->CalcHiddenParaField() ) - pMyTxtNd->Modify( 0, 0 ); + if( m_pTxtNode->CalcHiddenParaField() ) + { + m_pTxtNode->Modify( 0, 0 ); + } return; } } - aExpand = aNewExpand; + m_aExpand = aNewExpand; - // 0, this fuer Formatieren - pMyTxtNd->Modify( 0, (SfxPoolItem*)&GetFld() ); + // 0, this for formatting + m_pTxtNode->Modify( 0, const_cast<SwFmtFld*>( &GetFld() ) ); } /************************************************************************* @@ -319,11 +321,11 @@ void SwTxtFld::Expand() const void SwTxtFld::CopyFld( SwTxtFld *pDest ) const { - ASSERT( pMyTxtNd, "wo ist denn mein Node?" ); - ASSERT( pDest->pMyTxtNd, "wo ist denn mein Node?" ); + ASSERT( m_pTxtNode, "SwTxtFld: where is my TxtNode?" ); + ASSERT( pDest->m_pTxtNode, "SwTxtFld: where is pDest's TxtNode?" ); - IDocumentFieldsAccess* pIDFA = pMyTxtNd->getIDocumentFieldsAccess(); - IDocumentFieldsAccess* pDestIDFA = pDest->pMyTxtNd->getIDocumentFieldsAccess(); + IDocumentFieldsAccess* pIDFA = m_pTxtNode->getIDocumentFieldsAccess(); + IDocumentFieldsAccess* pDestIDFA = pDest->m_pTxtNode->getIDocumentFieldsAccess(); SwFmtFld& rFmtFld = (SwFmtFld&)pDest->GetFld(); const USHORT nFldWhich = rFmtFld.GetFld()->GetTyp()->Which(); @@ -366,10 +368,27 @@ void SwTxtFld::CopyFld( SwTxtFld *pDest ) const ((SwTblField*)rFmtFld.GetFld())->IsIntrnlName() ) { // erzeuge aus der internen (fuer CORE) die externe (fuer UI) Formel - const SwTableNode* pTblNd = pMyTxtNd->FindTableNode(); + const SwTableNode* pTblNd = m_pTxtNode->FindTableNode(); if( pTblNd ) // steht in einer Tabelle ((SwTblField*)rFmtFld.GetFld())->PtrToBoxNm( &pTblNd->GetTable() ); } } +/* -----------------26.06.2003 13:54----------------- + + --------------------------------------------------*/ +void SwTxtFld::NotifyContentChange(SwFmtFld& rFmtFld) +{ + //if not in undo section notify the change + if (m_pTxtNode && m_pTxtNode->GetNodes().IsDocNodes()) + { + m_pTxtNode->Modify(0, &rFmtFld); + } +} + +// #111840# +SwPosition * SwTxtFld::GetPosition() const +{ + return GetTxtNode().GetPosition(this); +} diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx index b33b90ffa9a8..d738497507a8 100644 --- a/sw/source/core/txtnode/atrflyin.cxx +++ b/sw/source/core/txtnode/atrflyin.cxx @@ -70,10 +70,10 @@ SfxPoolItem* __EXPORT SwFmtFlyCnt::Clone( SfxItemPool* ) const return new SwFmtFlyCnt( pFmt ); } -SwTxtFlyCnt::SwTxtFlyCnt( const SwFmtFlyCnt& rAttr, xub_StrLen nStartPos ) +SwTxtFlyCnt::SwTxtFlyCnt( SwFmtFlyCnt& rAttr, xub_StrLen nStartPos ) : SwTxtAttr( rAttr, nStartPos ) { - ((SwFmtFlyCnt&)rAttr).pTxtAttr = this; + rAttr.pTxtAttr = this; } diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx index 96a4f4d90761..4b51e94e3404 100644 --- a/sw/source/core/txtnode/atrftn.cxx +++ b/sw/source/core/txtnode/atrftn.cxx @@ -62,11 +62,11 @@ *************************************************************************/ -SwFmtFtn::SwFmtFtn( BOOL bEN ) +SwFmtFtn::SwFmtFtn( bool bEndNote ) : SfxPoolItem( RES_TXTATR_FTN ), pTxtAttr( 0 ), nNumber( 0 ), - bEndNote( bEN ) + m_bEndNote( bEndNote ) { } @@ -76,7 +76,7 @@ int SwFmtFtn::operator==( const SfxPoolItem& rAttr ) const ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" ); return nNumber == ((SwFmtFtn&)rAttr).nNumber && aNumber == ((SwFmtFtn&)rAttr).aNumber && - bEndNote == ((SwFmtFtn&)rAttr).bEndNote; + m_bEndNote == ((SwFmtFtn&)rAttr).m_bEndNote; } @@ -85,17 +85,19 @@ SfxPoolItem* SwFmtFtn::Clone( SfxItemPool* ) const SwFmtFtn* pNew = new SwFmtFtn; pNew->aNumber = aNumber; pNew->nNumber = nNumber; - pNew->bEndNote = bEndNote; + pNew->m_bEndNote = m_bEndNote; return pNew; } -void SwFmtFtn::SetEndNote( BOOL b ) +void SwFmtFtn::SetEndNote( bool b ) { - if ( b != bEndNote ) + if ( b != m_bEndNote ) { if ( GetTxtFtn() ) + { GetTxtFtn()->DelFrms(); - bEndNote = b; + } + m_bEndNote = b; } } @@ -173,13 +175,13 @@ XubString SwFmtFtn::GetViewNumStr( const SwDoc& rDoc, BOOL bInclStrings ) const * class SwTxt/FmtFnt *************************************************************************/ -SwTxtFtn::SwTxtFtn( const SwFmtFtn& rAttr, xub_StrLen nStartPos ) - : SwTxtAttr( rAttr, nStartPos ), - pStartNode( 0 ), - pMyTxtNd( 0 ), - nSeqNo( USHRT_MAX ) +SwTxtFtn::SwTxtFtn( SwFmtFtn& rAttr, xub_StrLen nStartPos ) + : SwTxtAttr( rAttr, nStartPos ) + , m_pStartNode( 0 ) + , m_pTxtNode( 0 ) + , m_nSeqNo( USHRT_MAX ) { - ((SwFmtFtn&)rAttr).pTxtAttr = this; + rAttr.pTxtAttr = this; } @@ -194,19 +196,25 @@ void SwTxtFtn::SetStartNode( const SwNodeIndex *pNewNode, BOOL bDelNode ) { if( pNewNode ) { - if( !pStartNode ) - pStartNode = new SwNodeIndex( *pNewNode ); + if ( !m_pStartNode ) + { + m_pStartNode = new SwNodeIndex( *pNewNode ); + } else - *pStartNode = *pNewNode; + { + *m_pStartNode = *pNewNode; + } } - else if( pStartNode ) + else if ( m_pStartNode ) { // Zwei Dinge muessen erledigt werden: // 1) Die Fussnoten muessen bei ihren Seiten abgemeldet werden // 2) Die Fussnoten-Sektion in den Inserts muss geloescht werden. SwDoc* pDoc; - if( pMyTxtNd ) - pDoc = pMyTxtNd->GetDoc(); + if ( m_pTxtNode ) + { + pDoc = m_pTxtNode->GetDoc(); + } else { //JP 27.01.97: der sw3-Reader setzt einen StartNode aber das @@ -214,7 +222,7 @@ void SwTxtFtn::SetStartNode( const SwNodeIndex *pNewNode, BOOL bDelNode ) // Wird es geloescht (z.B. bei Datei einfuegen mit // Ftn in einen Rahmen), muss auch der Inhalt // geloescht werden - pDoc = pStartNode->GetNodes().GetDoc(); + pDoc = m_pStartNode->GetNodes().GetDoc(); } // Wir duerfen die Fussnotennodes nicht loeschen @@ -226,7 +234,7 @@ void SwTxtFtn::SetStartNode( const SwNodeIndex *pNewNode, BOOL bDelNode ) { // 1) Die Section fuer die Fussnote wird beseitigt // Es kann sein, dass die Inserts schon geloescht wurden. - pDoc->DeleteSection( &pStartNode->GetNode() ); + pDoc->DeleteSection( &m_pStartNode->GetNode() ); } else // Werden die Nodes nicht geloescht mussen sie bei den Seiten @@ -234,7 +242,7 @@ void SwTxtFtn::SetStartNode( const SwNodeIndex *pNewNode, BOOL bDelNode ) // stehen (Undo loescht sie nicht!) DelFrms(); } - DELETEZ( pStartNode ); + DELETEZ( m_pStartNode ); // loesche die Fussnote noch aus dem Array am Dokument for( USHORT n = 0; n < pDoc->GetFtnIdxs().Count(); ++n ) @@ -264,16 +272,15 @@ void SwTxtFtn::SetNumber( const USHORT nNewNum, const XubString* pStr ) rFtn.aNumber = aEmptyStr; } - ASSERT( pMyTxtNd, "wo ist mein TextNode?" ); - SwNodes &rNodes = pMyTxtNd->GetDoc()->GetNodes(); - pMyTxtNd->Modify( 0, &rFtn ); - if( pStartNode ) + ASSERT( m_pTxtNode, "SwTxtFtn: where is my TxtNode?" ); + SwNodes &rNodes = m_pTxtNode->GetDoc()->GetNodes(); + m_pTxtNode->Modify( 0, &rFtn ); + if ( m_pStartNode ) { - // Wir muessen ueber alle TxtNodes iterieren, wegen der - // Fussnoten, die auf anderen Seiten stehen. + // must iterate over all TxtNodes because of footnotes on other pages SwNode* pNd; - ULONG nSttIdx = pStartNode->GetIndex() + 1, - nEndIdx = pStartNode->GetNode().EndOfSectionIndex(); + ULONG nSttIdx = m_pStartNode->GetIndex() + 1; + ULONG nEndIdx = m_pStartNode->GetNode().EndOfSectionIndex(); for( ; nSttIdx < nEndIdx; ++nSttIdx ) { // Es koennen ja auch Grafiken in der Fussnote stehen ... @@ -286,15 +293,15 @@ void SwTxtFtn::SetNumber( const USHORT nNewNum, const XubString* pStr ) // Die Fussnoten duplizieren void SwTxtFtn::CopyFtn( SwTxtFtn *pDest ) { - if( pStartNode && pDest->GetStartNode() ) + if ( m_pStartNode && pDest->GetStartNode() ) { // die Fussnoten koennen in unterschiedlichen Dokumenten stehen !! - SwDoc* pDstDoc = pDest->pMyTxtNd->GetDoc(); + SwDoc* pDstDoc = pDest->m_pTxtNode->GetDoc(); SwNodes &rDstNodes = pDstDoc->GetNodes(); // Wir kopieren nur den Inhalt der Sektion - SwNodeRange aRg( *pStartNode, 1, - *pStartNode->GetNode().EndOfSectionNode() ); + SwNodeRange aRg( *m_pStartNode, 1, + *m_pStartNode->GetNode().EndOfSectionNode() ); // Wir fuegen auf dem Ende von pDest ein, d.h. die Nodes // werden angehaengt. nDestLen haelt die Anzahl der CntNodes @@ -303,7 +310,7 @@ void SwTxtFtn::CopyFtn( SwTxtFtn *pDest ) SwNodeIndex aEnd( *aStart.GetNode().EndOfSectionNode() ); ULONG nDestLen = aEnd.GetIndex() - aStart.GetIndex() - 1; - pMyTxtNd->GetDoc()->CopyWithFlyInFly( aRg, aEnd, TRUE ); + m_pTxtNode->GetDoc()->CopyWithFlyInFly( aRg, 0, aEnd, TRUE ); // Wenn die Dest-Sektion nicht leer war, so muessen die alten // Nodes geloescht werden: @@ -323,7 +330,7 @@ void SwTxtFtn::CopyFtn( SwTxtFtn *pDest ) // lege eine neue leere TextSection fuer diese Fussnote an void SwTxtFtn::MakeNewTextSection( SwNodes& rNodes ) { - if( pStartNode ) + if ( m_pStartNode ) return; // Nun verpassen wir dem TxtNode noch die Fussnotenvorlage. @@ -347,20 +354,20 @@ void SwTxtFtn::MakeNewTextSection( SwNodes& rNodes ) SwStartNode* pSttNd = rNodes.MakeTextSection( SwNodeIndex( rNodes.GetEndOfInserts() ), SwFootnoteStartNode, pFmtColl ); - pStartNode = new SwNodeIndex( *pSttNd ); + m_pStartNode = new SwNodeIndex( *pSttNd ); } void SwTxtFtn::DelFrms() { - // loesche die Ftn-Frames aus den Seiten - ASSERT( pMyTxtNd, "wo ist mein TextNode?" ); - if( !pMyTxtNd ) - return ; + // delete the FtnFrames from the pages + ASSERT( m_pTxtNode, "SwTxtFtn: where is my TxtNode?" ); + if ( !m_pTxtNode ) + return; BOOL bFrmFnd = FALSE; { - SwClientIter aIter( *pMyTxtNd ); + SwClientIter aIter( *m_pTxtNode ); for( SwCntntFrm* pFnd = (SwCntntFrm*)aIter.First( TYPE( SwCntntFrm )); pFnd; pFnd = (SwCntntFrm*)aIter.Next() ) { @@ -374,10 +381,10 @@ void SwTxtFtn::DelFrms() } //JP 13.05.97: falls das Layout vorm loeschen der Fussnoten entfernt // wird, sollte man das ueber die Fussnote selbst tun - if( !bFrmFnd && pStartNode ) + if ( !bFrmFnd && m_pStartNode ) { - SwNodeIndex aIdx( *pStartNode ); - SwCntntNode* pCNd = pMyTxtNd->GetNodes().GoNext( &aIdx ); + SwNodeIndex aIdx( *m_pStartNode ); + SwCntntNode* pCNd = m_pTxtNode->GetNodes().GoNext( &aIdx ); if( pCNd ) { SwClientIter aIter( *pCNd ); @@ -415,10 +422,10 @@ void SwTxtFtn::DelFrms() USHORT SwTxtFtn::SetSeqRefNo() { - if( !pMyTxtNd ) + if( !m_pTxtNode ) return USHRT_MAX; - SwDoc* pDoc = pMyTxtNd->GetDoc(); + SwDoc* pDoc = m_pTxtNode->GetDoc(); if( pDoc->IsInReading() ) return USHRT_MAX; @@ -431,20 +438,33 @@ USHORT SwTxtFtn::SetSeqRefNo() // bestimmt werden muss. SwTxtFtn* pTxtFtn; for( n = 0; n < nFtnCnt; ++n ) - if( (pTxtFtn = pDoc->GetFtnIdxs()[ n ]) != this ) - aArr.Insert( pTxtFtn->nSeqNo ); + { + pTxtFtn = pDoc->GetFtnIdxs()[ n ]; + if ( pTxtFtn != this ) + { + aArr.Insert( pTxtFtn->m_nSeqNo ); + } + } - // teste erstmal ob die Nummer schon vorhanden ist: - if( USHRT_MAX != nSeqNo ) + // test if number is already in use + if ( USHRT_MAX != m_nSeqNo ) { for( n = 0; n < aArr.Count(); ++n ) - if( aArr[ n ] > nSeqNo ) - return nSeqNo; // nicht vorhanden -> also benutzen - else if( aArr[ n ] == nSeqNo ) - break; // schon vorhanden -> neue erzeugen + { + if ( aArr[ n ] > m_nSeqNo ) + { + return m_nSeqNo; // free -> use + } + else if ( aArr[ n ] == m_nSeqNo ) + { + break; // used -> create new one + } + } - if( n == aArr.Count() ) - return nSeqNo; // nicht vorhanden -> also benutzen + if ( n == aArr.Count() ) + { + return m_nSeqNo; // free -> use + } } // alle Nummern entsprechend geflag, also bestimme die richtige Nummer @@ -452,7 +472,7 @@ USHORT SwTxtFtn::SetSeqRefNo() if( n != aArr[ n ] ) break; - return nSeqNo = n; + return m_nSeqNo = n; } void SwTxtFtn::SetUniqueSeqRefNo( SwDoc& rDoc ) @@ -465,29 +485,45 @@ void SwTxtFtn::SetUniqueSeqRefNo( SwDoc& rDoc ) // dann alle Nummern zusammensammeln die schon existieren SwTxtFtn* pTxtFtn; for( n = 0; n < nFtnCnt; ++n ) - if( USHRT_MAX != (pTxtFtn = rDoc.GetFtnIdxs()[ n ])->nSeqNo ) - aArr.Insert( pTxtFtn->nSeqNo ); + { + pTxtFtn = rDoc.GetFtnIdxs()[ n ]; + if ( USHRT_MAX != pTxtFtn->m_nSeqNo ) + { + aArr.Insert( pTxtFtn->m_nSeqNo ); + } + } for( n = 0; n < nFtnCnt; ++n ) - if( USHRT_MAX == (pTxtFtn = rDoc.GetFtnIdxs()[ n ])->nSeqNo ) + { + pTxtFtn = rDoc.GetFtnIdxs()[ n ]; + if ( USHRT_MAX == pTxtFtn->m_nSeqNo ) { for( ; nStt < aArr.Count(); ++nStt ) - if( nStt != aArr[ nStt ] ) + { + if ( nStt != aArr[ nStt ] ) { - - pTxtFtn->nSeqNo = nStt; + pTxtFtn->m_nSeqNo = nStt; break; } + } - if( USHRT_MAX == pTxtFtn->nSeqNo ) - break; // nichts mehr gefunden + if ( USHRT_MAX == pTxtFtn->m_nSeqNo ) + { + break; // found nothing + } } + } // alle Nummern schon vergeben, also mit nStt++ weitermachen for( ; n < nFtnCnt; ++n ) - if( USHRT_MAX == (pTxtFtn = rDoc.GetFtnIdxs()[ n ])->nSeqNo ) - pTxtFtn->nSeqNo = nStt++; + { + pTxtFtn = rDoc.GetFtnIdxs()[ n ]; + if ( USHRT_MAX == pTxtFtn->m_nSeqNo ) + { + pTxtFtn->m_nSeqNo = nStt++; + } + } } void SwTxtFtn::CheckCondColl() diff --git a/sw/source/core/txtnode/atrref.cxx b/sw/source/core/txtnode/atrref.cxx index 210cd1ab2889..ea427f8e8877 100644 --- a/sw/source/core/txtnode/atrref.cxx +++ b/sw/source/core/txtnode/atrref.cxx @@ -79,25 +79,25 @@ SfxPoolItem* SwFmtRefMark::Clone( SfxItemPool* ) const // Attribut fuer Inhalts-/Positions-Referenzen im Text -SwTxtRefMark::SwTxtRefMark( const SwFmtRefMark& rAttr, - xub_StrLen nStartPos, xub_StrLen* pEnde ) - : SwTxtAttrEnd( rAttr, nStartPos, nStartPos ), - pMyTxtNd( 0 ), - pEnd( 0 ) +SwTxtRefMark::SwTxtRefMark( SwFmtRefMark& rAttr, + xub_StrLen nStartPos, xub_StrLen* pEnd ) + : SwTxtAttrEnd( rAttr, nStartPos, nStartPos ) + , m_pTxtNode( 0 ) + , m_pEnd( 0 ) { - ((SwFmtRefMark&)rAttr).pTxtAttr = this; - if( pEnde ) + rAttr.pTxtAttr = this; + if ( pEnd ) { - nEnd = *pEnde; - pEnd = &nEnd; + m_nEnd = *pEnd; + m_pEnd = & m_nEnd; } - SetDontMergeAttr( TRUE ); - SetDontMoveAttr( TRUE ); - SetOverlapAllowedAttr( TRUE ); + SetDontMergeAttr( true ); + SetDontMoveAttr( true ); + SetOverlapAllowedAttr( true ); } xub_StrLen* SwTxtRefMark::GetEnd() { - return pEnd; + return m_pEnd; } diff --git a/sw/source/core/txtnode/atrtox.cxx b/sw/source/core/txtnode/atrtox.cxx index 5581d891b79a..5cc9388dcbcd 100644 --- a/sw/source/core/txtnode/atrtox.cxx +++ b/sw/source/core/txtnode/atrtox.cxx @@ -38,21 +38,21 @@ #include <tox.hxx> #include <ndtxt.hxx> -SwTxtTOXMark::SwTxtTOXMark( const SwTOXMark& rAttr, - xub_StrLen nStartPos, xub_StrLen* pEnde ) - : SwTxtAttrEnd( rAttr, nStartPos, nStartPos ), - pEnd( 0 ), - pMyTxtNd( 0 ) +SwTxtTOXMark::SwTxtTOXMark( SwTOXMark& rAttr, + xub_StrLen nStartPos, xub_StrLen* pEnd ) + : SwTxtAttrEnd( rAttr, nStartPos, nStartPos ) + , m_pTxtNode( 0 ) + , m_pEnd( 0 ) { - ((SwTOXMark&)rAttr).pTxtAttr = this; - if( !rAttr.GetAlternativeText().Len() ) + rAttr.pTxtAttr = this; + if ( !rAttr.GetAlternativeText().Len() ) { - nEnd = *pEnde; - pEnd = &nEnd; + m_nEnd = *pEnd; + m_pEnd = & m_nEnd; } - SetDontMergeAttr( TRUE ); - SetDontMoveAttr( TRUE ); - SetOverlapAllowedAttr( TRUE ); + SetDontMergeAttr( true ); + SetDontMoveAttr( true ); + SetOverlapAllowedAttr( true ); } SwTxtTOXMark::~SwTxtTOXMark() @@ -61,7 +61,7 @@ SwTxtTOXMark::~SwTxtTOXMark() xub_StrLen* SwTxtTOXMark::GetEnd() { - return pEnd; + return m_pEnd; } void SwTxtTOXMark::CopyTOXMark( SwDoc* pDoc ) diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index d58236da16b9..516741fe12b3 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -912,10 +912,10 @@ static void lcl_DrawLineForWrongListData( if (rInf.GetOut().GetConnectMetaFile()) rInf.GetOut().Push(); - const Color aCol( rInf.GetOut().GetTextLineColor() ); + const Color aCol( rInf.GetOut().GetLineColor() ); const BOOL bColSave = aCol != aLineColor; if (bColSave) - rInf.GetOut().SetTextLineColor( aLineColor ); + rInf.GetOut().SetLineColor( aLineColor ); // iterate over all ranges stored in the respective SwWrongList do @@ -986,7 +986,7 @@ static void lcl_DrawLineForWrongListData( while (nWrLen && pWList->Check( nStart, nWrLen )); if (bColSave) - rInf.GetOut().SetTextLineColor( aCol ); + rInf.GetOut().SetLineColor( aCol ); if (rInf.GetOut().GetConnectMetaFile()) rInf.GetOut().Pop(); @@ -1906,10 +1906,10 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf ) WRONG_SHOW_MEDIUM < nHght ? WAVE_NORMAL : ( WRONG_SHOW_SMALL < nHght ? WAVE_SMALL : WAVE_FLAT ); - Color aCol( rInf.GetOut().GetTextLineColor() ); + Color aCol( rInf.GetOut().GetLineColor() ); BOOL bColSave = aCol != *pWaveCol; if ( bColSave ) - rInf.GetOut().SetTextLineColor( *pWaveCol ); + rInf.GetOut().SetLineColor( *pWaveCol ); Point aEnd; long nKernVal = pKernArray[ USHORT( rInf.GetLen() - 1 ) ]; @@ -1956,7 +1956,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf ) rInf.GetOut().DrawWaveLine( aCurrPos, aEnd, nWave ); if ( bColSave ) - rInf.GetOut().SetTextLineColor( aCol ); + rInf.GetOut().SetLineColor( aCol ); if ( rInf.GetOut().GetConnectMetaFile() ) rInf.GetOut().Pop(); @@ -2797,7 +2797,7 @@ sal_Bool SwDrawTextInfo::ApplyAutoColor( Font* pFont ) if ( COL_BLACK != rFnt.GetColor().GetColor() ) bChgFntColor = sal_True; - if ( (COL_BLACK != GetOut().GetTextLineColor().GetColor()) || + if ( (COL_BLACK != GetOut().GetLineColor().GetColor()) || (COL_BLACK != GetOut().GetOverlineColor().GetColor()) ) bChgLineColor = sal_True; } @@ -2894,8 +2894,8 @@ sal_Bool SwDrawTextInfo::ApplyAutoColor( Font* pFont ) { // get current font color or color set at output device aNewColor = pFont ? pFont->GetColor() : GetOut().GetFont().GetColor(); - if ( aNewColor != GetOut().GetTextLineColor() ) - GetOut().SetTextLineColor( aNewColor ); + if ( aNewColor != GetOut().GetLineColor() ) + GetOut().SetLineColor( aNewColor ); if ( aNewColor != GetOut().GetOverlineColor() ) GetOut().SetOverlineColor( aNewColor ); } diff --git a/sw/source/core/txtnode/ndhints.cxx b/sw/source/core/txtnode/ndhints.cxx index bd7da5b7d1f6..64ca41cf8516 100644 --- a/sw/source/core/txtnode/ndhints.cxx +++ b/sw/source/core/txtnode/ndhints.cxx @@ -237,39 +237,41 @@ BOOL SwpHtEnd::Seek_Entry( const SwTxtAttr *pElement, USHORT *pPos ) const * class SwpHintsArr *************************************************************************/ -void SwpHintsArr::Insert( const SwTxtAttr *pHt ) +void SwpHintsArray::Insert( const SwTxtAttr *pHt ) { Resort(); #ifndef PRODUCT USHORT nPos; - ASSERT(!SwpHtStart::Seek_Entry( pHt, &nPos ), "Insert: hint already in HtStart"); - ASSERT(!aHtEnd.Seek_Entry( pHt, &nPos ), "Insert: hint already in HtEnd"); + ASSERT(!m_HintStarts.Seek_Entry( pHt, &nPos ), + "Insert: hint already in HtStart"); + ASSERT(!m_HintEnds.Seek_Entry( pHt, &nPos ), + "Insert: hint already in HtEnd"); #endif - SwpHtStart::Insert( pHt ); - aHtEnd.Insert( pHt ); + m_HintStarts.Insert( pHt ); + m_HintEnds.Insert( pHt ); #ifndef PRODUCT #ifdef NIE - (aDbstream << "Insert: " ).WriteNumber( long( pHt ) )<< endl; - DumpHints( *this, aHtEnd ); + (aDbstream << "Insert: " ).WriteNumber( long( pHt ) ) << endl; + DumpHints( m_HintStarts, m_HintEnds ); #endif #endif } -void SwpHintsArr::DeleteAtPos( const USHORT nPos ) +void SwpHintsArray::DeleteAtPos( const USHORT nPos ) { - // Optimierung: nPos bezieht sich auf die Position im StartArray, also: - const SwTxtAttr *pHt = SwpHtStart::operator[]( nPos ); - SwpHtStart::Remove( nPos ); + // optimization: nPos is the position in the Starts array + const SwTxtAttr *pHt = m_HintStarts[ nPos ]; + m_HintStarts.Remove( nPos ); Resort(); USHORT nEndPos; - aHtEnd.Seek_Entry( pHt, &nEndPos ); - aHtEnd.Remove( nEndPos ); + m_HintEnds.Seek_Entry( pHt, &nEndPos ); + m_HintEnds.Remove( nEndPos ); #ifndef PRODUCT #ifdef NIE - (aDbstream << "DeleteAtPos: " ).WriteNumber( long( pHt ) )<< endl; - DumpHints( *this, aHtEnd ); + (aDbstream << "DeleteAtPos: " ).WriteNumber( long( pHt ) ) << endl; + DumpHints( m_HintStarts, m_HintEnds ); #endif #endif } @@ -277,7 +279,7 @@ void SwpHintsArr::DeleteAtPos( const USHORT nPos ) #ifndef PRODUCT /************************************************************************* - * SwpHintsArr::Check() + * SwpHintsArray::Check() *************************************************************************/ @@ -285,14 +287,15 @@ void SwpHintsArr::DeleteAtPos( const USHORT nPos ) if(!(cond)) \ { \ ASSERT(!this, text); \ - DumpHints(*(SwpHtStart*)this,aHtEnd); \ - return !((SwpHintsArr*)this)->Resort(); \ + DumpHints(m_HintStarts, m_HintEnds); \ + return !(const_cast<SwpHintsArray*>(this))->Resort(); \ } -BOOL SwpHintsArr::Check() const +bool SwpHintsArray::Check() const { // 1) gleiche Anzahl in beiden Arrays - CHECK_ERR( Count() == aHtEnd.Count(), "HintsCheck: wrong sizes" ); + CHECK_ERR( m_HintStarts.Count() == m_HintEnds.Count(), + "HintsCheck: wrong sizes" ); xub_StrLen nLastStart = 0; xub_StrLen nLastEnd = 0; @@ -304,7 +307,7 @@ BOOL SwpHintsArr::Check() const // --- Start-Kontrolle --- // 2a) gueltiger Pointer? vgl. DELETEFF - const SwTxtAttr *pHt = (*this)[i]; + const SwTxtAttr *pHt = m_HintStarts[i]; CHECK_ERR( 0xFF != *(unsigned char*)pHt, "HintsCheck: start ptr was deleted" ); // 3a) Stimmt die Start-Sortierung? @@ -321,7 +324,7 @@ BOOL SwpHintsArr::Check() const // --- End-Kontrolle --- // 2b) gueltiger Pointer? vgl. DELETEFF - const SwTxtAttr *pHtEnd = aHtEnd[i]; + const SwTxtAttr *pHtEnd = m_HintEnds[i]; CHECK_ERR( 0xFF != *(unsigned char*)pHtEnd, "HintsCheck: end ptr was deleted" ); // 3b) Stimmt die End-Sortierung? @@ -339,47 +342,48 @@ BOOL SwpHintsArr::Check() const // --- Ueberkreuzungen --- // 5) gleiche Pointer in beiden Arrays - if( !Seek_Entry( pHt, &nIdx ) ) + if( !m_HintStarts.Seek_Entry( pHt, &nIdx ) ) nIdx = STRING_LEN; CHECK_ERR( STRING_LEN != nIdx, "HintsCheck: no GetStartOf" ); // 6) gleiche Pointer in beiden Arrays - if( !aHtEnd.Seek_Entry( pHt, &nIdx ) ) + if( !m_HintEnds.Seek_Entry( pHt, &nIdx ) ) nIdx = STRING_LEN; CHECK_ERR( STRING_LEN != nIdx, "HintsCheck: no GetEndOf" ); // 7a) character attributes in array? USHORT nWhich = pHt->Which(); - CHECK_ERR( nWhich < RES_CHRATR_BEGIN || nWhich >= RES_CHRATR_END, - "HintsCheck: Character attribute in start array" ) + CHECK_ERR( !isCHRATR(nWhich), + "HintsCheck: Character attribute in start array" ); // 7b) character attributes in array? nWhich = pHtEnd->Which(); - CHECK_ERR( nWhich < RES_CHRATR_BEGIN || nWhich >= RES_CHRATR_END, - "HintsCheck: Character attribute in end array" ) + CHECK_ERR( !isCHRATR(nWhich), + "HintsCheck: Character attribute in end array" ); // 8) portion check #if OSL_DEBUG_LEVEL > 1 - const SwTxtAttr* pHtThis = (*this)[i]; - const SwTxtAttr* pHtLast = i > 0 ? (*this)[i-1] : 0; + const SwTxtAttr* pHtThis = m_HintStarts[i]; + const SwTxtAttr* pHtLast = i > 0 ? m_HintStarts[i-1] : 0; CHECK_ERR( 0 == i || ( RES_TXTATR_CHARFMT != pHtLast->Which() && RES_TXTATR_AUTOFMT != pHtLast->Which() ) || ( RES_TXTATR_CHARFMT != pHtThis->Which() && RES_TXTATR_AUTOFMT != pHtThis->Which() ) || ( *pHtThis->GetStart() >= *pHtLast->GetEnd() ) || ( *pHtThis->GetStart() == *pHtLast->GetStart() && *pHtThis->GetEnd() == *pHtLast->GetEnd() ) || ( *pHtThis->GetStart() == *pHtThis->GetEnd() ), - "HintsCheck: Portion inconsistency. This can be temporarily ok during undo operations" ) + "HintsCheck: Portion inconsistency. " + "This can be temporarily ok during undo operations" ); #endif } - return TRUE; + return true; } #endif /* PRODUCT */ /************************************************************************* - * SwpHintsArr::Resort() + * SwpHintsArray::Resort() *************************************************************************/ // Resort() wird vor jedem Insert und Delete gerufen. @@ -387,61 +391,61 @@ BOOL SwpHintsArr::Check() const // ndtxt.cxx angepasst. Leider erfolgt noch keine Neusortierung // auf gleichen Positionen. -BOOL SwpHintsArr::Resort() +bool SwpHintsArray::Resort() { - BOOL bResort = FALSE; + bool bResort = false; const SwTxtAttr *pLast = 0; USHORT i; - for( i = 0; i < SwpHtStart::Count(); ++i ) + for ( i = 0; i < m_HintStarts.Count(); ++i ) { - const SwTxtAttr *pHt = (*this)[i]; + const SwTxtAttr *pHt = m_HintStarts[i]; if( pLast && !lcl_IsLessStart( *pLast, *pHt ) ) { #ifdef NIE #ifndef PRODUCT // ASSERT( bResort, "!Resort/Start: correcting hints-array" ); aDbstream << "Resort: Starts" << endl; - DumpHints( *this, aHtEnd ); + DumpHints( m_HintStarts, m_HintEnds ); #endif #endif - SwpHtStart::Remove( i ); - SwpHtStart::Insert( pHt ); - pHt = (*this)[i]; + m_HintStarts.Remove( i ); + m_HintStarts.Insert( pHt ); + pHt = m_HintStarts[i]; if ( pHt != pLast ) --i; - bResort = TRUE; + bResort = true; } pLast = pHt; } pLast = 0; - for( i = 0; i < aHtEnd.Count(); ++i ) + for ( i = 0; i < m_HintEnds.Count(); ++i ) { - const SwTxtAttr *pHt = aHtEnd[i]; + const SwTxtAttr *pHt = m_HintEnds[i]; if( pLast && !lcl_IsLessEnd( *pLast, *pHt ) ) { #ifdef NIE #ifndef PRODUCT aDbstream << "Resort: Ends" << endl; - DumpHints( *this, aHtEnd ); + DumpHints( m_HintStarts, m_HintEnds ); #endif #endif - aHtEnd.Remove( i ); - aHtEnd.Insert( pHt ); - pHt = aHtEnd[i]; // normalerweise == pLast + m_HintEnds.Remove( i ); + m_HintEnds.Insert( pHt ); + pHt = m_HintEnds[i]; // normalerweise == pLast // Wenn die Unordnung etwas groesser ist (24200), // muessen wir Position i erneut vergleichen. if ( pLast != pHt ) --i; - bResort = TRUE; + bResort = true; } pLast = pHt; } #ifndef PRODUCT #ifdef NIE aDbstream << "Resorted:" << endl; - DumpHints( *this, aHtEnd ); + DumpHints( m_HintStarts, m_HintEnds ); #endif #endif return bResort; diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index b9ff68e3d422..99cebfd10102 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -33,9 +33,6 @@ #include <hintids.hxx> #include <hints.hxx> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ -#include <com/sun/star/i18n/ScriptType.hdl> -#endif #include <svx/fontitem.hxx> #include <svx/brkitem.hxx> #include <svx/escpitem.hxx> @@ -95,9 +92,7 @@ #include <numrule.hxx> //--> #outlinelevel added by zhaojianwei -#ifndef _SFXINTITEM_HXX #include <svtools/intitem.hxx> -#endif //<--end #include <swtable.hxx> #include <docsh.hxx> @@ -235,10 +230,10 @@ SwTxtNode::SwTxtNode( const SwNodeIndex &rWhere, SwTxtFmtColl *pTxtColl, const SfxItemSet* pAutoAttr ) : SwCntntNode( rWhere, ND_TEXTNODE, pTxtColl ), - pSwpHints( 0 ), + m_pSwpHints( 0 ), mpNodeNum( 0 ), - bNotifiable( false ), - bLastOutlineState( FALSE ), + m_bLastOutlineState( false ), + m_bNotifiable( false ), //nOutlineLevel( pTxtColl->GetOutlineLevel() )//#outline level, removed by zhaojianwei. // --> OD 2008-11-19 #i70748# mbEmptyListStyleSetDueToSetOutlineLevelAttr( false ), @@ -263,26 +258,26 @@ SwTxtNode::SwTxtNode( const SwNodeIndex &rWhere, // <-- GetNodes().UpdateOutlineNode(*this); - bNotifiable = true; + m_bNotifiable = true; - bContainsHiddenChars = bHiddenCharsHidePara = FALSE; - bRecalcHiddenCharFlags = TRUE; + m_bContainsHiddenChars = m_bHiddenCharsHidePara = false; + m_bRecalcHiddenCharFlags = true; } SwTxtNode::~SwTxtNode() { // delete loescht nur die Pointer, nicht die Arrayelemente! - if( pSwpHints ) + if ( m_pSwpHints ) { // damit Attribute die ihren Inhalt entfernen nicht doppelt // geloescht werden. - SwpHints* pTmpHints = pSwpHints; - pSwpHints = 0; + SwpHints* pTmpHints = m_pSwpHints; + m_pSwpHints = 0; for( USHORT j = pTmpHints->Count(); j; ) // erst muss das Attribut aus dem Array entfernt werden, // denn sonst wuerde es sich selbst loeschen (Felder) !!!! - DestroyAttr( pTmpHints->GetHt( --j ) ); + DestroyAttr( pTmpHints->GetTextHint( --j ) ); delete pTmpHints; } @@ -308,7 +303,7 @@ SwCntntFrm *SwTxtNode::MakeFrm() xub_StrLen SwTxtNode::Len() const { - return aText.Len(); + return m_Text.Len(); } /*--------------------------------------------------------------------------- @@ -330,7 +325,8 @@ void lcl_ChangeFtnRef( SwTxtNode &rNode ) SwFtnFrm* pFirstFtnOfNode = 0; for( USHORT j = pSwpHints->Count(); j; ) { - if( RES_TXTATR_FTN == (pHt = pSwpHints->GetHt(--j))->Which() ) + pHt = pSwpHints->GetTextHint(--j); + if (RES_TXTATR_FTN == pHt->Which()) { if( !pFrm ) { @@ -395,9 +391,21 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) { // lege den Node "vor" mir an xub_StrLen nSplitPos = rPos.nContent.GetIndex(); - xub_StrLen nTxtLen = aText.Len(); + xub_StrLen nTxtLen = m_Text.Len(); SwTxtNode* pNode = _MakeNewTxtNode( rPos.nNode, FALSE, nSplitPos==nTxtLen ); + // the first paragraph gets the XmlId, + // _except_ if it is empty and the second is not empty + if (nSplitPos != 0) { + pNode->RegisterAsCopyOf(*this, true); + if (nSplitPos == nTxtLen) + { + this->RemoveMetadataReference(); + // NB: SwUndoSplitNode will call pNode->JoinNext, + // which is sufficient even in this case! + } + } + // --> OD 2008-03-27 #refactorlists# // // --> OD 2007-07-09 #i77372# // // reset numbering attribute at current node, only if it is numbered. @@ -417,7 +425,7 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) } // <-- - if( GetDepends() && aText.Len() && (nTxtLen / 2) < nSplitPos ) + if ( GetDepends() && m_Text.Len() && (nTxtLen / 2) < nSplitPos ) { // JP 25.04.95: Optimierung fuer SplitNode: // Wird am Ende vom Node gesplittet, dann verschiebe die @@ -428,11 +436,9 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) // werden FlyFrames mit verschoben, so muessen diese nicht ihre // Frames zerstoeren. Im SwTxtFly::SetAnchor wird es abgefragt! - if( pSwpHints ) + if ( HasHints() ) { - if( !pNode->pSwpHints ) - pNode->pSwpHints = new SwpHints; - pNode->pSwpHints->bInSplitNode = TRUE; + pNode->GetOrCreateSwpHints().SetInSplitNode(true); } //Ersten Teil des Inhalts in den neuen Node uebertragen und @@ -455,35 +461,41 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) pNode->SetSmartTags( GetSmartTags()->SplitList( nSplitPos ) ); SetSmartTagDirty( true ); - if( pNode->pSwpHints ) + if ( pNode->HasHints() ) { - if ( pNode->pSwpHints->CanBeDeleted() ) + if ( pNode->m_pSwpHints->CanBeDeleted() ) { - delete pNode->pSwpHints; - pNode->pSwpHints = 0; + delete pNode->m_pSwpHints; + pNode->m_pSwpHints = 0; } else - pNode->pSwpHints->bInSplitNode = FALSE; + { + pNode->m_pSwpHints->SetInSplitNode(false); + } // alle zeichengebundenen Rahmen, die im neuen Absatz laden // muessen aus den alten Frame entfernt werden: // JP 01.10.96: alle leeren und nicht zu expandierenden // Attribute loeschen - if( pSwpHints ) + if ( HasHints() ) { SwTxtAttr* pHt; xub_StrLen* pEnd; - for( USHORT j = pSwpHints->Count(); j; ) - if( RES_TXTATR_FLYCNT == - ( pHt = pSwpHints->GetHt( --j ) )->Which() ) + for ( USHORT j = m_pSwpHints->Count(); j; ) + { + 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 ) { - // loeschen! - pSwpHints->DeleteAtPos( j ); + // delete it! + m_pSwpHints->DeleteAtPos( j ); DestroyAttr( pHt ); } + } } } @@ -531,8 +543,10 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) pNode->SwModify::Modify( 0, &aHint ); } } - if( pSwpHints ) + if ( HasHints() ) + { MoveTxtAttr_To_AttrSet(); + } pNode->MakeFrms( *this ); // neue Frames anlegen. lcl_ChangeFtnRef( *this ); } @@ -558,18 +572,21 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) // JP 01.10.96: alle leeren und nicht zu expandierenden // Attribute loeschen - if( pSwpHints ) + if ( HasHints() ) { SwTxtAttr* pHt; xub_StrLen* pEnd; - for( USHORT j = pSwpHints->Count(); j; ) - if( ( pHt = pSwpHints->GetHt( --j ) )->DontExpand() && - 0 != ( pEnd = pHt->GetEnd() ) && *pHt->GetStart() == *pEnd ) + for ( USHORT j = m_pSwpHints->Count(); j; ) + { + pHt = m_pSwpHints->GetTextHint( --j ); + pEnd = pHt->GetEnd(); + if ( pHt->DontExpand() && pEnd && (*pHt->GetStart() == *pEnd) ) { - // loeschen! - pSwpHints->DeleteAtPos( j ); + // delete it! + m_pSwpHints->DeleteAtPos( j ); DestroyAttr( pHt ); } + } MoveTxtAttr_To_AttrSet(); } @@ -612,10 +629,10 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) void SwTxtNode::MoveTxtAttr_To_AttrSet() { - ASSERT( pSwpHints, "MoveTxtAttr_To_AttrSet without SwpHints?" ); - for( USHORT i = 0; pSwpHints && i < pSwpHints->Count(); ++i ) + ASSERT( m_pSwpHints, "MoveTxtAttr_To_AttrSet without SwpHints?" ); + for ( USHORT i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { - SwTxtAttr *pHt = pSwpHints->GetHt(i); + SwTxtAttr *pHt = m_pSwpHints->GetTextHint(i); if( *pHt->GetStart() ) break; @@ -625,13 +642,13 @@ void SwTxtNode::MoveTxtAttr_To_AttrSet() if( !pHtEndIdx ) continue; - if( *pHtEndIdx < aText.Len() || pHt->IsCharFmtAttr() ) + if ( *pHtEndIdx < m_Text.Len() || pHt->IsCharFmtAttr() ) break; if( !pHt->IsDontMoveAttr() && SetAttr( pHt->GetAttr() ) ) { - pSwpHints->DeleteAtPos(i); + m_pSwpHints->DeleteAtPos(i); DestroyAttr( pHt ); --i; } @@ -649,7 +666,10 @@ SwCntntNode *SwTxtNode::JoinNext() SvULongs aBkmkArr( 15, 15 ); _SaveCntntIdx( pDoc, aIdx.GetIndex(), USHRT_MAX, aBkmkArr, SAVEFLY ); SwTxtNode *pTxtNode = aIdx.GetNode().GetTxtNode(); - xub_StrLen nOldLen = aText.Len(); + xub_StrLen nOldLen = m_Text.Len(); + + // METADATA: merge + this->JoinMetadatable(*pTxtNode, !this->Len(), !pTxtNode->Len()); SwWrongList *pList = GetWrong(); if( pList ) @@ -857,7 +877,7 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, SetAutoCompleteWordDirty( TRUE ); TmpHints* pCollector = NULL; - if( pSwpHints ) + if ( HasHints() ) { xub_StrLen nPos = aPos.GetIndex(); xub_StrLen* pIdx; @@ -865,10 +885,10 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, if( bNegativ ) { xub_StrLen nMax = nPos + nLen; - for( USHORT n = 0; n < pSwpHints->Count(); ++n ) + for ( USHORT n = 0; n < m_pSwpHints->Count(); ++n ) { BOOL bSttBefore = FALSE; - pHt = pSwpHints->GetHt(n); + pHt = m_pSwpHints->GetTextHint(n); pIdx = pHt->GetStart(); if( *pIdx >= nPos ) { @@ -898,7 +918,7 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, } } - pSwpHints->MergePortions( *this ); + m_pSwpHints->MergePortions( *this ); } else { @@ -913,17 +933,20 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, BOOL aDontExp[ coArrSz ]; memset( &aDontExp, 0, coArrSz * sizeof(BOOL) ); - for( USHORT n = 0; n < pSwpHints->Count(); ++n ) + for ( USHORT n = 0; n < m_pSwpHints->Count(); ++n ) { - pHt = pSwpHints->GetHt(n); + pHt = m_pSwpHints->GetTextHint(n); pIdx = pHt->GetStart(); - if( *pIdx >= nPos ) + pEnd = pHt->GetEnd(); + if ( *pIdx >= nPos ) { *pIdx = *pIdx + nLen; - if( 0 != ( pEnd = pHt->GetEnd() ) ) + if ( pEnd ) + { *pEnd = *pEnd + nLen; + } } - else if( 0 != ( pEnd = pHt->GetEnd() ) && *pEnd >= nPos ) + else if ( pEnd && *pEnd >= nPos ) { if( *pEnd > nPos || IsIgnoreDontExpand() ) { @@ -933,16 +956,19 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, { USHORT nWhPos, nWhich = pHt->Which(); - if( RES_CHRATR_BEGIN <= nWhich && - nWhich < RES_TXTATR_WITHEND_END ) - nWhPos = static_cast<USHORT>(nWhich - RES_CHRATR_BEGIN); - else if( RES_UNKNOWNATR_BEGIN <= nWhich && - nWhich < RES_UNKNOWNATR_END ) + if (isCHRATR(nWhich) || isTXTATR_WITHEND(nWhich)) + { + nWhPos = static_cast<USHORT>(nWhich - + RES_CHRATR_BEGIN); + } + else if (isUNKNOWNATR(nWhich)) + { nWhPos = static_cast<USHORT>( - nWhich - - static_cast<USHORT>(RES_UNKNOWNATR_BEGIN) + - static_cast<USHORT>(RES_TXTATR_WITHEND_END) - - static_cast<USHORT>(RES_CHRATR_BEGIN) ); + nWhich - + static_cast<USHORT>(RES_UNKNOWNATR_BEGIN) + + static_cast<USHORT>(RES_TXTATR_WITHEND_END) - + static_cast<USHORT>(RES_CHRATR_BEGIN) ); + } else continue; @@ -991,7 +1017,9 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, } } if( bResort ) - ((SwpHintsArr*)pSwpHints)->Resort(); + { + m_pSwpHints->Resort(); + } } } @@ -1055,7 +1083,9 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, { USHORT nCount = pCollector->Count(); for( USHORT i = 0; i < nCount; ++i ) - pSwpHints->Insert( (*pCollector)[ i ], *this, FALSE ); + { + m_pSwpHints->Insert( (*pCollector)[ i ], *this, FALSE ); + } delete pCollector; } @@ -1112,21 +1142,23 @@ void SwTxtNode::_ChgTxtCollUpdateNum( const SwTxtFmtColl *pOldColl, // Wenn man sich genau am Ende einer Text- bzw. INetvorlage befindet, // bekommt diese das DontExpand-Flag verpasst -BOOL SwTxtNode::DontExpandFmt( const SwIndex& rIdx, BOOL bFlag, +BOOL SwTxtNode::DontExpandFmt( const SwIndex& rIdx, bool bFlag, BOOL bFmtToTxtAttributes ) { const xub_StrLen nIdx = rIdx.GetIndex(); - if( bFmtToTxtAttributes && nIdx == aText.Len() ) + if ( bFmtToTxtAttributes && nIdx == m_Text.Len() ) + { FmtToTxtAttr( this ); + } BOOL bRet = FALSE; - if( pSwpHints ) + if ( HasHints() ) { - const USHORT nEndCnt = pSwpHints->GetEndCount(); + const USHORT nEndCnt = m_pSwpHints->GetEndCount(); USHORT nPos = nEndCnt; while( nPos ) { - SwTxtAttr *pTmp = pSwpHints->GetEnd( --nPos ); + SwTxtAttr *pTmp = m_pSwpHints->GetEnd( --nPos ); xub_StrLen *pEnd = pTmp->GetEnd(); if( !pEnd || *pEnd > nIdx ) continue; @@ -1136,7 +1168,7 @@ BOOL SwTxtNode::DontExpandFmt( const SwIndex& rIdx, BOOL bFlag, && *pEnd > *pTmp->GetStart()) { bRet = TRUE; - pSwpHints->NoteInHistory( pTmp ); + m_pSwpHints->NoteInHistory( pTmp ); pTmp->SetDontExpand( bFlag ); } } @@ -1158,12 +1190,13 @@ SwTxtAttr* SwTxtNode::GetTxtAttr( const SwIndex& rIdx, USHORT nWhichHt, const SwTxtAttr* pHt = 0; const xub_StrLen *pEndIdx = 0; const xub_StrLen nIdx = rIdx.GetIndex(); - const USHORT nSize = pSwpHints ? pSwpHints->Count() : 0; + const USHORT nSize = m_pSwpHints ? m_pSwpHints->Count() : 0; for( USHORT i = 0; i < nSize; ++i ) { // ist der Attribut-Anfang schon groesser als der Idx ? - if( nIdx < *((pHt = (*pSwpHints)[i])->GetStart()) ) + pHt = (*m_pSwpHints)[i]; + if ( nIdx < *(pHt->GetStart()) ) break; // beenden, kein gueltiges Attribut // ist es das gewuenschte Attribut ? @@ -1323,7 +1356,7 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, const xub_StrLen nOldPos ) { - if( pSwpHints ) // keine Attribute, keine Kekse + if ( HasHints() ) // keine Attribute, keine Kekse { const xub_StrLen *pEndIdx = 0; const SwTxtAttr *pHt = 0; @@ -1335,9 +1368,9 @@ void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, if( pOtherDoc == GetDoc() ) pOtherDoc = 0; - for( USHORT i = 0; i < pSwpHints->Count(); i++ ) + for ( USHORT i = 0; i < m_pSwpHints->Count(); i++ ) { - pHt = (*pSwpHints)[i]; + pHt = (*m_pSwpHints)[i]; if( nTxtStartIdx < ( nAttrStartIdx = *pHt->GetStart() ) ) break; // ueber das Textende, da nLen == 0 @@ -1385,7 +1418,7 @@ void SwTxtNode::Copy( SwTxtNode *pDest, xub_StrLen nLen, const bool bForceCopyOfAllAttrs ) { - SwIndex aIdx( pDest, pDest->aText.Len() ); + SwIndex aIdx( pDest, pDest->m_Text.Len() ); Copy( pDest, aIdx, rStart, nLen, bForceCopyOfAllAttrs ); } // <-- @@ -1436,16 +1469,16 @@ void SwTxtNode::Copy( SwTxtNode *pDest, } // 1. Text kopieren - xub_StrLen i = pDest->aText.Len() - nDestStart; + xub_StrLen i = pDest->m_Text.Len() - nDestStart; //JP 15.02.96: Bug 25537 - Attributbehandlung am Ende fehlt! Darum // ueber die InsertMethode den Text einfuegen und nicht // selbst direkt - pDest->Insert( aText.Copy( nTxtStartIdx, nLen ), rDestStart, - INS_EMPTYEXPAND ); + pDest->Insert( m_Text.Copy( nTxtStartIdx, nLen ), rDestStart, + INS_EMPTYEXPAND ); // um reale Groesse Updaten ! - nLen = pDest->aText.Len() - nDestStart - i; - if( !nLen ) // String nicht gewachsen ?? + nLen = pDest->m_Text.Len() - nDestStart - i; + if ( !nLen ) // string not longer? return; i = 0; @@ -1494,7 +1527,8 @@ void SwTxtNode::Copy( SwTxtNode *pDest, // 2. Attribute kopieren // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu kopierenden Bereich liegt - USHORT nWhich, nSize = pSwpHints ? pSwpHints->Count() : 0; + USHORT nWhich; + USHORT nSize = m_pSwpHints ? m_pSwpHints->Count() : 0; xub_StrLen nAttrStt, nAttrEnd; // wird in sich selbst kopiert, dann kann beim Einfuegen ein @@ -1506,10 +1540,10 @@ void SwTxtNode::Copy( SwTxtNode *pDest, SwpHts aRefMrkArr; //Achtung: kann ungueltig sein!! - while( ( i < nSize ) && - ((nAttrStartIdx = *(*pSwpHints)[i]->GetStart()) < nEnd) ) + while ( ( i < nSize ) && + ((nAttrStartIdx = *(*m_pSwpHints)[i]->GetStart()) < nEnd) ) { - pHt = (*pSwpHints)[i]; + pHt = (*m_pSwpHints)[i]; pNewHt = 0; pEndIdx = pHt->GetEnd(); nWhich = pHt->Which(); @@ -1645,14 +1679,14 @@ void SwTxtNode::Copy( SwTxtNode *pDest, SwTxtNode& SwTxtNode::Insert( const XubString &rStr, const SwIndex &rIdx, const USHORT nMode ) { - ASSERT( rIdx <= aText.Len(), "Array ueberindiziert." ); - ASSERT( (ULONG)aText.Len() + (ULONG)rStr.Len() <= STRING_LEN, - "STRING_LEN ueberschritten." ); + ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::Insert: invalid index." ); + ASSERT( (ULONG)m_Text.Len() + (ULONG)rStr.Len() <= STRING_LEN, + "SwTxtNode::Insert: node text with insertion > STRING_LEN." ); xub_StrLen aPos = rIdx.GetIndex(); - xub_StrLen nLen = aText.Len() - aPos; - aText.Insert( rStr, aPos ); - nLen = aText.Len() - aPos - nLen; + 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 ! @@ -1663,12 +1697,12 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, USHORT i; - if( pSwpHints ) + if ( HasHints() ) { - for( i = 0; i < pSwpHints->Count() && - rIdx >= *(*pSwpHints)[i]->GetStart(); ++i ) + for ( i = 0; i < m_pSwpHints->Count() && + rIdx >= *(*m_pSwpHints)[i]->GetStart(); ++i ) { - SwTxtAttr *pHt = pSwpHints->GetHt( i ); + SwTxtAttr *pHt = m_pSwpHints->GetTextHint( i ); xub_StrLen* pEndIdx = pHt->GetEnd(); if( !pEndIdx ) continue; @@ -1681,7 +1715,7 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, if( rIdx == *pHt->GetStart() ) *pHt->GetStart() = *pHt->GetStart() - nLen; *pEndIdx = *pEndIdx - nLen; - pSwpHints->DeleteAtPos(i); + m_pSwpHints->DeleteAtPos(i); Insert( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); } // leere Hints an rIdx.GetIndex ? @@ -1689,11 +1723,13 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, *pEndIdx == *pHt->GetStart() ) { *pHt->GetStart() = *pHt->GetStart() - nLen; - const USHORT nAktLen = pSwpHints->Count(); - pSwpHints->DeleteAtPos(i); + const USHORT nAktLen = m_pSwpHints->Count(); + m_pSwpHints->DeleteAtPos(i); Insert( pHt/* AUTOSTYLES:, nsSetAttrMode::SETATTR_NOHINTADJUST*/ ); - if( nAktLen > pSwpHints->Count() && i ) + if ( nAktLen > m_pSwpHints->Count() && i ) + { --i; + } continue; } else @@ -1706,13 +1742,12 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, !pHt->IsDontExpandStartAttr() ) { // Kein Feld, am Absatzanfang, HintExpand - pSwpHints->DeleteAtPos(i); + m_pSwpHints->DeleteAtPos(i); *pHt->GetStart() = *pHt->GetStart() - nLen; Insert( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); } } - if ( pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); } if ( GetDepends() ) @@ -1778,7 +1813,7 @@ 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->aText.Len(); + xub_StrLen nInitSize = pDest->m_Text.Len(); xub_StrLen *pEndIdx = 0; xub_StrLen nAttrStartIdx = 0; @@ -1788,8 +1823,8 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, // wird in sich selbst verschoben, muss es gesondert behandelt werden !! if( pDest == this ) { - aText.Insert( aText, nTxtStartIdx, nLen, nDestStart ); - aText.Erase( nTxtStartIdx + (nDestStart<nTxtStartIdx ? nLen : 0), nLen ); + 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; @@ -1804,8 +1839,8 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu verschiebenden Bereich liegt USHORT nAttrCnt = 0, nWhich; - while( pSwpHints && nAttrCnt < pSwpHints->Count() && - (nAttrStartIdx = *(pHt = pSwpHints->GetHt(nAttrCnt))-> + while ( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() && + (nAttrStartIdx = *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))-> GetStart()) < nEnd ) { pNewHt = 0; @@ -1831,7 +1866,7 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, if( !pEndIdx || *pEndIdx < nEnd ) { // Attribut verschieben - pSwpHints->Delete( pHt ); + m_pSwpHints->Delete( pHt ); // die Start/End Indicies neu setzen *pHt->GetStart() = nAttrStartIdx - nTxtStartIdx; if( pEndIdx ) @@ -1865,16 +1900,18 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, #ifdef CUTNOEXPAND else // wird am Ende eingefuegt, nur die Attribut-Indizies verschieben - if( 0 < nLen && 0 < nInitSize && pSwpHints ) + if ( 0 < nLen && 0 < nInitSize && m_pSwpHints ) { - // siehe nach, ob an der Einfuegeposition das Ende eines - // Attributes stand. Ist es kein Feld, muss es expandiert werden !!! - for( n = 0; n < pSwpHints->Count(); n++ ) + // 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++ ) { - pHt = pSwpHints->GetHt(n); - if( 0 != ( pEndIdx = pHt->GetEnd() ) && - *pEndIdx == nInitSize ) + pHt = m_pSwpHints->GetTextHint(n); + pEndIdx = pHt->GetEnd(); + if ( pEndIdx && (*pEndIdx == nInitSize) ) + { *pEndIdx = *pEndIdx + nLen; + } } } #endif @@ -1902,9 +1939,9 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, else { xub_StrLen i = nInitSize - nDestStart; - pDest->aText.Insert( aText, nTxtStartIdx, nLen, nDestStart ); - aText.Erase( nTxtStartIdx, nLen ); - nLen = pDest->aText.Len() - nDestStart - i; // um reale Groesse Updaten ! + 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! if( !nLen ) // String nicht gewachsen ?? return; @@ -1916,16 +1953,18 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, #ifdef CUTNOEXPAND else // wird am Ende eingefuegt, nur die Attribut-Indizies verschieben - if( 0 < nLen && 0 < nInitSize && pDest->pSwpHints ) + if ( 0 < nLen && 0 < nInitSize && pDest->m_pSwpHints ) { - // siehe nach, ob an der Einfuegeposition das Ende eines - // Attributes stand. Ist es kein Feld, muss es expandiert werden !!! - for( USHORT n = 0; n < pDest->pSwpHints->Count(); n++ ) + // check if there was the end of an attribute at the insertion + // position: if it is not a field, it must be expanded + for ( USHORT n = 0; n < pDest->m_pSwpHints->Count(); n++ ) { - pHt = pDest->pSwpHints->GetHt(n); - if( 0 != ( pEndIdx = pHt->GetEnd() ) && - *pEndIdx == nInitSize ) + pHt = pDest->m_pSwpHints->GetTextHint(n); + pEndIdx = pHt->GetEnd(); + if ( pEndIdx && (*pEndIdx == nInitSize) ) + { *pEndIdx = *pEndIdx + nLen; + } } } #endif @@ -1962,8 +2001,8 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu verschiebenden Bereich liegt USHORT nAttrCnt = 0, nWhich; - while( pSwpHints && nAttrCnt < pSwpHints->Count() && - ( (nAttrStartIdx = *(pHt = pSwpHints->GetHt(nAttrCnt))-> + while ( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() && + ( (nAttrStartIdx = *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))-> GetStart()) < nEnd ) ) { pNewHt = 0; @@ -1996,7 +2035,7 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, if ( GetDoc()->GetDocShell() ) GetDoc()->GetDocShell()->Broadcast( SfxSimpleHint(SFX_HINT_USER04)); // Attribut verschieben - pSwpHints->Delete( pHt ); + m_pSwpHints->Delete( pHt ); // die Start/End Indicies neu setzen *pHt->GetStart() = nDestStart + (nAttrStartIdx - nTxtStartIdx); @@ -2032,17 +2071,18 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, // eine hoehere Praezedenz. Also herausholen und das Array updaten. // Die dabei entstehenden leeren Hints werden von den gesicherten // "uebergeplaettet". (Bug: 6977) - if( pSwpHints && nAttrCnt < pSwpHints->Count() ) + if( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() ) { SwpHts aArr( 5 ); - for( ; nAttrCnt < pSwpHints->Count() && - nEnd == *(pHt = pSwpHints->GetHt(nAttrCnt))->GetStart(); + for ( ; nAttrCnt < m_pSwpHints->Count() && + nEnd == *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))->GetStart(); ++nAttrCnt ) { - if( 0 != ( pEndIdx = pHt->GetEnd() ) && *pEndIdx == nEnd ) + pEndIdx = pHt->GetEnd(); + if ( pEndIdx && *pEndIdx == nEnd ) { aArr.C40_INSERT( SwTxtAttr, pHt, aArr.Count() ); - pSwpHints->Delete( pHt ); + m_pSwpHints->Delete( pHt ); --nAttrCnt; } } @@ -2061,8 +2101,7 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, CHECK_SWPHINTS(this); } - if( pSwpHints && pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); // Frames benachrichtigen; SwInsTxt aInsHint( nDestStart, nLen ); @@ -2075,22 +2114,21 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, SwTxtNode& SwTxtNode::Erase(const SwIndex &rIdx, xub_StrLen nCount, const USHORT nMode ) { - ASSERT( rIdx <= aText.Len(), "Array ueberindiziert." ); + ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::Erase: invalid index." ); const xub_StrLen nCnt = STRING_LEN == nCount - ? aText.Len() - rIdx.GetIndex() : nCount; - aText.Erase( rIdx.GetIndex(), nCnt ); + ? m_Text.Len() - rIdx.GetIndex() : nCount; + m_Text.Erase( rIdx.GetIndex(), 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 */ - // Abfrage auf pSwpHints weil TextFelder und FlyFrames Text loeschen - // (Rekursion)!! - for( USHORT i = 0; pSwpHints && i < pSwpHints->Count(); ++i ) + // check m_pSwpHints because fields and FlyFrames delete text (recursion!) + for ( USHORT i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { - SwTxtAttr *pHt = pSwpHints->GetHt(i); + SwTxtAttr *pHt = m_pSwpHints->GetTextHint(i); const xub_StrLen nHtStt = *pHt->GetStart(); @@ -2109,11 +2147,10 @@ SwTxtNode& SwTxtNode::Erase(const SwIndex &rIdx, xub_StrLen nCount, if( !pHtEndIdx ) { - // TxtHints ohne EndIndex werden natuerlich auch geloescht: - if( RES_TXTATR_BEGIN <= nWhich && RES_TXTATR_END > nWhich && - nHtStt >= rIdx.GetIndex() && nHtStt < nEndIdx ) + if (isTXTATR(nWhich) && + (nHtStt >= rIdx.GetIndex()) && (nHtStt < nEndIdx)) { - pSwpHints->DeleteAtPos(i); + m_pSwpHints->DeleteAtPos(i); // Damit im Dtor der TxtAttr ohne End die CH_TXTATR nicht // geloescht werden... *(pHt->GetStart()) = USHRT_MAX; @@ -2140,13 +2177,12 @@ SwTxtNode& SwTxtNode::Erase(const SwIndex &rIdx, xub_StrLen nCount, ) continue; - pSwpHints->DeleteAtPos(i); + m_pSwpHints->DeleteAtPos(i); DestroyAttr( pHt ); --i; } - if ( pSwpHints && pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); Update( rIdx, nCnt, TRUE ); @@ -2182,20 +2218,20 @@ SwTxtNode& SwTxtNode::Erase(const SwIndex &rIdx, xub_StrLen nCount, void SwTxtNode::GCAttr() { - if ( !pSwpHints ) + if ( !HasHints() ) return; const SwTxtAttr *pHt = 0; const xub_StrLen *pEndIdx = 0; BOOL bChanged = FALSE; - USHORT nMin = aText.Len(), + USHORT nMin = m_Text.Len(), nMax = 0; BOOL bAll = nMin != 0; // Bei leeren Absaetzen werden nur die // INet-Formate entfernt. - for ( USHORT i = 0; pSwpHints && i < pSwpHints->Count(); ++i ) + for ( USHORT i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { - pHt = (*pSwpHints)[i]; + pHt = (*m_pSwpHints)[i]; // wenn Ende und Start gleich sind --> loeschen pEndIdx = pHt->GetEnd(); @@ -2205,14 +2241,13 @@ void SwTxtNode::GCAttr() bChanged = TRUE; nMin = Min( nMin, *pHt->GetStart() ); nMax = Max( nMax, *pHt->GetEnd() ); - DestroyAttr( pSwpHints->Cut(i) ); + DestroyAttr( m_pSwpHints->Cut(i) ); --i; } else ((SwTxtAttr*)pHt)->SetDontExpand( FALSE ); } - if ( pSwpHints && pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); if(bChanged) { @@ -2584,11 +2619,11 @@ SwCntntNode* SwTxtNode::AppendNode( const SwPosition & rPos ) SwTxtAttr *SwTxtNode::GetTxtAttr( const xub_StrLen nIdx, const USHORT nWhichHt ) const { - if( pSwpHints ) + if ( HasHints() ) { - for( USHORT i = 0; i < pSwpHints->Count(); ++i ) + for ( USHORT i = 0; i < m_pSwpHints->Count(); ++i ) { - SwTxtAttr *pPos = pSwpHints->GetHt(i); + SwTxtAttr *pPos = m_pSwpHints->GetTextHint(i); const xub_StrLen nStartPos = *pPos->GetStart(); if( nIdx < nStartPos ) return 0; @@ -2937,12 +2972,12 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, nLen = aDestIdx.GetIndex() - nDestStt; // alle FontAttribute mit CHARSET Symbol in dem Bereich setzen - if( pSwpHints ) + if ( HasHints() ) { xub_StrLen nInsPos = nDestStt - nIdx; - for( USHORT i = 0; i < pSwpHints->Count(); i++ ) + for ( USHORT i = 0; i < m_pSwpHints->Count(); i++ ) { - const SwTxtAttr* pHt = (*pSwpHints)[i]; + const SwTxtAttr* pHt = (*m_pSwpHints)[i]; xub_StrLen nAttrStartIdx; USHORT nWhich = pHt->Which(); if( nIdx + nLen <= ( nAttrStartIdx = *pHt->GetStart() ) ) @@ -2982,7 +3017,7 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, break; case RES_TXTATR_HARDBLANK: - rDestNd.aText.SetChar( nInsPos + nAttrStartIdx, + rDestNd.m_Text.SetChar( nInsPos + nAttrStartIdx, ((SwTxtHardBlank*)pHt)->GetChar() ); break; @@ -3059,12 +3094,12 @@ const ModelToViewHelper::ConversionMap* rRetText = rNodeText; ModelToViewHelper::ConversionMap* pConversionMap = 0; - SwpHints* pSwpHints2 = const_cast<SwTxtNode*>(this)->GetpSwpHints(); + const SwpHints* pSwpHints2 = GetpSwpHints(); xub_StrLen nPos = 0; for ( USHORT i = 0; pSwpHints2 && i < pSwpHints2->Count(); ++i ) { - const SwTxtAttr* pAttr = pSwpHints2->GetHt(i); + const SwTxtAttr* pAttr = (*pSwpHints2)[i]; if ( RES_TXTATR_FIELD == pAttr->Which() ) { const XubString aExpand( ((SwTxtFld*)pAttr)->GetFld().GetFld()->Expand() ); @@ -3168,18 +3203,21 @@ XubString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen, void SwTxtNode::Replace( const SwIndex& rStart, xub_Unicode cCh ) { + ASSERT( rStart.GetIndex() < m_Text.Len(), + "SwTxtNode::Replace: invalid index." ); - ASSERT( rStart.GetIndex() < aText.Len(), "ausserhalb des Strings" ); SwTxtAttr* pHt; - if( ( CH_TXTATR_BREAKWORD == aText.GetChar( rStart.GetIndex() ) || - CH_TXTATR_INWORD == aText.GetChar( rStart.GetIndex() )) && + if ( ( CH_TXTATR_BREAKWORD == m_Text.GetChar( rStart.GetIndex() ) || + CH_TXTATR_INWORD == m_Text.GetChar( rStart.GetIndex() )) && 0 != ( pHt = GetTxtAttr( rStart.GetIndex() ) )) { Delete( pHt ); - aText.Insert( cCh, rStart.GetIndex() ); + m_Text.Insert( cCh, rStart.GetIndex() ); } else - aText.SetChar( rStart.GetIndex(), cCh ); + { + m_Text.SetChar( rStart.GetIndex(), cCh ); + } SwDelTxt aDelHint( rStart.GetIndex(), 1 ); SwModify::Modify( 0, &aDelHint ); @@ -3192,22 +3230,24 @@ void SwTxtNode::Replace( const SwIndex& rStart, xub_Unicode cCh ) void SwTxtNode::Replace( const SwIndex& rStart, xub_StrLen nLen, const XubString& rText ) { - ASSERT( rStart.GetIndex() < aText.Len() && - rStart.GetIndex() + nLen <= aText.Len(), + ASSERT( rStart.GetIndex() < m_Text.Len() && + rStart.GetIndex() + nLen <= m_Text.Len(), "ausserhalb des Strings" ); SwTxtAttr* pHt; const xub_StrLen nStartPos = rStart.GetIndex(); xub_StrLen nEnde = nStartPos + nLen; xub_StrLen nDelLen = nLen; for( xub_StrLen nPos = nStartPos; nPos < nEnde; ++nPos ) - if( ( CH_TXTATR_BREAKWORD == aText.GetChar( nPos ) || - CH_TXTATR_INWORD == aText.GetChar( nPos )) && + { + if ( ( CH_TXTATR_BREAKWORD == m_Text.GetChar( nPos ) || + CH_TXTATR_INWORD == m_Text.GetChar( nPos )) && 0 != ( pHt = GetTxtAttr( nPos ) )) { Delete( pHt ); --nEnde; --nLen; } + } BOOL bOldExpFlg = IsIgnoreDontExpand(); SetIgnoreDontExpand( TRUE ); @@ -3216,22 +3256,22 @@ void SwTxtNode::Replace( const SwIndex& rStart, xub_StrLen nLen, { // dann das 1. Zeichen ersetzen den Rest loschen und einfuegen // Dadurch wird die Attributierung des 1. Zeichen expandiert! - aText.SetChar( nStartPos, rText.GetChar( 0 ) ); + m_Text.SetChar( nStartPos, rText.GetChar( 0 ) ); ((SwIndex&)rStart)++; - aText.Erase( rStart.GetIndex(), nLen - 1 ); + m_Text.Erase( rStart.GetIndex(), nLen - 1 ); Update( rStart, nLen - 1, TRUE ); XubString aTmpTxt( rText ); aTmpTxt.Erase( 0, 1 ); - aText.Insert( aTmpTxt, rStart.GetIndex() ); + m_Text.Insert( aTmpTxt, rStart.GetIndex() ); Update( rStart, aTmpTxt.Len(), FALSE ); } else { - aText.Erase( nStartPos, nLen ); + m_Text.Erase( nStartPos, nLen ); Update( rStart, nLen, TRUE ); - aText.Insert( rText, nStartPos ); + m_Text.Insert( rText, nStartPos ); Update( rStart, rText.Len(), FALSE ); } SetIgnoreDontExpand( bOldExpFlg ); @@ -3467,8 +3507,8 @@ namespace { void SwTxtNode::Modify( SfxPoolItem* pOldValue, SfxPoolItem* pNewValue ) { - bool bWasNotifiable = bNotifiable; - bNotifiable = false; + bool bWasNotifiable = m_bNotifiable; + m_bNotifiable = false; // Bug 24616/24617: // Modify ueberladen, damit beim Loeschen von Vorlagen diese @@ -3501,7 +3541,7 @@ void SwTxtNode::Modify( SfxPoolItem* pOldValue, SfxPoolItem* pNewValue ) pDoc->GetNodes().UpdateOutlineNode(*this); } - bNotifiable = bWasNotifiable; + m_bNotifiable = bWasNotifiable; } SwFmtColl* SwTxtNode::ChgFmtColl( SwFmtColl *pNewColl ) @@ -3583,9 +3623,9 @@ SwNumberTree::tNumberVector SwTxtNode::GetNumberVector() const } } -BOOL SwTxtNode::IsOutline() const +bool SwTxtNode::IsOutline() const { - BOOL bResult = FALSE; + bool bResult = false; //if ( GetOutlineLevel() != NO_NUMBERING )//#outline level,removed by zhaojianwei if ( GetAttrOutlineLevel() > 0 ) //<-end,zhaojianwei @@ -3604,14 +3644,14 @@ BOOL SwTxtNode::IsOutline() const return bResult; } -BOOL SwTxtNode::IsOutlineStateChanged() const +bool SwTxtNode::IsOutlineStateChanged() const { - return IsOutline() != bLastOutlineState; + return IsOutline() != m_bLastOutlineState; } void SwTxtNode::UpdateOutlineState() { - bLastOutlineState = IsOutline(); + m_bLastOutlineState = IsOutline(); } //#outline level, zhaojianwei @@ -3823,7 +3863,7 @@ SwNumberTree::tSwNumTreeNumber SwTxtNode::GetActualListStartValue() const bool SwTxtNode::IsNotifiable() const { - return bNotifiable && IsNotificationEnabled(); + return m_bNotifiable && IsNotificationEnabled(); } bool SwTxtNode::IsNotificationEnabled() const @@ -4846,3 +4886,50 @@ USHORT SwTxtNode::ResetAllAttr() return nRet; } // <-- + + +// sw::Metadatable +::sfx2::IXmlIdRegistry& SwTxtNode::GetRegistry() +{ + return GetDoc()->GetXmlIdRegistry(); +} + +bool SwTxtNode::IsInClipboard() const +{ + return GetDoc()->IsClipBoard(); +} + +bool SwTxtNode::IsInUndo() const +{ + return &GetNodes() == GetDoc()->GetUndoNds(); +} + +bool SwTxtNode::IsInContent() const +{ + return !GetDoc()->IsInHeaderFooter( SwNodeIndex(*this) ); +} + +#include <unoobj.hxx> + +::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > +SwTxtNode::MakeUnoObject() +{ + // re-use existing SwXParagraph + SwClientIter iter( *this ); + SwClient * pClient( iter.First( TYPE( SwXParagraph ) ) ); + while (pClient) { + SwXParagraph *pPara( dynamic_cast<SwXParagraph*>(pClient) ); + if (pPara && pPara->GetCoreObject() == this ) { + return pPara; + } + pClient = iter.Next(); + } + + // create new SwXParagraph + SwPosition Pos( *this ); + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent( + SwXTextRange::CreateParentXText( GetDoc(), Pos ) ); + SwXParagraph * pXPara( new SwXParagraph( xParent, this ) ); + return pXPara; +} + diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 74bb3e87e87e..1b5fc81d366f 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -40,9 +40,7 @@ #include <svtools/stylepool.hxx> #include <svx/fontitem.hxx> #include <svx/langitem.hxx> -#ifndef _SVX_EMPHITEM_HXX //autogen #include <svx/emphitem.hxx> -#endif #include <svx/charscaleitem.hxx> #include <svx/charrotateitem.hxx> // --> OD 2008-01-16 #newlistlevelattrs# @@ -97,6 +95,19 @@ using namespace ::com::sun::star::i18n; + +SwpHints::SwpHints() + : m_pHistory(0) + , m_bFontChange(true) + , m_bInSplitNode(false) + , m_bCalcHiddenParaField(false) + , m_bHasHiddenParaField(false) + , m_bFootnote(false) + , m_bDDEFields(false) +{ +} + + // 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 @@ -138,7 +149,7 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod { for ( USHORT i = 0; i < Count(); ++i ) { - SwTxtAttr* pOther = GetHt(i); + SwTxtAttr* pOther = GetTextHint(i); if ( nWhich == pOther->Which() ) { @@ -152,9 +163,9 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), nOtherStart, nThisStart ); aInsDelHints.push_back( pNewAttr ); - if( pHistory ) pHistory->Add( pOther ); + NoteInHistory( pOther ); *pOther->GetStart() = nThisStart; - if( pHistory ) pHistory->Add( pOther, TRUE ); + NoteInHistory( pOther, true ); nOtherStart = nThisStart; } @@ -162,12 +173,13 @@ 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 = rNode.MakeTxtAttr( pOther->GetAttr(), + nOtherStart, nThisEnd ); aInsDelHints.push_back( pNewAttr ); - if( pHistory ) pHistory->Add( pOther ); + NoteInHistory( pOther ); *pOther->GetStart() = nThisEnd; - if( pHistory ) pHistory->Add( pOther, TRUE ); + NoteInHistory( pOther, true ); } } } @@ -196,8 +208,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod } - SwpHintsArr::Insert( *aIter ); - if ( pHistory ) pHistory->Add( *aIter, TRUE ); + SwpHintsArray::Insert( *aIter ); + NoteInHistory( *aIter, true ); } aInsDelHints.clear(); @@ -206,7 +218,7 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // which are fully covered by the new attribute: for ( USHORT i = 0; i < Count(); ++i ) { - SwTxtAttr* pOther = GetHt(i); + SwTxtAttr* pOther = GetTextHint(i); if ( nWhich == pOther->Which() ) { const xub_StrLen nOtherStart = *pOther->GetStart(); @@ -222,9 +234,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod rNode.DestroyAttr( *aIter ); } - SwpHintsArr::Insert( &rNewHint ); - if ( pHistory ) - pHistory->Add( &rNewHint, TRUE ); + SwpHintsArray::Insert( &rNewHint ); + NoteInHistory( &rNewHint, true ); return; } @@ -241,7 +252,7 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod { for ( USHORT i = 0; i < Count(); ++i ) { - SwTxtAttr* pOther = GetHt(i); + SwTxtAttr* pOther = GetTextHint(i); if ( RES_TXTATR_CHARFMT != pOther->Which() && RES_TXTATR_AUTOFMT != pOther->Which() ) @@ -259,9 +270,9 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod static_cast<SwTxtCharFmt*>(pNewAttr)->SetSortNumber( static_cast<SwTxtCharFmt*>(pOther)->GetSortNumber() ); aInsDelHints.push_back( pNewAttr ); - if( pHistory ) pHistory->Add( pOther ); + NoteInHistory( pOther ); *pOther->GetStart() = nThisStart; - if( pHistory ) pHistory->Add( pOther, TRUE ); + NoteInHistory( pOther, true ); nOtherStart = nThisStart; } @@ -275,17 +286,17 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod static_cast<SwTxtCharFmt*>(pNewAttr)->SetSortNumber( static_cast<SwTxtCharFmt*>(pOther)->GetSortNumber() ); aInsDelHints.push_back( pNewAttr ); - if( pHistory ) pHistory->Add( pOther ); + NoteInHistory( pOther ); *pOther->GetStart() = nThisEnd; - if( pHistory ) pHistory->Add( pOther, TRUE ); + NoteInHistory( pOther, true ); } } // Insert the newly created attributes: for ( aIter = aInsDelHints.begin(); aIter != aInsDelHints.end(); ++aIter ) { - SwpHintsArr::Insert( *aIter ); - if ( pHistory ) pHistory->Add( *aIter, TRUE ); + SwpHintsArray::Insert( *aIter ); + NoteInHistory( *aIter, true ); } } @@ -305,7 +316,7 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod { for ( USHORT i = 0; i < Count(); ++i ) { - const SwTxtAttr* pOther = GetHt(i); + const SwTxtAttr* pOther = GetTextHint(i); if ( RES_TXTATR_CHARFMT != pOther->Which() && RES_TXTATR_AUTOFMT != pOther->Which() ) @@ -338,7 +349,7 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Get all hints that are in [nPorStart, nPorEnd[: for ( USHORT i = 0; i < Count(); ++i ) { - SwTxtAttr *pOther = GetHt(i); + SwTxtAttr *pOther = GetTextHint(i); if ( RES_TXTATR_CHARFMT != pOther->Which() && RES_TXTATR_AUTOFMT != pOther->Which() ) @@ -422,9 +433,10 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Create new AutoStyle if ( aNewSet.Count() ) { - pNewAttr = rNode.MakeTxtAttr( aNewSet, nPorStart, nPorEnd ); - SwpHintsArr::Insert( pNewAttr ); - if ( pHistory ) pHistory->Add( pNewAttr, TRUE ); + pNewAttr = rNode.MakeTxtAttr( aNewSet, + nPorStart, nPorEnd ); + SwpHintsArray::Insert( pNewAttr ); + NoteInHistory( pNewAttr, true ); } } ++aIter; @@ -563,9 +575,9 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod if ( pNewAttr ) { - SwpHintsArr::Insert( pNewAttr ); - if ( pHistory /* && bDestroyHint*/ ) - pHistory->Add( pNewAttr, TRUE ); + SwpHintsArray::Insert( pNewAttr ); +// if ( bDestroyHint ) + NoteInHistory( pNewAttr, true ); } if ( !bNoLengthAttribute ) @@ -585,13 +597,13 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod * SwTxtNode::MakeTxtAttr() *************************************************************************/ - // lege ein neues TextAttribut an und fuege es SwpHints-Array ein +// create new text attribute SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, xub_StrLen nStt, xub_StrLen nEnd, bool bRedlineAttr ) { SwDoc* pDoc = GetDoc(); - if ( !bRedlineAttr && RES_CHRATR_BEGIN <= rAttr.Which () && rAttr.Which() < RES_CHRATR_END ) + if ( !bRedlineAttr && 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 @@ -791,8 +803,8 @@ SwTxtAttr* SwTxtNode::InsertItem( const SfxPoolItem& rAttr, xub_StrLen nStt, xub_StrLen nEnd, USHORT nMode ) { // character attributes will be inserted as automatic styles: - ASSERT( rAttr.Which() < RES_CHRATR_BEGIN || rAttr.Which() >= RES_CHRATR_END, - "AUTOSTYLES - InsertItem should not be called with character attributes" ) + ASSERT( !isCHRATR(rAttr.Which()), "AUTOSTYLES - " + "SwTxtNode::InsertItem should not be called with character attributes"); SwTxtAttr* pNew = MakeTxtAttr( rAttr, nStt, nEnd ); @@ -866,11 +878,11 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) { // loesche das Zeichen aus dem String ! ASSERT( ( CH_TXTATR_BREAKWORD == - aText.GetChar(*pAttr->GetStart() ) || + m_Text.GetChar(*pAttr->GetStart() ) || CH_TXTATR_INWORD == - aText.GetChar(*pAttr->GetStart())), - "where is my attribu character" ); - aText.Erase( *pAttr->GetStart(), 1 ); + m_Text.GetChar(*pAttr->GetStart())), + "where is my attribute character?" ); + m_Text.Erase( *pAttr->GetStart(), 1 ); // Indizies Updaten SwIndex aTmpIdx( this, *pAttr->GetStart() ); Update( aTmpIdx, 1, TRUE ); @@ -904,11 +916,11 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) { // loesche das Zeichen aus dem String ! ASSERT( ( CH_TXTATR_BREAKWORD == - aText.GetChar(*pAttr->GetStart() ) || + m_Text.GetChar(*pAttr->GetStart() ) || CH_TXTATR_INWORD == - aText.GetChar(*pAttr->GetStart())), - "where is my attribu character" ); - aText.Erase( *pAttr->GetStart(), 1 ); + m_Text.GetChar(*pAttr->GetStart())), + "where is my attribute character?" ); + m_Text.Erase( *pAttr->GetStart(), 1 ); // Indizies Updaten SwIndex aTmpIdx( this, *pAttr->GetStart() ); Update( aTmpIdx, 1, TRUE ); @@ -922,7 +934,8 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) if( bNewFtn ) { ((SwTxtFtn*)pAttr)->MakeNewTextSection( GetNodes() ); - SwRegHistory* pHist = GetpSwpHints() ? GetpSwpHints()->getHistory() : 0; + SwRegHistory* pHist = GetpSwpHints() + ? GetpSwpHints()->GetHistory() : 0; if( pHist ) pHist->ChangeNodeIndex( GetIndex() ); } @@ -1014,17 +1027,18 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) ASSERT( *pAttr->GetEnd() <= Len(), "EndIdx hinter Len!" ); } - if ( !pSwpHints ) - pSwpHints = new SwpHints(); + GetOrCreateSwpHints(); // 4263: AttrInsert durch TextInsert => kein Adjust - pSwpHints->Insert( pAttr, *this, nMode ); + m_pSwpHints->Insert( 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 == pSwpHints->GetPos( pAttr ) ) + if ( USHRT_MAX == m_pSwpHints->GetPos( pAttr ) ) + { return FALSE; + } if( bHiddenPara ) SetCalcHiddenParaField(); @@ -1039,8 +1053,9 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) void SwTxtNode::Delete( SwTxtAttr *pAttr, BOOL bThisOnly ) { - if ( !pSwpHints ) + if ( !HasHints() ) return; + if( bThisOnly ) { xub_StrLen* pEndIdx = pAttr->GetEnd(); @@ -1056,13 +1071,12 @@ void SwTxtNode::Delete( SwTxtAttr *pAttr, BOOL bThisOnly ) // den MsgHint jetzt fuettern, weil gleich sind // Start und End weg. SwUpdateAttr aHint( *pAttr->GetStart(), *pEndIdx, pAttr->Which() ); - pSwpHints->Delete( pAttr ); + m_pSwpHints->Delete( pAttr ); pAttr->RemoveFromPool( GetDoc()->GetAttrPool() ); delete pAttr; SwModify::Modify( 0, &aHint ); // die Frames benachrichtigen - if( pSwpHints && pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); } return; @@ -1076,16 +1090,16 @@ void SwTxtNode::Delete( SwTxtAttr *pAttr, BOOL bThisOnly ) void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) { - if ( !pSwpHints ) + if ( !HasHints() ) return; const xub_StrLen *pEndIdx; const xub_StrLen *pSttIdx; SwTxtAttr* pTxtHt; - for( USHORT nPos = 0; pSwpHints && nPos < pSwpHints->Count(); nPos++ ) + for ( USHORT nPos = 0; m_pSwpHints && nPos < m_pSwpHints->Count(); nPos++ ) { - pTxtHt = pSwpHints->GetHt( nPos ); + pTxtHt = m_pSwpHints->GetTextHint( nPos ); const USHORT nWhich = pTxtHt->Which(); if( nWhich == nTxtWhich && *( pSttIdx = pTxtHt->GetStart()) == nStt ) @@ -1128,7 +1142,7 @@ void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) // Das CalcVisibleFlag bei HiddenParaFields entfaellt, // da dies das Feld im Dtor selbst erledigt. SwUpdateAttr aHint( *pSttIdx, *pEndIdx, nTxtWhich ); - pSwpHints->DeleteAtPos( nPos ); // gefunden, loeschen, + m_pSwpHints->DeleteAtPos( nPos ); // gefunden, loeschen, pTxtHt->RemoveFromPool( GetDoc()->GetAttrPool() ); delete pTxtHt; SwModify::Modify( 0, &aHint ); // die Frames benachrichtigen @@ -1136,8 +1150,7 @@ void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) } } } - if( pSwpHints && pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); } /************************************************************************* @@ -1148,7 +1161,7 @@ void SwTxtNode::DelSoftHyph( const xub_StrLen nStt, const xub_StrLen nEnd ) { xub_StrLen nFndPos = nStt, nEndPos = nEnd; while( STRING_NOTFOUND != - ( nFndPos = aText.Search( CHAR_SOFTHYPHEN, nFndPos )) && + ( nFndPos = m_Text.Search( CHAR_SOFTHYPHEN, nFndPos )) && nFndPos < nEndPos ) { const SwIndex aIdx( this, nFndPos ); @@ -1170,18 +1183,23 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, SfxItemSet aTxtSet( *rSet.GetPool(), RES_TXTATR_BEGIN, RES_TXTATR_END-1 ); // gesamter Bereich - if( !nStt && nEnd == aText.Len() && !(nMode & nsSetAttrMode::SETATTR_NOFORMATATTR ) ) + if ( !nStt && (nEnd == m_Text.Len()) && + !(nMode & nsSetAttrMode::SETATTR_NOFORMATATTR ) ) { // sind am Node schon Zeichenvorlagen gesetzt, muss man diese Attribute // (rSet) immer als TextAttribute setzen, damit sie angezeigt werden. int bHasCharFmts = FALSE; - if( pSwpHints ) - for( USHORT n = 0; n < pSwpHints->Count(); ++n ) - if( (*pSwpHints)[ n ]->IsCharFmtAttr() ) + if ( HasHints() ) + { + for ( USHORT n = 0; n < m_pSwpHints->Count(); ++n ) + { + if ( (*m_pSwpHints)[ n ]->IsCharFmtAttr() ) { bHasCharFmts = TRUE; break; } + } + } if( !bHasCharFmts ) { @@ -1211,8 +1229,7 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, } } - if ( !pSwpHints ) - pSwpHints = new SwpHints(); + GetOrCreateSwpHints(); SfxItemSet aCharSet( *rSet.GetPool(), aCharAutoFmtSetRange ); @@ -1223,47 +1240,50 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, do { - if( pItem && (SfxPoolItem*)-1 != pItem && - (( RES_CHRATR_BEGIN <= ( nWhich = pItem->Which()) && - RES_CHRATR_END > nWhich ) || - ( RES_TXTATR_BEGIN <= nWhich && RES_TXTATR_END > nWhich ) || - ( RES_UNKNOWNATR_BEGIN <= nWhich && RES_UNKNOWNATR_END > nWhich )) ) + if ( pItem && (reinterpret_cast<SfxPoolItem*>(-1) != pItem)) { - if( RES_TXTATR_CHARFMT == pItem->Which() && - GetDoc()->GetDfltCharFmt()==((SwFmtCharFmt*)pItem)->GetCharFmt()) - { - SwIndex aIndex( this, nStt ); - RstAttr( aIndex, nEnd - nStt, RES_TXTATR_CHARFMT, 0 ); - DontExpandFmt( aIndex ); - } - else + nWhich = pItem->Which(); + if ( isCHRATR(nWhich) || isTXTATR(nWhich) || isUNKNOWNATR(nWhich) ) { - if ( ( RES_CHRATR_BEGIN <= nWhich && RES_CHRATR_END > nWhich ) || - RES_TXTATR_UNKNOWN_CONTAINER == nWhich ) + if ((RES_TXTATR_CHARFMT == nWhich) && + (GetDoc()->GetDfltCharFmt() == + static_cast<const SwFmtCharFmt*>(pItem)->GetCharFmt())) { - aCharSet.Put( *pItem ); + SwIndex aIndex( this, nStt ); + RstAttr( aIndex, nEnd - nStt, RES_TXTATR_CHARFMT, 0 ); + DontExpandFmt( aIndex ); } else { - pNew = MakeTxtAttr( *pItem, nStt, nEnd ); - if( pNew ) + if (isCHRATR(nWhich) || + (RES_TXTATR_UNKNOWN_CONTAINER == nWhich)) { - // Attribut ohne Ende, aber Bereich markiert ? - if( nEnd != nStt && !pNew->GetEnd() ) + aCharSet.Put( *pItem ); + } + else + { + pNew = MakeTxtAttr( *pItem, nStt, nEnd ); + if ( pNew ) { - ASSERT( !this, "Attribut ohne Ende aber Bereich vorgegeben" ); - DestroyAttr( pNew ); // nicht einfuegen + if ( nEnd != nStt && !pNew->GetEnd() ) + { + ASSERT(false, + "Attribut without end, but area marked"); + DestroyAttr( pNew ); // do not insert + } + else if ( Insert( pNew, nMode ) ) + { + ++nCount; + } } - else if( Insert( pNew, nMode )) - ++nCount; } } } } - if( aIter.IsAtEnd() ) + if ( aIter.IsAtEnd() ) break; pItem = aIter.NextItem(); - } while( TRUE ); + } while( true ); if ( aCharSet.Count() ) { @@ -1272,8 +1292,7 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, ++nCount; } - if( pSwpHints && pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); return nCount ? TRUE : FALSE; } @@ -1372,7 +1391,7 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, BOOL bOnlyTxtAttr, BOOL bGetFromChrFmt, const bool bMergeIndentValuesOfNumRule ) const { - if( pSwpHints ) + if( HasHints() ) { /* stelle erstmal fest, welche Text-Attribut in dem Bereich gueltig * sind. Dabei gibt es folgende Faelle: @@ -1403,7 +1422,7 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, // <-- } - const USHORT nSize = pSwpHints->Count(); + const USHORT nSize = m_pSwpHints->Count(); USHORT n; xub_StrLen nAttrStart; const xub_StrLen* pAttrEnd; @@ -1412,7 +1431,7 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, { for( n = 0; n < nSize; ++n ) // { - const SwTxtAttr* pHt = (*pSwpHints)[n]; + const SwTxtAttr* pHt = (*m_pSwpHints)[n]; nAttrStart = *pHt->GetStart(); if( nAttrStart > nEnd ) // ueber den Bereich hinaus break; @@ -1441,7 +1460,7 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, for( n = 0; n < nSize; ++n ) { - const SwTxtAttr* pHt = (*pSwpHints)[n]; + const SwTxtAttr* pHt = (*m_pSwpHints)[n]; nAttrStart = *pHt->GetStart(); if( nAttrStart > nEnd ) // ueber den Bereich hinaus break; @@ -1494,13 +1513,21 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, pAttrArr = new std::vector< SwPoolItemEndPair >( coArrSz ); std::vector< SwPoolItemEndPair >::iterator pPrev = pAttrArr->begin(); - if( RES_CHRATR_BEGIN <= nHintWhich && nHintWhich < RES_TXTATR_WITHEND_END ) + if (isCHRATR(nHintWhich) || + isTXTATR_WITHEND(nHintWhich)) + { pPrev += nHintWhich - RES_CHRATR_BEGIN; - else if( RES_UNKNOWNATR_BEGIN <= nHintWhich && nHintWhich < RES_UNKNOWNATR_END ) + } + else if (isUNKNOWNATR(nHintWhich)) + { pPrev += nHintWhich - RES_UNKNOWNATR_BEGIN + ( - static_cast< USHORT >(RES_TXTATR_WITHEND_END) - static_cast< USHORT >(RES_CHRATR_BEGIN) ); + static_cast< USHORT >(RES_TXTATR_WITHEND_END) - + static_cast< USHORT >(RES_CHRATR_BEGIN) ); + } else + { pPrev = pAttrArr->end(); + } #if OSL_DEBUG_LEVEL > 1 SwPoolItemEndPair aTmp = *pPrev; @@ -1627,8 +1654,7 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) if( HasSwAttrSet() && GetpSwAttrSet()->Count() ) aThisSet.Put( *GetpSwAttrSet() ); - if ( !pSwpHints ) - pSwpHints = new SwpHints(); + GetOrCreateSwpHints(); if( pNd == this ) { @@ -1638,11 +1664,11 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) const SfxPoolItem* pItem = aIter.GetCurItem(); std::vector<USHORT> aClearWhichIds; - while( TRUE ) + while ( true ) { - if( lcl_IsNewAttrInSet( *pSwpHints, *pItem, GetTxt().Len() ) ) + if (lcl_IsNewAttrInSet( *m_pSwpHints, *pItem, GetTxt().Len() )) { - pSwpHints->SwpHintsArr::Insert( + m_pSwpHints->SwpHintsArray::Insert( MakeTxtAttr( *pItem, 0, GetTxt().Len() ) ); aClearWhichIds.push_back( pItem->Which() ); } @@ -1661,8 +1687,7 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) if( pNd->HasSwAttrSet() && pNd->GetpSwAttrSet()->Count() ) aNdSet.Put( *pNd->GetpSwAttrSet() ); - if ( !pNd->pSwpHints ) - pNd->pSwpHints = new SwpHints(); + pNd->GetOrCreateSwpHints(); if( aThisSet.Count() ) { @@ -1674,9 +1699,9 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) { if( ( SFX_ITEM_SET != aNdSet.GetItemState( pItem->Which(), FALSE, &pNdItem ) || *pItem != *pNdItem ) && - lcl_IsNewAttrInSet( *pSwpHints, *pItem, GetTxt().Len() ) ) + lcl_IsNewAttrInSet( *m_pSwpHints, *pItem, GetTxt().Len() ) ) { - pSwpHints->SwpHintsArr::Insert( + m_pSwpHints->SwpHintsArray::Insert( MakeTxtAttr( *pItem, 0, GetTxt().Len() ) ); aClearWhichIds.push_back( pItem->Which() ); } @@ -1695,11 +1720,14 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) const SfxPoolItem* pItem = aIter.GetCurItem(); std::vector<USHORT> aClearWhichIds; - while( TRUE ) + while ( true ) { - if( lcl_IsNewAttrInSet( *pNd->pSwpHints, *pItem, pNd->GetTxt().Len() ) ) - pNd->pSwpHints->SwpHintsArr::Insert( + if ( lcl_IsNewAttrInSet( *pNd->m_pSwpHints, *pItem, + pNd->GetTxt().Len() ) ) + { + pNd->m_pSwpHints->SwpHintsArray::Insert( pNd->MakeTxtAttr( *pItem, 0, pNd->GetTxt().Len() ) ); + } aClearWhichIds.push_back( pItem->Which() ); if( aIter.IsAtEnd() ) @@ -1715,8 +1743,7 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) SetCalcHiddenCharFlags(); - if( pNd->pSwpHints->CanBeDeleted() ) - DELETEZ( pNd->pSwpHints ); + pNd->TryDeleteSwpHints(); } /************************************************************************* @@ -1725,15 +1752,16 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) void SwpHints::CalcFlags() { - bDDEFlds = bFtn = FALSE; + m_bDDEFields = m_bFootnote = false; const USHORT nSize = Count(); const SwTxtAttr* pAttr; for( USHORT nPos = 0; nPos < nSize; ++nPos ) + { switch( ( pAttr = (*this)[ nPos ])->Which() ) { case RES_TXTATR_FTN: - bFtn = TRUE; - if( bDDEFlds ) + m_bFootnote = true; + if ( m_bDDEFields ) return; break; case RES_TXTATR_FIELD: @@ -1741,24 +1769,25 @@ void SwpHints::CalcFlags() const SwField* pFld = pAttr->GetFld().GetFld(); if( RES_DDEFLD == pFld->GetTyp()->Which() ) { - bDDEFlds = TRUE; - if( bFtn ) + m_bDDEFields = true; + if ( m_bFootnote ) return; } } break; } + } } /************************************************************************* * SwpHints::CalcVisibleFlag() *************************************************************************/ -BOOL SwpHints::CalcHiddenParaField() +bool SwpHints::CalcHiddenParaField() { - bCalcHiddenParaField = FALSE; - BOOL bOldHasHiddenParaField = bHasHiddenParaField; - BOOL bNewHasHiddenParaField = FALSE; + m_bCalcHiddenParaField = false; + bool bOldHasHiddenParaField = m_bHasHiddenParaField; + bool bNewHasHiddenParaField = false; const USHORT nSize = Count(); const SwTxtAttr *pTxtHt; @@ -1774,11 +1803,13 @@ BOOL SwpHints::CalcHiddenParaField() { if( !((SwHiddenParaField*)rFld.GetFld())->IsHidden() ) { - SetHiddenParaField(FALSE); + SetHiddenParaField(false); return bOldHasHiddenParaField != bNewHasHiddenParaField; } else - bNewHasHiddenParaField = TRUE; + { + bNewHasHiddenParaField = true; + } } } } @@ -1791,10 +1822,9 @@ BOOL SwpHints::CalcHiddenParaField() * SwpHints::NoteInHistory() *************************************************************************/ -void SwpHints::NoteInHistory( SwTxtAttr *pAttr, const BOOL bNew ) +void SwpHints::NoteInHistory( SwTxtAttr *pAttr, const bool bNew ) { - if ( pHistory ) - pHistory->Add( pAttr, bNew ); + if ( m_pHistory ) { m_pHistory->AddHint( pAttr, bNew ); } } /************************************************************************* @@ -1807,7 +1837,7 @@ bool SwpHints::MergePortions( SwTxtNode& rNode ) return false; // sort before merging - SwpHintsArr::Resort(); + SwpHintsArray::Resort(); bool bRet = false; typedef std::multimap< int, SwTxtAttr* > PortionMap; @@ -1819,7 +1849,7 @@ bool SwpHints::MergePortions( SwTxtNode& rNode ) // get portions by start position: for ( i = 0; i < Count(); ++i ) { - SwTxtAttr *pHt = GetHt( i ); + SwTxtAttr *pHt = GetTextHint( i ); if ( RES_TXTATR_CHARFMT != pHt->Which() && RES_TXTATR_AUTOFMT != pHt->Which() ) //&& @@ -1891,9 +1921,9 @@ bool SwpHints::MergePortions( SwTxtNode& rNode ) for ( aIter1 = aRange1.first; aIter1 != aRange1.second; ++aIter1 ) { SwTxtAttr* p1 = (*aIter1).second; - if( pHistory ) pHistory->Add( p1 ); + NoteInHistory( p1 ); *p1->GetEnd() = nNewPortionEnd; - if( pHistory ) pHistory->Add( p1, TRUE ); + NoteInHistory( p1, true ); bRet = true; } } @@ -1905,7 +1935,9 @@ bool SwpHints::MergePortions( SwTxtNode& rNode ) } if ( bRet ) - SwpHintsArr::Resort(); + { + SwpHintsArray::Resort(); + } return bRet; } @@ -2083,12 +2115,12 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) ((SwTxtRefMark*)pHint)->ChgTxtNode( &rNode ); if( rNode.GetNodes().IsDocNodes() ) { - //search for a refernce with the same name + // search for a reference with the same name SwTxtAttr* pTmpHt; xub_StrLen *pTmpHtEnd, *pTmpHintEnd; for( USHORT n = 0, nEnd = Count(); n < nEnd; ++n ) { - if( RES_TXTATR_REFMARK == (pTmpHt = GetHt( n ))->Which() && + if (RES_TXTATR_REFMARK == (pTmpHt = GetTextHint(n))->Which() && pHint->GetAttr() == pTmpHt->GetAttr() && 0 != ( pTmpHtEnd = pTmpHt->GetEnd() ) && 0 != ( pTmpHintEnd = pHint->GetEnd() ) ) @@ -2118,8 +2150,7 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) if( bDelOld ) { - if( pHistory ) - pHistory->Add( pTmpHt ); + NoteInHistory( pTmpHt ); rNode.DestroyAttr( Cut( n-- ) ); --nEnd; } @@ -2155,7 +2186,7 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) xub_StrLen nHtStart = *pHint->GetStart(); if( !pHtEnd ) { - SwpHintsArr::Insert( pHint ); + SwpHintsArray::Insert( pHint ); CalcFlags(); #ifndef PRODUCT if( !rNode.GetDoc()->IsInReading() ) @@ -2232,9 +2263,8 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) lcl_CheckSortNumber( *this, *static_cast<SwTxtCharFmt*>(pHint) ); // <-- - SwpHintsArr::Insert( pHint ); - if ( pHistory ) - pHistory->Add( pHint, TRUE ); + SwpHintsArray::Insert( pHint ); + NoteInHistory( pHint, true ); } } @@ -2259,10 +2289,10 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) void SwpHints::DeleteAtPos( const USHORT nPos ) { - SwTxtAttr *pHint = GetHt(nPos); + SwTxtAttr *pHint = GetTextHint(nPos); // ChainDelete( pHint ); - if( pHistory ) pHistory->Add( pHint ); - SwpHintsArr::DeleteAtPos( nPos ); + NoteInHistory( pHint ); + SwpHintsArray::DeleteAtPos( nPos ); if( RES_TXTATR_FIELD == pHint->Which() ) { @@ -2278,8 +2308,11 @@ void SwpHints::DeleteAtPos( const USHORT nPos ) { const_cast<SwFmtFld&>(((SwTxtFld*)pHint)->GetFld()).Broadcast( SwFmtFldHint( &((SwTxtFld*)pHint)->GetFld(), SWFMTFLD_REMOVED ) ); } - else if( bHasHiddenParaField && RES_HIDDENPARAFLD == pFldTyp->Which() ) - bCalcHiddenParaField = TRUE; + else if ( m_bHasHiddenParaField && + RES_HIDDENPARAFLD == pFldTyp->Which() ) + { + m_bCalcHiddenParaField = true; + } } CalcFlags(); @@ -2300,12 +2333,12 @@ void SwpHints::Delete( SwTxtAttr* pTxtHt ) void SwTxtNode::ClearSwpHintsArr( bool bDelFields ) { - if( pSwpHints ) + if ( HasHints() ) { USHORT nPos = 0; - while( nPos < pSwpHints->Count() ) + while ( nPos < m_pSwpHints->Count() ) { - SwTxtAttr* pDel = pSwpHints->GetHt( nPos ); + SwTxtAttr* pDel = m_pSwpHints->GetTextHint( nPos ); bool bDel = false; switch( pDel->Which() ) @@ -2325,7 +2358,7 @@ void SwTxtNode::ClearSwpHintsArr( bool bDelFields ) if( bDel ) { - pSwpHints->SwpHintsArr::DeleteAtPos( nPos ); + m_pSwpHints->SwpHintsArray::DeleteAtPos( nPos ); DestroyAttr( pDel ); } else @@ -2339,20 +2372,22 @@ USHORT SwTxtNode::GetLang( const xub_StrLen nBegin, const xub_StrLen nLen, { USHORT nRet = LANGUAGE_DONTKNOW; - if ( ! nScript ) - nScript = pBreakIt->GetRealScriptOfText( aText, nBegin ); + if ( ! nScript ) + { + nScript = pBreakIt->GetRealScriptOfText( m_Text, nBegin ); + } // --> FME 2008-09-29 #i91465# hennerdrewes: Consider nScript if pSwpHints == 0 const USHORT nWhichId = GetWhichOfScript( RES_CHRATR_LANGUAGE, nScript ); // <-- - if( pSwpHints ) + if ( HasHints() ) { const xub_StrLen nEnd = nBegin + nLen; - for( USHORT i = 0, nSize = pSwpHints->Count(); i < nSize; ++i ) + for ( USHORT i = 0, nSize = m_pSwpHints->Count(); i < nSize; ++i ) { // ist der Attribut-Anfang schon groesser als der Idx ? - const SwTxtAttr *pHt = pSwpHints->operator[](i); + const SwTxtAttr *pHt = m_pSwpHints->operator[](i); const xub_StrLen nAttrStart = *pHt->GetStart(); if( nEnd < nAttrStart ) break; diff --git a/sw/source/core/txtnode/txatbase.cxx b/sw/source/core/txtnode/txatbase.cxx index 71938961ef7f..17c94a9e20c9 100644 --- a/sw/source/core/txtnode/txatbase.cxx +++ b/sw/source/core/txtnode/txatbase.cxx @@ -37,12 +37,18 @@ #include <fmtfld.hxx> #include <docufld.hxx> -SwTxtAttr::SwTxtAttr( const SfxPoolItem& rAttr, xub_StrLen nStt ) - : pAttr( &rAttr ), nStart( nStt ) +SwTxtAttr::SwTxtAttr( const 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 ) { - bDontExpand = bLockExpandFlag = bDontMergeAttr = bDontMoveAttr = - bCharFmtAttr = bOverlapAllowedAttr = bPriorityAttr = - bDontExpandStart = FALSE; } SwTxtAttr::~SwTxtAttr( ) @@ -54,12 +60,11 @@ xub_StrLen* SwTxtAttr::GetEnd() return 0; } - // RemoveFromPool muss immer vorm DTOR Aufruf erfolgen!! - // Meldet sein Attribut beim Pool ab +// RemoveFromPool must be called before destructor! void SwTxtAttr::RemoveFromPool( SfxItemPool& rPool ) { rPool.Remove( GetAttr() ); - pAttr = 0; + m_pAttr = 0; } int SwTxtAttr::operator==( const SwTxtAttr& rAttr ) const @@ -67,13 +72,14 @@ int SwTxtAttr::operator==( const SwTxtAttr& rAttr ) const return GetAttr() == rAttr.GetAttr(); } -SwTxtAttrEnd::SwTxtAttrEnd( const SfxPoolItem& rAttr, xub_StrLen nS, - xub_StrLen nE ) - : SwTxtAttr( rAttr, nS ), nEnd( nE ) +SwTxtAttrEnd::SwTxtAttrEnd( const SfxPoolItem& rAttr, + xub_StrLen nStart, xub_StrLen nEnd ) : + SwTxtAttr( rAttr, nStart ), m_nEnd( nEnd ) { } xub_StrLen* SwTxtAttrEnd::GetEnd() { - return &nEnd; + return & m_nEnd; } + diff --git a/sw/source/core/txtnode/txtatr2.cxx b/sw/source/core/txtnode/txtatr2.cxx index d62b1bc31ff5..eca88502f771 100644 --- a/sw/source/core/txtnode/txtatr2.cxx +++ b/sw/source/core/txtnode/txtatr2.cxx @@ -56,10 +56,10 @@ TYPEINIT1(SwTxtRuby,SwClient); *************************************************************************/ SwTxtHardBlank::SwTxtHardBlank( const SwFmtHardBlank& rAttr, xub_StrLen nStt ) - : SwTxtAttr( rAttr, nStt ), - cChar( rAttr.GetChar() ) + : SwTxtAttr( rAttr, nStt ) + , m_Char( rAttr.GetChar() ) { - ASSERT( ' ' != cChar && '-' != cChar, + ASSERT( ' ' != m_Char && '-' != m_Char, "Invalid character for the HardBlank attribute - " "must be a normal unicode character" ); } @@ -69,13 +69,13 @@ SwTxtHardBlank::SwTxtHardBlank( const SwFmtHardBlank& rAttr, xub_StrLen nStt ) * class SwTxtCharFmt *************************************************************************/ -SwTxtCharFmt::SwTxtCharFmt( const SwFmtCharFmt& rAttr, +SwTxtCharFmt::SwTxtCharFmt( SwFmtCharFmt& rAttr, xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ), - pMyTxtNd( 0 ), - mnSortNumber( 0 ) + : SwTxtAttrEnd( rAttr, nStt, nEnde ) + , m_pTxtNode( 0 ) + , m_nSortNumber( 0 ) { - ((SwFmtCharFmt&)rAttr).pTxtAttr = this; + rAttr.pTxtAttr = this; SetCharFmtAttr( TRUE ); } @@ -86,29 +86,27 @@ SwTxtCharFmt::~SwTxtCharFmt( ) void SwTxtCharFmt::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) { USHORT nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0; -#ifndef PRODUCT - if ( (nWhich<RES_CHRATR_BEGIN || nWhich>RES_CHRATR_END) - && (nWhich!=RES_OBJECTDYING) - && (nWhich!=RES_ATTRSET_CHG) - && (nWhich!=RES_FMT_CHG) ) - ASSERT(!this, "SwTxtCharFmt::Modify(): unbekanntes Modify!"); -#endif - - if( pMyTxtNd ) + ASSERT( isCHRATR(nWhich) || (RES_OBJECTDYING == nWhich) + || (RES_ATTRSET_CHG == nWhich) || (RES_FMT_CHG == nWhich), + "SwTxtCharFmt::Modify(): unknown Modify"); + + if ( m_pTxtNode ) { SwUpdateAttr aUpdateAttr( *GetStart(), *GetEnd(), nWhich ); - pMyTxtNd->Modify( &aUpdateAttr, &aUpdateAttr ); + m_pTxtNode->Modify( &aUpdateAttr, &aUpdateAttr ); } } // erfrage vom Modify Informationen BOOL SwTxtCharFmt::GetInfo( SfxPoolItem& rInfo ) const { - if( RES_AUTOFMT_DOCNODE != rInfo.Which() || !pMyTxtNd || - &pMyTxtNd->GetNodes() != ((SwAutoFmtGetDocNode&)rInfo).pNodes ) + if ( RES_AUTOFMT_DOCNODE != rInfo.Which() || !m_pTxtNode || + &m_pTxtNode->GetNodes() != static_cast<SwAutoFmtGetDocNode&>(rInfo).pNodes ) + { return TRUE; + } - ((SwAutoFmtGetDocNode&)rInfo).pCntntNode = pMyTxtNd; + static_cast<SwAutoFmtGetDocNode&>(rInfo).pCntntNode = m_pTxtNode; return FALSE; } @@ -116,14 +114,15 @@ BOOL SwTxtCharFmt::GetInfo( SfxPoolItem& rInfo ) const * class SwTxtINetFmt *************************************************************************/ -SwTxtINetFmt::SwTxtINetFmt( const SwFmtINetFmt& rAttr, +SwTxtINetFmt::SwTxtINetFmt( SwFmtINetFmt& rAttr, xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ), - SwClient( 0 ), - pMyTxtNd( 0 ) + : SwTxtAttrEnd( rAttr, nStt, nEnde ) + , SwClient( 0 ) + , m_pTxtNode( 0 ) + , m_bVisited( false ) + , m_bVisitedValid( false ) { - bValidVis = FALSE; - ((SwFmtINetFmt&)rAttr).pTxtAttr = this; + rAttr.pTxtAttr = this; SetCharFmtAttr( TRUE ); } @@ -139,10 +138,10 @@ SwCharFmt* SwTxtINetFmt::GetCharFmt() if( rFmt.GetValue().Len() ) { const SwDoc* pDoc = GetTxtNode().GetDoc(); - if( !IsValidVis() ) + if( !IsVisitedValid() ) { SetVisited( pDoc->IsVisitedURL( rFmt.GetValue() ) ); - SetValidVis( TRUE ); + SetVisitedValid( true ); } USHORT nId; const String& rStr = IsVisited() ? rFmt.GetVisitedFmt() @@ -184,35 +183,33 @@ SwCharFmt* SwTxtINetFmt::GetCharFmt() void SwTxtINetFmt::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) { USHORT nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0; -#ifndef PRODUCT - if ( (nWhich<RES_CHRATR_BEGIN || nWhich>RES_CHRATR_END) - && (nWhich!=RES_OBJECTDYING) - && (nWhich!=RES_ATTRSET_CHG) - && (nWhich!=RES_FMT_CHG) ) - ASSERT(!this, "SwTxtCharFmt::Modify(): unbekanntes Modify!"); -#endif - - if( pMyTxtNd ) + ASSERT( isCHRATR(nWhich) || (RES_OBJECTDYING == nWhich) + || (RES_ATTRSET_CHG == nWhich) || (RES_FMT_CHG == nWhich), + "SwTxtINetFmt::Modify(): unknown Modify"); + + if ( m_pTxtNode ) { SwUpdateAttr aUpdateAttr( *GetStart(), *GetEnd(), nWhich ); - pMyTxtNd->Modify( &aUpdateAttr, &aUpdateAttr ); + m_pTxtNode->Modify( &aUpdateAttr, &aUpdateAttr ); } } // erfrage vom Modify Informationen BOOL SwTxtINetFmt::GetInfo( SfxPoolItem& rInfo ) const { - if( RES_AUTOFMT_DOCNODE != rInfo.Which() || !pMyTxtNd || - &pMyTxtNd->GetNodes() != ((SwAutoFmtGetDocNode&)rInfo).pNodes ) + if ( RES_AUTOFMT_DOCNODE != rInfo.Which() || !m_pTxtNode || + &m_pTxtNode->GetNodes() != static_cast<SwAutoFmtGetDocNode&>(rInfo).pNodes ) + { return TRUE; + } - ((SwAutoFmtGetDocNode&)rInfo).pCntntNode = pMyTxtNd; + static_cast<SwAutoFmtGetDocNode&>(rInfo).pCntntNode = m_pTxtNode; return FALSE; } BOOL SwTxtINetFmt::IsProtect( ) const { - return pMyTxtNd && pMyTxtNd->IsProtect(); + return m_pTxtNode && m_pTxtNode->IsProtect(); } // ATT_XNLCONTAINERITEM ****************************** @@ -224,20 +221,21 @@ SwTxtXMLAttrContainer::SwTxtXMLAttrContainer( {} +/************************************************************************* + * class SwTxtRuby + *************************************************************************/ -// ****************************** - -SwTxtRuby::SwTxtRuby( const SwFmtRuby& rAttr, - xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ), - SwClient( 0 ), - pMyTxtNd( 0 ) +SwTxtRuby::SwTxtRuby( SwFmtRuby& rAttr, + xub_StrLen nStart, xub_StrLen nEnd ) + : SwTxtAttrEnd( rAttr, nStart, nEnd ) + , SwClient( 0 ) + , m_pTxtNode( 0 ) { - ((SwFmtRuby&)rAttr).pTxtAttr = this; - SetDontExpand( TRUE ); // never expand this attribut - SetLockExpandFlag( TRUE ); - SetDontMergeAttr( TRUE ); - SetDontExpandStartAttr( TRUE ); + rAttr.pTxtAttr = this; + SetDontExpand( true ); // never expand this attribute + SetLockExpandFlag( true ); + SetDontMergeAttr( true ); + SetDontExpandStartAttr( true ); } SwTxtRuby::~SwTxtRuby() @@ -247,28 +245,26 @@ SwTxtRuby::~SwTxtRuby() void SwTxtRuby::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) { USHORT nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0; -#ifndef PRODUCT - if ( (nWhich<RES_CHRATR_BEGIN || nWhich>RES_CHRATR_END) - && (nWhich!=RES_OBJECTDYING) - && (nWhich!=RES_ATTRSET_CHG) - && (nWhich!=RES_FMT_CHG) ) - ASSERT(!this, "SwTxtCharFmt::Modify(): unbekanntes Modify!"); -#endif - - if( pMyTxtNd ) + ASSERT( isCHRATR(nWhich) || (RES_OBJECTDYING == nWhich) + || (RES_ATTRSET_CHG == nWhich) || (RES_FMT_CHG == nWhich), + "SwTxtRuby::Modify(): unknown Modify"); + + if ( m_pTxtNode ) { SwUpdateAttr aUpdateAttr( *GetStart(), *GetEnd(), nWhich ); - pMyTxtNd->Modify( &aUpdateAttr, &aUpdateAttr ); + m_pTxtNode->Modify( &aUpdateAttr, &aUpdateAttr ); } } BOOL SwTxtRuby::GetInfo( SfxPoolItem& rInfo ) const { - if( RES_AUTOFMT_DOCNODE != rInfo.Which() || !pMyTxtNd || - &pMyTxtNd->GetNodes() != ((SwAutoFmtGetDocNode&)rInfo).pNodes ) + if( RES_AUTOFMT_DOCNODE != rInfo.Which() || !m_pTxtNode || + &m_pTxtNode->GetNodes() != static_cast<SwAutoFmtGetDocNode&>(rInfo).pNodes ) + { return TRUE; + } - ((SwAutoFmtGetDocNode&)rInfo).pCntntNode = pMyTxtNd; + static_cast<SwAutoFmtGetDocNode&>(rInfo).pCntntNode = m_pTxtNode; return FALSE; } diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index b00e9c0febcd..51e4963698a7 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -50,12 +50,8 @@ #include <SwSmartTagMgr.hxx> #include <linguistic/lngprops.hxx> #include <com/sun/star/beans/XPropertySet.hpp> -#ifndef _COM_SUN_STAR_I18N_WORDTYPE_HDL #include <com/sun/star/i18n/WordType.hdl> -#endif -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif #include <unotools/transliterationwrapper.hxx> #include <unotools/charclass.hxx> #include <dlelstnr.hxx> @@ -64,9 +60,7 @@ #include <viewopt.hxx> #include <acmplwrd.hxx> #include <doc.hxx> // GetDoc() -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <txtfld.hxx> #include <fmtfld.hxx> #include <txatbase.hxx> @@ -380,25 +374,27 @@ static bool lcl_HaveCommonAttributes( IStyleAccess& rStyleAccess, SwTxtNode& SwTxtNode::Insert( xub_Unicode c, const SwIndex &rIdx ) { - xub_StrLen nOrigLen = aText.Len(); + xub_StrLen nOrigLen = m_Text.Len(); - ASSERT( rIdx <= nOrigLen, "Array ueberindiziert." ); - ASSERT( nOrigLen < STRING_LEN, "USHRT_MAX ueberschritten." ); + ASSERT( rIdx <= nOrigLen, "SwTxtNode::Insert: invalid index." ); + ASSERT( nOrigLen < STRING_LEN, + "SwTxtNode::Insert: node text with insertion > STRING_LEN." ); - if( nOrigLen == aText.Insert( c, rIdx.GetIndex() ).Len() ) + if ( nOrigLen == m_Text.Insert( c, rIdx.GetIndex() ).Len() ) return *this; Update(rIdx,1); // leere Hints und Feldattribute an rIdx.GetIndex suchen - if( pSwpHints ) + if ( HasHints() ) { USHORT* pEndIdx; - for( USHORT i=0; i < pSwpHints->Count() && - rIdx >= *(*pSwpHints)[i]->GetStart(); ++i) + for ( USHORT i=0; i < m_pSwpHints->Count() && + rIdx >= *(*m_pSwpHints)[i]->GetStart(); ++i) { - SwTxtAttr *pHt = pSwpHints->GetHt(i); - if( 0 != ( pEndIdx = pHt->GetEnd()) ) + SwTxtAttr *pHt = m_pSwpHints->GetTextHint(i); + pEndIdx = pHt->GetEnd(); + if ( pEndIdx ) { // leere Hints an rIdx.GetIndex ? BOOL bEmpty = *pEndIdx == *pHt->GetStart() @@ -406,7 +402,7 @@ SwTxtNode& SwTxtNode::Insert( xub_Unicode c, const SwIndex &rIdx ) if( bEmpty ) { - pSwpHints->DeleteAtPos(i); + m_pSwpHints->DeleteAtPos(i); if( bEmpty ) *pHt->GetStart() -= 1; else @@ -415,8 +411,7 @@ SwTxtNode& SwTxtNode::Insert( xub_Unicode c, const SwIndex &rIdx ) } } } - if ( pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); } // den Frames Bescheid sagen SwInsChr aHint( rIdx.GetIndex()-1 ); @@ -431,23 +426,22 @@ inline BOOL InRange(xub_StrLen nIdx, xub_StrLen nStart, xub_StrLen nEnd) { /* * void SwTxtNode::RstAttr(const SwIndex &rIdx, USHORT nLen) * - * loescht alle Attribute ab der Position rIdx ueber eine Laenge - * von nLen. + * Deletes all attributes, starting at position rIdx, for length nLen. */ -/* 5 Faelle: - * 1) Das Attribut liegt vollstaendig im Bereich: - * -> loeschen - * 2) Das Attributende liegt im Bereich: - * -> Loeschen, mit neuem Ende einfuegen - * 3) Der Attributanfang liegt im Bereich: - * -> Loeschen, mit neuem Anfang einfuegen - * 4) Das Attrib umfasst den Bereich: - * Aufsplitten, d.h. - * -> Loeschen, mit alten Anfang und Anfang des Bereiches einfuegen - * -> Neues Attribut mit Ende des Bereiches und altem Ende einfuegen - * 5) Das Attribut liegt ausserhalb des Bereiches - * -> nichts tun. +/* 5 cases: + * 1) The attribute is completely in the deletion range: + * -> delete it + * 2) The end of the attribute is in the deletion range: + * -> delete it, then re-insert it with new end + * 3) The start of the attribute is in the deletion range: + * -> delete it, then re-insert it with new start + * 4) The attribute contains the deletion range: + * Split, i.e., + * -> Delete, re-insert from old start to start of deletion range + * -> insert new attribute from end of deletion range to old end + * 5) The attribute is outside the deletion range + * -> nothing to do */ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, @@ -466,8 +460,8 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, BOOL bChanged = FALSE; - // nMin und nMax werden invers auf das Maximum bzw. Minimum gesetzt. - xub_StrLen nMin = aText.Len(); + // nMin and nMax initialized to maximum / minimum (inverse) + xub_StrLen nMin = m_Text.Len(); xub_StrLen nMax = nStt; const BOOL bNoLen = !nMin; @@ -477,16 +471,16 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, // They may not be forgotten inside the "Forget" function //std::vector< const SwTxtAttr* > aNewAttributes; - // durch das Attribute-Array, bis der Anfang des Geltungsbereiches - // des Attributs hinter dem Bereich liegt - while( (i < pSwpHints->Count()) && - ((( nAttrStart = *(*pSwpHints)[i]->GetStart()) < nEnd ) - || nLen==0) ) + // iterate over attribute array until start of attribute is behind + // deletion range + while ((i < m_pSwpHints->Count()) && + ((( nAttrStart = *(*m_pSwpHints)[i]->GetStart()) < nEnd ) || nLen==0) ) { - pHt = pSwpHints->GetHt(i); + pHt = m_pSwpHints->GetTextHint(i); - // Attribute ohne Ende bleiben drin! - if ( 0 == (pAttrEnd=pHt->GetEnd()) ) + // attributes without end stay in! + pAttrEnd = pHt->GetEnd(); + if ( !pAttrEnd ) { i++; continue; @@ -524,10 +518,8 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, RES_TXTATR_TOXMARK == pHt->Which(); } - if( bSkipAttr ) - + if ( bSkipAttr ) { - // Es sollen nur Attribute mit nWhich beachtet werden i++; continue; } @@ -550,7 +542,7 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, { const xub_StrLen nAttrEnd = *pAttrEnd; - pSwpHints->DeleteAtPos(i); + m_pSwpHints->DeleteAtPos(i); DestroyAttr( pHt ); if ( pStyleHandle.get() ) @@ -559,9 +551,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); } - // falls das letzte Attribut ein Field ist, loescht - // dieses das HintsArray !!! - if( !pSwpHints ) + // if the last attribute is a Field, the HintsArray is + // deleted! + if ( !m_pSwpHints ) break; //JP 26.11.96: @@ -576,9 +568,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, } else // Fall: 3 { - pSwpHints->NoteInHistory( pHt ); + m_pSwpHints->NoteInHistory( pHt ); *pHt->GetStart() = nEnd; - pSwpHints->NoteInHistory( pHt, TRUE ); + m_pSwpHints->NoteInHistory( pHt, TRUE ); if ( pStyleHandle.get() && nAttrStart < nEnd ) { @@ -603,9 +595,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, const xub_StrLen nAttrEnd = *pAttrEnd; - pSwpHints->NoteInHistory( pHt ); + m_pSwpHints->NoteInHistory( pHt ); *pAttrEnd = nStt; - pSwpHints->NoteInHistory( pHt, TRUE ); + m_pSwpHints->NoteInHistory( pHt, TRUE ); if ( pStyleHandle.get() ) { @@ -622,9 +614,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, nMax = *pAttrEnd; bChanged = TRUE; xub_StrLen nTmpEnd = *pAttrEnd; - pSwpHints->NoteInHistory( pHt ); + m_pSwpHints->NoteInHistory( pHt ); *pAttrEnd = nStt; - pSwpHints->NoteInHistory( pHt, TRUE ); + m_pSwpHints->NoteInHistory( pHt, TRUE ); if ( pStyleHandle.get() && nStt < nEnd ) { @@ -654,13 +646,12 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, ++i; } - if ( pSwpHints && pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); - if(bChanged) + TryDeleteSwpHints(); + if (bChanged) { - if ( pSwpHints ) + if ( HasHints() ) { - ((SwpHintsArr*)pSwpHints)->Resort(); + m_pSwpHints->Resort(); } //TxtFrm's reagieren auf aHint, andere auf aNew SwUpdateAttr aHint( nMin, nMax, 0 ); @@ -683,13 +674,12 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, * einen leeren String. *************************************************************************/ - - XubString SwTxtNode::GetCurWord( xub_StrLen nPos ) const { - ASSERT( nPos<=aText.Len() , "SwTxtNode::GetCurWord: Pos hinter String?"); - if (!aText.Len()) - return aText; + ASSERT( nPos <= m_Text.Len(), "SwTxtNode::GetCurWord: invalid index." ); + + if (!m_Text.Len()) + return m_Text; Boundary aBndry; const uno::Reference< XBreakIterator > &rxBreak = pBreakIt->xBreak; @@ -698,16 +688,19 @@ XubString SwTxtNode::GetCurWord( xub_StrLen nPos ) const sal_Int16 nWordType = WordType::DICTIONARY_WORD; lang::Locale aLocale( pBreakIt->GetLocale( GetLang( nPos ) ) ); #ifdef DEBUG - BOOL bBegin = rxBreak->isBeginWord( aText, nPos, aLocale, nWordType ); - BOOL bEnd = rxBreak->isEndWord ( aText, nPos, aLocale, nWordType ); + BOOL bBegin = rxBreak->isBeginWord( m_Text, nPos, aLocale, nWordType ); + BOOL bEnd = rxBreak->isEndWord ( m_Text, nPos, aLocale, nWordType ); (void)bBegin; (void)bEnd; #endif - aBndry = rxBreak->getWordBoundary( aText, nPos, aLocale, nWordType, TRUE ); + aBndry = + rxBreak->getWordBoundary( m_Text, nPos, aLocale, nWordType, TRUE ); // if no word was found use previous word (if any) if (aBndry.startPos == aBndry.endPos) - aBndry = rxBreak->previousWord( aText, nPos, aLocale, nWordType ); + { + aBndry = rxBreak->previousWord( m_Text, nPos, aLocale, nWordType ); + } } // check if word was found and if it uses a symbol font, if so @@ -715,7 +708,7 @@ XubString SwTxtNode::GetCurWord( xub_StrLen nPos ) const if (aBndry.endPos != aBndry.startPos && IsSymbol( (xub_StrLen)aBndry.startPos )) aBndry.endPos = aBndry.startPos; - return aText.Copy( static_cast<xub_StrLen>(aBndry.startPos), + return m_Text.Copy( static_cast<xub_StrLen>(aBndry.startPos), static_cast<xub_StrLen>(aBndry.endPos - aBndry.startPos) ); } @@ -865,19 +858,18 @@ USHORT SwTxtNode::Spell(SwSpellArgs* pArgs) xub_StrLen nBegin, nEnd; // modify string according to redline information and hidden text - const XubString aOldTxt( aText ); + const XubString aOldTxt( m_Text ); const bool bRestoreString = - lcl_MaskRedlinesAndHiddenText( *this, aText, 0, aText.Len() ) > 0; + lcl_MaskRedlinesAndHiddenText( *this, m_Text, 0, m_Text.Len() ) > 0; if ( pArgs->pStartNode != this ) nBegin = 0; else nBegin = pArgs->pStartIdx->GetIndex(); - if ( pArgs->pEndNode != this ) - nEnd = aText.Len(); - else - nEnd = pArgs->pEndIdx->GetIndex(); + nEnd = ( pArgs->pEndNode != this ) + ? m_Text.Len() + : pArgs->pEndIdx->GetIndex(); pArgs->xSpellAlt = NULL; @@ -893,12 +885,16 @@ USHORT SwTxtNode::Spell(SwSpellArgs* pArgs) // Text has been checked but there is an invalid range in the wrong list // // Nothing has to be done for case 1. - if( ( IsWrongDirty() || GetWrong() ) && aText.Len() ) + if ( ( IsWrongDirty() || GetWrong() ) && m_Text.Len() ) { - if( nBegin > aText.Len() ) - nBegin = aText.Len(); - if( nEnd > aText.Len() ) - nEnd = aText.Len(); + if ( nBegin > m_Text.Len() ) + { + nBegin = m_Text.Len(); + } + if ( nEnd > m_Text.Len() ) + { + nEnd = m_Text.Len(); + } // if(!IsWrongDirty()) { @@ -907,7 +903,9 @@ USHORT SwTxtNode::Spell(SwSpellArgs* pArgs) { // reset original text if ( bRestoreString ) - aText = aOldTxt; + { + m_Text = aOldTxt; + } return 0; } if(nTemp > nBegin) @@ -917,7 +915,7 @@ USHORT SwTxtNode::Spell(SwSpellArgs* pArgs) // In case 2. we pass the wrong list to the scanned, because only // the words in the wrong list have to be checked - SwScanner aScanner( *this, aText, 0, 0, + SwScanner aScanner( *this, m_Text, 0, 0, WordType::DICTIONARY_WORD, nBegin, nEnd ); while( !pArgs->xSpellAlt.is() && aScanner.NextWord() ) @@ -970,7 +968,9 @@ USHORT SwTxtNode::Spell(SwSpellArgs* pArgs) // reset original text if ( bRestoreString ) - aText = aOldTxt; + { + m_Text = aOldTxt; + } return pArgs->xSpellAlt.is() ? 1 : 0; } @@ -1025,28 +1025,27 @@ USHORT SwTxtNode::Convert( SwConversionArgs &rArgs ) } else nTextBegin = rArgs.pStartIdx->GetIndex(); - if (nTextBegin > aText.Len()) - nTextBegin = aText.Len(); - // - if ( rArgs.pEndNode != this ) - nTextEnd = aText.Len(); - else - nTextEnd = rArgs.pEndIdx->GetIndex(); - if (nTextEnd > aText.Len()) - nTextEnd = aText.Len(); + if (nTextBegin > m_Text.Len()) + { + nTextBegin = m_Text.Len(); + } + + nTextEnd = ( rArgs.pEndNode != this ) + ? m_Text.Len() + : ::std::min( rArgs.pEndIdx->GetIndex(), m_Text.Len() ); rArgs.aConvText = rtl::OUString(); // modify string according to redline information and hidden text - const XubString aOldTxt( aText ); + const XubString aOldTxt( m_Text ); const bool bRestoreString = - lcl_MaskRedlinesAndHiddenText( *this, aText, 0, aText.Len() ) > 0; + lcl_MaskRedlinesAndHiddenText( *this, m_Text, 0, m_Text.Len() ) > 0; sal_Bool bFound = sal_False; xub_StrLen nBegin = nTextBegin; xub_StrLen nLen = 0; LanguageType nLangFound = LANGUAGE_NONE; - if (!aText.Len()) + if (!m_Text.Len()) { if (rArgs.bAllowImplicitChangesForNotConvertibleText) { @@ -1075,7 +1074,9 @@ USHORT SwTxtNode::Convert( SwConversionArgs &rArgs ) // which becomes 65535 when converted to xub_StrLen, // and thus must be cut to the end of the actual string. if (nChPos == (xub_StrLen) -1) - nChPos = aText.Len(); + { + nChPos = m_Text.Len(); + } nLen = nChPos - nBegin; bFound = bLangOk && nLen > 0; @@ -1114,9 +1115,9 @@ USHORT SwTxtNode::Convert( SwConversionArgs &rArgs ) if (bFound && bInSelection) // convertible text found within selection/range? { - const XubString aTxtPortion = aText.Copy( nBegin, nLen ); - DBG_ASSERT( aText.Len() > 0, "convertible text portion missing!" ); - rArgs.aConvText = aText.Copy( nBegin, nLen ); + const XubString aTxtPortion = m_Text.Copy( nBegin, nLen ); + DBG_ASSERT( m_Text.Len() > 0, "convertible text portion missing!" ); + rArgs.aConvText = m_Text.Copy( nBegin, nLen ); rArgs.nConvTextLang = nLangFound; // position where to start looking in next iteration (after current ends) @@ -1129,7 +1130,9 @@ USHORT SwTxtNode::Convert( SwConversionArgs &rArgs ) // restore original text if ( bRestoreString ) - aText = aOldTxt; + { + m_Text = aOldTxt; + } return rArgs.aConvText.getLength() ? 1 : 0; } @@ -1153,15 +1156,17 @@ SwRect SwTxtFrm::_AutoSpell( const SwCntntNode* pActNode, const SwViewOption& rV SwAutoCompleteWord& rACW = SwDoc::GetAutoCompleteWords(); // modify string according to redline information and hidden text - const XubString aOldTxt( pNode->aText ); + const XubString aOldTxt( pNode->GetTxt() ); const bool bRestoreString = - lcl_MaskRedlinesAndHiddenText( *pNode, pNode->aText, 0, pNode->aText.Len() ) > 0; + lcl_MaskRedlinesAndHiddenText( *pNode, pNode->m_Text, + 0, pNode->GetTxt().Len() ) > 0; // a change of data indicates that at least one word has been modified - const sal_Bool bRedlineChg = ( pNode->aText.GetBuffer() != aOldTxt.GetBuffer() ); + const sal_Bool bRedlineChg = + ( pNode->GetTxt().GetBuffer() != aOldTxt.GetBuffer() ); xub_StrLen nBegin = 0; - xub_StrLen nEnd = pNode->aText.Len(); + xub_StrLen nEnd = pNode->GetTxt().Len(); xub_StrLen nInsertPos = 0; xub_StrLen nChgStart = STRING_LEN; xub_StrLen nChgEnd = 0; @@ -1177,8 +1182,10 @@ SwRect SwTxtFrm::_AutoSpell( const SwCntntNode* pActNode, const SwViewOption& rV if( STRING_LEN != nBegin ) { nEnd = pNode->GetWrong()->GetEndInv(); - if ( nEnd > pNode->aText.Len() ) - nEnd = pNode->aText.Len(); + if ( nEnd > pNode->GetTxt().Len() ) + { + nEnd = pNode->GetTxt().Len(); + } } // get word around nBegin, we start at nBegin - 1 @@ -1188,8 +1195,10 @@ SwRect SwTxtFrm::_AutoSpell( const SwCntntNode* pActNode, const SwViewOption& rV --nBegin; LanguageType eActLang = pNode->GetLang( nBegin ); - Boundary aBound = pBreakIt->xBreak->getWordBoundary( pNode->aText, nBegin, - pBreakIt->GetLocale( eActLang ), WordType::DICTIONARY_WORD, TRUE ); + Boundary aBound = + pBreakIt->xBreak->getWordBoundary( pNode->GetTxt(), nBegin, + pBreakIt->GetLocale( eActLang ), + WordType::DICTIONARY_WORD, TRUE ); nBegin = xub_StrLen(aBound.startPos); } @@ -1216,8 +1225,8 @@ SwRect SwTxtFrm::_AutoSpell( const SwCntntNode* pActNode, const SwViewOption& rV uno::Reference< XSpellChecker1 > xSpell( ::GetSpellChecker() ); SwDoc* pDoc = pNode->GetDoc(); - SwScanner aScanner( *pNode, pNode->aText, 0, 0, WordType::DICTIONARY_WORD, - nBegin, nEnd); + SwScanner aScanner( *pNode, pNode->GetTxt(), 0, 0, + WordType::DICTIONARY_WORD, nBegin, nEnd); while( aScanner.NextWord() ) { @@ -1274,7 +1283,9 @@ SwRect SwTxtFrm::_AutoSpell( const SwCntntNode* pActNode, const SwViewOption& rV // reset original text // i63141 before calling GetCharRect(..) with formatting! if ( bRestoreString ) - pNode->aText = aOldTxt; + { + pNode->m_Text = aOldTxt; + } if( pNode->GetWrong() ) { if( bFresh ) @@ -1443,7 +1454,7 @@ void SwTxtFrm::CollectAutoCmplWrds( SwCntntNode* pActNode, xub_StrLen nActPos ) SwAutoCompleteWord& rACW = SwDoc::GetAutoCompleteWords(); xub_StrLen nBegin = 0; - xub_StrLen nEnd = pNode->aText.Len(); + xub_StrLen nEnd = pNode->GetTxt().Len(); xub_StrLen nLen; BOOL bACWDirty = FALSE, bAnyWrd = FALSE; @@ -1451,8 +1462,8 @@ void SwTxtFrm::CollectAutoCmplWrds( SwCntntNode* pActNode, xub_StrLen nActPos ) if( nBegin < nEnd ) { USHORT nCnt = 200; - SwScanner aScanner( *pNode, pNode->aText, 0, 0, WordType::DICTIONARY_WORD, - nBegin, nEnd ); + SwScanner aScanner( *pNode, pNode->GetTxt(), 0, 0, + WordType::DICTIONARY_WORD, nBegin, nEnd ); while( aScanner.NextWord() ) { nBegin = aScanner.GetBegin(); @@ -1492,8 +1503,8 @@ void SwTxtFrm::CollectAutoCmplWrds( SwCntntNode* pActNode, xub_StrLen nActPos ) BOOL SwTxtNode::Hyphenate( SwInterHyphInfo &rHyphInf ) { // Abkuerzung: am Absatz ist keine Sprache eingestellt: - if( LANGUAGE_NONE == USHORT( GetSwAttrSet().GetLanguage().GetLanguage() ) && - USHRT_MAX == GetLang( 0, aText.Len() ) ) + if ( LANGUAGE_NONE == USHORT( GetSwAttrSet().GetLanguage().GetLanguage() ) + && USHRT_MAX == GetLang( 0, m_Text.Len() ) ) { if( !rHyphInf.IsCheck() ) rHyphInf.SetNoLang( TRUE ); @@ -1642,12 +1653,14 @@ void SwTxtNode::TransliterateText( utl::TransliterationWrapper& rTrans, xub_StrLen nLen = nEndPos - nStt; Sequence <sal_Int32> aOffsets; - String sChgd( rTrans.transliterate( aText, nLang, nStt, nLen, - &aOffsets )); - if( !aText.Equals( sChgd, nStt, nLen ) ) + String sChgd( rTrans.transliterate( m_Text, nLang, nStt, nLen, + &aOffsets )); + if( !m_Text.Equals( sChgd, nStt, nLen ) ) { - if( pUndo ) + if ( pUndo ) + { pUndo->AddChanges( *this, nStt, nLen, aOffsets ); + } ReplaceTextOnly( nStt, nLen, sChgd, aOffsets ); } nStt = nEndPos; @@ -1661,7 +1674,7 @@ void SwTxtNode::ReplaceTextOnly( xub_StrLen nPos, xub_StrLen nLen, const XubString& rText, const Sequence<sal_Int32>& rOffsets ) { - aText.Replace( nPos, nLen, rText ); + m_Text.Replace( nPos, nLen, rText ); xub_StrLen nTLen = rText.Len(); const sal_Int32* pOffsets = rOffsets.getConstArray(); @@ -1721,8 +1734,8 @@ void SwTxtNode::CountWords( SwDocStat& rStat, } else { - String aOldStr( aText ); - String& rCastStr = (String&)aText; + String aOldStr( m_Text ); + String& rCastStr = const_cast<String&>(m_Text); // fills the deleted redlines and hidden ranges with cChar: const xub_Unicode cChar(' '); @@ -1839,53 +1852,59 @@ struct SwParaIdleData_Impl void SwTxtNode::InitSwParaStatistics( bool bNew ) { if ( bNew ) - pParaIdleData_Impl = new SwParaIdleData_Impl; - else if ( pParaIdleData_Impl ) { - delete pParaIdleData_Impl->pWrong; - delete pParaIdleData_Impl->pGrammarCheck; - delete pParaIdleData_Impl->pSmartTags; - delete pParaIdleData_Impl; - pParaIdleData_Impl = 0; + m_pParaIdleData_Impl = new SwParaIdleData_Impl; + } + else if ( m_pParaIdleData_Impl ) + { + delete m_pParaIdleData_Impl->pWrong; + delete m_pParaIdleData_Impl->pGrammarCheck; + delete m_pParaIdleData_Impl->pSmartTags; + delete m_pParaIdleData_Impl; + m_pParaIdleData_Impl = 0; } } void SwTxtNode::SetWrong( SwWrongList* pNew, bool bDelete ) { - if ( pParaIdleData_Impl ) + if ( m_pParaIdleData_Impl ) { if ( bDelete ) - delete pParaIdleData_Impl->pWrong; - pParaIdleData_Impl->pWrong = pNew; + { + delete m_pParaIdleData_Impl->pWrong; + } + m_pParaIdleData_Impl->pWrong = pNew; } } SwWrongList* SwTxtNode::GetWrong() { - return pParaIdleData_Impl ? pParaIdleData_Impl->pWrong : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->pWrong : 0; } // --> OD 2008-05-27 #i71360# const SwWrongList* SwTxtNode::GetWrong() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->pWrong : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->pWrong : 0; } // <-- void SwTxtNode::SetGrammarCheck( SwGrammarMarkUp* pNew, bool bDelete ) { - if ( pParaIdleData_Impl ) + if ( m_pParaIdleData_Impl ) { if ( bDelete ) - delete pParaIdleData_Impl->pGrammarCheck; - pParaIdleData_Impl->pGrammarCheck = pNew; + { + delete m_pParaIdleData_Impl->pGrammarCheck; + } + m_pParaIdleData_Impl->pGrammarCheck = pNew; } } SwGrammarMarkUp* SwTxtNode::GetGrammarCheck() { - return pParaIdleData_Impl ? pParaIdleData_Impl->pGrammarCheck : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->pGrammarCheck : 0; } void SwTxtNode::SetSmartTags( SwWrongList* pNew, bool bDelete ) @@ -1893,81 +1912,97 @@ void SwTxtNode::SetSmartTags( SwWrongList* pNew, bool bDelete ) ASSERT( !pNew || SwSmartTagMgr::Get().IsSmartTagsEnabled(), "Weird - we have a smart tag list without any recognizers?" ) - if ( pParaIdleData_Impl ) + if ( m_pParaIdleData_Impl ) { if ( bDelete ) - delete pParaIdleData_Impl->pSmartTags; - pParaIdleData_Impl->pSmartTags = pNew; + { + delete m_pParaIdleData_Impl->pSmartTags; + } + m_pParaIdleData_Impl->pSmartTags = pNew; } } SwWrongList* SwTxtNode::GetSmartTags() { - return pParaIdleData_Impl ? pParaIdleData_Impl->pSmartTags : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->pSmartTags : 0; } void SwTxtNode::SetParaNumberOfWords( ULONG nNew ) const { - if ( pParaIdleData_Impl ) - pParaIdleData_Impl->nNumberOfWords = nNew; + if ( m_pParaIdleData_Impl ) + { + m_pParaIdleData_Impl->nNumberOfWords = nNew; + } } ULONG SwTxtNode::GetParaNumberOfWords() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->nNumberOfWords : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->nNumberOfWords : 0; } void SwTxtNode::SetParaNumberOfChars( ULONG nNew ) const { - if ( pParaIdleData_Impl ) - pParaIdleData_Impl->nNumberOfChars = nNew; + if ( m_pParaIdleData_Impl ) + { + m_pParaIdleData_Impl->nNumberOfChars = nNew; + } } ULONG SwTxtNode::GetParaNumberOfChars() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->nNumberOfChars : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->nNumberOfChars : 0; } void SwTxtNode::SetWordCountDirty( bool bNew ) const { - if ( pParaIdleData_Impl ) - pParaIdleData_Impl->bWordCountDirty = bNew; + if ( m_pParaIdleData_Impl ) + { + m_pParaIdleData_Impl->bWordCountDirty = bNew; + } } bool SwTxtNode::IsWordCountDirty() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->bWordCountDirty : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->bWordCountDirty : 0; } void SwTxtNode::SetWrongDirty( bool bNew ) const { - if ( pParaIdleData_Impl ) - pParaIdleData_Impl->bWrongDirty = bNew; + if ( m_pParaIdleData_Impl ) + { + m_pParaIdleData_Impl->bWrongDirty = bNew; + } } bool SwTxtNode::IsWrongDirty() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->bWrongDirty : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->bWrongDirty : 0; } void SwTxtNode::SetGrammarCheckDirty( bool bNew ) const { - if ( pParaIdleData_Impl ) - pParaIdleData_Impl->bGrammarCheckDirty = bNew; + if ( m_pParaIdleData_Impl ) + { + m_pParaIdleData_Impl->bGrammarCheckDirty = bNew; + } } bool SwTxtNode::IsGrammarCheckDirty() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->bGrammarCheckDirty : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->bGrammarCheckDirty : 0; } void SwTxtNode::SetSmartTagDirty( bool bNew ) const { - if ( pParaIdleData_Impl ) - pParaIdleData_Impl->bSmartTagDirty = bNew; + if ( m_pParaIdleData_Impl ) + { + m_pParaIdleData_Impl->bSmartTagDirty = bNew; + } } bool SwTxtNode::IsSmartTagDirty() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->bSmartTagDirty : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->bSmartTagDirty : 0; } void SwTxtNode::SetAutoCompleteWordDirty( bool bNew ) const { - if ( pParaIdleData_Impl ) - pParaIdleData_Impl->bAutoComplDirty = bNew; + if ( m_pParaIdleData_Impl ) + { + m_pParaIdleData_Impl->bAutoComplDirty = bNew; + } } bool SwTxtNode::IsAutoCompleteWordDirty() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->bAutoComplDirty : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->bAutoComplDirty : 0; } // // Paragraph statistics end diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 776dee62f443..aee144900959 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -72,41 +72,46 @@ #include <svx/brkitem.hxx> #include <bookmrk.hxx> -SV_IMPL_PTRARR( SwpHstry, SwHstryHintPtr) +SV_IMPL_PTRARR( SwpHstry, SwHistoryHintPtr) -String SwHstryHint::GetDescription() const +String SwHistoryHint::GetDescription() const { return String(); } -SwSetFmtHint::SwSetFmtHint( const SfxPoolItem* pFmtHt, ULONG nNd ) - : SwHstryHint( HSTRY_SETFMTHNT ), - pAttr( pFmtHt->Clone() ), - nNode( nNd ) +SwHistorySetFmt::SwHistorySetFmt( const SfxPoolItem* pFmtHt, ULONG nNd ) + : SwHistoryHint( HSTRY_SETFMTHNT ) + , m_pAttr( pFmtHt->Clone() ) + , m_nNodeIndex( nNd ) { - switch( pAttr->Which() ) + switch ( m_pAttr->Which() ) { - case RES_PAGEDESC: - ((SwFmtPageDesc*)pAttr)->ChgDefinedIn( 0 ); - break; - case RES_PARATR_DROP: - ((SwFmtDrop*)pAttr)->ChgDefinedIn( 0 ); - break; - case RES_BOXATR_FORMULA: + case RES_PAGEDESC: + static_cast<SwFmtPageDesc&>(*m_pAttr).ChgDefinedIn( 0 ); + break; + case RES_PARATR_DROP: + static_cast<SwFmtDrop&>(*m_pAttr).ChgDefinedIn( 0 ); + break; + case RES_BOXATR_FORMULA: { //JP 30.07.98: Bug 54295 - Formeln immer im Klartext speichern - SwTblBoxFormula& rNew = *(SwTblBoxFormula*)pAttr; - if( rNew.IsIntrnlName() ) + SwTblBoxFormula& rNew = static_cast<SwTblBoxFormula&>(*m_pAttr); + if ( rNew.IsIntrnlName() ) { - const SwTblBoxFormula& rOld = *(SwTblBoxFormula*)pFmtHt; + const SwTblBoxFormula& rOld = + *static_cast<const SwTblBoxFormula*>(pFmtHt); const SwNode* pNd = rOld.GetNodeOfFormula(); - if( pNd && 0 != (pNd = pNd->FindTableNode() )) + if ( pNd ) { - SwTableFmlUpdate aMsgHnt( &((SwTableNode*)pNd)->GetTable() ); - aMsgHnt.eFlags = TBL_BOXNAME; - rNew.ChgDefinedIn( rOld.GetDefinedIn() ); - rNew.ChangeState( &aMsgHnt ); + const SwTableNode* pTableNode = pNd->FindTableNode(); + if (pTableNode) + { + SwTableFmlUpdate aMsgHnt( &pTableNode->GetTable() ); + aMsgHnt.eFlags = TBL_BOXNAME; + rNew.ChgDefinedIn( rOld.GetDefinedIn() ); + rNew.ChangeState( &aMsgHnt ); + } } } rNew.ChgDefinedIn( 0 ); @@ -115,15 +120,15 @@ SwSetFmtHint::SwSetFmtHint( const SfxPoolItem* pFmtHt, ULONG nNd ) } } -String SwSetFmtHint::GetDescription() const +String SwHistorySetFmt::GetDescription() const { String aResult ; - USHORT nWhich = pAttr->Which(); + USHORT nWhich = m_pAttr->Which(); switch (nWhich) { case RES_BREAK: - switch (((SvxFmtBreakItem *) pAttr)->GetBreak()) + switch ((static_cast<SvxFmtBreakItem &>(*m_pAttr)).GetBreak()) { case SVX_BREAK_PAGE_BEFORE: case SVX_BREAK_PAGE_AFTER: @@ -148,58 +153,73 @@ String SwSetFmtHint::GetDescription() const return aResult; } -void SwSetFmtHint::SetInDoc( SwDoc* pDoc, BOOL bTmpSet ) +void SwHistorySetFmt::SetInDoc( SwDoc* pDoc, bool bTmpSet ) { - SwNode * pNode = pDoc->GetNodes()[ nNode ]; - if( pNode->IsCntntNode() ) + SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ]; + if ( pNode->IsCntntNode() ) { - ((SwCntntNode*)pNode)->SetAttr( *pAttr ); + static_cast<SwCntntNode*>(pNode)->SetAttr( *m_pAttr ); } - else if( pNode->IsTableNode() ) - ((SwTableNode*)pNode)->GetTable().GetFrmFmt()->SetFmtAttr( *pAttr ); - else if( pNode->IsStartNode() && - SwTableBoxStartNode == ((SwStartNode*)pNode)->GetStartNodeType() ) + else if ( pNode->IsTableNode() ) + { + static_cast<SwTableNode*>(pNode)->GetTable().GetFrmFmt()->SetFmtAttr( + *m_pAttr ); + } + else if ( pNode->IsStartNode() && (SwTableBoxStartNode == + static_cast<SwStartNode*>(pNode)->GetStartNodeType()) ) { SwTableNode* pTNd = pNode->FindTableNode(); - SwTableBox* pBox; - if( pTNd && 0 != ( pBox = pTNd->GetTable().GetTblBox( nNode ))) - pBox->ClaimFrmFmt()->SetFmtAttr( *pAttr ); + if ( pTNd ) + { + SwTableBox* pBox = pTNd->GetTable().GetTblBox( m_nNodeIndex ); + if (pBox) + { + pBox->ClaimFrmFmt()->SetFmtAttr( *m_pAttr ); + } + } } - if( !bTmpSet ) - DELETEZ( pAttr ); + if ( !bTmpSet ) + { + m_pAttr.reset(); + } } -SwSetFmtHint::~SwSetFmtHint() +SwHistorySetFmt::~SwHistorySetFmt() { - delete pAttr; } // --> OD 2008-02-27 #refactorlists# - removed <rDoc> -SwResetFmtHint::SwResetFmtHint( const SfxPoolItem* pFmtHt, ULONG nNodeIdx ) +SwHistoryResetFmt::SwHistoryResetFmt(const SfxPoolItem* pFmtHt, ULONG nNodeIdx) // <-- - : SwHstryHint( HSTRY_RESETFMTHNT ), - nNode( nNodeIdx ), - nWhich( pFmtHt->Which() ) + : SwHistoryHint( HSTRY_RESETFMTHNT ) + , m_nNodeIndex( nNodeIdx ) + , m_nWhich( pFmtHt->Which() ) { } -void SwResetFmtHint::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistoryResetFmt::SetInDoc( SwDoc* pDoc, bool ) { - SwNode * pNode = pDoc->GetNodes()[ nNode ]; + SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ]; if ( pNode->IsCntntNode() ) { - ((SwCntntNode*)pNode)->ResetAttr( nWhich ); + static_cast<SwCntntNode*>(pNode)->ResetAttr( m_nWhich ); + } + else if ( pNode->IsTableNode() ) + { + static_cast<SwTableNode*>(pNode)->GetTable().GetFrmFmt()-> + ResetFmtAttr( m_nWhich ); } - else if( pNode->IsTableNode() ) - ((SwTableNode*)pNode)->GetTable().GetFrmFmt()->ResetFmtAttr( nWhich ); } -SwSetTxtHint::SwSetTxtHint( SwTxtAttr* pTxtHt, ULONG nNodePos ) - : SwHstryHint( HSTRY_SETTXTHNT ) +SwHistorySetTxt::SwHistorySetTxt( SwTxtAttr* pTxtHt, ULONG nNodePos ) + : SwHistoryHint( HSTRY_SETTXTHNT ) + , m_nNodeIndex( nNodePos ) + , m_nStart( *pTxtHt->GetStart() ) + , m_nEnd( *pTxtHt->GetAnyEnd() ) { // !! Achtung: folgende Attribute erzeugen keine FormatAttribute: // - NoLineBreak, NoHypen, Inserted, Deleted @@ -208,354 +228,372 @@ SwSetTxtHint::SwSetTxtHint( SwTxtAttr* pTxtHt, ULONG nNodePos ) // ein bisschen kompliziert, aber ist Ok so: erst vom default // eine Kopie und dann die Werte aus dem Text Attribut zuweisen USHORT nWhich = pTxtHt->Which(); - if( RES_TXTATR_CHARFMT == nWhich ) - pAttr = new SwFmtCharFmt( pTxtHt->GetCharFmt().GetCharFmt() ); + if ( RES_TXTATR_CHARFMT == nWhich ) + { + m_pAttr.reset( new SwFmtCharFmt( pTxtHt->GetCharFmt().GetCharFmt() ) ); + } else - pAttr = pTxtHt->GetAttr().Clone(); - nNode = nNodePos; - nStart = *pTxtHt->GetStart(); - nEnd = *pTxtHt->GetAnyEnd(); + { + m_pAttr.reset( pTxtHt->GetAttr().Clone() ); + } } -SwSetTxtHint::~SwSetTxtHint() +SwHistorySetTxt::~SwHistorySetTxt() { - delete pAttr; } -void SwSetTxtHint::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistorySetTxt::SetInDoc( SwDoc* pDoc, bool ) { - if( !pAttr ) + if ( !m_pAttr.get() ) return; - if( RES_TXTATR_CHARFMT == pAttr->Which() ) + if ( RES_TXTATR_CHARFMT == m_pAttr->Which() ) { - // befrage das Doc, ob das CharFmt noch vorhanden ist ! - if( USHRT_MAX == pDoc->GetCharFmts()->GetPos( - ((SwFmtCharFmt*)pAttr)->GetCharFmt() ) ) - return; // nicht setzen, Format nicht vorhanden + // ask the Doc if the CharFmt still exists + if ( USHRT_MAX == pDoc->GetCharFmts()->GetPos( + (static_cast<SwFmtCharFmt&>(*m_pAttr)).GetCharFmt() ) ) + return; // do not set, format does not exist } - SwTxtNode * pTxtNd = pDoc->GetNodes()[ nNode ]->GetTxtNode(); - ASSERT( pTxtNd, "Undo-TxtAttr: kein TextNode" ); + SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode(); + ASSERT( pTxtNd, "SwHistorySetTxt::SetInDoc: not a TextNode" ); - if( pTxtNd ) - pTxtNd->InsertItem( *pAttr, nStart, nEnd, - nsSetAttrMode::SETATTR_NOTXTATRCHR | nsSetAttrMode::SETATTR_NOHINTADJUST ); + if ( pTxtNd ) + { + pTxtNd->InsertItem( *m_pAttr, m_nStart, m_nEnd, + nsSetAttrMode::SETATTR_NOTXTATRCHR | + nsSetAttrMode::SETATTR_NOHINTADJUST ); + } } -SwSetTxtFldHint::SwSetTxtFldHint( SwTxtFld* pTxtFld, ULONG nNodePos ) - : SwHstryHint( HSTRY_SETTXTFLDHNT ), pFldType( 0 ) +SwHistorySetTxtFld::SwHistorySetTxtFld( SwTxtFld* pTxtFld, ULONG nNodePos ) + : SwHistoryHint( HSTRY_SETTXTFLDHNT ) + , m_pFld( new SwFmtFld( *pTxtFld->GetFld().GetFld() ) ) + , m_pFldType( 0 ) { - pFld = new SwFmtFld( *pTxtFld->GetFld().GetFld() ); - - // nur kopieren wenn kein Sys-FieldType - SwDoc* pDoc = (SwDoc*)pTxtFld->GetTxtNode().GetDoc(); + // only copy if not Sys-FieldType + SwDoc* pDoc = pTxtFld->GetTxtNode().GetDoc(); - nFldWhich = pFld->GetFld()->GetTyp()->Which(); - if( nFldWhich == RES_DBFLD || - nFldWhich == RES_USERFLD || - nFldWhich == RES_SETEXPFLD || - nFldWhich == RES_DDEFLD || - !pDoc->GetSysFldType( nFldWhich )) + m_nFldWhich = m_pFld->GetFld()->GetTyp()->Which(); + if (m_nFldWhich == RES_DBFLD || + m_nFldWhich == RES_USERFLD || + m_nFldWhich == RES_SETEXPFLD || + m_nFldWhich == RES_DDEFLD || + !pDoc->GetSysFldType( m_nFldWhich )) { - pFldType = pFld->GetFld()->GetTyp()->Copy(); - pFld->GetFld()->ChgTyp( pFldType ); // Fieldtype umsetzen + m_pFldType.reset( m_pFld->GetFld()->GetTyp()->Copy() ); + m_pFld->GetFld()->ChgTyp( m_pFldType.get() ); // change field type } - nNode = nNodePos; - nPos = *pTxtFld->GetStart(); + m_nNodeIndex = nNodePos; + m_nPos = *pTxtFld->GetStart(); } -String SwSetTxtFldHint::GetDescription() const +String SwHistorySetTxtFld::GetDescription() const { - return pFld->GetFld()->GetDescription();; + return m_pFld->GetFld()->GetDescription();; } -SwSetTxtFldHint::~SwSetTxtFldHint() +SwHistorySetTxtFld::~SwHistorySetTxtFld() { - delete pFld; - delete pFldType; } -void SwSetTxtFldHint::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistorySetTxtFld::SetInDoc( SwDoc* pDoc, bool ) { - if( !pFld ) + if ( !m_pFld.get() ) return; - SwFieldType* pNewFldType = pFldType; - if( !pNewFldType ) - pNewFldType = pDoc->GetSysFldType( nFldWhich ); + SwFieldType* pNewFldType = m_pFldType.get(); + if ( !pNewFldType ) + { + pNewFldType = pDoc->GetSysFldType( m_nFldWhich ); + } else - // den Type am Dokuement anmelden - pNewFldType = pDoc->InsertFldType( *pFldType ); + { + // register type with the document + pNewFldType = pDoc->InsertFldType( *m_pFldType ); + } - pFld->GetFld()->ChgTyp( pNewFldType ); // Fieldtype umsetzen + m_pFld->GetFld()->ChgTyp( pNewFldType ); // change field type - SwTxtNode * pTxtNd = pDoc->GetNodes()[ nNode ]->GetTxtNode(); - ASSERT( pTxtNd, "Undo-TxtAttr: kein TextNode" ); + SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode(); + ASSERT( pTxtNd, "SwHistorySetTxtFld: no TextNode" ); - if( pTxtNd ) - pTxtNd->InsertItem( *pFld, nPos, nPos, nsSetAttrMode::SETATTR_NOTXTATRCHR ); + if ( pTxtNd ) + { + pTxtNd->InsertItem( *m_pFld, m_nPos, m_nPos, + nsSetAttrMode::SETATTR_NOTXTATRCHR ); + } } -SwSetRefMarkHint::SwSetRefMarkHint( SwTxtRefMark* pTxtHt, ULONG nNodePos ) - : SwHstryHint( HSTRY_SETREFMARKHNT ) +SwHistorySetRefMark::SwHistorySetRefMark( SwTxtRefMark* pTxtHt, ULONG nNodePos ) + : SwHistoryHint( HSTRY_SETREFMARKHNT ) + , m_RefName( pTxtHt->GetRefMark().GetRefName() ) + , m_nNodeIndex( nNodePos ) + , m_nStart( *pTxtHt->GetStart() ) + , m_nEnd( *pTxtHt->GetAnyEnd() ) { - aRefName = pTxtHt->GetRefMark().GetRefName(); - nNode = nNodePos; - nStart = *pTxtHt->GetStart(); - nEnd = *pTxtHt->GetAnyEnd(); } -void SwSetRefMarkHint::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistorySetRefMark::SetInDoc( SwDoc* pDoc, bool ) { - SwTxtNode * pTxtNd = pDoc->GetNodes()[ nNode ]->GetTxtNode(); - ASSERT( pTxtNd, "Undo-TxtAttr: kein TextNode" ); - if( !pTxtNd ) + SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode(); + ASSERT( pTxtNd, "SwHistorySetRefMark: no TextNode" ); + if ( !pTxtNd ) return; - SwFmtRefMark aRefMark( aRefName ); + SwFmtRefMark aRefMark( m_RefName ); - // existiert hier schon eine Referenz-Markierung ohne Ende, so - // darf es nicht eingefuegt werden !! - if( nStart != nEnd || !pTxtNd->GetTxtAttr( nStart, RES_TXTATR_REFMARK ) ) - pTxtNd->InsertItem( aRefMark, nStart, nEnd, nsSetAttrMode::SETATTR_NOTXTATRCHR ); + // 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->InsertItem( aRefMark, m_nStart, m_nEnd, + nsSetAttrMode::SETATTR_NOTXTATRCHR ); + } } -SwSetTOXMarkHint::SwSetTOXMarkHint( SwTxtTOXMark* pTxtHt, ULONG nNodePos ) - : SwHstryHint( HSTRY_SETTOXMARKHNT ), aTOXMark( pTxtHt->GetTOXMark() ) +SwHistorySetTOXMark::SwHistorySetTOXMark( SwTxtTOXMark* pTxtHt, ULONG nNodePos ) + : SwHistoryHint( HSTRY_SETTOXMARKHNT ) + , m_TOXMark( pTxtHt->GetTOXMark() ) + , m_TOXName( m_TOXMark.GetTOXType()->GetTypeName() ) + , m_eTOXTypes( m_TOXMark.GetTOXType()->GetType() ) + , m_nNodeIndex( nNodePos ) + , m_nStart( *pTxtHt->GetStart() ) + , m_nEnd( *pTxtHt->GetAnyEnd() ) { - aTOXName = aTOXMark.GetTOXType()->GetTypeName(); - eTOXTypes = aTOXMark.GetTOXType()->GetType(); - ((SwModify*)aTOXMark.GetRegisteredIn())->Remove( &aTOXMark ); - - nNode = nNodePos; - nStart = *pTxtHt->GetStart(); - nEnd = *pTxtHt->GetAnyEnd(); + const_cast<SwModify*>(m_TOXMark.GetRegisteredIn())->Remove( &m_TOXMark ); } -void SwSetTOXMarkHint::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistorySetTOXMark::SetInDoc( SwDoc* pDoc, bool ) { - SwTxtNode * pTxtNd = pDoc->GetNodes()[ nNode ]->GetTxtNode(); - ASSERT( pTxtNd, "Undo-TxtAttr: kein TextNode" ); - if( !pTxtNd ) + SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode(); + ASSERT( pTxtNd, "SwHistorySetTOXMark: no TextNode" ); + if ( !pTxtNd ) return; - // suche den entsprechenden Verzeichnistyp - USHORT nCnt = pDoc->GetTOXTypeCount( eTOXTypes ); - const SwTOXType* pToxType = 0; - for( USHORT n = 0; n < nCnt; ++n ) + // search for respective TOX type + USHORT nCnt = pDoc->GetTOXTypeCount( m_eTOXTypes ); + SwTOXType* pToxType = 0; + for ( USHORT n = 0; n < nCnt; ++n ) { - pToxType = pDoc->GetTOXType( eTOXTypes, n ); - if( pToxType->GetTypeName() == aTOXName ) + pToxType = const_cast<SwTOXType*>(pDoc->GetTOXType( m_eTOXTypes, n )); + if ( pToxType->GetTypeName() == m_TOXName ) break; pToxType = 0; } - if( !pToxType ) // Verzeichnistyp nicht gefunden, neu anlegen - pToxType = pDoc->InsertTOXType( SwTOXType( eTOXTypes, aTOXName )); + if ( !pToxType ) // TOX type not found, create new + { + pToxType = const_cast<SwTOXType*>( + pDoc->InsertTOXType( SwTOXType( m_eTOXTypes, m_TOXName ))); + } - SwTOXMark aNew( aTOXMark ); - ((SwTOXType*)pToxType)->Add( &aNew ); + SwTOXMark aNew( m_TOXMark ); + pToxType->Add( &aNew ); - pTxtNd->InsertItem( aNew, nStart, nEnd, nsSetAttrMode::SETATTR_NOTXTATRCHR ); + pTxtNd->InsertItem( aNew, m_nStart, m_nEnd, + nsSetAttrMode::SETATTR_NOTXTATRCHR ); } -int SwSetTOXMarkHint::IsEqual( const SwTOXMark& rCmp ) const +int SwHistorySetTOXMark::IsEqual( const SwTOXMark& rCmp ) const { - return aTOXName == rCmp.GetTOXType()->GetTypeName() && - eTOXTypes == rCmp.GetTOXType()->GetType() && - aTOXMark.GetAlternativeText() == rCmp.GetAlternativeText() && - ( TOX_INDEX == eTOXTypes - ? ( aTOXMark.GetPrimaryKey() == rCmp.GetPrimaryKey() && - aTOXMark.GetSecondaryKey() == rCmp.GetSecondaryKey() ) - : aTOXMark.GetLevel() == rCmp.GetLevel() + return m_TOXName == rCmp.GetTOXType()->GetTypeName() && + m_eTOXTypes == rCmp.GetTOXType()->GetType() && + m_TOXMark.GetAlternativeText() == rCmp.GetAlternativeText() && + ( (TOX_INDEX == m_eTOXTypes) + ? ( m_TOXMark.GetPrimaryKey() == rCmp.GetPrimaryKey() && + m_TOXMark.GetSecondaryKey() == rCmp.GetSecondaryKey() ) + : m_TOXMark.GetLevel() == rCmp.GetLevel() ); } -SwResetTxtHint::SwResetTxtHint( USHORT nWhich, xub_StrLen nAttrStt, - xub_StrLen nAttrEnd, ULONG nNodePos ) - : SwHstryHint( HSTRY_RESETTXTHNT ), - nNode( nNodePos ), nStart( nAttrStt ), nEnd( nAttrEnd ), nAttr( nWhich ) +SwHistoryResetTxt::SwHistoryResetTxt( USHORT nWhich, + xub_StrLen nAttrStart, xub_StrLen nAttrEnd, ULONG nNodePos ) + : SwHistoryHint( HSTRY_RESETTXTHNT ) + , m_nNodeIndex( nNodePos ), m_nStart( nAttrStart ), m_nEnd( nAttrEnd ) + , m_nAttr( nWhich ) { } -void SwResetTxtHint::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistoryResetTxt::SetInDoc( SwDoc* pDoc, bool ) { - SwTxtNode * pTxtNd = pDoc->GetNodes()[ nNode ]->GetTxtNode(); - ASSERT( pTxtNd, "Undo-TxtAttr: kein TextNode" ); - if( pTxtNd ) - pTxtNd->Delete( nAttr, nStart, nEnd ); + SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode(); + ASSERT( pTxtNd, "SwHistoryResetTxt: no TextNode" ); + if ( pTxtNd ) + { + pTxtNd->Delete( m_nAttr, m_nStart, m_nEnd ); + } } -SwSetFtnHint::SwSetFtnHint( SwTxtFtn* pTxtFtn, ULONG nNodePos ) - : SwHstryHint( HSTRY_SETFTNHNT ), - nNode( nNodePos ), nStart( *pTxtFtn->GetStart() ) +SwHistorySetFootnote::SwHistorySetFootnote( SwTxtFtn* pTxtFtn, ULONG nNodePos ) + : SwHistoryHint( HSTRY_SETFTNHNT ) + , m_pUndo( new SwUndoSaveSection ) + , m_FootnoteNumber( pTxtFtn->GetFtn().GetNumStr() ) + , m_nNodeIndex( nNodePos ) + , m_nStart( *pTxtFtn->GetStart() ) + , m_bEndNote( pTxtFtn->GetFtn().IsEndNote() ) { - ASSERT( pTxtFtn->GetStartNode(), "Footnote ohne Section" ); - - aFtnStr = pTxtFtn->GetFtn().GetNumStr(); - bEndNote = pTxtFtn->GetFtn().IsEndNote(); + ASSERT( pTxtFtn->GetStartNode(), + "SwHistorySetFootnote: Footnote without Section" ); // merke die alte NodePos, denn wer weiss was alles in der SaveSection // gespeichert (geloescht) wird - SwDoc* pDoc = (SwDoc*)pTxtFtn->GetTxtNode().GetDoc(); - SwNode* pSaveNd = pDoc->GetNodes()[ nNode ]; + SwDoc* pDoc = const_cast<SwDoc*>(pTxtFtn->GetTxtNode().GetDoc()); + SwNode* pSaveNd = pDoc->GetNodes()[ m_nNodeIndex ]; //Pointer auf StartNode der FtnSection merken und erstmal den Pointer im //Attribut zuruecksetzen -> Damit werden automatisch die Frms vernichtet. SwNodeIndex aSttIdx( *pTxtFtn->GetStartNode() ); pTxtFtn->SetStartNode( 0, FALSE ); - pUndo = new SwUndoSaveSection; - pUndo->SaveSection( pDoc, aSttIdx ); - nNode = pSaveNd->GetIndex(); + m_pUndo->SaveSection( pDoc, aSttIdx ); + m_nNodeIndex = pSaveNd->GetIndex(); } -SwSetFtnHint::SwSetFtnHint( const SwTxtFtn &rTxtFtn ) : - SwHstryHint( HSTRY_SETFTNHNT ), - pUndo( 0 ), - nNode( _SwTxtFtn_GetIndex( (&rTxtFtn) ) ), - nStart( *rTxtFtn.GetStart() ) +SwHistorySetFootnote::SwHistorySetFootnote( const SwTxtFtn &rTxtFtn ) + : SwHistoryHint( HSTRY_SETFTNHNT ) + , m_pUndo( 0 ) + , m_FootnoteNumber( rTxtFtn.GetFtn().GetNumStr() ) + , m_nNodeIndex( _SwTxtFtn_GetIndex( (&rTxtFtn) ) ) + , m_nStart( *rTxtFtn.GetStart() ) + , m_bEndNote( rTxtFtn.GetFtn().IsEndNote() ) { - ASSERT( rTxtFtn.GetStartNode(), "Footnote ohne Section" ); - - aFtnStr = rTxtFtn.GetFtn().GetNumStr(); - bEndNote = rTxtFtn.GetFtn().IsEndNote(); + ASSERT( rTxtFtn.GetStartNode(), + "SwHistorySetFootnote: Footnote without Section" ); } -String SwSetFtnHint::GetDescription() const +String SwHistorySetFootnote::GetDescription() const { return SW_RES(STR_FOOTNOTE); } -SwSetFtnHint::~SwSetFtnHint() +SwHistorySetFootnote::~SwHistorySetFootnote() { - delete pUndo; } -void SwSetFtnHint::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistorySetFootnote::SetInDoc( SwDoc* pDoc, bool ) { - SwTxtNode * pTxtNd = pDoc->GetNodes()[ nNode ]->GetTxtNode(); - ASSERT( pTxtNd, "Undo-TxtAttr: kein TextNode" ); - if( !pTxtNd ) + SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode(); + ASSERT( pTxtNd, "SwHistorySetFootnote: no TextNode" ); + if ( !pTxtNd ) return; - if ( pUndo ) + if ( m_pUndo.get() ) { - // setze die Fussnote im TextNode - SwFmtFtn aTemp( bEndNote ); - SwFmtFtn& rNew = (SwFmtFtn&)pDoc->GetAttrPool().Put(aTemp); - if( aFtnStr.Len() ) - rNew.SetNumStr( aFtnStr ); - SwTxtFtn* pTxtFtn = new SwTxtFtn( rNew, nStart ); - - // erzeuge schon die Section der Fussnote + // set the footnote in the TextNode + SwFmtFtn aTemp( m_bEndNote ); + SwFmtFtn& rNew = const_cast<SwFmtFtn&>( + static_cast<const SwFmtFtn&>(pDoc->GetAttrPool().Put(aTemp)) ); + if ( m_FootnoteNumber.Len() ) + { + rNew.SetNumStr( m_FootnoteNumber ); + } + SwTxtFtn* pTxtFtn = new SwTxtFtn( rNew, m_nStart ); + + // create the section of the Footnote SwNodeIndex aIdx( *pTxtNd ); - pUndo->RestoreSection( pDoc, &aIdx, SwFootnoteStartNode ); + m_pUndo->RestoreSection( pDoc, &aIdx, SwFootnoteStartNode ); pTxtFtn->SetStartNode( &aIdx ); - if( pUndo->GetHistory() ) - // erst jetzt die Frames anlegen lassen - pUndo->GetHistory()->Rollback( pDoc ); + if ( m_pUndo->GetHistory() ) + { + // create frames only now + m_pUndo->GetHistory()->Rollback( pDoc ); + } pTxtNd->Insert( pTxtFtn ); } else { - SwTxtFtn *pFtn = (SwTxtFtn*)pTxtNd->GetTxtAttr( nStart ); - SwFmtFtn &rFtn = (SwFmtFtn&)pFtn->GetFtn(); - rFtn.SetNumStr( aFtnStr ); - if( rFtn.IsEndNote() != bEndNote ) + SwTxtFtn *pFtn = const_cast<SwTxtFtn*>( + static_cast<const SwTxtFtn*>(pTxtNd->GetTxtAttr( m_nStart ))); + SwFmtFtn &rFtn = const_cast<SwFmtFtn&>(pFtn->GetFtn()); + rFtn.SetNumStr( m_FootnoteNumber ); + if ( rFtn.IsEndNote() != m_bEndNote ) { - rFtn.SetEndNote( bEndNote ); + rFtn.SetEndNote( m_bEndNote ); pFtn->CheckCondColl(); } } } -SwChgFmtColl::SwChgFmtColl( const SwFmtColl* pFmtColl, ULONG nNd, +SwHistoryChangeFmtColl::SwHistoryChangeFmtColl( SwFmtColl* pFmtColl, ULONG nNd, BYTE nNodeWhich ) - : SwHstryHint( HSTRY_CHGFMTCOLL ), - pColl( pFmtColl ), - nNode( nNd ), - nNdWhich( nNodeWhich ) + : SwHistoryHint( HSTRY_CHGFMTCOLL ) + , m_pColl( pFmtColl ) + , m_nNodeIndex( nNd ) + , m_nNodeType( nNodeWhich ) { } -void SwChgFmtColl::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistoryChangeFmtColl::SetInDoc( SwDoc* pDoc, bool ) { - SwCntntNode * pCntntNd = pDoc->GetNodes()[ nNode ]->GetCntntNode(); - ASSERT( pCntntNd, "Undo-ChgFmt: kein ContentNode" ); + SwCntntNode * pCntntNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetCntntNode(); + ASSERT( pCntntNd, "SwHistoryChangeFmtColl: no ContentNode" ); - // prufe vor dem setzen des Formates, ob dieses ueberhaupt noch im - // Dokument vorhanden ist. Wurde es schon geloescht, gibt es kein Undo !! - if( pCntntNd && nNdWhich == pCntntNd->GetNodeType() ) + // before setting the format, check if it is still available in the + // document. if it has been deleted, there is no undo! + if ( pCntntNd && m_nNodeType == pCntntNd->GetNodeType() ) { - if( ND_TEXTNODE == nNdWhich ) + if ( ND_TEXTNODE == m_nNodeType ) { - if( USHRT_MAX != pDoc->GetTxtFmtColls()->GetPos( (SwTxtFmtColl*)pColl )) + if ( USHRT_MAX != pDoc->GetTxtFmtColls()->GetPos( + static_cast<SwTxtFmtColl * const>(m_pColl) )) { - pCntntNd->ChgFmtColl( (SwFmtColl*)pColl ); + pCntntNd->ChgFmtColl( m_pColl ); } } - else if( USHRT_MAX != pDoc->GetGrfFmtColls()->GetPos( (SwGrfFmtColl*)pColl )) - pCntntNd->ChgFmtColl( (SwFmtColl*)pColl ); + else if ( USHRT_MAX != pDoc->GetGrfFmtColls()->GetPos( + static_cast<SwGrfFmtColl * const>(m_pColl) )) + { + pCntntNd->ChgFmtColl( m_pColl ); + } } } -SwHstryTxtFlyCnt::SwHstryTxtFlyCnt( SwTxtFlyCnt* pTxtFly ) - : SwHstryHint( HSTRY_FLYCNT ) +SwHistoryTxtFlyCnt::SwHistoryTxtFlyCnt( SwFrmFmt* const pFlyFmt ) + : SwHistoryHint( HSTRY_FLYCNT ) + , m_pUndo( new SwUndoDelLayFmt( pFlyFmt ) ) { - ASSERT( pTxtFly->GetFlyCnt().GetFrmFmt(), "FlyCntnt ohne Format" ); - pUndo = new SwUndoDelLayFmt( pTxtFly->GetFlyCnt().GetFrmFmt() ); - pUndo->ChgShowSel( FALSE ); + ASSERT( pFlyFmt, "SwHistoryTxtFlyCnt: no Format" ); + m_pUndo->ChgShowSel( FALSE ); } -SwHstryTxtFlyCnt::SwHstryTxtFlyCnt( SwFlyFrmFmt* pFlyFmt ) - : SwHstryHint( HSTRY_FLYCNT ) +SwHistoryTxtFlyCnt::~SwHistoryTxtFlyCnt() { - ASSERT( pFlyFmt, "kein Format" ); - pUndo = new SwUndoDelLayFmt( pFlyFmt ); - pUndo->ChgShowSel( FALSE ); } -SwHstryTxtFlyCnt::~SwHstryTxtFlyCnt() -{ - delete pUndo; -} - - -void SwHstryTxtFlyCnt::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistoryTxtFlyCnt::SetInDoc( SwDoc* pDoc, bool ) { SwPaM aPam( pDoc->GetNodes().GetEndOfPostIts() ); SwUndoIter aUndoIter( &aPam ); - pUndo->Undo( aUndoIter ); + m_pUndo->Undo( aUndoIter ); } -SwHstryBookmark::SwHstryBookmark( +SwHistoryBookmark::SwHistoryBookmark( const ::sw::mark::IMark& rBkmk, bool bSavePos, bool bSaveOtherPos) - : SwHstryHint(HSTRY_BOOKMARK) + : SwHistoryHint(HSTRY_BOOKMARK) , m_aName(rBkmk.GetName()) , m_aShortName() , m_aKeycode() @@ -581,7 +619,7 @@ SwHstryBookmark::SwHstryBookmark( } -void SwHstryBookmark::SetInDoc(SwDoc* pDoc, BOOL) +void SwHistoryBookmark::SetInDoc( SwDoc* pDoc, bool ) { bool bDoesUndo = pDoc->DoesUndo(); pDoc->DoUndo(false); @@ -595,7 +633,7 @@ void SwHstryBookmark::SetInDoc(SwDoc* pDoc, BOOL) { SwCntntNode* const pCntntNd = rNds[m_nNode]->GetCntntNode(); OSL_ENSURE(pCntntNd, - "<SwHstryBookmark::SetInDoc(..)>" + "<SwHistoryBookmark::SetInDoc(..)>" " - wrong node for a mark"); // #111660# don't crash when nNode1 doesn't point to content node. @@ -612,7 +650,7 @@ void SwHstryBookmark::SetInDoc(SwDoc* pDoc, BOOL) { SwCntntNode* const pCntntNd = rNds[m_nOtherNode]->GetCntntNode(); OSL_ENSURE(pCntntNd, - "<SwHstryBookmark::SetInDoc(..)>" + "<SwHistoryBookmark::SetInDoc(..)>" " - wrong node for a mark"); if(pPam.get() != NULL && pCntntNd) @@ -627,7 +665,7 @@ void SwHstryBookmark::SetInDoc(SwDoc* pDoc, BOOL) if(!pMark) pMark = pMarkAccess->findMark(m_aName)->get(); OSL_ENSURE(pMark->IsExpanded(), - "<SwHstryBookmark::SetInDoc(..)>" + "<SwHistoryBookmark::SetInDoc(..)>" " - missing pos on old mark"); pPam->SetMark(); *pPam->GetMark() = pMark->GetOtherMarkPos(); @@ -649,14 +687,14 @@ void SwHstryBookmark::SetInDoc(SwDoc* pDoc, BOOL) } -BOOL SwHstryBookmark::IsEqualBookmark(const ::sw::mark::IMark& rBkmk) +bool SwHistoryBookmark::IsEqualBookmark(const ::sw::mark::IMark& rBkmk) { return m_nNode == rBkmk.GetMarkPos().nNode.GetIndex() && m_nCntnt == rBkmk.GetMarkPos().nContent.GetIndex() && m_aName == rBkmk.GetName(); } -const ::rtl::OUString& SwHstryBookmark::GetName() const +const ::rtl::OUString& SwHistoryBookmark::GetName() const { return m_aName; } @@ -664,65 +702,70 @@ const ::rtl::OUString& SwHstryBookmark::GetName() const /*************************************************************************/ -SwHstrySetAttrSet::SwHstrySetAttrSet( const SfxItemSet& rSet, ULONG nNodePos, - const SvUShortsSort& rSetArr ) - : SwHstryHint( HSTRY_SETATTRSET ), - aOldSet( rSet ), - aResetArr( 0, 4 ), - nNode( nNodePos ), - // --> OD 2007-07-09 #i77372# - //mnNumLvl( MAXLEVEL),//NO_NUMBERING ), - mnNumLvl( MAXLEVEL), //#outline level,zhaojianwei - mbIsRestart( false ), - mnRestartVal( USHRT_MAX ), - mbIsCounted( false ) - // <-- -{ - SfxItemIter aIter( aOldSet ), aOrigIter( rSet ); +SwHistorySetAttrSet::SwHistorySetAttrSet( const SfxItemSet& rSet, + ULONG nNodePos, const SvUShortsSort& rSetArr ) + : SwHistoryHint( HSTRY_SETATTRSET ) + , m_OldSet( rSet ) + , m_ResetArray( 0, 4 ) + , m_nNodeIndex( nNodePos ) +{ + SfxItemIter aIter( m_OldSet ), aOrigIter( rSet ); const SfxPoolItem* pItem = aIter.FirstItem(), * pOrigItem = aOrigIter.FirstItem(); do { if( !rSetArr.Seek_Entry( pOrigItem->Which() )) { - aResetArr.Insert( pOrigItem->Which(), aResetArr.Count() ); - aOldSet.ClearItem( pOrigItem->Which() ); + m_ResetArray.Insert( pOrigItem->Which(), m_ResetArray.Count() ); + m_OldSet.ClearItem( pOrigItem->Which() ); } else { - switch( pItem->Which() ) + switch ( pItem->Which() ) { - case RES_PAGEDESC: - ((SwFmtPageDesc*)pItem)->ChgDefinedIn( 0 ); - break; + case RES_PAGEDESC: + static_cast<SwFmtPageDesc*>( + const_cast<SfxPoolItem*>(pItem))->ChgDefinedIn( 0 ); + break; - case RES_PARATR_DROP: - ((SwFmtDrop*)pItem)->ChgDefinedIn( 0 ); - break; + case RES_PARATR_DROP: + static_cast<SwFmtDrop*>( + const_cast<SfxPoolItem*>(pItem))->ChgDefinedIn( 0 ); + break; - case RES_BOXATR_FORMULA: - { + case RES_BOXATR_FORMULA: + { //JP 20.04.98: Bug 49502 - wenn eine Formel gesetzt ist, nie den // Value mit sichern. Der muss gegebenfalls neu // errechnet werden! //JP 30.07.98: Bug 54295 - Formeln immer im Klartext speichern - aOldSet.ClearItem( RES_BOXATR_VALUE ); + m_OldSet.ClearItem( RES_BOXATR_VALUE ); - SwTblBoxFormula& rNew = *(SwTblBoxFormula*)pItem; - if( rNew.IsIntrnlName() ) - { - const SwTblBoxFormula& rOld = (SwTblBoxFormula&)rSet.Get( RES_BOXATR_FORMULA ); - const SwNode* pNd = rOld.GetNodeOfFormula(); - if( pNd && 0 != (pNd = pNd->FindTableNode() )) + SwTblBoxFormula& rNew = + *static_cast<SwTblBoxFormula*>( + const_cast<SfxPoolItem*>(pItem)); + if ( rNew.IsIntrnlName() ) { - SwTableFmlUpdate aMsgHnt( &((SwTableNode*)pNd)->GetTable() ); - aMsgHnt.eFlags = TBL_BOXNAME; - rNew.ChgDefinedIn( rOld.GetDefinedIn() ); - rNew.ChangeState( &aMsgHnt ); + const SwTblBoxFormula& rOld = + static_cast<const SwTblBoxFormula&>( + rSet.Get( RES_BOXATR_FORMULA )); + const SwNode* pNd = rOld.GetNodeOfFormula(); + if ( pNd ) + { + const SwTableNode* pTableNode + = pNd->FindTableNode(); + if (pTableNode) + { + SwTableFmlUpdate aMsgHnt( + &pTableNode->GetTable() ); + aMsgHnt.eFlags = TBL_BOXNAME; + rNew.ChgDefinedIn( rOld.GetDefinedIn() ); + rNew.ChangeState( &aMsgHnt ); + } + } } + rNew.ChgDefinedIn( 0 ); } - rNew.ChgDefinedIn( 0 ); - } - break; + break; } } @@ -733,24 +776,29 @@ SwHstrySetAttrSet::SwHstrySetAttrSet( const SfxItemSet& rSet, ULONG nNodePos, } while( TRUE ); } -void SwHstrySetAttrSet::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistorySetAttrSet::SetInDoc( SwDoc* pDoc, bool ) { BOOL bDoesUndo = pDoc->DoesUndo(); pDoc->DoUndo( FALSE ); - SwNode * pNode = pDoc->GetNodes()[ nNode ]; - if( pNode->IsCntntNode() ) + SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ]; + if ( pNode->IsCntntNode() ) { - ((SwCntntNode*)pNode)->SetAttr( aOldSet ); - if( aResetArr.Count() ) - ((SwCntntNode*)pNode)->ResetAttr( aResetArr ); + static_cast<SwCntntNode*>(pNode)->SetAttr( m_OldSet ); + if ( m_ResetArray.Count() ) + { + static_cast<SwCntntNode*>(pNode)->ResetAttr( m_ResetArray ); + } } - else if( pNode->IsTableNode() ) + else if ( pNode->IsTableNode() ) { - SwFmt& rFmt = *((SwTableNode*)pNode)->GetTable().GetFrmFmt(); - rFmt.SetFmtAttr( aOldSet ); - if( aResetArr.Count() ) - rFmt.ResetFmtAttr( *aResetArr.GetData() ); + SwFmt& rFmt = + *static_cast<SwTableNode*>(pNode)->GetTable().GetFrmFmt(); + rFmt.SetFmtAttr( m_OldSet ); + if ( m_ResetArray.Count() ) + { + rFmt.ResetFmtAttr( *m_ResetArray.GetData() ); + } } pDoc->DoUndo( bDoesUndo ); @@ -759,11 +807,11 @@ void SwHstrySetAttrSet::SetInDoc( SwDoc* pDoc, BOOL ) /*************************************************************************/ -SwHstryResetAttrSet::SwHstryResetAttrSet( const SfxItemSet& rSet, +SwHistoryResetAttrSet::SwHistoryResetAttrSet( const SfxItemSet& rSet, ULONG nNodePos, xub_StrLen nAttrStt, xub_StrLen nAttrEnd ) - : SwHstryHint( HSTRY_RESETATTRSET ), - nNode( nNodePos ), nStart( nAttrStt ), nEnd( nAttrEnd ), - aArr( (BYTE)rSet.Count() ) + : SwHistoryHint( HSTRY_RESETATTRSET ) + , m_nNodeIndex( nNodePos ), m_nStart( nAttrStt ), m_nEnd( nAttrEnd ) + , m_Array( (BYTE)rSet.Count() ) { SfxItemIter aIter( rSet ); bool bAutoStyle = true; @@ -773,10 +821,14 @@ SwHstryResetAttrSet::SwHstryResetAttrSet( const SfxItemSet& rSet, const USHORT nWhich = aIter.GetCurItem()->Which(); // Character attribute cannot be inserted into the hints array // anymore. Therefore we have to treat them as one RES_TXTATR_AUTOFMT: - if ( RES_CHRATR_BEGIN <= nWhich && RES_CHRATR_END > nWhich ) + if (isCHRATR(nWhich)) + { bAutoStyle = true; + } else - aArr.Insert( aIter.GetCurItem()->Which() ,aArr.Count() ); + { + m_Array.Insert( aIter.GetCurItem()->Which(), m_Array.Count() ); + } if( aIter.IsAtEnd() ) break; @@ -785,32 +837,39 @@ SwHstryResetAttrSet::SwHstryResetAttrSet( const SfxItemSet& rSet, } if ( bAutoStyle ) - aArr.Insert( RES_TXTATR_AUTOFMT, aArr.Count() ); + { + m_Array.Insert( RES_TXTATR_AUTOFMT, m_Array.Count() ); + } } -void SwHstryResetAttrSet::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistoryResetAttrSet::SetInDoc( SwDoc* pDoc, bool ) { BOOL bDoesUndo = pDoc->DoesUndo(); pDoc->DoUndo( FALSE ); - SwCntntNode * pCntntNd = pDoc->GetNodes()[ nNode ]->GetCntntNode(); - ASSERT( pCntntNd, "wo ist mein CntntNode" ); + SwCntntNode * pCntntNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetCntntNode(); + ASSERT( pCntntNd, "SwHistoryResetAttrSet: no CntntNode" ); if (pCntntNd) { - const USHORT* pArr = aArr.GetData(); - if( USHRT_MAX == nEnd && USHRT_MAX == nStart ) + const USHORT* pArr = m_Array.GetData(); + if ( USHRT_MAX == m_nEnd && USHRT_MAX == m_nStart ) { - // kein Bereich also Schnittstelle zum Content-Node - for( USHORT n = aArr.Count(); n; --n, ++pArr ) + // no area: use ContentNode + for ( USHORT n = m_Array.Count(); n; --n, ++pArr ) + { pCntntNd->ResetAttr( *pArr ); + } } else { - // Bereich: also Schnittstelle zum Text-Node - for( USHORT n = aArr.Count(); n; --n, ++pArr ) - ((SwTxtNode*)pCntntNd)->Delete( *pArr, nStart, nEnd ); + // area: use TextNode + for ( USHORT n = m_Array.Count(); n; --n, ++pArr ) + { + static_cast<SwTxtNode*>(pCntntNd)-> + Delete( *pArr, m_nStart, m_nEnd ); + } } } @@ -821,41 +880,47 @@ void SwHstryResetAttrSet::SetInDoc( SwDoc* pDoc, BOOL ) /*************************************************************************/ -SwHstryChgFlyAnchor::SwHstryChgFlyAnchor( const SwFrmFmt& rFmt ) - : SwHstryHint( HSTRY_CHGFLYANCHOR ), - pFmt( (SwFrmFmt*)&rFmt ) +SwHistoryChangeFlyAnchor::SwHistoryChangeFlyAnchor( SwFrmFmt& rFmt ) + : SwHistoryHint( HSTRY_CHGFLYANCHOR ) + , m_rFmt( rFmt ) + , m_nOldNodeIndex( rFmt.GetAnchor().GetCntntAnchor()->nNode.GetIndex() ) + , m_nOldContentIndex( ( FLY_AUTO_CNTNT == rFmt.GetAnchor().GetAnchorId() ) + ? rFmt.GetAnchor().GetCntntAnchor()->nContent.GetIndex() + : STRING_MAXLEN ) { - const SwFmtAnchor& rAnchor = rFmt.GetAnchor(); - nOldPos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); - if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) - nOldCnt = rAnchor.GetCntntAnchor()->nContent.GetIndex(); - else - nOldCnt = STRING_MAXLEN; } -void SwHstryChgFlyAnchor::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistoryChangeFlyAnchor::SetInDoc( SwDoc* pDoc, bool ) { BOOL bDoesUndo = pDoc->DoesUndo(); pDoc->DoUndo( FALSE ); - USHORT nPos = pDoc->GetSpzFrmFmts()->GetPos( pFmt ); - if( USHRT_MAX != nPos ) // Format noch vorhanden + USHORT nPos = pDoc->GetSpzFrmFmts()->GetPos( &m_rFmt ); + if ( USHRT_MAX != nPos ) // Format does still exist { - SwFmtAnchor aTmp( pFmt->GetAnchor() ); + SwFmtAnchor aTmp( m_rFmt.GetAnchor() ); - SwNode* pNd = pDoc->GetNodes()[ nOldPos ]; + SwNode* pNd = pDoc->GetNodes()[ m_nOldNodeIndex ]; + SwCntntNode* pCNd = pNd->GetCntntNode(); SwPosition aPos( *pNd ); - if( STRING_MAXLEN != nOldCnt ) - aPos.nContent.Assign( (SwCntntNode*)pNd, nOldCnt ); + if ( STRING_MAXLEN != m_nOldContentIndex ) + { + ASSERT(pCNd, "SwHistoryChangeFlyAnchor: no ContentNode"); + if (pCNd) + { + aPos.nContent.Assign( pCNd, m_nOldContentIndex ); + } + } aTmp.SetAnchor( &aPos ); - // damit das Layout nicht durcheinander kommt! - SwCntntNode* pCNd = pNd->GetCntntNode(); - if( !pCNd || !pCNd->GetFrm( 0, 0, FALSE ) ) - pFmt->DelFrms(); + // so the Layout does not get confused + if ( !pCNd || !pCNd->GetFrm( 0, 0, FALSE ) ) + { + m_rFmt.DelFrms(); + } - pFmt->SetFmtAttr( aTmp ); + m_rFmt.SetFmtAttr( aTmp ); } pDoc->DoUndo( bDoesUndo ); } @@ -863,55 +928,64 @@ void SwHstryChgFlyAnchor::SetInDoc( SwDoc* pDoc, BOOL ) /*************************************************************************/ -SwHstryChgFlyChain::SwHstryChgFlyChain( const SwFlyFrmFmt& rFmt, +SwHistoryChangeFlyChain::SwHistoryChangeFlyChain( SwFlyFrmFmt& rFmt, const SwFmtChain& rAttr ) - : SwHstryHint( HSTRY_CHGFLYCHAIN ), - pPrevFmt( rAttr.GetPrev() ), - pNextFmt( rAttr.GetNext() ), - pFlyFmt( (SwFlyFrmFmt*)&rFmt ) + : SwHistoryHint( HSTRY_CHGFLYCHAIN ) + , m_pPrevFmt( rAttr.GetPrev() ) + , m_pNextFmt( rAttr.GetNext() ) + , m_pFlyFmt( &rFmt ) { } -void SwHstryChgFlyChain::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistoryChangeFlyChain::SetInDoc( SwDoc* pDoc, bool ) { - if( USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( pFlyFmt ) ) + if ( USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pFlyFmt ) ) { SwFmtChain aChain; - if( pPrevFmt && USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( pPrevFmt )) + + if ( m_pPrevFmt && + USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pPrevFmt ) ) { - aChain.SetPrev( pPrevFmt ); - SwFmtChain aTmp( pPrevFmt->GetChain() ); - aTmp.SetNext( pFlyFmt ); - pPrevFmt->SetFmtAttr( aTmp ); + aChain.SetPrev( m_pPrevFmt ); + SwFmtChain aTmp( m_pPrevFmt->GetChain() ); + aTmp.SetNext( m_pFlyFmt ); + m_pPrevFmt->SetFmtAttr( aTmp ); } - if( pNextFmt && USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( pNextFmt )) + + if ( m_pNextFmt && + USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pNextFmt ) ) { - aChain.SetNext( pNextFmt ); - SwFmtChain aTmp( pNextFmt->GetChain() ); - aTmp.SetPrev( pFlyFmt ); - pNextFmt->SetFmtAttr( aTmp ); + aChain.SetNext( m_pNextFmt ); + SwFmtChain aTmp( m_pNextFmt->GetChain() ); + aTmp.SetPrev( m_pFlyFmt ); + m_pNextFmt->SetFmtAttr( aTmp ); } - if( aChain.GetNext() || aChain.GetPrev() ) - pFlyFmt->SetFmtAttr( aChain ); + if ( aChain.GetNext() || aChain.GetPrev() ) + { + m_pFlyFmt->SetFmtAttr( aChain ); + } } } // -> #i27615# -SwHstryChgCharFmt::SwHstryChgCharFmt(const SfxItemSet & rSet, - const String & _sFmt) - : SwHstryHint(HSTRY_CHGCHARFMT), aOldSet(rSet), sFmt(_sFmt) +SwHistoryChangeCharFmt::SwHistoryChangeCharFmt(const SfxItemSet & rSet, + const String & sFmt) + : SwHistoryHint(HSTRY_CHGCHARFMT) + , m_OldSet(rSet), m_Fmt(sFmt) { } -void SwHstryChgCharFmt::SetInDoc(SwDoc * pDoc, BOOL ) +void SwHistoryChangeCharFmt::SetInDoc(SwDoc * pDoc, bool ) { - SwCharFmt * pCharFmt = pDoc->FindCharFmtByName(sFmt); + SwCharFmt * pCharFmt = pDoc->FindCharFmtByName(m_Fmt); if (pCharFmt) - pCharFmt->SetFmtAttr(aOldSet); + { + pCharFmt->SetFmtAttr(m_OldSet); + } } // <- #i27615# @@ -919,7 +993,8 @@ void SwHstryChgCharFmt::SetInDoc(SwDoc * pDoc, BOOL ) SwHistory::SwHistory( USHORT nInitSz, USHORT nGrowSz ) - : SwpHstry( (BYTE)nInitSz, (BYTE)nGrowSz ), nEndDiff( 0 ) + : m_SwpHstry( (BYTE)nInitSz, (BYTE)nGrowSz ) + , m_nEndDiff( 0 ) {} @@ -944,98 +1019,106 @@ void SwHistory::Add( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue, ULONG nNodeIdx ) // <-- { - ASSERT( !nEndDiff, "nach REDO wurde die History noch nicht geloescht" ); + ASSERT( !m_nEndDiff, "History was not deleted after REDO" ); USHORT nWhich = pNewValue->Which(); if( (nWhich >= POOLATTR_END) || (nWhich == RES_TXTATR_FIELD) ) return; - // kein default Attribut ?? - SwHstryHint * pHt; -#ifdef JP_NEWCORE - if( pOldValue && pOldValue->GetFmt() && - ( !pNewValue->GetFmt() || pOldValue->GetFmt()==pNewValue->GetFmt()) ) -#else - if( pOldValue && pOldValue != GetDfltAttr( pOldValue->Which() ) ) -#endif - pHt = new SwSetFmtHint( (SfxPoolItem*)pOldValue, nNodeIdx ); + // no default Attribute? + SwHistoryHint * pHt; + if ( pOldValue && pOldValue != GetDfltAttr( pOldValue->Which() ) ) + { + pHt = new SwHistorySetFmt( pOldValue, nNodeIdx ); + } else - pHt = new SwResetFmtHint( (SfxPoolItem*)pNewValue, nNodeIdx ); - Insert( pHt, Count() ); + { + pHt = new SwHistoryResetFmt( pNewValue, nNodeIdx ); + } + m_SwpHstry.Insert( pHt, Count() ); } -void SwHistory::Add( const SwTxtAttr* pHint, ULONG nNodeIdx, BOOL bNewAttr ) +void SwHistory::Add( SwTxtAttr* pHint, ULONG nNodeIdx, bool bNewAttr ) { + ASSERT( !m_nEndDiff, "History was not deleted after REDO" ); - ASSERT( !nEndDiff, "nach REDO wurde die History noch nicht geloescht" ); - - SwHstryHint * pHt; + SwHistoryHint * pHt; USHORT nAttrWhich = pHint->Which(); if( !bNewAttr ) { switch ( nAttrWhich ) { - case RES_TXTATR_FTN: - pHt = new SwSetFtnHint( (SwTxtFtn*)pHint, nNodeIdx ); - break; - case RES_TXTATR_FLYCNT: - pHt = new SwHstryTxtFlyCnt( (SwTxtFlyCnt*)pHint ); - break; - case RES_TXTATR_FIELD: - pHt = new SwSetTxtFldHint( (SwTxtFld*)pHint, nNodeIdx ); - break; - case RES_TXTATR_TOXMARK: - pHt = new SwSetTOXMarkHint( (SwTxtTOXMark*)pHint, nNodeIdx ); - break; - case RES_TXTATR_REFMARK: - pHt = new SwSetRefMarkHint( (SwTxtRefMark*)pHint, nNodeIdx ); - break; - default: - pHt = new SwSetTxtHint((SwTxtAttr*)pHint, nNodeIdx ); + case RES_TXTATR_FTN: + pHt = new SwHistorySetFootnote( + static_cast<SwTxtFtn*>(pHint), nNodeIdx ); + break; + case RES_TXTATR_FLYCNT: + pHt = new SwHistoryTxtFlyCnt( static_cast<SwTxtFlyCnt*>(pHint) + ->GetFlyCnt().GetFrmFmt() ); + break; + case RES_TXTATR_FIELD: + pHt = new SwHistorySetTxtFld( + static_cast<SwTxtFld*>(pHint), nNodeIdx ); + break; + case RES_TXTATR_TOXMARK: + pHt = new SwHistorySetTOXMark( + static_cast<SwTxtTOXMark*>(pHint), nNodeIdx ); + break; + case RES_TXTATR_REFMARK: + pHt = new SwHistorySetRefMark( + static_cast<SwTxtRefMark*>(pHint), nNodeIdx ); + break; + default: + pHt = new SwHistorySetTxt( + static_cast<SwTxtAttr*>(pHint), nNodeIdx ); } } else { - pHt = new SwResetTxtHint( pHint->Which(), *pHint->GetStart(), + pHt = new SwHistoryResetTxt( pHint->Which(), *pHint->GetStart(), *pHint->GetAnyEnd(), nNodeIdx ); } - Insert( pHt, Count() ); + m_SwpHstry.Insert( pHt, Count() ); } -void SwHistory::Add( const SwFmtColl* pColl, ULONG nNodeIdx, BYTE nWhichNd ) +void SwHistory::Add( SwFmtColl* pColl, ULONG nNodeIdx, BYTE nWhichNd ) { - ASSERT( !nEndDiff, "nach REDO wurde die History noch nicht geloescht" ); - SwHstryHint * pHt = new SwChgFmtColl( pColl, nNodeIdx, nWhichNd ); - Insert( pHt, Count() ); + ASSERT( !m_nEndDiff, "History was not deleted after REDO" ); + + SwHistoryHint * pHt = + new SwHistoryChangeFmtColl( pColl, nNodeIdx, nWhichNd ); + m_SwpHstry.Insert( pHt, Count() ); } void SwHistory::Add(const ::sw::mark::IMark& rBkmk, bool bSavePos, bool bSaveOtherPos) { - ASSERT(!nEndDiff, "nach REDO wurde die History noch nicht geloescht"); - SwHstryHint * pHt = new SwHstryBookmark(rBkmk, bSavePos, bSaveOtherPos); - Insert(pHt, Count()); + ASSERT( !m_nEndDiff, "History was not deleted after REDO" ); + + SwHistoryHint * pHt = new SwHistoryBookmark(rBkmk, bSavePos, bSaveOtherPos); + m_SwpHstry.Insert( pHt, Count() ); } -void SwHistory::Add( const SwFrmFmt& rFmt ) +void SwHistory::Add( SwFrmFmt& rFmt ) { - SwHstryHint * pHt = new SwHstryChgFlyAnchor( rFmt ); - Insert( pHt, Count() ); + SwHistoryHint * pHt = new SwHistoryChangeFlyAnchor( rFmt ); + m_SwpHstry.Insert( pHt, Count() ); } -void SwHistory::Add( const SwFlyFrmFmt& rFmt, USHORT& rSetPos ) +void SwHistory::Add( SwFlyFrmFmt& rFmt, USHORT& rSetPos ) { - ASSERT( !nEndDiff, "nach REDO wurde die History noch nicht geloescht" ); - SwHstryHint * pHint; + ASSERT( !m_nEndDiff, "History was not deleted after REDO" ); + + SwHistoryHint * pHint; const USHORT nWh = rFmt.Which(); if( RES_FLYFRMFMT == nWh || RES_DRAWFRMFMT == nWh ) { - pHint = new SwHstryTxtFlyCnt( (SwFlyFrmFmt*)&rFmt ); - Insert( pHint, Count() ); + pHint = new SwHistoryTxtFlyCnt( &rFmt ); + m_SwpHstry.Insert( pHint, Count() ); const SwFmtChain* pChainItem; if( SFX_ITEM_SET == rFmt.GetItemState( RES_CHAIN, FALSE, @@ -1043,8 +1126,9 @@ void SwHistory::Add( const SwFlyFrmFmt& rFmt, USHORT& rSetPos ) { if( pChainItem->GetNext() || pChainItem->GetPrev() ) { - SwHstryHint * pHt = new SwHstryChgFlyChain( rFmt, *pChainItem ); - Insert( pHt, rSetPos++ ); + SwHistoryHint * pHt = + new SwHistoryChangeFlyChain( rFmt, *pChainItem ); + m_SwpHstry.Insert( pHt, rSetPos++ ); if ( pChainItem->GetNext() ) { SwFmtChain aTmp( pChainItem->GetNext()->GetChain() ); @@ -1058,23 +1142,22 @@ void SwHistory::Add( const SwFlyFrmFmt& rFmt, USHORT& rSetPos ) pChainItem->GetPrev()->SetFmtAttr( aTmp ); } } - ((SwFlyFrmFmt&)rFmt).ResetFmtAttr( RES_CHAIN ); + rFmt.ResetFmtAttr( RES_CHAIN ); } } } void SwHistory::Add( const SwTxtFtn& rFtn ) { - SwHstryHint *pHt = new SwSetFtnHint( rFtn ); - Insert( pHt, Count() ); + SwHistoryHint *pHt = new SwHistorySetFootnote( rFtn ); + m_SwpHstry.Insert( pHt, Count() ); } // #i27615# void SwHistory::Add(const SfxItemSet & rSet, const SwCharFmt & rFmt) { - SwHstryHint * pHt = new SwHstryChgCharFmt(rSet, rFmt.GetName()); - - Insert(pHt, Count()); + SwHistoryHint * pHt = new SwHistoryChangeCharFmt(rSet, rFmt.GetName()); + m_SwpHstry.Insert(pHt, Count()); } /************************************************************************* @@ -1088,69 +1171,80 @@ void SwHistory::Add(const SfxItemSet & rSet, const SwCharFmt & rFmt) *************************************************************************/ -BOOL SwHistory::Rollback( SwDoc* pDoc, USHORT nStart ) +bool SwHistory::Rollback( SwDoc* pDoc, USHORT nStart ) { - if( !Count() ) - return FALSE; + if ( !Count() ) + return false; - SwHstryHint * pHHt; + SwHistoryHint * pHHt; USHORT i; - for( i = Count(); i > nStart ; ) + for ( i = Count(); i > nStart ; ) { - pHHt = operator[]( --i ); - pHHt->SetInDoc( pDoc, FALSE ); + pHHt = m_SwpHstry[ --i ]; + pHHt->SetInDoc( pDoc, false ); delete pHHt; } - SwpHstry::Remove( nStart, Count() - nStart ); - nEndDiff = 0; - return TRUE; + m_SwpHstry.Remove( nStart, Count() - nStart ); + m_nEndDiff = 0; + return true; } -BOOL SwHistory::TmpRollback( SwDoc* pDoc, USHORT nStart, BOOL bToFirst ) +bool SwHistory::TmpRollback( SwDoc* pDoc, USHORT nStart, bool bToFirst ) { - USHORT nEnd = Count() - nEndDiff; - if( !Count() || !nEnd || nStart >= nEnd ) - return FALSE; + USHORT nEnd = Count() - m_nEndDiff; + if ( !Count() || !nEnd || nStart >= nEnd ) + return false; - SwHstryHint * pHHt; - if( bToFirst ) - for( ; nEnd > nStart; ++nEndDiff ) + SwHistoryHint * pHHt; + if ( bToFirst ) + { + for ( ; nEnd > nStart; ++m_nEndDiff ) { - pHHt = operator[]( --nEnd ); - pHHt->SetInDoc( pDoc, TRUE ); + pHHt = m_SwpHstry[ --nEnd ]; + pHHt->SetInDoc( pDoc, true ); } + } else - for( ; nStart < nEnd; ++nEndDiff, ++nStart ) + { + for ( ; nStart < nEnd; ++m_nEndDiff, ++nStart ) { - pHHt = operator[]( nStart ); - pHHt->SetInDoc( pDoc, TRUE ); + pHHt = m_SwpHstry[ nStart ]; + pHHt->SetInDoc( pDoc, true ); } - return TRUE; + } + return true; } void SwHistory::Delete( USHORT nStart ) { - for( USHORT n = Count(); n > nStart; ) - SwpHstry::DeleteAndDestroy( --n, 1 ); - nEndDiff = 0; + for ( USHORT n = Count(); n > nStart; ) + { + m_SwpHstry.DeleteAndDestroy( --n, 1 ); + } + m_nEndDiff = 0; } USHORT SwHistory::SetTmpEnd( USHORT nNewTmpEnd ) { - ASSERT( nNewTmpEnd <= Count(), "das temp. Ende ist zu gross" ); + ASSERT( nNewTmpEnd <= Count(), "SwHistory::SetTmpEnd: out of bounds" ); - USHORT nOld = Count() - nEndDiff; - nEndDiff = Count() - nNewTmpEnd; + USHORT nOld = Count() - m_nEndDiff; + m_nEndDiff = Count() - nNewTmpEnd; - // rufe bei allen SwHstryFlyCnt das Redo vom UndoObject auf. Dadurch - // werden die Formate der Fly gesichert !! - for( USHORT n = nOld; n < nNewTmpEnd; n++ ) - if( HSTRY_FLYCNT == (*this)[ n ]->Which() ) - ((SwHstryTxtFlyCnt*)(*this)[ n ])->GetUDelLFmt()->Redo(); + // for every SwHistoryFlyCnt, call the Redo of its UndoObject. + // this saves the formats of the flys! + for ( USHORT n = nOld; n < nNewTmpEnd; n++ ) + { + if ( HSTRY_FLYCNT == (*this)[ n ]->Which() ) + { + static_cast<SwHistoryTxtFlyCnt*>((*this)[ n ]) + ->GetUDelLFmt()->Redo(); + } + } return nOld; } @@ -1173,21 +1267,21 @@ void SwHistory::CopyFmtAttr( const SfxItemSet& rSet, ULONG nNodeIdx ) } } -void SwHistory::CopyAttr( const SwpHints* pHts, ULONG nNodeIdx, - xub_StrLen nStt, xub_StrLen nEnd, BOOL bFields ) +void SwHistory::CopyAttr( SwpHints* pHts, ULONG nNodeIdx, + xub_StrLen nStart, xub_StrLen nEnd, bool bFields ) { if( !pHts ) return; - // kopiere alle Attribute aus dem TextNode die - // im Bereich von Position nStt bis Len liegen - const SwTxtAttr* pHt; + // copy all attributes of the TextNode in the area from nStart to nEnd + SwTxtAttr* pHt; xub_StrLen nAttrStt; const xub_StrLen * pEndIdx; for( USHORT n = 0; n < pHts->Count(); n++ ) { // BP: nAttrStt muss auch bei !pEndIdx gesetzt werden - nAttrStt = *(pHt = (*pHts)[n])->GetStart(); + pHt = pHts->GetTextHint(n); + nAttrStt = *pHt->GetStart(); // JP: ???? wieso nAttrStt >= nEnd // if( 0 != ( pEndIdx = pHt->GetEnd() ) && nAttrStt >= nEnd ) if( 0 != ( pEndIdx = pHt->GetEnd() ) && nAttrStt > nEnd ) @@ -1212,17 +1306,21 @@ void SwHistory::CopyAttr( const SwpHints* pHts, ULONG nNodeIdx, if( bNextAttr ) continue; - // alle Attribute, die irgendwie in diesem Bereich liegen speichern - if( nStt <= nAttrStt ) + // save all attributes that are somehow in this area + if ( nStart <= nAttrStt ) { - if( nEnd > nAttrStt + if ( nEnd > nAttrStt // JP: ???? wieso nAttrStt >= nEnd // || (nEnd == nAttrStt && (!pEndIdx || nEnd == pEndIdx->GetIndex())) ) - Add( pHt, nNodeIdx, FALSE ); + { + Add( pHt, nNodeIdx, false ); + } + } + else if ( pEndIdx && nStart < *pEndIdx ) + { + Add( pHt, nNodeIdx, false ); } - else if( pEndIdx && nStt < *pEndIdx ) - Add( pHt, nNodeIdx, FALSE ); } } @@ -1232,74 +1330,79 @@ void SwHistory::CopyAttr( const SwpHints* pHts, ULONG nNodeIdx, // Klasse zum Registrieren der History am Node, Format, HintsArray, ... SwRegHistory::SwRegHistory( SwHistory* pHst ) - : SwClient( 0 ), - pHstry( pHst ), - nNodeIdx( ULONG_MAX ) + : SwClient( 0 ) + , m_pHistory( pHst ) + , m_nNodeIndex( ULONG_MAX ) { - if( pHst ) - _MakeSetWhichIds(); + _MakeSetWhichIds(); } SwRegHistory::SwRegHistory( SwModify* pRegIn, const SwNode& rNd, SwHistory* pHst ) - : SwClient( pRegIn ), - pHstry( pHst ), - nNodeIdx( rNd.GetIndex() ) + : SwClient( pRegIn ) + , m_pHistory( pHst ) + , m_nNodeIndex( rNd.GetIndex() ) { - if( pHst ) - _MakeSetWhichIds(); + _MakeSetWhichIds(); } SwRegHistory::SwRegHistory( const SwNode& rNd, SwHistory* pHst ) - : SwClient( 0 ), - pHstry( pHst ), - nNodeIdx( rNd.GetIndex() ) + : SwClient( 0 ) + , m_pHistory( pHst ) + , m_nNodeIndex( rNd.GetIndex() ) { - if( pHstry ) - _MakeSetWhichIds(); + _MakeSetWhichIds(); } void SwRegHistory::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) { - // Attribut erfragen ?? ( mal sehen ) - if( pHstry && ( pOld || pNew ) ) + if ( m_pHistory && ( pOld || pNew ) ) { - if( pNew->Which() < POOLATTR_END ) - pHstry->Add( pOld, pNew, nNodeIdx ); - else if( RES_ATTRSET_CHG == pNew->Which() ) + if ( pNew->Which() < POOLATTR_END ) { - SwHstryHint* pNewHstr; - const SfxItemSet& rSet = *((SwAttrSetChg*)pOld)->GetChgSet(); - if( 1 < rSet.Count() ) - pNewHstr = new SwHstrySetAttrSet( rSet, nNodeIdx, - aSetWhichIds ); + m_pHistory->Add( pOld, pNew, m_nNodeIndex ); + } + else if ( RES_ATTRSET_CHG == pNew->Which() ) + { + SwHistoryHint* pNewHstr; + const SfxItemSet& rSet = + *static_cast<SwAttrSetChg*>(pOld)->GetChgSet(); + if ( 1 < rSet.Count() ) + { + pNewHstr = + new SwHistorySetAttrSet( rSet, m_nNodeIndex, m_WhichIdSet ); + } else { const SfxPoolItem* pItem = SfxItemIter( rSet ).FirstItem(); - if( aSetWhichIds.Seek_Entry( pItem->Which() ) ) - pNewHstr = new SwSetFmtHint( pItem, nNodeIdx ); + if ( m_WhichIdSet.Seek_Entry( pItem->Which() ) ) + { + pNewHstr = new SwHistorySetFmt( pItem, m_nNodeIndex ); + } else - pNewHstr = new SwResetFmtHint( pItem, nNodeIdx ); + { + pNewHstr = new SwHistoryResetFmt( pItem, m_nNodeIndex ); + } } - pHstry->Insert( pNewHstr, pHstry->Count() ); + m_pHistory->m_SwpHstry.Insert( pNewHstr, m_pHistory->Count() ); } } } -void SwRegHistory::Add( SwTxtAttr* pHt, const BOOL bNew ) +void SwRegHistory::AddHint( SwTxtAttr* pHt, const bool bNew ) { - pHstry->Add( pHt, nNodeIdx, bNew ); + m_pHistory->Add( pHt, m_nNodeIndex, bNew ); } SwRegHistory::SwRegHistory( SwTxtNode* pTxtNode, const SfxItemSet& rSet, xub_StrLen nStart, xub_StrLen nEnd, USHORT nFlags, SwHistory* pHst ) - : SwClient( pTxtNode ), - pHstry( pHst ), - nNodeIdx( pTxtNode->GetIndex() ) + : SwClient( pTxtNode ) + , m_pHistory( pHst ) + , m_nNodeIndex( pTxtNode->GetIndex() ) { if( !rSet.Count() ) return; @@ -1322,45 +1425,57 @@ SwRegHistory::SwRegHistory( SwTxtNode* pTxtNode, const SfxItemSet& rSet, if( pHst && bInsert ) { - SwHstryHint* pNewHstr = new SwHstryResetAttrSet( rSet, + SwHistoryHint* pNewHstr = new SwHistoryResetAttrSet( rSet, pTxtNode->GetIndex(), nStart, nEnd ); // der NodeIndex kann verschoben sein !! - pHst->Insert( pNewHstr, pHst->Count() ); + pHst->m_SwpHstry.Insert( pNewHstr, pHst->Count() ); } } void SwRegHistory::RegisterInModify( SwModify* pRegIn, const SwNode& rNd ) { - if( pHstry && pRegIn ) + if ( m_pHistory && pRegIn ) { pRegIn->Add( this ); - nNodeIdx = rNd.GetIndex(); + m_nNodeIndex = rNd.GetIndex(); _MakeSetWhichIds(); } - else if( aSetWhichIds.Count() ) - aSetWhichIds.Remove( 0, aSetWhichIds.Count() ); + else if ( m_WhichIdSet.Count() ) + { + m_WhichIdSet.Remove( 0, m_WhichIdSet.Count() ); + } } void SwRegHistory::_MakeSetWhichIds() { - if( aSetWhichIds.Count() ) - aSetWhichIds.Remove( 0, aSetWhichIds.Count() ); + if (!m_pHistory) return; + + if ( m_WhichIdSet.Count() ) + { + m_WhichIdSet.Remove( 0, m_WhichIdSet.Count() ); + } if( GetRegisteredIn() ) { const SfxItemSet* pSet = 0; if( GetRegisteredIn()->ISA( SwCntntNode ) ) - pSet = ((SwCntntNode*)GetRegisteredIn())->GetpSwAttrSet(); - else if( GetRegisteredIn()->ISA( SwFmt ) ) - pSet = &((SwFmt*)GetRegisteredIn())->GetAttrSet(); + { + pSet = static_cast<SwCntntNode*>( + const_cast<SwModify*>(GetRegisteredIn()))->GetpSwAttrSet(); + } + else if ( GetRegisteredIn()->ISA( SwFmt ) ) + { + pSet = &static_cast<SwFmt*>( + const_cast<SwModify*>(GetRegisteredIn()))->GetAttrSet(); + } if( pSet && pSet->Count() ) { SfxItemIter aIter( *pSet ); USHORT nW = aIter.FirstItem()->Which(); while( TRUE ) { - aSetWhichIds.Insert( nW ); + m_WhichIdSet.Insert( nW ); if( aIter.IsAtEnd() ) break; nW = aIter.NextItem()->Which(); @@ -1368,3 +1483,4 @@ void SwRegHistory::_MakeSetWhichIds() } } } + diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index df7c138481d4..7177a622e21b 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -37,9 +37,7 @@ #define _SVSTDARR_USHORTSSORT #include <hintids.hxx> #include <svx/svdmodel.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/svdpage.hxx> #include <svtools/itemiter.hxx> @@ -66,38 +64,48 @@ #include <ftninfo.hxx> #include <redline.hxx> #include <section.hxx> +#include <charfmt.hxx> + + inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } // ----------------------------------------------------- -_UndoFmtAttr::_UndoFmtAttr( SwFmt& rFmt, BOOL bSvDrwPt ) - : SwClient( &rFmt ), pUndo( 0 ), bSaveDrawPt( bSvDrwPt ) +SwUndoFmtAttrHelper::SwUndoFmtAttrHelper( SwFmt& rFmt, bool bSvDrwPt ) + : SwClient( &rFmt ) + , m_pUndo( 0 ) + , m_bSaveDrawPt( bSvDrwPt ) { } -void _UndoFmtAttr::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) +void SwUndoFmtAttrHelper::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) { if( pOld && pNew ) { if( POOLATTR_END >= pOld->Which() ) { - if( pUndo ) - pUndo->PutAttr( *pOld ); + if ( GetUndo() ) + { + m_pUndo->PutAttr( *pOld ); + } else - pUndo = new SwUndoFmtAttr( *pOld, *(SwFmt*)pRegisteredIn, - bSaveDrawPt ); + { + m_pUndo.reset( new SwUndoFmtAttr( *pOld, + *static_cast<SwFmt*>(pRegisteredIn), m_bSaveDrawPt ) ); + } } - else if( RES_ATTRSET_CHG == pOld->Which() ) + else if ( RES_ATTRSET_CHG == pOld->Which() ) { - if( pUndo ) + if ( GetUndo() ) { - SfxItemIter aIter( *((SwAttrSetChg*)pOld)->GetChgSet() ); + SfxItemIter aIter( + *(static_cast<SwAttrSetChg*>(pOld))->GetChgSet() ); const SfxPoolItem* pItem = aIter.GetCurItem(); - while( pItem ) + while ( pItem ) { - pUndo->PutAttr( *pItem ); + m_pUndo->PutAttr( *pItem ); if( aIter.IsAtEnd() ) break; pItem = aIter.NextItem(); @@ -105,8 +113,9 @@ void _UndoFmtAttr::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) } else { - pUndo = new SwUndoFmtAttr( *((SwAttrSetChg*)pOld)->GetChgSet(), - *(SwFmt*)pRegisteredIn, bSaveDrawPt ); + m_pUndo.reset( new SwUndoFmtAttr( + *static_cast<SwAttrSetChg*>(pOld)->GetChgSet(), + *static_cast<SwFmt*>(pRegisteredIn), m_bSaveDrawPt ) ); } } else @@ -116,91 +125,77 @@ void _UndoFmtAttr::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) SwClient::Modify( pOld, pNew ); } -// --> OD 2007-07-11 #i56253# -struct TxtNodeNumberingAttrs -{ - TxtNodeNumberingAttrs( ULONG nTxtNodeIdx, - int nNumLvl, - bool bIsRestart, - SwNumberTree::tSwNumTreeNumber nRestartVal, - bool bIsCounted ) - : mnTxtNodeIdx( nTxtNodeIdx ), - mnNumLvl( nNumLvl ), - mbIsRestart( bIsRestart ), - mnRestartVal( nRestartVal ), - mbIsCounted( bIsCounted ) - {} - - ULONG mnTxtNodeIdx; - int mnNumLvl; - bool mbIsRestart; - SwNumberTree::tSwNumTreeNumber mnRestartVal; - bool mbIsCounted; -}; -// <-- +// ----------------------------------------------------- SwUndoFmtAttr::SwUndoFmtAttr( const SfxItemSet& rOldSet, SwFmt& rChgFmt, - BOOL bSvDrwPt ) - : SwUndo( UNDO_INSFMTATTR ), - pFmt( &rChgFmt ), + bool bSaveDrawPt ) + : SwUndo( UNDO_INSFMTATTR ) + , m_pFmt( &rChgFmt ) // --> OD 2007-07-11 #i56253# - pOldSet( 0 ), + , m_pOldSet( new SfxItemSet( rOldSet ) ) // <-- - nNode( 0 ), - nFmtWhich( rChgFmt.Which() ), - bSaveDrawPt( bSvDrwPt ) + , m_nNodeIndex( 0 ) + , m_nFmtWhich( rChgFmt.Which() ) + , m_bSaveDrawPt( bSaveDrawPt ) { - pOldSet = new SfxItemSet( rOldSet ); Init(); } SwUndoFmtAttr::SwUndoFmtAttr( const SfxPoolItem& rItem, SwFmt& rChgFmt, - BOOL bSvDrwPt ) - : SwUndo( UNDO_INSFMTATTR ), - pFmt( &rChgFmt ), - nNode( 0 ), - nFmtWhich( rChgFmt.Which() ), - bSaveDrawPt( bSvDrwPt ) + bool bSaveDrawPt ) + : SwUndo( UNDO_INSFMTATTR ) + , m_pFmt( &rChgFmt ) + , m_pOldSet( m_pFmt->GetAttrSet().Clone( FALSE ) ) + , m_nNodeIndex( 0 ) + , m_nFmtWhich( rChgFmt.Which() ) + , m_bSaveDrawPt( bSaveDrawPt ) { - pOldSet = pFmt->GetAttrSet().Clone( FALSE ); - pOldSet->Put( rItem ); + m_pOldSet->Put( rItem ); Init(); } void SwUndoFmtAttr::Init() { - // Ankerwechsel gesondert behandeln - if( SFX_ITEM_SET == pOldSet->GetItemState( RES_ANCHOR, FALSE )) - SaveFlyAnchor( bSaveDrawPt ); - else if( RES_FRMFMT == nFmtWhich ) + // treat change of anchor specially + if ( SFX_ITEM_SET == m_pOldSet->GetItemState( RES_ANCHOR, FALSE )) + { + SaveFlyAnchor( m_bSaveDrawPt ); + } + else if ( RES_FRMFMT == m_nFmtWhich ) { - SwDoc* pDoc = pFmt->GetDoc(); - if( USHRT_MAX != - pDoc->GetTblFrmFmts()->GetPos( (const SwFrmFmtPtr)pFmt )) + SwDoc* pDoc = m_pFmt->GetDoc(); + if (USHRT_MAX != pDoc->GetTblFrmFmts()->GetPos( + static_cast<const SwFrmFmtPtr>(m_pFmt))) + { + // Table Format: save table position, table formats are volatile! + SwTable * pTbl = static_cast<SwTable*>( + SwClientIter( *m_pFmt ).First( TYPE( SwTable )) ); + if ( pTbl ) + { + m_nNodeIndex = pTbl->GetTabSortBoxes()[ 0 ]->GetSttNd() + ->FindTableNode()->GetIndex(); + } + } + else if (USHRT_MAX != pDoc->GetSections().GetPos( + static_cast<const SwSectionFmtPtr>(m_pFmt))) { - // TabellenFormat -> Tabellen Index Position merken, TabellenFormate - // sind fluechtig! - SwClient* pTbl = SwClientIter( *pFmt ).First( TYPE( SwTable )); - if( pTbl ) - nNode = ((SwTable*)pTbl)->GetTabSortBoxes()[ 0 ]-> - GetSttNd()->FindTableNode()->GetIndex(); + m_nNodeIndex = m_pFmt->GetCntnt().GetCntntIdx()->GetIndex(); } - else if( USHRT_MAX != - pDoc->GetSections().GetPos( (const SwSectionFmtPtr)pFmt )) - nNode = pFmt->GetCntnt().GetCntntIdx()->GetIndex(); - else if( 0 != dynamic_cast< SwTableBoxFmt* >( pFmt ) ) + else if ( 0 != dynamic_cast< SwTableBoxFmt* >( m_pFmt ) ) { - SwClient* pTblBox = SwClientIter( *pFmt ).First( TYPE( SwTableBox )); - if( pTblBox ) - nNode = static_cast< SwTableBox* >(pTblBox)->GetSttIdx(); + SwTableBox* pTblBox = static_cast< SwTableBox* >( + SwClientIter( *m_pFmt ).First( TYPE( SwTableBox ))); + if ( pTblBox ) + { + m_nNodeIndex = pTblBox->GetSttIdx(); + } } } } SwUndoFmtAttr::~SwUndoFmtAttr() { - delete pOldSet; } void SwUndoFmtAttr::Undo( SwUndoIter& rUndoIter) @@ -208,14 +203,14 @@ void SwUndoFmtAttr::Undo( SwUndoIter& rUndoIter) // OD 2004-10-26 #i35443# // Important note: <Undo(..)> also called by <ReDo(..)> - if( !pOldSet || !pFmt || !IsFmtInDoc( &rUndoIter.GetDoc() )) + if ( !m_pOldSet.get() || !m_pFmt || !IsFmtInDoc( &rUndoIter.GetDoc() )) return; // --> OD 2004-10-26 #i35443# - If anchor attribute has been successfull // restored, all other attributes are also restored. // Thus, keep track of its restoration bool bAnchorAttrRestored( false ); - if ( SFX_ITEM_SET == pOldSet->GetItemState( RES_ANCHOR, FALSE )) + if ( SFX_ITEM_SET == m_pOldSet->GetItemState( RES_ANCHOR, FALSE )) { bAnchorAttrRestored = RestoreFlyAnchor( rUndoIter ); if ( bAnchorAttrRestored ) @@ -228,105 +223,115 @@ void SwUndoFmtAttr::Undo( SwUndoIter& rUndoIter) { // Anchor attribute not restored due to invalid anchor position. // Thus, delete anchor attribute. - pOldSet->ClearItem( RES_ANCHOR ); + m_pOldSet->ClearItem( RES_ANCHOR ); } } if ( !bAnchorAttrRestored ) // <-- { - _UndoFmtAttr aTmp( *pFmt, bSaveDrawPt ); - pFmt->SetFmtAttr( *pOldSet ); - if( aTmp.pUndo ) + SwUndoFmtAttrHelper aTmp( *m_pFmt, m_bSaveDrawPt ); + m_pFmt->SetFmtAttr( *m_pOldSet ); + if ( aTmp.GetUndo() ) { - delete pOldSet; - pOldSet = aTmp.pUndo->pOldSet; - aTmp.pUndo->pOldSet = 0; // den Pointer auf 0 setzen (nicht - // doppelt loeschen) !! - delete aTmp.pUndo; // Undo-Object wieder loeschen + // transfer ownership of helper object's old set + m_pOldSet = aTmp.GetUndo()->m_pOldSet; } else - pOldSet->ClearItem(); + { + m_pOldSet->ClearItem(); + } - if( RES_FLYFRMFMT == nFmtWhich || RES_DRAWFRMFMT == nFmtWhich ) - rUndoIter.pSelFmt = (SwFrmFmt*)pFmt; + if ( RES_FLYFRMFMT == m_nFmtWhich || RES_DRAWFRMFMT == m_nFmtWhich ) + { + rUndoIter.pSelFmt = static_cast<SwFrmFmt*>(m_pFmt); + } } } -int SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc ) +bool SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc ) { - // suche im Dokument nach dem Format. Ist es nicht mehr vorhanden - // so wird das Attribut nicht mehr gesetzt ! + // search for the Format in the Document; if it does not exist any more, + // the attribute is not restored! USHORT nPos = USHRT_MAX; - switch( nFmtWhich ) + switch ( m_nFmtWhich ) { - case RES_TXTFMTCOLL: - nPos = pDoc->GetTxtFmtColls()->GetPos( - (const SwTxtFmtCollPtr)pFmt ); - break; + case RES_TXTFMTCOLL: + nPos = pDoc->GetTxtFmtColls()->GetPos( + static_cast<const SwTxtFmtCollPtr>(m_pFmt) ); + break; - case RES_GRFFMTCOLL: - nPos = pDoc->GetGrfFmtColls()->GetPos( - (const SwGrfFmtCollPtr)pFmt ); - break; - case RES_CHRFMT: - nPos = pDoc->GetCharFmts()->GetPos( - (const SwCharFmtPtr)pFmt ); - break; + case RES_GRFFMTCOLL: + nPos = pDoc->GetGrfFmtColls()->GetPos( + static_cast<const SwGrfFmtCollPtr>(m_pFmt) ); + break; - case RES_FRMFMT: - if( nNode && nNode < pDoc->GetNodes().Count() ) - { - SwNode* pNd = pDoc->GetNodes()[ nNode ]; - if( pNd->IsTableNode() ) - { - pFmt = ((SwTableNode*)pNd)->GetTable().GetFrmFmt(); - nPos = 0; - break; - } - else if( pNd->IsSectionNode() ) - { - pFmt = ((SwSectionNode*)pNd)->GetSection().GetFmt(); - nPos = 0; - break; - } - else if( pNd->IsStartNode() && SwTableBoxStartNode == - static_cast< SwStartNode* >(pNd)->GetStartNodeType() ) + case RES_CHRFMT: + nPos = pDoc->GetCharFmts()->GetPos( + static_cast<SwCharFmtPtr>(m_pFmt) ); + break; + + case RES_FRMFMT: + if ( m_nNodeIndex && (m_nNodeIndex < pDoc->GetNodes().Count()) ) { - SwTableNode* pTblNode = pNd->FindTableNode(); - if( pTblNode ) + SwNode* pNd = pDoc->GetNodes()[ m_nNodeIndex ]; + if ( pNd->IsTableNode() ) + { + m_pFmt = + static_cast<SwTableNode*>(pNd)->GetTable().GetFrmFmt(); + nPos = 0; + break; + } + else if ( pNd->IsSectionNode() ) + { + m_pFmt = + static_cast<SwSectionNode*>(pNd)->GetSection().GetFmt(); + nPos = 0; + break; + } + else if ( pNd->IsStartNode() && (SwTableBoxStartNode == + static_cast< SwStartNode* >(pNd)->GetStartNodeType()) ) { - SwTableBox* pBox = pTblNode->GetTable().GetTblBox( nNode ); - if( pBox ) + SwTableNode* pTblNode = pNd->FindTableNode(); + if ( pTblNode ) { - pFmt = pBox->GetFrmFmt(); - nPos = 0; - break; + SwTableBox* pBox = + pTblNode->GetTable().GetTblBox( m_nNodeIndex ); + if ( pBox ) + { + m_pFmt = pBox->GetFrmFmt(); + nPos = 0; + break; + } } } } - } - // kein break! - case RES_DRAWFRMFMT: - case RES_FLYFRMFMT: - if( USHRT_MAX == ( nPos = pDoc->GetSpzFrmFmts()->GetPos( - (const SwFrmFmtPtr)pFmt )) ) - nPos = pDoc->GetFrmFmts()->GetPos( - (const SwFrmFmtPtr)pFmt ); - break; + // no break! + case RES_DRAWFRMFMT: + case RES_FLYFRMFMT: + nPos = pDoc->GetSpzFrmFmts()->GetPos( + static_cast<const SwFrmFmtPtr>(m_pFmt) ); + if ( USHRT_MAX == nPos ) + { + nPos = pDoc->GetFrmFmts()->GetPos( + static_cast<const SwFrmFmtPtr>(m_pFmt) ); + } + break; } - // Format nicht mehr vorhanden, zurueck - if( USHRT_MAX == nPos ) - pFmt = 0; + if ( USHRT_MAX == nPos ) + { + // Format does not exist; reset + m_pFmt = 0; + } - return 0 != pFmt; + return 0 != m_pFmt; } // prueft, ob es noch im Doc ist! SwFmt* SwUndoFmtAttr::GetFmt( SwDoc& rDoc ) { - return pFmt && IsFmtInDoc( &rDoc ) ? pFmt : 0; + return m_pFmt && IsFmtInDoc( &rDoc ) ? m_pFmt : 0; } void SwUndoFmtAttr::Redo( SwUndoIter& rUndoIter) @@ -339,23 +344,29 @@ void SwUndoFmtAttr::Redo( SwUndoIter& rUndoIter) void SwUndoFmtAttr::Repeat( SwUndoIter& rUndoIter) { - if( !pOldSet ) + if ( !m_pOldSet.get() ) return; - SwUndoFmtAttr* pLast; - if( UNDO_INSFMTATTR == rUndoIter.GetLastUndoId() && - ( pLast = ((SwUndoFmtAttr*)rUndoIter.pLastUndoObj))->pOldSet && - pLast->pFmt ) - return; + if ( UNDO_INSFMTATTR == rUndoIter.GetLastUndoId()) + { + SwUndoFmtAttr* pLast + = static_cast<SwUndoFmtAttr*>(rUndoIter.pLastUndoObj); + if (pLast->m_pOldSet.get() && pLast->m_pFmt) + { + return; + } + } - switch( nFmtWhich ) + switch ( m_nFmtWhich ) { case RES_GRFFMTCOLL: { SwNoTxtNode * pNd = rUndoIter.pAktPam->GetNode()->GetNoTxtNode(); if( pNd ) - rUndoIter.GetDoc().SetAttr( pFmt->GetAttrSet(), + { + rUndoIter.GetDoc().SetAttr( m_pFmt->GetAttrSet(), *pNd->GetFmtColl() ); + } } break; @@ -363,8 +374,10 @@ void SwUndoFmtAttr::Repeat( SwUndoIter& rUndoIter) { SwTxtNode * pNd = rUndoIter.pAktPam->GetNode()->GetTxtNode(); if( pNd ) - rUndoIter.GetDoc().SetAttr( pFmt->GetAttrSet(), + { + rUndoIter.GetDoc().SetAttr( m_pFmt->GetAttrSet(), *pNd->GetFmtColl() ); + } } break; @@ -381,15 +394,18 @@ void SwUndoFmtAttr::Repeat( SwUndoIter& rUndoIter) if( pFly ) { // Bug 43672: es duerfen nicht alle Attribute gesetzt werden! - if( SFX_ITEM_SET == pFmt->GetAttrSet().GetItemState( RES_CNTNT )) + if (SFX_ITEM_SET == + m_pFmt->GetAttrSet().GetItemState( RES_CNTNT )) { - SfxItemSet aTmpSet( pFmt->GetAttrSet() ); + SfxItemSet aTmpSet( m_pFmt->GetAttrSet() ); aTmpSet.ClearItem( RES_CNTNT ); if( aTmpSet.Count() ) rUndoIter.GetDoc().SetAttr( aTmpSet, *pFly ); } else - rUndoIter.GetDoc().SetAttr( pFmt->GetAttrSet(), *pFly ); + { + rUndoIter.GetDoc().SetAttr( m_pFmt->GetAttrSet(), *pFly ); + } } break; } @@ -402,30 +418,34 @@ SwRewriter SwUndoFmtAttr::GetRewriter() const { SwRewriter aRewriter; - if (pFmt) - aRewriter.AddRule(UNDO_ARG1, pFmt->GetName()); + if (m_pFmt) + { + aRewriter.AddRule(UNDO_ARG1, m_pFmt->GetName()); + } return aRewriter; } void SwUndoFmtAttr::PutAttr( const SfxPoolItem& rItem ) { - pOldSet->Put( rItem ); - if( RES_ANCHOR == rItem.Which() ) - SaveFlyAnchor( bSaveDrawPt ); + m_pOldSet->Put( rItem ); + if ( RES_ANCHOR == rItem.Which() ) + { + SaveFlyAnchor( m_bSaveDrawPt ); + } } -void SwUndoFmtAttr::SaveFlyAnchor( BOOL bSvDrwPt ) +void SwUndoFmtAttr::SaveFlyAnchor( bool bSvDrwPt ) { // das Format ist gueltig, sonst wuerde man gar bis hier kommen if( bSvDrwPt ) { - if( RES_DRAWFRMFMT == pFmt->Which() ) + if ( RES_DRAWFRMFMT == m_pFmt->Which() ) { - Point aPt( ((SwFrmFmt*)pFmt)->FindSdrObject()->GetRelativePos() ); - // den alten Wert als zwischenspeichern. Attribut dafuer benutzen, - // dadurch bleibt der SwUndoFmtAttr klein. - pOldSet->Put( SwFmtFrmSize( ATT_VAR_SIZE, aPt.X(), aPt.Y() ) ); + Point aPt( static_cast<SwFrmFmt*>(m_pFmt)->FindSdrObject() + ->GetRelativePos() ); + // store old value as attribute, to keep SwUndoFmtAttr small + m_pOldSet->Put( SwFmtFrmSize( ATT_VAR_SIZE, aPt.X(), aPt.Y() ) ); } /* else { @@ -434,8 +454,8 @@ void SwUndoFmtAttr::SaveFlyAnchor( BOOL bSvDrwPt ) } */ } - const SwFmtAnchor& rAnchor = (SwFmtAnchor&)pOldSet->Get( - RES_ANCHOR, FALSE ); + const SwFmtAnchor& rAnchor = + static_cast<const SwFmtAnchor&>( m_pOldSet->Get( RES_ANCHOR, FALSE ) ); if( !rAnchor.GetCntntAnchor() ) return; @@ -447,14 +467,14 @@ void SwUndoFmtAttr::SaveFlyAnchor( BOOL bSvDrwPt ) nCntnt = rAnchor.GetCntntAnchor()->nContent.GetIndex(); case FLY_AT_CNTNT: case FLY_AT_FLY: - nNode = rAnchor.GetCntntAnchor()->nNode.GetIndex(); + m_nNodeIndex = rAnchor.GetCntntAnchor()->nNode.GetIndex(); break; default: return; } SwFmtAnchor aAnchor( rAnchor.GetAnchorId(), nCntnt ); - pOldSet->Put( aAnchor ); + m_pOldSet->Put( aAnchor ); } // --> OD 2004-10-26 #i35443# - Add return value, type <bool>. @@ -464,18 +484,19 @@ void SwUndoFmtAttr::SaveFlyAnchor( BOOL bSvDrwPt ) bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) { SwDoc* pDoc = &rIter.GetDoc(); - SwFlyFrmFmt* pFrmFmt = (SwFlyFrmFmt*)pFmt; - const SwFmtAnchor& rAnchor = (SwFmtAnchor&)pOldSet->Get( - RES_ANCHOR, FALSE ); + SwFlyFrmFmt* pFrmFmt = static_cast<SwFlyFrmFmt*>(m_pFmt); + const SwFmtAnchor& rAnchor = + static_cast<const SwFmtAnchor&>( m_pOldSet->Get( RES_ANCHOR, FALSE ) ); SwFmtAnchor aNewAnchor( rAnchor.GetAnchorId() ); if( FLY_PAGE != rAnchor.GetAnchorId() ) { - SwNode* pNd = pDoc->GetNodes()[ nNode ]; + SwNode* pNd = pDoc->GetNodes()[ m_nNodeIndex ]; - if( FLY_AT_FLY == rAnchor.GetAnchorId() ? ( !pNd->IsStartNode() || - SwFlyStartNode != ((SwStartNode*)pNd)->GetStartNodeType() ) : - !pNd->IsTxtNode() ) + if ( (FLY_AT_FLY == rAnchor.GetAnchorId()) + ? ( !pNd->IsStartNode() || (SwFlyStartNode != + static_cast<SwStartNode*>(pNd)->GetStartNodeType()) ) + : !pNd->IsTxtNode() ) { // --> OD 2004-10-26 #i35443# - invalid position. // Thus, anchor attribute not restored @@ -488,7 +509,8 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) { aPos.nContent.Assign( (SwTxtNode*)pNd, rAnchor.GetPageNum() ); - if( aPos.nContent.GetIndex() > ((SwTxtNode*)pNd)->GetTxt().Len() ) + if ( aPos.nContent.GetIndex() > + static_cast<SwTxtNode*>(pNd)->GetTxt().Len() ) { // --> OD 2004-10-26 #i35443# - invalid position. // Thus, anchor attribute not restored @@ -507,11 +529,11 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) if( RES_DRAWFRMFMT == pFrmFmt->Which() ) { // den alten zwischengespeicherten Wert herausholen. - const SwFmtFrmSize& rOldSize = (const SwFmtFrmSize&) - pOldSet->Get( RES_FRM_SIZE ); + const SwFmtFrmSize& rOldSize = static_cast<const SwFmtFrmSize&>( + m_pOldSet->Get( RES_FRM_SIZE ) ); aDrawSavePt.X() = rOldSize.GetWidth(); aDrawSavePt.Y() = rOldSize.GetHeight(); - pOldSet->ClearItem( RES_FRM_SIZE ); + m_pOldSet->ClearItem( RES_FRM_SIZE ); // den akt. wieder zwischenspeichern aDrawOldPt = pFrmFmt->FindSdrObject()->GetRelativePos(); @@ -519,7 +541,9 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) // pCont->DisconnectFromLayout(); } else - pFrmFmt->DelFrms(); // Frms vernichten. + { + pFrmFmt->DelFrms(); // delete Frms + } } const SwFmtAnchor &rOldAnch = pFrmFmt->GetAnchor(); @@ -543,7 +567,7 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) 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. @@ -551,25 +575,25 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) } { - pOldSet->Put( aNewAnchor ); - _UndoFmtAttr aTmp( *pFmt, bSaveDrawPt ); - pFmt->SetFmtAttr( *pOldSet ); - if( aTmp.pUndo ) + m_pOldSet->Put( aNewAnchor ); + SwUndoFmtAttrHelper aTmp( *m_pFmt, m_bSaveDrawPt ); + m_pFmt->SetFmtAttr( *m_pOldSet ); + if ( aTmp.GetUndo() ) { - delete pOldSet; - nNode = aTmp.pUndo->nNode; - pOldSet = aTmp.pUndo->pOldSet; - aTmp.pUndo->pOldSet = 0; // den Pointer auf 0 setzen (nicht - // doppelt loeschen) !! - delete aTmp.pUndo; // Undo-Object wieder loeschen + m_nNodeIndex = aTmp.GetUndo()->m_nNodeIndex; + // transfer ownership of helper object's old set + m_pOldSet = aTmp.GetUndo()->m_pOldSet; } else - pOldSet->ClearItem(); + { + m_pOldSet->ClearItem(); + } } - if( RES_DRAWFRMFMT == pFrmFmt->Which() ) + if ( RES_DRAWFRMFMT == pFrmFmt->Which() ) { - SwDrawContact *pCont = (SwDrawContact*)pFrmFmt->FindContactObj(); + SwDrawContact *pCont = + static_cast<SwDrawContact*>(pFrmFmt->FindContactObj()); // das Draw-Model hat auch noch ein Undo-Object fuer die // richtige Position vorbereitet; dieses ist aber relativ. // Darum verhinder hier, das durch setzen des Ankers das @@ -586,7 +610,8 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) pObj->SetRelativePos( aDrawSavePt ); // den alten Wert wieder zwischenspeichern. - pOldSet->Put( SwFmtFrmSize( ATT_VAR_SIZE, aDrawOldPt.X(), aDrawOldPt.Y() ) ); + m_pOldSet->Put( + SwFmtFrmSize( ATT_VAR_SIZE, aDrawOldPt.X(), aDrawOldPt.Y() ) ); } if( FLY_IN_CNTNT == aNewAnchor.GetAnchorId() ) @@ -608,73 +633,75 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) // <-- } +// ----------------------------------------------------- + // --> OD 2008-02-12 #newlistlevelattrs# SwUndoFmtResetAttr::SwUndoFmtResetAttr( SwFmt& rChangedFormat, const USHORT nWhichId ) - : SwUndo( UNDO_RESETATTR ), - mpChangedFormat( &rChangedFormat ), - mnWhichId( nWhichId ), - mpOldItem( 0 ) + : SwUndo( UNDO_RESETATTR ) + , m_pChangedFormat( &rChangedFormat ) + , m_nWhichId( nWhichId ) + , m_pOldItem( 0 ) { const SfxPoolItem* pItem = 0; - if ( rChangedFormat.GetItemState( nWhichId, FALSE, &pItem ) == SFX_ITEM_SET ) + if (rChangedFormat.GetItemState( nWhichId, FALSE, &pItem ) == SFX_ITEM_SET) { - mpOldItem = pItem->Clone(); + m_pOldItem.reset( pItem->Clone() ); } } SwUndoFmtResetAttr::~SwUndoFmtResetAttr() { - delete mpOldItem; } void SwUndoFmtResetAttr::Undo( SwUndoIter& ) { - if ( mpOldItem ) + if ( m_pOldItem.get() ) { - mpChangedFormat->SetFmtAttr( *mpOldItem ); + m_pChangedFormat->SetFmtAttr( *m_pOldItem ); } } void SwUndoFmtResetAttr::Redo( SwUndoIter& ) { - if ( mpOldItem ) + if ( m_pOldItem.get() ) { - mpChangedFormat->ResetFmtAttr( mnWhichId ); + m_pChangedFormat->ResetFmtAttr( m_nWhichId ); } } // <-- -/* */ +// ----------------------------------------------------- -SwUndoRstAttr::SwUndoRstAttr( const SwPaM& rRange, USHORT nFmt ) - : SwUndo( UNDO_RESETATTR ), SwUndRng( rRange ), - pHistory( new SwHistory ), nFmtId( nFmt ) +SwUndoResetAttr::SwUndoResetAttr( const SwPaM& rRange, USHORT nFmtId ) + : SwUndo( UNDO_RESETATTR ), SwUndRng( rRange ) + , m_pHistory( new SwHistory ) + , m_nFormatId( nFmtId ) { } -SwUndoRstAttr::SwUndoRstAttr( const SwDoc& , const SwPosition& rPos, - USHORT nWhich ) - : SwUndo( UNDO_RESETATTR ), pHistory( new SwHistory ), nFmtId( nWhich ) +SwUndoResetAttr::SwUndoResetAttr( const SwPosition& rPos, USHORT nFmtId ) + : SwUndo( UNDO_RESETATTR ) + , m_pHistory( new SwHistory ) + , m_nFormatId( nFmtId ) { nSttNode = nEndNode = rPos.nNode.GetIndex(); nSttCntnt = nEndCntnt = rPos.nContent.GetIndex(); } -SwUndoRstAttr::~SwUndoRstAttr() +SwUndoResetAttr::~SwUndoResetAttr() { - delete pHistory; } -void SwUndoRstAttr::Undo( SwUndoIter& rUndoIter ) +void SwUndoResetAttr::Undo( SwUndoIter& rUndoIter ) { - // die alten Werte wieder zurueck + // reset old values SwDoc& rDoc = rUndoIter.GetDoc(); - pHistory->TmpRollback( &rDoc, 0 ); - pHistory->SetTmpEnd( pHistory->Count() ); + m_pHistory->TmpRollback( &rDoc, 0 ); + m_pHistory->SetTmpEnd( m_pHistory->Count() ); - if( RES_CONDTXTFMTCOLL == nFmtId && nSttNode == nEndNode && - nSttCntnt == nEndCntnt ) + if ((RES_CONDTXTFMTCOLL == m_nFormatId) && + (nSttNode == nEndNode) && (nSttCntnt == nEndCntnt)) { SwTxtNode* pTNd = rDoc.GetNodes()[ nSttNode ]->GetTxtNode(); if( pTNd ) @@ -688,15 +715,15 @@ void SwUndoRstAttr::Undo( SwUndoIter& rUndoIter ) SetPaM( rUndoIter ); } -void SwUndoRstAttr::Redo( SwUndoIter& rUndoIter ) +void SwUndoResetAttr::Redo( SwUndoIter& rUndoIter ) { // setze Attribut in dem Bereich: SetPaM( rUndoIter ); SwDoc& rDoc = rUndoIter.GetDoc(); rUndoIter.pLastUndoObj = 0; - SvUShortsSort* pIdArr = aIds.Count() ? &aIds : 0; + SvUShortsSort* pIdArr = m_Ids.Count() ? &m_Ids : 0; - switch( nFmtId ) + switch ( m_nFormatId ) { case RES_CHRFMT: rUndoIter.GetDoc().RstTxtAttrs( *rUndoIter.pAktPam ); @@ -709,7 +736,7 @@ void SwUndoRstAttr::Redo( SwUndoIter& rUndoIter ) break; case RES_TXTATR_TOXMARK: - // Sonderbehandlung fuer TOXMarks + // special treatment for TOXMarks { SwTOXMarks aArr; SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode ); @@ -721,17 +748,19 @@ void SwUndoRstAttr::Redo( SwUndoIter& rUndoIter ) { if( 1 < nCnt ) { - // dann den richtigen suchen - SwHstryHint* pHHint = (*GetHistory())[ 0 ]; + // search for the right one + SwHistoryHint* pHHint = (GetHistory())[ 0 ]; if( pHHint && HSTRY_SETTOXMARKHNT == pHHint->Which() ) { while( nCnt ) - if( ((SwSetTOXMarkHint*)pHHint)->IsEqual( - *aArr[ --nCnt ] ) ) + { + if ( static_cast<SwHistorySetTOXMark*>(pHHint) + ->IsEqual( *aArr[ --nCnt ] ) ) { ++nCnt; break; } + } } else nCnt = 0; @@ -746,15 +775,18 @@ void SwUndoRstAttr::Redo( SwUndoIter& rUndoIter ) rUndoIter.pLastUndoObj = 0; } -void SwUndoRstAttr::Repeat( SwUndoIter& rUndoIter ) +void SwUndoResetAttr::Repeat( SwUndoIter& rUndoIter ) { - if( RES_FMT_BEGIN > nFmtId || - ( UNDO_RESETATTR == rUndoIter.GetLastUndoId() && - nFmtId == ((SwUndoRstAttr*)rUndoIter.pLastUndoObj)->nFmtId )) + if ( (RES_FMT_BEGIN > m_nFormatId) || + ( (UNDO_RESETATTR == rUndoIter.GetLastUndoId()) && + (m_nFormatId == static_cast<SwUndoResetAttr*>(rUndoIter.pLastUndoObj) + ->m_nFormatId) ) ) + { return; + } - SvUShortsSort* pIdArr = aIds.Count() ? &aIds : 0; - switch( nFmtId ) + SvUShortsSort* pIdArr = m_Ids.Count() ? &m_Ids : 0; + switch ( m_nFormatId ) { case RES_CHRFMT: rUndoIter.GetDoc().RstTxtAttrs( *rUndoIter.pAktPam ); @@ -770,59 +802,69 @@ void SwUndoRstAttr::Repeat( SwUndoIter& rUndoIter ) } -void SwUndoRstAttr::SetAttrs( const SvUShortsSort& rArr ) +void SwUndoResetAttr::SetAttrs( const SvUShortsSort& rArr ) { - if( aIds.Count() ) - aIds.Remove( 0, aIds.Count() ); - aIds.Insert( &rArr ); + if ( m_Ids.Count() ) + { + m_Ids.Remove( 0, m_Ids.Count() ); + } + m_Ids.Insert( &rArr ); } // ----------------------------------------------------- - SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxPoolItem& rAttr, USHORT nFlags ) - : SwUndo( UNDO_INSATTR ), SwUndRng( rRange ), - aSet( rRange.GetDoc()->GetAttrPool(), rAttr.Which(), rAttr.Which() ), - pHistory( new SwHistory ), - pRedlData( 0 ), pRedlSaveData( 0 ), - nNdIdx( ULONG_MAX ), nInsFlags( nFlags ) + : SwUndo( UNDO_INSATTR ), SwUndRng( rRange ) + , m_AttrSet( rRange.GetDoc()->GetAttrPool(), rAttr.Which(), rAttr.Which() ) + , m_pHistory( new SwHistory ) + , m_pRedlineData( 0 ) + , m_pRedlineSaveData( 0 ) + , m_nNodeIndex( ULONG_MAX ) + , m_nInsertFlags( nFlags ) { - aSet.Put( rAttr ); + m_AttrSet.Put( rAttr ); } SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxItemSet& rSet, USHORT nFlags ) - : SwUndo( UNDO_INSATTR ), SwUndRng( rRange ), aSet( rSet ), - pHistory( new SwHistory ), - pRedlData( 0 ), pRedlSaveData( 0 ), - nNdIdx( ULONG_MAX ), nInsFlags( nFlags ) + : SwUndo( UNDO_INSATTR ), SwUndRng( rRange ) + , m_AttrSet( rSet ) + , m_pHistory( new SwHistory ) + , m_pRedlineData( 0 ) + , m_pRedlineSaveData( 0 ) + , m_nNodeIndex( ULONG_MAX ) + , m_nInsertFlags( nFlags ) { } SwUndoAttr::~SwUndoAttr() { - delete pHistory; - delete pRedlData; - delete pRedlSaveData; } void SwUndoAttr::SaveRedlineData( const SwPaM& rPam, BOOL bIsCntnt ) { SwDoc* pDoc = rPam.GetDoc(); - if( pDoc->IsRedlineOn() ) - pRedlData = new SwRedlineData( bIsCntnt ? nsRedlineType_t::REDLINE_INSERT - : nsRedlineType_t::REDLINE_FORMAT, - pDoc->GetRedlineAuthor() ); + if ( pDoc->IsRedlineOn() ) + { + m_pRedlineData.reset( new SwRedlineData( bIsCntnt + ? nsRedlineType_t::REDLINE_INSERT + : nsRedlineType_t::REDLINE_FORMAT, + pDoc->GetRedlineAuthor() ) ); + } - pRedlSaveData = new SwRedlineSaveDatas; - if( !FillSaveDataForFmt( rPam, *pRedlSaveData )) - delete pRedlSaveData, pRedlSaveData = 0; + m_pRedlineSaveData.reset( new SwRedlineSaveDatas ); + if ( !FillSaveDataForFmt( rPam, *m_pRedlineSaveData )) + { + m_pRedlineSaveData.reset(0); + } SetRedlineMode( pDoc->GetRedlineMode() ); - if( bIsCntnt ) - nNdIdx = rPam.GetPoint()->nNode.GetIndex(); + if ( bIsCntnt ) + { + m_nNodeIndex = rPam.GetPoint()->nNode.GetIndex(); + } } void SwUndoAttr::Undo( SwUndoIter& rUndoIter ) @@ -834,10 +876,10 @@ void SwUndoAttr::Undo( SwUndoIter& rUndoIter ) if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) ) { SwPaM& rPam = *rUndoIter.pAktPam; - if( ULONG_MAX != nNdIdx ) + if ( ULONG_MAX != m_nNodeIndex ) { rPam.DeleteMark(); - rPam.GetPoint()->nNode = nNdIdx; + rPam.GetPoint()->nNode = m_nNodeIndex; rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nSttCntnt ); rPam.SetMark(); rPam.GetPoint()->nContent++; @@ -848,20 +890,22 @@ void SwUndoAttr::Undo( SwUndoIter& rUndoIter ) // alle Format-Redlines entfernen, werden ggfs. neu gesetzt SetPaM( rUndoIter ); pDoc->DeleteRedline( rPam, false, nsRedlineType_t::REDLINE_FORMAT ); - if( pRedlSaveData ) - SetSaveData( *pDoc, *pRedlSaveData ); + if ( m_pRedlineSaveData.get() ) + { + SetSaveData( *pDoc, *m_pRedlineSaveData ); + } } } - BOOL bToLast = 1 == aSet.Count() && - RES_TXTATR_FIELD <= *aSet.GetRanges() && - *aSet.GetRanges() <= RES_TXTATR_HARDBLANK; + const bool bToLast = (1 == m_AttrSet.Count()) + && (RES_TXTATR_FIELD <= *m_AttrSet.GetRanges()) + && (*m_AttrSet.GetRanges() <= RES_TXTATR_HARDBLANK); - // die alten Werte wieder zurueck - pHistory->TmpRollback( pDoc, 0, !bToLast ); - pHistory->SetTmpEnd( pHistory->Count() ); + // restore old values + m_pHistory->TmpRollback( pDoc, 0, !bToLast ); + m_pHistory->SetTmpEnd( m_pHistory->Count() ); - // setze noch den Cursor auf den Undo-Bereich + // set cursor onto Undo area SetPaM( rUndoIter ); } @@ -889,22 +933,30 @@ int lcl_HasEqualItems( const SfxItemSet& rSet1, const SfxItemSet& rSet2 ) void SwUndoAttr::Repeat( SwUndoIter& rUndoIter ) { - SwUndoAttr* pLast; - if( UNDO_INSATTR == rUndoIter.GetLastUndoId() && - ( pLast = ((SwUndoAttr*)rUndoIter.pLastUndoObj))->aSet.Count() == - aSet.Count() && pLast->nInsFlags == nInsFlags && - lcl_HasEqualItems( aSet, pLast->aSet )) - return; + if ( UNDO_INSATTR == rUndoIter.GetLastUndoId() ) + { + SwUndoAttr* pLast = static_cast<SwUndoAttr*>(rUndoIter.pLastUndoObj); + if ((pLast->m_AttrSet.Count() == m_AttrSet.Count()) && + (pLast->m_nInsertFlags == m_nInsertFlags ) && + lcl_HasEqualItems( m_AttrSet, pLast->m_AttrSet )) + { + return; + } + } - // RefMarks sind nicht repeatfaehig - if( SFX_ITEM_SET != aSet.GetItemState( RES_TXTATR_REFMARK, FALSE ) ) - rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, aSet, nInsFlags ); - else if( 1 < aSet.Count() ) + // RefMarks are not repeat capable + if ( SFX_ITEM_SET != m_AttrSet.GetItemState( RES_TXTATR_REFMARK, FALSE ) ) { - SfxItemSet aTmpSet( aSet ); + rUndoIter.GetDoc().Insert( *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, nInsFlags ); + rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, + aTmpSet, m_nInsertFlags ); } rUndoIter.pLastUndoObj = this; } @@ -916,26 +968,35 @@ void SwUndoAttr::Redo( SwUndoIter& rUndoIter ) SwPaM& rPam = *rUndoIter.pAktPam; SwDoc& rDoc = rUndoIter.GetDoc(); - if( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) ) + if ( m_pRedlineData.get() && + IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) ) { RedlineMode_t eOld = rDoc.GetRedlineMode(); - rDoc.SetRedlineMode_intern((RedlineMode_t)(eOld & ~nsRedlineMode_t::REDLINE_IGNORE)); - rDoc.Insert( rPam, aSet, nInsFlags ); + rDoc.SetRedlineMode_intern(static_cast<RedlineMode_t>( + eOld & ~nsRedlineMode_t::REDLINE_IGNORE)); + rDoc.Insert( rPam, m_AttrSet, m_nInsertFlags ); - if( ULONG_MAX != nNdIdx ) + if ( ULONG_MAX != m_nNodeIndex ) { rPam.SetMark(); - if( rPam.Move( fnMoveBackward ) ) - rDoc.AppendRedline( new SwRedline( *pRedlData, rPam ), true); + if ( rPam.Move( fnMoveBackward ) ) + { + rDoc.AppendRedline( new SwRedline( *m_pRedlineData, rPam ), + true); + } rPam.DeleteMark(); } else - rDoc.AppendRedline( new SwRedline( *pRedlData, rPam ), true); + { + rDoc.AppendRedline( new SwRedline( *m_pRedlineData, rPam ), true); + } rDoc.SetRedlineMode_intern( eOld ); } else - rDoc.Insert( rPam, aSet, nInsFlags ); + { + rDoc.Insert( rPam, m_AttrSet, m_nInsertFlags ); + } rUndoIter.pLastUndoObj = 0; } @@ -943,38 +1004,52 @@ void SwUndoAttr::Redo( SwUndoIter& rUndoIter ) void SwUndoAttr::RemoveIdx( SwDoc& rDoc ) { - if( SFX_ITEM_SET != aSet.GetItemState( RES_TXTATR_FTN, FALSE )) + if ( SFX_ITEM_SET != m_AttrSet.GetItemState( RES_TXTATR_FTN, FALSE )) return ; - SwHstryHint* pHstHnt; + SwHistoryHint* pHstHnt; SwNodes& rNds = rDoc.GetNodes(); - for( USHORT n = 0; n < pHistory->Count(); ++n ) + for ( USHORT n = 0; n < m_pHistory->Count(); ++n ) { xub_StrLen nCntnt = 0; ULONG nNode = 0; - switch( ( pHstHnt = (*pHistory)[ n ] )->Which() ) + pHstHnt = (*m_pHistory)[ n ]; + switch ( pHstHnt->Which() ) { - case HSTRY_RESETTXTHNT: - if( RES_TXTATR_FTN == ((SwResetTxtHint*)pHstHnt)->GetWhich() ) - { - nNode = ((SwResetTxtHint*)pHstHnt)->GetNode(); - nCntnt = ((SwResetTxtHint*)pHstHnt)->GetCntnt(); - } - break; - case HSTRY_RESETATTRSET: - if( STRING_MAXLEN != ( nCntnt = - ((SwHstryResetAttrSet*)pHstHnt)->GetCntnt() )) - { - const SvUShorts& rArr = ((SwHstryResetAttrSet*)pHstHnt)->GetArr(); - for( USHORT i = rArr.Count(); i; ) - if( RES_TXTATR_FTN == rArr[ --i ] ) + case HSTRY_RESETTXTHNT: + { + SwHistoryResetTxt * pHistoryHint + = static_cast<SwHistoryResetTxt*>(pHstHnt); + if ( RES_TXTATR_FTN == pHistoryHint->GetWhich() ) { - nNode = ((SwHstryResetAttrSet*)pHstHnt)->GetNode(); - break; + nNode = pHistoryHint->GetNode(); + nCntnt = pHistoryHint->GetCntnt(); } - } - break; - default: break; + } + break; + + case HSTRY_RESETATTRSET: + { + SwHistoryResetAttrSet * pHistoryHint + = static_cast<SwHistoryResetAttrSet*>(pHstHnt); + nCntnt = pHistoryHint->GetCntnt(); + if ( STRING_MAXLEN != nCntnt ) + { + const SvUShorts& rArr = pHistoryHint->GetArr(); + for ( USHORT i = rArr.Count(); i; ) + { + if ( RES_TXTATR_FTN == rArr[ --i ] ) + { + nNode = pHistoryHint->GetNode(); + break; + } + } + } + } + break; + + default: + break; } if( nNode ) @@ -987,7 +1062,7 @@ void SwUndoAttr::RemoveIdx( SwDoc& rDoc ) if( pTxtHt ) { // ok, dann hole mal die Werte - SwTxtFtn* pFtn = (SwTxtFtn*)pTxtHt; + SwTxtFtn* pFtn = static_cast<SwTxtFtn*>(pTxtHt); RemoveIdxFromSection( rDoc, pFtn->GetStartNode()->GetIndex() ); return ; } @@ -996,55 +1071,54 @@ void SwUndoAttr::RemoveIdx( SwDoc& rDoc ) } } -/* */ +// ----------------------------------------------------- SwUndoDefaultAttr::SwUndoDefaultAttr( const SfxItemSet& rSet ) - : SwUndo( UNDO_SETDEFTATTR ), pOldSet( 0 ), pTabStop( 0 ) + : SwUndo( UNDO_SETDEFTATTR ) + , m_pOldSet( 0 ) + , m_pTabStop( 0 ) { const SfxPoolItem* pItem; if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_TABSTOP, FALSE, &pItem ) ) { - pTabStop = (SvxTabStopItem*)pItem->Clone(); // gesondert merken, aendert sich !!! - if( 1 != rSet.Count() ) // gibts noch mehr Attribute ? - pOldSet = new SfxItemSet( rSet ); + // store separately, because it may change! + m_pTabStop.reset( static_cast<SvxTabStopItem*>(pItem->Clone()) ); + if ( 1 != rSet.Count() ) // are there more attributes? + { + m_pOldSet.reset( new SfxItemSet( rSet ) ); + } } else - pOldSet = new SfxItemSet( rSet ); + { + m_pOldSet.reset( new SfxItemSet( rSet ) ); + } } SwUndoDefaultAttr::~SwUndoDefaultAttr() { - if( pOldSet ) - delete pOldSet; - if( pTabStop ) - delete pTabStop; } void SwUndoDefaultAttr::Undo( SwUndoIter& rUndoIter) { SwDoc& rDoc = rUndoIter.GetDoc(); - if( pOldSet ) + if ( m_pOldSet.get() ) { - _UndoFmtAttr aTmp( *(SwTxtFmtColl*)rDoc.GetDfltTxtFmtColl() ); - rDoc.SetDefault( *pOldSet ); - delete pOldSet; - if( aTmp.pUndo ) + SwUndoFmtAttrHelper aTmp( + *const_cast<SwTxtFmtColl*>(rDoc.GetDfltTxtFmtColl()) ); + rDoc.SetDefault( *m_pOldSet ); + m_pOldSet.reset( 0 ); + if ( aTmp.GetUndo() ) { - pOldSet = aTmp.pUndo->pOldSet; - aTmp.pUndo->pOldSet = 0; // den Pointer auf 0 setzen (nicht - // doppelt loeschen) !! - delete aTmp.pUndo; // Undo-Object wieder loeschen + // transfer ownership of helper object's old set + m_pOldSet = aTmp.GetUndo()->m_pOldSet; } - else - pOldSet = 0; } - if( pTabStop ) + if ( m_pTabStop.get() ) { - SvxTabStopItem* pOld = (SvxTabStopItem*)rDoc.GetDefault( - RES_PARATR_TABSTOP ).Clone(); - rDoc.SetDefault( *pTabStop ); - delete pTabStop; - pTabStop = pOld; + SvxTabStopItem* pOld = static_cast<SvxTabStopItem*>( + rDoc.GetDefault( RES_PARATR_TABSTOP ).Clone() ); + rDoc.SetDefault( *m_pTabStop ); + m_pTabStop.reset( pOld ); } } @@ -1053,19 +1127,19 @@ void SwUndoDefaultAttr::Redo( SwUndoIter& rUndoIter) Undo( rUndoIter ); } -/* */ +// ----------------------------------------------------- -SwUndoMoveLeftMargin::SwUndoMoveLeftMargin( const SwPaM& rPam, BOOL bFlag, - BOOL bMod ) - : SwUndo( bFlag ? UNDO_INC_LEFTMARGIN : UNDO_DEC_LEFTMARGIN ), - SwUndRng( rPam ), bModulus( bMod ) +SwUndoMoveLeftMargin::SwUndoMoveLeftMargin( + const SwPaM& rPam, BOOL bFlag, BOOL bMod ) + : SwUndo( bFlag ? UNDO_INC_LEFTMARGIN : UNDO_DEC_LEFTMARGIN ) + , SwUndRng( rPam ) + , m_pHistory( new SwHistory ) + , m_bModulus( bMod ) { - pHistory = new SwHistory; } SwUndoMoveLeftMargin::~SwUndoMoveLeftMargin() { - delete pHistory; } void SwUndoMoveLeftMargin::Undo( SwUndoIter& rIter ) @@ -1074,9 +1148,9 @@ void SwUndoMoveLeftMargin::Undo( SwUndoIter& rIter ) BOOL bUndo = pDoc->DoesUndo(); pDoc->DoUndo( FALSE ); - // die alten Werte wieder zurueck - pHistory->TmpRollback( pDoc, 0 ); - pHistory->SetTmpEnd( pHistory->Count() ); + // restore old values + m_pHistory->TmpRollback( pDoc, 0 ); + m_pHistory->SetTmpEnd( m_pHistory->Count() ); pDoc->DoUndo( bUndo ); SetPaM( rIter ); @@ -1086,32 +1160,36 @@ void SwUndoMoveLeftMargin::Redo( SwUndoIter& rIter ) { SwDoc* pDoc = &rIter.GetDoc(); SetPaM( rIter ); - pDoc->MoveLeftMargin( *rIter.pAktPam, GetId() == UNDO_INC_LEFTMARGIN, bModulus ); + pDoc->MoveLeftMargin( *rIter.pAktPam, GetId() == UNDO_INC_LEFTMARGIN, + m_bModulus ); } void SwUndoMoveLeftMargin::Repeat( SwUndoIter& rIter ) { SwDoc* pDoc = &rIter.GetDoc(); - pDoc->MoveLeftMargin( *rIter.pAktPam, GetId() == UNDO_INC_LEFTMARGIN, bModulus ); + pDoc->MoveLeftMargin( *rIter.pAktPam, GetId() == UNDO_INC_LEFTMARGIN, + m_bModulus ); rIter.pLastUndoObj = this; } -/* */ +// ----------------------------------------------------- -SwUndoChgFtn::SwUndoChgFtn( const SwPaM& rRange, const String& rTxt, - USHORT nNum, BOOL bIsEndNote ) - : SwUndo( UNDO_CHGFTN ), SwUndRng( rRange ), - pHistory( new SwHistory() ), - sTxt( rTxt ), nNo( nNum ), bEndNote( bIsEndNote ) +SwUndoChangeFootNote::SwUndoChangeFootNote( + const SwPaM& rRange, const String& rTxt, + USHORT nNum, bool bIsEndNote ) + : SwUndo( UNDO_CHGFTN ), SwUndRng( rRange ) + , m_pHistory( new SwHistory() ) + , m_Text( rTxt ) + , m_nNumber( nNum ) + , m_bEndNote( bIsEndNote ) { } -SwUndoChgFtn::~SwUndoChgFtn() +SwUndoChangeFootNote::~SwUndoChangeFootNote() { - delete pHistory; } -void SwUndoChgFtn::Undo( SwUndoIter& rIter ) +void SwUndoChangeFootNote::Undo( SwUndoIter& rIter ) { SwDoc& rDoc = rIter.GetDoc(); SetPaM( rIter ); @@ -1119,8 +1197,8 @@ void SwUndoChgFtn::Undo( SwUndoIter& rIter ) BOOL bUndo = rDoc.DoesUndo(); rDoc.DoUndo( FALSE ); - pHistory->TmpRollback( &rDoc, 0 ); - pHistory->SetTmpEnd( pHistory->Count() ); + m_pHistory->TmpRollback( &rDoc, 0 ); + m_pHistory->SetTmpEnd( m_pHistory->Count() ); rDoc.GetFtnIdxs().UpdateAllFtn(); @@ -1128,89 +1206,85 @@ void SwUndoChgFtn::Undo( SwUndoIter& rIter ) rDoc.DoUndo( bUndo ); } -void SwUndoChgFtn::Redo( SwUndoIter& rIter ) +void SwUndoChangeFootNote::Redo( SwUndoIter& rIter ) { SetPaM( rIter ); - rIter.GetDoc().SetCurFtn( *rIter.pAktPam, sTxt, nNo, bEndNote ); + rIter.GetDoc().SetCurFtn( *rIter.pAktPam, m_Text, m_nNumber, m_bEndNote ); SetPaM( rIter ); } -void SwUndoChgFtn::Repeat( SwUndoIter& rIter ) +void SwUndoChangeFootNote::Repeat( SwUndoIter& rIter ) { SwDoc& rDoc = rIter.GetDoc(); - rDoc.SetCurFtn( *rIter.pAktPam, sTxt, nNo, bEndNote ); + rDoc.SetCurFtn( *rIter.pAktPam, m_Text, m_nNumber, m_bEndNote ); rIter.pLastUndoObj = this; } -/* */ +// ----------------------------------------------------- -SwUndoFtnInfo::SwUndoFtnInfo( const SwFtnInfo &rInfo ) : - SwUndo( UNDO_FTNINFO ), - pFtnInfo( new SwFtnInfo( rInfo ) ) +SwUndoFootNoteInfo::SwUndoFootNoteInfo( const SwFtnInfo &rInfo ) + : SwUndo( UNDO_FTNINFO ) + , m_pFootNoteInfo( new SwFtnInfo( rInfo ) ) { } -SwUndoFtnInfo::~SwUndoFtnInfo() +SwUndoFootNoteInfo::~SwUndoFootNoteInfo() { - delete pFtnInfo; } -void SwUndoFtnInfo::Undo( SwUndoIter &rIter ) +void SwUndoFootNoteInfo::Undo( SwUndoIter &rIter ) { SwDoc &rDoc = rIter.GetDoc(); SwFtnInfo *pInf = new SwFtnInfo( rDoc.GetFtnInfo() ); - rDoc.SetFtnInfo( *pFtnInfo ); - delete pFtnInfo; - pFtnInfo = pInf; + rDoc.SetFtnInfo( *m_pFootNoteInfo ); + m_pFootNoteInfo.reset( pInf ); } -void SwUndoFtnInfo::Redo( SwUndoIter &rIter ) +void SwUndoFootNoteInfo::Redo( SwUndoIter &rIter ) { SwDoc &rDoc = rIter.GetDoc(); SwFtnInfo *pInf = new SwFtnInfo( rDoc.GetFtnInfo() ); - rDoc.SetFtnInfo( *pFtnInfo ); - delete pFtnInfo; - pFtnInfo = pInf; + rDoc.SetFtnInfo( *m_pFootNoteInfo ); + m_pFootNoteInfo.reset( pInf ); } -/* */ -SwUndoEndNoteInfo::SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo ) : - SwUndo( UNDO_FTNINFO ), - pEndNoteInfo( new SwEndNoteInfo( rInfo ) ) +// ----------------------------------------------------- + +SwUndoEndNoteInfo::SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo ) + : SwUndo( UNDO_FTNINFO ) + , m_pEndNoteInfo( new SwEndNoteInfo( rInfo ) ) { } SwUndoEndNoteInfo::~SwUndoEndNoteInfo() { - delete pEndNoteInfo; } void SwUndoEndNoteInfo::Undo( SwUndoIter &rIter ) { SwDoc &rDoc = rIter.GetDoc(); SwEndNoteInfo *pInf = new SwEndNoteInfo( rDoc.GetEndNoteInfo() ); - rDoc.SetEndNoteInfo( *pEndNoteInfo ); - delete pEndNoteInfo; - pEndNoteInfo = pInf; + rDoc.SetEndNoteInfo( *m_pEndNoteInfo ); + m_pEndNoteInfo.reset( pInf ); } void SwUndoEndNoteInfo::Redo( SwUndoIter &rIter ) { SwDoc &rDoc = rIter.GetDoc(); SwEndNoteInfo *pInf = new SwEndNoteInfo( rDoc.GetEndNoteInfo() ); - rDoc.SetEndNoteInfo( *pEndNoteInfo ); - delete pEndNoteInfo; - pEndNoteInfo = pInf; + rDoc.SetEndNoteInfo( *m_pEndNoteInfo ); + m_pEndNoteInfo.reset( pInf ); } -/* */ +// ----------------------------------------------------- SwUndoDontExpandFmt::SwUndoDontExpandFmt( const SwPosition& rPos ) - : SwUndo( UNDO_DONTEXPAND ), - nNode( rPos.nNode.GetIndex() ), nCntnt( rPos.nContent.GetIndex() ) + : SwUndo( UNDO_DONTEXPAND ) + , m_nNodeIndex( rPos.nNode.GetIndex() ) + , m_nContentIndex( rPos.nContent.GetIndex() ) { } @@ -1220,8 +1294,8 @@ void SwUndoDontExpandFmt::Undo( SwUndoIter& rIter ) SwDoc* pDoc = pPam->GetDoc(); SwPosition& rPos = *pPam->GetPoint(); - rPos.nNode = nNode; - rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), nCntnt ); + rPos.nNode = m_nNodeIndex; + rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), m_nContentIndex); pDoc->DontExpandFmt( rPos, FALSE ); } @@ -1232,8 +1306,8 @@ void SwUndoDontExpandFmt::Redo( SwUndoIter& rIter ) SwDoc* pDoc = pPam->GetDoc(); SwPosition& rPos = *pPam->GetPoint(); - rPos.nNode = nNode; - rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), nCntnt ); + rPos.nNode = m_nNodeIndex; + rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), m_nContentIndex); pDoc->DontExpandFmt( rPos ); } @@ -1244,5 +1318,3 @@ void SwUndoDontExpandFmt::Repeat( SwUndoIter& rIter ) pDoc->DontExpandFmt( *pPam->GetPoint() ); } - - diff --git a/sw/source/core/undo/unbkmk.cxx b/sw/source/core/undo/unbkmk.cxx index 86a7797fe494..f49cea5ac7d3 100644 --- a/sw/source/core/undo/unbkmk.cxx +++ b/sw/source/core/undo/unbkmk.cxx @@ -43,51 +43,54 @@ #include "SwRewriter.hxx" + inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } -SwUndoBookmark::SwUndoBookmark( SwUndoId nUndoId, const ::sw::mark::IMark& rBkmk ) +SwUndoBookmark::SwUndoBookmark( SwUndoId nUndoId, + const ::sw::mark::IMark& rBkmk ) : SwUndo( nUndoId ) + , m_pHistoryBookmark(new SwHistoryBookmark(rBkmk, true, rBkmk.IsExpanded())) { - pHBookmark = new SwHstryBookmark(rBkmk, true, rBkmk.IsExpanded()); } - - SwUndoBookmark::~SwUndoBookmark() { - delete pHBookmark; } - void SwUndoBookmark::SetInDoc( SwDoc* pDoc ) { - pHBookmark->SetInDoc( pDoc, FALSE ); + m_pHistoryBookmark->SetInDoc( pDoc, false ); } void SwUndoBookmark::ResetInDoc( SwDoc* pDoc ) { IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); - for(IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->getMarksBegin(); - ppBkmk != pMarkAccess->getMarksEnd(); - ppBkmk++) - if( pHBookmark->IsEqualBookmark( **ppBkmk )) + for (IDocumentMarkAccess::const_iterator_t ppBkmk = + pMarkAccess->getMarksBegin(); + ppBkmk != pMarkAccess->getMarksEnd(); + ++ppBkmk) + { + if ( m_pHistoryBookmark->IsEqualBookmark( **ppBkmk ) ) { - pMarkAccess->deleteMark( ppBkmk ); - break; + pMarkAccess->deleteMark( ppBkmk ); + break; } + } } SwRewriter SwUndoBookmark::GetRewriter() const { SwRewriter aResult; - aResult.AddRule(UNDO_ARG1, pHBookmark->GetName()); + aResult.AddRule(UNDO_ARG1, m_pHistoryBookmark->GetName()); return aResult; } +//---------------------------------------------------------------------- + SwUndoDelBookmark::SwUndoDelBookmark( const ::sw::mark::IMark& rBkmk ) : SwUndoBookmark( UNDO_DELBOOKMARK, rBkmk ) { diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index e3ad5aa726f3..0ed447d8204f 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -371,11 +371,10 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, xub_StrLen nLen = bOneNode ? nEndCntnt - nSttCntnt : pSttTxtNd->GetTxt().Len() - nSttCntnt; SwRegHistory aRHst( *pSttTxtNd, pHistory ); - // immer alle TextAttribute sichern; ist fuers Undo mit voll- - // staendiger Attributierung am besten, wegen den evt. - // Ueberlappenden Bereichen von An/Aus. + // always save all text atttibutes because of possibly overlapping + // areas of on/off pHistory->CopyAttr( pSttTxtNd->GetpSwpHints(), nNdIdx, - 0, pSttTxtNd->GetTxt().Len(), TRUE ); + 0, pSttTxtNd->GetTxt().Len(), true ); if( !bOneNode && pSttTxtNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pSttTxtNd->GetpSwAttrSet(), nNdIdx ); @@ -383,6 +382,7 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, nLen = ( bOneNode ? pEnd->nContent.GetIndex() : pSttTxtNd->GetTxt().Len() ) - pStt->nContent.GetIndex(); + // loesche jetzt noch den Text (alle Attribut-Aenderungen kommen in // die Undo-History pSttStr = (String*)new String( pSttTxtNd->GetTxt().Copy( nSttCntnt, nLen )); @@ -390,6 +390,13 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, if( pSttTxtNd->GetpSwpHints() ) pSttTxtNd->GetpSwpHints()->DeRegister(); + // METADATA: store + bool emptied( pSttStr->Len() && !pSttTxtNd->Len() ); + if (!bOneNode || emptied) // merging may overwrite xmlids... + { + m_pMetadataUndoStart = pSttTxtNd->CreateUndo( emptied ); + } + if( bOneNode ) return FALSE; // keine Nodes mehr verschieben } @@ -402,15 +409,15 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, nNdIdx = pEnd->nNode.GetIndex(); SwRegHistory aRHst( *pEndTxtNd, pHistory ); - // immer alle TextAttribute sichern; ist fuers Undo mit voll- - // staendiger Attributierung am besten, wegen den evt. - // Ueberlappenden Bereichen von An/Aus. + // always save all text atttibutes because of possibly overlapping + // areas of on/off pHistory->CopyAttr( pEndTxtNd->GetpSwpHints(), nNdIdx, 0, - pEndTxtNd->GetTxt().Len(), TRUE ); + pEndTxtNd->GetTxt().Len(), true ); if( pEndTxtNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pEndTxtNd->GetpSwAttrSet(), nNdIdx ); + // loesche jetzt noch den Text (alle Attribut-Aenderungen kommen in // die Undo-History pEndStr = (String*)new String( pEndTxtNd->GetTxt().Copy( 0, @@ -418,6 +425,10 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, pEndTxtNd->Erase( aEndIdx, pEnd->nContent.GetIndex() ); if( pEndTxtNd->GetpSwpHints() ) pEndTxtNd->GetpSwpHints()->DeRegister(); + + // METADATA: store + bool emptied( pEndStr->Len() && !pEndTxtNd->Len() ); + m_pMetadataUndoEnd = pEndTxtNd->CreateUndo( emptied ); } // sind es nur zwei Nodes, dann ist schon alles erledigt. @@ -698,8 +709,12 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) lcl_ReAnchorAtCntntFlyFrames( *pDoc->GetSpzFrmFmts(), aPos, nOldIdx ); pTxtNd = aPos.nNode.GetNode().GetTxtNode(); } - if( pTxtNd ) // Robust + if( pTxtNd ) + { pTxtNd->Insert( *pEndStr, aPos.nContent, INS_NOHINTEXPAND ); + // METADATA: restore + pTxtNd->RestoreMetadata(m_pMetadataUndoEnd); + } } else if( pSttStr && bNodeMove ) { @@ -757,7 +772,7 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) } else { - aPos = aCopyIndex; + aPos = SwPosition( aCopyIndex ); nMoveIndex = aPos.nNode.GetIndex() + nReplaceDummy + 1; } SwNodeIndex aMvIdx( pDoc->GetNodes(), nMoveIndex ); @@ -790,12 +805,14 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) // -> im StartNode steht noch der Rest vom Join => loeschen aPos.nContent.Assign( pTxtNd, nSttCntnt ); pTxtNd->Insert( *pSttStr, aPos.nContent, INS_NOHINTEXPAND ); + // METADATA: restore + pTxtNd->RestoreMetadata(m_pMetadataUndoStart); } } if( pHistory ) { - pHistory->TmpRollback( pDoc, nSetPos, FALSE ); + pHistory->TmpRollback( pDoc, nSetPos, false ); if( nSetPos ) // es gab Fussnoten/FlyFrames { // gibts ausser diesen noch andere ? diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index 1b7f97b70a20..ae9535ced2f7 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -540,7 +540,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, SwTxtAttr* pFtnHnt = pTxtNd->GetTxtAttr( nFtnSttIdx ); ASSERT( pFtnHnt, "kein FtnAttribut" ); SwIndex aIdx( pTxtNd, nFtnSttIdx ); - pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), FALSE ); + pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), false ); pTxtNd->Erase( aIdx, 1 ); } @@ -563,7 +563,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, SwTxtAttr* pFtnHnt = pTxtNd->GetTxtAttr( nFtnSttIdx ); ASSERT( pFtnHnt, "kein FtnAttribut" ); SwIndex aIdx( pTxtNd, nFtnSttIdx ); - pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), FALSE ); + pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), false ); pTxtNd->Erase( aIdx, 1 ); } } @@ -600,7 +600,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, SwTxtNode* pTxtNd = pDoc->GetNodes()[ pAPos->nNode]->GetTxtNode(); SwTxtAttr* pFlyHnt = pTxtNd->GetTxtAttr( pAPos->nContent.GetIndex()); ASSERT( pFlyHnt, "kein FlyAttribut" ); - pHistory->Add( pFlyHnt, 0, FALSE ); + pHistory->Add( pFlyHnt, 0, false ); // n wieder zurueck, damit nicht ein Format uebesprungen wird ! n = n >= rSpzArr.Count() ? rSpzArr.Count() : n+1; } diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index 41a9ef71647c..1335844c7ff9 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -66,11 +66,14 @@ using namespace ::com::sun::star; class _UnReplaceData : private SwUndoSaveCntnt { - String sOld, sIns; - ULONG nSttNd, nEndNd, nOffset; - xub_StrLen nSttCnt, nEndCnt, nSetPos, nSelEnd; - BOOL bSplitNext : 1; - BOOL bRegExp : 1; + String m_sOld, m_sIns; + ULONG m_nSttNd, m_nEndNd, m_nOffset; + xub_StrLen m_nSttCnt, m_nEndCnt, m_nSetPos, m_nSelEnd; + BOOL m_bSplitNext : 1; + BOOL m_bRegExp : 1; + // metadata references for paragraph and following para (if m_bSplitNext) + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart; + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd; public: _UnReplaceData( const SwPaM& rPam, const String& rIns, BOOL bRegExp ); @@ -80,8 +83,8 @@ public: void Redo( SwUndoIter& rIter ); void SetEnd( const SwPaM& rPam ); - const String & GetOld() const { return sOld; } - const String & GetIns() const { return sIns; } + const String & GetOld() const { return m_sOld; } + const String & GetIns() const { return m_sIns; } }; @@ -626,20 +629,18 @@ void SwUndoReplace::SetEntryEnd( const SwPaM& rPam ) _UnReplaceData::_UnReplaceData( const SwPaM& rPam, const String& rIns, BOOL bRgExp ) - : sIns( rIns ), nOffset( 0 ) + : m_sIns( rIns ), m_nOffset( 0 ) { - bRegExp = bRgExp; + m_bRegExp = bRgExp; - const SwPosition *pStt = rPam.Start(), - *pEnd = rPam.GetPoint() == pStt - ? rPam.GetMark() - : rPam.GetPoint(); + const SwPosition * pStt( rPam.Start() ); + const SwPosition * pEnd( rPam.End() ); - nSttNd = nEndNd = pStt->nNode.GetIndex(); - nSttCnt = pStt->nContent.GetIndex(); - nSelEnd = nEndCnt = pEnd->nContent.GetIndex(); + m_nSttNd = m_nEndNd = pStt->nNode.GetIndex(); + m_nSttCnt = pStt->nContent.GetIndex(); + m_nSelEnd = m_nEndCnt = pEnd->nContent.GetIndex(); - bSplitNext = nSttNd != pEnd->nNode.GetIndex(); + m_bSplitNext = m_nSttNd != pEnd->nNode.GetIndex(); SwTxtNode* pNd = pStt->nNode.GetNode().GetTxtNode(); ASSERT( pNd, "wo ist der TextNode" ); @@ -647,16 +648,18 @@ _UnReplaceData::_UnReplaceData( const SwPaM& rPam, const String& rIns, pHistory = new SwHistory; DelCntntIndex( *rPam.GetMark(), *rPam.GetPoint() ); - nSetPos = pHistory->Count(); + m_nSetPos = pHistory->Count(); ULONG nNewPos = pStt->nNode.GetIndex(); - nOffset = nSttNd - nNewPos; + m_nOffset = m_nSttNd - nNewPos; - if( pNd->GetpSwpHints() ) + if ( pNd->GetpSwpHints() ) + { pHistory->CopyAttr( pNd->GetpSwpHints(), nNewPos, 0, - pNd->GetTxt().Len(), TRUE ); + pNd->GetTxt().Len(), true ); + } - if( bSplitNext ) + if ( m_bSplitNext ) { if( pNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pNd->GetpSwAttrSet(), nNewPos ); @@ -665,17 +668,21 @@ _UnReplaceData::_UnReplaceData( const SwPaM& rPam, const String& rIns, SwTxtNode* pNext = pEnd->nNode.GetNode().GetTxtNode(); ULONG nTmp = pNext->GetIndex(); pHistory->CopyAttr( pNext->GetpSwpHints(), nTmp, 0, - pNext->GetTxt().Len(), TRUE ); + pNext->GetTxt().Len(), true ); if( pNext->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pNext->GetpSwAttrSet(), nTmp ); pHistory->Add( pNext->GetTxtColl(),nTmp, ND_TEXTNODE ); + // METADATA: store + m_pMetadataUndoStart = pNd ->CreateUndo(); + m_pMetadataUndoEnd = pNext->CreateUndo(); } if( !pHistory->Count() ) delete pHistory, pHistory = 0; - xub_StrLen nECnt = bSplitNext ? pNd->GetTxt().Len() : pEnd->nContent.GetIndex(); - sOld = pNd->GetTxt().Copy( nSttCnt, nECnt - nSttCnt ); + xub_StrLen nECnt = m_bSplitNext ? pNd->GetTxt().Len() + : pEnd->nContent.GetIndex(); + m_sOld = pNd->GetTxt().Copy( m_nSttCnt, nECnt - m_nSttCnt ); } _UnReplaceData::~_UnReplaceData() @@ -688,72 +695,68 @@ void _UnReplaceData::Undo( SwUndoIter& rIter ) SwPaM& rPam = *rIter.pAktPam; rPam.DeleteMark(); - SwTxtNode* pNd = pDoc->GetNodes()[ nSttNd - nOffset ]->GetTxtNode(); + SwTxtNode* pNd = pDoc->GetNodes()[ m_nSttNd - m_nOffset ]->GetTxtNode(); ASSERT( pNd, "Wo ist der TextNode geblieben?" ) SwAutoCorrExceptWord* pACEWord = pDoc->GetAutoCorrExceptWord(); if( pACEWord ) { - if( 1 == sIns.Len() && 1 == sOld.Len() ) + if( 1 == m_sIns.Len() && 1 == m_sOld.Len() ) { - SwPosition aPos( *pNd ); aPos.nContent.Assign( pNd, nSttCnt ); - pACEWord->CheckChar( aPos, sOld.GetChar( 0 ) ); + SwPosition aPos( *pNd ); aPos.nContent.Assign( pNd, m_nSttCnt ); + pACEWord->CheckChar( aPos, m_sOld.GetChar( 0 ) ); } pDoc->SetAutoCorrExceptWord( 0 ); } - SwIndex aIdx( pNd, nSttCnt ); - if( nSttNd == nEndNd ) + SwIndex aIdx( pNd, m_nSttCnt ); + if( m_nSttNd == m_nEndNd ) { - pNd->Erase( aIdx, sIns.Len() ); -/* if( bSplitNext ) - { - SwPosition aPos( *pNd, aIdx ); - pDoc->SplitNode( aPos, FALSE ); - pNd = pDoc->GetNodes()[ nSttNd - nOffset ]->GetTxtNode(); - aIdx.Assign( pNd, nSttCnt ); - } -*/ } + pNd->Erase( aIdx, m_sIns.Len() ); + } else { rPam.GetPoint()->nNode = *pNd; - rPam.GetPoint()->nContent.Assign( pNd, nSttCnt ); + rPam.GetPoint()->nContent.Assign( pNd, m_nSttCnt ); rPam.SetMark(); - rPam.GetPoint()->nNode = nEndNd - nOffset; - rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nEndCnt ); + rPam.GetPoint()->nNode = m_nEndNd - m_nOffset; + rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), m_nEndCnt ); pDoc->DeleteAndJoin( rPam ); rPam.DeleteMark(); pNd = rPam.GetNode()->GetTxtNode(); ASSERT( pNd, "Wo ist der TextNode geblieben?" ); - aIdx.Assign( pNd, nSttCnt ); + aIdx.Assign( pNd, m_nSttCnt ); } - if( bSplitNext ) + if( m_bSplitNext ) { SwPosition aPos( *pNd, aIdx ); pDoc->SplitNode( aPos, false ); - pNd = pDoc->GetNodes()[ nSttNd - nOffset ]->GetTxtNode(); - aIdx.Assign( pNd, nSttCnt ); + pNd->RestoreMetadata(m_pMetadataUndoEnd); + pNd = pDoc->GetNodes()[ m_nSttNd - m_nOffset ]->GetTxtNode(); + aIdx.Assign( pNd, m_nSttCnt ); + // METADATA: restore + pNd->RestoreMetadata(m_pMetadataUndoStart); } - if( sOld.Len() ) - pNd->Insert( sOld, aIdx ); + if( m_sOld.Len() ) + pNd->Insert( m_sOld, aIdx ); if( pHistory ) { if( pNd->GetpSwpHints() ) pNd->ClearSwpHintsArr( true ); - pHistory->TmpRollback( pDoc, nSetPos, FALSE ); - if( nSetPos ) // es gab Fussnoten/FlyFrames + pHistory->TmpRollback( pDoc, m_nSetPos, false ); + if ( m_nSetPos ) // there were footnotes/FlyFrames { // gibts ausser diesen noch andere ? - if( nSetPos < pHistory->Count() ) + if( m_nSetPos < pHistory->Count() ) { // dann sicher die Attribute anderen Attribute SwHistory aHstr; - aHstr.Move( 0, pHistory, nSetPos ); + aHstr.Move( 0, pHistory, m_nSetPos ); pHistory->Rollback( pDoc ); pHistory->Move( 0, &aHstr ); } @@ -765,7 +768,7 @@ void _UnReplaceData::Undo( SwUndoIter& rIter ) } } - rPam.GetPoint()->nNode = nSttNd; + rPam.GetPoint()->nNode = m_nSttNd; rPam.GetPoint()->nContent = aIdx; } @@ -777,18 +780,18 @@ void _UnReplaceData::Redo( SwUndoIter& rIter ) SwPaM& rPam = *rIter.pAktPam; rPam.DeleteMark(); - rPam.GetPoint()->nNode = nSttNd; + rPam.GetPoint()->nNode = m_nSttNd; SwTxtNode* pNd = rPam.GetPoint()->nNode.GetNode().GetTxtNode(); ASSERT( pNd, "Wo ist der TextNode geblieben?" ) - rPam.GetPoint()->nContent.Assign( pNd, nSttCnt ); + rPam.GetPoint()->nContent.Assign( pNd, m_nSttCnt ); rPam.SetMark(); - if( bSplitNext ) + if( m_bSplitNext ) { - rPam.GetPoint()->nNode = nSttNd + 1; + rPam.GetPoint()->nNode = m_nSttNd + 1; pNd = rPam.GetPoint()->nNode.GetNode().GetTxtNode(); } - rPam.GetPoint()->nContent.Assign( pNd, nSelEnd ); + rPam.GetPoint()->nContent.Assign( pNd, m_nSelEnd ); if( pHistory ) { @@ -796,7 +799,7 @@ void _UnReplaceData::Redo( SwUndoIter& rIter ) SwHistory aHst; pHistory = &aHst; DelCntntIndex( *rPam.GetMark(), *rPam.GetPoint() ); - nSetPos = pHistory->Count(); + m_nSetPos = pHistory->Count(); pHistory = pSave; pHistory->Move( 0, &aHst ); @@ -805,12 +808,12 @@ void _UnReplaceData::Redo( SwUndoIter& rIter ) { pHistory = new SwHistory; DelCntntIndex( *rPam.GetMark(), *rPam.GetPoint() ); - nSetPos = pHistory->Count(); - if( !nSetPos ) + m_nSetPos = pHistory->Count(); + if( !m_nSetPos ) delete pHistory, pHistory = 0; } - rDoc.Replace( rPam, sIns, bRegExp ); + rDoc.Replace( rPam, m_sIns, m_bRegExp ); rPam.DeleteMark(); rDoc.DoUndo( bUndo ); } @@ -821,8 +824,8 @@ void _UnReplaceData::SetEnd( const SwPaM& rPam ) { // es wurden mehrere Absaetze eingefuegt const SwPosition* pEnd = rPam.End(); - nEndNd = nOffset + pEnd->nNode.GetIndex(); - nEndCnt = pEnd->nContent.GetIndex(); + m_nEndNd = m_nOffset + pEnd->nNode.GetIndex(); + m_nEndCnt = pEnd->nContent.GetIndex(); } } @@ -1087,10 +1090,12 @@ void SwUndoInsertLabel::SetFlys( SwFrmFmt& rOldFly, SfxItemSet& rChgSet, { if( LTYPE_OBJECT == eType || LTYPE_DRAW == eType ) { - _UndoFmtAttr aTmp( rOldFly, FALSE ); + SwUndoFmtAttrHelper aTmp( rOldFly, false ); rOldFly.SetFmtAttr( rChgSet ); - if( aTmp.pUndo ) - OBJECT.pUndoAttr = aTmp.pUndo; + if ( aTmp.GetUndo() ) + { + OBJECT.pUndoAttr = aTmp.ReleaseUndo(); + } OBJECT.pUndoFly = new SwUndoInsLayFmt( &rNewFly,0,0 ); } } diff --git a/sw/source/core/undo/unmove.cxx b/sw/source/core/undo/unmove.cxx index 067f6fda63c1..269f8de3cd63 100644 --- a/sw/source/core/undo/unmove.cxx +++ b/sw/source/core/undo/unmove.cxx @@ -62,18 +62,22 @@ SwUndoMove::SwUndoMove( const SwPaM& rRange, const SwPosition& rMvPos ) if( pTxtNd ) { pHistory->Add( pTxtNd->GetTxtColl(), nSttNode, ND_TEXTNODE ); - if( pTxtNd->GetpSwpHints() ) + if ( pTxtNd->GetpSwpHints() ) + { pHistory->CopyAttr( pTxtNd->GetpSwpHints(), nSttNode, - 0, pTxtNd->GetTxt().Len(), FALSE ); + 0, pTxtNd->GetTxt().Len(), false ); + } if( pTxtNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pTxtNd->GetpSwAttrSet(), nSttNode ); } if( pEndTxtNd && pEndTxtNd != pTxtNd ) { pHistory->Add( pEndTxtNd->GetTxtColl(), nEndNode, ND_TEXTNODE ); - if( pEndTxtNd->GetpSwpHints() ) + if ( pEndTxtNd->GetpSwpHints() ) + { pHistory->CopyAttr( pEndTxtNd->GetpSwpHints(), nEndNode, - 0, pEndTxtNd->GetTxt().Len(), FALSE ); + 0, pEndTxtNd->GetTxt().Len(), false ); + } if( pEndTxtNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pEndTxtNd->GetpSwAttrSet(), nEndNode ); } @@ -81,9 +85,11 @@ SwUndoMove::SwUndoMove( const SwPaM& rRange, const SwPosition& rMvPos ) if( 0 != (pTxtNd = rRange.GetDoc()->GetNodes()[ rMvPos.nNode ]->GetTxtNode() )) { pHistory->Add( pTxtNd->GetTxtColl(), nMvDestNode, ND_TEXTNODE ); - if( pTxtNd->GetpSwpHints() ) + if ( pTxtNd->GetpSwpHints() ) + { pHistory->CopyAttr( pTxtNd->GetpSwpHints(), nMvDestNode, - 0, pTxtNd->GetTxt().Len(), FALSE ); + 0, pTxtNd->GetTxt().Len(), false ); + } if( pTxtNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pTxtNd->GetpSwAttrSet(), nMvDestNode ); } diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx index a1d126e751cf..e01c2debaf56 100644 --- a/sw/source/core/undo/unovwr.cxx +++ b/sw/source/core/undo/unovwr.cxx @@ -97,7 +97,7 @@ SwUndoOverwrite::SwUndoOverwrite( SwDoc* pDoc, SwPosition& rPos, pHistory = new SwHistory; SwRegHistory aRHst( *pTxtNd, pHistory ); pHistory->CopyAttr( pTxtNd->GetpSwpHints(), nSttNode, 0, - nTxtNdLen, FALSE ); + nTxtNdLen, false ); rPos.nContent++; bInsChar = FALSE; } @@ -254,7 +254,7 @@ void SwUndoOverwrite::Undo( SwUndoIter& rUndoIter ) { if( pTxtNd->GetpSwpHints() ) pTxtNd->ClearSwpHintsArr( false ); - pHistory->TmpRollback( pDoc, 0, FALSE ); + pHistory->TmpRollback( pDoc, 0, false ); } if( pAktPam->GetMark()->nContent.GetIndex() != nSttCntnt ) @@ -420,7 +420,7 @@ void SwUndoTransliterate::Repeat( SwUndoIter& rUndoIter ) rUndoIter.pLastUndoObj = this; } -void SwUndoTransliterate::AddChanges( const SwTxtNode& rTNd, +void SwUndoTransliterate::AddChanges( SwTxtNode& rTNd, xub_StrLen nStart, xub_StrLen nLen, uno::Sequence <sal_Int32>& rOffsets ) { @@ -485,7 +485,7 @@ void SwUndoTransliterate::AddChanges( const SwTxtNode& rTNd, pNew->pHistory = new SwHistory; SwRegHistory aRHst( rTNd, pNew->pHistory ); pNew->pHistory->CopyAttr( rTNd.GetpSwpHints(), - pNew->nNdIdx, 0, rTNd.GetTxt().Len(), FALSE ); + pNew->nNdIdx, 0, rTNd.GetTxt().Len(), false ); } break; } @@ -511,7 +511,7 @@ void _UndoTransliterate_Data::SetChangeAtNode( SwDoc& rDoc ) { if( pTNd->GetpSwpHints() ) pTNd->ClearSwpHintsArr( false ); - pHistory->TmpRollback( &rDoc, 0, FALSE ); + pHistory->TmpRollback( &rDoc, 0, false ); pHistory->SetTmpEnd( pHistory->Count() ); } } diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx index 36f5f549562b..f26643a09352 100644 --- a/sw/source/core/undo/unsect.cxx +++ b/sw/source/core/undo/unsect.cxx @@ -167,8 +167,10 @@ void SwUndoInsSection::Undo( SwUndoIter& rUndoIter ) if( bSplitAtEnd ) Join( rDoc, nEndNode ); - if( pHistory ) - pHistory->TmpRollback( &rDoc, 0, FALSE ); + if ( pHistory ) + { + pHistory->TmpRollback( &rDoc, 0, false ); + } if( bUpdateFtn ) rDoc.GetFtnIdxs().UpdateFtn( aIdx ); @@ -265,7 +267,7 @@ void SwUndoInsSection::SaveSplitNode( SwTxtNode* pTxtNd, BOOL bAtStt ) if( !pHistory ) pHistory = new SwHistory; pHistory->CopyAttr( pTxtNd->GetpSwpHints(), pTxtNd->GetIndex(), 0, - pTxtNd->GetTxt().Len(), FALSE ); + pTxtNd->GetTxt().Len(), false ); } if( bAtStt ) diff --git a/sw/source/core/undo/unspnd.cxx b/sw/source/core/undo/unspnd.cxx index 96b0daf6a5df..31d2243c6b6c 100644 --- a/sw/source/core/undo/unspnd.cxx +++ b/sw/source/core/undo/unspnd.cxx @@ -66,7 +66,7 @@ SwUndoSplitNode::SwUndoSplitNode( SwDoc* pDoc, const SwPosition& rPos, { pHistory = new SwHistory; pHistory->CopyAttr( pTxtNd->GetpSwpHints(), nNode, 0, - pTxtNd->GetTxt().Len(), FALSE ); + pTxtNd->GetTxt().Len(), false ); if( !pHistory->Count() ) DELETEZ( pHistory ); } @@ -155,7 +155,7 @@ void SwUndoSplitNode::Undo( SwUndoIter& rUndoIter ) rPam.GetPoint()->nContent = pTNd->GetTxt().Len(); pDoc->RstTxtAttrs( rPam, TRUE ); - pHistory->TmpRollback( pDoc, 0, FALSE ); + pHistory->TmpRollback( pDoc, 0, false ); } } } diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index cbe7d97cd05b..93f6daf2c445 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -63,11 +63,10 @@ #include <node2lay.hxx> #include <tblrwcl.hxx> #include <fmtanchr.hxx> -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif #include <unochart.hxx> + #ifdef PRODUCT #define CHECK_TABLE(t) #else @@ -215,13 +214,16 @@ So we need to remember not only the start node position but the end node positio struct SwTblToTxtSave { - ULONG nNode; - ULONG nEndNd; - xub_StrLen nCntnt; - SwHistory* pHstry; + ULONG m_nSttNd; + ULONG m_nEndNd; + xub_StrLen m_nCntnt; + SwHistory* m_pHstry; + // metadata references for first and last paragraph in cell + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart; + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd; SwTblToTxtSave( SwDoc& rDoc, ULONG nNd, ULONG nEndIdx, xub_StrLen nCntnt ); - ~SwTblToTxtSave() { delete pHstry; } + ~SwTblToTxtSave() { delete m_pHstry; } }; SV_IMPL_PTRARR( SfxItemSets, SfxItemSetPtr ) @@ -387,26 +389,41 @@ SwRewriter SwUndoInsTbl::GetRewriter() const // ----------------------------------------------------- SwTblToTxtSave::SwTblToTxtSave( SwDoc& rDoc, ULONG nNd, ULONG nEndIdx, xub_StrLen nCnt ) - : nNode( nNd ), nEndNd( nEndIdx), nCntnt( nCnt ), pHstry( 0 ) + : m_nSttNd( nNd ), m_nEndNd( nEndIdx), m_nCntnt( nCnt ), m_pHstry( 0 ) { // Attributierung des gejointen Node merken. - if( USHRT_MAX != nCnt ) - ++nNd; - SwTxtNode* pNd = rDoc.GetNodes()[ nNd ]->GetTxtNode(); if( pNd ) { - pHstry = new SwHistory; + m_pHstry = new SwHistory; - pHstry->Add( pNd->GetTxtColl(), nNd, ND_TEXTNODE ); - if( pNd->GetpSwpHints() ) - pHstry->CopyAttr( pNd->GetpSwpHints(), nNd, 0, - pNd->GetTxt().Len(), FALSE ); + m_pHstry->Add( pNd->GetTxtColl(), nNd, ND_TEXTNODE ); + if ( pNd->GetpSwpHints() ) + { + m_pHstry->CopyAttr( pNd->GetpSwpHints(), nNd, 0, + pNd->GetTxt().Len(), false ); + } if( pNd->HasSwAttrSet() ) - pHstry->CopyFmtAttr( *pNd->GetpSwAttrSet(), nNd ); + m_pHstry->CopyFmtAttr( *pNd->GetpSwAttrSet(), nNd ); + + if( !m_pHstry->Count() ) + delete m_pHstry, m_pHstry = 0; + + // METADATA: store + m_pMetadataUndoStart = pNd->CreateUndo(); + } - if( !pHstry->Count() ) - delete pHstry, pHstry = 0; + // we also need to store the metadata reference of the _last_ paragraph + // we subtract 1 to account for the removed cell start/end node pair + // (after SectionUp, the end of the range points to the node after the cell) + if ( nEndIdx - 1 > nNd ) + { + SwTxtNode* pLastNode( rDoc.GetNodes()[ nEndIdx - 1 ]->GetTxtNode() ); + if( pLastNode ) + { + // METADATA: store + m_pMetadataUndoEnd = pLastNode->CreateUndo(); + } } } @@ -433,7 +450,7 @@ SwUndoTblToTxt::SwUndoTblToTxt( const SwTable& rTbl, sal_Unicode cCh ) for( USHORT n = 0; n < rFrmFmtTbl.Count(); ++n ) { const SwPosition* pAPos; - const SwFrmFmt* pFmt = rFrmFmtTbl[ n ]; + SwFrmFmt* pFmt = rFrmFmtTbl[ n ]; const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && ( FLY_AUTO_CNTNT == pAnchor->GetAnchorId() || @@ -562,22 +579,24 @@ SwTableNode* SwNodes::UndoTableToText( ULONG nSttNd, ULONG nEndNd, for( USHORT n = rSavedData.Count(); n; ) { SwTblToTxtSave* pSave = rSavedData[ --n ]; - aSttIdx = pSave->nNode; + // if the start node was merged with last from prev. cell, + // subtract 1 from index to get the merged paragraph, and split that + aSttIdx = pSave->m_nSttNd - ( ( USHRT_MAX != pSave->m_nCntnt ) ? 1 : 0); SwTxtNode* pTxtNd = aSttIdx.GetNode().GetTxtNode(); - if( USHRT_MAX != pSave->nCntnt ) + if( USHRT_MAX != pSave->m_nCntnt ) { // an der ContentPosition splitten, das vorherige Zeichen // loeschen (ist der Trenner!) ASSERT( pTxtNd, "Wo ist der TextNode geblieben?" ); - SwIndex aCntPos( pTxtNd, pSave->nCntnt - 1 ); + SwIndex aCntPos( pTxtNd, pSave->m_nCntnt - 1 ); pTxtNd->Erase( aCntPos, 1 ); SwCntntNode* pNewNd = pTxtNd->SplitCntntNode( SwPosition( aSttIdx, aCntPos )); if( aBkmkArr.Count() ) - _RestoreCntntIdx( aBkmkArr, *pNewNd, pSave->nCntnt, - pSave->nCntnt + 1 ); + _RestoreCntntIdx( aBkmkArr, *pNewNd, pSave->m_nCntnt, + pSave->m_nCntnt + 1 ); } else { @@ -590,6 +609,8 @@ SwTableNode* SwNodes::UndoTableToText( ULONG nSttNd, ULONG nEndNd, if( pTxtNd ) { + // METADATA: restore + pTxtNd->GetTxtNode()->RestoreMetadata(pSave->m_pMetadataUndoStart); if( pTxtNd->HasSwAttrSet() ) pTxtNd->ResetAllAttr(); @@ -597,14 +618,25 @@ SwTableNode* SwNodes::UndoTableToText( ULONG nSttNd, ULONG nEndNd, pTxtNd->ClearSwpHintsArr( false ); } - if( pSave->pHstry ) + if( pSave->m_pHstry ) + { + USHORT nTmpEnd = pSave->m_pHstry->GetTmpEnd(); + pSave->m_pHstry->TmpRollback( GetDoc(), 0 ); + pSave->m_pHstry->SetTmpEnd( nTmpEnd ); + } + + // METADATA: restore + // end points to node after cell + if ( pSave->m_nEndNd - 1 > pSave->m_nSttNd ) { - USHORT nTmpEnd = pSave->pHstry->GetTmpEnd(); - pSave->pHstry->TmpRollback( GetDoc(), 0 ); - pSave->pHstry->SetTmpEnd( nTmpEnd ); + SwTxtNode* pLastNode = (*this)[ pSave->m_nEndNd - 1 ]->GetTxtNode(); + if (pLastNode) + { + pLastNode->RestoreMetadata(pSave->m_pMetadataUndoEnd); + } } - aEndIdx = pSave->nEndNd; + aEndIdx = pSave->m_nEndNd; SwStartNode* pSttNd = new SwStartNode( aSttIdx, ND_STARTNODE, SwTableBoxStartNode ); pSttNd->pStartOfSection = pTblNd; @@ -2229,11 +2261,10 @@ SwUndoTblNumFmt::SwUndoTblNumFmt( const SwTableBox& rBox, pHistory = new SwHistory; SwRegHistory aRHst( *rBox.GetSttNd(), pHistory ); - // immer alle TextAttribute sichern; ist fuers Undo mit voll- - // staendiger Attributierung am besten, wegen den evt. - // Ueberlappenden Bereichen von An/Aus. + // always save all text atttibutes because of possibly overlapping + // areas of on/off pHistory->CopyAttr( pTNd->GetpSwpHints(), nNdPos, 0, - pTNd->GetTxt().Len(), TRUE ); + pTNd->GetTxt().Len(), true ); if( pTNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pTNd->GetpSwAttrSet(), nNdPos ); @@ -2827,7 +2858,8 @@ SwUndo* SwUndoTblCpyTbl::PrepareRedline( SwDoc* pDoc, const SwTableBox& rBox, } else if( !rJoin ) // If the old part is empty and joined, we are finished { // if it is not joined, we have to delete this empty paragraph - aCellEnd = SwNodeIndex( *rBox.GetSttNd()->EndOfSectionNode() ); + aCellEnd = SwPosition( + SwNodeIndex( *rBox.GetSttNd()->EndOfSectionNode() )); SwPaM aTmpPam( aDeleteStart, aCellEnd ); pUndo = new SwUndoDelete( aTmpPam, TRUE ); } diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index 73e6151869b5..581e2185907e 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -59,7 +59,7 @@ SwUndoInserts::SwUndoInserts( SwUndoId nUndoId, const SwPaM& rPam ) { pTxtFmtColl = pTxtNd->GetTxtColl(); pHistory->CopyAttr( pTxtNd->GetpSwpHints(), nSttNode, - 0, pTxtNd->GetTxt().Len(), FALSE ); + 0, pTxtNd->GetTxt().Len(), false ); if( pTxtNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pTxtNd->GetpSwAttrSet(), nSttNode ); @@ -264,7 +264,7 @@ void SwUndoInserts::Undo( SwUndoIter& rUndoIter ) pTxtFmtColl = (SwTxtFmtColl*)pTxtNode->ChgFmtColl( pTxtFmtColl ); pHistory->SetTmpEnd( nSetPos ); - pHistory->TmpRollback( pDoc, 0, FALSE ); + pHistory->TmpRollback( pDoc, 0, false ); } } @@ -288,7 +288,7 @@ void SwUndoInserts::Redo( SwUndoIter& rUndoIter ) pSavTxtFmtColl = ((SwTxtNode*)pCNd)->GetTxtColl(); pHistory->SetTmpEnd( nSetPos ); - pHistory->TmpRollback( pDoc, 0, FALSE ); + pHistory->TmpRollback( pDoc, 0, false ); // alte Anfangs-Position fuers Rollback zurueckholen if( ( nSttNode != nEndNode || nSttCntnt != nEndCntnt ) && pPos ) @@ -346,7 +346,7 @@ void SwUndoInserts::Repeat( SwUndoIter& rUndoIter ) SwPaM aPam( *rUndoIter.pAktPam->GetPoint() ); SetPaM( aPam ); - aPam.GetDoc()->Copy( aPam, *rUndoIter.pAktPam->GetPoint() ); + aPam.GetDoc()->Copy( 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 d58f7f86cab3..a922c5334f3e 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -286,7 +286,7 @@ uno::Reference< beans::XPropertySetInfo > SwXBookmark::getPropertySetInfo(void) static uno::Reference< beans::XPropertySetInfo > aRef; if(!aRef.is()) { - uno::Reference< beans::XPropertySetInfo > xInfo = aSwMapProvider.GetPropertySet(PROPERTY_MAP_BOOKMARK)->getPropertySetInfo(); + aRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_BOOKMARK)->getPropertySetInfo(); } return aRef; } diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index b89163f60a3e..b09f4196d396 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -35,12 +35,8 @@ #include <algorithm> -#ifndef _COM_SUN_STAR_CHART_DATAROWSOURCE_HPP_ #include <com/sun/star/chart/ChartDataRowSource.hpp> -#endif -#ifndef _COM_SUN_STAR_CHART_DATAROWSOURCE_HPP_ #include <com/sun/star/chart2/data/LabelOrigin.hpp> -#endif #include <cppuhelper/interfacecontainer.hxx> #include <vos/mutex.hxx> #include <osl/mutex.hxx> @@ -283,11 +279,9 @@ static String GetCellRangeName( SwFrmFmt &rTblFmt, SwUnoCrsr &rTblCrsr ) //!! see also SwXTextTableCursor::getRangeName - SwUnoTableCrsr* pUnoTblCrsr = rTblCrsr; -#if OSL_DEBUG_LEVEL > 1 + SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<SwUnoTableCrsr*>(&rTblCrsr); if (!pUnoTblCrsr) return String(); -#endif pUnoTblCrsr->MakeBoxSels(); const SwStartNode* pStart; @@ -491,7 +485,8 @@ static void GetFormatAndCreateCursorFromRangeRep( pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = *pUnoCrsr; + SwUnoTableCrsr* pCrsr = + dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); if (ppUnoCrsr) @@ -2064,9 +2059,8 @@ SwChartDataSequence::SwChartDataSequence( // check if it can properly convert into a SwUnoTableCrsr // which is required for some functions - SwUnoTableCrsr* pUnoTblCrsr = *pTblCrsr; - if (!pUnoTblCrsr) - pUnoTblCrsr = *pTblCrsr; + SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr); + DBG_ASSERT(pUnoTblCrsr, "SwChartDataSequence: cursor not SwUnoTableCrsr"); #endif } @@ -2115,9 +2109,8 @@ SwChartDataSequence::SwChartDataSequence( const SwChartDataSequence &rObj ) : // check if it can properly convert into a SwUnoTableCrsr // which is required for some functions - SwUnoTableCrsr* pUnoTblCrsr = *pTblCrsr; - if (!pUnoTblCrsr) - pUnoTblCrsr = *pTblCrsr; + SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr); + DBG_ASSERT(pUnoTblCrsr, "SwChartDataSequence: cursor not SwUnoTableCrsr"); #endif } @@ -2779,7 +2772,7 @@ bool SwChartDataSequence::ExtendTo( bool bExtendCol, { bool bChanged = false; - SwUnoTableCrsr* pUnoTblCrsr = *pTblCrsr; + SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr); //pUnoTblCrsr->MakeBoxSels(); const SwStartNode *pStartNd = 0; diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index b17cf48f5d9f..decd73e07e63 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -985,7 +985,8 @@ uno::Any SwXFrames::getByIndex(sal_Int32 nIndex) throw(IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) throw uno::RuntimeException(); + if(!IsValid()) + throw uno::RuntimeException(); if(nIndex < 0 || nIndex >= USHRT_MAX) throw IndexOutOfBoundsException(); const Reference<XEnumeration> xEnum = createEnumeration(); while(xEnum->hasMoreElements()) @@ -1000,7 +1001,8 @@ uno::Any SwXFrames::getByName(const OUString& rName) throw(NoSuchElementException, WrappedTargetException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) throw uno::RuntimeException(); + if(!IsValid()) + throw uno::RuntimeException(); const Reference<XEnumeration> xEnum = createEnumeration(); while(xEnum->hasMoreElements()) { @@ -1016,7 +1018,8 @@ uno::Any SwXFrames::getByName(const OUString& rName) uno::Sequence<OUString> SwXFrames::getElementNames(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) throw uno::RuntimeException(); + if(!IsValid()) + throw uno::RuntimeException(); const Reference<XEnumeration> xEnum = createEnumeration(); ::std::vector<OUString> vNames; while(xEnum->hasMoreElements()) @@ -1063,7 +1066,8 @@ uno::Type SAL_CALL SwXFrames::getElementType() throw(uno::RuntimeException) sal_Bool SwXFrames::hasElements(void) throw(uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(IsValid()) throw uno::RuntimeException(); + if(!IsValid()) + throw uno::RuntimeException(); return createEnumeration()->hasMoreElements(); } @@ -1650,9 +1654,9 @@ Sequence< OUString > SwXFootnotes::getSupportedServiceNames(void) throw( Runtime /*-- 14.01.99 09:03:52--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXFootnotes::SwXFootnotes(sal_Bool bEnd, SwDoc* _pDoc) : - SwUnoCollection(_pDoc), - bEndnote(bEnd) +SwXFootnotes::SwXFootnotes(sal_Bool bEnd, SwDoc* _pDoc) + : SwUnoCollection(_pDoc) + , m_bEndnote(bEnd) { } /*-- 14.01.99 09:03:52--------------------------------------------------- @@ -1676,7 +1680,7 @@ sal_Int32 SwXFootnotes::getCount(void) throw( uno::RuntimeException ) { pTxtFtn = GetDoc()->GetFtnIdxs()[ n ]; const SwFmtFtn& rFtn = pTxtFtn->GetFtn(); - if ( rFtn.IsEndNote() != bEndnote ) + if ( rFtn.IsEndNote() != m_bEndnote ) continue; nCount++; } @@ -1700,7 +1704,7 @@ uno::Any SwXFootnotes::getByIndex(sal_Int32 nIndex) { pTxtFtn = GetDoc()->GetFtnIdxs()[ n ]; const SwFmtFtn& rFtn = pTxtFtn->GetFtn(); - if( rFtn.IsEndNote() != bEndnote ) + if ( rFtn.IsEndNote() != m_bEndnote ) continue; if(nCount == nIndex) diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index f7b5fe716a59..8d754eca0879 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1020,12 +1020,10 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: throw beans::PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); SwDoc* pDoc = pFmt->GetDoc(); - if( eType == FLYCNTTYPE_GRF && - (pEntry->nWID >= RES_GRFATR_BEGIN && - pEntry->nWID < RES_GRFATR_END)|| - pEntry->nWID == FN_PARAM_COUNTOUR_PP || - pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR || - pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR ) + if ((eType == FLYCNTTYPE_GRF) && isGRFATR(pEntry->nWID) || + (FN_PARAM_COUNTOUR_PP == pEntry->nWID) || + (FN_UNO_IS_AUTOMATIC_CONTOUR == pEntry->nWID) || + (FN_UNO_IS_PIXEL_CONTOUR == pEntry->nWID) ) { const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); if(pIdx) @@ -1468,8 +1466,7 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName) { if( ((eType == FLYCNTTYPE_GRF) || (eType == FLYCNTTYPE_OLE)) && pEntry && - ((pEntry->nWID >= RES_GRFATR_BEGIN && - pEntry->nWID < RES_GRFATR_END )|| + (isGRFATR(pEntry->nWID) || pEntry->nWID == FN_PARAM_COUNTOUR_PP || pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR || pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR )) @@ -1758,13 +1755,13 @@ uno::Sequence< beans::PropertyState > SwXFrame::getPropertyStates( FN_UNO_GRAPHIC_FILTER == pEntry->nWID|| FN_UNO_ACTUAL_SIZE == pEntry->nWID|| FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID) + { pStates[i] = beans::PropertyState_DIRECT_VALUE; + } else { - if(eType == FLYCNTTYPE_GRF && - pEntry && - (pEntry->nWID >= RES_GRFATR_BEGIN && - pEntry->nWID <= RES_GRFATR_END)) + if ((eType == FLYCNTTYPE_GRF) && + pEntry && isGRFATR(pEntry->nWID)) { const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); if(pIdx) @@ -1817,9 +1814,7 @@ void SwXFrame::setPropertyToDefault( const OUString& rPropertyName ) pEntry->nWID != FN_UNO_ANCHOR_TYPES && pEntry->nWID != FN_PARAM_LINK_DISPLAY_NAME) { - if( eType == FLYCNTTYPE_GRF && - (pEntry->nWID >= RES_GRFATR_BEGIN && - pEntry->nWID < RES_GRFATR_END)) + if ( (eType == FLYCNTTYPE_GRF) && isGRFATR(pEntry->nWID) ) { const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); if(pIdx) diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 00b907ad0674..9b2bebb67977 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -150,30 +150,6 @@ uno::Sequence< sal_Int8 > CreateUnoTunnelId() Hilfsklassen ****************************************************************************/ -SwParaSelection::SwParaSelection(SwUnoCrsr* pCrsr) : - pUnoCrsr(pCrsr) -{ - if(pUnoCrsr->HasMark()) - pUnoCrsr->DeleteMark(); - // steht er schon am Anfang? - if(pUnoCrsr->GetPoint()->nContent != 0) - pUnoCrsr->MovePara(fnParaCurr, fnParaStart); - // oder gleichzeitig am Ende? - if(pUnoCrsr->GetPoint()->nContent != pUnoCrsr->GetCntntNode()->Len()) - { - pUnoCrsr->SetMark(); - pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); - } -} - -SwParaSelection::~SwParaSelection() -{ - if(pUnoCrsr->GetPoint()->nContent != 0) - { - pUnoCrsr->DeleteMark(); - pUnoCrsr->MovePara(fnParaCurr, fnParaStart); - } -} /* -----------------13.05.98 12:15------------------- * * --------------------------------------------------*/ diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index e49e69ea5cdf..7a27bd597eb0 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -65,9 +65,7 @@ #include <fmtfld.hxx> #include <fmtpdsc.hxx> #include <pagedesc.hxx> -#ifndef _POOLFMT_HRC #include <poolfmt.hrc> -#endif #include <poolfmt.hxx> #include <edimp.hxx> #include <fchrfmt.hxx> @@ -620,7 +618,8 @@ uno::Reference< XEnumeration > SwXTextCursor::createEnumeration(void) throw( Ru *pNewCrsr->GetMark() = *pUnoCrsr->GetMark(); } CursorType eSetType = eType == CURSOR_TBLTEXT ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - SwXParagraphEnumeration *pEnum = new SwXParagraphEnumeration(pParentText, *pNewCrsr, eSetType); + SwXParagraphEnumeration *pEnum = + new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); uno::Reference< XEnumeration > xRet = pEnum; if (eType == CURSOR_TBLTEXT) { @@ -1078,8 +1077,9 @@ uno::Reference< XTextContent > SAL_CALL SwXParagraphEnumeration::NextElement_Imp } else { - SwUnoCrsr* pNewCrsr = pUnoCrsr->GetDoc()->CreateUnoCrsr(*pStart, sal_False); - aRef = (XTextContent*)new SwXParagraph((SwXText*)pText, pNewCrsr, nFirstContent, nLastContent); + aRef = new SwXParagraph(static_cast<SwXText*>(pText), + pStart->nNode.GetNode().GetTxtNode(), + nFirstContent, nLastContent); } } } @@ -1170,8 +1170,9 @@ Sequence< OUString > SwXTextRange::getSupportedServiceNames(void) throw( Runtime return aRet; } -SwXTextRange::SwXTextRange(SwPaM& rPam, const uno::Reference< XText > & rxParent) : - eRangePosition(RANGE_IN_TEXT), +SwXTextRange::SwXTextRange(SwPaM& rPam, + const uno::Reference< XText > & rxParent, enum RangePosition eRange) : + eRangePosition(eRange), pDoc(rPam.GetDoc()), pBox(0), pBoxStartNode(0), @@ -1180,46 +1181,6 @@ SwXTextRange::SwXTextRange(SwPaM& rPam, const uno::Reference< XText > & rxParent xParentText(rxParent), pMark(NULL) { - //Bookmark an der anlegen - _CreateNewBookmark(rPam); -} - -SwXTextRange::SwXTextRange(SwFrmFmt& rFmt, SwPaM& rPam) : - eRangePosition(RANGE_IN_FRAME), - pDoc(rPam.GetDoc()), - pBox(0), - pBoxStartNode(0), - aObjectDepend(this, &rFmt), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - pMark(NULL) -{ - //Bookmark an der anlegen - _CreateNewBookmark(rPam); -} - -SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt, SwTableBox& rTblBox, SwPaM& rPam) : - eRangePosition(RANGE_IN_CELL), - pDoc(rPam.GetDoc()), - pBox(&rTblBox), - pBoxStartNode(0), - aObjectDepend(this, &rTblFmt), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - pMark(NULL) -{ - //Bookmark an der anlegen - _CreateNewBookmark(rPam); -} - -SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt, const SwStartNode& rStartNode, SwPaM& rPam) : - eRangePosition(RANGE_IN_CELL), - pDoc(rPam.GetDoc()), - pBox(0), - pBoxStartNode(&rStartNode), - aObjectDepend(this, &rTblFmt), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - pMark(NULL) -{ - //Bookmark an der anlegen _CreateNewBookmark(rPam); } @@ -1287,50 +1248,22 @@ void SwXTextRange::DeleteAndInsert(const String& rText) uno::Reference< XText > SwXTextRange::getText(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!xParentText.is()) + if (!xParentText.is()) { - if(eRangePosition == RANGE_IN_FRAME && - aObjectDepend.GetRegisteredIn()) - { - SwFrmFmt* pFrmFmt = (SwFrmFmt*)aObjectDepend.GetRegisteredIn(); - SwXTextFrame* pxFrm = (SwXTextFrame*)SwClientIter( *pFrmFmt ). - First( TYPE( SwXTextFrame )); - if(pxFrm) - ((SwXTextRange*)this)->xParentText = pxFrm; - else - ((SwXTextRange*)this)->xParentText = new SwXTextFrame(*pFrmFmt); - ((SwModify*)aObjectDepend.GetRegisteredIn())-> - Remove(&((SwXTextRange*)this)->aObjectDepend); - - } - else if(eRangePosition == RANGE_IN_CELL && - aObjectDepend.GetRegisteredIn()) - { - const SwStartNode* pSttNd = pBoxStartNode ? pBoxStartNode : pBox->GetSttNd(); - const SwTableNode* pTblNode = pSttNd->FindTableNode(); - const SwFrmFmt* pTableFmt = pTblNode->GetTable().GetFrmFmt(); - ((SwXTextRange*)this)->xParentText = - pBox ? SwXCell::CreateXCell((SwFrmFmt*)pTableFmt, pBox) - : new SwXCell( (SwFrmFmt*)pTableFmt, *pBoxStartNode ); - ((SwModify*)aObjectDepend.GetRegisteredIn())-> - Remove(&((SwXTextRange*)this)->aObjectDepend); - } - else if(eRangePosition == RANGE_IS_TABLE && + if (eRangePosition == RANGE_IS_TABLE && aObjectDepend.GetRegisteredIn() ) { SwFrmFmt* pTblFmt = (SwFrmFmt*)aObjectDepend.GetRegisteredIn(); SwTable* pTable = SwTable::FindTable( pTblFmt ); SwTableNode* pTblNode = pTable->GetTableNode(); SwPosition aPosition( *pTblNode ); - uno::Reference< XTextRange > xRange = SwXTextRange::CreateTextRangeFromPosition(pDoc, - aPosition, 0); + uno::Reference< XTextRange > xRange = + SwXTextRange::CreateTextRangeFromPosition(pDoc, aPosition, 0); xParentText = xRange->getText(); } else { - // jetzt noch alle Faelle finden, die nicht abgedeckt sind - // (Body, Kopf-/Fusszeilen, Fussnotentext ) - DBG_WARNING("not implemented"); + OSL_ENSURE(false, "SwXTextRange::getText: no text"); } } return xParentText; @@ -1491,34 +1424,32 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, } else { - SwDoc* pDoc = 0; - const SwPaM* pUnoCrsr = 0; if (pPara) { - pUnoCrsr = pPara->GetCrsr(); - if (pUnoCrsr) - pDoc = pUnoCrsr->GetDoc(); + const SwTxtNode * pTxtNode( pPara->GetTxtNode() ); + + if (pTxtNode) { + bRet = sal_True; + *rToFill.GetPoint() = SwPosition( *pTxtNode ); + // set selection to the whole paragraph + rToFill.SetMark(); + rToFill.GetMark()->nContent = pTxtNode->GetTxt().Len(); + } } else { - pDoc = pCursor ? pCursor->GetDoc() : NULL; + 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; - } - if(pUnoCrsr && pDoc == rToFill.GetDoc()) + if (pUnoCrsr && pDoc == rToFill.GetDoc()) { DBG_ASSERT((SwPaM*)pUnoCrsr->GetNext() == pUnoCrsr, "was machen wir mit Ringen?" ); bRet = sal_True; *rToFill.GetPoint() = *pUnoCrsr->GetPoint(); - if(pPara) - { - // set selection to the whole paragraph - rToFill.SetMark(); - rToFill.GetMark()->nContent = - pUnoCrsr->GetNode()->GetTxtNode()->GetTxt().Len(); - } - else if(pUnoCrsr->HasMark()) + if (pUnoCrsr->HasMark()) { rToFill.SetMark(); *rToFill.GetMark() = *pUnoCrsr->GetMark(); @@ -1526,6 +1457,7 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, else rToFill.DeleteMark(); } + } } return bRet; } @@ -1555,18 +1487,28 @@ sal_Bool lcl_IsStartNodeInFormat(sal_Bool bHeader, SwStartNode* pSttNode, return bRet; } -uno::Reference< XTextRange > SwXTextRange::CreateTextRangeFromPosition(SwDoc* pDoc, - const SwPosition& rPos, const SwPosition* pMark) +uno::Reference< XTextRange > SwXTextRange::CreateTextRangeFromPosition( + SwDoc* pDoc, const SwPosition& rPos, const SwPosition* pMark) { - uno::Reference< XTextRange > aRet; - SwUnoCrsr* pNewCrsr = pDoc->CreateUnoCrsr(rPos, sal_False); + uno::Reference< XText > xParentText( CreateParentXText(pDoc, rPos) ); + std::auto_ptr<SwUnoCrsr> pNewCrsr( pDoc->CreateUnoCrsr(rPos, sal_False) ); if(pMark) { pNewCrsr->SetMark(); *pNewCrsr->GetMark() = *pMark; } - uno::Reference< XText > xParentText; - //jetzt besorgen wir uns mal den Parent: + bool isCell( dynamic_cast<SwXCell*>(xParentText.get()) ); + uno::Reference< XTextRange > xRet( + new SwXTextRange(*pNewCrsr, xParentText, + isCell ? RANGE_IN_CELL : RANGE_IN_TEXT) ); + return xRet; + +} + +uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, + const SwPosition& rPos) +{ + uno::Reference< XText > xParentText; SwStartNode* pSttNode = rPos.nNode.GetNode().StartOfSectionNode(); while(pSttNode && pSttNode->IsSectionNode()) { @@ -1581,19 +1523,19 @@ uno::Reference< XTextRange > SwXTextRange::CreateTextRangeFromPosition(SwDoc* pD SwFrmFmt* pTableFmt = (SwFrmFmt*)pTblNode->GetTable().GetFrmFmt(); SwTableBox* pBox = pSttNode->GetTblBox(); - if( pBox ) - aRet = new SwXTextRange(*pTableFmt, *pBox, *pNewCrsr); - else - aRet = new SwXTextRange(*pTableFmt, *pSttNode, *pNewCrsr); + xParentText = pBox + ? SwXCell::CreateXCell( pTableFmt, pBox ) + : new SwXCell( pTableFmt, *pSttNode ); } break; case SwFlyStartNode: { - SwFrmFmt* pFmt; - if(0 != (pFmt = pSttNode->GetFlyFmt())) + SwFrmFmt* pFmt = pSttNode->GetFlyFmt(); + if (0 != pFmt) { - aRet = new SwXTextRange(*pFmt, *pNewCrsr); - + SwXTextFrame* pFrame( static_cast<SwXTextFrame*>( + SwClientIter( *pFmt ).First( TYPE( SwXTextFrame ) ) ) ); + xParentText = pFrame ? pFrame : new SwXTextFrame( *pFmt ); } } break; @@ -1640,13 +1582,15 @@ uno::Reference< XTextRange > SwXTextRange::CreateTextRangeFromPosition(SwDoc* pD (void)pTmpSttNode; #endif - if(pSttNode == pTxtFtn->GetStartNode()->GetNode(). + if (pSttNode == pTxtFtn->GetStartNode()->GetNode(). FindSttNodeByType(SwFootnoteStartNode)) { xParentText = ((SwUnoCallBack*)pDoc->GetUnoCallBack())-> GetFootnote(rFtn); - if(!xParentText.is()) + if (!xParentText.is()) + { xParentText = new SwXFootnote(pDoc, rFtn); + } break; } } @@ -1654,17 +1598,16 @@ uno::Reference< XTextRange > SwXTextRange::CreateTextRangeFromPosition(SwDoc* pD break; default: { - // dann ist es der Body-Text - uno::Reference<frame::XModel> xModel = pDoc->GetDocShell()->GetBaseModel(); + // then it is the body text + uno::Reference<frame::XModel> xModel = + pDoc->GetDocShell()->GetBaseModel(); uno::Reference< XTextDocument > xDoc( xModel, uno::UNO_QUERY); xParentText = xDoc->getText(); } } - if(!aRet.is()) - aRet = new SwXTextRange(*pNewCrsr, xParentText); - delete pNewCrsr; - return aRet; + OSL_ENSURE(xParentText.is(), "no parent text?"); + return xParentText; } uno::Reference< XEnumeration > SAL_CALL SwXTextRange::createContentEnumeration( @@ -1707,7 +1650,8 @@ uno::Reference< XEnumeration > SwXTextRange::createEnumeration(void) throw( Runt } DBG_ASSERT(pParentText, "parent is not a SwXText"); CursorType eSetType = RANGE_IN_CELL == eRangePosition ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - uno::Reference< XEnumeration > xRet = new SwXParagraphEnumeration(pParentText, *pNewCrsr, eSetType); + uno::Reference< XEnumeration > xRet = + new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); return xRet; } @@ -2090,23 +2034,25 @@ Sequence< OUString > SwXParaFrameEnumeration::getSupportedServiceNames(void) thr /*-- 23.03.99 13:22:29--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwUnoCrsr& rUnoCrsr, +SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, sal_uInt8 nParaFrameMode, SwFrmFmt* pFmt) { - SwDoc* pDoc = rUnoCrsr.GetDoc(); - SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(*rUnoCrsr.GetPoint(), sal_False); - if(rUnoCrsr.HasMark()) + SwDoc* pDoc = rPaM.GetDoc(); + SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(*rPaM.GetPoint(), sal_False); + if (rPaM.HasMark()) { pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *rUnoCrsr.GetMark(); + *pUnoCrsr->GetMark() = *rPaM.GetMark(); } pUnoCrsr->Add(this); - if(PARAFRAME_PORTION_PARAGRAPH == nParaFrameMode) - ::CollectFrameAtNode( *this, rUnoCrsr.GetPoint()->nNode, + if (PARAFRAME_PORTION_PARAGRAPH == nParaFrameMode) + { + ::CollectFrameAtNode( *this, rPaM.GetPoint()->nNode, aFrameArr, FALSE ); - else if(pFmt) + } + else if (pFmt) { //jetzt einen SwDepend anlegen und in das Array einfuegen SwDepend* pNewDepend = new SwDepend(this, pFmt); diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 7662df99afed..d21439ff120e 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -33,9 +33,7 @@ #include <cmdid.h> -#ifndef _UNOMID_H #include <unomid.h> -#endif #include <unoobj.hxx> #include <unomap.hxx> #include <unocrsr.hxx> @@ -45,6 +43,7 @@ #include <ndtxt.hxx> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> +#include <docsh.hxx> #define _SVSTDARR_USHORTS #define _SVSTDARR_USHORTSSORT @@ -53,21 +52,61 @@ #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp> #include <com/sun/star/beans/GetPropertyTolerantResult.hpp> #include <com/sun/star/beans/TolerantPropertySetResultType.hpp> -#ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif #include <com/sun/star/text/WrapTextMode.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> using namespace ::com::sun::star; using ::rtl::OUString; + +/* -----------------------------01.12.00 18:09-------------------------------- + + ---------------------------------------------------------------------------*/ +class SwParaSelection +{ + SwCursor* m_pCursor; +public: + SwParaSelection(SwCursor* pPam); + ~SwParaSelection(); +}; + +SwParaSelection::SwParaSelection(SwCursor* pCursor) + : m_pCursor(pCursor) +{ + if (m_pCursor->HasMark()) + { + m_pCursor->DeleteMark(); + } + // is it at the start? + if (m_pCursor->GetPoint()->nContent != 0) + { + m_pCursor->MovePara(fnParaCurr, fnParaStart); + } + // or at the end already? + if (m_pCursor->GetPoint()->nContent != m_pCursor->GetCntntNode()->Len()) + { + m_pCursor->SetMark(); + m_pCursor->MovePara(fnParaCurr, fnParaEnd); + } +} + +SwParaSelection::~SwParaSelection() +{ + if (m_pCursor->GetPoint()->nContent != 0) + { + m_pCursor->DeleteMark(); + m_pCursor->MovePara(fnParaCurr, fnParaStart); + } +} + + /****************************************************************** * forward declarations ******************************************************************/ beans::PropertyState lcl_SwXParagraph_getPropertyState( - SwUnoCrsr& rUnoCrsr, + const SwTxtNode& rTxtNode, const SwAttrSet** ppSet, const SfxItemPropertySimpleEntry& rEntry, sal_Bool &rAttrSetFetched ) @@ -76,6 +115,9 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( /****************************************************************** * SwXParagraph ******************************************************************/ + +TYPEINIT1(SwXParagraph, SwClient); + /* -----------------------------11.07.00 12:10-------------------------------- ---------------------------------------------------------------------------*/ @@ -164,9 +206,9 @@ SwXParagraph::SwXParagraph() : /*-- 11.12.98 08:12:47--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXParagraph::SwXParagraph(SwXText* pParent, SwUnoCrsr* pCrsr, sal_Int32 nSelStart, sal_Int32 nSelEnd) : - SwClient(pCrsr), - xParentText(pParent), +SwXParagraph::SwXParagraph(uno::Reference< text::XText > const & i_xParent, SwTxtNode * i_pTxtNode, sal_Int32 nSelStart, sal_Int32 nSelEnd) : + SwClient(i_pTxtNode), + xParentText(i_xParent), aLstnrCntnr( (text::XTextRange*)this), m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH)), nSelectionStartPos(nSelStart), @@ -179,10 +221,6 @@ SwXParagraph::SwXParagraph(SwXText* pParent, SwUnoCrsr* pCrsr, sal_Int32 nSelSta -----------------------------------------------------------------------*/ SwXParagraph::~SwXParagraph() { - vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - delete pUnoCrsr; } /* -----------------------------11.07.00 14:48-------------------------------- @@ -247,14 +285,15 @@ void SAL_CALL SwXParagraph::SetPropertyValues_Impl( throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + if (GetTxtNode()) { + SwPosition aPos( *GetTxtNode() ); + SwCursor aCursor( aPos, 0, false ); const OUString* pPropertyNames = rPropertyNames.getConstArray(); const uno::Any* pValues = rValues.getConstArray(); const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); OUString sTmp; - SwParaSelection aParaSel(pUnoCrsr); + SwParaSelection aParaSel( & aCursor ); for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) { const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pPropertyNames[nProp] ); @@ -265,7 +304,7 @@ void SAL_CALL SwXParagraph::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, + SwXTextCursor::SetPropertyValue(aCursor, *m_pPropSet, sTmp, pValues[nProp]); } } @@ -304,14 +343,15 @@ uno::Sequence< uno::Any > SAL_CALL SwXParagraph::GetPropertyValues_Impl( throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) { uno::Sequence< uno::Any > aValues(rPropertyNames.getLength()); - SwUnoCrsr* pUnoCrsr = ((SwXParagraph*)this)->GetCrsr(); - if(pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { + SwPosition aPos( *pTxtNode ); + SwPaM aPam( aPos ); uno::Any* pValues = aValues.getArray(); const OUString* pPropertyNames = rPropertyNames.getConstArray(); const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); - SwNode& rTxtNode = pUnoCrsr->GetPoint()->nNode.GetNode(); - const SwAttrSet& rAttrSet = ((SwTxtNode&)rTxtNode).GetSwAttrSet(); + const SwAttrSet& rAttrSet( pTxtNode->GetSwAttrSet() ); for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) { const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pPropertyNames[nProp] ); @@ -323,7 +363,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXParagraph::GetPropertyValues_Impl( BOOL bDone = FALSE; beans::PropertyState eTemp; bDone = SwUnoCursorHelper::getCrsrPropertyValue( - *pEntry, *pUnoCrsr, &(pValues[nProp]), eTemp, rTxtNode.GetTxtNode() ); + *pEntry, aPam, &(pValues[nProp]), eTemp, pTxtNode ); if(!bDone) m_pPropSet->getPropertyValue(*pEntry, rAttrSet, pValues[nProp]); } @@ -400,8 +440,9 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setProp if (rPropertyNames.getLength() != rValues.getLength()) throw lang::IllegalArgumentException(); - SwUnoCrsr* pUnoCrsr = ((SwXParagraph*)this)->GetCrsr(); - if(!pUnoCrsr) + + const SwTxtNode * const pTxtNode( GetTxtNode() ); + if (!pTxtNode) throw uno::RuntimeException(); //SwNode& rTxtNode = pUnoCrsr->GetPoint()->nNode.GetNode(); @@ -422,7 +463,9 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setProp const SfxItemPropertyMap* pPropMap = m_pPropSet->getPropertyMap(); OUString sTmp; - SwParaSelection aParaSel( pUnoCrsr ); + SwPosition aPos( *pTxtNode ); + SwCursor aCursor( aPos, 0, false ); + SwParaSelection aParaSel( & aCursor ); for (sal_Int32 i = 0; i < nProps; ++i) { try @@ -441,7 +484,7 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXParagraph::setProp else { SwXTextCursor::SetPropertyValue( - *pUnoCrsr, *m_pPropSet, pProp[i], pValue[i] ); + aCursor, *m_pPropSet, pProp[i], pValue[i] ); } } } @@ -506,11 +549,10 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::G { vos::OGuard aGuard( Application::GetSolarMutex() ); - SwUnoCrsr* pUnoCrsr = ((SwXParagraph*)this)->GetCrsr(); - if (!pUnoCrsr) - throw uno::RuntimeException(); - SwTxtNode* pTxtNode = pUnoCrsr->GetPoint()->nNode.GetNode().GetTxtNode(); + const SwTxtNode * const pTxtNode( GetTxtNode() ); DBG_ASSERT( pTxtNode != NULL, "need text node" ); + if (!pTxtNode) + throw uno::RuntimeException(); // #i46786# Use SwAttrSet pointer for determining the state. // Use the value SwAttrSet (from the paragraph OR the style) @@ -546,7 +588,7 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::G // (compare to SwXParagraph::getPropertyState) sal_Bool bAttrSetFetched = sal_True; beans::PropertyState eState = lcl_SwXParagraph_getPropertyState( - *pUnoCrsr, &pAttrSet, *pEntry, bAttrSetFetched ); + *pTxtNode, &pAttrSet, *pEntry, bAttrSetFetched ); rResult.State = eState; // if (bDirectValuesOnly && PropertyState_DIRECT_VALUE != eState) @@ -561,12 +603,14 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph::G if (!SwXParagraph::getDefaultTextContentValue( aValue, pProp[i], pEntry->nWID ) ) { + SwPosition aPos( *pTxtNode ); + SwPaM aPam( aPos ); // handle properties that are not part of the attribute // and thus only pretendend to be paragraph attributes BOOL bDone = FALSE; beans::PropertyState eTemp; bDone = SwUnoCursorHelper::getCrsrPropertyValue( - *pEntry, *pUnoCrsr, &aValue, eTemp, pTxtNode ); + *pEntry, aPam, &aValue, eTemp, pTxtNode ); // if not found try the real paragraph attributes... if (!bDone) @@ -677,7 +721,8 @@ void SwXParagraph::removeVetoableChangeListener(const OUString& /*PropertyName*/ } //----------------------------------------------------------------------------- beans::PropertyState lcl_SwXParagraph_getPropertyState( - SwUnoCrsr& rUnoCrsr, +// SwUnoCrsr& rUnoCrsr, + const SwTxtNode& rTxtNode, const SwAttrSet** ppSet, const SfxItemPropertySimpleEntry& rEntry, sal_Bool &rAttrSetFetched ) @@ -687,15 +732,16 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( if(!(*ppSet) && !rAttrSetFetched ) { - SwNode& rTxtNode = rUnoCrsr.GetPoint()->nNode.GetNode(); - (*ppSet) = ((SwTxtNode&)rTxtNode).GetpSwAttrSet(); + (*ppSet) = rTxtNode.GetpSwAttrSet(); rAttrSetFetched = sal_True; } + SwPosition aPos( rTxtNode ); + SwPaM aPam( aPos ); switch( rEntry.nWID ) { case FN_UNO_NUM_RULES: - //wenn eine Numerierung gesetzt ist, dann hier herausreichen, sonst nichts tun - SwUnoCursorHelper::getNumberingProperty( rUnoCrsr, eRet, NULL ); + // if numbering is set, return it; else do nothing + SwUnoCursorHelper::getNumberingProperty( aPam, eRet, NULL ); break; case FN_UNO_ANCHOR_TYPES: break; @@ -711,7 +757,7 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( case FN_UNO_PARA_CONDITIONAL_STYLE_NAME: { SwFmtColl* pFmt = SwXTextCursor::GetCurTxtFmtColl( - rUnoCrsr, rEntry.nWID == FN_UNO_PARA_CONDITIONAL_STYLE_NAME); + aPam, rEntry.nWID == FN_UNO_PARA_CONDITIONAL_STYLE_NAME); eRet = pFmt ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE; } @@ -719,7 +765,7 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( case FN_UNO_PAGE_STYLE: { String sVal; - SwUnoCursorHelper::GetCurPageStyle( rUnoCrsr, sVal ); + SwUnoCursorHelper::GetCurPageStyle( aPam, sVal ); eRet = sVal.Len() ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE; } @@ -741,16 +787,16 @@ beans::PropertyState SwXParagraph::getPropertyState(const OUString& rPropertyNam { vos::OGuard aGuard(Application::GetSolarMutex()); beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; - SwUnoCrsr* pUnoCrsr = ((SwXParagraph*)this)->GetCrsr(); - if( pUnoCrsr ) + const SwTxtNode * const pTxtNode( GetTxtNode() ); + if (pTxtNode) { const SwAttrSet* pSet = 0; const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); if(!pEntry) throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); sal_Bool bDummy = sal_False; - eRet = lcl_SwXParagraph_getPropertyState( *pUnoCrsr, &pSet, *pEntry, - bDummy ); + eRet = lcl_SwXParagraph_getPropertyState( *pTxtNode, &pSet, *pEntry, + bDummy ); } else throw uno::RuntimeException(); @@ -769,10 +815,10 @@ uno::Sequence< beans::PropertyState > SwXParagraph::getPropertyStates( uno::Sequence< beans::PropertyState > aRet(PropertyNames.getLength()); beans::PropertyState* pStates = aRet.getArray(); - SwUnoCrsr* pUnoCrsr = ((SwXParagraph*)this)->GetCrsr(); - const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); - if( pUnoCrsr ) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { + const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); const SwAttrSet* pSet = 0; sal_Bool bAttrSetFetched = sal_False; for(sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd; i++,++pStates,++pNames ) @@ -780,12 +826,16 @@ uno::Sequence< beans::PropertyState > SwXParagraph::getPropertyStates( const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( *pNames ); if(!pEntry) throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + *pNames, static_cast < cppu::OWeakObject * > ( this ) ); - if (bAttrSetFetched && !pSet && - pEntry->nWID >= RES_CHRATR_BEGIN && - pEntry->nWID <= RES_UNKNOWNATR_END ) + + if (bAttrSetFetched && !pSet && isATR(pEntry->nWID)) + { *pStates = beans::PropertyState_DEFAULT_VALUE; + } else - *pStates = lcl_SwXParagraph_getPropertyState( *pUnoCrsr, &pSet,*pEntry, bAttrSetFetched ); + { + *pStates = lcl_SwXParagraph_getPropertyState( + *pTxtNode, &pSet, *pEntry, bAttrSetFetched ); + } } } else @@ -800,16 +850,18 @@ void SwXParagraph::setPropertyToDefault(const OUString& rPropertyName) throw( beans::UnknownPropertyException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { + SwPosition aPos( *pTxtNode ); + SwCursor aCursor( aPos, 0, false ); if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)) || rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPES)) || rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_TEXT_WRAP))) return; - // Absatz selektieren - SwParaSelection aParaSel(pUnoCrsr); + // select paragraph + SwParaSelection aParaSel( & aCursor ); const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); if(pEntry) { @@ -821,14 +873,17 @@ void SwXParagraph::setPropertyToDefault(const OUString& rPropertyName) SvUShortsSort aWhichIds; aWhichIds.Insert(pEntry->nWID); if(pEntry->nWID < RES_PARATR_BEGIN) - pUnoCrsr->GetDoc()->ResetAttrs(*pUnoCrsr, sal_True, &aWhichIds); + { + aCursor.GetDoc()->ResetAttrs(aCursor, sal_True, &aWhichIds); + } else { - //fuer Absatzattribute muss die Selektion jeweils auf - //Absatzgrenzen erweitert werden - SwPosition aStart = *pUnoCrsr->Start(); - SwPosition aEnd = *pUnoCrsr->End(); - SwUnoCrsr* pTemp = pUnoCrsr->GetDoc()->CreateUnoCrsr(aStart, sal_False); + // for paragraph attributes the selection must be extended + // to paragraph boundaries + SwPosition aStart( *aCursor.Start() ); + SwPosition aEnd ( *aCursor.End() ); + std::auto_ptr<SwUnoCrsr> pTemp( + aCursor.GetDoc()->CreateUnoCrsr(aStart, sal_False) ); if(!SwUnoCursorHelper::IsStartOfPara(*pTemp)) { pTemp->MovePara(fnParaCurr, fnParaStart); @@ -842,11 +897,12 @@ void SwXParagraph::setPropertyToDefault(const OUString& rPropertyName) pTemp->MovePara(fnParaCurr, fnParaEnd); } pTemp->GetDoc()->ResetAttrs(*pTemp, sal_True, &aWhichIds); - delete pTemp; } } else - SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, *pUnoCrsr); + { + SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, aCursor); + } } else throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); @@ -861,8 +917,8 @@ uno::Any SwXParagraph::getPropertyDefault(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) { uno::Any aRet; - SwUnoCrsr* pUnoCrsr = ((SwXParagraph*)this)->GetCrsr(); - if(pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { if(SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) return aRet; @@ -873,7 +929,8 @@ uno::Any SwXParagraph::getPropertyDefault(const OUString& rPropertyName) if(pEntry->nWID < RES_FRMATR_END) { const SfxPoolItem& rDefItem = - pUnoCrsr->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); + pTxtNode->GetDoc()->GetAttrPool().GetDefaultItem( + pEntry->nWID); rDefItem.QueryValue(aRet, pEntry->nMemberId); } } @@ -904,12 +961,14 @@ uno::Reference< text::XTextRange > SwXParagraph::getAnchor(void) throw( uno::Ru { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > aRet; - SwUnoCrsr* pUnoCrsr = ((SwXParagraph*)this)->GetCrsr(); - if(pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { - // Absatz selektieren - SwParaSelection aSelection(pUnoCrsr); - aRet = new SwXTextRange(*pUnoCrsr, xParentText); + SwPosition aPos( *pTxtNode ); + SwCursor aCursor( aPos, 0, false ); + // select paragraph + SwParaSelection aParaSel( & aCursor ); + aRet = new SwXTextRange(aCursor, xParentText); } else throw uno::RuntimeException(); @@ -921,16 +980,16 @@ uno::Reference< text::XTextRange > SwXParagraph::getAnchor(void) throw( uno::Ru void SwXParagraph::dispose(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXParagraph*)this)->GetCrsr(); - if(pUnoCrsr) + SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { - // Absatz selektieren + SwCursor aCursor( SwPosition( *pTxtNode ), 0, false ); + // select paragraph { - SwParaSelection aSelection(pUnoCrsr); - pUnoCrsr->GetDoc()->DelFullPara(*pUnoCrsr); + SwParaSelection aParaSel( & aCursor ); + pTxtNode->GetDoc()->DelFullPara(aCursor); } aLstnrCntnr.Disposing(); - delete pUnoCrsr; } else throw uno::RuntimeException(); @@ -959,9 +1018,14 @@ uno::Reference< container::XEnumeration > SwXParagraph::createEnumeration(void) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< container::XEnumeration > aRef; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - aRef = new SwXTextPortionEnumeration(*pUnoCrsr, xParentText, nSelectionStartPos, nSelectionEndPos); + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) + { + SwPosition aPos( *pTxtNode ); + SwPaM aPam ( aPos ); + aRef = new SwXTextPortionEnumeration(aPam, xParentText, + nSelectionStartPos, nSelectionEndPos); + } else throw uno::RuntimeException(); return aRef; @@ -980,10 +1044,7 @@ uno::Type SwXParagraph::getElementType(void) throw( uno::RuntimeException ) sal_Bool SwXParagraph::hasElements(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(((SwXParagraph*)this)->GetCrsr()) - return sal_True; - else - return sal_False; + return (GetTxtNode()) ? sal_True : sal_False; } /*-- 11.12.98 08:12:55--------------------------------------------------- @@ -999,11 +1060,13 @@ uno::Reference< text::XTextRange > SwXParagraph::getStart(void) throw( uno::Run { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if( pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { - SwParaSelection aSelection(pUnoCrsr); - SwPaM aPam(*pUnoCrsr->Start()); + SwPosition aPos( *pTxtNode ); + SwCursor aCursor( aPos, 0, false ); + SwParaSelection aParaSel( &aCursor ); + SwPaM aPam( *aCursor.Start() ); uno::Reference< text::XText > xParent = getText(); xRet = new SwXTextRange(aPam, xParent); } @@ -1018,11 +1081,13 @@ uno::Reference< text::XTextRange > SwXParagraph::getEnd(void) throw( uno::Runti { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if( pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { - SwParaSelection aSelection(pUnoCrsr); - SwPaM aPam(*pUnoCrsr->End()); + SwPosition aPos( *pTxtNode ); + SwCursor aCursor( aPos, 0, false ); + SwParaSelection aParaSel( &aCursor ); + SwPaM aPam( *aCursor.End() ); uno::Reference< text::XText > xParent = getText(); xRet = new SwXTextRange(aPam, xParent); } @@ -1037,11 +1102,13 @@ OUString SwXParagraph::getString(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); OUString aRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if( pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { - SwParaSelection aSelection(pUnoCrsr); - SwXTextCursor::getTextFromPam(*pUnoCrsr, aRet); + SwPosition aPos( *pTxtNode ); + SwCursor aCursor( aPos, 0, false ); + SwParaSelection aParaSel( & aCursor ); + SwXTextCursor::getTextFromPam(aCursor, aRet); } else if(IsDescriptor()) aRet = m_sText; @@ -1055,17 +1122,21 @@ OUString SwXParagraph::getString(void) throw( uno::RuntimeException ) void SwXParagraph::setString(const OUString& aString) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { - if(!SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr)) - pUnoCrsr->MovePara(fnParaCurr, fnParaStart); - SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); - if(pUnoCrsr->GetNode()->GetTxtNode()->GetTxt().Len()) - pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); - SwXTextCursor::SetString(*pUnoCrsr, aString); - SwXTextCursor::SelectPam(*pUnoCrsr, sal_False); + SwPosition aPos( *pTxtNode ); + SwCursor aCursor( aPos, 0, false ); + if (!SwUnoCursorHelper::IsStartOfPara(aCursor)) { + aCursor.MovePara(fnParaCurr, fnParaStart); + } + SwXTextCursor::SelectPam(aCursor, sal_True); + if (pTxtNode->GetTxt().Len()) { + aCursor.MovePara(fnParaCurr, fnParaEnd); + } + SwXTextCursor::SetString(aCursor, aString); + SwXTextCursor::SelectPam(aCursor, sal_False); } else if(IsDescriptor()) m_sText = aString; @@ -1079,11 +1150,14 @@ void SwXParagraph::setString(const OUString& aString) throw( uno::RuntimeExcepti uno::Reference< container::XEnumeration > SwXParagraph::createContentEnumeration(const OUString& rServiceName) throw( uno::RuntimeException ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if( !pUnoCrsr || COMPARE_EQUAL != rServiceName.compareToAscii("com.sun.star.text.TextContent") ) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if(!pTxtNode || !rServiceName.equalsAscii("com.sun.star.text.TextContent")) throw uno::RuntimeException(); - uno::Reference< container::XEnumeration > xRet = new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_PARAGRAPH); + SwPosition aPos( *pTxtNode ); + SwPaM aPam( aPos ); + uno::Reference< container::XEnumeration > xRet = + new SwXParaFrameEnumeration(aPam, PARAFRAME_PORTION_PARAGRAPH); return xRet; } /* -----------------23.03.99 12:49------------------- @@ -1106,3 +1180,33 @@ void SwXParagraph::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) aLstnrCntnr.Disposing(); } +const SwTxtNode * SwXParagraph::GetTxtNode() const +{ + return static_cast<const SwTxtNode*>(GetRegisteredIn()); +} + +SwTxtNode * SwXParagraph::GetTxtNode() +{ + return static_cast<SwTxtNode*>(pRegisteredIn); +} + +::sfx2::Metadatable* SwXParagraph::GetCoreObject() +{ + SwTxtNode * pTxtNode( GetTxtNode() ); + return pTxtNode; +} + +uno::Reference<frame::XModel> SwXParagraph::GetModel() +{ + SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) + { + const SwDocShell * pShell( pTxtNode->GetDoc()->GetDocShell() ); + return (pShell) ? pShell->GetModel() : 0; + } + else + { + return 0; + } +} + diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index 6fcff2505136..4aa2d1a27d6f 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -86,7 +86,7 @@ SwFmtFld* SwXTextPortion::GetFldFmt(sal_Bool bInit) -----------------------------------------------------------------------*/ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, - uno::Reference< text::XText > & rParent, + uno::Reference< text::XText > const& rParent, SwTextPortionType eType) : aLstnrCntnr( (text::XTextRange*)this), m_pPropSet(aSwMapProvider.GetPropertySet( @@ -121,8 +121,9 @@ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, /* -----------------24.03.99 16:30------------------- * * --------------------------------------------------*/ -SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, uno::Reference< text::XText > & rParent, - SwFrmFmt& rFmt ) : +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), @@ -1072,7 +1073,7 @@ void SwXTextPortion::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) ---------------------------------------------------------------------------*/ SwXRubyPortion::SwXRubyPortion(const SwUnoCrsr* pPortionCrsr, SwTxtRuby& rAttr, - uno::Reference< text::XText > & rParent, + uno::Reference< text::XText > const& rParent, sal_Bool bEnd ) : SwXTextPortion(pPortionCrsr, rParent, bEnd ? PORTION_RUBY_END : PORTION_RUBY_START ) { diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index eee230794051..d972329b0f52 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -57,12 +57,14 @@ #include <boost/shared_ptr.hpp> #include <boost/bind.hpp> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::text; using ::rtl::OUString; using namespace ::std; + namespace { static const BYTE BKM_TYPE_START = 0; @@ -165,6 +167,7 @@ namespace } } + /****************************************************************** * SwXTextPortionEnumeration ******************************************************************/ @@ -284,7 +287,8 @@ uno::Any SwXTextPortionEnumeration::nextElement(void) ---------------------------------------------------------------------------*/ void lcl_InsertRefMarkPortion( - XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, Reference<XText>& rParent, SwTxtAttr* pAttr, BOOL bEnd) + XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, + Reference<XText> const& rParent, SwTxtAttr* pAttr, BOOL bEnd) { SwDoc* pDoc = pUnoCrsr->GetDoc(); SwFmtRefMark& rRefMark = ((SwFmtRefMark&)pAttr->GetAttr()); @@ -311,18 +315,17 @@ void lcl_InsertRefMarkPortion( } //----------------------------------------------------------------------------- void lcl_InsertRubyPortion( XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, - Reference<XText>& rParent, SwTxtAttr* pAttr, BOOL bEnd) + Reference<XText> const& rParent, SwTxtAttr* pAttr, BOOL bEnd) { - SwXRubyPortion* pPortion = 0; - rArr.Insert( - new Reference< XTextRange >(pPortion = new SwXRubyPortion(*pUnoCrsr, *(SwTxtRuby*)pAttr, rParent, - bEnd)), - rArr.Count()); + SwXRubyPortion* pPortion = + new SwXRubyPortion(pUnoCrsr, *(SwTxtRuby*)pAttr, rParent, bEnd); + rArr.Insert( new Reference< XTextRange >(pPortion), rArr.Count() ); pPortion->SetCollapsed(pAttr->GetEnd() ? FALSE : TRUE); } //----------------------------------------------------------------------------- void lcl_InsertTOXMarkPortion( - XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, Reference<XText>& rParent, SwTxtAttr* pAttr, BOOL bEnd) + XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, Reference<XText> const& rParent, + SwTxtAttr* pAttr, BOOL bEnd) { SwDoc* pDoc = pUnoCrsr->GetDoc(); SwTOXMark& rTOXMark = ((SwTOXMark&)pAttr->GetAttr()); @@ -455,20 +458,17 @@ typedef std::multiset < SwXRedlinePortion_ImplSharedPtr, RedlineCompareStruct > //----------------------------------------------------------------------------- Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, - XTextRangeArr& rPortionArr, - SwUnoCrsr* pUnoCrsr, - Reference<XText> & rParent, - const xub_StrLen nCurrentIndex, - SwTextPortionType& ePortionType, - const xub_StrLen& nFirstFrameIndex, - SwXBookmarkPortion_ImplList& aBkmArr, - SwXRedlinePortion_ImplList& aRedArr, - SwSoftPageBreakList& aBreakArr, - sal_Int32 nEndPos ) + XTextRangeArr& rPortionArr, + SwUnoCrsr* pUnoCrsr, + const Reference<XText> & rParent, + const xub_StrLen nCurrentIndex, + SwTextPortionType & rePortionType, + bool & io_rbRightMoveForbidden, + sal_Int32 & o_rNextAttrPosition ) { Reference<XTextRange> xRef; SwDoc* pDoc = pUnoCrsr->GetDoc(); - sal_Bool bAttrFound = sal_False; + bool bAlreadyMoved = false; //search for special text attributes - first some ends sal_uInt16 nEndIndex = 0; sal_uInt16 nNextEnd = 0; @@ -490,29 +490,31 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, case RES_TXTATR_TOXMARK: lcl_InsertTOXMarkPortion( rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; break; case RES_TXTATR_REFMARK: lcl_InsertRefMarkPortion( rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; 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( - rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - ePortionType = PORTION_TEXT; + rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); + rePortionType = PORTION_TEXT; break; } } } nEndIndex++; } - //#111716# the cursor must not move right at the end position of a selection! - BOOL bRightMoveForbidden = FALSE; - if(nEndPos > 0 && nCurrentIndex >= nEndPos) - bRightMoveForbidden = TRUE; - //then som starts + // then some starts sal_uInt16 nStartIndex = 0; sal_uInt16 nNextStart = 0; while(nStartIndex < pHints->GetStartCount() && @@ -529,29 +531,29 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, switch( nAttrWhich ) { case RES_TXTATR_FIELD: - if(!bRightMoveForbidden) + if(!io_rbRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) break; - bAttrFound = sal_True; - ePortionType = PORTION_FIELD; + bAlreadyMoved = true; + rePortionType = PORTION_FIELD; } break; case RES_TXTATR_FLYCNT : - if(!bRightMoveForbidden) + if(!io_rbRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) break; // Robust #i81708 content in covered cells pUnoCrsr->Exchange(); - bAttrFound = sal_True; - ePortionType = PORTION_FRAME; + bAlreadyMoved = true; + rePortionType = PORTION_FRAME; } break; case RES_TXTATR_FTN : { - if(!bRightMoveForbidden) + if(!io_rbRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) @@ -563,8 +565,8 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, SwXFootnotes::GetObject(*pDoc, pAttr->SwTxtAttr::GetFtn()), UNO_QUERY); pPortion->SetFootnote(xContent); - bAttrFound = sal_True; - ePortionType = PORTION_TEXT; + bAlreadyMoved = true; + rePortionType = PORTION_TEXT; } } break; @@ -577,12 +579,12 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, pUnoCrsr, rParent, PORTION_CONTROL_CHAR)), rPortionArr.Count()); pPortion->SetControlChar(3); - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; } break; case RES_TXTATR_HARDBLANK: { - ePortionType = PORTION_CONTROL_CHAR; + rePortionType = PORTION_CONTROL_CHAR; SwXTextPortion* pPortion = 0; rPortionArr.Insert( new Reference< XTextRange >( @@ -594,26 +596,26 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, pPortion->SetControlChar(2);//HARD_HYPHEN else pPortion->SetControlChar(4);//HARD_SPACE - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; } break; case RES_TXTATR_TOXMARK: lcl_InsertTOXMarkPortion( rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; break; case RES_TXTATR_REFMARK: - if(!bRightMoveForbidden || pAttr->GetEnd()) + if(!io_rbRightMoveForbidden || pAttr->GetEnd()) { if(!pAttr->GetEnd()) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); - bAttrFound = sal_True; + bAlreadyMoved = true; } lcl_InsertRefMarkPortion( rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; if(!pAttr->GetEnd()) { if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) @@ -623,11 +625,12 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, } break; case RES_TXTATR_CJK_RUBY: - if(pAttr->GetEnd()) + //#i91534# GetEnd() == 0 mixes the order of ruby start/end + if(pAttr->GetEnd() && (*pAttr->GetEnd() != *pAttr->GetStart())) { lcl_InsertRubyPortion( rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; } break; default: @@ -638,7 +641,7 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, nStartIndex++; } - if(!bAttrFound) + if (!bAlreadyMoved) { // search for attribute changes behind the current cursor position // break up at frames, bookmarks, redlines @@ -654,37 +657,54 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, while(nEndIndex < pHints->GetEndCount() && nCurrentIndex >= (nNextEnd = (*pHints->GetEnd(nEndIndex)->GetAnyEnd()))) nEndIndex++; - //nMovePos legt die neue EndPosition fest - sal_uInt16 nMovePos = nNextStart > nCurrentIndex && nNextStart < nNextEnd ? nNextStart : nNextEnd; - if (nMovePos <= nCurrentIndex) - nMovePos = pUnoCrsr->GetCntntNode()->Len(); - if(nEndPos >= 0 && nMovePos > nEndPos) - nMovePos = (USHORT)nEndPos; - - if(aBkmArr.size() && (*aBkmArr.begin())->getIndex() < nMovePos) - { - DBG_ASSERT((*aBkmArr.begin())->getIndex() > nCurrentIndex, - "forgotten bookmark(s)"); - nMovePos = (sal_uInt16)(*aBkmArr.begin())->getIndex(); - } - // break up portions for redlines - if (aRedArr.size() && (*aRedArr.begin())->getRealIndex() < nMovePos) + sal_Int32 nNextPos = + ((nNextStart > nCurrentIndex) && (nNextStart < nNextEnd)) + ? nNextStart : nNextEnd; + if (nNextPos > nCurrentIndex) { - nMovePos = (sal_uInt16)(*aRedArr.begin())->getRealIndex(); + o_rNextAttrPosition = nNextPos; } - // break up portions for soft page breaks - if (aBreakArr.size() && *aBreakArr.begin() < nMovePos) - { - nMovePos = *aBreakArr.begin(); - } - // break up if the destination is behind a frame - if(nFirstFrameIndex != STRING_MAXLEN && nMovePos > nFirstFrameIndex) - nMovePos = nFirstFrameIndex; + } + else + { + io_rbRightMoveForbidden = true; + } + return xRef; +} + +void lcl_MoveCursor( SwUnoCrsr* pUnoCrsr, + const xub_StrLen nCurrentIndex, + const sal_Int32 nNextFrameIndex, const sal_Int32 nNextPortionIndex, + const sal_Int32 nNextAttrIndex, const sal_Int32 nEndPos ) +{ + sal_Int32 nMovePos = pUnoCrsr->GetCntntNode()->Len(); + + if ((nEndPos >= 0) && (nEndPos < nMovePos)) + { + nMovePos = nEndPos; + } - if(nMovePos > nCurrentIndex) + if ((nNextFrameIndex >= 0) && (nNextFrameIndex < nMovePos)) + { + nMovePos = nNextFrameIndex; + } + + if ((nNextPortionIndex >= 0) && (nNextPortionIndex < nMovePos)) + { + nMovePos = nNextPortionIndex; + } + + if ((nNextAttrIndex >= 0) && (nNextAttrIndex < nMovePos)) + { + nMovePos = nNextAttrIndex; + } + + if (nMovePos > nCurrentIndex) + { // pUnoCrsr->Right(nMovePos - nCurrentIndex); - pUnoCrsr->GetPoint()->nContent = nMovePos; + pUnoCrsr->GetPoint()->nContent = static_cast<USHORT>(nMovePos); + } else if(nEndPos < 0 || nCurrentIndex < nEndPos) { // ensure proper exit: move to paragraph end @@ -696,8 +716,6 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, "may only happen at paragraph end"); pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); } - } - return xRef; } //----------------------------------------------------------------------------- @@ -757,8 +775,7 @@ void lcl_ExportRedline( { rPortionArr.Insert( new Reference< XTextRange >( new SwXRedlinePortion( - pPtr->pRedline, *pUnoCrsr, rParent, - pPtr->bStart)), + pPtr->pRedline, pUnoCrsr, rParent, pPtr->bStart)), rPortionArr.Count()); rRedlineArr.erase ( aIter++ ); } @@ -823,6 +840,7 @@ void SwXTextPortionEnumeration::CreatePortions() 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); } if(pUnoCrsr /*&& !bAtEnd*/) @@ -932,58 +950,34 @@ void SwXTextPortionEnumeration::CreatePortions() } if(!xRef.is()) { - lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr, nCurrentIndex, pUnoCrsr, xParent, aPortionArr); - if(pHints) + 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) { - xRef = lcl_ExportHints(pHints, - aPortionArr, - pUnoCrsr, - xParent, - nCurrentIndex, - ePortionType, - nFirstFrameIndex, - aBkmArr, - aRedArr, - aBreakArr, - nEndPos); + // N.B.: side-effects bRightMoveForbidden + // and nNextAttrIndex + xRef = lcl_ExportHints(pHints, aPortionArr, + pUnoCrsr, xParent, nCurrentIndex, ePortionType, + bRightMoveForbidden, nNextAttrIndex); } - else if(USHRT_MAX != nFirstFrameIndex) + if (!bRightMoveForbidden) { - pUnoCrsr->Right(nFirstFrameIndex - nCurrentIndex,CRSR_SKIP_CHARS,FALSE,FALSE); - } - else - { - sal_Int32 nNextIndex = lcl_GetNextIndex(aBkmArr, aRedArr, aBreakArr); - DBG_ASSERT( nNextIndex <= pCNd->Len(), "illegal next index" ); - if( nNextIndex > pCNd->Len() ) - { - nNextIndex = pCNd->Len(); - bAtEnd = sal_True; - } - if(nEndPos >= 0 && (nNextIndex > nEndPos || nNextIndex < 0)) - { - nNextIndex = nEndPos; - bAtEnd = sal_True; - } - if(nNextIndex < 0) - { - // a text portion should stay within it's paragraph (#i56165) - //sal_Bool bMove = pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); - pUnoCrsr->GetPoint()->nContent = pCNd->Len(); - bAtEnd = sal_True; - } - else - { - DBG_ASSERT(nNextIndex > nCurrentIndex || nNextIndex == nEndPos, - "wrong move index"); - pUnoCrsr->Right((sal_uInt16)(nNextIndex - nCurrentIndex),CRSR_SKIP_CHARS,FALSE,FALSE); - } + 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->GetMark()->nContent.GetIndex(); - xub_StrLen end=pUnoCrsr->GetPoint()->nContent.GetIndex(); + 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); @@ -1082,17 +1076,15 @@ void SwXTextPortionEnumeration::CreatePortions() 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, - STRING_MAXLEN, - aBkmArr, - aRedArr, - aBreakArr, - nEndPos); + bDummy, nDummy); if(xRef.is()) aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count()); } diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 120df01d0aa9..722235e3c391 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -3025,10 +3025,7 @@ void SAL_CALL SwXStyle::setAllPropertiesToDefault( ) // --> OD 2008-07-25 #i91928# // aFrmSz.SetWidth( LONG_MAX ); // aFrmSz.SetHeight( LONG_MAX ); - SvxPaper ePaper = SvxPaperInfo::GetDefaultSvxPaper( - static_cast<LanguageType>( GetAppLanguage() ) ); - const Size aPhysSize = SvxPaperInfo::GetPaperSize( ePaper ); - aFrmSz.SetSize( aPhysSize ); + aFrmSz.SetSize( SvxPaperInfo::GetDefaultPaperSize() ); // <-- } diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index e4aed674e7ae..20dde56ead7d 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -79,9 +79,7 @@ #include <com/sun/star/style/PageStyleLayout.hpp> #include <com/sun/star/style/BreakType.hpp> #include <com/sun/star/style/GraphicLocation.hpp> -#ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif #include <com/sun/star/chart/XChartDataChangeEventListener.hpp> #include <com/sun/star/chart/ChartDataChangeEvent.hpp> #include <com/sun/star/chart2/data/XDataSequence.hpp> @@ -1600,7 +1598,7 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt* pFmt, SwTableBox* pBox) : SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(aPos, sal_True); pUnoCrsr->Move( fnMoveForward, fnGoNode ); pUnoCrsr->Add(&aCrsrDepend); - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pTblCrsr->MakeBoxSels(); } /*-- 11.12.98 12:16:14--------------------------------------------------- @@ -1618,12 +1616,12 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt& rTableFmt, const SwTableCursor* *pUnoCrsr->GetMark() = *pTableSelection->GetMark(); } const SwSelBoxes& rBoxes = pTableSelection->GetBoxes(); - SwTableCursor* pTableCrsr = (SwTableCursor*) *pUnoCrsr; + SwTableCursor* pTableCrsr = dynamic_cast<SwTableCursor*>(pUnoCrsr); for(sal_uInt16 i = 0; i < rBoxes.Count(); i++) pTableCrsr->InsertBox( *rBoxes.GetObject(i) ); pUnoCrsr->Add(&aCrsrDepend); - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pTblCrsr->MakeBoxSels(); } /*-- 11.12.98 12:16:14--------------------------------------------------- @@ -1648,7 +1646,7 @@ OUString SwXTextTableCursor::getRangeName(void) throw( uno::RuntimeException ) //!! see also SwChartDataSequence::getSourceRangeRepresentation if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pTblCrsr->MakeBoxSels(); const SwStartNode* pNode = pTblCrsr->GetPoint()->nNode.GetNode().FindTableBoxStartNode(); const SwTable* pTable = SwTable::FindTable( GetFrmFmt() ); @@ -1689,7 +1687,7 @@ sal_Bool SwXTextTableCursor::gotoCellByName(const OUString& CellName, sal_Bool E SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); lcl_CrsrSelect( pTblCrsr, Expand ); String sCellName(CellName); bRet = pTblCrsr->GotoTblBox(sCellName); @@ -1706,7 +1704,7 @@ sal_Bool SwXTextTableCursor::goLeft(sal_Int16 Count, sal_Bool Expand) throw( uno SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); lcl_CrsrSelect( pTblCrsr, Expand ); bRet = pTblCrsr->Left( Count,CRSR_SKIP_CHARS, FALSE, FALSE); } @@ -1722,7 +1720,7 @@ sal_Bool SwXTextTableCursor::goRight(sal_Int16 Count, sal_Bool Expand) throw( un SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); lcl_CrsrSelect( pTblCrsr, Expand ); bRet = pTblCrsr->Right( Count, CRSR_SKIP_CHARS, FALSE, FALSE); } @@ -1738,7 +1736,7 @@ sal_Bool SwXTextTableCursor::goUp(sal_Int16 Count, sal_Bool Expand) throw( uno:: SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); lcl_CrsrSelect( pTblCrsr, Expand ); bRet = pTblCrsr->UpDown(sal_True, Count, 0, 0); } @@ -1754,7 +1752,7 @@ sal_Bool SwXTextTableCursor::goDown(sal_Int16 Count, sal_Bool Expand) throw( uno SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); lcl_CrsrSelect( pTblCrsr, Expand ); bRet = pTblCrsr->UpDown(sal_False, Count, 0, 0); } @@ -1769,7 +1767,7 @@ void SwXTextTableCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); lcl_CrsrSelect( pTblCrsr, Expand ); pTblCrsr->MoveTable(fnTableCurr, fnTableStart); } @@ -1783,7 +1781,7 @@ void SwXTextTableCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException ) SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); lcl_CrsrSelect( pTblCrsr, Expand ); pTblCrsr->MoveTable(fnTableCurr, fnTableEnd); } @@ -1802,7 +1800,7 @@ sal_Bool SwXTextTableCursor::mergeRange(void) throw( uno::RuntimeException ) // hier muessen die Actions aufgehoben werden UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc()); } - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pTblCrsr->MakeBoxSels(); { @@ -1835,7 +1833,7 @@ sal_Bool SwXTextTableCursor::splitRange(sal_Int16 Count, sal_Bool Horizontal) th // hier muessen die Actions aufgehoben werden UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc()); } - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pTblCrsr->MakeBoxSels(); { UnoActionContext aContext(pUnoCrsr->GetDoc()); @@ -1877,7 +1875,7 @@ void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, SwStartNode* pSttNode = pUnoCrsr->GetNode()->StartOfSectionNode(); const SwTableNode* pTblNode = pSttNode->FindTableNode(); lcl_FormatTable((SwFrmFmt*)pTblNode->GetTable().GetFrmFmt()); - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); if(pEntry) @@ -1936,7 +1934,7 @@ uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName) SwStartNode* pSttNode = pUnoCrsr->GetNode()->StartOfSectionNode(); const SwTableNode* pTblNode = pSttNode->FindTableNode(); lcl_FormatTable((SwFrmFmt*)pTblNode->GetTable().GetFrmFmt()); - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); if(pEntry) @@ -2648,7 +2646,7 @@ uno::Reference< table::XCellRange > SwXTextTable::GetRangeByName(SwFrmFmt* pFmt pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = *pUnoCrsr; + SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); // pUnoCrsr wird uebergeben und nicht geloescht SwXCellRange* pCellRange = new SwXCellRange(pUnoCrsr, *pFmt, rDesc); @@ -3322,7 +3320,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = *pUnoCrsr; + SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); SfxItemSet aSet(pDoc->GetAttrPool(), @@ -3517,7 +3515,7 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName) throw( be pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = *pUnoCrsr; + SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); SfxItemSet aSet(pDoc->GetAttrPool(), @@ -4011,7 +4009,7 @@ uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByPosition( pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = *pUnoCrsr; + SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); // pUnoCrsr wird uebergeben und nicht geloescht SwXCellRange* pCellRange = new SwXCellRange(pUnoCrsr, *pFmt, aNewDesc); @@ -4081,7 +4079,7 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, // remove actions to enable box selection UnoActionRemoveContext aRemoveContext(pDoc); } - SwUnoTableCrsr* pCrsr = *pTblCrsr; + SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr); pCrsr->MakeBoxSels(); switch(pEntry->nWID ) { @@ -4243,7 +4241,7 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName) throw( be RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, 0L); // erstmal die Attribute des Cursors - SwUnoTableCrsr* pCrsr = *pTblCrsr; + SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr); SwXTextCursor::GetCrsrAttr(pCrsr->GetSelRing(), aSet); m_pPropSet->getPropertyValue(*pEntry, aSet, aRet); } @@ -4459,7 +4457,7 @@ SwUnoCrsr * lcl_CreateCursor( SwFrmFmt &rTblFmt, pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pEndBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr *pCrsr = *pUnoCrsr; + SwUnoTableCrsr *pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); } return pUnoCrsr; @@ -4891,7 +4889,7 @@ void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rD if(pFmt && SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) { - SwUnoTableCrsr* pTableCrsr = *pTblCrsr; + SwUnoTableCrsr* pTableCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr); pTableCrsr->MakeBoxSels(); UnoActionContext aContext( pFmt->GetDoc() ); pFmt->GetDoc()->SortTbl(pTableCrsr->GetBoxes(), aSortOpt); @@ -5152,7 +5150,8 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount) throw( uno: pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pBLBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = *pUnoCrsr; + SwUnoTableCrsr* pCrsr = + dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); { // Die Klammer ist wichtig UnoActionContext aAction(pFrmFmt->GetDoc()); @@ -5384,7 +5383,8 @@ void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount) throw( u pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pTRBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = *pUnoCrsr; + SwUnoTableCrsr* pCrsr = + dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); { // Die Klammer ist wichtig UnoActionContext aAction(pFrmFmt->GetDoc()); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 7c921808b908..c00c21f5494e 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -35,9 +35,7 @@ #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/text/ControlCharacter.hpp> -#ifndef _CMDID_H #include <cmdid.h> -#endif #include <vos/mutex.hxx> #include <vcl/svapp.hxx> #include <rtl/uuid.h> @@ -544,96 +542,7 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang xTempRange = xRange; else xTempRange = xRange->getStart(); - SwXTextTable* pTable = reinterpret_cast< SwXTextTable * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXTextTable::getUnoTunnelId()) )); - - if(pTable) - pTable->attachToRange(xTempRange); - else - { - if(pBookmark) - pBookmark ->attachToRange(xTempRange); - else - { - if(pSection) - pSection ->attachToRange(xTempRange); - else - { - SwXFootnote* pFootnote = reinterpret_cast< SwXFootnote * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXFootnote::getUnoTunnelId()) )); - - if(pFootnote) - pFootnote->attachToRange(xTempRange); - else - { - if(pReferenceMark) - pReferenceMark->attachToRange(xTempRange); - else - { - SwXFrame* pFrame = reinterpret_cast< SwXFrame * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXFrame::getUnoTunnelId()) )); - - if(pFrame) - pFrame->attachToRange(xTempRange); - else - { - SwXDocumentIndex* pDocumentIndex = reinterpret_cast< SwXDocumentIndex * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXDocumentIndex::getUnoTunnelId()) )); - - if(pDocumentIndex) - pDocumentIndex->attachToRange(xTempRange); - else - { - if(pDocumentIndexMark) - pDocumentIndexMark->attachToRange(xTempRange); - else - { - SwXTextField* pTextField = reinterpret_cast< SwXTextField * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXTextField::getUnoTunnelId()) )); - - if(pTextField) - pTextField->attachToRange(xTempRange); - else - { - uno::Reference<beans::XPropertySet> xShapeProperties(xContent, uno::UNO_QUERY); - SwXShape* pShape = 0; - if(xShapeProperties.is()) - pShape = reinterpret_cast< SwXShape * >( - sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXShape::getUnoTunnelId()) )); - if(pShape) - { - uno::Any aPos(&xRange, - ::getCppuType((uno::Reference<text::XTextRange>*)0)); - pShape->setPropertyValue(C2U("TextRange"), aPos); - - uno::Reference<frame::XModel> xModel = - pDoc->GetDocShell()->GetBaseModel(); - uno::Reference<drawing::XDrawPageSupplier> xPageSupp( - xModel, uno::UNO_QUERY); - - uno::Reference<drawing::XDrawPage> xPage = xPageSupp->getDrawPage(); - - uno::Reference<drawing::XShape> xShape((cppu::OWeakObject*)pShape, - uno::UNO_QUERY); - //nuer die XShapes haengen an der Sw-Drawpage - uno::Reference<drawing::XShapes> xShps(xPage, uno::UNO_QUERY); - xShps->add(xShape); - } - else - { - lang::IllegalArgumentException aArgException; - aArgException.Message = C2U("unknown text content"); - throw aArgException; - } - } - } - } - } - } - } - } - } - } + xContent->attach(xTempRange); } else { @@ -1411,8 +1320,9 @@ uno::Reference< text::XTextRange > SwXText::finishOrAppendParagraph( throw aEx; } } - SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(*aPam.Start(), sal_False); - xRet = new SwXParagraph(this, pUnoCrsr); + SwTxtNode * pTxtNode( aPam.Start()->nNode.GetNode().GetTxtNode() ); + OSL_ENSURE(pTxtNode, "no SwTxtNode?"); + xRet = new SwXParagraph(this, pTxtNode); } return xRet; diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 740b06b39f7e..6775bf213736 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -36,9 +36,7 @@ #include <sfx2/printer.hxx> #include <sfx2/objsh.hxx> -#ifndef _INTN_HXX //autogen // #include <tools/intn.hxx> -#endif #include <sfx2/progress.hxx> #include <sfx2/app.hxx> #include <sfx2/prnmon.hxx> @@ -752,7 +750,7 @@ SwDoc * ViewShell::CreatePrtDoc( SfxPrinter* pPrt, SfxObjectShellRef &rDocShellR // Wir bauen uns ein neues Dokument SwDoc *pPrtDoc = new SwDoc; pPrtDoc->acquire(); - pPrtDoc->SetRefForDocShell( (SfxObjectShellRef*)&(long&)rDocShellRef ); + pPrtDoc->SetRefForDocShell( boost::addressof(rDocShellRef) ); pPrtDoc->LockExpFlds(); // Der Drucker wird uebernommen @@ -770,9 +768,11 @@ SwDoc * ViewShell::CreatePrtDoc( SfxPrinter* pPrt, SfxObjectShellRef &rDocShellR pPrtDoc->ReplaceStyles( *GetDoc() ); SwShellCrsr *pActCrsr = pFESh->_GetCrsr(); - SwShellCrsr *pFirstCrsr = (SwShellCrsr*)*((SwCursor*)pActCrsr->GetNext()); + SwShellCrsr *pFirstCrsr = dynamic_cast<SwShellCrsr*>(pActCrsr->GetNext()); if( !pActCrsr->HasMark() ) // bei Multiselektion kann der aktuelle Cursor leer sein - pActCrsr = (SwShellCrsr*)*((SwCursor*)pActCrsr->GetPrev()); + { + pActCrsr = dynamic_cast<SwShellCrsr*>(pActCrsr->GetPrev()); + } // Die Y-Position der ersten Selektion const Point aSelPoint = pFESh->IsTableMode() ? @@ -838,7 +838,7 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) // Wir bauen uns ein neues Dokument // SwDoc *pPrtDoc = new SwDoc; // pPrtDoc->acquire(); -// pPrtDoc->SetRefForDocShell( (SvEmbeddedObjectRef*)&(long&)rDocShellRef ); +// pPrtDoc->SetRefForDocShell( boost::addressof(rDocShellRef) ); pPrtDoc->LockExpFlds(); // Der Drucker wird uebernommen @@ -858,9 +858,11 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) pPrtDoc->ReplaceStyles( *GetDoc() ); SwShellCrsr *pActCrsr = pFESh->_GetCrsr(); - SwShellCrsr *pFirstCrsr = (SwShellCrsr*)*((SwCursor*)pActCrsr->GetNext()); + SwShellCrsr *pFirstCrsr = dynamic_cast<SwShellCrsr*>(pActCrsr->GetNext()); if( !pActCrsr->HasMark() ) // bei Multiselektion kann der aktuelle Cursor leer sein - pActCrsr = (SwShellCrsr*)*((SwCursor*)pActCrsr->GetPrev()); + { + pActCrsr = dynamic_cast<SwShellCrsr*>(pActCrsr->GetPrev()); + } // Die Y-Position der ersten Selektion // Die Y-Position der ersten Selektion @@ -1297,7 +1299,7 @@ BOOL ViewShell::Prt( SwPrtOptions& rOptions, SfxProgress* pProgress, aSize.Width() = aSize.Height(); aSize.Height() = nWidth; } - Paper ePaper = SvxPaperInfo::GetSvPaper(aSize,MAP_TWIP,TRUE); + Paper ePaper = SvxPaperInfo::GetSvxPaper(aSize,MAP_TWIP,TRUE); if ( PAPER_USER == ePaper ) pPrt->SetPaperSizeUser( aSize ); else diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index 14a197320a1a..aaa640de0ef4 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -882,8 +882,9 @@ ULONG SwWriter::Write( WriterRef& rxWriter, const String* pRealFileName ) { SwPageDesc aNew( rPgDsc ); SwFmtFrmSize aNewSz( rSz ); - aNewSz.SetHeight( lA4Height ); - aNewSz.SetWidth( lA4Width ); + Size a4(SvxPaperInfo::GetPaperSize( PAPER_A4 )); + aNewSz.SetHeight( a4.Width() ); + aNewSz.SetWidth( a4.Height() ); aNew.GetMaster().SetFmtAttr( aNewSz ); pOutDoc->ChgPageDesc( 0, aNew ); } diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx index 0049097a5178..7e3e088eb7d9 100644 --- a/sw/source/filter/html/htmlfld.cxx +++ b/sw/source/filter/html/htmlfld.cxx @@ -35,8 +35,6 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> -#include <com/sun/star/document/XDocumentInfo.hpp> -#include <com/sun/star/document/XDocumentInfoSupplier.hpp> #include "docsh.hxx" #include <svtools/htmltokn.h> @@ -487,16 +485,9 @@ void SwHTMLParser::NewField() if( nSub >= DI_INFO1 && nSub <= DI_INFO4 && aName.Len() == 0 ) { - // backward compatibility: map to names from document info - SfxObjectShell* pShell = pDoc->GetDocShell(); - DBG_ASSERT(pShell, "no object shell"); - if (pShell) { - uno::Reference<document::XDocumentInfoSupplier> xDIS( - pShell->GetModel(), uno::UNO_QUERY_THROW); - uno::Reference<document::XDocumentInfo> xDocInfo - = xDIS->getDocumentInfo(); - aName = xDocInfo->getUserFieldName(nSub - DI_INFO1); - } + // backward compatibility for OOo 2: + // map to names stored in AddMetaUserDefined + aName = m_InfoNames[nSub - DI_INFO1]; nSub = DI_CUSTOM; } diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx index 21589c4283c7..dd93a4e60b92 100644 --- a/sw/source/filter/html/htmlform.cxx +++ b/sw/source/filter/html/htmlform.cxx @@ -45,6 +45,7 @@ #include <svtools/htmlkywd.hxx> #include <svtools/htmltokn.h> #include <svtools/urihelper.hxx> +#include <sfx2/request.hxx> #include <sfx2/docfile.hxx> #ifndef _SFXAPP_HXX #include <sfx2/viewfrm.hxx> @@ -724,6 +725,12 @@ void SwHTMLParser::SetControlSize( const uno::Reference< drawing::XShape >& rSha SwDocShell *pDocSh = pDoc->GetDocShell(); if( pDocSh ) { + if ( pDocSh->GetMedium() ) + { + // if there is no hidden property in the MediaDescriptor it should be removed after loading + SFX_ITEMSET_ARG( pDocSh->GetMedium()->GetItemSet(), pHiddenItem, SfxBoolItem, SID_HIDDEN, sal_False ); + bRemoveHidden = ( pHiddenItem == NULL || !pHiddenItem->GetValue() ); + } pTempViewFrame = SfxViewFrame::CreateViewFrame( *pDocSh, 0, sal_True ); CallStartAction(); diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 70dbcb2d8949..aa42977d9a02 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -50,9 +50,7 @@ #include <svtools/ctrltool.hxx> #include <svtools/pathoptions.hxx> #include <vcl/svapp.hxx> -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <sfx2/fcontnr.hxx> #include <sfx2/docfile.hxx> @@ -99,9 +97,7 @@ #include <poolfmt.hxx> #include <pagedesc.hxx> #include <IMark.hxx> // fuer SwBookmark ... -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <editsh.hxx> // fuer Start/EndAction #include <docufld.hxx> #include <swcss1.hxx> @@ -334,6 +330,7 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn, bInFootEndNoteSymbol( FALSE ), // bIgnoreHTMLComments( bNoHTMLComments ) bIgnoreHTMLComments( bNoHTMLComments ), + bRemoveHidden( FALSE ), pTempViewFrame(0) { nEventId = 0; @@ -501,10 +498,17 @@ __EXPORT SwHTMLParser::~SwHTMLParser() { // keiner will mehr das Doc haben, also weg damit delete pDoc; + pDoc = NULL; } if ( pTempViewFrame ) + { pTempViewFrame->DoClose(); + + // the temporary view frame is hidden, so the hidden flag might need to be removed + if ( bRemoveHidden && pDoc && pDoc->GetDocShell() && pDoc->GetDocShell()->GetMedium() ) + pDoc->GetDocShell()->GetMedium()->GetItemSet()->ClearItem( SID_HIDDEN ); + } } IMPL_LINK( SwHTMLParser, AsyncCallback, void*, /*pVoid*/ ) @@ -1341,11 +1345,7 @@ void __EXPORT SwHTMLParser::NextToken( int nToken ) xDocProps = xDPS->getDocumentProperties(); DBG_ASSERT(xDocProps.is(), "DocumentProperties is null"); } - // always call ParseMetaOptions, it sets the encoding (#i96700#) - if (!ParseMetaOptions( xDocProps, pHTTPHeader ) && IsNewDoc()) - { - ParseMoreMetaOptions(); - } + ParseMetaOptions( xDocProps, pHTTPHeader ); } } break; @@ -2303,7 +2303,7 @@ BOOL SwHTMLParser::AppendTxtNode( SwHTMLAppendMode eMode, BOOL bUpdateNum ) SwpHints& rHints = pTxtNd->GetSwpHints(); for( sal_uInt16 i=0; i < nCntAttr; i++ ) { - SwTxtAttr *pHt = rHints.GetHt( i ); + SwTxtAttr *pHt = rHints.GetTextHint( i ); sal_uInt16 nWhich = pHt->Which(); sal_Int16 nIdx = -1; if( RES_CHRATR_CJK_FONT <= nWhich && @@ -2613,8 +2613,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, ( !pAttr->IsLikePara() && nEndParaIdx == rEndIdx.GetIndex() && pAttr->GetEndCnt() < nEndCnt && - RES_CHRATR_BEGIN <= nWhich && - RES_TXTATR_WITHEND_END > nWhich ) || + (isCHRATR(nWhich) || isTXTATR_WITHEND(nWhich)) ) || ( bBeforeTable && nEndParaIdx == rEndIdx.GetIndex() && !pAttr->GetEndCnt() ); @@ -2663,9 +2662,8 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, { // durch die elende Loescherei von Nodes kann auch mal // ein Index auf einen End-Node zeigen :-( - if( pAttr->GetSttPara() == pAttr->GetEndPara() && - (nWhich < RES_TXTATR_NOEND_BEGIN || - nWhich >= RES_TXTATR_NOEND_END) ) + if ( (pAttr->GetSttPara() == pAttr->GetEndPara()) && + !isTXTATR_NOEND(nWhich) ) { // wenn der End-Index auch auf den Node zeigt // brauchen wir auch kein Attribut mehr zu setzen, @@ -2696,9 +2694,8 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, pAttrPam->GetPoint()->nContent.Assign( pCNd, pAttr->nSttCntnt ); pAttrPam->SetMark(); - if( pAttr->GetSttPara() != pAttr->GetEndPara() && - (nWhich < RES_TXTATR_NOEND_BEGIN || - nWhich >= RES_TXTATR_NOEND_END) ) + if ( (pAttr->GetSttPara() != pAttr->GetEndPara()) && + !isTXTATR_NOEND(nWhich) ) { pCNd = pDoc->GetNodes()[ pAttr->nEndPara ]->GetCntntNode(); if( !pCNd ) @@ -2738,8 +2735,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, // muessen wir es im Node davor beenden oder wegschmeissen, // wenn es erst in dem Node beginnt if( nWhich != RES_BREAK && nWhich != RES_PAGEDESC && - (nWhich < RES_TXTATR_NOEND_BEGIN || - nWhich >= RES_TXTATR_NOEND_END) ) + !isTXTATR_NOEND(nWhich) ) { if( pAttrPam->GetMark()->nNode.GetIndex() != rEndIdx.GetIndex() ) @@ -5501,3 +5497,32 @@ void _HTMLAttr::InsertPrev( _HTMLAttr *pPrv ) pAttr->pPrev = pPrv; } + +bool SwHTMLParser::ParseMetaOptions( + const uno::Reference<document::XDocumentProperties> & i_xDocProps, + SvKeyValueIterator *i_pHeader ) +{ + // always call base ParseMetaOptions, it sets the encoding (#i96700#) + bool ret( HTMLParser::ParseMetaOptions(i_xDocProps, i_pHeader) ); + if (!ret && IsNewDoc()) + { + ParseMoreMetaOptions(); + } + return ret; +} + +// override so we can parse DOCINFO field subtypes INFO[1-4] +void SwHTMLParser::AddMetaUserDefined( ::rtl::OUString const & i_rMetaName ) +{ + // unless we already have 4 names, append the argument to m_InfoNames + ::rtl::OUString* pName // the first empty string in m_InfoNames + (!m_InfoNames[0].getLength() ? &m_InfoNames[0] : + (!m_InfoNames[1].getLength() ? &m_InfoNames[1] : + (!m_InfoNames[2].getLength() ? &m_InfoNames[2] : + (!m_InfoNames[3].getLength() ? &m_InfoNames[3] : 0 )))); + if (pName) + { + (*pName) = i_rMetaName; + } +} + diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx index 0ece396670d4..45349e626032 100644 --- a/sw/source/filter/html/swhtml.hxx +++ b/sw/source/filter/html/swhtml.hxx @@ -499,6 +499,10 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient sal_Bool bInFootEndNoteAnchor : 1; sal_Bool bInFootEndNoteSymbol : 1; sal_Bool bIgnoreHTMLComments : 1; + sal_Bool bRemoveHidden : 1; // the filter implementation might set the hidden flag + + /// the names corresponding to the DOCINFO field subtypes INFO[1-4] + ::rtl::OUString m_InfoNames[4]; SfxViewFrame* pTempViewFrame; @@ -925,6 +929,8 @@ protected: // wird das Dok geloescht, ist auch der Parser zu loeschen virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); + virtual void AddMetaUserDefined( ::rtl::OUString const & i_rMetaName ); + public: SwHTMLParser( SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn, @@ -941,6 +947,10 @@ public: // fuers asynchrone lesen aus dem SvStream virtual void Continue( int nToken ); + + virtual bool ParseMetaOptions( const ::com::sun::star::uno::Reference< + ::com::sun::star::document::XDocumentProperties>&, + SvKeyValueIterator* ); }; diff --git a/sw/source/filter/rtf/rtfatr.cxx b/sw/source/filter/rtf/rtfatr.cxx index 88dc0da19562..659515efaa09 100644 --- a/sw/source/filter/rtf/rtfatr.cxx +++ b/sw/source/filter/rtf/rtfatr.cxx @@ -1328,8 +1328,6 @@ static Writer& OutRTF_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) nChrCnt = nStrPos & 0xff00; } - HandleHyperlinks(rWrt, pNd->GetpSwpHints(), nStrPos); - if( nAttrPos < nCntAttr && *pHt->GetStart() == nStrPos && nStrPos != nEnde ) { @@ -1361,6 +1359,8 @@ static Writer& OutRTF_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) else aEndPosLst.OutScriptChange( nStrPos ); + HandleHyperlinks(rWrt, pNd->GetpSwpHints(), nStrPos); + if( rRTFWrt.bOutFmtAttr ) rRTFWrt.Strm() << ' '; diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 20d28499e796..09d43495f51f 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -118,6 +118,7 @@ #include <svx/xlnwtit.hxx> #include <svx/svdoutl.hxx> #include <svx/outlobj.hxx> +#include <svx/paperinf.hxx> #include <tools/stream.hxx> #include <basegfx/polygon/b2dpolygon.hxx> @@ -1649,7 +1650,8 @@ void fixKeepAndSplitAttributes(SwTableNode *pTableNode) SwTableLine* pSplitLine = rLns[ nLines-2 ]; SwTableBox* pSplitBox = pSplitLine->GetTabBoxes()[ 0 ]; SwNodeIndex aSplitIdx( *pSplitBox->GetSttNd() ); - pDoc->SplitTable( aSplitIdx, HEADLINE_NONE, !isTableKeep ); + pDoc->SplitTable( SwPosition(aSplitIdx), HEADLINE_NONE, + !isTableKeep ); SwTable& rSplitTable=aSplitIdx.GetNode().FindTableNode()->GetTable(); aSplitIdx-=2; pDoc->GetNodes().Delete(aSplitIdx); @@ -1667,7 +1669,7 @@ void fixKeepAndSplitAttributes(SwTableNode *pTableNode) if (isTableKeep) { SwNodeIndex aTmpIdx( *pBox->GetSttNd() ); - pDoc->SplitTable( aTmpIdx, HEADLINE_NONE, FALSE ); + pDoc->SplitTable( SwPosition(aTmpIdx), HEADLINE_NONE, FALSE ); SwTable& rSplitTable=aTmpIdx.GetNode().FindTableNode()->GetTable(); aTmpIdx-=2; pDoc->GetNodes().Delete(aTmpIdx); @@ -3295,7 +3297,8 @@ void SwRTFParser::ReadPageDescTbl() SvxULSpaceItem aUL( RES_UL_SPACE ), aHUL( RES_UL_SPACE ), aFUL( RES_UL_SPACE ); SvxLRSpaceItem aLR( RES_LR_SPACE ), aHLR( RES_LR_SPACE ), aFLR( RES_LR_SPACE ); - SwFmtFrmSize aSz( ATT_FIX_SIZE, 11905, 16837 ); // DIN A4 defaulten + Size a4 = SvxPaperInfo::GetPaperSize(PAPER_A4); + SwFmtFrmSize aSz( ATT_FIX_SIZE, a4.Width(), a4.Height() ); // DIN A4 defaulten SwFmtFrmSize aFSz( ATT_MIN_SIZE ), aHSz( ATT_MIN_SIZE ); SvxFrameDirectionItem aFrmDir(FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR); @@ -3358,8 +3361,7 @@ void SwRTFParser::ReadPageDescTbl() #ifndef CFRONT SETPAGEDESC_DEFAULTS: #endif - // aSz = pPgFmt->GetFrmSize(); - aSz.SetWidth( 11905 ); aSz.SetHeight( 16837 ); // DIN A4 defaulten + aSz.SetWidth( a4.Width() ); aSz.SetHeight( a4.Height() ); aLR.SetLeft( 0 ); aLR.SetRight( 0 ); aUL.SetLower( 0 ); aUL.SetUpper( 0 ); aHLR.SetLeft( 0 ); aHLR.SetRight( 0 ); @@ -3415,8 +3417,7 @@ void SwRTFParser::ReadPageDescTbl() aHUL.SetLower( 0 ); aHUL.SetUpper( 0 ); aFLR.SetLeft( 0 ); aFLR.SetRight( 0 ); aFUL.SetLower( 0 ); aFUL.SetUpper( 0 ); -// aSz = pPgFmt->GetFrmSize(); - aSz.SetWidth( 11905 ); aSz.SetHeight( 16837 ); // DIN A4 defaulten + aSz.SetWidth( a4.Width() ); aSz.SetHeight( a4.Height() ); // DIN A4 default nCols = USHRT_MAX; nColSpace = USHRT_MAX; nAktCol = 0; aFSz.SetHeightSizeType( ATT_MIN_SIZE ); aFSz.SetHeight( 0 ); aHSz.SetHeightSizeType( ATT_MIN_SIZE ); aHSz.SetHeight( 0 ); diff --git a/sw/source/filter/rtf/wrtrtf.cxx b/sw/source/filter/rtf/wrtrtf.cxx index c10528f112ee..d0129f29380f 100644 --- a/sw/source/filter/rtf/wrtrtf.cxx +++ b/sw/source/filter/rtf/wrtrtf.cxx @@ -440,8 +440,9 @@ void SwRTFWriter::MakeHeader() if( LONG_MAX == rSz.GetHeight() || LONG_MAX == rSz.GetWidth() ) { Strm() << OOO_STRING_SVTOOLS_RTF_PAPERH; - OutULong( lA4Height ) << OOO_STRING_SVTOOLS_RTF_PAPERW; - OutULong( lA4Width ); + Size a4 = SvxPaperInfo::GetPaperSize(PAPER_A4); + OutULong( a4.Height() ) << OOO_STRING_SVTOOLS_RTF_PAPERW; + OutULong( a4.Width() ); } else { diff --git a/sw/source/filter/ww8/dump/ww8scan.cxx b/sw/source/filter/ww8/dump/ww8scan.cxx index 21e18c2a32d7..9b90b721697a 100644 --- a/sw/source/filter/ww8/dump/ww8scan.cxx +++ b/sw/source/filter/ww8/dump/ww8scan.cxx @@ -6661,7 +6661,7 @@ SEPr::SEPr() : dttmPropRMark(0), dxtCharSpace(0), dyaLinePitch(0), clm(0), reserved1(0), dmOrientPage(0), iHeadingPgn(0), pgnStart(1), lnnMin(0), wTextFlow(0), reserved2(0), pgbApplyTo(0), pgbPageDepth(0), pgbOffsetFrom(0), - xaPage(12240), yaPage(15840), xaPageNUp(12240), yaPageNUp(15840), + xaPage(12242), yaPage(15842), xaPageNUp(12242), yaPageNUp(15842), dxaLeft(1800), dxaRight(1800), dyaTop(1440), dyaBottom(1440), dzaGutter(0), dyaHdrTop(720), dyaHdrBottom(720), ccolM1(0), fEvenlySpaced(1), reserved3(0), fBiDi(0), fFacingCol(0), fRTLGutter(0), fRTLAlignment(0), diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx index 7bd34acde6bf..17f854eaa1d6 100644 --- a/sw/source/filter/ww8/writerwordglue.cxx +++ b/sw/source/filter/ww8/writerwordglue.cxx @@ -69,23 +69,6 @@ namespace myImplHelpers { - class closeenough : public std::unary_function<long, bool> - { - private: - long mnValue; - long mnWriggleRoom; - public: - closeenough(long nValue, long nWriggleRoom) - : mnValue(nValue), mnWriggleRoom(nWriggleRoom) {} - bool operator()(long nTest) const - { - return ( - (mnValue - nTest < mnWriggleRoom) && - (mnValue - nTest > -mnWriggleRoom) - ); - } - }; - SwTwips CalcHdFtDist(const SwFrmFmt& rFmt, sal_uInt16 nSpacing) { /* @@ -400,38 +383,6 @@ namespace myImplHelpers namespace sw { - namespace types - { - long SnapPageDimension(long nSize) throw() - { - static const long aSizes[] = - { - lA0Width, lA0Height, lA1Width, lA2Width, lA3Width, lA4Width, - lA5Width, lB4Width, lB4Height, lB5Width, lB6Width, lC4Width, - lC4Height, lC5Width, lC6Width, lC65Width, lC65Height, lDLWidth, - lDLHeight, lJISB4Width, lJISB4Height, lJISB5Width, lJISB6Width, - lLetterWidth, lLetterHeight, lLegalHeight, lTabloidWidth, - lTabloidHeight, lDiaWidth, lDiaHeight, lScreenWidth, - lScreenHeight, lAWidth, lAHeight, lBHeight, lCHeight, lDHeight, - lEHeight, lExeWidth, lExeHeight, lLegal2Width, lLegal2Height, - lCom675Width, lCom675Height, lCom9Width, lCom9Height, - lCom10Width, lCom10Height, lCom11Width, lCom11Height, - lCom12Width, lMonarchHeight, lKai16Width, lKai16Height, - lKai32Width, lKai32BigWidth, lKai32BigHeight - }; - - const long nWriggleRoom = 5; - const long *pEnd = aSizes + sizeof(aSizes) / sizeof(aSizes[0]); - const long *pEntry = - std::find_if(aSizes, pEnd, myImplHelpers::closeenough(nSize, nWriggleRoom)); - - if (pEntry != pEnd) - nSize = *pEntry; - - return nSize; - } - } - namespace util { diff --git a/sw/source/filter/ww8/writerwordglue.hxx b/sw/source/filter/ww8/writerwordglue.hxx index e86cca7d3eec..4554e4869932 100644 --- a/sw/source/filter/ww8/writerwordglue.hxx +++ b/sw/source/filter/ww8/writerwordglue.hxx @@ -94,25 +94,6 @@ namespace sw { return ww::needed_cast<Ret, Param>(in); } - - - /** If a page dimension is close to a standard page size, snap to it. - - Commonly a page dimension is slightly different from a standard - page size, so close that its likely a rounding error after - creeping in. Use this to snap to standard sizes when within a - trivial distance from a standard size. - - @param - nSize the dimension to test against standard dimensions - - @return New dimension to use, equal to nSize unless within a - trivial amount of a standard page dimension - - @author - <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> - */ - long SnapPageDimension(long nSize) throw(); } namespace util diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index a6286ef52f76..828f56e2cb49 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -1137,11 +1137,11 @@ void WW8_SdrAttrIter::OutParaAttr(bool bCharAttr) if( nSlotId && nWhich != nSlotId && 0 != ( nWhich = pDstPool->GetWhich( nSlotId ) ) && nWhich != nSlotId && - 0 != ( pOut = aWW8AttrFnTab[ nWhich - RES_CHRATR_BEGIN ] ) - && ( bCharAttr ? ( nWhich >= RES_CHRATR_BEGIN + ( bCharAttr ? ( nWhich >= RES_CHRATR_BEGIN && nWhich < RES_TXTATR_END) : (nWhich >= RES_PARATR_BEGIN - && nWhich < RES_FRMATR_END) ) ) + && nWhich < RES_FRMATR_END) ) && + 0 != ( pOut = aWW8AttrFnTab[ nWhich - RES_CHRATR_BEGIN ] ) ) { // use always the SW-Which Id ! SfxPoolItem* pI = pItem->Clone(); diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 2d6f3b73f5a3..18d75d5826bf 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -1080,6 +1080,12 @@ void WW8_SwAttrIter::OutSwTOXMark(const SwTOXMark& rAttr, case TOX_INDEX: if( rAttr.GetPrimaryKey().Len() ) { + if ( rAttr.GetSecondaryKey( ).Len( ) ) + { + sTxt.Insert( ':', 0 ); + sTxt.Insert( rAttr.GetSecondaryKey(), 0 ); + } + sTxt.Insert( ':', 0 ); sTxt.Insert( rAttr.GetPrimaryKey(), 0 ); } diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 70c967d0ab9c..a28067b9367d 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -432,8 +432,14 @@ void WW8WrtStyle::BuildUpx(const SwFmt* pFmt, bool bPap, USHORT nPos, if( bPap ) SwWW8Writer::InsUInt16( *pO, nPos); // Style-Nummer + ASSERT(rWrt.pCurrentStyle==NULL, "Current style not NULL"); // set current style before calling out + rWrt.pCurrentStyle=pFmt; + rWrt.Out_SwFmt( *pFmt, bPap, !bPap ); + ASSERT(rWrt.pCurrentStyle!=pFmt, "current style was changed"); // reset current style... + rWrt.pCurrentStyle=NULL; + if( bInsDefCharSiz ) // nicht abgeleitet v. anderem Style Set1StyleDefaults( *pFmt, bPap ); diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index c77427c39c7f..99df3307254c 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -107,6 +107,13 @@ #include "dbgoutsw.hxx" +#include <sfx2/docfile.hxx> +#include <svtools/stritem.hxx> +#include <unotools/tempfile.hxx> +#include <svx/mscodec.hxx> +#include <osl/time.h> +#include <rtl/random.h> + using namespace sw::util; using namespace sw::types; @@ -645,6 +652,11 @@ bool WW8_WrPlcFld::Write(SwWW8Writer& rWrt) plc = &rWrt.pFib->lcbPlcffldEdn; break; + case TXT_ATN: + pfc = &rWrt.pFib->fcPlcffldAtn; + plc = &rWrt.pFib->lcbPlcffldAtn; + break; + case TXT_TXTBOX: pfc = &rWrt.pFib->fcPlcffldTxbx; plc = &rWrt.pFib->lcbPlcffldTxbx; @@ -2463,6 +2475,7 @@ void SwWW8Writer::WriteFkpPlcUsw() pFldHdFt->Write( *this ); // Fields ( Header/Footer ) pFldFtn->Write( *this ); // Fields ( FootNotes ) pFldEdn->Write( *this ); // Fields ( EndNotes ) + pFldAtn->Write( *this ); // Fields ( Annotations ) pBkmks->Write( *this ); // Bookmarks - sttbfBkmk/ // plcfBkmkf/plcfBkmkl WriteDop( *this ); // Document-Properties @@ -2498,6 +2511,7 @@ void SwWW8Writer::WriteFkpPlcUsw() pFldHdFt->Write( *this ); // Fields ( Header/Footer ) pFldFtn->Write( *this ); // Fields ( FootNotes ) pFldEdn->Write( *this ); // Fields ( EndNotes ) + pFldAtn->Write( *this ); // Fields ( Annotations ) pFldTxtBxs->Write( *this ); // Fields ( Textboxes ) pFldHFTxtBxs->Write( *this ); // Fields ( Head/Foot-Textboxes ) @@ -2680,6 +2694,28 @@ void SwWW8Writer::CollectOutlineBookmarks(const SwDoc &rDoc) } } +namespace +{ +#define WW_BLOCKSIZE 0x200 + + void EncryptRC4(svx::MSCodec_Std97& rCtx, SvStream &rIn, SvStream &rOut) + { + rIn.Seek(STREAM_SEEK_TO_END); + ULONG nLen = rIn.Tell(); + rIn.Seek(0); + + sal_uInt8 in[WW_BLOCKSIZE]; + for (ULONG nI = 0, nBlock = 0; nI < nLen; nI += WW_BLOCKSIZE, ++nBlock) + { + ULONG nBS = (nLen - nI > WW_BLOCKSIZE) ? WW_BLOCKSIZE : nLen - nI; + rIn.Read(in, nBS); + rCtx.InitCipher(nBlock); + rCtx.Encode(in, nBS, in, nBS); + rOut.Write(in, nBS); + } + } +} + ULONG SwWW8Writer::StoreDoc() { nCharFmtStart = ANZ_DEFAULT_STYLES; @@ -2701,6 +2737,7 @@ ULONG SwWW8Writer::StoreDoc() // <-- nStyleBeforeFly = nLastFmtId = 0; pStyAttr = 0; + pCurrentStyle = NULL; pOutFmtNode = 0; pEscher = 0; pRedlAuthors = 0; @@ -2777,6 +2814,41 @@ ULONG SwWW8Writer::StoreDoc() pStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); + String sUniPassword; + if ( mpMedium ) + { + SfxItemSet* pSet = mpMedium->GetItemSet(); + + const SfxPoolItem* pPasswordItem = NULL; + if ( pSet && SFX_ITEM_SET == pSet->GetItemState( SID_PASSWORD, sal_True, &pPasswordItem ) ) + if( pPasswordItem != NULL ) + sUniPassword = ( (const SfxStringItem*)pPasswordItem )->GetValue(); + } + + utl::TempFile aTempMain; + aTempMain.EnableKillingFile(); + utl::TempFile aTempTable; + aTempTable.EnableKillingFile(); + utl::TempFile aTempData; + aTempData.EnableKillingFile(); + + bool bEncrypt = false; + + xub_StrLen nLen = sUniPassword.Len(); + if ( nLen > 0 && nLen <= 15) // Password has been set + { + bEncrypt =true; + + pStrm = aTempMain.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE ); + + pTableStrm = aTempTable.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE ); + + pDataStrm = aTempData.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE ); + + sal_uInt8 aRC4EncryptionHeader[ 52 ] = {0}; + pTableStrm->Write( aRC4EncryptionHeader, 52 ); + } + const SwSectionFmt *pFmt=0; // Default: "Standard" pAktPageDesc = &const_cast<const SwDoc *>(pDoc)->GetPageDesc( 0 ); @@ -2842,6 +2914,7 @@ ULONG SwWW8Writer::StoreDoc() pFldHdFt = new WW8_WrPlcFld( 2, TXT_HDFT ); pFldFtn = new WW8_WrPlcFld( 2, TXT_FTN ); pFldEdn = new WW8_WrPlcFld( 2, TXT_EDN ); + pFldAtn = new WW8_WrPlcFld( 2, TXT_ATN ); pFldTxtBxs = new WW8_WrPlcFld( 2, TXT_TXTBOX ); pFldHFTxtBxs = new WW8_WrPlcFld( 2, TXT_HFTXTBOX ); @@ -2874,6 +2947,62 @@ ULONG SwWW8Writer::StoreDoc() StoreDoc1(); + if ( bEncrypt ) + { + // Generate random number with a seed of time as salt. + TimeValue aTime; + osl_getSystemTime( &aTime ); + rtlRandomPool aRandomPool = rtl_random_createPool (); + rtl_random_addBytes ( aRandomPool, &aTime, 8 ); + + sal_uInt8 aDocId[ 16 ] = {0}; + rtl_random_getBytes( aRandomPool, aDocId, 16 ); + + rtl_random_destroyPool( aRandomPool ); + + sal_Unicode aPassword[16] = {0}; + for (xub_StrLen nChar = 0; nChar < nLen; ++nChar ) + aPassword[nChar] = sUniPassword.GetChar(nChar); + + svx::MSCodec_Std97 aCtx; + aCtx.InitKey(aPassword, aDocId); + + SvStream *pStrmTemp, *pTableStrmTemp, *pDataStrmTemp; + pStrmTemp = &xWwStrm; + pTableStrmTemp = &xTableStrm; + pDataStrmTemp = &xDataStrm; + + if ( pDataStrmTemp && pDataStrmTemp != pStrmTemp) + EncryptRC4(aCtx, *pDataStrm, *pDataStrmTemp); + + EncryptRC4(aCtx, *pTableStrm, *pTableStrmTemp); + + // Write Unencrypted Header 52 bytes to the start of the table stream + // EncryptionVersionInfo (4 bytes): A Version structure where Version.vMajor MUST be 0x0001, and Version.vMinor MUST be 0x0001. + pTableStrmTemp->Seek( 0 ); + sal_uInt32 nEncType = 0x10001; + *pTableStrmTemp << nEncType; + + sal_uInt8 pSaltData[16] = {0}; + sal_uInt8 pSaltDigest[16] = {0}; + aCtx.GetEncryptKey( aDocId, pSaltData, pSaltDigest ); + + pTableStrmTemp->Write( aDocId, 16 ); + pTableStrmTemp->Write( pSaltData, 16 ); + pTableStrmTemp->Write( pSaltDigest, 16 ); + + EncryptRC4(aCtx, *pStrm, *pStrmTemp); + + // Write Unencrypted Fib 68 bytes to the start of the workdocument stream + pFib->fEncrypted = 1; // fEncrypted indicates the document is encrypted. + pFib->fObfuscated = 0; // Must be 0 for RC4. + pFib->nHash = 0x34; // encrypt header bytes count of table stream. + pFib->nKey = 0; // lkey2 must be 0 for RC4. + + pStrmTemp->Seek( 0 ); + pFib->WriteHeader( *pStrmTemp ); + } + if (nRedlineMode != pDoc->GetRedlineMode()) pDoc->SetRedlineMode((RedlineMode_t)(nRedlineMode)); @@ -2891,6 +3020,7 @@ ULONG SwWW8Writer::StoreDoc() DELETEZ( pFldFtn ); DELETEZ( pFldTxtBxs ); DELETEZ( pFldHFTxtBxs ); + DELETEZ( pFldAtn ); DELETEZ( pFldEdn ); DELETEZ( pFldHdFt ); DELETEZ( pFldMain ); @@ -3054,11 +3184,38 @@ ULONG SwWW8Writer::WriteMedium( SfxMedium& ) return WriteStorage(); } +ULONG SwWW8Writer::Write( SwPaM& rPaM, SfxMedium& rMed, + const String* pFileName ) +{ + mpMedium = &rMed; + ULONG nRet = StgWriter::Write( rPaM, rMed, pFileName ); + mpMedium = NULL; + return nRet; +} + +ULONG SwWW8Writer::Write( SwPaM& rPaM, const uno::Reference < embed::XStorage >& xStorage, const String* pFileName, SfxMedium* pMedium ) +{ + // this method was added to let the windows compiler be happy, otherwise it shows warning + return StgWriter::Write( rPaM, xStorage, pFileName, pMedium ); +} + +ULONG SwWW8Writer::Write( SwPaM& rPaM, SotStorage& rStorage, const String* pFileName ) +{ + // this method was added to let the windows compiler be happy, otherwise it shows warning + return StgWriter::Write( rPaM, rStorage, pFileName ); +} + +ULONG SwWW8Writer::Write( SwPaM& rPaM, SvStream& rStream, const String* pFileName ) +{ + // this method was added to let the solaris compiler be happy, otherwise it shows warning + return StgWriter::Write( rPaM, rStream, pFileName ); +} + SwWW8Writer::SwWW8Writer(const String& rFltName, const String& rBaseURL) : aMainStg(sMainStream), pISet(0), pUsedNumTbl(0), mpTopNodeOfHdFtPage(0), pBmpPal(0), pKeyMap(0), pOLEExp(0), pOCXExp(0), pOleMap(0), mpTableInfo(new ww8::WW8TableInfo()), nUniqueList(0), - mnHdFtIndex(0), pAktPageDesc(0), pPapPlc(0), pChpPlc(0), pChpIter(0), pO(0), + mnHdFtIndex(0), mpMedium(0), pAktPageDesc(0), pPapPlc(0), pChpPlc(0), pChpIter(0), pO(0), bHasHdr(false), bHasFtr(false) { SetBaseURL( rBaseURL ); @@ -3118,7 +3275,11 @@ void WW8_WrPlcFtnEdn::WritePlc( SwWW8Writer& rWrt ) const bool WW8_WrPlcPostIt::WriteTxt(SwWW8Writer& rWrt) { - return WriteGenericTxt( rWrt, TXT_ATN, rWrt.pFib->ccpAtn ); + bool bRet = WriteGenericTxt( rWrt, TXT_ATN, rWrt.pFib->ccpAtn ); + rWrt.pFldAtn->Finish( rWrt.Fc2Cp( rWrt.Strm().Tell() ), + rWrt.pFib->ccpText + rWrt.pFib->ccpFtn + + rWrt.pFib->ccpHdr ); + return bRet; } void WW8_WrPlcPostIt::WritePlc( SwWW8Writer& rWrt ) const diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index 87414259edbe..82af29567353 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -405,6 +405,8 @@ friend Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ); USHORT nUniqueList; // current number for creating unique list names unsigned int mnHdFtIndex; + SfxMedium* mpMedium; + virtual ULONG WriteStorage(); virtual ULONG WriteMedium( SfxMedium& ); @@ -473,6 +475,7 @@ public: WW8_WrPlcFld* pFldHdFt; // Felder in Header/Footer WW8_WrPlcFld* pFldFtn; // Felder in FootNotes WW8_WrPlcFld* pFldEdn; // Felder in EndNotes + WW8_WrPlcFld* pFldAtn; // Felder in Annotations WW8_WrPlcFld* pFldTxtBxs; // fields in textboxes WW8_WrPlcFld* pFldHFTxtBxs; // fields in header/footer textboxes WW8_WrMagicTable *pMagicTable; // keeps track of table cell positions, and @@ -482,6 +485,7 @@ public: SwWW8WrGrf* pGrf; const SwAttrSet* pStyAttr; // StyleAttr fuer Tabulatoren const SwModify* pOutFmtNode; // write Format or Node + const SwFmt *pCurrentStyle; // iff bStyDef=true, then this store the current style MainTxtPlcDrawObj *pSdrObjs; // Draw-/Fly-Objects HdFtPlcDrawObj *pHFSdrObjs; // Draw-/Fly-Objects in header or footer @@ -518,6 +522,10 @@ public: BYTE bHasFtr : 1; + virtual ULONG Write( SwPaM&, SfxMedium&, const String* = 0 ); + virtual ULONG Write( SwPaM&, const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String* = 0, SfxMedium* = 0 ); + virtual ULONG Write( SwPaM&, SotStorage&, const String* = 0 ); + virtual ULONG Write( SwPaM&, SvStream&, const String* = 0 ); SvxMSExportOLEObjects& GetOLEExp() { return *pOLEExp; } diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 1d608c1004fe..b3e13520a14d 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -77,9 +77,7 @@ #include <svx/shdditem.hxx> #include <svx/akrnitem.hxx> #include <svx/pbinitem.hxx> -#ifndef _SVX_EMPHITEM_HXX #include <svx/emphitem.hxx> -#endif #include <svx/twolinesitem.hxx> #include <svx/charscaleitem.hxx> #include <svx/charrotateitem.hxx> @@ -89,6 +87,7 @@ #include <svx/frmdiritem.hxx> #include <svx/blnkitem.hxx> #include <svx/charhiddenitem.hxx> +#include <svx/paperinf.hxx> #include <fmtfld.hxx> #include <fchrfmt.hxx> #include <fmtfsize.hxx> @@ -184,7 +183,7 @@ static Writer& OutWW8_SwNumRuleItem( Writer& rWrt, const SfxPoolItem& rHt ); /* Sadly word does not have two different sizes for asian font size and western -font size, it has to different fonts, but not sizes, so we have to use our +font size, it has two different fonts, but not sizes, so we have to use our guess as to the script used and disable the export of one type. The same occurs for font weight and posture (bold and italic) @@ -283,10 +282,10 @@ void SwWW8Writer::ExportPoolItemsToCHP(sw::PoolItems &rItems, USHORT nScript) { const SfxPoolItem *pItem = aI->second; USHORT nWhich = pItem->Which(); + if (!isCHRATR(nWhich) && !isTXTATR(nWhich)) + continue; if (FnAttrOut pOut = aWW8AttrFnTab[nWhich - RES_CHRATR_BEGIN]) { - if (nWhich < RES_CHRATR_BEGIN || nWhich >= RES_TXTATR_END) - continue; if (SwWW8Writer::CollapseScriptsforWordOk(nScript, nWhich)) (*pOut)(*this, *pItem); } @@ -344,17 +343,17 @@ void SwWW8Writer::Out_SfxItemSet(const SfxItemSet& rSet, bool bPapFmt, if (bChpFmt) ExportPoolItemsToCHP(aItems, nScript); - sw::cPoolItemIter aEnd = aItems.end(); - for (sw::cPoolItemIter aI = aItems.begin(); aI != aEnd; ++aI) + if (bPapFmt) { - pItem = aI->second; - USHORT nWhich = pItem->Which(); - pOut = aWW8AttrFnTab[nWhich - RES_CHRATR_BEGIN]; - if( 0 != pOut && (!bPapFmt || RES_PARATR_NUMRULE != nWhich )) + sw::cPoolItemIter aEnd = aItems.end(); + for (sw::cPoolItemIter aI = aItems.begin(); aI != aEnd; ++aI) { - bool bPap = nWhich >= RES_PARATR_BEGIN - && nWhich < RES_FRMATR_END; - if (bPapFmt && bPap) + pItem = aI->second; + USHORT nWhich = pItem->Which(); + if (nWhich < RES_PARATR_BEGIN || nWhich >= RES_FRMATR_END || nWhich == RES_PARATR_NUMRULE) + continue; + pOut = aWW8AttrFnTab[nWhich - RES_CHRATR_BEGIN]; + if( 0 != pOut ) (*pOut)(*this, *pItem); } } @@ -1770,6 +1769,9 @@ WW8_WrPlcFld* SwWW8Writer::CurrentFieldPlc() const case TXT_EDN: pFldP = pFldEdn; break; + case TXT_ATN: + pFldP = pFldAtn; + break; case TXT_TXTBOX: pFldP = pFldTxtBxs; break; @@ -3424,7 +3426,7 @@ static Writer& OutWW8_SwFrmSize( Writer& rWrt, const SfxPoolItem& rHt ) else rWW8Wrt.pO->Insert( 164, rWW8Wrt.pO->Count() ); rWW8Wrt.InsUInt16( - msword_cast<sal_uInt16>(SnapPageDimension(rSz.GetWidth()))); + msword_cast<sal_uInt16>(SvxPaperInfo::GetSloppyPaperDimension(rSz.GetWidth()))); /*sprmSYaPage*/ if( rWW8Wrt.bWrtWW8 ) @@ -3432,7 +3434,7 @@ static Writer& OutWW8_SwFrmSize( Writer& rWrt, const SfxPoolItem& rHt ) else rWW8Wrt.pO->Insert( 165, rWW8Wrt.pO->Count() ); rWW8Wrt.InsUInt16( - msword_cast<sal_uInt16>(SnapPageDimension(rSz.GetHeight()))); + msword_cast<sal_uInt16>(SvxPaperInfo::GetSloppyPaperDimension(rSz.GetHeight()))); } return rWrt; } @@ -4957,8 +4959,36 @@ static Writer& OutWW8_SwTabStop(Writer& rWrt, const SfxPoolItem& rHt) { SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; const SvxTabStopItem & rTStops = (const SvxTabStopItem&)rHt; - const SfxPoolItem* pLR = rWW8Wrt.HasItem( RES_LR_SPACE ); - long nCurrentLeft = pLR ? ((const SvxLRSpaceItem*)pLR)->GetTxtLeft() : 0; + bool bTabsRelativeToIndex = rWW8Wrt.pCurPam->GetDoc()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT); + long nCurrentLeft = 0; + + if (bTabsRelativeToIndex) + { + const SfxPoolItem* pLR = rWW8Wrt.HasItem( RES_LR_SPACE ); + + if (pLR != NULL) + nCurrentLeft = ((const SvxLRSpaceItem*)pLR)->GetTxtLeft(); + } + + + // --> FLR 2009-03-17 #i100264# + if (rWW8Wrt.bStyDef + && rWW8Wrt.pCurrentStyle!=NULL + && rWW8Wrt.pCurrentStyle->DerivedFrom()!=NULL) + { + SvxTabStopItem aTabs(0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP); + const SwFmt *pParentStyle=rWW8Wrt.pCurrentStyle->DerivedFrom(); + const SvxTabStopItem* pParentTabs=HasItem<SvxTabStopItem>(pParentStyle->GetAttrSet(), RES_PARATR_TABSTOP); + if (pParentTabs) + { + aTabs.Insert(pParentTabs); + } + + OutWW8_SwTabStopDelAdd(rWW8Wrt, aTabs, 0, rTStops, 0); + return rWrt; + } + // <-- + // StyleDef -> "einfach" eintragen || keine Style-Attrs -> dito const SvxTabStopItem* pStyleTabs = 0; @@ -4972,9 +5002,14 @@ static Writer& OutWW8_SwTabStop(Writer& rWrt, const SfxPoolItem& rHt) OutWW8_SwTabStopAdd(rWW8Wrt, rTStops, nCurrentLeft); else { - const SvxLRSpaceItem &rStyleLR = + long nStyleLeft = 0; + + if (bTabsRelativeToIndex) + { + const SvxLRSpaceItem &rStyleLR = ItemGet<SvxLRSpaceItem>(*rWW8Wrt.pStyAttr, RES_LR_SPACE); - long nStyleLeft = rStyleLR.GetTxtLeft(); + nStyleLeft = rStyleLR.GetTxtLeft(); + } OutWW8_SwTabStopDelAdd(rWW8Wrt, *pStyleTabs, nStyleLeft, rTStops, nCurrentLeft); diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx index 90bd25b489a3..81d605457e9c 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 ); + pD->Copy( aPam, aPos, false ); rBlocks.PutDoc(); } } @@ -258,92 +258,21 @@ bool WW8Glossary::Load( SwTextBlocks &rBlocks, bool bSaveRelFile ) bool WW8GlossaryFib::IsGlossaryFib() { - if (!nFibError) - { - INT16 nFibMin; - INT16 nFibMax; - switch(nVersion) - { - case 6: - nFibMin = 0x0065; // von 101 WinWord 6.0 - // 102 " - // und 103 WinWord 6.0 fuer Macintosh - // 104 " - nFibMax = 0x0069; // bis 105 WinWord 95 - break; - case 7: - nFibMin = 0x0069; // von 105 WinWord 95 - nFibMax = 0x0069; // bis 105 WinWord 95 - break; - case 8: - nFibMin = 0x006A; // von 106 WinWord 97 - nFibMax = 0x00c2; // bis 194 WinWord 2000 - break; - default: - nFibMin = 0; // Programm-Fehler! - nFibMax = 0; - nFib = nFibBack = 1; - break; - } - if ( (nFibBack < nFibMin) || (nFibBack > nFibMax) ) - nFibError = ERR_SWG_READ_ERROR; // Error melden - } - return !nFibError; + // fGlsy will indicate whether this has AutoText or not + return fGlsy; } -UINT32 WW8GlossaryFib::FindGlossaryFibOffset(SvStream &rTableStrm, - SvStream &rStrm, const WW8Fib &rFib) +UINT32 WW8GlossaryFib::FindGlossaryFibOffset(SvStream & /* rTableStrm */, + SvStream & /* rStrm */, + const WW8Fib &rFib) { - WW8PLCF aPlc( &rTableStrm, rFib.fcPlcfsed, rFib.lcbPlcfsed, 12 ); - WW8_CP start,ende; - void *pData; - aPlc.Get(start,ende,pData); - UINT32 nPo = SVBT32ToUInt32((BYTE *)pData+2); - //*pOut << hex << "Offset of last SEPX is " << nPo << endl; - - UINT16 nLen; - if (nPo != 0xFFFFFFFF) - { - rStrm.Seek(nPo); - rStrm >> nLen; - } - else - { - nPo=0; - nLen=0; - } - -// *pOut << hex << "Ends at " << nPo+len << endl; - nPo+=nLen; - UINT32 nEndLastPage; - if (nPo%512) + UINT32 nGlossaryFibOffset = 0; + if ( rFib.fDot ) // its a template { - nEndLastPage = (nPo)/512; - nEndLastPage = (nEndLastPage+1)*512; + if ( rFib.pnNext ) + nGlossaryFibOffset = ( rFib.pnNext * 512 ); } - else - nEndLastPage = nPo; - - //*pOut << hex << "SECOND FIB SHOULD BE FOUND at " << k << endl; - - WW8PLCF xcPLCF( &rTableStrm, rFib.fcPlcfbteChpx, - rFib.lcbPlcfbteChpx, (8 > rFib.nVersion) ? 2 : 4); - - xcPLCF.Get(start,ende,pData); - - nPo = SVBT32ToUInt32((BYTE *)pData); - //*pOut << hex << "Offset of last CHPX is " << (nPo+1) *512<< endl; - if (((nPo+1)*512) > nEndLastPage) nEndLastPage = (nPo+1)*512; - - WW8PLCF xpPLCF( &rTableStrm, rFib.fcPlcfbtePapx, - rFib.lcbPlcfbtePapx, (8 > rFib.nVersion) ? 2 : 4); - xpPLCF.Get(start,ende,pData); - nPo = SVBT32ToUInt32((BYTE *)pData); - //*pOut << hex << "Offset of last PAPX is " << nPo *512 << endl; - if (((nPo+1)*512) > nEndLastPage) nEndLastPage = (nPo+1)*512; - - //*pOut << hex << "SECOND FIB SHOULD BE FOUND at " << nEndLastPage << endl; - return nEndLastPage; + return nGlossaryFibOffset; } /* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index d19a0869b1b1..4948ac5eddae 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -2749,6 +2749,8 @@ SwFrmFmt* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp ) if ( bMoveToBackgrd ) aFlySet.Put(SvxOpaqueItem(RES_OPAQUE,false)); + String aObjName = pObject->GetName(); + SwFrmFmt* pRetFrmFmt = 0; if (bReplaceable) { @@ -2834,6 +2836,10 @@ SwFrmFmt* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp ) // <-- if (!IsInlineEscherHack()) MapWrapIntoFlyFmt(pRecord, pRetFrmFmt); + + // Set frame name with object name + if( aObjName.Len() ) + pRetFrmFmt->SetName( aObjName ); return AddAutoAnchor(pRetFrmFmt); } diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index b02ba42344eb..82682078e294 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -2220,39 +2220,60 @@ void SwWW8ImplReader::PostProcessAttrs() case they default to CP1252. If not then its perhaps that the font encoding is only in use for 6/7 and for 8+ if we are in 8bit mode then the encoding is always 1252. + + So a encoding converter that on an undefined character attempts to + convert from 1252 on the undefined character */ -sal_Unicode Custom8BitToUnicode(rtl_TextToUnicodeConverter hConverter, - sal_Char cChar) +sal_Size Custom8BitToUnicode(rtl_TextToUnicodeConverter hConverter, + sal_Char *pIn, sal_Size nInLen, sal_Unicode *pOut, sal_Size nOutLen) { const sal_uInt32 nFlags = + RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE | + RTL_TEXTTOUNICODE_FLAGS_FLUSH; + + const sal_uInt32 nFlags2 = RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE | RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE | RTL_TEXTTOUNICODE_FLAGS_FLUSH; - sal_Unicode nConvChar; - sal_uInt32 nInfo=0; - sal_Size nSrcBytes=0; - sal_Size nDestChars = rtl_convertTextToUnicode(hConverter, 0, - &cChar, 1, &nConvChar, 1, nFlags, &nInfo, &nSrcBytes ); + sal_Size nDestChars=0; + sal_Size nConverted=0; - if (nInfo & RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE) + do { - rtl_TextToUnicodeConverter hCP1252Converter = - rtl_createTextToUnicodeConverter(RTL_TEXTENCODING_MS_1252); - nDestChars = rtl_convertTextToUnicode(hCP1252Converter, 0, - &cChar, 1, &nConvChar, 1, nFlags, &nInfo, &nSrcBytes ); - rtl_destroyTextToUnicodeConverter(hCP1252Converter); - } + sal_uInt32 nInfo = 0; + sal_Size nThisConverted=0; - ASSERT(nDestChars == 1, "impossible to get more than 1 char"); + nDestChars += rtl_convertTextToUnicode(hConverter, 0, + pIn+nConverted, nInLen-nConverted, + pOut+nDestChars, nOutLen-nDestChars, + nFlags, &nInfo, &nThisConverted); - ASSERT(nInfo == 0, "A character conversion failed, gulp!"); + ASSERT(nInfo == 0, "A character conversion failed!"); - if (nDestChars == 1) - return nConvChar; - else - return cChar; + nConverted += nThisConverted; + + if ( + nInfo & RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR || + nInfo & RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR + ) + { + sal_Size nOtherConverted; + rtl_TextToUnicodeConverter hCP1252Converter = + rtl_createTextToUnicodeConverter(RTL_TEXTENCODING_MS_1252); + nDestChars += rtl_convertTextToUnicode(hCP1252Converter, 0, + pIn+nConverted, 1, + pOut+nDestChars, nOutLen-nDestChars, + nFlags2, &nInfo, &nOtherConverted); + rtl_destroyTextToUnicodeConverter(hCP1252Converter); + nConverted+=1; + } + } while (nConverted < nInLen); + + return nDestChars; } bool SwWW8ImplReader::LangUsesHindiNumbers(USHORT nLang) @@ -2318,12 +2339,18 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs) // (re)alloc UniString data String sPlainCharsBuf; - sal_Unicode* pWork = sPlainCharsBuf.AllocBuffer( nLen ); + sal_Unicode* pBuffer = sPlainCharsBuf.AllocBuffer( nLen ); + sal_Unicode* pWork = pBuffer; + + sal_Char* p8Bits = NULL; rtl_TextToUnicodeConverter hConverter = 0; if (!bIsUnicode || bVer67) hConverter = rtl_createTextToUnicodeConverter(eSrcCharSet); + if (!bIsUnicode) + p8Bits = new sal_Char[nLen]; + // read the stream data BYTE nBCode = 0; UINT16 nUCode; @@ -2354,7 +2381,6 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs) if ((32 > nUCode) || (0xa0 == nUCode)) { pStrm->SeekRel( bIsUnicode ? -2 : -1 ); - sPlainCharsBuf.ReleaseBufferAccess( nL2 ); break; // Sonderzeichen < 32, == 0xa0 gefunden } @@ -2375,21 +2401,28 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs) } else { - *pWork = Custom8BitToUnicode(hConverter, static_cast< sal_Char >(nUCode & 0x00FF)); + sal_Char cTest = static_cast< sal_Char >(nUCode & 0x00FF); + Custom8BitToUnicode(hConverter, &cTest, 1, pWork, 1); } } } else - *pWork = Custom8BitToUnicode(hConverter, nBCode); - - if (m_bRegardHindiDigits && bBidi && LangUsesHindiNumbers(nCTLLang)) - { - *pWork = TranslateToHindiNumbers(*pWork); - } + p8Bits[nL2] = nBCode; } if (nL2) { + xub_StrLen nEndUsed = nL2; + + if (!bIsUnicode) + nEndUsed = Custom8BitToUnicode(hConverter, p8Bits, nL2, pBuffer, nLen); + + for( xub_StrLen nI = 0; nI < nLen; ++nI, ++pBuffer ) + if (m_bRegardHindiDigits && bBidi && LangUsesHindiNumbers(nCTLLang)) + *pBuffer = TranslateToHindiNumbers(*pBuffer); + + sPlainCharsBuf.ReleaseBufferAccess( nEndUsed ); + AddTextToParagraph(sPlainCharsBuf); rPos += nL2; if (!maApos.back()) //a para end in apo doesn't count @@ -2398,6 +2431,7 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs) if (hConverter) rtl_destroyTextToUnicodeConverter(hConverter); + delete [] p8Bits; return nL2 >= nLen; } @@ -4312,6 +4346,13 @@ ULONG SwWW8ImplReader::LoadThroughDecryption(SwPaM& rPaM ,WW8Glossary *pGloss) DecryptRC4(aCtx, *pDataStream, aDecryptData); pDataStream = &aDecryptData; } + SfxMedium* pMedium = mpDocShell->GetMedium(); + if ( pMedium ) + { + SfxItemSet* pSet = pMedium->GetItemSet(); + if ( pSet ) + pSet->Put( SfxStringItem(SID_PASSWORD, sUniPassword) ); + } } } } @@ -4326,8 +4367,6 @@ ULONG SwWW8ImplReader::LoadThroughDecryption(SwPaM& rPaM ,WW8Glossary *pGloss) pWwFib = new WW8Fib(*pStrm, nWantedVersion); if (pWwFib->nFibError) nErrRet = ERR_SWG_READ_ERROR; - if(!nErrRet && mpDocShell->GetDoc()) - mpDocShell->GetDoc()->SetWinEncryption(true); } } diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index e636a47a66f0..ec81c82bbebd 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -81,6 +81,8 @@ #include <frmatr.hxx> +#include <iostream> + #define MAX_COL 64 // WW6-Beschreibung: 32, WW6-UI: 31 & WW8-UI: 63! using namespace ::com::sun::star; @@ -1399,14 +1401,34 @@ void WW8TabBandDesc::ProcessSprmTInsert(const BYTE* pParamsTInsert) if( nWwCols && pParamsTInsert ) // set one or more cell length(s) { BYTE nitcInsert = pParamsTInsert[0]; // position at which to insert + if (nitcInsert >= MAX_COL) // cannot insert into cell outside max possible index + return; BYTE nctc = pParamsTInsert[1]; // number of cells USHORT ndxaCol = SVBT16ToShort( pParamsTInsert+2 ); short nNewWwCols; if (nitcInsert > nWwCols) + { nNewWwCols = nitcInsert+nctc; + //if new count would be outside max possible count, clip it, and calc a new replacement + //legal nctc + if (nNewWwCols > MAX_COL) + { + nNewWwCols = MAX_COL; + nctc = ::sal::static_int_cast<BYTE>(nNewWwCols-nitcInsert); + } + } else + { nNewWwCols = nWwCols+nctc; + //if new count would be outside max possible count, clip it, and calc a new replacement + //legal nctc + if (nNewWwCols > MAX_COL) + { + nNewWwCols = MAX_COL; + nctc = ::sal::static_int_cast<BYTE>(nNewWwCols-nWwCols); + } + } WW8_TCell *pTC2s = new WW8_TCell[nNewWwCols]; setcelldefaults(pTC2s, nNewWwCols); @@ -1542,25 +1564,42 @@ void WW8TabBandDesc::ProcessSprmTDelete(const BYTE* pParamsTDelete) if( nWwCols && pParamsTDelete ) // set one or more cell length(s) { BYTE nitcFirst= pParamsTDelete[0]; // first col to be deleted + if (nitcFirst >= nWwCols) // first index to delete from doesn't exist + return; BYTE nitcLim = pParamsTDelete[1]; // (last col to be deleted)+1 + if (nitcLim <= nitcFirst) // second index to delete to is not greater than first index + return; - BYTE nShlCnt = static_cast< BYTE >(nWwCols - nitcLim); // count of cells to be shifted - + /* + * sprmTDelete causes any rgdxaCenter and rgtc entries whose index is + * greater than or equal to itcLim to be moved + */ + int nShlCnt = nWwCols - nitcLim; // count of cells to be shifted - WW8_TCell* pAktTC = pTCs + nitcFirst; - int i = 0; - for( ; i < nShlCnt; i++, ++pAktTC ) + if (nShlCnt >= 0) //There exist entries whose index is greater than or equal to itcLim { - // adjust the left x-position - nCenter[nitcFirst + i] = nCenter[nitcLim + i]; + WW8_TCell* pAktTC = pTCs + nitcFirst; + int i = 0; + while( i < nShlCnt ) + { + // adjust the left x-position + nCenter[nitcFirst + i] = nCenter[nitcLim + i]; + + // adjust the cell's borders + *pAktTC = pTCs[ nitcLim + i]; - // adjust the cell's borders - *pAktTC = pTCs[ nitcLim + i]; + ++i; + ++pAktTC; + } + // adjust the left x-position of the dummy at the very end + nCenter[nitcFirst + i] = nCenter[nitcLim + i]; } - // adjust the left x-position of the dummy at the very end - nCenter[nitcFirst + i] = nCenter[nitcLim + i]; - nWwCols -= (nitcLim - nitcFirst); + short nCellsDeleted = nitcLim - nitcFirst; + //clip delete request to available number of cells + if (nCellsDeleted > nWwCols) + nCellsDeleted = nWwCols; + nWwCols -= nCellsDeleted; } } @@ -2343,7 +2382,8 @@ void WW8TabDesc::CalcDefaults() } } */ - if (nMinLeft && ((!bIsBiDi && text::HoriOrientation::LEFT == eOri) || (bIsBiDi && text::HoriOrientation::RIGHT == eOri))) + if ((nMinLeft && !bIsBiDi && text::HoriOrientation::LEFT == eOri) || + (nMinLeft != -108 && bIsBiDi && text::HoriOrientation::RIGHT == eOri)) // Word sets the first nCenter value to -108 when no indent is used eOri = text::HoriOrientation::LEFT_AND_WIDTH; // absolutely positioned nDefaultSwCols = nMinCols; // da Zellen einfuegen billiger ist als Mergen @@ -2509,9 +2549,20 @@ void WW8TabDesc::CreateSwTable() //ability to set the margin. SvxLRSpaceItem aL( RES_LR_SPACE ); // set right to original DxaLeft (i28656) - aL.SetLeft( !bIsBiDi ? - static_cast<long>(GetMinLeft()) : - static_cast<long>(pIo->maSectionManager.GetTextAreaWidth() - nPreferredWidth - nOrgDxaLeft) ); + + long nLeft = 0; + if (!bIsBiDi) + nLeft = GetMinLeft(); + else + { + if (nPreferredWidth) + nLeft = pIo->maSectionManager.GetTextAreaWidth() - nPreferredWidth - nOrgDxaLeft; + else + nLeft = -GetMinLeft(); + } + + aL.SetLeft(nLeft); + aItemSet.Put(aL); } } diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index c9e1ceb28495..b6dbdbcfba7a 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -444,7 +444,7 @@ void wwSectionManager::SetPage(SwPageDesc &rInPageDesc, SwFrmFmt &rFmt, // 2. Papiergroesse SwFmtFrmSize aSz( rFmt.GetFrmSize() ); aSz.SetWidth(rSection.GetPageWidth()); - aSz.SetHeight(SnapPageDimension(rSection.GetPageHeight())); + aSz.SetHeight(SvxPaperInfo::GetSloppyPaperDimension(rSection.GetPageHeight())); rFmt.SetFmtAttr(aSz); rFmt.SetFmtAttr( @@ -788,8 +788,8 @@ void SwWW8ImplReader::HandleLineNumbering(const wwSection &rSection) wwSection::wwSection(const SwPosition &rPos) : maStart(rPos.nNode), mpSection(0), mpTitlePage(0), mpPage(0), meDir(FRMDIR_HORI_LEFT_TOP), - nPgWidth(lA4Width), nPgLeft(MM_250), nPgRight(MM_250), mnBorders(0), - mbHasFootnote(false) + nPgWidth(SvxPaperInfo::GetPaperSize(PAPER_A4).Width()), + nPgLeft(MM_250), nPgRight(MM_250), mnBorders(0), mbHasFootnote(false) { } @@ -1010,11 +1010,10 @@ void wwSectionManager::CreateSep(const long nTxtPos, bool /*bMustHaveBreak*/) aNewSection.maSep.dmOrientPage = ReadBSprm(pSep, pIds[0], 0); // 2. Papiergroesse - aNewSection.maSep.xaPage = ReadUSprm(pSep, pIds[1], (USHORT)lLetterWidth); + aNewSection.maSep.xaPage = ReadUSprm(pSep, pIds[1], lLetterWidth); + aNewSection.nPgWidth = SvxPaperInfo::GetSloppyPaperDimension(aNewSection.maSep.xaPage); - aNewSection.nPgWidth = SnapPageDimension(aNewSection.maSep.xaPage); - - aNewSection.maSep.yaPage = ReadUSprm(pSep, pIds[2], (USHORT)lLetterHeight); + aNewSection.maSep.yaPage = ReadUSprm(pSep, pIds[2], lLetterHeight); // 3. LR-Raender static const USHORT nLef[] = { MM_250, 1800 }; @@ -2308,14 +2307,12 @@ WW8DupProperties::WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStk) const SwFltStackEntry* pEntry = (*pCtrlStck)[ i ]; if(pEntry->bLocked) { - if (pEntry->pAttr->Which() > RES_CHRATR_BEGIN && - pEntry->pAttr->Which() < RES_CHRATR_END) + if (isCHRATR(pEntry->pAttr->Which())) { aChrSet.Put( *pEntry->pAttr ); } - else if (pEntry->pAttr->Which() > RES_PARATR_BEGIN && - pEntry->pAttr->Which() < RES_PARATR_END) + else if (isPARATR(pEntry->pAttr->Which())) { aParSet.Put( *pEntry->pAttr ); } diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 604af8ec6332..f3a4c3630e4c 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -5624,14 +5624,15 @@ WW8Fib::WW8Fib(BYTE nVer) // <-- #i90932# } -bool WW8Fib::Write(SvStream& rStrm) +bool WW8Fib::WriteHeader(SvStream& rStrm) { - BYTE *pDataPtr = new BYTE[ fcMin ]; - BYTE *pData = pDataPtr; - memset( pData, 0, fcMin ); - bool bVer8 = 8 == nVersion; + size_t nUnencryptedHdr = bVer8 ? 0x44 : 0x24; + BYTE *pDataPtr = new BYTE[ nUnencryptedHdr ]; + BYTE *pData = pDataPtr; + memset( pData, 0, nUnencryptedHdr ); + ULONG nPos = rStrm.Tell(); cbMac = rStrm.Seek( STREAM_SEEK_TO_END ); rStrm.Seek( nPos ); @@ -5652,6 +5653,7 @@ bool WW8Fib::Write(SvStream& rStrm) if( fWhichTblStm ) nBits16 |= 0x0200; if( fExtChar ) nBits16 |= 0x1000; if( fFarEast ) nBits16 |= 0x4000; // #i90932# + if( fObfuscated ) nBits16 |= 0x8000; Set_UInt16( pData, nBits16 ); Set_UInt16( pData, nFibBack ); @@ -5697,6 +5699,27 @@ bool WW8Fib::Write(SvStream& rStrm) // Marke: "rglw" Beginning of the array of longs Set_UInt32( pData, cbMac ); + rStrm.Write( pDataPtr, nUnencryptedHdr ); + delete[] pDataPtr; + return 0 == rStrm.GetError(); +} + +bool WW8Fib::Write(SvStream& rStrm) +{ + bool bVer8 = 8 == nVersion; + + WriteHeader( rStrm ); + + size_t nUnencryptedHdr = bVer8 ? 0x44 : 0x24; + + BYTE *pDataPtr = new BYTE[ fcMin - nUnencryptedHdr ]; + BYTE *pData = pDataPtr; + memset( pData, 0, fcMin - nUnencryptedHdr ); + + ULONG nPos = rStrm.Tell(); + cbMac = rStrm.Seek( STREAM_SEEK_TO_END ); + rStrm.Seek( nPos ); + // 2 Longs uebergehen, da unwichtiger Quatsch pData += 2 * sizeof( INT32); @@ -5905,7 +5928,7 @@ bool WW8Fib::Write(SvStream& rStrm) Set_UInt32( pData, 0); } - rStrm.Write( pDataPtr, fcMin ); + rStrm.Write( pDataPtr, fcMin - nUnencryptedHdr ); delete[] pDataPtr; return 0 == rStrm.GetError(); } @@ -7283,7 +7306,7 @@ SEPr::SEPr() : dttmPropRMark(0), dxtCharSpace(0), dyaLinePitch(0), clm(0), reserved1(0), dmOrientPage(0), iHeadingPgn(0), pgnStart(1), lnnMin(0), wTextFlow(0), reserved2(0), pgbApplyTo(0), pgbPageDepth(0), pgbOffsetFrom(0), - xaPage(12240), yaPage(15840), xaPageNUp(12240), yaPageNUp(15840), + xaPage(lLetterWidth), yaPage(lLetterHeight), xaPageNUp(lLetterWidth), yaPageNUp(lLetterHeight), dxaLeft(1800), dxaRight(1800), dyaTop(1440), dyaBottom(1440), dzaGutter(0), dyaHdrTop(720), dyaHdrBottom(720), ccolM1(0), fEvenlySpaced(1), reserved3(0), fBiDi(0), fFacingCol(0), fRTLGutter(0), fRTLAlignment(0), diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx index 58a0c5c82aaf..30bf841bdcdd 100644 --- a/sw/source/filter/ww8/ww8scan.hxx +++ b/sw/source/filter/ww8/ww8scan.hxx @@ -1040,6 +1040,7 @@ public: UINT16 fExtChar :1; // 1000 =1, when using extended character set in file UINT16 fFarEast :1; // 4000 =1, probably, when far-East language vaiants of Word is used to create a file #i90932# + UINT16 fObfuscated :1; // 8000=1. specifies whether the document is obfuscated using XOR obfuscation. otherwise this bit MUST be ignored. UINT16 nFibBack; // 0xc UINT16 nHash; // 0xe file encrypted hash @@ -1434,6 +1435,7 @@ public: /* leider falsch, man braucht auch noch einen fuer den Export */ WW8Fib( BYTE nVersion = 6 ); + bool WriteHeader(SvStream& rStrm); bool Write(SvStream& rStrm); static rtl_TextEncoding GetFIBCharset(UINT16 chs); ww::WordVersion GetFIBVersion() const; @@ -1766,6 +1768,11 @@ std::vector<BYTE> ChpxToSprms(const Word2CHPX &rChpx); ULONG SafeReadString(ByteString &rStr,USHORT nLen,SvStream &rStrm); +//MS has a (slightly) inaccurate view of how many twips +//are in the default letter size of a page +const USHORT lLetterWidth = 12242; +const USHORT lLetterHeight = 15842; + #endif /* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index 2536b9bf57e3..abe69df298d6 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -54,6 +54,7 @@ #include <com/sun/star/io/XActiveDataSource.hpp> #include <com/sun/star/packages/zip/ZipIOException.hpp> #include <com/sun/star/packages/WrongPasswordException.hpp> +#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> #include <svtools/svstdarr.hxx> #include <sfx2/docfile.hxx> #include <svtools/sfxecode.hxx> @@ -70,16 +71,12 @@ #include <errhdl.hxx> #include <fltini.hxx> #include <doc.hxx> -#ifndef _DOCSH_HXX //autogen wg. SwDoc #include <docsh.hxx> -#endif #include <unoobj.hxx> #include <swmodule.hxx> #include <SwXMLSectionList.hxx> -#ifndef _STATSTR_HRC #include <statstr.hrc> -#endif // --> OD 2005-09-06 #i44177# #include <SwStyleNameMapper.hxx> @@ -103,6 +100,8 @@ #include <istyleaccess.hxx> #define LOGFILE_AUTHOR "mb93740" +#include <sfx2/DocumentMetadataAccess.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -516,6 +515,7 @@ void lcl_ConvertSdrOle2ObjsToSdrGrafObjs( SwDoc& _rDoc ) } // <-- + ULONG XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const String & rName ) { // Get service factory @@ -810,23 +810,25 @@ ULONG XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const S xInfoSet->setPropertyValue( sPropName, makeAny( aBaseURL ) ); // TODO/LATER: separate links from usual embedded objects + ::rtl::OUString StreamPath; if( SFX_CREATE_MODE_EMBEDDED == rDoc.GetDocShell()->GetCreateMode() ) { - OUString aName; if ( pMedDescrMedium && pMedDescrMedium->GetItemSet() ) { const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>( pMedDescrMedium->GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) ); if ( pDocHierarchItem ) - aName = pDocHierarchItem->GetValue(); + StreamPath = pDocHierarchItem->GetValue(); } else - aName = ::rtl::OUString::createFromAscii( "dummyObjectName" ); + { + StreamPath = ::rtl::OUString::createFromAscii( "dummyObjectName" ); + } - if( aName.getLength() ) + if( StreamPath.getLength() ) { sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath")); - xInfoSet->setPropertyValue( sPropName, makeAny( aName ) ); + xInfoSet->setPropertyValue( sPropName, makeAny( StreamPath ) ); } } @@ -869,6 +871,38 @@ ULONG XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const S makeAny( bTextDocInOOoFileFormat ) ); } // <-- + + 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) + { + 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 went wrong? + } + } + catch (uno::Exception &) + { + nWarnRDF = WARN_SWG_FEATURES_LOST; // uhh... something went wrong? + } + sal_uInt32 nWarn = 0; sal_uInt32 nWarn2 = 0; // read storage streams @@ -924,13 +958,7 @@ ULONG XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const S else if ( rDoc.IsOLEPrtNotifyPending() ) rDoc.PrtOLENotify( TRUE ); - if( !nRet ) - { - if( nWarn ) - nRet = nWarn; - else if( nWarn2 ) - nRet = nWarn2; - } + nRet = nRet ? nRet : (nWarn ? nWarn : (nWarn2 ? nWarn2 : nWarnRDF ) ); aOpt.ResetAllFmtsOnly(); diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx index e944ad81aba7..09b7bdd8ed30 100644 --- a/sw/source/filter/xml/wrtxml.cxx +++ b/sw/source/filter/xml/wrtxml.cxx @@ -54,19 +54,18 @@ #include <pam.hxx> #include <doc.hxx> #include <docstat.hxx> -#ifndef _DOCSH_HXX //autogen wg. SwDoc #include <docsh.hxx> -#endif #include <unotools/ucbstreamhelper.hxx> #include <errhdl.hxx> #include <swerror.h> #include <wrtxml.hxx> -#ifndef _STATSTR_HRC #include <statstr.hrc> -#endif #include <rtl/logfile.hxx> +#include <comphelper/documentconstants.hxx> +#include <comphelper/makesequence.hxx> +#include <com/sun/star/rdf/XDocumentMetadataAccess.hpp> using ::rtl::OUString; using namespace ::com::sun::star; @@ -366,6 +365,35 @@ pGraphicHelper = SvXMLGraphicHelper::Create( xStg, sal_Bool bWarn = sal_False, bErr = sal_False; String sWarnFile, sErrFile; + // RDF metadata: export if ODF >= 1.2 + // N.B.: embedded documents have their own manifest.rdf! + if ( bOASIS ) + { + const uno::Reference<beans::XPropertySet> xPropSet(xStg, + uno::UNO_QUERY_THROW); + const ::rtl::OUString VersionProp( + ::rtl::OUString::createFromAscii("Version")); + try + { + ::rtl::OUString Version; + // ODF >= 1.2 + if ((xPropSet->getPropertyValue(VersionProp) >>= Version) + && !Version.equals(ODFVER_010_TEXT) + && !Version.equals(ODFVER_011_TEXT)) + { + const uno::Reference<rdf::XDocumentMetadataAccess> xDMA( + xModelComp, uno::UNO_QUERY_THROW); + xDMA->storeMetadataToStorage(xStg); + } + } + catch (beans::UnknownPropertyException &) + { /* ignore */ } + catch (uno::Exception &) + { + bWarn = sal_True; + } + } + sal_Bool bStoreMeta = ( SFX_CREATE_MODE_EMBEDDED != pDoc->GetDocShell()->GetCreateMode() ); if ( !bStoreMeta ) { diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index 6ae1bf52931c..a25bfbb45659 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -45,9 +45,7 @@ #include <xmloff/xmltkmap.hxx> #include <xmloff/nmspmap.hxx> -#ifndef _XMLOFF_FAMILIES_HXX #include <xmloff/families.hxx> -#endif #include <xmloff/xmluconv.hxx> #include <xmloff/i18nmap.hxx> #include <svx/protitem.hxx> @@ -98,6 +96,7 @@ enum SwXMLTableElemTokens enum SwXMLTableCellAttrTokens { + XML_TOK_TABLE_XMLID, XML_TOK_TABLE_STYLE_NAME, XML_TOK_TABLE_NUM_COLS_SPANNED, XML_TOK_TABLE_NUM_ROWS_SPANNED, @@ -137,6 +136,7 @@ static __FAR_DATA SvXMLTokenMapEntry aTableElemTokenMap[] = static __FAR_DATA SvXMLTokenMapEntry aTableCellAttrTokenMap[] = { + { XML_NAMESPACE_XML, XML_ID, XML_TOK_TABLE_XMLID }, { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_STYLE_NAME }, { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED, XML_TOK_TABLE_NUM_COLS_SPANNED }, { XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED, XML_TOK_TABLE_NUM_ROWS_SPANNED }, @@ -174,6 +174,8 @@ class SwXMLTableCell_Impl { OUString aStyleName; + OUString mXmlId; + OUString sFormula; // cell formula; valid if length > 0 double dValue; // formula value @@ -206,7 +208,8 @@ public: sal_Bool bHasValue = sal_False, sal_Bool mbCovered = sal_False, double dVal = 0.0, - sal_Bool mbTextValue = sal_False ); + sal_Bool mbTextValue = sal_False, + OUString const& i_rXmlId = OUString()); sal_Bool IsUsed() const { return pStartNode!=0 || xSubTable.Is() || bProtected;} @@ -221,6 +224,7 @@ public: sal_Bool IsProtected() const { return bProtected; } sal_Bool IsCovered() const { return mbCovered; } sal_Bool HasTextValue() const { return mbTextValue; } + const OUString& GetXmlId() const { return mXmlId; } const SwStartNode *GetStartNode() const { return pStartNode; } inline void SetStartNode( const SwStartNode *pSttNd ); @@ -239,7 +243,8 @@ inline void SwXMLTableCell_Impl::Set( const OUString& rStyleName, sal_Bool bHasVal, sal_Bool bCov, double dVal, - sal_Bool bTextVal ) + sal_Bool bTextVal, + OUString const& i_rXmlId ) { aStyleName = rStyleName; nRowSpan = nRSpan; @@ -252,6 +257,11 @@ inline void SwXMLTableCell_Impl::Set( const OUString& rStyleName, mbTextValue = bTextVal; bProtected = bProtect; + if (!mbCovered) // ensure uniqueness + { + mXmlId = i_rXmlId; + } + // set formula, if valid if (pFormula != NULL) { @@ -286,6 +296,7 @@ class SwXMLTableRow_Impl { OUString aStyleName; OUString aDfltCellStyleName; + OUString mXmlId; SwXMLTableCells_Impl aCells; @@ -294,13 +305,15 @@ class SwXMLTableRow_Impl public: SwXMLTableRow_Impl( const OUString& rStyleName, sal_uInt32 nCells, - const OUString *pDfltCellStyleName = 0 ); + const OUString *pDfltCellStyleName = 0, + const OUString& i_rXmlId = OUString() ); ~SwXMLTableRow_Impl() {} inline SwXMLTableCell_Impl *GetCell( sal_uInt32 nCol ) const; inline void Set( const OUString& rStyleName, - const OUString& rDfltCellStyleName ); + const OUString& rDfltCellStyleName, + const OUString& i_rXmlId ); void Expand( sal_uInt32 nCells, sal_Bool bOneCell ); @@ -309,14 +322,17 @@ public: const OUString& GetStyleName() const { return aStyleName; } const OUString& GetDefaultCellStyleName() const { return aDfltCellStyleName; } + const OUString& GetXmlId() const { return mXmlId; } void Dispose(); }; SwXMLTableRow_Impl::SwXMLTableRow_Impl( const OUString& rStyleName, sal_uInt32 nCells, - const OUString *pDfltCellStyleName ) : + const OUString *pDfltCellStyleName, + const OUString& i_rXmlId ) : aStyleName( rStyleName ), + mXmlId( i_rXmlId ), bSplitable( sal_False ) { if( pDfltCellStyleName ) @@ -365,10 +381,12 @@ void SwXMLTableRow_Impl::Expand( sal_uInt32 nCells, sal_Bool bOneCell ) } inline void SwXMLTableRow_Impl::Set( const OUString& rStyleName, - const OUString& rDfltCellStyleName ) + const OUString& rDfltCellStyleName, + const OUString& i_rXmlId ) { aStyleName = rStyleName; aDfltCellStyleName = rDfltCellStyleName; + mXmlId = i_rXmlId; } void SwXMLTableRow_Impl::Dispose() @@ -384,6 +402,7 @@ class SwXMLTableCellContext_Impl : public SvXMLImportContext OUString aStyleName; OUString sFormula; OUString sSaveParaDefault; + OUString mXmlId; SvXMLImportContextRef xMyTable; @@ -456,6 +475,9 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl( GetSwImport().GetTableCellAttrTokenMap(); switch( rTokenMap.Get( nPrefix, aLocalName ) ) { + case XML_TOK_TABLE_XMLID: + mXmlId = rValue; + break; case XML_TOK_TABLE_STYLE_NAME: aStyleName = rValue; GetImport().GetTextImport()->sCellParaStyleDefault = rValue; @@ -550,6 +572,7 @@ inline void SwXMLTableCellContext_Impl::_InsertContent() { GetTable()->InsertCell( aStyleName, nRowSpan, nColSpan, GetTable()->InsertTableSection(), + mXmlId, NULL, bProtect, &sFormula, bHasValue, fValue, bHasTextValue ); } @@ -569,7 +592,7 @@ inline void SwXMLTableCellContext_Impl::InsertContentIfNotThere() inline void SwXMLTableCellContext_Impl::InsertContent( SwXMLTableContext *pTable ) { - GetTable()->InsertCell( aStyleName, nRowSpan, nColSpan, 0, pTable, bProtect ); + GetTable()->InsertCell( aStyleName, nRowSpan, nColSpan, 0, mXmlId, pTable, bProtect ); bHasTableContent = sal_True; } @@ -580,11 +603,12 @@ SvXMLImportContext *SwXMLTableCellContext_Impl::CreateChildContext( { SvXMLImportContext *pContext = 0; + OUString sXmlId; sal_Bool bSubTable = sal_False; if( XML_NAMESPACE_TABLE == nPrefix && IsXMLToken( rLocalName, XML_TABLE ) ) { - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; for( sal_Int16 i=0; i < nAttrCount; i++ ) { const OUString& rAttrName = xAttrList->getNameByIndex( i ); @@ -596,7 +620,15 @@ SvXMLImportContext *SwXMLTableCellContext_Impl::CreateChildContext( if( XML_NAMESPACE_TABLE == nPrefix2 && IsXMLToken( aLocalName, XML_IS_SUB_TABLE ) && IsXMLToken( xAttrList->getValueByIndex( i ), XML_TRUE ) ) + { bSubTable = sal_True; + } + else if ( (XML_NAMESPACE_XML == nPrefix2) && + IsXMLToken( aLocalName, XML_ID ) ) + { + sXmlId = xAttrList->getValueByIndex( i ); + } +//FIXME: RDFa } } @@ -606,7 +638,7 @@ SvXMLImportContext *SwXMLTableCellContext_Impl::CreateChildContext( { SwXMLTableContext *pTblContext = new SwXMLTableContext( GetSwImport(), nPrefix, rLocalName, - xAttrList, GetTable() ); + xAttrList, GetTable(), sXmlId ); pContext = pTblContext; if( GetTable()->IsValid() ) InsertContent( pTblContext ); @@ -638,7 +670,7 @@ void SwXMLTableCellContext_Impl::EndElement() GetImport().GetTextImport()->DeleteParagraph(); if( nColRepeat > 1 && nColSpan == 1 ) { - // The original text is is invalid after deleting the last + // The original text is invalid after deleting the last // paragraph Reference < XTextCursor > xSrcTxtCursor = GetImport().GetTextImport()->GetText()->createTextCursor(); @@ -667,7 +699,7 @@ void SwXMLTableCellContext_Impl::EndElement() SwPaM aSrcPaM( *pSrcPaM->GetPoint(), *pSrcPaM->GetMark() ); SwPosition aDstPos( *pDstTxtCrsr->GetPaM()->GetPoint() ); - pDoc->Copy( aSrcPaM, aDstPos ); + pDoc->Copy( aSrcPaM, aDstPos, false ); nColRepeat--; } @@ -738,6 +770,12 @@ SwXMLTableColContext_Impl::SwXMLTableColContext_Impl( else if( IsXMLToken( aLocalName, XML_DEFAULT_CELL_STYLE_NAME ) ) aDfltCellStyleName = rValue; } + else if ( (XML_NAMESPACE_XML == nPrefix) && + IsXMLToken( aLocalName, XML_ID ) ) + { + (void) rValue; +//FIXME where to put this??? columns do not actually exist in writer... + } } sal_Int32 nWidth = MINLAY; @@ -870,6 +908,7 @@ SwXMLTableRowContext_Impl::SwXMLTableRowContext_Impl( SwXMLImport& rImport, nRowRepeat( 1 ) { OUString aStyleName, aDfltCellStyleName; + OUString sXmlId; sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; for( sal_Int16 i=0; i < nAttrCount; i++ ) @@ -898,9 +937,15 @@ SwXMLTableRowContext_Impl::SwXMLTableRowContext_Impl( SwXMLImport& rImport, aDfltCellStyleName = rValue; } } + else if ( (XML_NAMESPACE_XML == nPrefix) && + IsXMLToken( aLocalName, XML_ID ) ) + { + sXmlId = rValue; + } } if( GetTable()->IsValid() ) - GetTable()->InsertRow( aStyleName, aDfltCellStyleName, bInHead ); + GetTable()->InsertRow( aStyleName, aDfltCellStyleName, bInHead, + sXmlId ); } void SwXMLTableRowContext_Impl::EndElement() @@ -1269,6 +1314,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport, nWidth( 0UL ) { OUString aName; + OUString sXmlId; // this method will modify the document directly -> lock SolarMutex vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1292,6 +1338,11 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport, else if( IsXMLToken( aLocalName, XML_DEFAULT_CELL_STYLE_NAME ) ) aDfltCellStyleName = rValue; } + else if ( (XML_NAMESPACE_XML == nPrefix) && + IsXMLToken( aLocalName, XML_ID ) ) + { + sXmlId = rValue; + } } SwDoc *pDoc = SwImport::GetDocFromXMLImport( GetSwImport() ); @@ -1343,6 +1394,10 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport, if( xTable.is() ) { +//FIXME + // xml:id for RDF metadata + GetImport().SetXmlId(xTable, sXmlId); + Reference<XUnoTunnel> xTableTunnel( xTable, UNO_QUERY); if( xTableTunnel.is() ) { @@ -1381,8 +1436,10 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const Reference< xml::sax::XAttributeList > &, - SwXMLTableContext *pTable ) : + SwXMLTableContext *pTable, + OUString const & i_rXmlId ) : XMLTextTableContext( rImport, nPrfx, rLName ), + mXmlId( i_rXmlId ), pColumnDefaultCellStyleNames( 0 ), pRows( new SwXMLTableRows_Impl ), pTableNode( pTable->pTableNode ), @@ -1529,6 +1586,7 @@ OUString SwXMLTableContext::GetColumnDefaultCellStyleName( sal_uInt32 nCol ) con void SwXMLTableContext::InsertCell( const OUString& rStyleName, sal_uInt32 nRowSpan, sal_uInt32 nColSpan, const SwStartNode *pStartNode, + const OUString & i_rXmlId, SwXMLTableContext *pTable, sal_Bool bProtect, const OUString* pFormula, @@ -1629,7 +1687,8 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName, const bool bCovered = i != nColSpan || j != nRowSpan; GetCell( nRowsReq-j, nColsReq-i ) ->Set( sStyleName, j, i, pStartNode, - pTable, bProtect, pFormula, bHasValue, bCovered, fValue, bTextValue); + pTable, bProtect, pFormula, bHasValue, bCovered, fValue, + bTextValue, i_rXmlId ); } } @@ -1641,7 +1700,8 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName, void SwXMLTableContext::InsertRow( const OUString& rStyleName, const OUString& rDfltCellStyleName, - sal_Bool bInHead ) + sal_Bool bInHead, + const OUString & i_rXmlId ) { ASSERT( nCurRow < USHRT_MAX, "SwXMLTableContext::InsertRow: no space left" ); @@ -1656,13 +1716,14 @@ void SwXMLTableContext::InsertRow( const OUString& rStyleName, { // The current row has already been inserted because of a row span // of a previous row. - (*pRows)[(sal_uInt16)nCurRow]->Set( rStyleName, rDfltCellStyleName ); + (*pRows)[(sal_uInt16)nCurRow]->Set( + rStyleName, rDfltCellStyleName, i_rXmlId ); } else { // add a new row pRows->Insert( new SwXMLTableRow_Impl( rStyleName, GetColumnCount(), - &rDfltCellStyleName ), + &rDfltCellStyleName, i_rXmlId ), pRows->Count() ); } @@ -1692,7 +1753,9 @@ void SwXMLTableContext::InsertRepRows( sal_uInt32 nCount ) GetCell( nCurRow-1, nCurCol ); InsertCell( pSrcCell->GetStyleName(), 1U, pSrcCell->GetColSpan(), - InsertTableSection(), 0, pSrcCell->IsProtected(), + InsertTableSection(), + OUString(), + 0, pSrcCell->IsProtected(), &pSrcCell->GetFormula(), pSrcCell->HasValue(), pSrcCell->GetValue(), pSrcCell->HasTextValue() ); @@ -1892,6 +1955,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox( SwTableLine *pUpper, sal_uInt32 nBottomRow, sal_uInt32 nRightCol ) { +//FIXME: here would be a great place to handle XmlId for cell SwTableBox *pBox = new SwTableBox( pBoxFmt, 0, pUpper ); sal_uInt32 nColSpan = nRightCol - nLeftCol; @@ -1990,6 +2054,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox( sal_uInt32 /*nTopRow*/, sal_uInt32 nLeftCol, sal_uInt32 /*nBottomRow*/, sal_uInt32 nRightCol ) { +//FIXME: here would be a great place to handle XmlId for cell SwTableBox *pBox; sal_uInt32 nColSpan = nRightCol - nLeftCol; sal_Int32 nColWidth = GetColumnWidth( nLeftCol, nColSpan ); @@ -2151,6 +2216,7 @@ SwTableLine *SwXMLTableContext::MakeTableLine( SwTableBox *pUpper, sal_uInt32 nBottomRow, sal_uInt32 nRightCol ) { +//FIXME: here would be a great place to handle XmlId for row SwTableLine *pLine; if( !pUpper && 0UL==nTopRow ) { @@ -2618,6 +2684,17 @@ void SwXMLTableContext::MakeTable() // those don't need to be locked separately. vos::OGuard aGuard(Application::GetSolarMutex()); + // #i97274# handle invalid tables + if (!pRows || !pRows->Count() || !GetColumnCount()) + { + ASSERT(false, "invalid table: no cells; deleting..."); + pTableNode->GetDoc()->DeleteSection( pTableNode ); + pTableNode = 0; + pBox1 = 0; + pSttNd1 = 0; + return; + } + SwXMLImport& rSwImport = GetSwImport(); SwFrmFmt *pFrmFmt = pTableNode->GetTable().GetFrmFmt(); @@ -2742,7 +2819,7 @@ void SwXMLTableContext::MakeTable() if( bSetHoriOrient ) pFrmFmt->SetFmtAttr( SwFmtHoriOrient( 0, eHoriOrient ) ); - // This must be bahind the call to _MakeTable, because nWidth might be + // This must be after the call to _MakeTable, because nWidth might be // changed there. pFrmFmt->LockModify(); SwFmtFrmSize aSize( ATT_VAR_SIZE, nWidth ); @@ -2773,6 +2850,7 @@ void SwXMLTableContext::MakeTable() pTableNode->SetNewTable(pDDETable, FALSE); } + // ??? this is always false: root frame is only created in ViewShell::Init if( pTableNode->GetDoc()->GetRootFrm() ) { pTableNode->DelFrms(); @@ -2783,6 +2861,7 @@ void SwXMLTableContext::MakeTable() void SwXMLTableContext::MakeTable( SwTableBox *pBox, sal_Int32 nW ) { +//FIXME: here would be a great place to handle XmlId for subtable pLineFmt = GetParentTable()->pLineFmt; pBoxFmt = GetParentTable()->pBoxFmt; nWidth = nW; diff --git a/sw/source/filter/xml/xmltbli.hxx b/sw/source/filter/xml/xmltbli.hxx index 6cbef964a324..b9f903ba14a9 100644 --- a/sw/source/filter/xml/xmltbli.hxx +++ b/sw/source/filter/xml/xmltbli.hxx @@ -31,9 +31,7 @@ #ifndef _XMLTBLI_HXX #define _XMLTBLI_HXX -#ifndef _XMLOFF_XMLTEXTTABLECONTEXT_HXX #include <xmloff/XMLTextTableContext.hxx> -#endif // STL include #include <hash_map> @@ -69,6 +67,8 @@ class SwXMLTableContext : public XMLTextTableContext { ::rtl::OUString aStyleName; ::rtl::OUString aDfltCellStyleName; + /// NB: this contains the xml:id only if this table is a subtable! + ::rtl::OUString mXmlId; SvUShorts aColumnWidths; SvBools aColumnRelWidths; @@ -154,7 +154,8 @@ public: const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList, - SwXMLTableContext *pTable ); + SwXMLTableContext *pTable, + const ::rtl::OUString& i_rXmlId ); virtual ~SwXMLTableContext(); @@ -180,6 +181,7 @@ public: void InsertCell( const ::rtl::OUString& rStyleName, sal_uInt32 nRowSpan=1U, sal_uInt32 nColSpan=1U, const SwStartNode *pStNd=0, + const ::rtl::OUString & i_rXmlId = ::rtl::OUString(), SwXMLTableContext *pTable=0, sal_Bool bIsProtected = sal_False, const ::rtl::OUString *pFormula=0, @@ -188,7 +190,8 @@ public: sal_Bool bTextValue = sal_False ); void InsertRow( const ::rtl::OUString& rStyleName, const ::rtl::OUString& rDfltCellStyleName, - sal_Bool bInHead ); + sal_Bool bInHead, + const ::rtl::OUString & i_rXmlId = ::rtl::OUString() ); void FinishRow(); void InsertRepRows( sal_uInt32 nCount ); SwXMLTableCell_Impl *GetCell( sal_uInt32 nRow, sal_uInt32 nCol ) const; diff --git a/sw/source/ui/app/appenv.cxx b/sw/source/ui/app/appenv.cxx index b7591ad2ba37..7f3acf375b35 100644 --- a/sw/source/ui/app/appenv.cxx +++ b/sw/source/ui/app/appenv.cxx @@ -395,10 +395,7 @@ static USHORT nTitleNo = 0; Size aPaperSize = pPrt->PixelToLogic( pPrt->GetPaperSizePixel(), MAP_TWIP); if ( !aPaperSize.Width() && !aPaperSize.Height() ) - { - aPaperSize.Width() = lA4Width; - aPaperSize.Height()= lA4Height; - } + aPaperSize = SvxPaperInfo::GetPaperSize(PAPER_A4); if ( aPaperSize.Width() > aPaperSize.Height() ) Swap( aPaperSize ); diff --git a/sw/source/ui/app/apphdl.cxx b/sw/source/ui/app/apphdl.cxx index 8f9a6b8eb71d..7fe0d349e8a7 100644 --- a/sw/source/ui/app/apphdl.cxx +++ b/sw/source/ui/app/apphdl.cxx @@ -57,12 +57,8 @@ #include <svtools/stritem.hxx> #include <svtools/ctloptions.hxx> #include <svtools/useroptions.hxx> -#ifndef _VCL_MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif -#ifndef _VCL_WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <svx/insctrl.hxx> #include <svx/selctrl.hxx> #include <com/sun/star/document/UpdateDocMode.hpp> @@ -73,46 +69,32 @@ #include <sfx2/objface.hxx> #include <sfx2/app.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <pview.hxx> -#ifndef _SRCVIEW_HXX #include <srcview.hxx> -#endif #include <wrtsh.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #ifndef _CMDID_H #include <cmdid.h> // Funktion-Ids #endif #include <initui.hxx> #include <uitool.hxx> #include <swmodule.hxx> -#ifndef _WDOCSH_HXX #include <wdocsh.hxx> -#endif -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <usrpref.hxx> #include <gloslst.hxx> // SwGlossaryList #include <glosdoc.hxx> // SwGlossaryList #include <doc.hxx> #include <cfgitems.hxx> #include <prtopt.hxx> -#ifndef _MODCFG_HXX #include <modcfg.hxx> -#endif #include <globals.h> // globale Konstanten z.B. #ifndef _APP_HRC #include <app.hrc> #endif #include <fontcfg.hxx> -#ifndef _BARCFG_HXX #include <barcfg.hxx> -#endif #include <uinums.hxx> #include <dbconfig.hxx> #include <mmconfigitem.hxx> @@ -155,7 +137,7 @@ using namespace ::com::sun::star; #define PrintSettings #define _ExecAddress ExecOther #define _StateAddress StateOther -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include <svx/svxslots.hxx> #include "swslots.hxx" #include <cfgid.h> diff --git a/sw/source/ui/app/appopt.cxx b/sw/source/ui/app/appopt.cxx index da681b63b077..4a4de8b648b9 100644 --- a/sw/source/ui/app/appopt.cxx +++ b/sw/source/ui/app/appopt.cxx @@ -201,6 +201,9 @@ SfxItemSet* SwModule::CreateItemSet( USHORT nId ) aLang >>= aLocale; pRet->Put(SvxLanguageItem(SvxLocaleToLanguage( aLocale ), SID_ATTR_CHAR_CJK_LANGUAGE)); + aLang = aLinguCfg.GetProperty(C2U("DefaultLocale_CTL")); + aLang >>= aLocale; + pRet->Put(SvxLanguageItem(SvxLocaleToLanguage( aLocale ), SID_ATTR_CHAR_CTL_LANGUAGE)); } if(bTextDialog) pRet->Put(SwPtrItem(FN_PARAM_STDFONTS, GetStdFontConfig())); diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx index 498c10133954..dd5ecb185c2d 100644 --- a/sw/source/ui/app/docsh.cxx +++ b/sw/source/ui/app/docsh.cxx @@ -30,17 +30,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> #include <rtl/logfile.hxx> -#ifndef _MSGBOX_HXX #include <vcl/msgbox.hxx> -#endif -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <vcl/jobset.hxx> #include <tools/urlobj.hxx> #include <svtools/whiter.hxx> @@ -53,9 +48,7 @@ #include <sfx2/app.hxx> #include <sfx2/request.hxx> #include <svtools/misccfg.hxx> -#ifndef _PASSWD_HXX #include <sfx2/passwd.hxx> -#endif #include <sfx2/bindings.hxx> #include <sfx2/docfile.hxx> #include <sfx2/evntconf.hxx> @@ -70,9 +63,7 @@ #include <sot/clsids.hxx> #include <basic/basmgr.hxx> #include <basic/sbmod.hxx> -//#ifndef _SB_SBJSMOD_HXX //autogen //#include <basic/sbjsmod.hxx> -//#endif #include <swevent.hxx> #include <fmtpdsc.hxx> #include <fmtfsize.hxx> @@ -81,41 +72,27 @@ #include <swwait.hxx> #include <swprtopt.hxx> #include <frmatr.hxx> -#ifndef _VIEW_HXX #include <view.hxx> // fuer die aktuelle Sicht -#endif #include <edtwin.hxx> #include <PostItMgr.hxx> #include <postit.hxx> #include <wrtsh.hxx> // Verbindung zur Core -#ifndef _DOCSH_HXX #include <docsh.hxx> // Dokumenterzeugung -#endif -#ifndef _BASESH_HXX #include <basesh.hxx> -#endif #include <viewopt.hxx> -#ifndef _WDOCSH_HXX #include <wdocsh.hxx> -#endif #include <swmodule.hxx> -#ifndef _GLOBDOC_HXX #include <globdoc.hxx> -#endif #include <usrpref.hxx> #include <shellio.hxx> // I/O #include <docstyle.hxx> #include <doc.hxx> #include <docstat.hxx> #include <pagedesc.hxx> -#ifndef _PVIEW_HXX #include <pview.hxx> -#endif #include <mdiexp.hxx> #include <swbaslnk.hxx> -#ifndef _SRCVIEW_HXX #include <srcview.hxx> -#endif #include <ndindex.hxx> #include <ndole.hxx> #include <swcli.hxx> @@ -127,18 +104,10 @@ #include <docary.hxx> // <-- #include <swerror.h> // Fehlermeldungen -#ifndef _HELPID_H #include <helpid.h> -#endif -#ifndef _CMDID_H -#include <cmdid.h> // -#endif -#ifndef _GLOBALS_HRC +#include <cmdid.h> #include <globals.hrc> -#endif -#ifndef _APP_HRC #include <app.hrc> -#endif #include "warnpassword.hxx" #include <cfgid.h> @@ -150,12 +119,8 @@ #include <comphelper/storagehelper.hxx> #define SwDocShell -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif #include <com/sun/star/document/UpdateDocMode.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> @@ -163,6 +128,9 @@ #include <unomid.h> +#include <sfx2/Metadatable.hxx> + + using rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -336,7 +304,7 @@ BOOL SwDocShell::ConvertFrom( SfxMedium& rMedium ) SW_MOD()->SetEmbeddedLoadSave( FALSE ); - SetError( nErr ); + SetError( nErr, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); BOOL bOk = !IsError( nErr ); // --> OD 2006-11-07 #i59688# @@ -443,7 +411,7 @@ BOOL SwDocShell::Save() } SW_MOD()->SetEmbeddedLoadSave( FALSE ); } - SetError( nErr ? nErr : nVBWarning ); + SetError( nErr ? nErr : nVBWarning, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); SfxViewFrame* pFrm = pWrtShell ? pWrtShell->GetView().GetViewFrame() : 0; if( pFrm ) @@ -578,7 +546,7 @@ sal_Bool SwDocShell::SaveAs( SfxMedium& rMedium ) SW_MOD()->SetEmbeddedLoadSave( FALSE ); } - SetError( nErr ? nErr : nVBWarning ); + SetError( nErr ? nErr : nVBWarning, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); return !IsError( nErr ); } @@ -610,17 +578,6 @@ BOOL SwDocShell::ConvertTo( SfxMedium& rMedium ) return FALSE; } - // if the imported word document is password protected - warn the user - // about saving it without the password. - if(pDoc->IsWinEncrypted()) - { - if(!SwWarnPassword::WarningOnPassword( rMedium )) - { - SetError(ERRCODE_ABORT); - return FALSE; - } - } - //#i3370# remove quick help to prevent saving of autocorrection suggestions if(pView) pView->GetEditWin().StopQuickHelp(); @@ -672,7 +629,7 @@ BOOL SwDocShell::ConvertTo( SfxMedium& rMedium ) Sequence<rtl::OUString> aModNames = xLib->getElementNames(); if(aModNames.getLength()) { - SetError(WARN_SWG_HTML_NO_MACROS); + SetError(WARN_SWG_HTML_NO_MACROS, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); break; } } @@ -844,7 +801,7 @@ BOOL SwDocShell::ConvertTo( SfxMedium& rMedium ) } SW_MOD()->SetEmbeddedLoadSave( FALSE ); - SetError( nErrno ? nErrno : nVBWarning ); + SetError( nErrno ? nErrno : nVBWarning, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); if( !rMedium.IsStorage() ) rMedium.CloseOutStream(); @@ -1416,4 +1373,8 @@ BOOL SwTmpPersist::SaveCompleted( SvStorage * pStor ) return FALSE; } */ +const ::sfx2::IXmlIdRegistry* SwDocShell::GetXmlIdRegistry() const +{ + return pDoc ? &pDoc->GetXmlIdRegistry() : 0; +} diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index 40265dc364b7..182bda09d7b8 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -863,7 +863,7 @@ void SwDocShell::Execute(SfxRequest& rReq) bMerge = 0 != (nFlags&SFX_MERGE_STYLES); aOpt.SetMerge( !bMerge ); - SetError( LoadStylesFromFile( aFileName, aOpt, FALSE )); + SetError( LoadStylesFromFile( aFileName, aOpt, FALSE ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) )); if ( !GetError() ) rReq.Done(); } @@ -918,33 +918,6 @@ void SwDocShell::Execute(SfxRequest& rReq) if(!pBool || !pBool->GetValue()) break; } - else - { - // try to store the document - sal_uInt32 nErrorCode = ERRCODE_NONE; - try - { - uno::Reference< frame::XStorable > xStorable( GetModel(), uno::UNO_QUERY_THROW ); - xStorable->store(); - } - catch( task::ErrorCodeIOException& aErrEx ) - { - nErrorCode = (sal_uInt32)aErrEx.ErrCode; - } - catch( uno::Exception& ) - { - nErrorCode = ERRCODE_IO_GENERAL; - } - - if ( nErrorCode != ERRCODE_NONE ) - { - // if the saving has failed show the error and break the action - if ( nErrorCode != ERRCODE_ABORT ) - ErrorHandler::HandleError( nErrorCode ); - - break; - } - } } #ifdef DBG_UTIL { diff --git a/sw/source/ui/app/docshini.cxx b/sw/source/ui/app/docshini.cxx index 900a1f7fd060..e355dcba5e64 100644 --- a/sw/source/ui/app/docshini.cxx +++ b/sw/source/ui/app/docshini.cxx @@ -668,7 +668,7 @@ sal_Bool SwDocShell::Load( SfxMedium& rMedium ) UpdateFontList(); InitDraw(); - SetError( nErr ); + SetError( nErr, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); bRet = !IsError( nErr ); // --> OD 2006-11-07 #i59688# @@ -749,7 +749,7 @@ sal_Bool SwDocShell::LoadFrom( SfxMedium& rMedium ) */ } - SetError( nErr ); + SetError( nErr, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); bRet = !IsError( nErr ); } while( sal_False ); diff --git a/sw/source/ui/app/swmodul1.cxx b/sw/source/ui/app/swmodul1.cxx index 8a63254f42c1..863ef3c22f76 100644 --- a/sw/source/ui/app/swmodul1.cxx +++ b/sw/source/ui/app/swmodul1.cxx @@ -437,7 +437,7 @@ sal_uInt16 SwModule::InsertRedlineAuthor(const String& rAuthor) void lcl_FillAuthorAttr( sal_uInt16 nAuthor, SfxItemSet &rSet, const AuthorCharAttr &rAttr ) { - Color aCol( (ColorData)rAttr.nColor ); + Color aCol( rAttr.nColor ); if( COL_TRANSPARENT == rAttr.nColor ) { diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 763e5e82d62e..96719f17bd58 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -60,19 +60,19 @@ TabPage TP_CONTENT_OPT CheckBox CB_CROSS { Pos = MAP_APPFONT ( 12 , 14 ) ; - Size = MAP_APPFONT ( 108 , 10 ) ; + Size = MAP_APPFONT ( 118 , 10 ) ; Text [ en-US ] = "Guides ~while moving"; }; CheckBox CB_HANDLE { Pos = MAP_APPFONT ( 12 , 27 ) ; - Size = MAP_APPFONT ( 108 , 10 ) ; + Size = MAP_APPFONT ( 118 , 10 ) ; Text [ en-US ] = "Sim~ple handles"; }; CheckBox CB_BIGHANDLE { Pos = MAP_APPFONT ( 12 , 40 ) ; - Size = MAP_APPFONT ( 108 , 10 ) ; + Size = MAP_APPFONT ( 118 , 10 ) ; Text [ en-US ] = "Large handles"; }; FixedLine FL_WINDOW @@ -103,7 +103,7 @@ TabPage TP_CONTENT_OPT CheckBox CB_HRULER { Pos = MAP_APPFONT ( 142 , 53 ) ; - Size = MAP_APPFONT ( 61 , 10 ) ; + Size = MAP_APPFONT ( 62 , 10 ) ; Text [ en-US ] = "Hori~zontal ruler" ; }; ListBox LB_HMETRIC @@ -115,7 +115,7 @@ TabPage TP_CONTENT_OPT CheckBox CB_VRULER { Pos = MAP_APPFONT ( 142 , 66 ) ; - Size = MAP_APPFONT ( 61 , 10 ) ; + Size = MAP_APPFONT ( 62 , 10 ) ; Text [ en-US ] = "Verti~cal ruler" ; }; CheckBox CB_VRULER_RIGHT diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx index 082269122539..4b85042d0003 100644 --- a/sw/source/ui/config/optpage.cxx +++ b/sw/source/ui/config/optpage.cxx @@ -1688,7 +1688,7 @@ struct CharAttr }; // Editieren entspricht Einfuegen-Attributen -static CharAttr __FAR_DATA aInsertAttr[] = +static CharAttr __FAR_DATA aRedlineAttr[] = { { SID_ATTR_CHAR_CASEMAP, SVX_CASEMAP_NOT_MAPPED }, { SID_ATTR_CHAR_WEIGHT, WEIGHT_BOLD }, @@ -1702,7 +1702,17 @@ static CharAttr __FAR_DATA aInsertAttr[] = { SID_ATTR_CHAR_CASEMAP, SVX_CASEMAP_TITEL }, { SID_ATTR_BRUSH, 0 } }; +// Items from aRedlineAttr relevant for InsertAttr: strikethrough is +// not used +static USHORT aInsertAttrMap[] = { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10 }; +// Items from aRedlineAttr relevant for DeleteAttr: underline and +// double underline is not used +static USHORT aDeletedAttrMap[] = { 0, 1, 2, 5, 6, 7, 8, 9, 10 }; + +// Items from aRedlineAttr relevant for ChangeAttr: strikethrough is +// not used +static USHORT aChangedAttrMap[] = { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10 }; /*----------------------------------------------------------------------- Beschreibung: Markierungsvorschau @@ -1860,6 +1870,23 @@ void SwMarkPreview::DrawRect(const Rectangle &rRect, const Color &rFillColor, co Window::DrawRect(rRect); } +namespace +{ + void lcl_FillRedlineAttrListBox( + ListBox& rLB, const AuthorCharAttr& rAttrToSelect, + const USHORT* pAttrMap, const USHORT nAttrMapSize) + { + for (USHORT i = 0; i != nAttrMapSize; ++i) + { + CharAttr& rAttr(aRedlineAttr[pAttrMap[i]]); + rLB.SetEntryData(i, &rAttr); + if (rAttr.nItemId == rAttrToSelect.nItemId && + rAttr.nAttr == rAttrToSelect.nAttr) + rLB.SelectEntryPos(i); + } + } +} + SwRedlineOptionsTabPage::SwRedlineOptionsTabPage( Window* pParent, const SfxItemSet& rSet ) : SfxTabPage(pParent, SW_RES(TP_REDLINE_OPT), rSet), @@ -1908,6 +1935,13 @@ SwRedlineOptionsTabPage::SwRedlineOptionsTabPage( Window* pParent, aChangedLB.InsertEntry(sEntry); }; + // remove strikethrough from insert and change and underline + double + // underline from delete + aInsertLB.RemoveEntry(5); + aChangedLB.RemoveEntry(5); + aDeletedLB.RemoveEntry(4); + aDeletedLB.RemoveEntry(3); + Link aLk = LINK(this, SwRedlineOptionsTabPage, AttribHdl); aInsertLB.SetSelectHdl( aLk ); aDeletedLB.SetSelectHdl( aLk ); @@ -1945,7 +1979,7 @@ BOOL SwRedlineOptionsTabPage::FillItemSet( SfxItemSet& ) AuthorCharAttr aOldDeletedAttr(pOpt->GetDeletedAuthorAttr()); AuthorCharAttr aOldChangedAttr(pOpt->GetFormatAuthorAttr()); - ULONG nOldMarkColor = pOpt->GetMarkAlignColor().GetColor(); + ColorData nOldMarkColor = pOpt->GetMarkAlignColor().GetColor(); USHORT nOldMarkMode = pOpt->GetMarkAlignMode(); USHORT nPos = aInsertLB.GetSelectEntryPos(); @@ -2105,7 +2139,7 @@ void SwRedlineOptionsTabPage::Reset( const SfxItemSet& ) aChangedColorLB.SetUpdateMode( TRUE ); aMarkColorLB.SetUpdateMode( TRUE ); - ULONG nColor = rInsertAttr.nColor; + ColorData nColor = rInsertAttr.nColor; switch (nColor) { @@ -2149,41 +2183,16 @@ void SwRedlineOptionsTabPage::Reset( const SfxItemSet& ) aMarkColorLB.SelectEntry(pOpt->GetMarkAlignColor()); - // Attributlistboxen initialisieren - USHORT nNum = sizeof(aInsertAttr) / sizeof(CharAttr); - aInsertLB.SelectEntryPos(0); aDeletedLB.SelectEntryPos(0); aChangedLB.SelectEntryPos(0); - for (i = 0; i < nNum; i++) - { - aInsertLB.SetEntryData(i, &aInsertAttr[i]); - if (aInsertAttr[i].nItemId == rInsertAttr.nItemId && - aInsertAttr[i].nAttr == rInsertAttr.nAttr) - aInsertLB.SelectEntryPos(i); - } - - for (i = 0; i < nNum; i++) - { - aDeletedLB.SetEntryData(i, &aInsertAttr[i]); - if (aInsertAttr[i].nItemId == rDeletedAttr.nItemId && - aInsertAttr[i].nAttr == rDeletedAttr.nAttr) - aDeletedLB.SelectEntryPos(i); - } - - for (i = 0; i < nNum; i++) - { - aChangedLB.SetEntryData(i, &aInsertAttr[i]); - if (aInsertAttr[i].nItemId == rChangedAttr.nItemId && - aInsertAttr[i].nAttr == rChangedAttr.nAttr) - aChangedLB.SelectEntryPos(i); - } - //remove strikethrough from insert and delete and underline+double underline from delete - aInsertLB.RemoveEntry(5); - aChangedLB.RemoveEntry(5); - aDeletedLB.RemoveEntry(4); - aDeletedLB.RemoveEntry(3); + lcl_FillRedlineAttrListBox(aInsertLB, rInsertAttr, aInsertAttrMap, + sizeof(aInsertAttrMap) / sizeof(USHORT)); + lcl_FillRedlineAttrListBox(aDeletedLB, rDeletedAttr, aDeletedAttrMap, + sizeof(aDeletedAttrMap) / sizeof(USHORT)); + lcl_FillRedlineAttrListBox(aChangedLB, rChangedAttr, aChangedAttrMap, + sizeof(aChangedAttrMap) / sizeof(USHORT)); USHORT nPos = 0; switch (pOpt->GetMarkAlignMode()) @@ -2266,7 +2275,8 @@ IMPL_LINK( SwRedlineOptionsTabPage, AttribHdl, ListBox *, pLB ) nPos = 0; CharAttr* pAttr = ( CharAttr* ) pLB->GetEntryData( nPos ); - + //switch off preview background color + pPrev->ResetColor(); switch (pAttr->nItemId) { case SID_ATTR_CHAR_WEIGHT: diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index cbc77678e84e..93fad7cb699d 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -35,7 +35,7 @@ #endif #include <stdio.h> - +#include <unotxdoc.hxx> #include <com/sun/star/text/NotePrintMode.hpp> #include <sfx2/app.hxx> #include <com/sun/star/sdb/CommandType.hpp> @@ -43,17 +43,13 @@ #include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/XEventListener.hpp> -#ifndef _COM_SUN_STAR_UTIL_iXNUMBERFORMATTER_HPP_ #include <com/sun/star/util/XNumberFormatter.hpp> -#endif #include <com/sun/star/sdb/XCompletedConnection.hpp> #include <com/sun/star/sdb/XCompletedExecution.hpp> #include <com/sun/star/container/XChild.hpp> -#ifndef _COM_SUN_STAR_TEXT_MAILMERGEEVENT_ #include <com/sun/star/text/MailMergeEvent.hpp> -#endif #include <com/sun/star/frame/XStorable.hpp> -#include "com/sun/star/ui/dialogs/TemplateDescription.hpp" +#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/ui/dialogs/XFilePicker.hpp> #include <com/sun/star/ui/dialogs/XFilterManager.hpp> #include <com/sun/star/uno/XNamingService.hpp> @@ -65,9 +61,7 @@ #include <dbconfig.hxx> #include <swdbtoolsclient.hxx> #include <pagedesc.hxx> -#ifndef _LSTBOX_HXX //autogen #include <vcl/lstbox.hxx> -#endif #include <unotools/tempfile.hxx> #include <svtools/pathoptions.hxx> #include <svtools/urihelper.hxx> @@ -86,39 +80,25 @@ #include <goodies/mailenum.hxx> #include <cmdid.h> #include <swmodule.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <edtwin.hxx> #include <wrtsh.hxx> #include <fldbas.hxx> #include <initui.hxx> #include <swundo.hxx> #include <flddat.hxx> -#ifndef _MODCFG_HXX #include <modcfg.hxx> -#endif #include <swprtopt.hxx> #include <shellio.hxx> #include <dbui.hxx> -#ifndef _DBMGR_HXX #include <dbmgr.hxx> -#endif #include <doc.hxx> #include <swwait.hxx> #include <swunohelper.hxx> -#ifndef _DBUI_HRC #include <dbui.hrc> -#endif -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif -#ifndef _STATSTR_HRC #include <statstr.hrc> -#endif #include <mmconfigitem.hxx> #include <sfx2/request.hxx> #include <hintids.hxx> @@ -1756,6 +1736,7 @@ ULONG SwNewDBMgr::GetColumnFmt( const String& rDBName, uno::Reference< XConnection> xConnection; sal_Bool bUseMergeData = sal_False; uno::Reference< XColumnsSupplier> xColsSupp; + bool bDisposeConnection = false; if(pImpl->pMergeData && pImpl->pMergeData->sDataSource.equals(rDBName) && pImpl->pMergeData->sCommand.equals(rTableName)) { @@ -1780,6 +1761,7 @@ ULONG SwNewDBMgr::GetColumnFmt( const String& rDBName, { rtl::OUString sDBName(rDBName); xConnection = RegisterConnection( sDBName ); + bDisposeConnection = true; } if(bUseMergeData) pImpl->pMergeData->xConnection = xConnection; @@ -1810,6 +1792,10 @@ ULONG SwNewDBMgr::GetColumnFmt( const String& rDBName, { ::comphelper::disposeComponent( xColsSupp ); } + if(bDisposeConnection) + { + ::comphelper::disposeComponent( xConnection ); + } } else nRet = pNFmtr->GetFormatIndex( NF_NUMBER_STANDARD, LANGUAGE_SYSTEM ); @@ -3185,7 +3171,6 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig, SwWrtShell& rSourceShell = rSourceView.GetWrtShell(); BOOL bSynchronizedDoc = rSourceShell.IsLabelDoc() && rSourceShell.GetSectionFmtCount() > 1; - String sSourceDocURL; //save the settings of the first rSourceShell.SttEndDoc(TRUE); USHORT nStartingPageNo = rSourceShell.GetVirtPageNum(); @@ -3195,22 +3180,6 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig, try { - // save the working document into a temporary location - sSourceDocURL = URIHelper::SmartRel2Abs( - INetURLObject(), utl::TempFile::CreateTempName(), - URIHelper::GetMaybeFileHdl()); - const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat( - String::CreateFromAscii( FILTER_XML ), - SwDocShell::Factory().GetFilterContainer() ); - - SfxStringItem aFilterName( SID_FILTER_NAME, pSfxFlt->GetFilterName()); - uno::Sequence< beans::PropertyValue > aValues(1); - beans::PropertyValue* pValues = aValues.getArray(); - pValues[0].Name = C2U("FilterName"); - pValues[0].Value <<= ::rtl::OUString(pSfxFlt->GetFilterName()); - uno::Reference< frame::XStorable > xStore( rSourceView.GetDocShell()->GetModel(), uno::UNO_QUERY); - xStore->storeToURL( sSourceDocURL, aValues ); - // create a target docshell to put the merged document into SfxObjectShellRef xTargetDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) ); xTargetDocShell->DoInitNew( 0 ); @@ -3259,116 +3228,120 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig, Application::Reschedule(); } - // create a new docshell from the temporary document - SfxBoolItem aHidden( SID_HIDDEN, TRUE ); - SfxStringItem aReferer( SID_REFERER, String::CreateFromAscii(URL_PREFIX_PRIV_SOFFICE )); - SfxStringItem aTarget( SID_TARGETNAME, String::CreateFromAscii("_blank") ); - SfxStringItem aURL( SID_FILE_NAME, sSourceDocURL ); - const SfxPoolItem* pReturnValue = - rSourceView.GetViewFrame()->GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, - &aURL, &aFilterName, &aHidden, &aReferer, &aTarget, 0L); - if(pReturnValue) - { - SfxViewFrameItem* pVItem = (SfxViewFrameItem*)pReturnValue; - SwView* pWorkView = (SwView*) pVItem->GetFrame()->GetViewShell(); - SwWrtShell& rWorkShell = pWorkView->GetWrtShell(); - pWorkView->AttrChangedNotify( &rWorkShell );//Damit SelectShell gerufen wird. - - // merge the data - SwDoc* pWorkDoc = rWorkShell.GetDoc(); - SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr(); - pWorkDoc->SetNewDBMgr( this ); - pWorkDoc->EmbedAllLinks(); - if(UNDO_UI_DELETE_INVISIBLECNTNT == rWorkShell.GetUndoIds()) - rWorkShell.Undo(); - // create a layout - rWorkShell.CalcLayout(); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, rWorkShell.GetView().GetViewFrame()->GetObjectShell())); - rWorkShell.ViewShell::UpdateFlds(); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, rWorkShell.GetView().GetViewFrame()->GetObjectShell())); - - // strip invisible content and convert fields to text - rWorkShell.RemoveInvisibleContent(); - rWorkShell.ConvertFieldsToText(); - rWorkShell.SetNumberingRestart(); - - - // insert the document into the target document - rWorkShell.SttEndDoc(FALSE); - rWorkShell.SttEndDoc(TRUE); - rWorkShell.SelAll(); - pTargetShell->SttEndDoc(FALSE); - - //#i63806# put the styles to the target document - //if the source uses headers or footers each new copy need to copy a new page styles - if(bPageStylesWithHeaderFooter) - { - //create a new pagestyle - //copy the pagedesc from the current document to the new document and change the name of the to-be-applied style - - SwDoc* pTargetDoc = pTargetShell->GetDoc(); - String sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo ); - pTargetShell->GetDoc()->MakePageDesc( sNewPageDescName ); - SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName ); - if(pSourcePageDesc && pTargetPageDesc) - { - pTargetDoc->CopyPageDesc( *pSourcePageDesc, *pTargetPageDesc, sal_False ); - sModifiedStartingPageDesc = sNewPageDescName; - lcl_CopyFollowPageDesc( *pTargetShell, *pSourcePageDesc, *pTargetPageDesc, nDocNo ); - } - } - if(nDocNo == 1 || bPageStylesWithHeaderFooter) - { - pTargetView->GetDocShell()->_LoadStyles( *pWorkView->GetDocShell(), sal_True ); - } - if(nDocNo > 1) - { - pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo ); - } - else - { - pTargetShell->SetPageStyle(sModifiedStartingPageDesc); - } - USHORT nPageCountBefore = pTargetShell->GetPageCnt(); - DBG_ASSERT(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended"); - //#i51359# add a second paragraph in case there's only one + // copy the source document + SfxObjectShellRef xWorkDocSh; + if(nDocNo == 1 ) + { + uno::Reference< util::XCloneable > xClone( rSourceView.GetDocShell()->GetModel(), uno::UNO_QUERY); + uno::Reference< lang::XUnoTunnel > xWorkDocShell( xClone->createClone(), uno::UNO_QUERY); + SwXTextDocument* pWorkModel = reinterpret_cast<SwXTextDocument*>(xWorkDocShell->getSomething(SwXTextDocument::getUnoTunnelId())); + xWorkDocSh = pWorkModel->GetDocShell(); + } + else + { + SwDoc* pNewDoc = rSourceView.GetDocShell()->GetDoc()->CreateCopy(); + xWorkDocSh = new SwDocShell( pNewDoc, SFX_CREATE_MODE_STANDARD ); + xWorkDocSh->DoInitNew(); + } + //create a ViewFrame + SwView* pWorkView = static_cast< SwView* >( SfxViewFrame::CreateViewFrame( *xWorkDocSh, 0, sal_True )->GetViewShell() ); + SwWrtShell& rWorkShell = pWorkView->GetWrtShell(); + pWorkView->AttrChangedNotify( &rWorkShell );//Damit SelectShell gerufen wird. + + // merge the data + SwDoc* pWorkDoc = rWorkShell.GetDoc(); + SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr(); + pWorkDoc->SetNewDBMgr( this ); + pWorkDoc->EmbedAllLinks(); + if(UNDO_UI_DELETE_INVISIBLECNTNT == rWorkShell.GetUndoIds()) + rWorkShell.Undo(); + // create a layout + rWorkShell.CalcLayout(); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, rWorkShell.GetView().GetViewFrame()->GetObjectShell())); + rWorkShell.ViewShell::UpdateFlds(); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, rWorkShell.GetView().GetViewFrame()->GetObjectShell())); + + // strip invisible content and convert fields to text + rWorkShell.RemoveInvisibleContent(); + rWorkShell.ConvertFieldsToText(); + rWorkShell.SetNumberingRestart(); + + + // insert the document into the target document + rWorkShell.SttEndDoc(FALSE); + rWorkShell.SttEndDoc(TRUE); + rWorkShell.SelAll(); + pTargetShell->SttEndDoc(FALSE); + + //#i63806# put the styles to the target document + //if the source uses headers or footers each new copy need to copy a new page styles + if(bPageStylesWithHeaderFooter) + { + //create a new pagestyle + //copy the pagedesc from the current document to the new document and change the name of the to-be-applied style + + SwDoc* pTargetDoc = pTargetShell->GetDoc(); + String sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo ); + pTargetShell->GetDoc()->MakePageDesc( sNewPageDescName ); + SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName ); + if(pSourcePageDesc && pTargetPageDesc) { - SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 ); - SwPosition aTestPos( aIdx ); - SwCursor aTestCrsr(aTestPos,0,false); - if(!aTestCrsr.MovePara(fnParaNext, fnParaStart)) - { - //append a paragraph - pWorkDoc->AppendTxtNode( aTestPos ); - } + pTargetDoc->CopyPageDesc( *pSourcePageDesc, *pTargetPageDesc, sal_False ); + sModifiedStartingPageDesc = sNewPageDescName; + lcl_CopyFollowPageDesc( *pTargetShell, *pSourcePageDesc, *pTargetPageDesc, nDocNo ); } - pTargetShell->Paste( rWorkShell.GetDoc(), sal_True ); - //convert fields in page styles (header/footer - has to be done after the first document has been pasted - if(1 == nDocNo) + } + if(nDocNo == 1 || bPageStylesWithHeaderFooter) + { + pTargetView->GetDocShell()->_LoadStyles( *pWorkView->GetDocShell(), sal_True ); + } + if(nDocNo > 1) + { + pTargetShell->InsertPageBreak( &sModifiedStartingPageDesc, nStartingPageNo ); + } + else + { + pTargetShell->SetPageStyle(sModifiedStartingPageDesc); + } + USHORT nPageCountBefore = pTargetShell->GetPageCnt(); + DBG_ASSERT(!pTargetShell->GetTableFmt(),"target document ends with a table - paragraph should be appended"); + //#i51359# add a second paragraph in case there's only one + { + SwNodeIndex aIdx( pWorkDoc->GetNodes().GetEndOfExtras(), 2 ); + SwPosition aTestPos( aIdx ); + SwCursor aTestCrsr(aTestPos,0,false); + if(!aTestCrsr.MovePara(fnParaNext, fnParaStart)) { - pTargetShell->CalcLayout(); - pTargetShell->ConvertFieldsToText(); + //append a paragraph + pWorkDoc->AppendTxtNode( aTestPos ); } - //add the document info to the config item - SwDocMergeInfo aMergeInfo; - aMergeInfo.nStartPageInTarget = nPageCountBefore; - //#i72820# calculate layout to be able to find the correct page index + } + pTargetShell->Paste( rWorkShell.GetDoc(), sal_True ); + //convert fields in page styles (header/footer - has to be done after the first document has been pasted + if(1 == nDocNo) + { pTargetShell->CalcLayout(); - aMergeInfo.nEndPageInTarget = pTargetShell->GetPageCnt(); - aMergeInfo.nDBRow = nStartRow; - rMMConfig.AddMergedDocument( aMergeInfo ); - ++nRet; - - // the print monitor needs some time to act - for( USHORT i = 0; i < 25; i++) - Application::Reschedule(); - - //restore the ole DBMgr - pWorkDoc->SetNewDBMgr( pWorkDBMgr ); - //now the temporary document should be closed - SfxObjectShellRef xDocSh(pWorkView->GetDocShell()); - xDocSh->DoClose(); + pTargetShell->ConvertFieldsToText(); } + //add the document info to the config item + SwDocMergeInfo aMergeInfo; + aMergeInfo.nStartPageInTarget = nPageCountBefore; + //#i72820# calculate layout to be able to find the correct page index + pTargetShell->CalcLayout(); + aMergeInfo.nEndPageInTarget = pTargetShell->GetPageCnt(); + aMergeInfo.nDBRow = nStartRow; + rMMConfig.AddMergedDocument( aMergeInfo ); + ++nRet; + + // the print monitor needs some time to act + for( USHORT i = 0; i < 25; i++) + Application::Reschedule(); + + //restore the ole DBMgr + pWorkDoc->SetNewDBMgr( pWorkDBMgr ); + //now the temporary document should be closed + SfxObjectShellRef xDocSh(pWorkView->GetDocShell()); + xDocSh->DoClose(); nEndRow = pImpl->pMergeData->xResultSet->getRow(); ++nDocNo; } while( !bCancel && @@ -3390,8 +3363,6 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig, { DBG_ERROR("exception caught in SwNewDBMgr::MergeDocuments"); } - if(sSourceDocURL.Len()) - File::remove( sSourceDocURL ); DELETEZ(pImpl->pMergeData); bInMerge = FALSE; return nRet; diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx index 44c2aeeb6220..cd04ebeb2e59 100644 --- a/sw/source/ui/dbui/mmlayoutpage.cxx +++ b/sw/source/ui/dbui/mmlayoutpage.cxx @@ -802,7 +802,8 @@ IMPL_LINK(SwMailMergeLayoutPage, GreetingsHdl_Impl, PushButton*, pButton) { bool bDown = pButton == &m_aDownPB; BOOL bMoved = m_pExampleWrtShell->MoveParagraph( bDown ? 1 : -1 ); - m_pWizard->GetConfigItem().MoveGreeting(bDown ? 1 : -1 ); + if (bMoved || bDown) + m_pWizard->GetConfigItem().MoveGreeting(bDown ? 1 : -1 ); if(!bMoved && bDown) { //insert a new paragraph before the greeting line diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx index 64fd024fab57..72fc1e122a8e 100644 --- a/sw/source/ui/dbui/mmoutputpage.cxx +++ b/sw/source/ui/dbui/mmoutputpage.cxx @@ -428,6 +428,8 @@ SwMailMergeOutputPage::SwMailMergeOutputPage( SwMailMergeWizard* _pParent) : m_aSendAllRB.SetClickHdl(LINK(this, SwMailMergeOutputPage, DocumentSelectionHdl_Impl)); m_aFromRB.SetClickHdl(LINK(this, SwMailMergeOutputPage, DocumentSelectionHdl_Impl)); + //#i63267# printing might be disabled + m_aPrintRB.Enable(!Application::GetSettings().GetMiscSettings().GetDisablePrinting()); } /*-- 02.04.2004 13:15:44--------------------------------------------------- diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 627676707214..ab2a1d8e3d3c 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -93,7 +93,6 @@ #include <glossary.hxx> //add for SwGlossaryDlg #include <inpdlg.hxx> //add for SwFldInputDlg #include <insfnote.hxx> //add for SwInsFootNoteDlg -#include <insrc.hxx> //add for SwInsRowColDlg #include <insrule.hxx> //add for SwInsertGrfRulerDlg #include <instable.hxx> //add for SwInsTableDlg #include <javaedit.hxx> //add for SwJavaEditDialog @@ -1359,14 +1358,11 @@ AbstractInsFootNoteDlg* SwAbstractDialogFactory_Impl::CreateInsFootNoteDlg( int } VclAbstractDialog * SwAbstractDialogFactory_Impl::CreateVclSwViewDialog( int nResId, - SwView& rView, BOOL bCol ) //add for SwInsRowColDlg, SwLineNumberingDlg + SwView& rView, BOOL /*bCol*/ ) //add for SwInsRowColDlg, SwLineNumberingDlg { Dialog* pDlg=NULL; switch ( nResId ) { - case DLG_INS_ROW_COL : - pDlg = new SwInsRowColDlg( rView, bCol ); - break; case DLG_LINE_NUMBERING : pDlg = new SwLineNumberingDlg( &rView ); break; diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx index 6539ad9d7284..ea6ab45f4ec1 100644 --- a/sw/source/ui/dochdl/swdtflvr.cxx +++ b/sw/source/ui/dochdl/swdtflvr.cxx @@ -166,7 +166,7 @@ extern BOOL bDDINetAttr; extern BOOL bExecuteDrag; -#define OLESIZE lA4Width - 2 * lMinBorder, 6 * MM50 +#define OLESIZE 11905 - 2 * lMinBorder, 6 * MM50 #define SWTRANSFER_OBJECTTYPE_DRAWMODEL 0x00000001 #define SWTRANSFER_OBJECTTYPE_HTML 0x00000002 @@ -468,7 +468,7 @@ sal_Bool SwTransferable::GetData( const DATA_FLAVOR& rFlavor ) pClpDocFac = new SwDocFac; SwDoc* pTmpDoc = pClpDocFac->GetDoc(); - pTmpDoc->SetRefForDocShell( (SfxObjectShellRef*)&(long&)aDocShellRef ); + pTmpDoc->SetRefForDocShell( boost::addressof(aDocShellRef) ); pTmpDoc->LockExpFlds(); // nie die Felder updaten - Text so belassen pWrtShell->Copy( pTmpDoc ); @@ -561,10 +561,14 @@ sal_Bool SwTransferable::GetData( const DATA_FLAVOR& rFlavor ) break; case SOT_FORMAT_STRING: - bOK = SetObject( pClpDocFac->GetDoc(), + { + SwDoc* pDoc = pClpDocFac->GetDoc(); + ASSERT( pDoc, "Document not found" ); + pDoc->SetClipBoard( true ); + bOK = SetObject( pDoc, SWTRANSFER_OBJECTTYPE_STRING, rFlavor ); - break; - + } + break; case SOT_FORMAT_RTF: bOK = SetObject( pClpDocFac->GetDoc(), SWTRANSFER_OBJECTTYPE_RTF, rFlavor ); @@ -879,7 +883,7 @@ int SwTransferable::PrepareForCopy( BOOL bIsCut ) SwDoc* pTmpDoc = pClpDocFac->GetDoc(); pTmpDoc->SetClipBoard( true ); - pTmpDoc->SetRefForDocShell( (SfxObjectShellRef*)&(long&)aDocShellRef ); + pTmpDoc->SetRefForDocShell( boost::addressof(aDocShellRef) ); pTmpDoc->LockExpFlds(); // nie die Felder updaten - Text so belassen pWrtShell->Copy( pTmpDoc ); @@ -1063,7 +1067,7 @@ int SwTransferable::CopyGlossary( SwTextBlocks& rGlossary, SwCntntNode* pCNd = rNds.GoNext( &aNodeIdx ); // gehe zum 1. ContentNode SwPaM aPam( *pCNd ); - pCDoc->SetRefForDocShell( (SfxObjectShellRef*)&(long&)aDocShellRef ); + pCDoc->SetRefForDocShell( boost::addressof(aDocShellRef) ); pCDoc->LockExpFlds(); // nie die Felder updaten - Text so belassen pCDoc->InsertGlossary( rGlossary, rStr, aPam, 0 ); @@ -2894,6 +2898,15 @@ static USHORT aPasteSpecialIds[] = 0 }; + +int SwTransferable::PasteUnformatted( SwWrtShell& rSh, TransferableDataHelper& rData ) +{ + // Plain text == unformatted + return SwTransferable::PasteFormat( rSh, rData, SOT_FORMAT_STRING ); +} + +// ----------------------------------------------------------------------- + int SwTransferable::PasteSpecial( SwWrtShell& rSh, TransferableDataHelper& rData, ULONG& rFormatUsed ) { int nRet = 0; diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 5166f0f01d5c..8236791701ef 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -420,7 +420,7 @@ void SwEditWin::UpdatePointer(const Point &rLPt, USHORT nModifier ) SdrObject* pObj; SdrPageView* pPV; pSdrView->SetHitTolerancePixel( HIT_PIX ); if ( bNotInSelObj && bExecHyperlinks && - pSdrView->PickObj( rLPt, pObj, pPV, SDRSEARCH_PICKMACRO )) + pSdrView->PickObj( rLPt, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO )) { SdrObjMacroHitRec aTmp; aTmp.aPos = rLPt; diff --git a/sw/source/ui/docvw/postit.cxx b/sw/source/ui/docvw/postit.cxx index a7c12f54f100..8b4c46b6f2c1 100644 --- a/sw/source/ui/docvw/postit.cxx +++ b/sw/source/ui/docvw/postit.cxx @@ -117,6 +117,14 @@ #include <ndtxt.hxx> #include <langhelper.hxx> +#include <sw_primitivetypes2d.hxx> +#include <drawinglayer/primitive2d/primitivetools2d.hxx> +#include <drawinglayer/attribute/fillattribute.hxx> +#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx> +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#include <drawinglayer/primitive2d/shadowprimitive2d.hxx> + using namespace ::com::sun::star; #define METABUTTON_WIDTH 16 @@ -915,12 +923,17 @@ void SwMarginWin::SetPosAndSize() basegfx::B2DPoint( mAnkorRect.Left(), mAnkorRect.Bottom()+2*15), basegfx::B2DPoint( mPageBorder ,mAnkorRect.Bottom()+2*15), basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()), - basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()) , mColorAnkor,LineInfo(LINE_DASH,ANKORLINE_WIDTH*15), false); + basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y()) , + mColorAnkor, + false, + false); mpAnkor->SetHeight(mAnkorRect.Height()); mpAnkor->setVisible(true); mpAnkor->SetAnkorState(AS_TRI); if (HasChildPathFocus()) - mpAnkor->SetLineInfo(LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); + { + mpAnkor->setLineSolid(true); + } pOverlayManager->add(*mpAnkor); } } @@ -1493,7 +1506,7 @@ void SwMarginWin::SetViewState(ShadowState bState) SwMarginWin* pWin = GetTopReplyNote(); if (IsFollow() && pWin) pWin->Ankor()->SetAnkorState(AS_END); - mpAnkor->SetLineInfo(LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); + mpAnkor->setLineSolid(true); } if (mpShadow) mpShadow->SetShadowState(bState); @@ -1502,7 +1515,7 @@ void SwMarginWin::SetViewState(ShadowState bState) case SS_VIEW: { if (mpAnkor) - mpAnkor->SetLineInfo(LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); + mpAnkor->setLineSolid(true); if (mpShadow) mpShadow->SetShadowState(bState); break; @@ -1521,11 +1534,11 @@ void SwMarginWin::SetViewState(ShadowState bState) if (pTopWinSelf && (pTopWinSelf!=pTopWinActive)) { if (pTopWinSelf!=mpMgr->GetActivePostIt()) - pTopWinSelf->Ankor()->SetLineInfo(LineInfo(LINE_DASH,ANKORLINE_WIDTH*15)); + pTopWinSelf->Ankor()->setLineSolid(false); pTopWinSelf->Ankor()->SetAnkorState(AS_ALL); } } - mpAnkor->SetLineInfo(LineInfo(LINE_DASH,ANKORLINE_WIDTH*15)); + mpAnkor->setLineSolid(false); } if (mpShadow) mpShadow->SetShadowState(bState); @@ -1965,60 +1978,116 @@ bool SwRedComment::IsProtected() } */ -/****** SwPostItShadow ***********************************************************/ -SwPostItShadow::SwPostItShadow(const basegfx::B2DPoint& rBasePos,const basegfx::B2DPoint& rSecondPosition, - Color aBaseColor,ShadowState aState) - : OverlayObjectWithBasePosition(rBasePos, aBaseColor), - maSecondPosition(rSecondPosition), - mShadowState(aState) -{ -// mbAllowsAnimation = sal_True; -} +////////////////////////////////////////////////////////////////////////////// +// helper SwPostItShadowPrimitive +// +// Used to allow view-dependent primitive definition. For that purpose, the +// initially created primitive (this one) always has to be view-independent, +// but the decomposition is made view-dependent. Very simple primitive which +// just remembers the discrete data and applies it at decomposition time. -SwPostItShadow::~SwPostItShadow() +class SwPostItShadowPrimitive : public drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D { -} +private: + basegfx::B2DPoint maBasePosition; + basegfx::B2DPoint maSecondPosition; + ShadowState maShadowState; -void SwPostItShadow::Trigger(sal_uInt32 /*nTime*/) -{ -} +protected: + virtual drawinglayer::primitive2d::Primitive2DSequence createLocalDecomposition( + const drawinglayer::geometry::ViewInformation2D& rViewInformation) const; -void SwPostItShadow::drawGeometry(OutputDevice& rOutputDevice) -{ - rOutputDevice.SetLineColor(); - rOutputDevice.SetFillColor(); +public: + SwPostItShadowPrimitive( + const basegfx::B2DPoint& rBasePosition, + const basegfx::B2DPoint& rSecondPosition, + ShadowState aShadowState) + : drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D(), + maBasePosition(rBasePosition), + maSecondPosition(rSecondPosition), + maShadowState(aShadowState) + {} - const Fraction& f( rOutputDevice.GetMapMode().GetScaleY() ); - sal_Int32 aBigHeight( 4 * f.GetNumerator() / f.GetDenominator()); - sal_Int32 aSmallHeight( 2 * f.GetNumerator() / f.GetDenominator()); + // data access + const basegfx::B2DPoint& getBasePosition() const { return maBasePosition; } + const basegfx::B2DPoint& getSecondPosition() const { return maSecondPosition; } + ShadowState getShadowState() const { return maShadowState; } - const Point aStart(FRound(getBasePosition().getX()), FRound(getBasePosition().getY())); - const Point aEndSmall(FRound(GetSecondPosition().getX()), FRound(GetSecondPosition().getY() + rOutputDevice.PixelToLogic(Size(0,aSmallHeight)).Height())); - const Point aEndBig(FRound(GetSecondPosition().getX()), FRound(GetSecondPosition().getY() + rOutputDevice.PixelToLogic(Size(0,aBigHeight)).Height())); - Rectangle aSmallRectangle(aStart, aEndSmall); - Rectangle aBigRectangle(aStart, aEndBig); + virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const; - switch(mShadowState) + DeclPrimitrive2DIDBlock() +}; + +drawinglayer::primitive2d::Primitive2DSequence SwPostItShadowPrimitive::createLocalDecomposition( + const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const +{ + // get logic sizes in object coordinate system + drawinglayer::primitive2d::Primitive2DSequence xRetval; + basegfx::B2DRange aRange(getBasePosition()); + + switch(maShadowState) { case SS_NORMAL: { - Gradient aGradient(GRADIENT_LINEAR,Color(230,230,230),POSTIT_SHADOW_BRIGHT); - aGradient.SetAngle(1800); - rOutputDevice.DrawGradient(aSmallRectangle, aGradient); + aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (2.0 * getDiscreteUnit()))); + const drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute( + drawinglayer::attribute::GRADIENTSTYLE_LINEAR, + 0.0, + 0.5, + 0.5, + 1800.0 * F_PI1800, + basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0), + basegfx::BColor(180.0/255.0,180.0/255.0,180.0/255.0), + 2); + + const drawinglayer::primitive2d::Primitive2DReference xReference( + new drawinglayer::primitive2d::FillGradientPrimitive2D( + aRange, + aFillGradientAttribute)); + + xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); break; } case SS_VIEW: { - Gradient aGradient(GRADIENT_LINEAR,Color(230,230,230),POSTIT_SHADOW_BRIGHT); - aGradient.SetAngle(1800); - rOutputDevice.DrawGradient(aBigRectangle, aGradient); + aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (4.0 * getDiscreteUnit()))); + const drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute( + drawinglayer::attribute::GRADIENTSTYLE_LINEAR, + 0.0, + 0.5, + 0.5, + 1800.0 * F_PI1800, + basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0), + basegfx::BColor(180.0/255.0,180.0/255.0,180.0/255.0), + 4); + + const drawinglayer::primitive2d::Primitive2DReference xReference( + new drawinglayer::primitive2d::FillGradientPrimitive2D( + aRange, + aFillGradientAttribute)); + + xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); break; } case SS_EDIT: { - Gradient aGradient(GRADIENT_LINEAR,Color(230,230,230),POSTIT_SHADOW_DARK); - aGradient.SetAngle(1800); - rOutputDevice.DrawGradient(aBigRectangle, aGradient); + aRange.expand(basegfx::B2DTuple(getSecondPosition().getX(), getSecondPosition().getY() + (4.0 * getDiscreteUnit()))); + const drawinglayer::attribute::FillGradientAttribute aFillGradientAttribute( + drawinglayer::attribute::GRADIENTSTYLE_LINEAR, + 0.0, + 0.5, + 0.5, + 1800.0 * F_PI1800, + basegfx::BColor(230.0/255.0,230.0/255.0,230.0/255.0), + basegfx::BColor(83.0/255.0,83.0/255.0,83.0/255.0), + 4); + + const drawinglayer::primitive2d::Primitive2DReference xReference( + new drawinglayer::primitive2d::FillGradientPrimitive2D( + aRange, + aFillGradientAttribute)); + + xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); break; } default: @@ -2026,19 +2095,48 @@ void SwPostItShadow::drawGeometry(OutputDevice& rOutputDevice) break; } } + + return xRetval; +} + +bool SwPostItShadowPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const +{ + if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) + { + const SwPostItShadowPrimitive& rCompare = static_cast< const SwPostItShadowPrimitive& >(rPrimitive); + + return (getBasePosition() == rCompare.getBasePosition() + && getSecondPosition() == rCompare.getSecondPosition() + && getShadowState() == rCompare.getShadowState()); + } + + return false; } -void SwPostItShadow::createBaseRange(OutputDevice& rOutputDevice) +ImplPrimitrive2DIDBlock(SwPostItShadowPrimitive, PRIMITIVE2D_ID_SWPOSTITSHADOWPRIMITIVE) + +/****** SwPostItShadow ***********************************************************/ +SwPostItShadow::SwPostItShadow(const basegfx::B2DPoint& rBasePos,const basegfx::B2DPoint& rSecondPosition, + Color aBaseColor,ShadowState aState) + : OverlayObjectWithBasePosition(rBasePos, aBaseColor), + maSecondPosition(rSecondPosition), + mShadowState(aState) { - maBaseRange.reset(); +// mbAllowsAnimation = false; +} - const Fraction& f( rOutputDevice.GetMapMode().GetScaleY() ); - sal_Int32 aBigHeight( 4 * f.GetNumerator() / f.GetDenominator()); +SwPostItShadow::~SwPostItShadow() +{ +} - Rectangle aRect(Point(FRound(getBasePosition().getX()),FRound(getBasePosition().getY())), - Point(FRound(GetSecondPosition().getX()),FRound(GetSecondPosition().getY()+rOutputDevice.PixelToLogic(Size(0,aBigHeight)).Height()))); - maBaseRange.expand(basegfx::B2DPoint(aRect.Left(), aRect.Top())); - maBaseRange.expand(basegfx::B2DPoint(aRect.Right(), aRect.Bottom())); +drawinglayer::primitive2d::Primitive2DSequence SwPostItShadow::createOverlayObjectPrimitive2DSequence() +{ + const drawinglayer::primitive2d::Primitive2DReference aReference( + new SwPostItShadowPrimitive( + getBasePosition(), + GetSecondPosition(), + GetShadowState())); + return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1); } void SwPostItShadow::SetShadowState(ShadowState aState) @@ -2046,6 +2144,7 @@ void SwPostItShadow::SetShadowState(ShadowState aState) if (mShadowState != aState) { mShadowState = aState; + objectChange(); } } @@ -2053,22 +2152,210 @@ void SwPostItShadow::SetShadowState(ShadowState aState) void SwPostItShadow::SetPosition(const basegfx::B2DPoint& rPoint1, const basegfx::B2DPoint& rPoint2) { - maBasePosition = rPoint1; - maSecondPosition = rPoint2; + if(!rPoint1.equal(getBasePosition()) || !rPoint2.equal(GetSecondPosition())) + { + maBasePosition = rPoint1; + maSecondPosition = rPoint2; - objectChange(); + objectChange(); + } } -void SwPostItShadow::transform(const basegfx::B2DHomMatrix& rMatrix) + +////////////////////////////////////////////////////////////////////////////// +// helper class: Primitive for discrete visualisation + +class SwPostItAnkorPrimitive : public drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D { - if(!rMatrix.isIdentity()) +private: + basegfx::B2DPolygon maTriangle; + basegfx::B2DPolygon maLine; + basegfx::B2DPolygon maLineTop; + AnkorState maAnkorState; + basegfx::BColor maColor; + + // discrete line width + double mfLogicLineWidth; + + // bitfield + bool mbShadow : 1; + bool mbLineSolid : 1; + +protected: + virtual drawinglayer::primitive2d::Primitive2DSequence createLocalDecomposition( + const drawinglayer::geometry::ViewInformation2D& rViewInformation) const; + +public: + SwPostItAnkorPrimitive( + const basegfx::B2DPolygon& rTriangle, + const basegfx::B2DPolygon& rLine, + const basegfx::B2DPolygon& rLineTop, + AnkorState aAnkorState, + const basegfx::BColor& rColor, + double fLogicLineWidth, + bool bShadow, + bool bLineSolid) + : drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D(), + maTriangle(rTriangle), + maLine(rLine), + maLineTop(rLineTop), + maAnkorState(aAnkorState), + maColor(rColor), + mfLogicLineWidth(fLogicLineWidth), + mbShadow(bShadow), + mbLineSolid(bLineSolid) + {} + + // data access + const basegfx::B2DPolygon& getTriangle() const { return maTriangle; } + const basegfx::B2DPolygon& getLine() const { return maLine; } + const basegfx::B2DPolygon& getLineTop() const { return maLineTop; } + AnkorState getAnkorState() const { return maAnkorState; } + const basegfx::BColor& getColor() const { return maColor; } + double getLogicLineWidth() const { return mfLogicLineWidth; } + bool getShadow() const { return mbShadow; } + bool getLineSolid() const { return mbLineSolid; } + + virtual bool operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const; + + DeclPrimitrive2DIDBlock() +}; + +drawinglayer::primitive2d::Primitive2DSequence SwPostItAnkorPrimitive::createLocalDecomposition( + const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const +{ + drawinglayer::primitive2d::Primitive2DSequence aRetval; + + if(AS_TRI == getAnkorState() || AS_ALL == getAnkorState() || AS_START == getAnkorState()) { - // transform base position - OverlayObjectWithBasePosition::transform(rMatrix); - maSecondPosition = rMatrix * GetSecondPosition(); - objectChange(); + // create triangle + const drawinglayer::primitive2d::Primitive2DReference aTriangle( + new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( + basegfx::B2DPolyPolygon(getTriangle()), + getColor())); + + drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aTriangle); + } + + if(AS_ALL == getAnkorState() || AS_START == getAnkorState()) + { + // create line start + const drawinglayer::attribute::LineAttribute aLineAttribute( + getColor(), + getLogicLineWidth() / (basegfx::fTools::equalZero(getDiscreteUnit()) ? 1.0 : getDiscreteUnit())); + + if(getLineSolid()) + { + const drawinglayer::primitive2d::Primitive2DReference aSolidLine( + new drawinglayer::primitive2d::PolygonStrokePrimitive2D( + getLine(), + aLineAttribute)); + + drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aSolidLine); + } + else + { + ::std::vector< double > aDotDashArray; + const double fDistance(3.0 * 15.0); + const double fDashLen(5.0 * 15.0); + + aDotDashArray.push_back(fDashLen); + aDotDashArray.push_back(fDistance); + + const drawinglayer::attribute::StrokeAttribute aStrokeAttribute( + aDotDashArray, + fDistance + fDashLen); + + const drawinglayer::primitive2d::Primitive2DReference aStrokedLine( + new drawinglayer::primitive2d::PolygonStrokePrimitive2D( + getLine(), + aLineAttribute, + aStrokeAttribute)); + + drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aStrokedLine); + } + } + + if(aRetval.hasElements() && getShadow()) + { + // shadow is only for triangle and line start, and in upper left + // and lower right direction, in different colors + const double fColorChange(20.0 / 255.0); + const basegfx::B3DTuple aColorChange(fColorChange, fColorChange, fColorChange); + basegfx::BColor aLighterColor(getColor() + aColorChange); + basegfx::BColor aDarkerColor(getColor() - aColorChange); + + aLighterColor.clamp(); + aDarkerColor.clamp(); + + // create shadow sequence + drawinglayer::primitive2d::Primitive2DSequence aShadows(2); + basegfx::B2DHomMatrix aTransform; + + aTransform.set(0, 2, -getDiscreteUnit()); + aTransform.set(1, 2, -getDiscreteUnit()); + + aShadows[0] = drawinglayer::primitive2d::Primitive2DReference( + new drawinglayer::primitive2d::ShadowPrimitive2D( + aTransform, + aLighterColor, + aRetval)); + + aTransform.set(0, 2, getDiscreteUnit()); + aTransform.set(1, 2, getDiscreteUnit()); + + aShadows[1] = drawinglayer::primitive2d::Primitive2DReference( + new drawinglayer::primitive2d::ShadowPrimitive2D( + aTransform, + aDarkerColor, + aRetval)); + + // add shadow before geometry to make it be proccessed first + const drawinglayer::primitive2d::Primitive2DSequence aTemporary(aRetval); + + aRetval = aShadows; + drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, aTemporary); + } + + if(AS_ALL == getAnkorState() || AS_END == getAnkorState()) + { + // LineTop has to be created, too, but uses no shadow, so add after + // the other parts are created + const drawinglayer::attribute::LineAttribute aLineAttribute( + getColor(), + getLogicLineWidth() / (basegfx::fTools::equalZero(getDiscreteUnit()) ? 1.0 : getDiscreteUnit())); + + const drawinglayer::primitive2d::Primitive2DReference aLineTop( + new drawinglayer::primitive2d::PolygonStrokePrimitive2D( + getLineTop(), + aLineAttribute)); + + drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aLineTop); } + + return aRetval; } +bool SwPostItAnkorPrimitive::operator==( const drawinglayer::primitive2d::BasePrimitive2D& rPrimitive ) const +{ + if(drawinglayer::primitive2d::DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) + { + const SwPostItAnkorPrimitive& rCompare = static_cast< const SwPostItAnkorPrimitive& >(rPrimitive); + + return (getTriangle() == rCompare.getTriangle() + && getLine() == rCompare.getLine() + && getLineTop() == rCompare.getLineTop() + && getAnkorState() == rCompare.getAnkorState() + && getColor() == rCompare.getColor() + && getLogicLineWidth() == rCompare.getLogicLineWidth() + && getShadow() == rCompare.getShadow() + && getLineSolid() == rCompare.getLineSolid()); + } + + return false; +} + +ImplPrimitrive2DIDBlock(SwPostItAnkorPrimitive, PRIMITIVE2D_ID_SWPOSTITANKORPRIMITIVE) + /****** SwPostItAnkor ***********************************************************/ void SwPostItAnkor::implEnsureGeometry() @@ -2102,100 +2389,6 @@ void SwPostItAnkor::implResetGeometry() maLineTop.clear(); } -void SwPostItAnkor::implDrawGeometry(OutputDevice& rOutputDevice, Color aColor, double fOffX, double fOffY) -{ - basegfx::B2DPolygon aTri(maTriangle); - basegfx::B2DPolygon aLin(maLine); - const Polygon aLinTop(maLineTop); - - if(0.0 != fOffX || 0.0 != fOffY) - { - // transform polygons - basegfx::B2DHomMatrix aTranslate; - aTranslate.set(0, 2, fOffX); - aTranslate.set(1, 2, fOffY); - - aTri.transform(aTranslate); - aLin.transform(aTranslate); - } - - switch (mAnkorState) - { - case AS_TRI: - { - rOutputDevice.SetLineColor(); - rOutputDevice.SetFillColor(aColor); - rOutputDevice.DrawPolygon(Polygon(aTri)); - break; - } - case AS_ALL: - { - rOutputDevice.SetLineColor(); - rOutputDevice.SetFillColor(aColor); - //rOutputDevice.DrawTransparent(Polygon(aTri), 50); - rOutputDevice.DrawPolygon(Polygon(aTri)); - - // draw line - rOutputDevice.SetLineColor(aColor); - rOutputDevice.SetFillColor(); - rOutputDevice.DrawPolyLine(Polygon(aLin), mLineInfo); - rOutputDevice.DrawPolyLine(aLinTop,LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); - break; - } - case AS_START: - { - rOutputDevice.SetLineColor(); - rOutputDevice.SetFillColor(aColor); - rOutputDevice.DrawPolygon(Polygon(aTri)); - // draw line - rOutputDevice.SetLineColor(aColor); - rOutputDevice.SetFillColor(); - rOutputDevice.DrawPolyLine(Polygon(aLin), mLineInfo); - break; - } - case AS_END: - { - // draw line - rOutputDevice.SetLineColor(aColor); - rOutputDevice.SetFillColor(); - rOutputDevice.DrawPolyLine(aLinTop,LineInfo(LINE_SOLID,ANKORLINE_WIDTH*15)); - break; - } - } -} - -Color SwPostItAnkor::implBlendColor(const Color aOriginal, sal_Int16 nChange) -{ - if(0 != nChange) - { - sal_Int16 nR(aOriginal.GetRed() + nChange); - sal_Int16 nG(aOriginal.GetGreen() + nChange); - sal_Int16 nB(aOriginal.GetBlue() + nChange); - - // truncate R, G and B - if(nR > 0xff) - nR = 0xff; - else if(nR < 0) - nR = 0; - - if(nG > 0xff) - nG = 0xff; - else if(nG < 0) - nG = 0; - - if(nB > 0xff) - nB = 0xff; - else if(nB < 0) - nB = 0; - - return Color((sal_uInt8)nR, (sal_uInt8)nG, (sal_uInt8)nB); - } - else - { - return aOriginal; - } -} - SwPostItAnkor::SwPostItAnkor(const basegfx::B2DPoint& rBasePos, const basegfx::B2DPoint& rSecondPos, const basegfx::B2DPoint& rThirdPos, @@ -2204,8 +2397,8 @@ SwPostItAnkor::SwPostItAnkor(const basegfx::B2DPoint& rBasePos, const basegfx::B2DPoint& rSixthPos, const basegfx::B2DPoint& rSeventhPos, Color aBaseColor, - const LineInfo &aLineInfo, - bool bShadowedEffect) + bool bShadowedEffect, + bool bLineSolid) : OverlayObjectWithBasePosition(rBasePos, aBaseColor), maSecondPosition(rSecondPos), maThirdPosition(rThirdPos), @@ -2216,93 +2409,36 @@ SwPostItAnkor::SwPostItAnkor(const basegfx::B2DPoint& rBasePos, maTriangle(), maLine(), maLineTop(), - mLineInfo(aLineInfo), mHeight(0), + mAnkorState(AS_ALL), mbShadowedEffect(bShadowedEffect), - mAnkorState(AS_ALL) + mbLineSolid(bLineSolid) { - if (mLineInfo.GetStyle()==LINE_DASH) - { - mLineInfo.SetDistance( 3 * 15); - mLineInfo.SetDashLen( 5 * 15); - mLineInfo.SetDashCount(100); - } - //mbAllowsAnimation = sal_True; + //mbAllowsAnimation = true; } SwPostItAnkor::~SwPostItAnkor() { } -void SwPostItAnkor::Trigger(sal_uInt32 /*nTime*/) -{ -} - -void SwPostItAnkor::drawGeometry(OutputDevice& rOutputDevice) +drawinglayer::primitive2d::Primitive2DSequence SwPostItAnkor::createOverlayObjectPrimitive2DSequence() { implEnsureGeometry(); - if(getShadowedEffect()) - { - // calculate one pixel offset - const basegfx::B2DVector aOnePixelOffset(rOutputDevice.GetInverseViewTransformation() * basegfx::B2DVector(1.0, 1.0)); - const Color aLighterColor(implBlendColor(getBaseColor(), 20)); - const Color aDarkerColor(implBlendColor(getBaseColor(), -20)); - - // draw top-left - implDrawGeometry(rOutputDevice, aLighterColor, -aOnePixelOffset.getX(), -aOnePixelOffset.getY()); - - // draw bottom-right - implDrawGeometry(rOutputDevice, aDarkerColor, aOnePixelOffset.getX(), aOnePixelOffset.getY()); - } - - // draw original - implDrawGeometry(rOutputDevice, getBaseColor(), 0.0, 0.0); -} - -void SwPostItAnkor::createBaseRange(OutputDevice& rOutputDevice) -{ - // get range from geometry - implEnsureGeometry(); - maBaseRange = basegfx::tools::getRange(maTriangle); - maBaseRange.expand(basegfx::tools::getRange(maLine)); - maBaseRange.expand(basegfx::tools::getRange(maLineTop)); - - /* - basegfx::B2DHomMatrix aMatrix; - aMatrix.translate(-maTriangle.getB2DPoint(0).getX(),-maTriangle.getB2DPoint(0).getY()); - aMatrix.scale(1.0,-1.0); - aMatrix.translate(maTriangle.getB2DPoint(0).getX(),maTriangle.getB2DPoint(0).getY()); - aMatrix.translate(0,(mHeight*-1) + 13 * 15 ); - basegfx::B2DRange MyRange(basegfx::tools::getRange(maTriangle)); - MyRange.transform(aMatrix); - maBaseRange.expand(MyRange); - */ - - // expand range for thick lines and shadowed geometry - double fExpand(0.0); + const drawinglayer::primitive2d::Primitive2DReference aReference( + new SwPostItAnkorPrimitive( + maTriangle, + maLine, + maLineTop, + GetAnkorState(), + getBaseColor().getBColor(), + ANKORLINE_WIDTH * 15.0, + getShadowedEffect(), + getLineSolid())); - // take fat line into account - if(0 != mLineInfo.GetWidth()) - { - // expand range for logic half line width - fExpand += static_cast< double >(mLineInfo.GetWidth()) / 2.0; - } - - // take shadowed into account - if(getShadowedEffect()) - { - const basegfx::B2DVector aOnePixelOffset(rOutputDevice.GetInverseViewTransformation() * basegfx::B2DVector(1.0, 1.0)); - fExpand += ::std::max(aOnePixelOffset.getX(), aOnePixelOffset.getY()); - } - - if(0.0 != fExpand) - { - maBaseRange.grow(fExpand); - } + return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1); } - void SwPostItAnkor::SetAllPosition(const basegfx::B2DPoint& rPoint1, const basegfx::B2DPoint& rPoint2, const basegfx::B2DPoint& rPoint3, @@ -2311,16 +2447,25 @@ void SwPostItAnkor::SetAllPosition(const basegfx::B2DPoint& rPoint1, const basegfx::B2DPoint& rPoint6, const basegfx::B2DPoint& rPoint7) { - maBasePosition = rPoint1; - maSecondPosition = rPoint2; - maThirdPosition = rPoint3; - maFourthPosition = rPoint4; - maFifthPosition = rPoint5; - maSixthPosition = rPoint6; - maSeventhPosition = rPoint7; + if(rPoint1 != getBasePosition() + || rPoint2 != GetSecondPosition() + || rPoint3 != GetThirdPosition() + || rPoint4 != GetFourthPosition() + || rPoint5 != GetFifthPosition() + || rPoint6 != GetSixthPosition() + || rPoint7 != GetSeventhPosition()) + { + maBasePosition = rPoint1; + maSecondPosition = rPoint2; + maThirdPosition = rPoint3; + maFourthPosition = rPoint4; + maFifthPosition = rPoint5; + maSixthPosition = rPoint6; + maSeventhPosition = rPoint7; - implResetGeometry(); - objectChange(); + implResetGeometry(); + objectChange(); + } } void SwPostItAnkor::SetSixthPosition(const basegfx::B2DPoint& rNew) @@ -2346,54 +2491,28 @@ void SwPostItAnkor::SetSeventhPosition(const basegfx::B2DPoint& rNew) void SwPostItAnkor::SetTriPosition(const basegfx::B2DPoint& rPoint1,const basegfx::B2DPoint& rPoint2,const basegfx::B2DPoint& rPoint3, const basegfx::B2DPoint& rPoint4,const basegfx::B2DPoint& rPoint5) { - maBasePosition = rPoint1; - maSecondPosition = rPoint2; - maThirdPosition = rPoint3; - maFourthPosition = rPoint4; - maFifthPosition = rPoint5; - - implResetGeometry(); - objectChange(); -} - -void SwPostItAnkor::transform(const basegfx::B2DHomMatrix& rMatrix) -{ - if(!rMatrix.isIdentity()) + if(rPoint1 != getBasePosition() + || rPoint2 != GetSecondPosition() + || rPoint3 != GetThirdPosition() + || rPoint4 != GetFourthPosition() + || rPoint5 != GetFifthPosition()) { - // transform base position - OverlayObjectWithBasePosition::transform(rMatrix); - - maSecondPosition = rMatrix * GetSecondPosition(); - maThirdPosition = rMatrix * GetThirdPosition(); - maFourthPosition = rMatrix * GetFourthPosition(); - maFifthPosition = rMatrix * GetFifthPosition(); - maSixthPosition = rMatrix * GetSixthPosition(); - maSeventhPosition = rMatrix * GetSeventhPosition(); + maBasePosition = rPoint1; + maSecondPosition = rPoint2; + maThirdPosition = rPoint3; + maFourthPosition = rPoint4; + maFifthPosition = rPoint5; implResetGeometry(); objectChange(); } } -void SwPostItAnkor::SetLineInfo(const LineInfo &aLineInfo) +void SwPostItAnkor::setLineSolid(bool bNew) { - if (aLineInfo != mLineInfo) + if(bNew != getLineSolid()) { - mLineInfo = aLineInfo; - if (mLineInfo.GetStyle()==LINE_DASH) - { - mLineInfo.SetDistance( 3 * 15); - mLineInfo.SetDashLen( 5 * 15); - mLineInfo.SetDashCount(100); - } - //remove and add overlayobject, so it is the last one inside the manager to draw - //therefore this line is on top - sdr::overlay::OverlayManager* pMgr = getOverlayManager(); - if (pMgr) - { - pMgr->remove(*this); - pMgr->add(*this); - } + mbLineSolid = bNew; objectChange(); } } diff --git a/sw/source/ui/docvw/romenu.cxx b/sw/source/ui/docvw/romenu.cxx index 437f7eabb25c..50776ef80f11 100644 --- a/sw/source/ui/docvw/romenu.cxx +++ b/sw/source/ui/docvw/romenu.cxx @@ -34,12 +34,8 @@ #include <tools/urlobj.hxx> -#ifndef _GRAPH_HXX //autogen #include <vcl/graph.hxx> -#endif -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <sot/formats.hxx> #include <svtools/eitem.hxx> #include <svtools/stritem.hxx> @@ -61,30 +57,18 @@ #include <fmturl.hxx> #include <fmtinfmt.hxx> #include <docsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <wrtsh.hxx> #include <viewopt.hxx> #include <swmodule.hxx> #include <romenu.hxx> #include <pagedesc.hxx> -#ifndef _MODCFG_HXX #include <modcfg.hxx> -#endif -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _HELPID_H #include <helpid.h> -#endif -#ifndef _DOCVW_HRC #include <docvw.hrc> -#endif -#ifndef _DOCVW_HRC #include <docvw.hrc> -#endif #include <com/sun/star/ui/dialogs/XFilePicker.hpp> #include <com/sun/star/ui/dialogs/XFilterManager.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> @@ -92,6 +76,7 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; +using namespace ::com::sun::star; using namespace ::com::sun::star::ui::dialogs; using namespace ::sfx2; @@ -415,22 +400,13 @@ static void lcl_GetPreferedExtension( String &rExt, const Graphic &rGrf ) String SwReadOnlyPopup::SaveGraphic( USHORT nId ) { -/* SvtPathOptions aPathOpt; - String sGrfPath( aPathOpt.GetGraphicPath() ); - - FileDialogHelper aDlgHelper( TemplateDescription::FILESAVE_SIMPLE, 0 ); - Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker(); - -// aExpDlg.SetHelpId(HID_FILEDLG_ROMENU); - INetURLObject aPath; - aPath.SetSmartURL( sGrfPath);*/ //Namen der Grafik herausfischen. String aName; if ( MN_READONLY_SAVEBACKGROUND == nId ) { if ( pItem->GetGraphicLink() ) - aName = *pItem->GetGraphicLink(); + sGrfName = *pItem->GetGraphicLink(); ((SvxBrushItem*)pItem)->SetDoneLink( Link() ); const Graphic *pGrf = pItem->GetGraphic( rView.GetDocShell() ); if ( pGrf ) @@ -442,12 +418,10 @@ String SwReadOnlyPopup::SaveGraphic( USHORT nId ) else return aEmptyStr; } - else - aName = sGrfName; - return ExportGraphic( aGraphic, sGrfName, aName ); + return ExportGraphic( aGraphic, sGrfName ); } -String ExportGraphic( const Graphic &rGraphic, const String &rGrfName, const String &rName ) +String ExportGraphic( const Graphic &rGraphic, const String &rGrfName ) { SvtPathOptions aPathOpt; String sGrfPath( aPathOpt.GetGraphicPath() ); @@ -457,16 +431,16 @@ String ExportGraphic( const Graphic &rGraphic, const String &rGrfName, const Str // aExpDlg.SetHelpId(HID_FILEDLG_ROMENU); INetURLObject aPath; - aPath.SetSmartURL( rName ); + aPath.SetSmartURL( sGrfPath ); //Namen der Grafik herausfischen. String aName = rGrfName; + aDlgHelper.SetTitle( SW_RESSTR(STR_EXPORT_GRAFIK_TITLE)); + aDlgHelper.SetDisplayDirectory( aPath.GetMainURL(INetURLObject::DECODE_TO_IURI) ); INetURLObject aURL; aURL.SetSmartURL( aName ); - aPath.Append( aURL.GetName() ); - xFP->setDisplayDirectory( aPath.GetMainURL(INetURLObject::DECODE_TO_IURI) ); - xFP->setTitle( SW_RESSTR(STR_EXPORT_GRAFIK_TITLE)); + aDlgHelper.SetFileName( aURL.GetName() ); GraphicFilter& rGF = *GetGrfFilter(); const USHORT nCount = rGF.GetExportFormatCount(); diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx index 51c9018315ee..f6fb3f596a35 100644 --- a/sw/source/ui/envelp/envfmt.cxx +++ b/sw/source/ui/envelp/envfmt.cxx @@ -179,11 +179,11 @@ SwEnvFmtPage::SwEnvFmtPage(Window* pParent, const SfxItemSet& rSet) : aSizeFormatBox .SetSelectHdl(LINK(this, SwEnvFmtPage, FormatHdl)); // aSizeFormatBox - for (USHORT i = SVX_PAPER_A3; i <= SVX_PAPER_KAI32BIG; i++) + for (USHORT i = PAPER_A3; i <= PAPER_KAI32BIG; i++) { - if (i != SVX_PAPER_USER) + if (i != PAPER_USER) { - String aPaperName = SvxPaperInfo::GetName((SvxPaper) i), + String aPaperName = SvxPaperInfo::GetName((Paper) i), aEntryName; USHORT nPos = 0; @@ -200,8 +200,8 @@ SwEnvFmtPage::SwEnvFmtPage(Window* pParent, const SfxItemSet& rSet) : aIDs.Insert((USHORT) i, nPos); } } - aSizeFormatBox.InsertEntry(SvxPaperInfo::GetName(SVX_PAPER_USER)); - aIDs.Insert((USHORT) SVX_PAPER_USER, aIDs.Count()); + aSizeFormatBox.InsertEntry(SvxPaperInfo::GetName(PAPER_USER)); + aIDs.Insert((USHORT) PAPER_USER, aIDs.Count()); } @@ -228,14 +228,14 @@ IMPL_LINK_INLINE_START( SwEnvFmtPage, ModifyHdl, Edit *, pEdit ) if (pEdit == &aSizeWidthField || pEdit == &aSizeHeightField) { - SvxPaper ePaper = SvxPaperInfo::GetPaper( + Paper ePaper = SvxPaperInfo::GetSvxPaper( Size(lHeight, lWidth), MAP_TWIP, TRUE); for (USHORT i = 0; i < aIDs.Count(); i++) if (aIDs[i] == (USHORT)ePaper) aSizeFormatBox.SelectEntryPos(i); // Benutzergroesse merken - if (aIDs[aSizeFormatBox.GetSelectEntryPos()] == (USHORT)SVX_PAPER_USER) + if (aIDs[aSizeFormatBox.GetSelectEntryPos()] == (USHORT)PAPER_USER) { lUserW = lWidth ; lUserH = lHeight; @@ -470,9 +470,9 @@ IMPL_LINK( SwEnvFmtPage, FormatHdl, ListBox *, EMPTYARG ) long lAddrFromTop; USHORT nPaper = aIDs[aSizeFormatBox.GetSelectEntryPos()]; - if (nPaper != (USHORT)SVX_PAPER_USER) + if (nPaper != (USHORT)PAPER_USER) { - Size aSz = SvxPaperInfo::GetPaperSize((SvxPaper)nPaper); + Size aSz = SvxPaperInfo::GetPaperSize((Paper)nPaper); lWidth = Max(aSz.Width(), aSz.Height()); lHeight = Min(aSz.Width(), aSz.Height()); } @@ -581,7 +581,7 @@ void SwEnvFmtPage::FillItem(SwEnvItem& rItem) rItem.lSendFromTop = static_cast< sal_Int32 >(GetFldVal(aSendTopField )); USHORT nPaper = aIDs[aSizeFormatBox.GetSelectEntryPos()]; - if (nPaper == (USHORT)SVX_PAPER_USER) + if (nPaper == (USHORT)PAPER_USER) { long lWVal = static_cast< long >(GetFldVal(aSizeWidthField )); long lHVal = static_cast< long >(GetFldVal(aSizeHeightField)); @@ -590,8 +590,8 @@ void SwEnvFmtPage::FillItem(SwEnvItem& rItem) } else { - long lWVal = SvxPaperInfo::GetPaperSize((SvxPaper)nPaper).Width (); - long lHVal = SvxPaperInfo::GetPaperSize((SvxPaper)nPaper).Height(); + long lWVal = SvxPaperInfo::GetPaperSize((Paper)nPaper).Width (); + long lHVal = SvxPaperInfo::GetPaperSize((Paper)nPaper).Height(); rItem.lWidth = Max(lWVal, lHVal); rItem.lHeight = Min(lWVal, lHVal); } @@ -614,7 +614,7 @@ void __EXPORT SwEnvFmtPage::Reset(const SfxItemSet& rSet) { const SwEnvItem& rItem = (const SwEnvItem&) rSet.Get(FN_ENVELOP); - SvxPaper ePaper = SvxPaperInfo::GetPaper( + Paper ePaper = SvxPaperInfo::GetSvxPaper( Size( Min(rItem.lWidth, rItem.lHeight), Max(rItem.lWidth, rItem.lHeight)), MAP_TWIP, TRUE); for (USHORT i = 0; i < (USHORT) aIDs.Count(); i++) diff --git a/sw/source/ui/envelp/envimg.cxx b/sw/source/ui/envelp/envimg.cxx index aada68947ceb..fa1744ca1ae5 100644 --- a/sw/source/ui/envelp/envimg.cxx +++ b/sw/source/ui/envelp/envimg.cxx @@ -119,8 +119,9 @@ SwEnvItem::SwEnvItem() : aSendText = MakeSender(); lSendFromLeft = 566; // 1 cm lSendFromTop = 566; // 1 cm - lWidth = lC65Width; - lHeight = lC65Height; + Size aEnvSz = SvxPaperInfo::GetPaperSize(PAPER_ENV_C65); + lWidth = aEnvSz.Width(); + lHeight = aEnvSz.Height(); eAlign = ENV_HOR_LEFT; bPrintFromAbove = TRUE; lShiftRight = 0; diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx index 7b1170b35efe..fd9caec98c24 100644 --- a/sw/source/ui/envelp/mailmrge.cxx +++ b/sw/source/ui/envelp/mailmrge.cxx @@ -35,44 +35,27 @@ #endif -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif +#include <vcl/svapp.hxx> #include <tools/urlobj.hxx> #include <svtools/urihelper.hxx> #include <svtools/pathoptions.hxx> #include <goodies/mailenum.hxx> #include <svx/svxdlg.hxx> #include <svx/dialogs.hrc> -#ifndef _HELPID_H #include <helpid.h> -#endif -#ifndef _VIEW_HXX #include <view.hxx> -#endif -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif -#ifndef IDOCUMENTDEVICEACCESS_HXX_INCLUDED #include <IDocumentDeviceAccess.hxx> -#endif #include <wrtsh.hxx> -#ifndef _DBMGR_HXX #include <dbmgr.hxx> -#endif #include <dbui.hxx> #include <prtopt.hxx> #include <swmodule.hxx> -#ifndef _MODCFG_HXX #include <modcfg.hxx> -#endif #include <mailmergehelper.hxx> -#ifndef _ENVELP_HRC #include <envelp.hrc> -#endif -#ifndef _MAILMRGE_HRC #include <mailmrge.hrc> -#endif #include <mailmrge.hxx> #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> @@ -83,9 +66,7 @@ #include <com/sun/star/sdbcx/XRowLocate.hpp> #include <com/sun/star/sdb/XResultSetAccess.hpp> #include <com/sun/star/sdbc/XDataSource.hpp> -#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/unohlp.hxx> -#endif #include <comphelper/processfactory.hxx> #include <com/sun/star/form/XFormController.hpp> #include <cppuhelper/implbase1.hxx> @@ -95,6 +76,8 @@ #include <unomid.h> +#include <algorithm> + using namespace rtl; using namespace ::com::sun::star; using namespace ::com::sun::star::container; @@ -384,7 +367,11 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell, aPrinterRB.SetClickHdl(aLk); aMailingRB.SetClickHdl(aLk); aFileRB.SetClickHdl(aLk); - OutputTypeHdl(&aPrinterRB); + + //#i63267# printing might be disabled + bool bIsPrintable = !Application::GetSettings().GetMiscSettings().GetDisablePrinting(); + aPrinterRB.Enable(bIsPrintable); + OutputTypeHdl(bIsPrintable ? &aPrinterRB : &aFileRB); aLk = LINK(this, SwMailMergeDlg, FilenameHdl); aGenerateFromDataBaseCB.SetClickHdl( aLk ); @@ -402,6 +389,8 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell, aLk = LINK(this, SwMailMergeDlg, ModifyHdl); aFromNF.SetModifyHdl(aLk); aToNF.SetModifyHdl(aLk); + aFromNF.SetMax(SAL_MAX_INT32); + aToNF.SetMax(SAL_MAX_INT32); SwNewDBMgr* pNewDBMgr = rSh.GetNewDBMgr(); if(_xConnection.is()) @@ -783,19 +772,16 @@ bool SwMailMergeDlg::ExecQryShell() if (aFromRB.IsChecked()) // Liste Einfuegen { - ULONG nStart = static_cast< ULONG >(aFromNF.GetValue()); - ULONG nEnd = static_cast< ULONG >(aToNF.GetValue()); + // Safe: the maximal value of the fields is limited + sal_Int32 nStart = sal::static_int_cast<sal_Int32>(aFromNF.GetValue()); + sal_Int32 nEnd = sal::static_int_cast<sal_Int32>(aToNF.GetValue()); if (nEnd < nStart) - { - ULONG nZw = nEnd; - nEnd = nStart; - nStart = nZw; - } + std::swap(nEnd, nStart); m_aSelection.realloc(nEnd - nStart + 1); Any* pSelection = m_aSelection.getArray(); - for (ULONG i = nStart; i <= nEnd; ++i, ++pSelection) + for (sal_Int32 i = nStart; i != nEnd; ++i, ++pSelection) *pSelection <<= i; } else if (aAllRB.IsChecked() ) diff --git a/sw/source/ui/fldui/flddinf.hxx b/sw/source/ui/fldui/flddinf.hxx index 7f1b16c7abc1..2b72b1aec33a 100644 --- a/sw/source/ui/fldui/flddinf.hxx +++ b/sw/source/ui/fldui/flddinf.hxx @@ -45,7 +45,7 @@ /*-------------------------------------------------------------------- Beschreibung: --------------------------------------------------------------------*/ -class SfxDocumentInfoItem; + class SwFldDokInfPage : public SwFldPage { FixedText aTypeFT; diff --git a/sw/source/ui/fldui/fldmgr.cxx b/sw/source/ui/fldui/fldmgr.cxx index df77741d5cd7..f35efbe41253 100644 --- a/sw/source/ui/fldui/fldmgr.cxx +++ b/sw/source/ui/fldui/fldmgr.cxx @@ -31,9 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#ifndef _CMDID_H #include <cmdid.h> -#endif #include <hintids.hxx> #include <svtools/stritem.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -63,21 +61,15 @@ #include <svtools/zforlist.hxx> #include <svtools/zformat.hxx> #include <vcl/mnemonic.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <wrtsh.hxx> // Actives Fenster #include <doc.hxx> // Actives Fenster -#ifndef _DOCSH_HXX #include <docsh.hxx> // Actives Fenster -#endif #include <swmodule.hxx> #include <charatr.hxx> #include <fmtinfmt.hxx> #include <cellatr.hxx> -#ifndef _DBMGR_HXX #include <dbmgr.hxx> -#endif #include <shellres.hxx> #include <fldbas.hxx> #include <docufld.hxx> @@ -92,9 +84,8 @@ #include <fldmgr.hxx> #include <crsskip.hxx> #include <flddropdown.hxx> -#ifndef _FLDUI_HRC #include <fldui.hrc> -#endif +#include <tox.hxx> using rtl::OUString; using namespace com::sun::star::uno; @@ -1552,6 +1543,27 @@ void SwFldMgr::UpdateCurFld(ULONG nFormat, bSetPar1 = bSetPar2 = FALSE; } break; + case TYP_AUTHORITY : + { + //#i99069# changes to a bibliography field should change the field type + SwAuthorityField* pAuthorityField = static_cast<SwAuthorityField*>(pTmpFld); + SwAuthorityFieldType* pAuthorityType = static_cast<SwAuthorityFieldType*>(pType); + SwAuthEntry aTempEntry; + for( USHORT i = 0; i < AUTH_FIELD_END; ++i ) + aTempEntry.SetAuthorField( (ToxAuthorityField)i, + rPar1.GetToken( i, TOX_STYLE_DELIMITER )); + if( pAuthorityType->ChangeEntryContent( &aTempEntry ) ) + { + pType->UpdateFlds(); + pSh->SetModified(); + } + + if( aTempEntry.GetAuthorField( AUTH_FIELD_IDENTIFIER ) == + pAuthorityField->GetFieldText( AUTH_FIELD_IDENTIFIER ) ) + bSetPar1 = FALSE; //otherwise it's a new or changed entry, the field needs to be updated + bSetPar2 = FALSE; + } + break; } // Format setzen diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index 24c025fb55d8..b288d51cf520 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -265,7 +265,7 @@ void SwFldRefPage::Reset(const SfxItemSet& ) } // Endnoten: - if( pSh->HasFtns(TRUE) ) + if ( pSh->HasFtns(true) ) { nPos = aTypeLB.InsertEntry(sEndnoteTxt); aTypeLB.SetEntryData(nPos, (void*)REFFLDFLAG_ENDNOTE); @@ -576,7 +576,7 @@ void SwFldRefPage::UpdateSubType() { aSelectionLB.SetStyle(aSelectionLB.GetStyle() & ~WB_SORT); SwSeqFldList aArr; - USHORT nCnt = pSh->GetSeqFtnList( aArr, TRUE ); + USHORT nCnt = pSh->GetSeqFtnList( aArr, true ); for( USHORT n = 0; n < nCnt; ++n ) { @@ -936,7 +936,7 @@ BOOL SwFldRefPage::FillItemSet(SfxItemSet& ) nSubType = REF_ENDNOTE; aName.Erase(); - if (pSh->GetSeqFtnList(aArr, TRUE) && aArr.SeekEntry(aElem, &nPos)) + if (pSh->GetSeqFtnList(aArr, true) && aArr.SeekEntry(aElem, &nPos)) { aVal = String::CreateFromInt32( aArr[nPos]->nSeqNo ); diff --git a/sw/source/ui/frmdlg/colex.cxx b/sw/source/ui/frmdlg/colex.cxx index 3423e6f5f0e1..4b7a12868328 100644 --- a/sw/source/ui/frmdlg/colex.cxx +++ b/sw/source/ui/frmdlg/colex.cxx @@ -328,7 +328,7 @@ SwColumnOnlyExample::SwColumnOnlyExample( Window* pParent, const ResId& rResId) SetBorderStyle( WINDOW_BORDER_MONO ); - m_aFrmSize = Size(11907, 16433);// DIN A4 + m_aFrmSize = SvxPaperInfo::GetPaperSize(PAPER_A4);// DIN A4 ::FitToActualSize(m_aCols, (USHORT)m_aFrmSize.Width()); long nHeight = m_aFrmSize.Height(); diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx index 03dd5fa36fdd..a9df9762ad92 100644 --- a/sw/source/ui/frmdlg/column.cxx +++ b/sw/source/ui/frmdlg/column.cxx @@ -230,6 +230,8 @@ SwColumnDlg::SwColumnDlg(Window* pParent, SwWrtShell& rSh) : //#i80458# if no columns can be set then disable OK if( !aApplyToLB.GetEntryCount() ) aOK.Enable( sal_False ); + //#i97810# set focus to the TabPage + pTabPage->ActivateColumnControl(); } /*-------------------------------------------------------------------- diff --git a/sw/source/ui/inc/colex.hxx b/sw/source/ui/inc/colex.hxx index 9d9e61904c78..eca121c4e556 100644 --- a/sw/source/ui/inc/colex.hxx +++ b/sw/source/ui/inc/colex.hxx @@ -31,6 +31,7 @@ #define _COLEX_HXX #include <svx/pagectrl.hxx> +#include <svx/paperinf.hxx> #include "swdllapi.h" #include <fmtclds.hxx> #include "frmatr.hxx" @@ -46,7 +47,7 @@ class SW_DLLPUBLIC SwPageExample : public SvxPageWindow public: SwPageExample(Window* pPar, const ResId& rResId ) : SvxPageWindow(pPar, rResId ) - {SetSize(Size(11907, 16433));/*DIN A4*/} + {SetSize(SvxPaperInfo::GetPaperSize(PAPER_A4));/*DIN A4*/} void UpdateExample( const SfxItemSet& rSet ); }; diff --git a/sw/source/ui/inc/column.hxx b/sw/source/ui/inc/column.hxx index 491a603d52ab..a8e6597cf757 100644 --- a/sw/source/ui/inc/column.hxx +++ b/sw/source/ui/inc/column.hxx @@ -223,6 +223,7 @@ public: void ShowBalance(BOOL bShow) {aBalanceColsCB.Show(bShow);} void SetInSection(BOOL bSet); + void ActivateColumnControl() {aCLNrEdt.GrabFocus();} }; #endif diff --git a/sw/source/ui/inc/convert.hxx b/sw/source/ui/inc/convert.hxx index bce24ac08018..6e550b4c9607 100644 --- a/sw/source/ui/inc/convert.hxx +++ b/sw/source/ui/inc/convert.hxx @@ -63,14 +63,14 @@ class SwConvertTableDlg: public SfxModalDialog FixedText aRepeatHeaderAfterFT; TextControlCombo aRepeatHeaderCombo; + FixedLine aOptionsFL; CheckBox aDontSplitCB; CheckBox aBorderCB; - FixedLine aOptionsFL; + PushButton aAutoFmtBtn; OKButton aOkBtn; CancelButton aCancelBtn; HelpButton aHelpBtn; - PushButton aAutoFmtBtn; String sConvertTextTable; SwTableAutoFmt* pTAutoFmt; diff --git a/sw/source/ui/inc/hidfunc.h b/sw/source/ui/inc/hidfunc.h index a85d5181031a..b2b961a882d4 100644 --- a/sw/source/ui/inc/hidfunc.h +++ b/sw/source/ui/inc/hidfunc.h @@ -209,6 +209,7 @@ #define HID_SET_STANDARD_FONTS 1442 #define HID_COPY 1102 #define HID_PASTE 1113 +#define HID_PASTEUNFORMATTED 1115 #define HID_PASTESPECIAL 1114 #define HID_CUT 1103 #define HID_FLIP_HORZ_GRAFIC 1425 diff --git a/sw/source/ui/inc/swdtflvr.hxx b/sw/source/ui/inc/swdtflvr.hxx index 5cd5a2a319e1..d2a5a2ed4d2b 100644 --- a/sw/source/ui/inc/swdtflvr.hxx +++ b/sw/source/ui/inc/swdtflvr.hxx @@ -193,6 +193,7 @@ public: static BOOL IsPasteSpecial( const SwWrtShell& rWrtShell, const TransferableDataHelper& ); + static int PasteUnformatted( SwWrtShell& rSh, TransferableDataHelper& ); static int PasteSpecial( SwWrtShell& rSh, TransferableDataHelper&, ULONG& rFormatUsed ); static int PasteFormat( SwWrtShell& rSh, TransferableDataHelper& rData, ULONG nFormat ); diff --git a/sw/source/ui/inc/table.hrc b/sw/source/ui/inc/table.hrc index 77ac72c12c33..0903a95453ad 100644 --- a/sw/source/ui/inc/table.hrc +++ b/sw/source/ui/inc/table.hrc @@ -33,7 +33,7 @@ #define DLG_INSERT_TABLE RC_TABLE_BEGIN #define DLG_FORMAT_TABLE (RC_TABLE_BEGIN + 1) #define DLG_CONV_TEXT_TABLE (RC_TABLE_BEGIN + 2) -#define DLG_INS_ROW_COL (RC_TABLE_BEGIN + 3) +//#define DLG_INS_ROW_COL (RC_TABLE_BEGIN + 3) moved to svx #define DLG_ROW_HEIGHT (RC_TABLE_BEGIN + 4) #define DLG_SPLIT (RC_TABLE_BEGIN + 5) #define DLG_COL_WIDTH (RC_TABLE_BEGIN + 6) diff --git a/sw/source/ui/inc/uivwimp.hxx b/sw/source/ui/inc/uivwimp.hxx index 65b8d0b9b95b..d23da67e4209 100644 --- a/sw/source/ui/inc/uivwimp.hxx +++ b/sw/source/ui/inc/uivwimp.hxx @@ -153,7 +153,7 @@ public: SfxObjectShellRef & GetTmpSelectionDoc() { return xTmpSelDocSh; } - SfxObjectShellRef& GetEmbeddedObjRef() { return (SfxObjectShellRef&)(long&)aEmbeddedObjRef; } + SfxObjectShellRef& GetEmbeddedObjRef() { return *boost::addressof(aEmbeddedObjRef); } void AddTransferable(SwTransferable& rTransferable); diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx index 70e509972ddb..5656f6df1ab4 100644 --- a/sw/source/ui/inc/wrtsh.hxx +++ b/sw/source/ui/inc/wrtsh.hxx @@ -157,6 +157,7 @@ public: void SetInsMode( BOOL bOn = TRUE ); void ToggleInsMode() { SetInsMode( !bIns ); } BOOL IsInsMode() const { return bIns; } + void SetRedlineModeAndCheckInsMode( USHORT eMode ); void EnterSelFrmMode(const Point *pStartDrag = 0); void LeaveSelFrmMode(); diff --git a/sw/source/ui/index/cnttab.src b/sw/source/ui/index/cnttab.src index 1bccc6c27765..8b84ca3d2b92 100644 --- a/sw/source/ui/index/cnttab.src +++ b/sw/source/ui/index/cnttab.src @@ -342,12 +342,12 @@ TabPage TP_TOX_SELECT CheckBox CB_FROMFILE { Pos = MAP_APPFONT ( 136 , 124 ) ; - Size = MAP_APPFONT ( 63 , 10 ) ; + Size = MAP_APPFONT ( 115 , 10 ) ; Text [ en-US ] = "~Concordance file"; }; MenuButton MB_AUTOMARK { - Pos = MAP_APPFONT ( 201 , 122 ) ; + Pos = MAP_APPFONT ( 136 , 137 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; ButtonMenu = Menu @@ -486,32 +486,32 @@ TabPage TP_TOX_SELECT }; FixedLine FL_SORTOPTIONS { - Pos = MAP_APPFONT ( 6, 150) ; + Pos = MAP_APPFONT ( 6, 153) ; Size = MAP_APPFONT ( 248, 8 ) ; Text [ en-US ] = "Sort"; }; FixedText FT_LANGUAGE { - Pos = MAP_APPFONT ( 12, 163) ; + Pos = MAP_APPFONT ( 12, 166) ; Size = MAP_APPFONT ( 33, 8 ) ; Text [ en-US ] = "Language"; }; ListBox LB_LANGUAGE { - Pos = MAP_APPFONT ( 47, 161) ; + Pos = MAP_APPFONT ( 47, 164) ; Size = MAP_APPFONT ( 80, 50 ) ; Border = TRUE; DropDown = TRUE; }; FixedText FT_SORTALG { - Pos = MAP_APPFONT ( 130, 163) ; + Pos = MAP_APPFONT ( 130, 166) ; Size = MAP_APPFONT ( 50, 8 ) ; Text [ en-US ] = "Key type"; }; ListBox LB_SORTALG { - Pos = MAP_APPFONT ( 201, 161) ; + Pos = MAP_APPFONT ( 201, 164) ; Size = MAP_APPFONT ( 50, 50 ) ; Border = TRUE; DropDown = TRUE; @@ -1049,7 +1049,7 @@ TabPage TP_TOX_STYLES FixedText FT_LEVEL { Pos = MAP_APPFONT ( 11 , 14 ) ; - Size = MAP_APPFONT ( 24 , 8 ) ; + Size = MAP_APPFONT ( 102 , 8 ) ; Text [ en-US ] = "~Levels" ; Left = TRUE ; }; @@ -1064,7 +1064,7 @@ TabPage TP_TOX_STYLES FixedText FT_TEMPLATE { Pos = MAP_APPFONT ( 142 , 14 ) ; - Size = MAP_APPFONT ( 54 , 8 ) ; + Size = MAP_APPFONT ( 102 , 8 ) ; Text [ en-US ] = "Paragraph ~Styles" ; Left = TRUE ; }; diff --git a/sw/source/ui/misc/glshell.cxx b/sw/source/ui/misc/glshell.cxx index 4ad5311307c9..a79e67eec31c 100644 --- a/sw/source/ui/misc/glshell.cxx +++ b/sw/source/ui/misc/glshell.cxx @@ -49,12 +49,8 @@ #include <sfx2/viewfrm.hxx> #include <uitool.hxx> #include <wrtsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif -#ifndef _GLSHELL_HXX #include <glshell.hxx> -#endif #include <doc.hxx> #include <glosdoc.hxx> #include <shellio.hxx> @@ -72,12 +68,8 @@ #define SwWebGlosDocShell #define SwGlosDocShell -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif using namespace ::com::sun::star; diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx index 1f2f9e152c65..3fb0157b89f3 100644 --- a/sw/source/ui/misc/pggrid.cxx +++ b/sw/source/ui/misc/pggrid.cxx @@ -245,6 +245,7 @@ void SwTextGridPage::Reset(const SfxItemSet &rSet) default: pButton = &aCharsGridRB; } pButton->Check(); + aDisplayCB.Check(rGridItem.IsDisplayGrid()); GridTypeHdl(pButton); aSnapToCharsCB.Check(rGridItem.IsSnapToChars()); aLinesPerPageNF.SetValue(rGridItem.GetLines()); @@ -254,7 +255,6 @@ void SwTextGridPage::Reset(const SfxItemSet &rSet) aRubySizeMF.SetValue(aRubySizeMF.Normalize(rGridItem.GetRubyHeight()), FUNIT_TWIP); aCharWidthMF.SetValue(aCharWidthMF.Normalize(rGridItem.GetBaseWidth()), FUNIT_TWIP); aRubyBelowCB.Check(rGridItem.IsRubyTextBelow()); - aDisplayCB.Check(rGridItem.IsDisplayGrid()); aPrintCB.Check(rGridItem.IsPrintGrid()); aColorLB.SelectEntry(rGridItem.GetColor()); } diff --git a/sw/source/ui/ribbar/conrect.cxx b/sw/source/ui/ribbar/conrect.cxx index b079f70ff9a1..e5540dab1c11 100644 --- a/sw/source/ui/ribbar/conrect.cxx +++ b/sw/source/ui/ribbar/conrect.cxx @@ -163,15 +163,17 @@ BOOL ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt) break; case OBJ_CAPTION: - if( bCapVertical && pObj ) + { + SdrCaptionObj* pCaptObj = dynamic_cast<SdrCaptionObj*>(pObj); + if( bCapVertical && pCaptObj ) { - SdrCaptionObj* pCaptObj = (SdrCaptionObj*)pObj; pCaptObj->ForceOutlinerParaObject(); OutlinerParaObject* pOPO = pCaptObj->GetOutlinerParaObject(); if( pOPO && !pOPO->IsVertical() ) pOPO->SetVertical( TRUE ); } - break; + } + break; default:; //prevent warning } } diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx index b4a4491c220d..054220be6707 100755 --- a/sw/source/ui/shells/annotsh.cxx +++ b/sw/source/ui/shells/annotsh.cxx @@ -138,7 +138,7 @@ using namespace ::com::sun::star::i18n; #define SwAnnotationShell -#include <itemdef.hxx> +#include <sfx2/msg.hxx> #include <swslots.hxx> SFX_IMPL_INTERFACE(SwAnnotationShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT)) diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx index 66276be3e4ff..0c17c85dd301 100644 --- a/sw/source/ui/shells/basesh.cxx +++ b/sw/source/ui/shells/basesh.cxx @@ -41,33 +41,22 @@ #include <svx/linkmgr.hxx> #include <svx/htmlmode.hxx> #include <svx/imapdlg.hxx> -#ifndef _SFX_DISPATCH_HXX //autogen #include <sfx2/dispatch.hxx> -#endif #include <sfx2/docfile.hxx> -#ifndef _SFX_VIEWFRM_HXX //autogen #include <sfx2/viewfrm.hxx> -#endif #include <sfx2/request.hxx> #include <svtools/whiter.hxx> #include <svtools/visitem.hxx> #include <sfx2/objitem.hxx> -#ifndef _SFX_DISPATCH_HXX //autogen -#include <sfx2/dispatch.hxx> -#endif #include <svtools/filter.hxx> #include <svx/gallery.hxx> #include <svx/langitem.hxx> #include <svx/clipfmtitem.hxx> #include <svx/contdlg.hxx> -#ifndef _GRAPH_HXX //autogen #include <vcl/graph.hxx> -#endif #include <svx/impgrf.hxx> #include <svtools/slstitm.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svtools/ptitem.hxx> #include <svtools/itemiter.hxx> #include <svtools/stritem.hxx> @@ -86,20 +75,14 @@ #include <fmturl.hxx> #include <fmthdft.hxx> #include <fmtclds.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <wrtsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <swmodule.hxx> #include <swundo.hxx> #include <fldbas.hxx> #include <uitool.hxx> -#ifndef _BASESH_HXX #include <basesh.hxx> -#endif #include <viewopt.hxx> #include <fontcfg.hxx> #include <docstat.hxx> @@ -171,7 +154,7 @@ static BYTE nFooterPos; #define SwBaseShell #define Shadow -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" #define SWCONTOURDLG(rView) ( (SvxContourDlg*) ( rView.GetViewFrame()->GetChildWindow( \ @@ -387,6 +370,41 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq) } break; + case SID_PASTE_UNFORMATTED: + { + TransferableDataHelper aDataHelper( + TransferableDataHelper::CreateFromSystemClipboard( + &rSh.GetView().GetEditWin()) ); + if( aDataHelper.GetXTransferable().is() && + SwTransferable::IsPaste( rSh, aDataHelper )) + { + // temp. Variablen, da die Shell nach dem Paste schon + // zerstoert sein kann + SwView* pView = &rView; + rReq.Ignore(); + bIgnore = sal_True; + int nRet = SwTransferable::PasteUnformatted( rSh, aDataHelper ); + if(nRet)// && rReq.IsRecording() ) + { + SfxViewFrame* pViewFrame = pView->GetViewFrame(); + uno::Reference< frame::XDispatchRecorder > xRecorder = + pViewFrame->GetBindings().GetRecorder(); + if(xRecorder.is()) { + SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS ); + aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, SOT_FORMAT_STRING ) ); + aReq.Done(); + } + } + + if (rSh.IsFrmSelected() || rSh.IsObjSelected()) + rSh.EnterSelFrmMode(); + pView->AttrChangedNotify( &rSh ); + } + else + return; + } + break; + case FN_PASTESPECIAL: { TransferableDataHelper aDataHelper( @@ -465,7 +483,10 @@ void SwBaseShell::StateClpbrd(SfxItemSet &rSet) case FN_PASTESPECIAL: if( !GetView().IsPasteSpecialAllowed() ) + { rSet.DisableItem( FN_PASTESPECIAL ); + rSet.DisableItem( SID_PASTE_UNFORMATTED ); + } break; case SID_CLIPBOARD_FORMAT_ITEMS: @@ -1730,9 +1751,12 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) rSh.GetGraphic(FALSE); // start the loading } else if( rSh.IsFrmSelected() ) - bDisable = GRAPHIC_NONE == - rSh.GetIMapGraphic().GetType()|| - nSel & nsSelectionType::SEL_FRM; + { + // #i102253# applied patch from OD (see task) + bDisable = + nSel & nsSelectionType::SEL_FRM || + GRAPHIC_NONE == rSh.GetIMapGraphic().GetType(); + } } bSet = bDisable ? FALSE : rWrap.IsContour(); @@ -2082,14 +2106,22 @@ void SwBaseShell::ExecTxtCtrl( SfxRequest& rReq ) if( pArgs ) { - SwTxtFmtColl* pColl; - if( (!(RES_CHRATR_BEGIN <= nWhich && nWhich < RES_CHRATR_END ) || - ( rSh.HasSelection() && rSh.IsSelFullPara() ) ) && - 0 != (pColl = rSh.GetCurTxtFmtColl()) && - pColl->IsAutoUpdateFmt() ) - rSh.AutoUpdatePara( pColl, *pArgs ); - else + bool bAuto = false; + if ( !isCHRATR(nWhich) || + ( rSh.HasSelection() && rSh.IsSelFullPara() ) ) + { + SwTxtFmtColl * pColl = rSh.GetCurTxtFmtColl(); + if ( pColl && pColl->IsAutoUpdateFmt() ) + { + rSh.AutoUpdatePara( pColl, *pArgs ); + bAuto = true; + } + } + + if (!bAuto) + { rSh.SetAttr( *pArgs ); + } } delete pSSetItem; } diff --git a/sw/source/ui/shells/beziersh.cxx b/sw/source/ui/shells/beziersh.cxx index b6bc159e7ecd..cc3493fe5120 100644 --- a/sw/source/ui/shells/beziersh.cxx +++ b/sw/source/ui/shells/beziersh.cxx @@ -52,7 +52,7 @@ #include "popup.hrc" #include "shells.hrc" #define SwBezierShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" #include <unomid.h> diff --git a/sw/source/ui/shells/drawsh.cxx b/sw/source/ui/shells/drawsh.cxx index ed7d60e84e6f..4da015e2d586 100644 --- a/sw/source/ui/shells/drawsh.cxx +++ b/sw/source/ui/shells/drawsh.cxx @@ -69,7 +69,7 @@ #include "drawsh.hxx" #define SwDrawShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" #include "swabstdlg.hxx" //CHINA001 #include "misc.hrc" diff --git a/sw/source/ui/shells/drformsh.cxx b/sw/source/ui/shells/drformsh.cxx index 254d01ccb960..97cac7006b98 100644 --- a/sw/source/ui/shells/drformsh.cxx +++ b/sw/source/ui/shells/drformsh.cxx @@ -60,14 +60,12 @@ #include "drwbassh.hxx" #include "drformsh.hxx" #include <svtools/urihelper.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <sfx2/docfile.hxx> #include <docsh.hxx> #define SwDrawFormShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" #include <unomid.h> diff --git a/sw/source/ui/shells/drwbassh.cxx b/sw/source/ui/shells/drwbassh.cxx index 725d5239e6fe..339c332c9135 100644 --- a/sw/source/ui/shells/drwbassh.cxx +++ b/sw/source/ui/shells/drwbassh.cxx @@ -41,9 +41,7 @@ #include <sfx2/bindings.hxx> #include <svtools/aeitem.hxx> #include <svx/svdview.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svx/srchitem.hxx> #include <svtools/whiter.hxx> #include <svx/swframevalidation.hxx> @@ -56,20 +54,14 @@ #endif #include <swmodule.hxx> #include <wrtsh.hxx> -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <edtwin.hxx> #include <viewopt.hxx> #include <dcontact.hxx> #include <frmfmt.hxx> #include <wrap.hxx> -#ifndef _DRAWBASE_HXX #include <drawbase.hxx> -#endif -#ifndef _DRWBASSH_HXX #include <drwbassh.hxx> -#endif #include <swdtflvr.hxx> #include <svx/svdogrp.hxx> #include <svx/svdpage.hxx> @@ -77,12 +69,8 @@ #include <shells.hrc> #define SwDrawBaseShell -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif #include <svx/svxdlg.hxx> #include <svx/dialogs.hrc> #include "swabstdlg.hxx" diff --git a/sw/source/ui/shells/drwtxtsh.cxx b/sw/source/ui/shells/drwtxtsh.cxx index a0f38300fba2..99a2bf71bca7 100644 --- a/sw/source/ui/shells/drwtxtsh.cxx +++ b/sw/source/ui/shells/drwtxtsh.cxx @@ -59,15 +59,11 @@ #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <swtypes.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <wrtsh.hxx> #include <viewopt.hxx> #include <initui.hxx> // fuer SpellPointer -#ifndef _DRWTXTSH_HXX #include <drwtxtsh.hxx> -#endif #include <swundo.hxx> #include <breakit.hxx> @@ -85,19 +81,13 @@ #endif #define SwDrawTextShell -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif #ifndef _POPUP_HRC #include <popup.hrc> #endif #include <uitool.hxx> -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <swmodule.hxx> #include <svx/xtable.hxx> diff --git a/sw/source/ui/shells/frmsh.cxx b/sw/source/ui/shells/frmsh.cxx index 4df31175e1aa..3f61bab9a20e 100644 --- a/sw/source/ui/shells/frmsh.cxx +++ b/sw/source/ui/shells/frmsh.cxx @@ -57,9 +57,7 @@ #include <fmtcnct.hxx> #include <swmodule.hxx> #include <wrtsh.hxx> -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <frmatr.hxx> #include <uitool.hxx> #include <frmfmt.hxx> @@ -104,7 +102,7 @@ const SwFrmFmt* lcl_GetFrmFmtByName(SwWrtShell& rSh, const String& rName) } #define SwFrameShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" SFX_IMPL_INTERFACE(SwFrameShell, SwBaseShell, SW_RES(STR_SHELLNAME_FRAME)) diff --git a/sw/source/ui/shells/grfsh.cxx b/sw/source/ui/shells/grfsh.cxx index 026e22a228c4..62a3af2f6f28 100644 --- a/sw/source/ui/shells/grfsh.cxx +++ b/sw/source/ui/shells/grfsh.cxx @@ -39,9 +39,7 @@ #endif #include <hintids.hxx> #include <tools/urlobj.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svtools/stritem.hxx> #include <svtools/whiter.hxx> #include <svtools/urihelper.hxx> @@ -64,21 +62,15 @@ #include <svx/grfflt.hxx> #include <svx/tbxcolor.hxx> #include <fmturl.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <wrtsh.hxx> #include <viewopt.hxx> #include <swmodule.hxx> #include <frmatr.hxx> #include <swundo.hxx> #include <uitool.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif -#ifndef _GRFSH_HXX #include <grfsh.hxx> -#endif #include <frmmgr.hxx> #include <frmdlg.hxx> #include <frmfmt.hxx> @@ -90,7 +82,7 @@ #include <popup.hrc> #define SwGrfShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" #include "swabstdlg.hxx" @@ -122,7 +114,7 @@ void SwGrfShell::Execute(SfxRequest &rReq) { String sGrfNm, sFilterNm; rSh.GetGrfNms( &sGrfNm, &sFilterNm ); - ExportGraphic( *pGraphic, sGrfNm, sGrfNm ); + ExportGraphic( *pGraphic, sGrfNm ); } } break; diff --git a/sw/source/ui/shells/listsh.cxx b/sw/source/ui/shells/listsh.cxx index c1c8435bd12f..34f349befbc9 100644 --- a/sw/source/ui/shells/listsh.cxx +++ b/sw/source/ui/shells/listsh.cxx @@ -65,7 +65,7 @@ #include "edtwin.hxx" #define SwListShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" #include <IDocumentOutlineNodes.hxx> diff --git a/sw/source/ui/shells/mediash.cxx b/sw/source/ui/shells/mediash.cxx index 933d7254bb8a..ae1ed883cb8b 100644 --- a/sw/source/ui/shells/mediash.cxx +++ b/sw/source/ui/shells/mediash.cxx @@ -39,9 +39,7 @@ #endif #include <hintids.hxx> #include <tools/urlobj.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svtools/stritem.hxx> #include <svtools/whiter.hxx> #include <svtools/urihelper.hxx> @@ -60,21 +58,15 @@ #include <svx/brshitem.hxx> #include <svx/grfflt.hxx> #include <fmturl.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <wrtsh.hxx> #include <viewopt.hxx> #include <swmodule.hxx> #include <frmatr.hxx> #include <swundo.hxx> #include <uitool.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif -#ifndef _MEDIASH_HXX #include <mediash.hxx> -#endif #include <frmmgr.hxx> #include <frmdlg.hxx> #include <frmfmt.hxx> @@ -95,7 +87,7 @@ #include <avmedia/mediaitem.hxx> #define SwMediaShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" #include "swabstdlg.hxx" diff --git a/sw/source/ui/shells/olesh.cxx b/sw/source/ui/shells/olesh.cxx index 6d6f1985e56b..2bf523d27e3b 100644 --- a/sw/source/ui/shells/olesh.cxx +++ b/sw/source/ui/shells/olesh.cxx @@ -37,9 +37,7 @@ #include <sfx2/objface.hxx> #include <sfx2/objitem.hxx> #include <wrtsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #ifndef _HELPID_H #include <helpid.h> #endif @@ -63,12 +61,8 @@ #define SwOleShell -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif SFX_IMPL_INTERFACE(SwOleShell, SwFrameShell, SW_RES(STR_SHELLNAME_OBJECT)) diff --git a/sw/source/ui/shells/slotadd.cxx b/sw/source/ui/shells/slotadd.cxx index 804b6127de4f..333128a18db9 100644 --- a/sw/source/ui/shells/slotadd.cxx +++ b/sw/source/ui/shells/slotadd.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: slotadd.cxx,v $ - * $Revision: 1.30 $ + * $Revision: 1.30.124.1 $ * * This file is part of OpenOffice.org. * @@ -147,7 +147,7 @@ #define avmedia_MediaItem ::avmedia::MediaItem #define SFX_TYPEMAP -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" diff --git a/sw/source/ui/shells/tabsh.cxx b/sw/source/ui/shells/tabsh.cxx index 3c1d84666c7a..7ba4d0b8e954 100644 --- a/sw/source/ui/shells/tabsh.cxx +++ b/sw/source/ui/shells/tabsh.cxx @@ -57,9 +57,7 @@ #include <svx/svxdlg.hxx> #include <svtools/zformat.hxx> #include <sfx2/bindings.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <sfx2/request.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/objface.hxx> @@ -72,28 +70,20 @@ #include <fmtfsize.hxx> #include <swmodule.hxx> #include <wrtsh.hxx> -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <frmatr.hxx> #include <uitool.hxx> -#ifndef _INPUTWIN_HXX #include <inputwin.hxx> -#endif #include <uiitems.hxx> #include <usrpref.hxx> -#ifndef _TABSH_HXX #include <tabsh.hxx> -#endif #include "swtablerep.hxx" #include <tablemgr.hxx> #include <cellatr.hxx> #include <frmfmt.hxx> #include <swundo.hxx> #include <swtable.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <tblsel.hxx> #include <dialog.hrc> @@ -130,12 +120,8 @@ #include <unoobj.hxx> #define SwTableShell -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif #include "swabstdlg.hxx" #include <table.hrc> @@ -984,13 +970,18 @@ void SwTableShell::Execute(SfxRequest &rReq) { if ( FN_TABLE_INSERT_ROW_DLG != nSlot || !rSh.IsInRepeatedHeadline()) { - SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - DBG_ASSERT(pFact, "Dialogdiet fail!"); - VclAbstractDialog* pDlg = pFact->CreateVclSwViewDialog( DLG_INS_ROW_COL, - GetView(), FN_TABLE_INSERT_COL_DLG == nSlot ); - DBG_ASSERT(pDlg, "Dialogdiet fail!"); - pDlg->Execute(); - delete pDlg; + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ::std::auto_ptr<SvxAbstractInsRowColDlg> pDlg( pFact ? pFact->CreateSvxInsRowColDlg( GetView().GetWindow(), nSlot == FN_TABLE_INSERT_COL_DLG, nSlot) : 0); + + if( pDlg.get() && (pDlg->Execute() == 1) ) + { + USHORT nDispatchSlot = (nSlot == FN_TABLE_INSERT_COL_DLG) ? FN_TABLE_INSERT_COL : FN_TABLE_INSERT_ROW; + SfxUInt16Item aCountItem( nDispatchSlot, static_cast< UINT16 >(pDlg->getInsertCount()) ); + SfxBoolItem aAfter( FN_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() ); + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if( pVFrame ) + pVFrame->GetDispatcher()->Execute( nDispatchSlot, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aCountItem, &aAfter, 0L); + } } } break; diff --git a/sw/source/ui/shells/textsh.cxx b/sw/source/ui/shells/textsh.cxx index f0874a954b97..742e93b646c2 100644 --- a/sw/source/ui/shells/textsh.cxx +++ b/sw/source/ui/shells/textsh.cxx @@ -46,18 +46,14 @@ #include <svtools/ptitem.hxx> #include <svtools/stritem.hxx> #include <svtools/moduleoptions.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <sfx2/fcontnr.hxx> #include <svx/hlnkitem.hxx> #include <svx/srchitem.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/docfile.hxx> #include <svtools/urihelper.hxx> -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include <basic/sbxvar.hxx> -#endif #include <svtools/whiter.hxx> #include <sfx2/request.hxx> #include <svx/opaqitem.hxx> @@ -71,9 +67,7 @@ #include <svx/htmlmode.hxx> #include <svx/pfiledlg.hxx> #include <svx/htmlcfg.hxx> -#ifndef _COM_SUN_STAR_I18N_TRANSLITERATIONMODULES_HDL_ #include <com/sun/star/i18n/TransliterationModules.hdl> -#endif #include <sot/clsids.hxx> #include <svx/acorrcfg.hxx> @@ -84,12 +78,8 @@ #include <fmtfsize.hxx> #include <swmodule.hxx> #include <wrtsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <doc.hxx> #include <uitool.hxx> #ifndef _CMDID_H @@ -99,9 +89,7 @@ #include <globals.hrc> #endif #include <frmmgr.hxx> -#ifndef _TEXTSH_HXX #include <textsh.hxx> -#endif #include <frmfmt.hxx> #include <tablemgr.hxx> #include <swundo.hxx> // fuer Undo-IDs @@ -137,12 +125,8 @@ #define HyphenZone #define TextFont #define DropCap -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif #include <SwRewriter.hxx> #include <undobj.hxx> #ifndef _COMCORE_HRC diff --git a/sw/source/ui/table/colwd.src b/sw/source/ui/table/colwd.src index 8f83a797d2ab..609b080941bc 100644 --- a/sw/source/ui/table/colwd.src +++ b/sw/source/ui/table/colwd.src @@ -38,39 +38,39 @@ ModalDialog DLG_COL_WIDTH HelpID = FN_TABLE_SET_COL_WIDTH ; OutputSize = TRUE ; SVLook = TRUE ; - Size = MAP_APPFONT ( 149 , 60 ) ; + Size = MAP_APPFONT ( 159 , 60 ) ; Text [ en-US ] = "Column Width" ; Moveable = TRUE ; OKButton BT_OK { - Pos = MAP_APPFONT ( 94 , 6 ) ; + Pos = MAP_APPFONT ( 104 , 6 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; DefButton = TRUE ; }; CancelButton BT_CANCEL { - Pos = MAP_APPFONT ( 94 , 23 ) ; + Pos = MAP_APPFONT ( 104 , 23 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; }; HelpButton BT_HELP { - Pos = MAP_APPFONT ( 94 , 43 ) ; + Pos = MAP_APPFONT ( 104 , 43 ) ; Size = MAP_APPFONT ( 50 , 14 ) ; TabStop = TRUE ; }; FixedText FT_WIDTH { Pos = MAP_APPFONT ( 12 , 31 ) ; - Size = MAP_APPFONT ( 22 , 8 ) ; + Size = MAP_APPFONT ( 35 , 8 ) ; Text [ en-US ] = "~Width" ; Left = TRUE ; }; MetricField ED_WIDTH { Border = TRUE ; - Pos = MAP_APPFONT ( 41 , 30 ) ; + Pos = MAP_APPFONT ( 51 , 30 ) ; Size = MAP_APPFONT ( 38 , 12 ) ; TabStop = TRUE ; Left = TRUE ; @@ -88,20 +88,20 @@ ModalDialog DLG_COL_WIDTH FixedLine FL_WIDTH { Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 81 , 8 ) ; + Size = MAP_APPFONT ( 91 , 8 ) ; Text [ en-US ] = "Width" ; }; FixedText FT_COL { Pos = MAP_APPFONT ( 12 , 16 ) ; - Size = MAP_APPFONT ( 29 , 8 ) ; + Size = MAP_APPFONT ( 35 , 8 ) ; Text [ en-US ] = "~Column" ; Left = TRUE ; }; NumericField ED_COL { Border = TRUE ; - Pos = MAP_APPFONT ( 41 , 14 ) ; + Pos = MAP_APPFONT ( 51 , 14 ) ; Size = MAP_APPFONT ( 38 , 12 ) ; TabStop = TRUE ; Left = TRUE ; diff --git a/sw/source/ui/table/convert.cxx b/sw/source/ui/table/convert.cxx index 1792b639e5d8..63f8ac8a2e00 100644 --- a/sw/source/ui/table/convert.cxx +++ b/sw/source/ui/table/convert.cxx @@ -141,14 +141,14 @@ SwConvertTableDlg::SwConvertTableDlg( SwView& rView, bool bToTable ) aRepeatHeaderAfterFT (this), aRepeatHeaderCombo (this, SW_RES(WIN_REPEAT_HEADER), aRepeatHeaderNF, aRepeatHeaderBeforeFT, aRepeatHeaderAfterFT), + aOptionsFL (this, SW_RES(FL_OPTIONS)), aDontSplitCB (this, SW_RES(CB_DONT_SPLIT)), aBorderCB (this, SW_RES(CB_BORDER)), - aOptionsFL (this, SW_RES(FL_OPTIONS)), + aAutoFmtBtn(this,SW_RES(BT_AUTOFORMAT)), aOkBtn(this,SW_RES(BT_OK)), aCancelBtn(this,SW_RES(BT_CANCEL)), aHelpBtn(this, SW_RES(BT_HELP)), - aAutoFmtBtn(this,SW_RES(BT_AUTOFORMAT)), #ifdef MSC #pragma warning (default : 4355) #endif diff --git a/sw/source/ui/table/convert.src b/sw/source/ui/table/convert.src index 3eec84232ba1..44a8923d9e48 100644 --- a/sw/source/ui/table/convert.src +++ b/sw/source/ui/table/convert.src @@ -36,7 +36,7 @@ ModalDialog DLG_CONV_TEXT_TABLE { HelpID = FN_CONVERT_TEXT_TABLE ; OUTPUTSIZE = TRUE ; - Size = MAP_APPFONT ( 203 , 152 ) ; + Size = MAP_APPFONT ( 203 , 169 ) ; Text [ en-US ] = "Convert Table to Text" ; MOVEABLE = TRUE ; SVLOOK = TRUE ; @@ -176,8 +176,8 @@ ModalDialog DLG_CONV_TEXT_TABLE }; PushButton BT_AUTOFORMAT { - Pos = MAP_APPFONT ( 147 , 60 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; + Pos = MAP_APPFONT ( 12 , 152 ) ; + Size = MAP_APPFONT ( 66 , 14 ) ; TabStop = TRUE ; Hide = TRUE ; Text [ en-US ] = "Auto~Format..." ; diff --git a/sw/source/ui/table/makefile.mk b/sw/source/ui/table/makefile.mk index f862365cc35f..5e39d0af3af3 100644 --- a/sw/source/ui/table/makefile.mk +++ b/sw/source/ui/table/makefile.mk @@ -50,7 +50,6 @@ SRC1FILES = \ colwd.src \ convert.src \ chartins.src \ - insrc.src \ instable.src \ mergetbl.src \ rowht.src \ @@ -63,7 +62,6 @@ SLOFILES = \ $(SLO)$/colwd.obj \ $(SLO)$/convert.obj \ $(SLO)$/chartins.obj \ - $(SLO)$/insrc.obj \ $(SLO)$/instable.obj \ $(SLO)$/mergetbl.obj \ $(SLO)$/rowht.obj \ diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index 7c12f537761e..8fe6b9511f8f 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -39,9 +39,7 @@ #include <vcl/fixed.hxx> #include <vcl/help.hxx> #include <vcl/cmdevt.hxx> -#ifndef _SV_BUTTON_HXX //autogen #include <vcl/button.hxx> -#endif #include <svtools/printdlg.hxx> #include <svtools/whiter.hxx> #include <svtools/stritem.hxx> @@ -71,20 +69,12 @@ #include <swmodule.hxx> #include <modcfg.hxx> #include <wrtsh.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <viewopt.hxx> #include <doc.hxx> -#ifndef _PVIEW_HXX #include <pview.hxx> -#endif -#ifndef _VIEW_HXX #include <view.hxx> -#endif -#ifndef _TEXTSH_HXX #include <textsh.hxx> -#endif #include <scroll.hxx> #include <swprtopt.hxx> #include <docstat.hxx> @@ -109,12 +99,8 @@ #endif #define SwPagePreView -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif // OD 12.12.2002 #103492# #include <pagepreviewlayout.hxx> @@ -384,7 +370,7 @@ SwPreviewPrintOptionsDialog::SwPreviewPrintOptionsDialog( SwPagePreViewWin& rPar aSettings.aPrtSize = pPrinter->GetPaperSize(); //#97682# make sure that no division by zero occurs if(!aSettings.aPrtSize.Width() || !aSettings.aPrtSize.Height()) - aSettings.aPrtSize = Size(lA4Width, lA4Height); + aSettings.aPrtSize = SvxPaperInfo::GetPaperSize(PAPER_A4); aSettings.bPrinterLandscape = pPrinter->GetOrientation() == ORIENTATION_LANDSCAPE; diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx index 7898e4db1cb2..34cfebe663a1 100644 --- a/sw/source/ui/uiview/srcview.cxx +++ b/sw/source/ui/uiview/srcview.cxx @@ -76,7 +76,7 @@ #include <srcview.hxx> #include <viewfunc.hxx> #include <doc.hxx> -#include <itemdef.hxx> +#include <sfx2/msg.hxx> #include <shellio.hxx> #include <cmdid.h> // FN_ ... diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx index f5e84ee1048b..5e3afd2ed8fa 100644 --- a/sw/source/ui/uiview/view.cxx +++ b/sw/source/ui/uiview/view.cxx @@ -672,6 +672,7 @@ void SwView::_CheckReadonlyState() SID_DELETE, FN_BACKSPACE, FN_SHIFT_BACKSPACE, SID_UNDO, SID_REDO, SID_REPEAT, SID_PASTE, + SID_PASTE_UNFORMATTED, FN_PASTESPECIAL, SID_SBA_BRW_INSERT, SID_BACKGROUND_COLOR, FN_INSERT_BOOKMARK, SID_CHARMAP, FN_INSERT_SOFT_HYPHEN, diff --git a/sw/source/ui/uiview/view0.cxx b/sw/source/ui/uiview/view0.cxx index 2e9a3bc783e7..38f885657450 100644 --- a/sw/source/ui/uiview/view0.cxx +++ b/sw/source/ui/uiview/view0.cxx @@ -49,9 +49,7 @@ #include <svx/srchdlg.hxx> #include <sfx2/templdlg.hxx> #include <uivwimp.hxx> -#ifndef _AVMEDIA_MEDIAPPLAYER_HXX #include <avmedia/mediaplayer.hxx> -#endif #include <swmodule.hxx> #include <sfx2/objface.hxx> @@ -92,7 +90,7 @@ #define WebListInText #define WebListInTable #define TextPage -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include <svx/svxslots.hxx> #include "swslots.hxx" #include <PostItMgr.hxx> diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index c063c72c5892..6a03909d92f9 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -584,7 +584,7 @@ void __EXPORT SwView::Execute(SfxRequest &rReq) USHORT nOn = ((const SfxBoolItem*)pItem)->GetValue() ? nsRedlineMode_t::REDLINE_ON : 0; USHORT nMode = pWrtShell->GetRedlineMode(); - pWrtShell->SetRedlineMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn); + pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn); } } break; @@ -624,7 +624,7 @@ void __EXPORT SwView::Execute(SfxRequest &rReq) nOn = 0; } USHORT nMode = pIDRA->GetRedlineMode(); - pWrtShell->SetRedlineMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn); + pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn); rReq.AppendItem( SfxBoolItem( FN_REDLINE_PROTECT, ((nMode&nsRedlineMode_t::REDLINE_ON)==0) ) ); } else @@ -641,7 +641,7 @@ void __EXPORT SwView::Execute(SfxRequest &rReq) if( ((const SfxBoolItem*)pItem)->GetValue() ) nMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE; - pWrtShell->SetRedlineMode( nMode ); + pWrtShell->SetRedlineModeAndCheckInsMode( nMode ); } break; case FN_MAILMERGE_SENDMAIL_CHILDWINDOW: diff --git a/sw/source/ui/uiview/viewdraw.cxx b/sw/source/ui/uiview/viewdraw.cxx index d366a5ddc16c..4fb7746db4d7 100644 --- a/sw/source/ui/uiview/viewdraw.cxx +++ b/sw/source/ui/uiview/viewdraw.cxx @@ -501,7 +501,7 @@ sal_Bool SwView::EnterDrawTextMode(const Point& aDocPos) if( pSdrView->IsMarkedHit( aDocPos ) && !pSdrView->PickHandle( aDocPos ) && IsTextTool() && - pSdrView->PickObj( aDocPos, pObj, pPV, SDRSEARCH_PICKTEXTEDIT ) && + pSdrView->PickObj( aDocPos, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKTEXTEDIT ) && // #108784# // To allow SwDrawVirtObj text objects to be activated, allow their type, too. diff --git a/sw/source/ui/uiview/viewport.cxx b/sw/source/ui/uiview/viewport.cxx index 23d98a64b49d..1cc886f5d204 100644 --- a/sw/source/ui/uiview/viewport.cxx +++ b/sw/source/ui/uiview/viewport.cxx @@ -1278,10 +1278,7 @@ Size SwView::GetOptimalSizePixel() const { Size aPgSize; if ( pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) ) - { - aPgSize.Height() = lA4Height; - aPgSize.Width() = lA4Width; - } + aPgSize = SvxPaperInfo::GetPaperSize(PAPER_A4); else { aPgSize = GetWrtShell().GetAnyCurRect(RECT_PAGE).SSize(); diff --git a/sw/source/ui/uiview/viewsrch.cxx b/sw/source/ui/uiview/viewsrch.cxx index c5602411f324..690a1900749e 100644 --- a/sw/source/ui/uiview/viewsrch.cxx +++ b/sw/source/ui/uiview/viewsrch.cxx @@ -607,10 +607,10 @@ void SwView::Replace() { if (GetPostItMgr()->GetActivePostIt()) GetPostItMgr()->Replace(pSrchItem); - pWrtShell->SwEditShell::Replace( pSrchItem->GetReplaceString(), + sal_Bool bReplaced = pWrtShell->SwEditShell::Replace( pSrchItem->GetReplaceString(), pSrchItem->GetRegExp()); - if( pReplList && pReplList->Count() && pWrtShell->HasSelection() ) + if( bReplaced && pReplList && pReplList->Count() && pWrtShell->HasSelection() ) { SfxItemSet aReplSet( pWrtShell->GetAttrPool(), aTxtFmtCollSetRange ); diff --git a/sw/source/ui/uno/swdetect.cxx b/sw/source/ui/uno/swdetect.cxx index 5eea99c6b1fb..ac2f6b5ce130 100644 --- a/sw/source/ui/uno/swdetect.cxx +++ b/sw/source/ui/uno/swdetect.cxx @@ -223,7 +223,7 @@ SwFilterDetect::~SwFilterDetect() // error during storage creation means _here_ that the medium // is broken, but we can not handle it in medium since impossibility // to create a storage does not _always_ means that the medium is broken - aMedium.SetError( aMedium.GetLastStorageCreationState() ); + aMedium.SetError( aMedium.GetLastStorageCreationState(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); if ( xInteraction.is() ) { OUString empty; @@ -299,12 +299,12 @@ SwFilterDetect::~SwFilterDetect() if ( nIndexOfInteractionHandler != -1 ) lDescriptor[nIndexOfInteractionHandler].Value <<= uno::Reference< XInteractionHandler >( static_cast< task::XInteractionHandler* >( xHandler.get() ) ); - aMedium.SetError( ERRCODE_ABORT ); + aMedium.SetError( ERRCODE_ABORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); } } else // no interaction, error handling as usual - aMedium.SetError( ERRCODE_IO_BROKENPACKAGE ); + aMedium.SetError( ERRCODE_IO_BROKENPACKAGE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); if ( !bRepairAllowed ) { diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index dfdbacab354b..0c67e24b8d10 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -416,7 +416,7 @@ sal_Bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextR if(pxCursor) { SwPaM* pUnoCrsr = pxCursor->GetPaM(); - bRet |= (true == pxCursor->GetDoc()->Copy( *pUnoCrsr, aPos )); + bRet |= (true == pxCursor->GetDoc()->Copy( *pUnoCrsr, aPos, false )); } else { @@ -424,7 +424,7 @@ 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)); + bRet |= (true == pxRange->GetDoc()->Copy(aTmp, aPos, false)); } } } diff --git a/sw/source/ui/uno/unomod.cxx b/sw/source/ui/uno/unomod.cxx index 57a2a8ec6c1f..19d0faa0bfce 100644 --- a/sw/source/ui/uno/unomod.cxx +++ b/sw/source/ui/uno/unomod.cxx @@ -50,13 +50,13 @@ #include <com/sun/star/text/NotePrintMode.hpp> #include <doc.hxx> #include <comphelper/TypeGeneration.hxx> -#ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif +#include <com/sun/star/view/DocumentZoomType.hpp> #include <comphelper/ChainablePropertySetInfo.hxx> #include <edtwin.hxx> #include <rtl/ustrbuf.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; @@ -726,23 +726,28 @@ void SwXViewSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, c if(!(rValue >>= nZoom)) throw IllegalArgumentException(); SvxZoomType eZoom = (SvxZoomType)USHRT_MAX; - switch(nZoom) + switch (nZoom) { - case /*DocumentZoomType_OPTIMAL */0: + case view::DocumentZoomType::OPTIMAL: eZoom = SVX_ZOOM_OPTIMAL; break; - case /*DocumentZoomType_PAGE_WIDTH */ 1: + case view::DocumentZoomType::PAGE_WIDTH: eZoom = SVX_ZOOM_PAGEWIDTH; break; - case /*DocumentZoomType_ENTIRE_PAGE */ 2: + case view::DocumentZoomType::ENTIRE_PAGE: eZoom = SVX_ZOOM_WHOLEPAGE; break; - case /*DocumentZoomType_BY_VALUE */ 3: + case view::DocumentZoomType::BY_VALUE: eZoom = SVX_ZOOM_PERCENT; break; - case /*DocumentZoomType_PAGE_WIDTH_EXACT */ 4: + case view::DocumentZoomType::PAGE_WIDTH_EXACT: eZoom = SVX_ZOOM_PAGEWIDTH_NOBORDER; break; + default: + throw IllegalArgumentException( + ::rtl::OUString::createFromAscii( + "SwXViewSettings: invalid zoom type"), 0, 0); + break; } if(eZoom < USHRT_MAX) { @@ -915,23 +920,27 @@ void SwXViewSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, u case HANDLE_VIEWSET_ZOOM_TYPE: { bBool = FALSE; - sal_Int16 nRet; - switch(mpConstViewOption->GetZoomType()) + sal_Int16 nRet(0); + switch (mpConstViewOption->GetZoomType()) { case SVX_ZOOM_OPTIMAL: - nRet = /*DocumentZoomType_OPTIMAL*/ 0; + nRet = view::DocumentZoomType::OPTIMAL; break; case SVX_ZOOM_PAGEWIDTH: - nRet = /*DocumentZoomType_PAGE_WIDTH */1; + nRet = view::DocumentZoomType::PAGE_WIDTH; break; case SVX_ZOOM_WHOLEPAGE: - nRet = /*DocumentZoomType_ENTIRE_PAGE */ 2; + nRet = view::DocumentZoomType::ENTIRE_PAGE; break; case SVX_ZOOM_PERCENT: - nRet = /*DocumentZoomType_BY_VALUE */ 3; + nRet = view::DocumentZoomType::BY_VALUE; + break; + case SVX_ZOOM_PAGEWIDTH_NOBORDER: + nRet = view::DocumentZoomType::PAGE_WIDTH_EXACT; break; default: - ; + OSL_ENSURE(false, "SwXViewSettings: invalid zoom type"); + break; } rValue <<= nRet; } diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index ed997c6392ba..04a26d47b324 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -37,16 +37,12 @@ #include <vcl/virdev.hxx> #include <vcl/svapp.hxx> #include <sfx2/viewfrm.hxx> -#ifndef _TOOLKIT_UNOHLP_HXX #include <toolkit/helper/vclunohelper.hxx> -#endif #include <wdocsh.hxx> #include <wrtsh.hxx> #include <view.hxx> #include <pview.hxx> -#ifndef _SRCVIEW_HXX #include <srcview.hxx> -#endif #include <viewsh.hxx> #include <pvprtdat.hxx> #include <swprtopt.hxx> @@ -84,9 +80,7 @@ #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> -#ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif #include <com/sun/star/document/RedlineDisplayType.hpp> #include <svx/linkmgr.hxx> #include <svx/unofill.hxx> @@ -94,13 +88,9 @@ #include <sfx2/progress.hxx> #include <swmodule.hxx> #include <docstat.hxx> -#ifndef _MODOPT_HXX // #include <modcfg.hxx> -#endif #include <ndtxt.hxx> -#ifndef _UTLUI_HRC #include <utlui.hrc> -#endif #include <swcont.hxx> #include <unodefaults.hxx> #include <SwXDocumentSettings.hxx> @@ -2851,7 +2841,27 @@ uno::Reference< text::XFlatParagraphIterator > SAL_CALL SwXTextDocument::getFlat { return new SwXFlatParagraphIterator( *pDocShell->GetDoc(), nTextMarkupType, bAutomatic ); } +/*-- 07.05.2009 09:21:12--------------------------------------------------- + -----------------------------------------------------------------------*/ +uno::Reference< util::XCloneable > SwXTextDocument::createClone( ) throw (uno::RuntimeException) +{ + ::vos::OGuard aGuard(Application::GetSolarMutex()); + if(!IsValid()) + throw RuntimeException(); + //create a new document - hidden - copy the storage and return it + SwDoc* pCopyDoc = pDocShell->GetDoc()->CreateCopy(); + SfxObjectShell* pShell = new SwDocShell( pCopyDoc, SFX_CREATE_MODE_STANDARD ); + pShell->DoInitNew(); + + uno::Reference< embed::XStorage > xSourceStorage = getDocumentStorage(); + uno::Reference< frame::XModel > xNewModel = pShell->GetModel(); + //copy this storage + uno::Reference< document::XStorageBasedDocument > xStorageDoc( xNewModel, uno::UNO_QUERY ); + uno::Reference< embed::XStorage > xNewStorage = xStorageDoc->getDocumentStorage(); + xSourceStorage->copyToStorage( xNewStorage ); + return uno::Reference< util::XCloneable >( xNewModel, UNO_QUERY ); +} /* -----------------------------20.06.00 09:54-------------------------------- ---------------------------------------------------------------------------*/ diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index eaba514a6e6a..6197bb489d61 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -38,9 +38,7 @@ #include <hintids.hxx> #include <docsh.hxx> #include <rubylist.hxx> -#ifndef _SWDOC_HXX //autogen #include <doc.hxx> -#endif #include <unotxvw.hxx> #include <unodispatch.hxx> #include <unomap.hxx> @@ -1442,9 +1440,9 @@ void SwXTextViewCursor::gotoRange( const ::sw::mark::IMark* const pBkmk = pRange->GetBookmark(); pSrcNode = &(pBkmk->GetMarkPos().nNode.GetNode()); } - else if (pPara && pPara->GetCrsr()) + else if (pPara && pPara->GetTxtNode()) { - pSrcNode = pPara->GetCrsr()->GetNode(); + pSrcNode = pPara->GetTxtNode(); } const SwStartNode* pTmp = pSrcNode ? pSrcNode->FindSttNodeByType(eSearchNodeType) : 0; diff --git a/sw/source/ui/web/wdocsh.cxx b/sw/source/ui/web/wdocsh.cxx index 9f7eff770172..dbfdf87dc94d 100644 --- a/sw/source/ui/web/wdocsh.cxx +++ b/sw/source/ui/web/wdocsh.cxx @@ -43,7 +43,7 @@ #include <sot/clsids.hxx> #include <sfx2/objface.hxx> -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "cfgid.h" #include "cmdid.h" #include "swtypes.hxx" diff --git a/sw/source/ui/web/wformsh.cxx b/sw/source/ui/web/wformsh.cxx index 8a629fbfeac2..ed9a84667c79 100644 --- a/sw/source/ui/web/wformsh.cxx +++ b/sw/source/ui/web/wformsh.cxx @@ -33,7 +33,7 @@ -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #ifndef _SVX_SVXIDS_HRC #include <svx/svxids.hrc> diff --git a/sw/source/ui/web/wfrmsh.cxx b/sw/source/ui/web/wfrmsh.cxx index e43a0e2d7850..ee2f61884000 100644 --- a/sw/source/ui/web/wfrmsh.cxx +++ b/sw/source/ui/web/wfrmsh.cxx @@ -50,7 +50,7 @@ // STATIC DATA ----------------------------------------------------------- #define SwWebFrameShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" diff --git a/sw/source/ui/web/wgrfsh.cxx b/sw/source/ui/web/wgrfsh.cxx index 5a935bb9e2e1..00a21da8e1b7 100644 --- a/sw/source/ui/web/wgrfsh.cxx +++ b/sw/source/ui/web/wgrfsh.cxx @@ -32,8 +32,7 @@ #include "precompiled_sw.hxx" - -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include <svx/srchitem.hxx> #include <sfx2/app.hxx> diff --git a/sw/source/ui/web/wlistsh.cxx b/sw/source/ui/web/wlistsh.cxx index a505928134b9..fc3f0635b54d 100644 --- a/sw/source/ui/web/wlistsh.cxx +++ b/sw/source/ui/web/wlistsh.cxx @@ -32,9 +32,7 @@ #include "precompiled_sw.hxx" -#include "itemdef.hxx" - - +#include <sfx2/msg.hxx> #include <sfx2/app.hxx> #include <sfx2/objface.hxx> #include <svx/srchitem.hxx> diff --git a/sw/source/ui/web/wolesh.cxx b/sw/source/ui/web/wolesh.cxx index 481c9405e439..131b6d72da10 100644 --- a/sw/source/ui/web/wolesh.cxx +++ b/sw/source/ui/web/wolesh.cxx @@ -32,8 +32,7 @@ #include "precompiled_sw.hxx" - -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include <sfx2/app.hxx> #include <sfx2/objface.hxx> #include <svx/srchitem.hxx> diff --git a/sw/source/ui/web/wtabsh.cxx b/sw/source/ui/web/wtabsh.cxx index 7af0bef34232..c47541214d58 100644 --- a/sw/source/ui/web/wtabsh.cxx +++ b/sw/source/ui/web/wtabsh.cxx @@ -51,7 +51,7 @@ #include "wtabsh.hxx" #define SwWebTableShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "svx/svxids.hrc" #include "swslots.hxx" diff --git a/sw/source/ui/web/wtextsh.cxx b/sw/source/ui/web/wtextsh.cxx index 2bbf79cfab94..abdcee987840 100644 --- a/sw/source/ui/web/wtextsh.cxx +++ b/sw/source/ui/web/wtextsh.cxx @@ -37,9 +37,7 @@ #include <sfx2/objface.hxx> #include <sfx2/app.hxx> #include <svx/srchitem.hxx> //*** -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include <basic/sbxvar.hxx> -#endif #ifndef _SVX_SVXIDS_HRC //autogen #include <svx/svxids.hrc> #endif @@ -63,7 +61,7 @@ #define HyphenZone #define TextFont #define DropCap -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" diff --git a/sw/source/ui/web/wview.cxx b/sw/source/ui/web/wview.cxx index 6d1b0ca68c03..34ccd8f72378 100644 --- a/sw/source/ui/web/wview.cxx +++ b/sw/source/ui/web/wview.cxx @@ -32,7 +32,7 @@ #include "precompiled_sw.hxx" -#include <itemdef.hxx> +#include <sfx2/msg.hxx> #include <svx/srchitem.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/templdlg.hxx> diff --git a/sw/source/ui/wrtsh/select.cxx b/sw/source/ui/wrtsh/select.cxx index 5124cf66d687..f45c68ef7ec9 100644 --- a/sw/source/ui/wrtsh/select.cxx +++ b/sw/source/ui/wrtsh/select.cxx @@ -701,6 +701,13 @@ void SwWrtShell::SetInsMode( BOOL bOn ) StartAction(); EndAction(); } +//Overwrite mode is incompatible with red-lining +void SwWrtShell::SetRedlineModeAndCheckInsMode( USHORT eMode ) +{ + SetRedlineMode( eMode ); + if (IsRedlineOn()) + SetInsMode( true ); +} /* * Rahmen bearbeiten diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx index 6624668fcd8a..42cfb1c3d64d 100644 --- a/sw/source/ui/wrtsh/wrtsh2.cxx +++ b/sw/source/ui/wrtsh/wrtsh2.cxx @@ -30,12 +30,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> // define ITEMIDs #include <svtools/macitem.hxx> #include <sfx2/frame.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svtools/urihelper.hxx> #include <svtools/eitem.hxx> #include <svtools/stritem.hxx> @@ -47,9 +46,7 @@ #include <frmatr.hxx> #include <swtypes.hxx> // SET_CURR_SHELL #include <wrtsh.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <fldbas.hxx> // Felder #include <expfld.hxx> #include <ddefld.hxx> @@ -61,9 +58,7 @@ #include <frmfmt.hxx> // fuer UpdateTable #include <swtable.hxx> // fuer UpdateTable #include <mdiexp.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <swevent.hxx> #include <poolfmt.hxx> #include <section.hxx> @@ -71,12 +66,8 @@ #include <navipi.hxx> #include <crsskip.hxx> #include <txtinet.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _WRTSH_HRC #include <wrtsh.hrc> -#endif #include "swabstdlg.hxx" #include "fldui.hrc" @@ -355,8 +346,8 @@ void SwWrtShell::ClickToINetAttr( const SwFmtINetFmt& rItem, USHORT nFilter ) const SwTxtINetFmt* pTxtAttr = rItem.GetTxtINetFmt(); if( pTxtAttr ) { - ((SwTxtINetFmt*)pTxtAttr)->SetVisited( sal_True ); - ((SwTxtINetFmt*)pTxtAttr)->SetValidVis( sal_True ); + const_cast<SwTxtINetFmt*>(pTxtAttr)->SetVisited( true ); + const_cast<SwTxtINetFmt*>(pTxtAttr)->SetVisitedValid( true ); } bIsInClickToEdit = FALSE; diff --git a/sw/uiconfig/swform/menubar/menubar.xml b/sw/uiconfig/swform/menubar/menubar.xml index df973292bcaa..13448e424754 100644 --- a/sw/uiconfig/swform/menubar/menubar.xml +++ b/sw/uiconfig/swform/menubar/menubar.xml @@ -37,7 +37,6 @@ </menu:menu> <menu:menuseparator/> <menu:menuitem menu:id=".uno:SetDocumentProperties"/> - <menu:menuitem menu:id=".uno:Signature"/> <menu:menu menu:id=".uno:TemplateMenu"> <menu:menupopup> <menu:menuitem menu:id=".uno:Organizer"/> @@ -421,7 +420,6 @@ <menu:menuitem menu:id=".uno:MacroRecorder"/> <menu:menuitem menu:id=".uno:RunMacro"/> <menu:menu menu:id=".uno:ScriptOrganizer"/> - <menu:menuitem menu:id=".uno:MacroSignature"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:MacroOrganizer?TabId:short=1"/> </menu:menupopup> diff --git a/sw/uiconfig/swreport/menubar/menubar.xml b/sw/uiconfig/swreport/menubar/menubar.xml index 5ef70e2eed70..1f94b7ced1c3 100644 --- a/sw/uiconfig/swreport/menubar/menubar.xml +++ b/sw/uiconfig/swreport/menubar/menubar.xml @@ -37,7 +37,6 @@ </menu:menu> <menu:menuseparator/> <menu:menuitem menu:id=".uno:SetDocumentProperties"/> - <menu:menuitem menu:id=".uno:Signature"/> <menu:menu menu:id=".uno:TemplateMenu"> <menu:menupopup> <menu:menuitem menu:id=".uno:Organizer"/> @@ -421,7 +420,6 @@ <menu:menuitem menu:id=".uno:MacroRecorder"/> <menu:menuitem menu:id=".uno:RunMacro"/> <menu:menu menu:id=".uno:ScriptOrganizer"/> - <menu:menuitem menu:id=".uno:MacroSignature"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:MacroOrganizer?TabId:short=1"/> </menu:menupopup> diff --git a/sw/util/makefile.mk b/sw/util/makefile.mk index 405604c9ee45..4fc3be91b954 100644 --- a/sw/util/makefile.mk +++ b/sw/util/makefile.mk @@ -255,7 +255,6 @@ LIB3OBJFILES = \ $(SLO)$/glossary.obj \ $(SLO)$/inpdlg.obj \ $(SLO)$/insfnote.obj \ - $(SLO)$/insrc.obj \ $(SLO)$/instable.obj \ $(SLO)$/insrule.obj \ $(SLO)$/javaedit.obj \ |