diff options
author | Michael Stahl <mst@openoffice.org> | 2010-03-16 11:28:30 +0100 |
---|---|---|
committer | Michael Stahl <mst@openoffice.org> | 2010-03-16 11:28:30 +0100 |
commit | 99a588660bd7f22a6c16d7b46f3c4fe841445ce0 (patch) | |
tree | f14802b9ede6901c2a066d742a8c329db134c42a /sw | |
parent | b0832f9ced2972f84f48d753554c1a5efc63d382 (diff) |
odfmetadata4: #i109599#: remove SwSection::operator=():
move most SwSection members to new class SwSectionData.
replace evil SwSection::operator=() with SwSection::SetSectionData().
various method signatures changed to take SwSectionData parameter.
rename SwDoc::ChgSection() to UpdateSection().
SwUnodo{Ins,Chg,Del}Section: adapt to store SwSectionData/SwTOXBase.
regionsw.hxx: SectRepr: change SwSection member to SwSectionData.
Diffstat (limited to 'sw')
37 files changed, 749 insertions, 568 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 3b0f82bce4b6..d433ff603b2f 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -164,6 +164,7 @@ class SwRubyList; class SwRubyListEntry; class SwSectionFmt; class SwSectionFmts; +class SwSectionData; class SwSelBoxes; class SwSpzFrmFmts; class SwTOXBase; @@ -1803,7 +1804,7 @@ public: inline const Link& GetOle2Link() const {return aOle2Link;} // insert section (the ODF kind of section, not the nodesarray kind) - SwSection * InsertSwSection(SwPaM const& rRange, SwSection const&, + SwSection * InsertSwSection(SwPaM const& rRange, SwSectionData &, SwTOXBase const*const pTOXBase = 0, SfxItemSet const*const pAttr = 0, bool const bUpdate = true); sal_uInt16 IsInsRegionAvailable( const SwPaM& rRange, @@ -1813,7 +1814,8 @@ public: const SwSectionFmts& GetSections() const { return *pSectionFmtTbl; } SwSectionFmt *MakeSectionFmt( SwSectionFmt *pDerivedFrom ); void DelSectionFmt( SwSectionFmt *pFmt, sal_Bool bDelNodes = sal_False ); - void ChgSection( sal_uInt16 nSect, const SwSection&, const SfxItemSet* = 0, sal_Bool bPreventLinkUpdate = FALSE); + void UpdateSection(sal_uInt16 const nSect, SwSectionData &, + SfxItemSet const*const = 0, bool const bPreventLinkUpdate = false); String GetUniqueSectionName( const String* pChkStr = 0 ) const; /* @@@MAINTAINABILITY-HORROR@@@ diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index 8cb9cbd5f26a..2d890f32a8bf 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -88,6 +88,7 @@ class SwTable; class SwTextBlocks; // fuer GlossaryRW class SwFmtFtn; class SwSection; +class SwSectionData; class SwSectionFmt; class SwTOXMarks; class SwTOXBase; @@ -805,9 +806,8 @@ public: // gebe Liste aller Fussnoten und deren Anfangstexte USHORT GetSeqFtnList( SwSeqFldList& rList, bool bEndNotes = false ); - // SS fuer Bereiche - const SwSection* InsertSection( const SwSection& rNew, - const SfxItemSet* = 0 ); + SwSection const* InsertSection( + SwSectionData & rNewData, SfxItemSet const*const = 0 ); BOOL IsInsRegionAvailable() const; const SwSection* GetCurrSection() const; // liefert wie GetCurrSection() den aktuellen Bereich, allerdings geht diese Funktion @@ -821,7 +821,8 @@ public: USHORT GetSectionFmtPos( const SwSectionFmt& ) const; const SwSectionFmt& GetSectionFmt(USHORT nFmt) const; void DelSectionFmt( USHORT nFmt ); - void ChgSection( USHORT nSect, const SwSection&, const SfxItemSet* = 0 ); + void UpdateSection(sal_uInt16 const nSect, SwSectionData &, + SfxItemSet const*const = 0); BOOL IsAnySectionInDoc( BOOL bChkReadOnly = FALSE, BOOL bChkHidden = FALSE, BOOL BChkTOX = FALSE ) const; @@ -867,7 +868,7 @@ public: BOOL IsGlblDocSaveLinks() const; USHORT GetGlobalDocContent( SwGlblDocContents& rArr ) const; BOOL InsertGlobalDocContent( const SwGlblDocContent& rPos, - const SwSection& rNew ); + SwSectionData & rNew ); BOOL InsertGlobalDocContent( const SwGlblDocContent& rPos, const SwTOXBase& rTOX ); BOOL InsertGlobalDocContent( const SwGlblDocContent& rPos ); diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx index df629c188dd5..d041dfc488c7 100644 --- a/sw/inc/ndarr.hxx +++ b/sw/inc/ndarr.hxx @@ -55,7 +55,7 @@ class SwNodeRange; class SwOLENode; class SwOutlineNodes; class SwPaM; -class SwSection; +class SwSectionData; class SwSectionFmt; class SwTOXBase; class SwSectionNode; @@ -313,7 +313,7 @@ public: // fuege eine neue SwSection ein SwSectionNode* InsertTextSection(SwNodeIndex const& rNdIdx, SwSectionFmt& rSectionFmt, - SwSection const&, + SwSectionData const&, SwTOXBase const*const pTOXBase, SwNodeIndex const*const pEnde, bool const bInsAtStart = true, diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx index 6ca584c82a11..6249251a7514 100644 --- a/sw/inc/section.hxx +++ b/sw/inc/section.hxx @@ -28,14 +28,15 @@ #ifndef _SECTION_HXX #define _SECTION_HXX +#include <boost/utility.hpp> #include <com/sun/star/uno/Sequence.h> + #include <sfx2/lnkbase.hxx> #include <tools/rtti.hxx> -#ifndef _TOOLS_REF_HXX #include <tools/ref.hxx> -#endif #include <svl/svarray.hxx> + #include <frmfmt.hxx> @@ -77,61 +78,119 @@ enum LinkCreateType CREATE_UPDATE // Link connecten und updaten }; +class SW_DLLPUBLIC SwSectionData +{ +private: + SectionType m_eType; + + String m_sSectionName; + String m_sCondition; + String m_sLinkFileName; + String m_sLinkFilePassword; // JP 27.02.2001: must be changed to Sequence + ::com::sun::star::uno::Sequence <sal_Int8> m_Password; + + /// it seems this flag caches the current final "hidden" state + bool m_bHiddenFlag : 1; + /// flags that correspond to attributes in the format: + /// may have different value than format attribute: + /// format attr has value for this section, while flag is + /// effectively ORed with parent sections! + bool m_bProtectFlag : 1; + // --> FME 2004-06-22 #114856# edit in readonly sections + bool m_bEditInReadonlyFlag : 1; + // <-- + bool m_bHidden : 1; // all paragraphs hidden? + bool m_bCondHiddenFlag : 1; // Hiddenflag for condition + bool m_bConnectFlag : 1; // connected to server? + +public: + + SwSectionData(SectionType const eType, String const& rName); + explicit SwSectionData(SwSection const&); + SwSectionData(SwSectionData const&); + SwSectionData & operator=(SwSectionData const&); + bool operator==(SwSectionData const&) const; + + String const& GetSectionName() const { return m_sSectionName; } + void SetSectionName(String const& rName){ m_sSectionName = rName; } + SectionType GetType() const { return m_eType; } + void SetType(SectionType const eNew) { m_eType = eNew; } + + bool IsHidden() const { return m_bHidden; } + void SetHidden(bool const bFlag = true) { m_bHidden = bFlag; } + + bool IsHiddenFlag() const { return m_bHiddenFlag; } + SW_DLLPRIVATE void + SetHiddenFlag(bool const bFlag) { m_bHiddenFlag = bFlag; } + bool IsProtectFlag() const { return m_bProtectFlag; } + SW_DLLPRIVATE void + SetProtectFlag(bool const bFlag) { m_bProtectFlag = bFlag; } + // --> FME 2004-06-22 #114856# edit in readonly sections + bool IsEditInReadonlyFlag() const { return m_bEditInReadonlyFlag; } + void SetEditInReadonlyFlag(bool const bFlag) + { m_bEditInReadonlyFlag = bFlag; } + // <-- + + void SetCondHidden(bool const bFlag = true) { m_bCondHiddenFlag = bFlag; }; + bool IsCondHidden() const { return m_bCondHiddenFlag; } + + String const& GetCondition() const { return m_sCondition; } + void SetCondition(String const& rNew) { m_sCondition = rNew; } + + String const& GetLinkFileName() const { return m_sLinkFileName; }; + void SetLinkFileName(String const& rNew, String const* pPassWd = 0) + { + m_sLinkFileName = rNew; + if (pPassWd) { SetLinkFilePassword(*pPassWd); } + } + + String const& GetLinkFilePassword() const { return m_sLinkFilePassword; } + void SetLinkFilePassword(String const& rS) { m_sLinkFilePassword = rS; } + + ::com::sun::star::uno::Sequence<sal_Int8> const& GetPassword() const + { return m_Password; } + void SetPassword(::com::sun::star::uno::Sequence<sal_Int8> const& rNew) + { m_Password = rNew; } + bool IsLinkType() const + { return (DDE_LINK_SECTION == m_eType) || (FILE_LINK_SECTION == m_eType); } -class SW_DLLPUBLIC SwSection : public SwClient + bool IsConnectFlag() const { return m_bConnectFlag; } + void SetConnectFlag(bool const bFlag = true){ m_bConnectFlag = bFlag; } +}; + +class SW_DLLPUBLIC SwSection + : public SwClient + , private ::boost::noncopyable { // damit beim Anlegen/Loeschen von Frames das Flag richtig gepflegt wird! friend class SwSectionNode; // the "read CTOR" of SwSectionFrm have to change the Hiddenflag friend class SwSectionFrm; - String sSectionNm; - String sCondition; // erstmal, vielleicht auch mal ein Feld ?? - String sLinkFileName, - sLinkFilePassWd; // JP 27.02.2001: must later changed to Sequence - ::com::sun::star::uno::Sequence <sal_Int8> aPasswd; +private: + SwSectionData m_Data; SwServerObjectRef refObj; // falls DataServer -> Pointer gesetzt ::sfx2::SvBaseLinkRef refLink; - SectionType eType; - - BOOL bProtectFlag : 1; // Flags fuer schnelle Abfragen, wird ueber - // Attribut im Format gesetzt - BOOL bHiddenFlag : 1; // Flag: Absaetze versteckt ? - // --> FME 2004-06-22 #114856# edit in readonly sections - BOOL bEditInReadonlyFlag : 1; - // <-- - BOOL bHidden : 1; // alle Absaetze nicht sichtbar ? - BOOL bCondHiddenFlag : 1; // Hiddenflag fuer die Bedingung ? - BOOL bConnectFlag : 1; // Flag: "Verbindung zum Server" vorhanden? - - - SW_DLLPRIVATE void _SetHiddenFlag( BOOL bHidden, BOOL bCondition ); - SW_DLLPRIVATE void _SetProtectFlag( BOOL bFlag ) { bProtectFlag = bFlag; } - /* SW_DLLPUBLIC */ BOOL _IsProtect() const; - - // --> FME 2004-06-22 #114856# edit in readonly sections - void _SetEditInReadonlyFlag( BOOL bFlag ) { bEditInReadonlyFlag = bFlag; } - BOOL _IsEditInReadonly() const; - // <-- + SW_DLLPRIVATE void ImplSetHiddenFlag( + bool const bHidden, bool const bCondition); public: TYPEINFO(); // rtti - SwSection( SectionType eType, const String& rName, - SwSectionFmt* pFmt = 0 ); - ~SwSection(); + SwSection(SectionType const eType, String const& rName, + SwSectionFmt & rFormat); + virtual ~SwSection(); + + bool DataEquals(SwSectionData const& rCmp) const; - // kopiere nur die Daten der Section! - // Ableitung bleibt (beim Left) erhalten. - SwSection& operator=( const SwSection& ); - BOOL operator==( const SwSection& rCmp ) const; + void SetSectionData(SwSectionData const& rData); - const String& GetName() const { return sSectionNm; } - void SetName( const String& rName ) { sSectionNm = rName; } - SectionType GetType() const { return eType; } - void SetType( SectionType eNew ) { eType = eNew; } + String const& GetName() const { return m_Data.GetSectionName(); } + void SetName(String const& rName) { m_Data.SetSectionName(rName); } + SectionType GetType() const { return m_Data.GetType(); } + void SetType(SectionType const eType) { return m_Data.SetType(eType); } SwSectionFmt* GetFmt() { return (SwSectionFmt*)pRegisteredIn; } SwSectionFmt* GetFmt() const { return (SwSectionFmt*)pRegisteredIn; } @@ -140,50 +199,47 @@ public: // setze die Hidden/Protected -> gesamten Baum updaten ! // (Attribute/Flags werden gesetzt/erfragt) - BOOL IsHidden() const { return bHidden; } - BOOL IsProtect() const { return GetFmt() ? _IsProtect() - : IsProtectFlag(); } - + bool IsHidden() const { return m_Data.IsHidden(); } + void SetHidden (bool const bFlag = true); + bool IsProtect() const; + void SetProtect(bool const bFlag = true); // --> FME 2004-06-22 #114856# edit in readonly sections - BOOL IsEditInReadonly()const { return GetFmt() ? _IsEditInReadonly() : IsEditInReadonlyFlag(); } - void SetEditInReadonly( BOOL bFlag = TRUE ); + bool IsEditInReadonly() const; + void SetEditInReadonly(bool const bFlag = true); // <-- - void SetHidden( BOOL bFlag = TRUE ); - void SetProtect( BOOL bFlag = TRUE ); - // erfrage die internen Flags (Zustand inklusive Parents nicht, was // aktuell an der Section gesetzt ist!!) - BOOL IsHiddenFlag() const { return bHiddenFlag; } - BOOL IsProtectFlag() const { return bProtectFlag; } + bool IsHiddenFlag() const { return m_Data.IsHiddenFlag(); } + bool IsProtectFlag() const { return m_Data.IsProtectFlag(); } // --> FME 2004-06-22 #114856# edit in readonly sections - BOOL IsEditInReadonlyFlag() const { return bEditInReadonlyFlag; } + bool IsEditInReadonlyFlag() const { return m_Data.IsEditInReadonlyFlag(); } // <-- - void SetCondHidden( BOOL bFlag = TRUE ); - BOOL IsCondHidden() const { return bCondHiddenFlag; } + void SetCondHidden(bool const bFlag = true); + bool IsCondHidden() const { return m_Data.IsCondHidden(); } // erfrage (auch ueber die Parents), ob diese Section versteckt sein soll. BOOL CalcHiddenFlag() const; inline SwSection* GetParent() const; - // setze/erfrage die Bedingung - const String& GetCondition() const { return sCondition; } - void SetCondition( const String& rNew ) { sCondition = rNew; } + String const& GetCondition() const { return m_Data.GetCondition(); } + void SetCondition(String const& rNew) { m_Data.SetCondition(rNew); } - // setze/erfrage den gelinkten FileNamen const String& GetLinkFileName() const; - void SetLinkFileName( const String& rNew, const String* pPassWd = 0 ); - // Passwort des gelinkten Files (nur waehrend der Laufzeit gueltig!) - const String& GetLinkFilePassWd() const { return sLinkFilePassWd; } - void SetLinkFilePassWd( const String& rS ) { sLinkFilePassWd = rS; } + void SetLinkFileName(String const& rNew, String const*const pPassWd = 0); + // password of linked file (only valid during runtime!) + String const& GetLinkFilePassword() const + { return m_Data.GetLinkFilePassword(); } + void SetLinkFilePassword(String const& rS) + { m_Data.SetLinkFilePassword(rS); } // get / set password of this section - const ::com::sun::star::uno::Sequence <sal_Int8>& - GetPasswd() const { return aPasswd; } - void SetPasswd( const ::com::sun::star::uno::Sequence <sal_Int8>& rNew ) - { aPasswd = rNew; } + ::com::sun::star::uno::Sequence<sal_Int8> const& GetPassword() const + { return m_Data.GetPassword(); } + void SetPassword(::com::sun::star::uno::Sequence <sal_Int8> const& rNew) + { m_Data.SetPassword(rNew); } // Daten Server-Methoden void SetRefObject( SwServerObject* pObj ); @@ -206,12 +262,12 @@ public: void MakeChildLinksVisible( const SwSectionNode& rSectNd ); - BOOL IsLinkType() const - { return DDE_LINK_SECTION == eType || FILE_LINK_SECTION == eType; } + bool IsLinkType() const { return m_Data.IsLinkType(); } // Flags fuer UI - Verbindung geklappt? - BOOL IsConnectFlag() const { return bConnectFlag; } - void SetConnectFlag( BOOL bFlag = TRUE ) { bConnectFlag = bFlag; } + bool IsConnectFlag() const { return m_Data.IsConnectFlag(); } + void SetConnectFlag(bool const bFlag = true) + { m_Data.SetConnectFlag(bFlag); } // return the TOX base class if the section is a TOX section const SwTOXBase* GetTOXBase() const; @@ -219,10 +275,7 @@ public: // --> OD 2007-02-14 #b6521322# void BreakLink(); // <-- -private: - // privater Constructor, weil nie kopiert werden darf !! - SwSection( const SwSection& ); - // @@@ but copy assignment "SwSection & operator= ( const SwSection& )" is public? @@@ + }; diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index 824e3269e1a5..d189f3c31349 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -73,7 +73,7 @@ class SwForm; struct CurTOXType; class SwTOXDescription; class SwTOXBase; -class SwSection; +class SwSectionData; struct SwDBData; class SwField; class Printer; @@ -194,7 +194,7 @@ public: class AbstractInsertSectionTabDialog : public VclAbstractDialog //add for SwInsertSectionTabDialog { public: - virtual void SetSection(const SwSection& rSect) = 0; + virtual void SetSectionData(SwSectionData const& rSect) = 0; }; class AbstractSwWordCountDialog : public VclAbstractDialog diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx index c1232bfb52bd..f0b9eac22fda 100644 --- a/sw/inc/undobj.hxx +++ b/sw/inc/undobj.hxx @@ -71,7 +71,7 @@ class SwTableBox; struct SwSortOptions; class SwFrmFmt; class SwHistoryBookmark; -class SwSection; +class SwSectionData; class SwSectionFmt; class SwTOXBase; class SvxTabStopItem; @@ -1382,7 +1382,7 @@ public: class SwUndoInsSection : public SwUndo, private SwUndRng { SwHistory* pHistory; - SwSection* pSection; + const ::std::auto_ptr<SwSectionData> m_pSectionData; const ::std::auto_ptr<SwTOXBase> m_pTOXBase; /// set iff section is TOX SwRedlineData* pRedlData; SfxItemSet* pAttr; @@ -1394,7 +1394,7 @@ class SwUndoInsSection : public SwUndo, private SwUndRng void Join( SwDoc& rDoc, ULONG nNode ); public: - SwUndoInsSection(SwPaM const&, SwSection const&, + SwUndoInsSection(SwPaM const&, SwSectionData const&, SfxItemSet const*const pSet, SwTOXBase const*const pTOXBase); virtual ~SwUndoInsSection(); virtual void Undo( SwUndoIter& ); @@ -1410,7 +1410,7 @@ public: class SwUndoDelSection : public SwUndo { ULONG nSttNd, nEndNd; - SwSection* pSection; + ::std::auto_ptr<SwSectionData> m_pSectionData; /// set iff section not TOX ::std::auto_ptr<SwTOXBase> m_pTOXBase; /// set iff section is TOX SfxItemSet* pAttr; public: @@ -1424,7 +1424,7 @@ public: class SwUndoChgSection : public SwUndo { ULONG nSttNd; - SwSection* pSection; + ::std::auto_ptr<SwSectionData> m_pSectionData; SfxItemSet* pAttr; BOOL bOnlyAttrChgd; public: diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 31c88825ec35..0caff6058136 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -2283,11 +2283,10 @@ BOOL SwDoc::RemoveInvisibleContent() } if( pSect->GetCondition().Len() ) { - SwSection aSect( pSect->GetType(), pSect->GetName() ); - aSect = *pSect; - aSect.SetCondition( aEmptyStr ); - aSect.SetHidden( FALSE ); - ChgSection( n, aSect ); + SwSectionData aSectionData( *pSect ); + aSectionData.SetCondition( aEmptyStr ); + aSectionData.SetHidden( false ); + UpdateSection( n, aSectionData ); } } diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index e332675569b6..53f7b36aa4bf 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -400,11 +400,11 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, default: { String sNm( INetURLObject( sFileName ).GetName() ); - SwSection aSect( FILE_LINK_SECTION, + SwSectionData aSectData( FILE_LINK_SECTION, GetUniqueSectionName( &sNm )); SwSectionFmt* pFmt = MakeSectionFmt( 0 ); - aSect.SetLinkFileName(sFileName ); - aSect.SetProtect(); + aSectData.SetLinkFileName(sFileName); + aSectData.SetProtectFlag(true); aEndIdx--; // im InsertSection ist Ende inclusive while( aEndIdx.GetNode().IsStartNode() ) @@ -458,12 +458,12 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, if (aEndIdx >= aStartIdx) { pSectNd = GetNodes().InsertTextSection(aStartIdx, - *pFmt, aSect, 0, &aEndIdx, false); + *pFmt, aSectData, 0, &aEndIdx, false); } else { pSectNd = GetNodes().InsertTextSection(aEndIdx, - *pFmt, aSect, 0, &aStartIdx, false); + *pFmt, aSectData, 0, &aStartIdx, false); } // <- #i26762# @@ -751,11 +751,11 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, int nOutlineLevel ) default: { String sNm( INetURLObject( sFileName ).GetName() ); - SwSection aSect( FILE_LINK_SECTION, + SwSectionData aSectData( FILE_LINK_SECTION, GetUniqueSectionName( &sNm )); SwSectionFmt* pFmt = MakeSectionFmt( 0 ); - aSect.SetLinkFileName(sFileName ); - aSect.SetProtect(); + aSectData.SetLinkFileName(sFileName); + aSectData.SetProtectFlag(true); aEndIdx--; // im InsertSection ist Ende inclusive while( aEndIdx.GetNode().IsStartNode() ) @@ -805,12 +805,12 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, int nOutlineLevel ) if (aEndIdx >= aStartIdx) { pSectNd = GetNodes().InsertTextSection(aStartIdx, - *pFmt, aSect, 0, &aEndIdx, false); + *pFmt, aSectData, 0, &aEndIdx, false); } else { pSectNd = GetNodes().InsertTextSection(aEndIdx, - *pFmt, aSect, 0, &aStartIdx, false); + *pFmt, aSectData, 0, &aStartIdx, false); } pSectNd->GetSection().CreateLink( CREATE_CONNECT ); diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 13aaf3c1c1a0..4fea35442347 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -369,9 +369,9 @@ const SwTOXBaseSection* SwDoc::InsertTableOf( const SwPosition& rPos, String sSectNm( rTOX.GetTOXName() ); sSectNm = GetUniqueTOXBaseName( *rTOX.GetTOXType(), &sSectNm ); SwPaM aPam( rPos ); - SwSection aSection( TOX_CONTENT_SECTION, sSectNm ); + SwSectionData aSectionData( TOX_CONTENT_SECTION, sSectNm ); SwTOXBaseSection *const pNewSection = dynamic_cast<SwTOXBaseSection *>( - InsertSwSection( aPam, aSection, & rTOX, pSet, false )); + InsertSwSection( aPam, aSectionData, & rTOX, pSet, false )); if (pNewSection) { SwSectionNode *const pSectNd = pNewSection->GetFmt()->GetSectionNode(); @@ -397,12 +397,12 @@ const SwTOXBaseSection* SwDoc::InsertTableOf( const SwPosition& rPos, // ??Resource sNm.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "_Head" )); - SwSection aSect( TOX_HEADER_SECTION, sNm ); + SwSectionData headerData( TOX_HEADER_SECTION, sNm ); SwNodeIndex aStt( *pHeadNd ); aIdx--; SwSectionFmt* pSectFmt = MakeSectionFmt( 0 ); GetNodes().InsertTextSection( - aStt, *pSectFmt, aSect, 0, &aIdx, true, false); + aStt, *pSectFmt, headerData, 0, &aIdx, true, false); } } @@ -431,7 +431,7 @@ const SwTOXBaseSection* SwDoc::InsertTableOf( ULONG nSttNd, ULONG nEndNd, String sSectNm( rTOX.GetTOXName() ); sSectNm = GetUniqueTOXBaseName(*rTOX.GetTOXType(), &sSectNm); - SwSection aSection(TOX_CONTENT_SECTION, sSectNm); + SwSectionData aSectionData( TOX_CONTENT_SECTION, sSectNm ); SwNodeIndex aStt( GetNodes(), nSttNd ), aEnd( GetNodes(), nEndNd ); SwSectionFmt* pFmt = MakeSectionFmt( 0 ); @@ -441,7 +441,7 @@ const SwTOXBaseSection* SwDoc::InsertTableOf( ULONG nSttNd, ULONG nEndNd, // --aEnd; // im InsertSection ist Ende inclusive SwSectionNode *const pNewSectionNode = - GetNodes().InsertTextSection(aStt, *pFmt, aSection, &rTOX, &aEnd); + GetNodes().InsertTextSection(aStt, *pFmt, aSectionData, &rTOX, &aEnd); if (!pNewSectionNode) { DelSectionFmt( pFmt ); @@ -768,7 +768,7 @@ const SwTxtNode* lcl_FindChapterNode( const SwNode& rNd, BYTE nLvl = 0 ) SwTOXBaseSection::SwTOXBaseSection(SwTOXBase const& rBase, SwSectionFmt & rFmt) : SwTOXBase( rBase ) - , SwSection( TOX_CONTENT_SECTION, aEmptyStr, & rFmt ) + , SwSection( TOX_CONTENT_SECTION, aEmptyStr, rFmt ) { SetProtect( rBase.IsProtected() ); SwSection::SetName( GetTOXName() ); @@ -953,12 +953,12 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr, // ??Resource sNm.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "_Head" )); - SwSection aSect( TOX_HEADER_SECTION, sNm ); + SwSectionData headerData( TOX_HEADER_SECTION, sNm ); SwNodeIndex aStt( *pHeadNd ); aIdx--; SwSectionFmt* pSectFmt = pDoc->MakeSectionFmt( 0 ); pDoc->GetNodes().InsertTextSection( - aStt, *pSectFmt, aSect, 0, &aIdx, true, false); + aStt, *pSectFmt, headerData, 0, &aIdx, true, false); } // jetzt waere ein prima Zeitpunkt, um die Numerierung zu updaten diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index 88203d87f10f..9fbe0c9b4a8f 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -137,7 +137,7 @@ bool lcl_IsInSameTblBox( SwNodes& _rNds, return true; } -void lcl_CheckEmptyLayFrm( SwNodes& rNds, SwSection& rSect, +void lcl_CheckEmptyLayFrm( SwNodes& rNds, SwSectionData& rSectionData, const SwNode& rStt, const SwNode& rEnd ) { SwNodeIndex aIdx( rStt ); @@ -151,12 +151,14 @@ void lcl_CheckEmptyLayFrm( SwNodes& rNds, SwSection& rSect, !CheckNodesRange( rEnd, aIdx, TRUE ) || // OD 04.11.2003 #i21457# !lcl_IsInSameTblBox( rNds, rEnd, false )) - rSect.SetHidden( FALSE ); + { + rSectionData.SetHidden( false ); + } } } SwSection * -SwDoc::InsertSwSection(SwPaM const& rRange, SwSection const& rNew, +SwDoc::InsertSwSection(SwPaM const& rRange, SwSectionData & rNewData, SwTOXBase const*const pTOXBase, SfxItemSet const*const pAttr, bool const bUpdate) { @@ -171,14 +173,15 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSection const& rNew, // Teste ob das gesamte Dokument versteckt werden soll, // koennen wir zur Zeit nicht !!!! - if( rNew.IsHidden() && rRange.HasMark() ) + if (rNewData.IsHidden() && rRange.HasMark()) { const SwPosition *pStt = rRange.Start(), *pEnd = rRange.End(); if( !pStt->nContent.GetIndex() && pEnd->nNode.GetNode().GetCntntNode()->Len() == pEnd->nContent.GetIndex() ) { - ::lcl_CheckEmptyLayFrm( GetNodes(), const_cast<SwSection&>(rNew), + ::lcl_CheckEmptyLayFrm( GetNodes(), + rNewData, pStt->nNode.GetNode(), pEnd->nNode.GetNode() ); } @@ -188,7 +191,7 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSection const& rNew, if( DoesUndo() ) { ClearRedo(); - pUndoInsSect = new SwUndoInsSection(rRange, rNew, pAttr, pTOXBase); + pUndoInsSect = new SwUndoInsSection(rRange, rNewData, pAttr, pTOXBase); AppendUndo( pUndoInsSect ); DoUndo( FALSE ); } @@ -219,7 +222,7 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSection const& rNew, --aEnd; // im InsertSection ist Ende inclusive pNewSectNode = GetNodes().InsertTextSection( - aStt, *pFmt, rNew, pTOXBase, & aEnd); + aStt, *pFmt, rNewData, pTOXBase, & aEnd); } else { @@ -291,7 +294,7 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSection const& rNew, } } pNewSectNode = GetNodes().InsertTextSection( - pSttPos->nNode, *pFmt, rNew, pTOXBase, &pEndPos->nNode); + pSttPos->nNode, *pFmt, rNewData, pTOXBase, &pEndPos->nNode); } } else @@ -301,12 +304,12 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSection const& rNew, if( !pPos->nContent.GetIndex() ) { pNewSectNode = GetNodes().InsertTextSection( - pPos->nNode, *pFmt, rNew, pTOXBase, 0, true); + pPos->nNode, *pFmt, rNewData, pTOXBase, 0, true); } else if( pPos->nContent.GetIndex() == pCNd->Len() ) { pNewSectNode = GetNodes().InsertTextSection( - pPos->nNode, *pFmt, rNew, pTOXBase, 0, false); + pPos->nNode, *pFmt, rNewData, pTOXBase, 0, false); } else { @@ -316,7 +319,7 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSection const& rNew, } SplitNode( *pPos, false ); pNewSectNode = GetNodes().InsertTextSection( - pPos->nNode, *pFmt, rNew, pTOXBase, 0, true); + pPos->nNode, *pFmt, rNewData, pTOXBase, 0, true); } } @@ -340,7 +343,7 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSection const& rNew, } // ist eine Condition gesetzt - if( rNew.IsHidden() && rNew.GetCondition().Len() ) + if (rNewData.IsHidden() && rNewData.GetCondition().Len()) { // dann berechne bis zu dieser Position SwCalc aCalc( *this ); @@ -374,7 +377,7 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSection const& rNew, DoUndo( TRUE ); } - if( rNew.IsLinkType() ) + if (rNewData.IsLinkType()) { pNewSectNode->GetSection().CreateLink( bUpdate ? CREATE_UPDATE : CREATE_CONNECT ); } @@ -615,9 +618,8 @@ void SwDoc::DelSectionFmt( SwSectionFmt *pFmt, BOOL bDelNodes ) SetModified(); } -void SwDoc::ChgSection( USHORT nPos, const SwSection& rSect, - const SfxItemSet* pAttr, - sal_Bool bPreventLinkUpdate ) +void SwDoc::UpdateSection(sal_uInt16 const nPos, SwSectionData & rNewData, + SfxItemSet const*const pAttr, bool const bPreventLinkUpdate) { SwSectionFmt* pFmt = (*pSectionFmtTbl)[ nPos ]; SwSection* pSection = pFmt->GetSection(); @@ -625,7 +627,7 @@ void SwDoc::ChgSection( USHORT nPos, const SwSection& rSect, /// remember hidden condition flag of SwSection before changes bool bOldCondHidden = pSection->IsCondHidden() ? true : false; - if( *pSection == rSect ) + if (pSection->DataEquals(rNewData)) { // die Attribute ueberpruefen BOOL bOnlyAttrChg = FALSE; @@ -674,12 +676,19 @@ void SwDoc::ChgSection( USHORT nPos, const SwSection& rSect, // versteckt werden soll, koennen wir zur Zeit nicht !!!! const SwNodeIndex* pIdx = 0; { - const SwSectionNode* pSectNd; - if( rSect.IsHidden() && 0 != (pIdx = pFmt->GetCntnt().GetCntntIdx() ) - && 0 != (pSectNd = pIdx->GetNode().GetSectionNode() ) ) + if (rNewData.IsHidden()) { - ::lcl_CheckEmptyLayFrm( GetNodes(), (SwSection&)rSect, + pIdx = pFmt->GetCntnt().GetCntntIdx(); + if (pIdx) + { + const SwSectionNode* pSectNd = + pIdx->GetNode().GetSectionNode(); + if (pSectNd) + { + ::lcl_CheckEmptyLayFrm( GetNodes(), rNewData, *pSectNd, *pSectNd->EndOfSectionNode() ); + } + } } } @@ -698,13 +707,13 @@ void SwDoc::ChgSection( USHORT nPos, const SwSection& rSect, // #56167# Der LinkFileName koennte auch nur aus Separatoren bestehen String sCompareString = sfx2::cTokenSeperator; sCompareString += sfx2::cTokenSeperator; - BOOL bUpdate = ( !pSection->IsLinkType() && rSect.IsLinkType() ) || - ( rSect.GetLinkFileName().Len() && - rSect.GetLinkFileName() != sCompareString && - rSect.GetLinkFileName() != - pSection->GetLinkFileName()); + const bool bUpdate = + (!pSection->IsLinkType() && rNewData.IsLinkType()) + || ( rNewData.GetLinkFileName().Len() + && (rNewData.GetLinkFileName() != sCompareString) + && (rNewData.GetLinkFileName() != pSection->GetLinkFileName())); - String sSectName( rSect.GetName() ); + String sSectName( rNewData.GetSectionName() ); if( sSectName != pSection->GetName() ) GetUniqueSectionName( &sSectName ); else @@ -717,7 +726,7 @@ void SwDoc::ChgSection( USHORT nPos, const SwSection& rSect, /// or it is set to the value of SwSection which is assigned to it. /// Discussion with AMA results that the adjustment to the assignment operator /// could be very risky -> see notes in bug #102894#. - *pSection = rSect; + pSection->SetSectionData(rNewData); if( pAttr ) pSection->GetFmt()->SetFmtAttr( *pAttr ); @@ -735,7 +744,7 @@ void SwDoc::ChgSection( USHORT nPos, const SwSection& rSect, FldsToCalc( aCalc, pIdx->GetIndex(), USHRT_MAX ); /// OD 04.10.2002 #102894# /// Because on using SwSection::operator=() to set up <pSection> - /// with <rSect> and the above given note, the hidden condition flag + /// with <rNewData> and the above given note, the hidden condition flag /// has to be set to FALSE, if hidden condition flag of <pFmt->GetSection()> /// (SwSection before the changes) is FALSE (already saved in <bOldCondHidden>) /// and new calculated condition is TRUE. @@ -806,15 +815,15 @@ void lcl_DeleteFtn( SwSectionNode *pNd, ULONG nStt, ULONG nEnd ) } } -inline BOOL lcl_IsTOXSection( const SwSection& rSection ) +static inline bool lcl_IsTOXSection(SwSectionData const& rSectionData) { - return TOX_CONTENT_SECTION == rSection.GetType() || - TOX_HEADER_SECTION == rSection.GetType(); + return (TOX_CONTENT_SECTION == rSectionData.GetType()) + || (TOX_HEADER_SECTION == rSectionData.GetType()); } SwSectionNode* SwNodes::InsertTextSection(SwNodeIndex const& rNdIdx, SwSectionFmt& rSectionFmt, - const SwSection& rSection, + SwSectionData const& rSectionData, SwTOXBase const*const pTOXBase, SwNodeIndex const*const pEnde, bool const bInsAtStart, bool const bCreateFrms) @@ -828,7 +837,7 @@ SwSectionNode* SwNodes::InsertTextSection(SwNodeIndex const& rNdIdx, if( bInsAtStart ) { - if( !lcl_IsTOXSection( rSection )) + if (!lcl_IsTOXSection(rSectionData)) { do { aInsPos--; @@ -840,11 +849,15 @@ SwSectionNode* SwNodes::InsertTextSection(SwNodeIndex const& rNdIdx, { SwNode* pNd; aInsPos++; - if( !lcl_IsTOXSection( rSection )) + if (!lcl_IsTOXSection(rSectionData)) + { while( aInsPos.GetIndex() < Count() - 1 && ( pNd = &aInsPos.GetNode())->IsEndNode() && pNd->StartOfSectionNode()->IsSectionNode()) + { aInsPos++; + } + } } } @@ -916,7 +929,7 @@ SwSectionNode* SwNodes::InsertTextSection(SwNodeIndex const& rNdIdx, } new SwEndNode( aInsPos, *pSectNd ); - pSectNd->GetSection() = rSection; + pSectNd->GetSection().SetSectionData(rSectionData); SwSectionFmt* pSectFmt = pSectNd->GetSection().GetFmt(); // Hier bietet sich als Optimierung an, vorhandene Frames nicht zu @@ -1018,7 +1031,7 @@ SwSectionNode::SwSectionNode(SwNodeIndex const& rIdx, } pSection = (pTOXBase) ? new SwTOXBaseSection(*pTOXBase, rFmt) - : new SwSection( CONTENT_SECTION, rFmt.GetName(), & rFmt ); + : new SwSection( CONTENT_SECTION, rFmt.GetName(), rFmt ); // jetzt noch die Verbindung von Format zum Node setzen // Modify unterdruecken, interresiert keinen @@ -1097,7 +1110,7 @@ SwSectionNode::~SwSectionNode() SwFrm *SwSectionNode::MakeFrm() { - pSection->bHiddenFlag = FALSE; + pSection->m_Data.SetHiddenFlag(false); return new SwSectionFrm( *pSection ); } @@ -1225,7 +1238,7 @@ void SwSectionNode::MakeFrms( SwNodeIndex* pIdxBehind, SwNodeIndex* pEndIdx ) *pIdxBehind = *this; - pSection->bHiddenFlag = TRUE; + pSection->m_Data.SetHiddenFlag(true); if( rNds.IsDocNodes() ) { @@ -1252,7 +1265,7 @@ void SwSectionNode::DelFrms() pSection->GetFmt()->DelFrms(); // unser Flag muessen wir noch aktualisieren - pSection->bHiddenFlag = TRUE; + pSection->m_Data.SetHiddenFlag(true); // Bug 30582: falls der Bereich in Fly oder TabellenBox ist, dann // kann er nur "gehiddet" werden, wenn weiterer Content @@ -1270,7 +1283,9 @@ void SwSectionNode::DelFrms() !CheckNodesRange( *EndOfSectionNode(), aIdx, TRUE ) || // OD 04.11.2003 #i21457# !lcl_IsInSameTblBox( rNds, *EndOfSectionNode(), false )) - pSection->bHiddenFlag = FALSE; + { + pSection->m_Data.SetHiddenFlag(false); + } } } } diff --git a/sw/source/core/docnode/node2lay.cxx b/sw/source/core/docnode/node2lay.cxx index b0d6a4a931b5..cce0919e1e1a 100644 --- a/sw/source/core/docnode/node2lay.cxx +++ b/sw/source/core/docnode/node2lay.cxx @@ -233,8 +233,8 @@ SwLayoutFrm* SwNode2LayImpl::UpperFrm( SwFrm* &rpFrm, const SwNode &rNode ) { // #137684#: pFrm could be a "dummy"-section if( ((SwSectionFrm*)pFrm)->GetSection() && - ((SwSectionNode*)pNode)->GetSection() == - *((SwSectionFrm*)pFrm)->GetSection() ) + (&((SwSectionNode*)pNode)->GetSection() == + ((SwSectionFrm*)pFrm)->GetSection()) ) { // OD 2004-06-02 #i22922# - consider columned sections // 'Go down' the section frame as long as the layout frame diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 653ce6794e7e..19e527658d5f 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -51,9 +51,7 @@ #include <frmtool.hxx> #include <editsh.hxx> #include <hints.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <ndtxt.hxx> #include <section.hxx> #include <swserv.hxx> @@ -115,39 +113,126 @@ SV_IMPL_PTRARR( SwSections, SwSection*) SV_IMPL_PTRARR(SwSectionFmts,SwSectionFmt*) +SwSectionData::SwSectionData(SectionType const eType, String const& rName) + : m_eType(eType) + , m_sSectionName(rName) + , m_bHiddenFlag(false) + , m_bProtectFlag(false) + // --> FME 2004-06-22 #114856# edit in readonly sections + , m_bEditInReadonlyFlag(false) + // <-- + , m_bHidden(false) + , m_bCondHiddenFlag(true) + , m_bConnectFlag(true) +{ +} -SwSection::SwSection( SectionType eTyp, const String& rName, - SwSectionFmt* pFmt ) - : SwClient( pFmt ), sSectionNm( rName ), - eType( eTyp ) +// this must have the same semantics as operator=() +SwSectionData::SwSectionData(SwSection const& rSection) + : m_eType(rSection.GetType()) + , m_sSectionName(rSection.GetName()) + , m_sCondition(rSection.GetCondition()) + , m_sLinkFileName(rSection.GetLinkFileName()) + , m_sLinkFilePassword(rSection.GetLinkFilePassword()) + , m_Password(rSection.GetPassword()) + , m_bHiddenFlag(rSection.IsHiddenFlag()) + , m_bProtectFlag(rSection.IsProtect()) + // --> FME 2004-06-22 #114856# edit in readonly sections + , m_bEditInReadonlyFlag(rSection.IsEditInReadonly()) + // <-- + , m_bHidden(rSection.IsHidden()) + , m_bCondHiddenFlag(true) + , m_bConnectFlag(rSection.IsConnectFlag()) { - bHidden = FALSE; - bHiddenFlag = FALSE; - bProtectFlag = FALSE; +} + +// this must have the same semantics as operator=() +SwSectionData::SwSectionData(SwSectionData const& rOther) + : m_eType(rOther.m_eType) + , m_sSectionName(rOther.m_sSectionName) + , m_sCondition(rOther.m_sCondition) + , m_sLinkFileName(rOther.m_sLinkFileName) + , m_sLinkFilePassword(rOther.m_sLinkFilePassword) + , m_Password(rOther.m_Password) + , m_bHiddenFlag(rOther.m_bHiddenFlag) + , m_bProtectFlag(rOther.m_bProtectFlag) // --> FME 2004-06-22 #114856# edit in readonly sections - bEditInReadonlyFlag = FALSE; + , m_bEditInReadonlyFlag(rOther.m_bEditInReadonlyFlag) // <-- - bCondHiddenFlag = TRUE; - bConnectFlag = TRUE; + , m_bHidden(rOther.m_bHidden) + , m_bCondHiddenFlag(true) + , m_bConnectFlag(rOther.m_bConnectFlag) +{ +} + +// the semantics here are weird for reasons of backward compatibility +SwSectionData & SwSectionData::operator= (SwSectionData const& rOther) +{ + m_eType = rOther.m_eType; + m_sSectionName = rOther.m_sSectionName; + m_sCondition = rOther.m_sCondition; + m_sLinkFileName = rOther.m_sLinkFileName; + m_sLinkFilePassword = rOther.m_sLinkFilePassword; + m_bConnectFlag = rOther.m_bConnectFlag; + m_Password = rOther.m_Password; + + m_bEditInReadonlyFlag = rOther.m_bEditInReadonlyFlag; + m_bProtectFlag = rOther.m_bProtectFlag; + + m_bHidden = rOther.m_bHidden; + // FIXME: old code did not assign m_bHiddenFlag ? + // FIXME: why should m_bCondHiddenFlag always default to true? + m_bCondHiddenFlag = true; + + return *this; +} + +// the semantics here are weird for reasons of backward compatibility +bool SwSectionData::operator==(SwSectionData const& rOther) const +{ + return (m_eType == rOther.m_eType) + && (m_sSectionName == rOther.m_sSectionName) + && (m_sCondition == rOther.m_sCondition) + && (m_bHidden == rOther.m_bHidden) + && (m_bProtectFlag == rOther.m_bProtectFlag) + && (m_bEditInReadonlyFlag == rOther.m_bEditInReadonlyFlag) + && (m_sLinkFileName == rOther.m_sLinkFileName) + && (m_sLinkFilePassword == rOther.m_sLinkFilePassword) + && (m_Password == rOther.m_Password); + // FIXME: old code ignored m_bCondHiddenFlag m_bHiddenFlag m_bConnectFlag +} - SwSectionPtr pParentSect = GetParent(); +// SwSection =========================================================== + +SwSection::SwSection( + SectionType const eType, String const& rName, SwSectionFmt & rFormat) + : SwClient(& rFormat) + , m_Data(eType, rName) +{ + SwSection *const pParentSect = GetParent(); if( pParentSect ) { if( pParentSect->IsHiddenFlag() ) - SetHidden( TRUE ); + { + SetHidden( true ); + } - _SetProtectFlag( pParentSect->IsProtectFlag() ); + m_Data.SetProtectFlag( pParentSect->IsProtectFlag() ); // --> FME 2004-06-22 #114856# edit in readonly sections - _SetEditInReadonlyFlag( pParentSect->IsEditInReadonlyFlag() ); + m_Data.SetEditInReadonlyFlag( pParentSect->IsEditInReadonlyFlag() ); // <-- } - if( pFmt && !bProtectFlag ) - _SetProtectFlag( pFmt->GetProtect().IsCntntProtected() ); + if (!m_Data.IsProtectFlag()) + { + m_Data.SetProtectFlag( rFormat.GetProtect().IsCntntProtected() ); + } // --> FME 2004-06-22 #114856# edit in readonly sections - if ( pFmt && !bEditInReadonlyFlag ) - _SetEditInReadonlyFlag( pFmt->GetEditInReadonly().GetValue() ); + if (!m_Data.IsEditInReadonlyFlag()) + { + m_Data.SetEditInReadonlyFlag( rFormat.GetEditInReadonly().GetValue() ); + } // <-- } @@ -170,8 +255,10 @@ SwSection::~SwSection() { pFmt->Remove( this ); // austragen, - if( CONTENT_SECTION != eType ) // den Link austragen + if (CONTENT_SECTION != m_Data.GetType()) + { pDoc->GetLinkManager().Remove( refLink ); + } if( refObj.Is() ) // als Server austragen pDoc->GetLinkManager().RemoveServer( &refObj ); @@ -194,74 +281,50 @@ SwSection::~SwSection() refObj->Closed(); } - -SwSection& SwSection::operator=( const SwSection& rCpy ) +void SwSection::SetSectionData(SwSectionData const& rData) { - sSectionNm = rCpy.sSectionNm; - sCondition = rCpy.sCondition; - sLinkFileName = rCpy.GetLinkFileName(); - SetLinkFilePassWd( rCpy.GetLinkFilePassWd() ); - SetConnectFlag( rCpy.IsConnectFlag() ); - SetPasswd( rCpy.GetPasswd() ); - - eType = rCpy.eType; - - if( !GetFmt() ) + bool const bOldHidden( m_Data.IsHidden() ); + m_Data = rData; + // now update format and reflink with new data +// SetLinkFileName(m_Data.GetLinkFileName()); // old code did not do this? + // next 2 may actually overwrite m_Data.m_b{Protect,EditInReadonly}Flag + // in Modify, which should result in same flag value as the old code! + SetProtect(m_Data.IsProtectFlag()); + SetEditInReadonly(m_Data.IsEditInReadonlyFlag()); + if (bOldHidden != m_Data.IsHidden()) // check if changed... { - SetProtect( rCpy.IsProtect() ); - // --> FME 2004-06-22 #114856# edit in readonly sections - SetEditInReadonly( rCpy.IsEditInReadonly() ); - // <-- + ImplSetHiddenFlag(m_Data.IsHidden(), m_Data.IsCondHidden()); } - else if( rCpy.GetFmt() ) - { - _SetProtectFlag( rCpy.bProtectFlag ); - // --> FME 2004-06-22 #114856# edit in readonly sections - _SetEditInReadonlyFlag( rCpy.bEditInReadonlyFlag ); - // <-- - } - else - { - SetProtect( rCpy.bProtectFlag ); - // --> FME 2004-06-22 #114856# edit in readonly sections - SetEditInReadonly( rCpy.bEditInReadonlyFlag ); - // <-- - } - - bCondHiddenFlag = TRUE; // sollte immer defaultet werden - SetHidden( rCpy.bHidden ); - - return *this; } - -BOOL SwSection::operator==( const SwSection& rCmp ) const +bool SwSection::DataEquals(SwSectionData const& rCmp) const { - return sSectionNm == rCmp.sSectionNm && - sCondition == rCmp.sCondition && - eType == rCmp.eType && - bHidden == rCmp.bHidden && - IsProtect() == rCmp.IsProtect() && - // --> FME 2004-06-22 #114856# edit in readonly sections - IsEditInReadonly() == rCmp.IsEditInReadonly() && - // <-- - GetLinkFileName() == rCmp.GetLinkFileName() && - GetLinkFilePassWd() == rCmp.GetLinkFilePassWd() && - GetPasswd() == rCmp.GetPasswd() && - ( !GetFmt() || !rCmp.GetFmt() || GetFmt() == rCmp.GetFmt()); + // note that the old code compared the flags of the parameter with the + // format attributes of this; the following mess should do the same... + (void) GetLinkFileName(); // updates m_sLinkFileName + bool const bProtect(m_Data.IsProtectFlag()); + bool const bEditInReadonly(m_Data.IsEditInReadonlyFlag()); + const_cast<SwSection*>(this)->m_Data.SetProtectFlag(IsProtect()); + const_cast<SwSection*>(this)->m_Data + .SetEditInReadonlyFlag(IsEditInReadonly()); + bool const bResult( m_Data == rCmp ); + const_cast<SwSection*>(this)->m_Data.SetProtectFlag(bProtect); + const_cast<SwSection*>(this)->m_Data.SetEditInReadonlyFlag(bEditInReadonly); + return bResult; } -void SwSection::_SetHiddenFlag( BOOL bTmpHidden, BOOL bCondition ) +void SwSection::ImplSetHiddenFlag(bool const bTmpHidden, bool const bCondition) { SwSectionFmt* pFmt = GetFmt(); + ASSERT(pFmt, "ImplSetHiddenFlag: no format?"); if( pFmt ) { - BOOL bHide = bTmpHidden && bCondition; + const bool bHide = bTmpHidden && bCondition; - if( bHide ) // die Nodes also "verstecken" + if (bHide) // should be hidden { - if( !bHiddenFlag ) // ist nicht versteckt + if (!m_Data.IsHiddenFlag()) // is not hidden { // wie sieht es mit dem Parent aus, ist der versteckt ? // (eigentlich muesste das vom bHiddenFlag angezeigt werden!) @@ -274,7 +337,7 @@ void SwSection::_SetHiddenFlag( BOOL bTmpHidden, BOOL bCondition ) pFmt->DelFrms(); } } - else if( bHiddenFlag ) // die Nodes wieder anzeigen + else if (m_Data.IsHiddenFlag()) // show Nodes again { // alle Frames sichtbar machen ( Childs Sections werden vom // MakeFrms beruecksichtigt). Aber nur wenn die ParentSection @@ -304,57 +367,76 @@ BOOL SwSection::CalcHiddenFlag() const return FALSE; } -BOOL SwSection::_IsProtect() const +bool SwSection::IsProtect() const { - return GetFmt()->GetProtect().IsCntntProtected(); + SwSectionFmt *const pFmt( GetFmt() ); + ASSERT(pFmt, "SwSection::IsProtect: no format?"); + return (pFmt) + ? pFmt->GetProtect().IsCntntProtected() + : IsProtectFlag(); } // --> FME 2004-06-22 #114856# edit in readonly sections -BOOL SwSection::_IsEditInReadonly() const +bool SwSection::IsEditInReadonly() const { - return GetFmt()->GetEditInReadonly().GetValue(); + SwSectionFmt *const pFmt( GetFmt() ); + ASSERT(pFmt, "SwSection::IsEditInReadonly: no format?"); + return (pFmt) + ? pFmt->GetEditInReadonly().GetValue() + : IsEditInReadonlyFlag(); } // <-- -void SwSection::SetHidden( BOOL bFlag ) +void SwSection::SetHidden(bool const bFlag) { - if( !bHidden == !bFlag ) + if (!m_Data.IsHidden() == !bFlag) return; - bHidden = bFlag; - _SetHiddenFlag( bHidden, bCondHiddenFlag ); + m_Data.SetHidden(bFlag); + ImplSetHiddenFlag(bFlag, m_Data.IsCondHidden()); } -void SwSection::SetProtect( BOOL bFlag ) +void SwSection::SetProtect(bool const bFlag) { - if( GetFmt() ) + SwSectionFmt *const pFormat( GetFmt() ); + ASSERT(pFormat, "SwSection::SetProtect: no format?"); + if (pFormat) { SvxProtectItem aItem( RES_PROTECT ); aItem.SetCntntProtect( (BOOL)bFlag ); - GetFmt()->SetFmtAttr( aItem ); + pFormat->SetFmtAttr( aItem ); + // note: this will call m_Data.SetProtectFlag via Modify! } else - bProtectFlag = bFlag; + { + m_Data.SetProtectFlag(bFlag); + } } // --> FME 2004-06-22 #114856# edit in readonly sections -void SwSection::SetEditInReadonly( BOOL bFlag ) +void SwSection::SetEditInReadonly(bool const bFlag) { - if( GetFmt() ) + SwSectionFmt *const pFormat( GetFmt() ); + ASSERT(pFormat, "SwSection::SetEditInReadonly: no format?"); + if (pFormat) { SwFmtEditInReadonly aItem; aItem.SetValue( (BOOL)bFlag ); - GetFmt()->SetFmtAttr( aItem ); + pFormat->SetFmtAttr( aItem ); + // note: this will call m_Data.SetEditInReadonlyFlag via Modify! } else - bEditInReadonlyFlag = bFlag; + { + m_Data.SetEditInReadonlyFlag(bFlag); + } } // <-- void SwSection::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) { - BOOL bRemake = FALSE, bUpdateFtn = FALSE; + bool bRemake = false; + bool bUpdateFtn = false; switch( pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ) { case RES_ATTRSET_CHG: @@ -366,7 +448,8 @@ void SwSection::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) if( SFX_ITEM_SET == pNewSet->GetItemState( RES_PROTECT, FALSE, &pItem ) ) { - _SetProtectFlag( ((SvxProtectItem*)pItem)->IsCntntProtected() ); + m_Data.SetProtectFlag( static_cast<SvxProtectItem const*>(pItem) + ->IsCntntProtected() ); pNewSet->ClearItem( RES_PROTECT ); pOldSet->ClearItem( RES_PROTECT ); } @@ -375,7 +458,8 @@ void SwSection::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) if( SFX_ITEM_SET == pNewSet->GetItemState( RES_EDIT_IN_READONLY, FALSE, &pItem ) ) { - _SetEditInReadonlyFlag( ((SwFmtEditInReadonly*)pItem)->GetValue() ); + m_Data.SetEditInReadonlyFlag( + static_cast<SwFmtEditInReadonly const*>(pItem)->GetValue()); pNewSet->ClearItem( RES_EDIT_IN_READONLY ); pOldSet->ClearItem( RES_EDIT_IN_READONLY ); } @@ -385,7 +469,9 @@ void SwSection::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) RES_FTN_AT_TXTEND, FALSE, &pItem ) || SFX_ITEM_SET == pNewSet->GetItemState( RES_END_AT_TXTEND, FALSE, &pItem )) - bUpdateFtn = TRUE; + { + bUpdateFtn = true; + } if( !pNewSet->Count() ) return; @@ -395,7 +481,8 @@ void SwSection::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) case RES_PROTECT: if( pNew ) { - BOOL bNewFlag = ((SvxProtectItem*)pNew)->IsCntntProtected(); + bool bNewFlag = + static_cast<SvxProtectItem*>(pNew)->IsCntntProtected(); if( !bNewFlag ) { // Abschalten: teste ob nicht vielleich ueber die Parents @@ -404,32 +491,34 @@ void SwSection::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) do { if( pSect->IsProtect() ) { - bNewFlag = TRUE; + bNewFlag = true; break; } - } while( 0 != ( pSect = pSect->GetParent()) ); + pSect = pSect->GetParent(); + } while (pSect); } - _SetProtectFlag( bNewFlag ); + m_Data.SetProtectFlag( bNewFlag ); } return; // --> FME 2004-06-22 #114856# edit in readonly sections case RES_EDIT_IN_READONLY: if( pNew ) { - BOOL bNewFlag = ((SwFmtEditInReadonly*)pNew)->GetValue(); - _SetEditInReadonlyFlag( bNewFlag ); + const bool bNewFlag = + static_cast<SwFmtEditInReadonly*>(pNew)->GetValue(); + m_Data.SetEditInReadonlyFlag( bNewFlag ); } return; // <-- case RES_SECTION_HIDDEN: - bHiddenFlag = TRUE; + m_Data.SetHiddenFlag(true); return; case RES_SECTION_NOT_HIDDEN: case RES_SECTION_RESETHIDDENFLAG: - bHiddenFlag = bHidden && bCondHiddenFlag; + m_Data.SetHiddenFlag( m_Data.IsHidden() && m_Data.IsCondHidden() ); return; case RES_COL: @@ -438,12 +527,16 @@ void SwSection::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) case RES_FTN_AT_TXTEND: if( pNew && pOld ) - bUpdateFtn = TRUE; + { + bUpdateFtn = true; + } break; case RES_END_AT_TXTEND: if( pNew && pOld ) - bUpdateFtn = TRUE; + { + bUpdateFtn = true; + } break; } @@ -468,13 +561,13 @@ void SwSection::SetRefObject( SwServerObject* pObj ) } -void SwSection::SetCondHidden( BOOL bFlag ) +void SwSection::SetCondHidden(bool const bFlag) { - if( !bCondHiddenFlag == !bFlag ) + if (!m_Data.IsCondHidden() == !bFlag) return; - bCondHiddenFlag = bFlag; - _SetHiddenFlag( bHidden, bCondHiddenFlag ); + m_Data.SetCondHidden(bFlag); + ImplSetHiddenFlag(m_Data.IsHidden(), bFlag); } @@ -484,7 +577,7 @@ const String& SwSection::GetLinkFileName() const if( refLink.Is() ) { String sTmp; - switch( eType ) + switch (m_Data.GetType()) { case DDE_LINK_SECTION: sTmp = refLink->GetLinkSourceName(); @@ -505,26 +598,29 @@ const String& SwSection::GetLinkFileName() const // ist die Section im UndoNodesArray, dann steht // der Link nicht im LinkManager, kann also auch nicht // erfragt werden. Dann returne den akt. Namen - return sLinkFileName; + return m_Data.GetLinkFileName(); } } break; default: break; } - ((SwSection*)this)->sLinkFileName = sTmp; + const_cast<SwSection*>(this)->m_Data.SetLinkFileName(sTmp); } - return sLinkFileName; + return m_Data.GetLinkFileName(); } -void SwSection::SetLinkFileName( const String& rNew, const String* pPassWd ) +void SwSection::SetLinkFileName(const String& rNew, String const*const pPassWd) { if( refLink.Is() ) + { refLink->SetLinkSourceName( rNew ); - else - sLinkFileName = rNew; + } + m_Data.SetLinkFileName(rNew); if( pPassWd ) - SetLinkFilePassWd( *pPassWd ); + { + SetLinkFilePassword( *pPassWd ); + } } // falls es ein gelinkter Bereich war, dann muessen alle @@ -563,6 +659,8 @@ const SwTOXBase* SwSection::GetTOXBase() const return pRet; } +// SwSectionFmt ======================================================== + SwSectionFmt::SwSectionFmt( SwSectionFmt* pDrvdFrm, SwDoc *pDoc ) : SwFrmFmt( pDoc->GetAttrPool(), sSectionFmtNm, pDrvdFrm ) { @@ -594,7 +692,7 @@ SwSectionFmt::~SwSectionFmt() if( !pParentSect || !pParentSect->IsHiddenFlag() ) { // Nodes wieder anzeigen - rSect.SetHidden( FALSE ); + rSect.SetHidden(false); } } SwClientIter aIter( *this ); @@ -923,7 +1021,7 @@ USHORT SwSectionFmt::GetChildSections( SwSections& rArr, if( GetDepends() ) { - SwClientIter aIter( *(SwSectionFmt*)this ); + SwClientIter aIter( *this ); SwClient * pLast; const SwNodeIndex* pIdx; for( pLast = aIter.First(TYPE(SwSectionFmt)); pLast; pLast = aIter.Next() ) @@ -979,7 +1077,7 @@ void SwSectionFmt::UpdateParent() // Parent wurde veraendert // --> FME 2004-06-22 #114856# edit in readonly sections const SwFmtEditInReadonly* pEditInReadonly = 0; // <-- - int bIsHidden = FALSE; + bool bIsHidden = false; SwClientIter aIter( *this ); SwClient * pLast = aIter.GoStart(); @@ -1008,16 +1106,20 @@ void SwSectionFmt::UpdateParent() // Parent wurde veraendert bIsHidden = pSection->IsHidden(); } } - if( pProtect->IsCntntProtected() != - pSection->IsProtectFlag() ) + if (!pProtect->IsCntntProtected() != + !pSection->IsProtectFlag()) + { pLast->Modify( (SfxPoolItem*)pProtect, (SfxPoolItem*)pProtect ); + } // --> FME 2004-06-22 #114856# edit in readonly sections - if ( pEditInReadonly->GetValue() != - pSection->IsEditInReadonlyFlag() ) + if (!pEditInReadonly->GetValue() != + !pSection->IsEditInReadonlyFlag()) + { pLast->Modify( (SfxPoolItem*)pEditInReadonly, (SfxPoolItem*)pEditInReadonly ); + } // <-- if( bIsHidden == pSection->IsHiddenFlag() ) @@ -1330,7 +1432,7 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType, } SwSection& rSection = pSectNd->GetSection(); - rSection.SetConnectFlag( FALSE ); + rSection.SetConnectFlag(false); ::rtl::OUString sNewFileName; Reader* pRead = 0; @@ -1362,7 +1464,7 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType, else { nRet = lcl_FindDocShell( xDocSh, sFileName, - rSection.GetLinkFilePassWd(), + rSection.GetLinkFilePassword(), sFilter, 0, pDoc->GetDocShell() ); if( nRet ) { @@ -1374,18 +1476,18 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType, if( nRet ) { - rSection.SetConnectFlag( TRUE ); + rSection.SetConnectFlag(true); SwNodeIndex aSave( pPam->GetPoint()->nNode, -1 ); SwNodeRange* pCpyRg = 0; if( xDocSh->GetMedium() && - !rSection.GetLinkFilePassWd().Len() ) + !rSection.GetLinkFilePassword().Len() ) { const SfxPoolItem* pItem; if( SFX_ITEM_SET == xDocSh->GetMedium()->GetItemSet()-> GetItemState( SID_PASSWORD, FALSE, &pItem ) ) - rSection.SetLinkFilePassWd( + rSection.SetLinkFilePassword( ((SfxStringItem*)pItem)->GetValue() ); } @@ -1518,7 +1620,9 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType, SwReader aTmpReader( aStrm, aEmptyStr, pDoc->GetDocShell()->GetMedium()->GetBaseURL(), *pPam ); if( !IsError( aTmpReader.Read( *pRead ) )) - rSection.SetConnectFlag( TRUE ); + { + rSection.SetConnectFlag(true); + } if( pESh ) { @@ -1565,19 +1669,18 @@ void SwIntrnlSectRefLink::Closed() else pSh->StartAction(); - SwSection aSect( CONTENT_SECTION, aEmptyStr ); - aSect = *rSectFmt.GetSection(); - aSect.SetType( CONTENT_SECTION ); - aSect.SetLinkFileName( aEmptyStr ); - aSect.SetHidden( FALSE ); - aSect.SetProtect( FALSE ); + SwSectionData aSectionData(*rSectFmt.GetSection()); + aSectionData.SetType( CONTENT_SECTION ); + aSectionData.SetLinkFileName( aEmptyStr ); + aSectionData.SetHidden( false ); + aSectionData.SetProtectFlag( false ); // --> FME 2004-06-22 #114856# edit in readonly sections - aSect.SetEditInReadonly( FALSE ); + aSectionData.SetEditInReadonlyFlag( false ); // <-- - aSect.SetConnectFlag( FALSE ); + aSectionData.SetConnectFlag( false ); - pDoc->ChgSection( n, aSect ); + pDoc->UpdateSection( n, aSectionData ); // alle in der Section liegenden Links werden sichtbar SwSectionNode* pSectNd = rSectFmt.GetSectionNode( FALSE ); @@ -1598,7 +1701,8 @@ void SwIntrnlSectRefLink::Closed() void SwSection::CreateLink( LinkCreateType eCreateType ) { SwSectionFmt* pFmt = GetFmt(); - if( !pFmt || CONTENT_SECTION == eType ) + ASSERT(pFmt, "SwSection::CreateLink: no format?"); + if (!pFmt || (CONTENT_SECTION == m_Data.GetType())) return ; USHORT nUpdateType = sfx2::LINKUPDATE_ALWAYS; @@ -1612,7 +1716,7 @@ void SwSection::CreateLink( LinkCreateType eCreateType ) SwIntrnlSectRefLink* pLnk = (SwIntrnlSectRefLink*)&refLink; - String sCmd( sLinkFileName ); + String sCmd( m_Data.GetLinkFileName() ); xub_StrLen nPos; while( STRING_NOTFOUND != (nPos = sCmd.SearchAscii( " " )) ) sCmd.Erase( nPos, 1 ); @@ -1620,7 +1724,7 @@ void SwSection::CreateLink( LinkCreateType eCreateType ) pLnk->SetUpdateMode( nUpdateType ); pLnk->SetVisible( pFmt->GetDoc()->IsVisibleLinks() ); - switch( eType ) + switch (m_Data.GetType()) { case DDE_LINK_SECTION: pLnk->SetLinkSourceName( sCmd ); @@ -1632,7 +1736,7 @@ void SwSection::CreateLink( LinkCreateType eCreateType ) String sFltr( sCmd.GetToken( 1, sfx2::cTokenSeperator ) ); String sRange( sCmd.GetToken( 2, sfx2::cTokenSeperator ) ); pFmt->GetDoc()->GetLinkManager().InsertFileLink( *pLnk, - static_cast<USHORT>(eType), + static_cast<USHORT>(m_Data.GetType()), sCmd.GetToken( 0, sfx2::cTokenSeperator ), ( sFltr.Len() ? &sFltr : 0 ), ( sRange.Len() ? &sRange : 0 ) ); @@ -1670,9 +1774,11 @@ void SwSection::BreakLink() // release link, if it exists if ( refLink.Is() ) { - if ( GetFmt() ) + SwSectionFmt *const pFormat( GetFmt() ); + ASSERT(pFormat, "SwSection::BreakLink: no format?"); + if (pFormat) { - GetFmt()->GetDoc()->GetLinkManager().Remove( refLink ); + pFormat->GetDoc()->GetLinkManager().Remove( refLink ); } refLink.Clear(); } @@ -1680,7 +1786,7 @@ void SwSection::BreakLink() SetType( CONTENT_SECTION ); // reset linked file data SetLinkFileName( aEmptyStr ); - SetLinkFilePassWd( aEmptyStr ); + SetLinkFilePassword( aEmptyStr ); } // <-- diff --git a/sw/source/core/edit/edglbldc.cxx b/sw/source/core/edit/edglbldc.cxx index 5ecc92e79acb..6f884f244326 100644 --- a/sw/source/core/edit/edglbldc.cxx +++ b/sw/source/core/edit/edglbldc.cxx @@ -146,7 +146,7 @@ USHORT SwEditShell::GetGlobalDocContent( SwGlblDocContents& rArr ) const } BOOL SwEditShell::InsertGlobalDocContent( const SwGlblDocContent& rInsPos, - const SwSection& rNew ) + SwSectionData & rNew) { if( !getIDocumentSettingAccess()->get(IDocumentSettingAccess::GLOBAL_DOCUMENT) ) return FALSE; diff --git a/sw/source/core/edit/edsect.cxx b/sw/source/core/edit/edsect.cxx index 0b0533b3e745..ba3c2e9c7966 100644 --- a/sw/source/core/edit/edsect.cxx +++ b/sw/source/core/edit/edsect.cxx @@ -42,9 +42,9 @@ #include <rootfrm.hxx> // SwRootFrm - // SS fuer Bereiche -const SwSection* SwEditShell::InsertSection( const SwSection& rNew, - const SfxItemSet* pAttr ) +SwSection const* +SwEditShell::InsertSection( + SwSectionData & rNewData, SfxItemSet const*const pAttr) { const SwSection* pRet = 0; if( !IsTableMode() ) @@ -54,7 +54,7 @@ const SwSection* SwEditShell::InsertSection( const SwSection& rNew, FOREACHPAM_START(this) SwSection const*const pNew = - GetDoc()->InsertSwSection( *PCURCRSR, rNew, 0, pAttr ); + GetDoc()->InsertSwSection( *PCURCRSR, rNewData, 0, pAttr ); if( !pRet ) pRet = pNew; FOREACHPAM_END() @@ -178,11 +178,11 @@ void SwEditShell::DelSectionFmt( USHORT nFmt ) } -void SwEditShell::ChgSection( USHORT nSect, const SwSection& rSect, - const SfxItemSet* pAttr ) +void SwEditShell::UpdateSection(sal_uInt16 const nSect, + SwSectionData & rNewData, SfxItemSet const*const pAttr) { StartAllAction(); - GetDoc()->ChgSection( nSect, rSect, pAttr ); + GetDoc()->UpdateSection( nSect, rNewData, pAttr ); // rufe das AttrChangeNotify auf der UI-Seite. CallChgLnk(); EndAllAction(); diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx index 97b2531cdbe2..95f6961c76e1 100644 --- a/sw/source/core/edit/edtox.cxx +++ b/sw/source/core/edit/edtox.cxx @@ -132,10 +132,9 @@ void SwEditShell::SetTOXBaseReadonly(const SwTOXBase& rTOXBase, BOOL bReadonly) ((SwTOXBase&)rTOXBase).SetProtected(bReadonly); ASSERT( rTOXSect.SwSection::GetType() == TOX_CONTENT_SECTION, "not a TOXContentSection" ); - SwSection aSect(TOX_CONTENT_SECTION, rTOXSect.GetName()); - aSect = rTOXSect; - aSect.SetProtect(bReadonly); - ChgSection( GetSectionFmtPos( *rTOXSect.GetFmt() ), aSect, 0 ); + SwSectionData aSectionData(rTOXSect); + aSectionData.SetProtectFlag(bReadonly); + UpdateSection( GetSectionFmtPos( *rTOXSect.GetFmt() ), aSectionData, 0 ); } /* -----------------02.09.99 07:47------------------- diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx index 2651251d4cf4..2cf07350341f 100644 --- a/sw/source/core/undo/unsect.cxx +++ b/sw/source/core/undo/unsect.cxx @@ -75,16 +75,14 @@ SfxItemSet* lcl_GetAttrSet( const SwSection& rSect ) } SwUndoInsSection::SwUndoInsSection( - SwPaM const& rPam, SwSection const& rNew, + SwPaM const& rPam, SwSectionData const& rNewData, SfxItemSet const*const pSet, SwTOXBase const*const pTOXBase) : SwUndo( UNDO_INSSECTION ), SwUndRng( rPam ) , pHistory( 0 ) - , pSection(new SwSection(rNew.GetType(), rNew.GetName())) + , m_pSectionData(new SwSectionData(rNewData)) , m_pTOXBase(pTOXBase ? new SwTOXBase(*pTOXBase) : 0) , pRedlData( 0 ), pAttr( 0 ), nSectNodePos( 0 ) { - *pSection = rNew; - SwDoc& rDoc = *(SwDoc*)rPam.GetDoc(); if( rDoc.IsRedlineOn() ) { @@ -121,7 +119,6 @@ SwUndoInsSection::SwUndoInsSection( SwUndoInsSection::~SwUndoInsSection() { - delete pSection; delete pRedlData; delete pAttr; @@ -187,7 +184,7 @@ void SwUndoInsSection::Redo( SwUndoIter& rUndoIter ) else { rDoc.InsertSwSection(*rUndoIter.pAktPam, - *pSection, 0, pAttr, true); + *m_pSectionData, 0, pAttr, true); } if( pHistory ) @@ -233,7 +230,7 @@ void SwUndoInsSection::Repeat( SwUndoIter& rUndoIter ) else { rUndoIter.GetDoc().InsertSwSection( *rUndoIter.pAktPam, - *pSection, 0, pAttr); + *m_pSectionData, 0, pAttr); } } @@ -286,8 +283,7 @@ SwUndoDelSection::SwUndoDelSection( const SwSectionFmt& rFmt ) m_pTOXBase.reset( new SwTOXBase(static_cast<SwTOXBaseSection const&>(rSect)) ); } - pSection = new SwSection( rSect.GetType(), rSect.GetName() ); - *pSection = rSect; + m_pSectionData.reset( new SwSectionData(rSect) ); pAttr = ::lcl_GetAttrSet( rSect ); @@ -299,7 +295,6 @@ SwUndoDelSection::SwUndoDelSection( const SwSectionFmt& rFmt ) SwUndoDelSection::~SwUndoDelSection() { - delete pSection; delete pAttr; } @@ -323,7 +318,7 @@ void SwUndoDelSection::Undo( SwUndoIter& rUndoIter ) /// OD 04.10.2002 #102894# /// remember inserted section node for further calculations SwSectionNode* pInsertedSectNd = rDoc.GetNodes().InsertTextSection( - aStt, *pFmt, *pSection, 0, & aEnd); + aStt, *pFmt, *m_pSectionData, 0, & aEnd); if( SFX_ITEM_SET == pFmt->GetItemState( RES_FTN_AT_TXTEND ) || SFX_ITEM_SET == pFmt->GetItemState( RES_END_AT_TXTEND )) @@ -370,8 +365,8 @@ SwUndoChgSection::SwUndoChgSection( const SwSectionFmt& rFmt, BOOL bOnlyAttr ) : SwUndo( UNDO_CHGSECTION ), bOnlyAttrChgd( bOnlyAttr ) { const SwSection& rSect = *rFmt.GetSection(); - pSection = new SwSection( rSect.GetType(), rSect.GetName() ); - *pSection = rSect; + + m_pSectionData.reset( new SwSectionData(rSect) ); pAttr = ::lcl_GetAttrSet( rSect ); @@ -381,7 +376,6 @@ SwUndoChgSection::SwUndoChgSection( const SwSectionFmt& rFmt, BOOL bOnlyAttr ) SwUndoChgSection::~SwUndoChgSection() { - delete pSection; delete pAttr; } @@ -419,18 +413,16 @@ void SwUndoChgSection::Undo( SwUndoIter& rUndoIter ) if( !bOnlyAttrChgd ) { - BOOL bUpdate = (!rNdSect.IsLinkType() && pSection->IsLinkType() ) || - ( pSection->GetLinkFileName().Len() && - pSection->GetLinkFileName() != - rNdSect.GetLinkFileName()); - - SwSection* pTmp = new SwSection( CONTENT_SECTION, aEmptyStr ); - *pTmp = rNdSect; // das aktuelle sichern - - rNdSect = *pSection; // das alte setzen - - delete pSection; - pSection = pTmp; // das aktuelle ist jetzt das alte + const bool bUpdate = + (!rNdSect.IsLinkType() && m_pSectionData->IsLinkType()) + || ( m_pSectionData->GetLinkFileName().Len() + && (m_pSectionData->GetLinkFileName() != + rNdSect.GetLinkFileName())); + + // swap stored section data with live section data + SwSectionData *const pOld( new SwSectionData(rNdSect) ); + rNdSect.SetSectionData(*m_pSectionData); + m_pSectionData.reset(pOld); if( bUpdate ) rNdSect.CreateLink( CREATE_UPDATE ); diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index a4d248852272..01b1f671a6aa 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -915,9 +915,9 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, const SwSectionFmt* pTmpFmt = rSects[ i ]; if (pTmpFmt == pSectionFmt) { - m_pImpl->m_pDoc->ChgSection( i, - static_cast<SwTOXBaseSection&>(rTOXBase), - & aAttrSet); + SwSectionData tmpData( + static_cast<SwTOXBaseSection&>(rTOXBase)); + m_pImpl->m_pDoc->UpdateSection(i, tmpData, & aAttrSet); break; } } diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index fe8fe6d43431..566178b6d27d 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -369,7 +369,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) } String tmp(m_pImpl->m_sName); - SwSection aSect(eType, pDoc->GetUniqueSectionName(&tmp)); + SwSectionData aSect(eType, pDoc->GetUniqueSectionName(&tmp)); aSect.SetCondition(m_pImpl->m_pProps->m_sCondition); ::rtl::OUStringBuffer sLinkNameBuf(m_pImpl->m_pProps->m_sLinkFileName); sLinkNameBuf.append(sfx2::cTokenSeperator); @@ -379,9 +379,9 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) aSect.SetLinkFileName(sLinkNameBuf.makeStringAndClear()); aSect.SetHidden(m_pImpl->m_pProps->m_bHidden); - aSect.SetProtect(m_pImpl->m_pProps->m_bProtect); + aSect.SetProtectFlag(m_pImpl->m_pProps->m_bProtect); // --> FME 2004-06-22 #114856# edit in readonly sections - aSect.SetEditInReadonly(m_pImpl->m_pProps->m_bEditInReadonly); + aSect.SetEditInReadonlyFlag(m_pImpl->m_pProps->m_bEditInReadonly); // <-- SfxItemSet aSet(pDoc->GetAttrPool(), @@ -427,7 +427,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) // section password if (m_pImpl->m_pProps->m_Password.getLength() > 0) { - aSect.SetPasswd(m_pImpl->m_pProps->m_Password); + aSect.SetPassword(m_pImpl->m_pProps->m_Password); } SwSection *const pRet = @@ -566,12 +566,10 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, throw uno::RuntimeException(); } - SwSection aSection(CONTENT_SECTION, aEmptyStr); SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0; - if (pFmt) - { - aSection = *pSect; - } + ::std::auto_ptr<SwSectionData> const pSectionData( + (pFmt) ? new SwSectionData(*pSect) : 0); + OUString const*const pPropertyNames = rPropertyNames.getConstArray(); uno::Any const*const pValues = rValues.getConstArray(); ::std::auto_ptr<SfxItemSet> pItemSet; @@ -609,7 +607,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, } else { - aSection.SetCondition(uTmp); + pSectionData->SetCondition(uTmp); } } break; @@ -637,16 +635,16 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, } else { - String sLinkFileName(aSection.GetLinkFileName()); - if (aSection.GetType() != DDE_LINK_SECTION) + String sLinkFileName(pSectionData->GetLinkFileName()); + if (pSectionData->GetType() != DDE_LINK_SECTION) { sLinkFileName = sfx2::cTokenSeperator; sLinkFileName += sfx2::cTokenSeperator; - aSection.SetType(DDE_LINK_SECTION); + pSectionData->SetType(DDE_LINK_SECTION); } sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE, sfx2::cTokenSeperator, sTmp); - aSection.SetLinkFileName(sLinkFileName); + pSectionData->SetLinkFileName(sLinkFileName); } } break; @@ -683,10 +681,10 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, } else { - if (aSection.GetType() != FILE_LINK_SECTION && + if (pSectionData->GetType() != FILE_LINK_SECTION && aLink.FileURL.getLength()) { - aSection.SetType(FILE_LINK_SECTION); + pSectionData->SetType(FILE_LINK_SECTION); } ::rtl::OUStringBuffer sFileNameBuf; if (aLink.FileURL.getLength()) @@ -700,14 +698,14 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, sFileNameBuf.append(aLink.FilterName); sFileNameBuf.append(sfx2::cTokenSeperator); sFileNameBuf.append( - aSection.GetLinkFileName().GetToken(2, + pSectionData->GetLinkFileName().GetToken(2, sfx2::cTokenSeperator)); const ::rtl::OUString sFileName( sFileNameBuf.makeStringAndClear()); - aSection.SetLinkFileName(sFileName); + pSectionData->SetLinkFileName(sFileName); if (sFileName.getLength() < 3) { - aSection.SetType(CONTENT_SECTION); + pSectionData->SetType(CONTENT_SECTION); } } } @@ -723,21 +721,21 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, } else { - if (aSection.GetType() != FILE_LINK_SECTION && + if (pSectionData->GetType() != FILE_LINK_SECTION && sLink.getLength()) { - aSection.SetType(FILE_LINK_SECTION); + pSectionData->SetType(FILE_LINK_SECTION); } - String sSectLink(aSection.GetLinkFileName()); + String sSectLink(pSectionData->GetLinkFileName()); while (3 < sSectLink.GetTokenCount(sfx2::cTokenSeperator)) { sSectLink += sfx2::cTokenSeperator; } sSectLink.SetToken(2, sfx2::cTokenSeperator, sLink); - aSection.SetLinkFileName(sSectLink); + pSectionData->SetLinkFileName(sSectLink); if (sSectLink.Len() < 3) { - aSection.SetType(CONTENT_SECTION); + pSectionData->SetType(CONTENT_SECTION); } } } @@ -755,7 +753,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, } else { - aSection.SetHidden(!bVal); + pSectionData->SetHidden(!bVal); } } break; @@ -772,9 +770,9 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, } else { - if (aSection.GetCondition().Len() != 0) + if (pSectionData->GetCondition().Len() != 0) { - aSection.SetCondHidden(!bVal); + pSectionData->SetCondHidden(!bVal); } } } @@ -792,7 +790,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, } else { - aSection.SetProtect(bVal); + pSectionData->SetProtectFlag(bVal); } } break; @@ -810,7 +808,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, } else { - aSection.SetEditInReadonly(bVal); + pSectionData->SetEditInReadonlyFlag(bVal); } } // <-- @@ -825,7 +823,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, } else { - aSection.SetPasswd(aSeq); + pSectionData->SetPassword(aSeq); } } break; @@ -934,7 +932,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, { if (rFmts[i]->GetSection()->GetName() == pSect->GetName()) { - pDoc->ChgSection(i, aSection, pItemSet.get(), + pDoc->UpdateSection(i, *pSectionData, pItemSet.get(), pDoc->IsInReading()); { // temporarily remove actions to allow cursor update @@ -1222,7 +1220,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, case WID_SECT_PASSWORD: { pRet[nProperty] <<= (m_bIsDescriptor) - ? m_pProps->m_Password : pSect->GetPasswd(); + ? m_pProps->m_Password : pSect->GetPassword(); } break; default: @@ -1562,12 +1560,6 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) throw uno::RuntimeException(); } - SwSection aSection(CONTENT_SECTION, aEmptyStr); - SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0; - if (pFmt) - { - aSection = *pSect; - } SfxItemPropertySimpleEntry const*const pEntry = m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName); if (!pEntry) @@ -1584,6 +1576,10 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) static_cast<cppu::OWeakObject *>(this)); } + SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0; + ::std::auto_ptr<SwSectionData> const pSectionData( + (pFmt) ? new SwSectionData(*pSect) : 0); + ::std::auto_ptr<SfxItemSet> pNewAttrSet; switch (pEntry->nWID) { @@ -1595,7 +1591,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) } else { - aSection.SetCondition(aEmptyStr); + pSectionData->SetCondition(aEmptyStr); } } break; @@ -1604,10 +1600,11 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) case WID_SECT_DDE_ELEMENT : case WID_SECT_LINK : case WID_SECT_REGION : - aSection.SetType(CONTENT_SECTION); + pSectionData->SetType(CONTENT_SECTION); break; case WID_SECT_DDE_AUTOUPDATE: - aSection.SetUpdateType(sfx2::LINKUPDATE_ALWAYS); +// FIXME this would crash? +// aSection.SetUpdateType(sfx2::LINKUPDATE_ALWAYS); break; case WID_SECT_VISIBLE : { @@ -1617,7 +1614,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) } else { - aSection.SetHidden(FALSE); + pSectionData->SetHidden(false); } } break; @@ -1629,7 +1626,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) } else { - aSection.SetProtect(FALSE); + pSectionData->SetProtectFlag(false); } } break; @@ -1642,7 +1639,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) } else { - aSection.SetEditInReadonly(FALSE); + pSectionData->SetEditInReadonlyFlag(false); } } break; @@ -1687,7 +1684,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) { if (rFmts[i]->GetSection()->GetName() == pSect->GetName()) { - pDoc->ChgSection(i, aSection, pNewAttrSet.get(), + pDoc->UpdateSection(i, *pSectionData, pNewAttrSet.get(), pDoc->IsInReading()); { // temporarily remove actions to allow cursor update @@ -1801,11 +1798,10 @@ throw (uno::RuntimeException) SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt(); if(pFmt) { - SwSection aSection(CONTENT_SECTION, aEmptyStr); SwSection *const pSect = pFmt->GetSection(); - aSection = *pSect; + SwSectionData aSection(*pSect); String sNewName(rName); - aSection.SetName(sNewName); + aSection.SetSectionName(sNewName); const SwSectionFmts& rFmts = pFmt->GetDoc()->GetSections(); sal_uInt16 nApplyPos = USHRT_MAX; @@ -1824,7 +1820,7 @@ throw (uno::RuntimeException) { { UnoActionContext aContext(pFmt->GetDoc()); - pFmt->GetDoc()->ChgSection( nApplyPos, aSection); + pFmt->GetDoc()->UpdateSection(nApplyPos, aSection); } { // temporarily remove actions to allow cursor update diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx index c03f39d5e2dd..ac2f348532e8 100644 --- a/sw/source/filter/html/htmlsect.cxx +++ b/sw/source/filter/html/htmlsect.cxx @@ -28,26 +28,19 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <rtl/uri.hxx> - - -#include "hintids.hxx" - -#ifndef _APP_HXX //autogen +#include <svl/urihelper.hxx> #include <vcl/svapp.hxx> -#endif -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <editeng/adjitem.hxx> #include <editeng/ulspitem.hxx> #include <editeng/brkitem.hxx> #include <svtools/htmltokn.h> -#ifndef _HTMLKYWD_H #include <svtools/htmlkywd.hxx> -#endif #include <sfx2/linkmgr.hxx> -#include <rtl/uri.hxx> + +#include "hintids.hxx" #include <fmtornt.hxx> #include <fmthdft.hxx> #include <fmtcntnt.hxx> @@ -69,7 +62,6 @@ #include "viewsh.hxx" #include "swcss1.hxx" #include "swhtml.hxx" -#include <svl/urihelper.hxx> #define CONTEXT_FLAGS_MULTICOL (HTML_CNTXT_STRIP_PARA | \ HTML_CNTXT_KEEP_NUMRULE | \ @@ -321,12 +313,12 @@ void SwHTMLParser::NewDivision( int nToken ) aHRef = aURL; } - SwSection aSection( aHRef.Len() ? FILE_LINK_SECTION + SwSectionData aSection( (aHRef.Len()) ? FILE_LINK_SECTION : CONTENT_SECTION, aName ); if( aHRef.Len() ) { aSection.SetLinkFileName( aHRef ); - aSection.SetProtect(); + aSection.SetProtectFlag(true); } SfxItemSet aFrmItemSet( pDoc->GetAttrPool(), @@ -708,7 +700,7 @@ void SwHTMLParser::NewMultiCol() // Make section name unique. String aName( pDoc->GetUniqueSectionName( aId.Len() ? &aId : 0 ) ); - SwSection aSection( CONTENT_SECTION, aName ); + SwSectionData aSection( CONTENT_SECTION, aName ); SfxItemSet aFrmItemSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 ); diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx index 60f43492dd7f..c511d4aab02a 100644 --- a/sw/source/filter/inc/fltshell.hxx +++ b/sw/source/filter/inc/fltshell.hxx @@ -255,14 +255,15 @@ public: class SwFltSection : public SfxPoolItem { - SwSection* pSection; + SwSectionData * m_pSection; + public: - SwFltSection( SwSection* pSect ); + SwFltSection( SwSectionData *const pSect ); SwFltSection( const SwFltSection& ); // "pure virtual Methoden" vom SfxPoolItem virtual int operator==(const SfxPoolItem&) const; virtual SfxPoolItem* Clone(SfxItemPool* = 0) const; - SwSection* GetSection() { return pSection; } + SwSectionData * GetSectionData() { return m_pSection; } }; // Der WWEndStack verhaelt sich wie der WWControlStck, nur dass die Attribute // auf ihm bis ans Ende des Dokuments gehortet werden, falls auf sie noch diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index b595ad7b6dfd..5a5e7a65e0a7 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -829,7 +829,8 @@ void rtfSections::SetHdFt(rtfSection &rSection) SwSectionFmt *rtfSections::InsertSection(SwPaM& rMyPaM, rtfSection &rSection) { - SwSection aSection(CONTENT_SECTION, mrReader.pDoc->GetUniqueSectionName()); + SwSectionData aSectionData(CONTENT_SECTION, + mrReader.pDoc->GetUniqueSectionName()); SfxItemSet aSet( mrReader.pDoc->GetAttrPool(), aFrmFmtSetRange ); @@ -838,7 +839,7 @@ SwSectionFmt *rtfSections::InsertSection(SwPaM& rMyPaM, rtfSection &rSection) nRTLPgn ? FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR)); rSection.mpSection = - mrReader.pDoc->InsertSwSection( rMyPaM, aSection, 0, &aSet ); + mrReader.pDoc->InsertSwSection( rMyPaM, aSectionData, 0, &aSet ); ASSERT(rSection.mpSection, "section not inserted!"); if (!rSection.mpSection) return 0; diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx index d13ae6bfa13f..ba3879aad165 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/ww1/fltshell.cxx @@ -559,9 +559,9 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* case RES_FLTR_SECTION: MakePoint(pEntry, pDoc, aRegion); // bislang immer Point==Mark pDoc->InsertSwSection(aRegion, - *(static_cast<SwFltSection*>(pEntry->pAttr))->GetSection(), - 0, false); - delete(((SwFltSection*)pEntry->pAttr)->GetSection()); + *(static_cast<SwFltSection*>(pEntry->pAttr))->GetSectionData(), + 0, 0, false); + delete (((SwFltSection*)pEntry->pAttr)->GetSectionData()); break; case RES_FLTR_REDLINE: { @@ -865,19 +865,21 @@ SfxPoolItem* SwFltTOX::Clone(SfxItemPool*) const //------ hier stehen die Methoden von SwFltSwSection ----------- -SwFltSection::SwFltSection(SwSection *pSect) : - SfxPoolItem(RES_FLTR_SECTION), pSection(pSect) +SwFltSection::SwFltSection(SwSectionData *const pSect) + : SfxPoolItem(RES_FLTR_SECTION) + , m_pSection(pSect) { } -SwFltSection::SwFltSection(const SwFltSection& rCpy) : - SfxPoolItem(RES_FLTR_SECTION), pSection(rCpy.pSection) +SwFltSection::SwFltSection(const SwFltSection& rCpy) + : SfxPoolItem(RES_FLTR_SECTION) + , m_pSection(rCpy.m_pSection) { } int SwFltSection::operator==(const SfxPoolItem& rItem) const { - return pSection == ((SwFltSection&)rItem).pSection; + return m_pSection == ((SwFltSection&)rItem).m_pSection; } SfxPoolItem* __EXPORT SwFltSection::Clone(SfxItemPool*) const @@ -962,9 +964,9 @@ SwFltShell::~SwFltShell() SwDoc& rDoc = GetDoc(); // 1. SectionFmt und Section anlegen SwSectionFmt* pSFmt = rDoc.MakeSectionFmt( 0 ); - SwSection aS( CONTENT_SECTION, String::CreateFromAscii( + SwSectionData aSectionData( CONTENT_SECTION, String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("PMW-Protect") )); - aS.SetProtect( TRUE ); + aSectionData.SetProtectFlag( true ); // 2. Start- und EndIdx suchen const SwNode* pEndNd = &rDoc.GetNodes().GetEndOfContent(); SwNodeIndex aEndIdx( *pEndNd, -1L ); @@ -973,7 +975,7 @@ SwFltShell::~SwFltShell() // Section einfuegen // Section einfuegen rDoc.GetNodes().InsertTextSection( - aSttIdx, *pSFmt, aS, 0, &aEndIdx, false ); + aSttIdx, *pSFmt, aSectionData, 0, &aEndIdx, false ); if( !IsFlagSet(SwFltControlStack::DONT_HARD_PROTECT) ){ SwDocShell* pDocSh = rDoc.GetDocShell(); diff --git a/sw/source/filter/ww1/w1filter.cxx b/sw/source/filter/ww1/w1filter.cxx index 9ab5e84a6967..45e94726cddc 100644 --- a/sw/source/filter/ww1/w1filter.cxx +++ b/sw/source/filter/ww1/w1filter.cxx @@ -870,10 +870,10 @@ oncemore: String aName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "WW" ))); - SwSection* pSection = new SwSection( FILE_LINK_SECTION, + SwSectionData * pSection = new SwSectionData( FILE_LINK_SECTION, rOut.GetDoc().GetUniqueSectionName( &aStr ) ); pSection->SetLinkFileName( aFName ); - pSection->SetProtect( TRUE ); + pSection->SetProtectFlag( true ); rOut << SwFltSection( pSection ); rOut.EndItem( RES_FLTR_SECTION ); rOut.NextParagraph(); diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 38a2d14c9d1a..79f7537e4ac8 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -2271,9 +2271,10 @@ eF_ResT SwWW8ImplReader::Read_F_IncludeText( WW8FieldDesc* /*pF*/, String& rStr */ SwPosition aTmpPos(*pPaM->GetPoint()); - SwSection aSection(FILE_LINK_SECTION, maSectionNameGenerator.UniqueName()); + SwSectionData aSection(FILE_LINK_SECTION, + maSectionNameGenerator.UniqueName()); aSection.SetLinkFileName( aPara ); - aSection.SetProtect(true); + aSection.SetProtectFlag(true); SwSection *const pSection = rDoc.InsertSwSection(*pPaM, aSection, 0, 0, false); diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 67d712385e07..6dacf0d126fe 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -672,7 +672,8 @@ void wwSectionManager::SetPageULSpaceItems(SwFrmFmt &rFmt, SwSectionFmt *wwSectionManager::InsertSection( SwPaM& rMyPaM, wwSection &rSection) { - SwSection aSection( CONTENT_SECTION, mrReader.rDoc.GetUniqueSectionName() ); + SwSectionData aSection( CONTENT_SECTION, + mrReader.rDoc.GetUniqueSectionName() ); SfxItemSet aSet( mrReader.rDoc.GetAttrPool(), aFrmFmtSetRange ); @@ -685,7 +686,7 @@ SwSectionFmt *wwSectionManager::InsertSection( if (0 == mrReader.pWDop->epc) aSet.Put( SwFmtEndAtTxtEnd(FTNEND_ATTXTEND)); - aSection.SetProtect(SectionIsProtected(rSection)); + aSection.SetProtectFlag(SectionIsProtected(rSection)); rSection.mpSection = mrReader.rDoc.InsertSwSection( rMyPaM, aSection, 0, & aSet ); @@ -836,9 +837,9 @@ void wwSectionManager::CreateSep(const long nTxtPos, bool /*bMustHaveBreak*/) pWkb->Get(nTest, pData); String sSectionName = mrReader.aLinkStringMap[SVBT16ToShort( ((WW8_WKB*)pData)->nLinkId) ]; mrReader.ConvertFFileName(sSectionName, sSectionName); - SwSection aSection(FILE_LINK_SECTION, sSectionName); + SwSectionData aSection(FILE_LINK_SECTION, sSectionName); aSection.SetLinkFileName( sSectionName ); - aSection.SetProtect(true); + aSection.SetProtectFlag(true); // --> CMC, OD 2004-06-18 #i19922# improvement: // return value of method <Insert> not used. mrReader.rDoc.InsertSwSection(*mrReader.pPaM, aSection, 0, 0, false); diff --git a/sw/source/ui/app/applab.cxx b/sw/source/ui/app/applab.cxx index 7ff62b4a0c1b..311276e26d51 100644 --- a/sw/source/ui/app/applab.cxx +++ b/sw/source/ui/app/applab.cxx @@ -394,19 +394,20 @@ static sal_uInt16 nBCTitleNo = 0; else pSh->SetMark(); // set only the mark - SwSection aSect( CONTENT_SECTION, - String::CreateFromAscii(MASTER_LABEL)); + SwSectionData aSect(CONTENT_SECTION, + String::CreateFromAscii(MASTER_LABEL)); pSh->InsertSection(aSect); } } else if (rItem.bSynchron) { - SwSection aSect(FILE_LINK_SECTION, pSh->GetUniqueSectionName()); + SwSectionData aSect(FILE_LINK_SECTION, + pSh->GetUniqueSectionName()); String sLinkName(sfx2::cTokenSeperator); sLinkName += sfx2::cTokenSeperator; sLinkName += String::CreateFromAscii(MASTER_LABEL); aSect.SetLinkFileName(sLinkName); - aSect.SetProtect(); + aSect.SetProtectFlag(true); pSh->Insert(aDotStr); // Dummytext zum Zuweisen der Section pSh->SttDoc(); pSh->EndDoc(sal_True); // Alles im Rahmen selektieren diff --git a/sw/source/ui/dialog/regionsw.cxx b/sw/source/ui/dialog/regionsw.cxx index ef9e8f4f85de..8a4304bcd5a9 100644 --- a/sw/source/ui/dialog/regionsw.cxx +++ b/sw/source/ui/dialog/regionsw.cxx @@ -117,7 +117,7 @@ void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) else aTmpStr = rSh.GetUniqueSectionName(); - SwSection aSection(CONTENT_SECTION,aTmpStr); + SwSectionData aSection(CONTENT_SECTION, aTmpStr); rReq.SetReturnValue(SfxStringItem(FN_INSERT_REGION, aTmpStr)); aSet.Put( *pSet ); @@ -153,10 +153,10 @@ void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) (BOOL)((const SfxBoolItem *)pItem)->GetValue():FALSE; // <-- - aSection.SetProtect(bProtect); + aSection.SetProtectFlag(bProtect); aSection.SetHidden(bHidden); // --> FME 2004-06-22 #114856# edit in readonly sections - aSection.SetEditInReadonly(bEditInReadonly); + aSection.SetEditInReadonlyFlag(bEditInReadonly); // <-- if(SFX_ITEM_SET == @@ -193,9 +193,10 @@ void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) } } -IMPL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSection*, pSect ) +IMPL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSectionData*, pSect ) { - if( pSect ) + ::std::auto_ptr<SwSectionData> pSectionData(pSect); + if (pSectionData.get()) { SfxItemSet aSet(pThis->GetView().GetPool(), RES_COL, RES_COL, @@ -214,10 +215,9 @@ IMPL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSection*, pSect ) AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog( DLG_INSERT_SECTION, &pThis->GetView().GetViewFrame()->GetWindow(),aSet , *pThis); DBG_ASSERT(aTabDlg, "Dialogdiet fail!"); - aTabDlg->SetSection(*pSect); + aTabDlg->SetSectionData(*pSectionData); aTabDlg->Execute(); - delete pSect; delete aTabDlg; } return 0; diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index bdc3a320dcd6..8447489e5b03 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -566,9 +566,10 @@ void AbstractEditRegionDlg_Impl::SelectSection(const String& rSectionName) } // AbstractEditRegionDlg_Impl end //AbstractInsertSectionTabDialog_Impl begin -void AbstractInsertSectionTabDialog_Impl::SetSection(const SwSection& rSect) +void +AbstractInsertSectionTabDialog_Impl::SetSectionData(SwSectionData const& rSect) { - pDlg->SetSection( rSect); + pDlg->SetSectionData(rSect); } // AbstractInsertSectionTabDialog_Impl end diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 462c571a06fa..5d8611d51f54 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -377,7 +377,7 @@ class SwInsertSectionTabDialog; class AbstractInsertSectionTabDialog_Impl : public AbstractInsertSectionTabDialog { DECL_ABSTDLG_BASE(AbstractInsertSectionTabDialog_Impl,SwInsertSectionTabDialog) - virtual void SetSection(const SwSection& rSect); + virtual void SetSectionData(SwSectionData const& rSect); }; //for SwInsertSectionTabDialog end diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx index c1e6df5edbf5..c8b4d721e7bb 100644 --- a/sw/source/ui/dialog/uiregionsw.cxx +++ b/sw/source/ui/dialog/uiregionsw.cxx @@ -164,15 +164,15 @@ public: Beschreibung: User Data Klasse fuer Bereichsinformationen ----------------------------------------------------------------------------*/ -SectRepr::SectRepr( USHORT nPos, SwSection& rSect ) : - aSection( CONTENT_SECTION, aEmptyStr ), +SectRepr::SectRepr( USHORT nPos, SwSection& rSect ) + : m_SectionData( rSect ) + , aBrush( RES_BACKGROUND ), aFrmDirItem( FRMDIR_ENVIRONMENT, RES_FRAMEDIR ), aLRSpaceItem( RES_LR_SPACE ), bSelected(FALSE) { - aSection = rSect; - bContent = aSection.GetLinkFileName().Len() == 0; + bContent = m_SectionData.GetLinkFileName().Len() == 0; nArrPos=nPos; SwSectionFmt *pFmt = rSect.GetFmt(); if( pFmt ) @@ -192,7 +192,7 @@ void SectRepr::SetFile( const String& rFile ) String sNewFile( INetURLObject::decode( rFile, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS, RTL_TEXTENCODING_UTF8 )); - String sOldFileName( aSection.GetLinkFileName() ); + String sOldFileName( m_SectionData.GetLinkFileName() ); String sSub( sOldFileName.GetToken( 2, sfx2::cTokenSeperator ) ); if( rFile.Len() || sSub.Len() ) @@ -205,19 +205,23 @@ void SectRepr::SetFile( const String& rFile ) sNewFile += sSub; } - aSection.SetLinkFileName( sNewFile ); + m_SectionData.SetLinkFileName( sNewFile ); if( rFile.Len() || sSub.Len() ) - aSection.SetType( FILE_LINK_SECTION ); + { + m_SectionData.SetType( FILE_LINK_SECTION ); + } else - aSection.SetType( CONTENT_SECTION ); + { + m_SectionData.SetType( CONTENT_SECTION ); + } } void SectRepr::SetFilter( const String& rFilter ) { String sNewFile; - String sOldFileName( aSection.GetLinkFileName() ); + String sOldFileName( m_SectionData.GetLinkFileName() ); String sFile( sOldFileName.GetToken( 0, sfx2::cTokenSeperator ) ); String sSub( sOldFileName.GetToken( 2, sfx2::cTokenSeperator ) ); @@ -227,16 +231,18 @@ void SectRepr::SetFilter( const String& rFilter ) else if( sSub.Len() ) (( sNewFile = sfx2::cTokenSeperator ) += sfx2::cTokenSeperator ) += sSub; - aSection.SetLinkFileName( sNewFile ); + m_SectionData.SetLinkFileName( sNewFile ); if( sNewFile.Len() ) - aSection.SetType( FILE_LINK_SECTION ); + { + m_SectionData.SetType( FILE_LINK_SECTION ); + } } void SectRepr::SetSubRegion(const String& rSubRegion) { String sNewFile; - String sOldFileName( aSection.GetLinkFileName() ); + String sOldFileName( m_SectionData.GetLinkFileName() ); String sFilter( sOldFileName.GetToken( 1, sfx2::cTokenSeperator ) ); sOldFileName = sOldFileName.GetToken( 0, sfx2::cTokenSeperator ); @@ -244,21 +250,25 @@ void SectRepr::SetSubRegion(const String& rSubRegion) (((( sNewFile = sOldFileName ) += sfx2::cTokenSeperator ) += sFilter ) += sfx2::cTokenSeperator ) += rSubRegion; - aSection.SetLinkFileName( sNewFile ); + m_SectionData.SetLinkFileName( sNewFile ); if( rSubRegion.Len() || sOldFileName.Len() ) - aSection.SetType( FILE_LINK_SECTION ); + { + m_SectionData.SetType( FILE_LINK_SECTION ); + } else - aSection.SetType( CONTENT_SECTION ); + { + m_SectionData.SetType( CONTENT_SECTION ); + } } String SectRepr::GetFile() const { - String sLinkFile( aSection.GetLinkFileName() ); + String sLinkFile( m_SectionData.GetLinkFileName() ); if( sLinkFile.Len() ) { - if( DDE_LINK_SECTION == aSection.GetType() ) + if (DDE_LINK_SECTION == m_SectionData.GetType()) { USHORT n = sLinkFile.SearchAndReplace( sfx2::cTokenSeperator, ' ' ); sLinkFile.SearchAndReplace( sfx2::cTokenSeperator, ' ', n ); @@ -276,7 +286,7 @@ String SectRepr::GetFile() const String SectRepr::GetSubRegion() const { - String sLinkFile( aSection.GetLinkFileName() ); + String sLinkFile( m_SectionData.GetLinkFileName() ); if( sLinkFile.Len() ) sLinkFile = sLinkFile.GetToken( 2, sfx2::cTokenSeperator ); return sLinkFile; @@ -552,7 +562,7 @@ void SwEditRegionDlg::SelectSection(const String& rSectionName) while(pEntry) { SectReprPtr pRepr = (SectReprPtr)pEntry->GetUserData(); - if(pRepr->GetSection().GetName() == rSectionName) + if (pRepr->GetSectionData().GetSectionName() == rSectionName) break; pEntry = aTree.Next(pEntry); } @@ -589,15 +599,15 @@ IMPL_LINK( SwEditRegionDlg, GetFirstEntryHdl, SvTreeListBox *, pBox ) // <-- aFileCB.EnableTriState( TRUE ); - BOOL bHiddenValid = TRUE; - BOOL bProtectValid = TRUE; - BOOL bConditionValid = TRUE; + bool bHiddenValid = true; + bool bProtectValid = true; + bool bConditionValid = true; // --> FME 2004-06-22 #114856# edit in readonly sections - BOOL bEditInReadonlyValid = TRUE; - BOOL bEditInReadonly = TRUE; + bool bEditInReadonlyValid = true; + bool bEditInReadonly = true; // <-- - BOOL bHidden = TRUE; - BOOL bProtect = TRUE; + bool bHidden = true; + bool bProtect = true; String sCondition; BOOL bFirst = TRUE; BOOL bFileValid = TRUE; @@ -794,8 +804,10 @@ IMPL_LINK( SwEditRegionDlg, OkHdl, CheckBox *, EMPTYARG ) { SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData(); SwSectionFmt* pFmt = aOrigArray[ pRepr->GetArrPos() ]; - if( !pRepr->GetSection().IsProtectFlag()) - pRepr->GetSection().SetPasswd(UNO_NMSPC::Sequence <sal_Int8 >()); + if (!pRepr->GetSectionData().IsProtectFlag()) + { + pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >()); + } USHORT nNewPos = rDocFmts.GetPos( pFmt ); if( USHRT_MAX != nNewPos ) { @@ -821,7 +833,7 @@ IMPL_LINK( SwEditRegionDlg, OkHdl, CheckBox *, EMPTYARG ) if( pFmt->GetLRSpace() != pRepr->GetLRSpace()) pSet->Put( pRepr->GetLRSpace()); - rSh.ChgSection( nNewPos, pRepr->GetSection(), + rSh.UpdateSection( nNewPos, pRepr->GetSectionData(), pSet->Count() ? pSet : 0 ); delete pSet; } @@ -1221,8 +1233,8 @@ IMPL_LINK( SwEditRegionDlg, FileNameHdl, Edit *, pEdit ) nPos = sLink.SearchAndReplace( ' ', sfx2::cTokenSeperator ); sLink.SearchAndReplace( ' ', sfx2::cTokenSeperator, nPos ); - pSectRepr->GetSection().SetLinkFileName( sLink ); - pSectRepr->GetSection().SetType( DDE_LINK_SECTION ); + pSectRepr->GetSectionData().SetLinkFileName( sLink ); + pSectRepr->GetSectionData().SetType( DDE_LINK_SECTION ); } else { @@ -1343,10 +1355,12 @@ IMPL_LINK( SwEditRegionDlg, ChangePasswdHdl, Button *, pBox ) break; } } - pRepr->GetSection().SetPasswd(pRepr->GetTempPasswd()); + pRepr->GetSectionData().SetPassword(pRepr->GetTempPasswd()); } else - pRepr->GetSection().SetPasswd(UNO_NMSPC::Sequence <sal_Int8 >()); + { + pRepr->GetSectionData().SetPassword(uno::Sequence<sal_Int8 >()); + } pEntry = aTree.NextSelected(pEntry); } return 0; @@ -1368,7 +1382,7 @@ IMPL_LINK( SwEditRegionDlg, NameEditHdl, Edit *, EMPTYARG ) String aName = aCurName.GetText(); aTree.SetEntryText(pEntry,aName); SectReprPtr pRepr = (SectReprPtr) pEntry->GetUserData(); - pRepr->GetSection().SetName(aName); + pRepr->GetSectionData().SetSectionName(aName); aOK.Enable(aName.Len() != 0); } @@ -1495,8 +1509,8 @@ static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox ) SwInsertSectionTabDialog::SwInsertSectionTabDialog( Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh) : SfxTabDialog( pParent, SW_RES(DLG_INSERT_SECTION), &rSet ), - rWrtSh(rSh), - pToInsertSection(0) + rWrtSh(rSh) + , m_pSectionData(0) { String sInsert(SW_RES(ST_INSERT)); GetOKButton().SetText(sInsert); @@ -1527,7 +1541,6 @@ SwInsertSectionTabDialog::SwInsertSectionTabDialog( * --------------------------------------------------*/ SwInsertSectionTabDialog::~SwInsertSectionTabDialog() { - delete pToInsertSection; } /* -----------------21.05.99 10:23------------------- * @@ -1556,10 +1569,9 @@ void SwInsertSectionTabDialog::PageCreated( USHORT nId, SfxTabPage &rPage ) * * --------------------------------------------------*/ -void SwInsertSectionTabDialog::SetSection(const SwSection& rSect) +void SwInsertSectionTabDialog::SetSectionData(SwSectionData const& rSect) { - pToInsertSection = new SwSection(CONTENT_SECTION, aEmptyStr); - *pToInsertSection = rSect; + m_pSectionData.reset( new SwSectionData(rSect) ); } /* -----------------21.05.99 13:10------------------- * @@ -1567,9 +1579,10 @@ void SwInsertSectionTabDialog::SetSection(const SwSection& rSect) short SwInsertSectionTabDialog::Ok() { short nRet = SfxTabDialog::Ok(); - DBG_ASSERT(pToInsertSection, "keiner Section?"); + DBG_ASSERT(m_pSectionData.get(), + "SwInsertSectionTabDialog: no SectionData?"); const SfxItemSet* pOutputItemSet = GetOutputItemSet(); - rWrtSh.InsertSection(*pToInsertSection, pOutputItemSet); + rWrtSh.InsertSection(*m_pSectionData, pOutputItemSet); SfxViewFrame* pViewFrm = rWrtSh.GetView().GetViewFrame(); uno::Reference< frame::XDispatchRecorder > xRecorder = pViewFrm->GetBindings().GetRecorder(); @@ -1582,15 +1595,20 @@ short SwInsertSectionTabDialog::Ok() aRequest.AppendItem(SfxUInt16Item(SID_ATTR_COLUMNS, ((const SwFmtCol*)pCol)->GetColumns().Count())); } - aRequest.AppendItem(SfxStringItem( FN_PARAM_REGION_NAME, pToInsertSection->GetName())); - aRequest.AppendItem(SfxStringItem( FN_PARAM_REGION_CONDITION, pToInsertSection->GetCondition())); - aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_HIDDEN, pToInsertSection->IsHidden())); - aRequest.AppendItem(SfxBoolItem(FN_PARAM_REGION_PROTECT, pToInsertSection->IsProtect())); + aRequest.AppendItem(SfxStringItem( FN_PARAM_REGION_NAME, + m_pSectionData->GetSectionName())); + aRequest.AppendItem(SfxStringItem( FN_PARAM_REGION_CONDITION, + m_pSectionData->GetCondition())); + aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_HIDDEN, + m_pSectionData->IsHidden())); + aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_PROTECT, + m_pSectionData->IsProtectFlag())); // --> FME 2004-06-22 #114856# edit in readonly sections - aRequest.AppendItem(SfxBoolItem(FN_PARAM_REGION_EDIT_IN_READONLY, pToInsertSection->IsEditInReadonly())); + aRequest.AppendItem(SfxBoolItem( FN_PARAM_REGION_EDIT_IN_READONLY, + m_pSectionData->IsEditInReadonlyFlag())); // <-- - String sLinkFileName( pToInsertSection->GetLinkFileName() ); + String sLinkFileName( m_pSectionData->GetLinkFileName() ); aRequest.AppendItem(SfxStringItem( FN_PARAM_1, sLinkFileName.GetToken( 0, sfx2::cTokenSeperator ))); aRequest.AppendItem(SfxStringItem( FN_PARAM_2, sLinkFileName.GetToken( 1, sfx2::cTokenSeperator ))); aRequest.AppendItem(SfxStringItem( FN_PARAM_3, sLinkFileName.GetToken( 2, sfx2::cTokenSeperator ))); @@ -1675,13 +1693,16 @@ void SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh) lcl_FillSubRegionList( *m_pWrtSh, aSubRegionED, &aCurName ); - SwSection* pSect = ((SwInsertSectionTabDialog*)GetTabDialog())->GetSection(); - if( pSect ) // etwas vorgegeben ? + SwSectionData *const pSectionData = + static_cast<SwInsertSectionTabDialog*>(GetTabDialog()) + ->GetSectionData(); + if (pSectionData) // something set? { - aCurName.SetText( rSh.GetUniqueSectionName( &pSect->GetName() )); - aProtectCB.Check( 0 != pSect->IsProtect() ); - m_sFileName = pSect->GetLinkFileName(); - m_sFilePasswd = pSect->GetLinkFilePassWd(); + aCurName.SetText( + rSh.GetUniqueSectionName(& pSectionData->GetSectionName())); + aProtectCB.Check( 0 != pSectionData->IsProtectFlag() ); + m_sFileName = pSectionData->GetLinkFileName(); + m_sFilePasswd = pSectionData->GetLinkFilePassword(); aFileCB.Check( 0 != m_sFileName.Len() ); aFileNameED.SetText( m_sFileName ); UseFileHdl( &aFileCB ); @@ -1696,16 +1717,18 @@ void SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh) * --------------------------------------------------*/ BOOL SwInsertSectionTabPage::FillItemSet( SfxItemSet& ) { - SwSection aSection(CONTENT_SECTION, aCurName.GetText()); + SwSectionData aSection(CONTENT_SECTION, aCurName.GetText()); aSection.SetCondition(aConditionED.GetText()); BOOL bProtected = aProtectCB.IsChecked(); - aSection.SetProtect(bProtected); + aSection.SetProtectFlag(bProtected); aSection.SetHidden(aHideCB.IsChecked()); // --> FME 2004-06-22 #114856# edit in readonly sections - aSection.SetEditInReadonly(aEditInReadonlyCB.IsChecked()); + aSection.SetEditInReadonlyFlag(aEditInReadonlyCB.IsChecked()); // <-- if(bProtected) - aSection.SetPasswd(m_aNewPasswd); + { + aSection.SetPassword(m_aNewPasswd); + } String sFileName = aFileNameED.GetText(); String sSubRegion = aSubRegionED.GetText(); BOOL bDDe = aDDECB.IsChecked(); @@ -1733,7 +1756,7 @@ BOOL SwInsertSectionTabPage::FillItemSet( SfxItemSet& ) aAbs = pMedium->GetURLObject(); aLinkFile = URIHelper::SmartRel2Abs( aAbs, sFileName, URIHelper::GetMaybeFileHdl() ); - aSection.SetLinkFilePassWd( m_sFilePasswd ); + aSection.SetLinkFilePassword( m_sFilePasswd ); } aLinkFile += sfx2::cTokenSeperator; @@ -1750,7 +1773,7 @@ BOOL SwInsertSectionTabPage::FillItemSet( SfxItemSet& ) FILE_LINK_SECTION); } } - ((SwInsertSectionTabDialog*)GetTabDialog())->SetSection(aSection); + ((SwInsertSectionTabDialog*)GetTabDialog())->SetSectionData(aSection); return TRUE; } /* -----------------21.05.99 10:32------------------- diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx index a49141e896d9..4bce94b43cbe 100644 --- a/sw/source/ui/dochdl/swdtflvr.cxx +++ b/sw/source/ui/dochdl/swdtflvr.cxx @@ -2211,9 +2211,9 @@ int SwTransferable::_PasteDDE( TransferableDataHelper& rData, if( rWrtShell.HasSelection() ) rWrtShell.DelRight(); - SwSection aSect( DDE_LINK_SECTION, aName ); + SwSectionData aSect( DDE_LINK_SECTION, aName ); aSect.SetLinkFileName( aCmd ); - aSect.SetProtect(); + aSect.SetProtectFlag(true); rWrtShell.InsertSection( aSect ); pDDETyp = 0; // FeldTypen wieder entfernen @@ -2554,10 +2554,11 @@ int SwTransferable::_PasteFileName( TransferableDataHelper& rData, ) { // und dann per PostUser Event den Bereich-Einfuegen-Dialog hochreissen - SwSection* pSect = new SwSection( FILE_LINK_SECTION, + SwSectionData * pSect = new SwSectionData( + FILE_LINK_SECTION, rSh.GetDoc()->GetUniqueSectionName() ); pSect->SetLinkFileName( sFileURL ); - pSect->SetProtect( TRUE ); + pSect->SetProtectFlag( true ); Application::PostUserEvent( STATIC_LINK( &rSh, SwWrtShell, InsertRegionDialog ), pSect ); diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx index eb067cc61c71..0a3c8cc33623 100644 --- a/sw/source/ui/frmdlg/column.cxx +++ b/sw/source/ui/frmdlg/column.cxx @@ -354,7 +354,8 @@ IMPL_LINK(SwColumnDlg, OkHdl, OKButton*, EMPTYARG) const SwSection* pCurrSection = rWrtShell.GetCurrSection(); const SwSectionFmt* pFmt = pCurrSection->GetFmt(); USHORT nNewPos = rWrtShell.GetSectionFmtPos( *pFmt ); - rWrtShell.ChgSection( nNewPos, *pCurrSection, pSectionSet ); + SwSectionData aData(*pCurrSection); + rWrtShell.UpdateSection( nNewPos, aData, pSectionSet ); } if(pSectionSet && pSectionSet->Count() && bSelSectionChanged ) diff --git a/sw/source/ui/inc/regionsw.hxx b/sw/source/ui/inc/regionsw.hxx index 40ba9d3d0a15..21b48f99998d 100644 --- a/sw/source/ui/inc/regionsw.hxx +++ b/sw/source/ui/inc/regionsw.hxx @@ -67,7 +67,7 @@ namespace sfx2 class SectRepr { - SwSection aSection; + SwSectionData m_SectionData; SwFmtCol aCol; SvxBrushItem aBrush; SwFmtFtnAtTxtEnd aFtnNtAtEnd; @@ -88,7 +88,8 @@ public: BOOL operator <(SectRepr& rSectRef) const {return nArrPos<rSectRef.GetArrPos();} - SwSection& GetSection() { return aSection; } + SwSectionData & GetSectionData() { return m_SectionData; } + SwSectionData const&GetSectionData() const { return m_SectionData; } SwFmtCol& GetCol() { return aCol; } SvxBrushItem& GetBackground() { return aBrush; } SwFmtFtnAtTxtEnd& GetFtnNtAtEnd() { return aFtnNtAtEnd; } @@ -98,8 +99,9 @@ public: SvxLRSpaceItem& GetLRSpace() { return aLRSpaceItem; } USHORT GetArrPos() const {return nArrPos;} - const String& GetCondition() const {return aSection.GetCondition();} - const String& GetName() const { return aSection.GetName(); } + const String& GetCondition() const + { return m_SectionData.GetCondition(); } + const String& GetName() const { return m_SectionData.GetSectionName(); } String GetFile() const; String GetSubRegion() const; void SetFile( const String& rFile ); @@ -107,37 +109,38 @@ public: void SetSubRegion( const String& rSubRegion ); void SetFilePasswd( const String& rPasswd ) - { aSection.SetLinkFilePassWd( rPasswd ); } + { m_SectionData.SetLinkFilePassword( rPasswd ); } void SetCondition( const String& rString ) - {aSection.SetCondition( rString);} - BOOL IsCondHidden()const - {return aSection.IsCondHidden();} - BOOL IsHidden()const - {return aSection.IsHidden();} - BOOL IsProtect()const - {return aSection.IsProtect();} + { m_SectionData.SetCondition( rString); } + bool IsCondHidden() const + { return m_SectionData.IsCondHidden(); } + bool IsHidden() const + { return m_SectionData.IsHidden(); } + bool IsProtect() const + { return m_SectionData.IsProtectFlag(); } // --> FME 2004-06-22 #114856# edit in readonly sections - BOOL IsEditInReadonly()const - {return aSection.IsEditInReadonly();} - void SetEditInReadonly(BOOL bFlag = TRUE) - {aSection.SetEditInReadonly(bFlag);} + bool IsEditInReadonly() const + { return m_SectionData.IsEditInReadonlyFlag(); } + void SetEditInReadonly(const bool bFlag = true) + { m_SectionData.SetEditInReadonlyFlag(bFlag); } // <-- - void SetHidden(BOOL bFlag = TRUE) - {aSection.SetHidden(bFlag);} - void SetCondHidden(BOOL bFlag = TRUE) - {aSection.SetCondHidden(bFlag);} - void SetProtect(BOOL bFlag = TRUE) - {aSection.SetProtect(bFlag);} + void SetHidden(const bool bFlag = true) + { m_SectionData.SetHidden(bFlag); } + void SetCondHidden(const bool bFlag = true) + { m_SectionData.SetCondHidden(bFlag); } + void SetProtect(const bool bFlag = true) + { m_SectionData.SetProtectFlag(bFlag); } BOOL IsContent(){return bContent;} void SetContent(BOOL bValue){bContent = bValue;} - void SetSectionType(SectionType eSectionType) {aSection.SetType(eSectionType);} - SectionType GetSectionType(){return aSection.GetType();} + void SetSectionType(SectionType eSectionType) { m_SectionData.SetType(eSectionType); } + SectionType GetSectionType() const { return m_SectionData.GetType() ;} void SetSelected(){bSelected = TRUE;} BOOL IsSelected() const {return bSelected;} - const ::com::sun::star::uno::Sequence <sal_Int8 >& GetPasswd() const {return aSection.GetPasswd();} + const ::com::sun::star::uno::Sequence <sal_Int8 >& GetPasswd() const + { return m_SectionData.GetPassword(); } ::com::sun::star::uno::Sequence <sal_Int8 >& GetTempPasswd() {return aTempPasswd;} void SetTempPasswd(const ::com::sun::star::uno::Sequence <sal_Int8 >& aPasswd) {aTempPasswd = aPasswd;} }; @@ -385,7 +388,8 @@ public: class SwInsertSectionTabDialog : public SfxTabDialog { SwWrtShell& rWrtSh; - SwSection* pToInsertSection; + ::std::auto_ptr<SwSectionData> m_pSectionData; + protected: virtual void PageCreated( USHORT nId, SfxTabPage &rPage ); virtual short Ok(); @@ -393,8 +397,8 @@ public: SwInsertSectionTabDialog(Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh); virtual ~SwInsertSectionTabDialog(); - void SetSection(const SwSection& rSect); - SwSection* GetSection() { return pToInsertSection;} + void SetSectionData(SwSectionData const& rSect); + SwSectionData * GetSectionData() { return m_pSectionData.get(); } }; /* -----------------21.05.99 13:07------------------- diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx index 90180b86110b..43cc414380a4 100644 --- a/sw/source/ui/inc/wrtsh.hxx +++ b/sw/source/ui/inc/wrtsh.hxx @@ -46,7 +46,7 @@ class SdrView; class SwView; class SvGlobalName; class SwInputFieldList; -class SwSection; +class SwSectionData; class Timer; class SvxMacro; class SwFmtINetFmt; @@ -456,7 +456,7 @@ typedef BOOL (SwWrtShell:: *FNSimpleMove)(); void AutoUpdatePara(SwTxtFmtColl* pColl, const SfxItemSet& rStyleSet); // Link fuers einfuegen von Bereichen uebers Drag&Drop/Clipboard - DECL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSection* ); + DECL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSectionData* ); //ctoren, der erstere ist eine Art kontrollierter copy ctor fuer weitere diff --git a/sw/source/ui/uiview/viewtab.cxx b/sw/source/ui/uiview/viewtab.cxx index 7088347480a8..44e314a7475b 100644 --- a/sw/source/ui/uiview/viewtab.cxx +++ b/sw/source/ui/uiview/viewtab.cxx @@ -422,7 +422,8 @@ void SwView::ExecTabWin( SfxRequest& rReq ) ::ResizeFrameCols(aCols, aSectRect.Width(), aSectRect.Width() - nDiffWidth, nLeftDiff ); aSet.Put( aCols ); } - rSh.ChgSection( rSh.GetSectionFmtPos(*pSectFmt), *pCurrSect, &aSet ); + SwSectionData aData(*pCurrSect); + rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet); } else { // Seitenraender einstellen @@ -511,8 +512,8 @@ void SwView::ExecTabWin( SfxRequest& rReq ) ::ResizeFrameCols(aCols, aSectRect.Height(), aSectRect.Height() - nDiffWidth, nLeftDiff ); aSet.Put( aCols ); } - rSh.ChgSection( rSh.GetSectionFmtPos(*pSectFmt), *pCurrSect, &aSet ); - + SwSectionData aData(*pCurrSect); + rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet); } else { SwPageDesc aDesc( rDesc ); diff --git a/sw/source/ui/utlui/glbltree.cxx b/sw/source/ui/utlui/glbltree.cxx index fea4b72462e3..1480e4831b3e 100644 --- a/sw/source/ui/utlui/glbltree.cxx +++ b/sw/source/ui/utlui/glbltree.cxx @@ -32,18 +32,14 @@ #define _SVSTDARR_STRINGSDTOR #include <svl/svstdarr.hxx> #endif -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svl/stritem.hxx> #include <sfx2/fcontnr.hxx> #include <sfx2/linkmgr.hxx> #include <sfx2/dispatch.hxx> #include <svl/urihelper.hxx> #include <sfx2/docfile.hxx> -#ifndef _HELP_HXX //autogen #include <vcl/help.hxx> -#endif #include <sot/filelist.hxx> #include <svl/eitem.hxx> #include <svl/urlbmk.hxx> @@ -54,13 +50,9 @@ #include <sfx2/app.hxx> #include <swmodule.hxx> #include <wrtsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <errhdl.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <content.hxx> #include <edglbldc.hxx> #include <section.hxx> @@ -72,12 +64,8 @@ #include <edtwin.hxx> #include <uitool.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _HELPID_H #include <helpid.h> -#endif #ifndef _NAVIPI_HRC #include <navipi.hrc> #endif @@ -1471,15 +1459,15 @@ void SwGlobalTree::InsertRegion( const SwGlblDocContent* _pContent, const Sequen if ( nAddNumber ) sSectionName = sTempSectionName; - SwSection aSection(CONTENT_SECTION, sSectionName); - aSection.SetProtect(TRUE); - aSection.SetHidden(FALSE); + SwSectionData aSectionData(CONTENT_SECTION, sSectionName); + aSectionData.SetProtectFlag(true); + aSectionData.SetHidden(false); - aSection.SetLinkFileName(sFileName); - aSection.SetType( FILE_LINK_SECTION); - aSection.SetLinkFilePassWd( sFilePassword ); + aSectionData.SetLinkFileName(sFileName); + aSectionData.SetType(FILE_LINK_SECTION); + aSectionData.SetLinkFilePassword( sFilePassword ); - rSh.InsertGlobalDocContent( *pAnchorContent, aSection ); + rSh.InsertGlobalDocContent( *pAnchorContent, aSectionData ); } if ( bMove ) { diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx index a2477349ee44..0472124df128 100644 --- a/sw/source/ui/wrtsh/wrtsh2.cxx +++ b/sw/source/ui/wrtsh/wrtsh2.cxx @@ -461,20 +461,20 @@ void SwWrtShell::NavigatorPaste( const NaviContentBookmark& rBkmk, } else { - SwSection aSection( FILE_LINK_SECTION, GetUniqueSectionName( 0 ) ); + SwSectionData aSection( FILE_LINK_SECTION, GetUniqueSectionName( 0 ) ); String aLinkFile( rBkmk.GetURL().GetToken(0, '#') ); aLinkFile += sfx2::cTokenSeperator; aLinkFile += sfx2::cTokenSeperator; aLinkFile += rBkmk.GetURL().GetToken(1, '#'); aSection.SetLinkFileName( aLinkFile ); - aSection.SetProtect( TRUE ); + aSection.SetProtectFlag( true ); const SwSection* pIns = InsertSection( aSection ); if( EXCHG_IN_ACTION_MOVE == nAction && pIns ) { - aSection = *pIns; + aSection = SwSectionData(*pIns); aSection.SetLinkFileName( aEmptyStr ); aSection.SetType( CONTENT_SECTION ); - aSection.SetProtect( FALSE ); + aSection.SetProtectFlag( false ); // the update of content from linked section at time delete // the undostack. Then the change of the section dont create @@ -482,7 +482,7 @@ void SwWrtShell::NavigatorPaste( const NaviContentBookmark& rBkmk, BOOL bDoesUndo = DoesUndo(); if( UNDO_INSSECTION != GetUndoIds() ) DoUndo( FALSE ); - ChgSection( GetSectionFmtPos( *pIns->GetFmt() ), aSection ); + UpdateSection( GetSectionFmtPos( *pIns->GetFmt() ), aSection ); DoUndo( bDoesUndo ); } } |