diff options
Diffstat (limited to 'sw/source')
125 files changed, 3662 insertions, 3173 deletions
diff --git a/sw/source/core/access/acchyperlink.cxx b/sw/source/core/access/acchyperlink.cxx index 6a9ff9738165..ece5bbb614c5 100644 --- a/sw/source/core/access/acchyperlink.cxx +++ b/sw/source/core/access/acchyperlink.cxx @@ -101,8 +101,8 @@ sal_Bool SAL_CALL SwAccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex ) const SwTxtINetFmt* pTxtAttr2 = rINetFmt.GetTxtINetFmt(); if( pTxtAttr2 ) { - const_cast< SwTxtINetFmt* >( pTxtAttr2 )->SetVisited( sal_True ); - const_cast< SwTxtINetFmt* >( pTxtAttr2 )->SetValidVis( sal_True ); + const_cast<SwTxtINetFmt*>(pTxtAttr2)->SetVisited(true); + const_cast<SwTxtINetFmt*>(pTxtAttr2)->SetVisitedValid(true); } bRet = sal_True; } diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx index 03b82378df53..e4410c26e8bb 100644 --- a/sw/source/core/attr/calbck.cxx +++ b/sw/source/core/attr/calbck.cxx @@ -386,8 +386,10 @@ SwClient *SwModify::_Remove(SwClient * pDepend) void SwModify::CheckCaching( const USHORT nWhich ) { - if( RES_CHRATR_BEGIN <= nWhich && RES_CHRATR_END > nWhich ) + if (isCHRATR(nWhich)) + { SetInSwFntCache( FALSE ); + } else switch ( nWhich ) { diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 8b54e9647be3..6652cd86dab4 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -59,9 +59,7 @@ #include <callnk.hxx> #include <viscrs.hxx> #include <section.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <scriptinfo.hxx> #include <globdoc.hxx> #include <pamtyp.hxx> @@ -173,7 +171,7 @@ BOOL SwCrsrShell::DestroyCrsr() SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, SwCursor* pNextCrsr = (SwCursor*)pCurCrsr->GetNext(); delete pCurCrsr; - pCurCrsr = (SwShellCrsr*)*pNextCrsr; + pCurCrsr = dynamic_cast<SwShellCrsr*>(pNextCrsr); UpdateCrsr(); return TRUE; } @@ -201,9 +199,8 @@ SwPaM* SwCrsrShell::GetCrsr( BOOL bMakeTblCrsr ) const if( pTblCrsr->IsChgd() ) { - SwCrsrShell* pThis = (SwCrsrShell*)this; - pThis->pCurCrsr = (SwShellCrsr*) - *pTblCrsr->MakeBoxSels( pThis->pCurCrsr ); + const_cast<SwCrsrShell*>(this)->pCurCrsr = + dynamic_cast<SwShellCrsr*>(pTblCrsr->MakeBoxSels( pCurCrsr )); } } return pCurCrsr; @@ -539,7 +536,7 @@ BOOL SwCrsrShell::SttEndDoc( BOOL bStt ) { SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen - SwShellCrsr* pTmpCrsr = pBlockCrsr ? pBlockCrsr->getShellCrsr() : pCurCrsr; + SwShellCrsr* pTmpCrsr = pBlockCrsr ? &pBlockCrsr->getShellCrsr() : pCurCrsr; BOOL bRet = pTmpCrsr->SttEndDoc( bStt ); if( bRet ) { @@ -920,7 +917,8 @@ BOOL SwCrsrShell::ChgCurrPam( const Point & rPt, UpdateCrsr(); // Cursor steht schon richtig return TRUE; } - } while( pCurCrsr != ( pCmp = (SwShellCrsr*)*((SwCursor*)pCmp->GetNext()) ) ); + } while( pCurCrsr != + ( pCmp = dynamic_cast<SwShellCrsr*>(pCmp->GetNext()) ) ); return FALSE; } @@ -1124,7 +1122,7 @@ BOOL SwCrsrShell::GoNextCrsr() SET_CURR_SHELL( this ); SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen - pCurCrsr = (SwShellCrsr*)*((SwCursor*)pCurCrsr->GetNext()); + pCurCrsr = dynamic_cast<SwShellCrsr*>(pCurCrsr->GetNext()); // Bug 24086: auch alle anderen anzeigen if( !ActionPend() ) @@ -1146,7 +1144,7 @@ BOOL SwCrsrShell::GoPrevCrsr() SET_CURR_SHELL( this ); SwCallLink aLk( *this ); // Crsr-Moves ueberwachen, evt. Link callen - pCurCrsr = (SwShellCrsr*)*((SwCursor*)pCurCrsr->GetPrev()); + pCurCrsr = dynamic_cast<SwShellCrsr*>(pCurCrsr->GetPrev()); // Bug 24086: auch alle anderen anzeigen if( !ActionPend() ) @@ -1957,7 +1955,9 @@ BOOL SwCrsrShell::Pop( BOOL bOldCrsr ) // der Nachfolger wird der Aktuelle if( pCrsrStk->GetNext() != pCrsrStk ) - pTmp = (SwShellCrsr*)*((SwCursor*)pCrsrStk->GetNext()); + { + pTmp = dynamic_cast<SwShellCrsr*>(pCrsrStk->GetNext()); + } if( bOldCrsr ) // loesche vom Stack delete pCrsrStk; // @@ -2029,7 +2029,9 @@ void SwCrsrShell::Combine() SwShellCrsr * pTmp = 0; if( pCrsrStk->GetNext() != pCrsrStk ) - pTmp = (SwShellCrsr*)*((SwCursor*)pCrsrStk->GetNext()); + { + pTmp = dynamic_cast<SwShellCrsr*>(pCrsrStk->GetNext()); + } delete pCrsrStk; pCrsrStk = pTmp; if( !pCurCrsr->IsInProtectTable( TRUE ) && @@ -3041,16 +3043,6 @@ BOOL SwCrsrShell::HasReadonlySel() const return bRet; } -// SwCursor - Methode !!!! -BOOL SwCursor::IsReadOnlyAvailable() const -{ - const SwShellCrsr* pShCrsr = *this; - const SwUnoCrsr* pUnoCrsr = *this; - return pShCrsr ? pShCrsr->GetShell()->IsReadOnlyAvailable() : - pUnoCrsr ? TRUE : FALSE; -} - - BOOL SwCrsrShell::IsSelFullPara() const { BOOL bRet = FALSE; diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx index 61aa9f95ffd7..4a98c1ce558e 100644 --- a/sw/source/core/crsr/findattr.cxx +++ b/sw/source/core/crsr/findattr.cxx @@ -888,7 +888,7 @@ BOOL SwPaM::Find( const SfxPoolItem& rAttr, BOOL bValue, SwMoveFn fnMove, { // stelle fest welches Attribut gesucht wird: USHORT nWhich = rAttr.Which(); - int bCharAttr = RES_CHRATR_BEGIN <= nWhich && nWhich < RES_TXTATR_END; + int bCharAttr = isCHRATR(nWhich) || isTXTATR(nWhich); SwPaM* pPam = MakeRegion( fnMove, pRegion ); @@ -931,7 +931,7 @@ BOOL SwPaM::Find( const SfxPoolItem& rAttr, BOOL bValue, SwMoveFn fnMove, bFound = TRUE; break; } - else if( RES_TXTATR_BEGIN < nWhich ) // TextAttribut + else if (isTXTATR(nWhich)) continue; // --> also weiter } diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index 860117babcc0..e50cdbf943a5 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -74,24 +74,29 @@ inline xub_StrLen GetSttOrEnd( BOOL bCondition, const SwCntntNode& rNd ) *************************************************************************/ -SwPosition::SwPosition( const SwNodeIndex &rNode, const SwIndex &rCntnt ) - : nNode( rNode ),nContent( rCntnt ) +SwPosition::SwPosition( const SwNodeIndex & rNodeIndex, const SwIndex & rCntnt ) + : nNode( rNodeIndex ), nContent( rCntnt ) { } -SwPosition::SwPosition( const SwNodeIndex &rNode ) - : nNode( rNode ), nContent( 0 ) +SwPosition::SwPosition( const SwNodeIndex & rNodeIndex ) + : nNode( rNodeIndex ), nContent( nNode.GetNode().GetCntntNode() ) { } SwPosition::SwPosition( const SwNode& rNode ) - : nNode( rNode ), nContent( 0 ) + : nNode( rNode ), nContent( nNode.GetNode().GetCntntNode() ) +{ +} + +SwPosition::SwPosition( SwCntntNode & rNode, const xub_StrLen nOffset ) + : nNode( rNode ), nContent( &rNode, nOffset ) { } -SwPosition::SwPosition(const SwPosition &rPos) - : nNode(rPos.nNode),nContent(rPos.nContent) +SwPosition::SwPosition( const SwPosition & rPos ) + : nNode( rPos.nNode ), nContent( rPos.nContent ) { } @@ -380,129 +385,170 @@ SwCntntNode* GoPreviousNds( SwNodeIndex * pIdx, BOOL bChk ) *************************************************************************/ SwPaM::SwPaM( const SwPosition& rPos, SwPaM* pRing ) - : Ring( pRing ), aBound1( rPos ), aBound2( rPos ), bIsInFrontOfLabel(FALSE) + : Ring( pRing ) + , m_Bound1( rPos ) + , m_Bound2( rPos.nNode.GetNode().GetNodes() ) // default initialize + , m_pPoint( &m_Bound1 ) + , m_pMark( m_pPoint ) + , m_bIsInFrontOfLabel( false ) { - pPoint = pMark = &aBound1; } -SwPaM::SwPaM( const SwPosition& rMk, const SwPosition& rPt, SwPaM* pRing ) - : Ring( pRing ), aBound1( rMk ), aBound2( rPt ), bIsInFrontOfLabel(FALSE) +SwPaM::SwPaM( const SwPosition& rMark, const SwPosition& rPoint, SwPaM* pRing ) + : Ring( pRing ) + , m_Bound1( rMark ) + , m_Bound2( rPoint ) + , m_pPoint( &m_Bound2 ) + , m_pMark( &m_Bound1 ) + , m_bIsInFrontOfLabel( false ) { - pMark = &aBound1; - pPoint = &aBound2; } -SwPaM::SwPaM( const SwNodeIndex& rMk, const SwNodeIndex& rPt, - long nMkOffset, long nPtOffset, SwPaM* pRing ) - : Ring( pRing ), aBound1( rMk ), aBound2( rPt ), bIsInFrontOfLabel(FALSE) +SwPaM::SwPaM( const SwNodeIndex& rMark, const SwNodeIndex& rPoint, + long nMarkOffset, long nPointOffset, SwPaM* pRing ) + : Ring( pRing ) + , m_Bound1( rMark ) + , m_Bound2( rPoint ) + , m_pPoint( &m_Bound2 ) + , m_pMark( &m_Bound1 ) + , m_bIsInFrontOfLabel( false ) { - if( nMkOffset ) - aBound1.nNode += nMkOffset; - if( nPtOffset ) - aBound2.nNode += nPtOffset; - - aBound1.nContent.Assign( aBound1.nNode.GetNode().GetCntntNode(), 0 ); - aBound2.nContent.Assign( aBound2.nNode.GetNode().GetCntntNode(), 0 ); - pMark = &aBound1; - pPoint = &aBound2; + if ( nMarkOffset ) + { + m_pMark->nNode += nMarkOffset; + } + if ( nPointOffset ) + { + m_pPoint->nNode += nPointOffset; + } + + m_Bound1.nContent.Assign( m_Bound1.nNode.GetNode().GetCntntNode(), 0 ); + m_Bound2.nContent.Assign( m_Bound2.nNode.GetNode().GetCntntNode(), 0 ); } -SwPaM::SwPaM( const SwNode& rMk, const SwNode& rPt, - long nMkOffset, long nPtOffset, SwPaM* pRing ) - : Ring( pRing ), aBound1( rMk ), aBound2( rPt ), bIsInFrontOfLabel(FALSE) +SwPaM::SwPaM( const SwNode& rMark, const SwNode& rPoint, + long nMarkOffset, long nPointOffset, SwPaM* pRing ) + : Ring( pRing ) + , m_Bound1( rMark ) + , m_Bound2( rPoint ) + , m_pPoint( &m_Bound2 ) + , m_pMark( &m_Bound1 ) + , m_bIsInFrontOfLabel( false ) { - if( nMkOffset ) - aBound1.nNode += nMkOffset; - if( nPtOffset ) - aBound2.nNode += nPtOffset; - - aBound1.nContent.Assign( aBound1.nNode.GetNode().GetCntntNode(), 0 ); - aBound2.nContent.Assign( aBound2.nNode.GetNode().GetCntntNode(), 0 ); - pMark = &aBound1; - pPoint = &aBound2; + if ( nMarkOffset ) + { + m_pMark->nNode += nMarkOffset; + } + if ( nPointOffset ) + { + m_pPoint->nNode += nPointOffset; + } + + m_Bound1.nContent.Assign( m_Bound1.nNode.GetNode().GetCntntNode(), 0 ); + m_Bound2.nContent.Assign( m_Bound2.nNode.GetNode().GetCntntNode(), 0 ); } -SwPaM::SwPaM( const SwNodeIndex& rMk, xub_StrLen nMkCntnt, - const SwNodeIndex& rPt, xub_StrLen nPtCntnt, SwPaM* pRing ) - : Ring( pRing ), aBound1( rMk ), aBound2( rPt ), bIsInFrontOfLabel(FALSE) +SwPaM::SwPaM( const SwNodeIndex& rMark , xub_StrLen nMarkCntnt, + const SwNodeIndex& rPoint, xub_StrLen nPointCntnt, SwPaM* pRing ) + : Ring( pRing ) + , m_Bound1( rMark ) + , m_Bound2( rPoint ) + , m_pPoint( &m_Bound2 ) + , m_pMark( &m_Bound1 ) + , m_bIsInFrontOfLabel( false ) { - aBound1.nContent.Assign( rMk.GetNode().GetCntntNode(), nMkCntnt ); - aBound2.nContent.Assign( rPt.GetNode().GetCntntNode(), nPtCntnt ); - pMark = &aBound1; - pPoint = &aBound2; + m_pPoint->nContent.Assign( rPoint.GetNode().GetCntntNode(), nPointCntnt); + m_pMark ->nContent.Assign( rMark .GetNode().GetCntntNode(), nMarkCntnt ); } -SwPaM::SwPaM( const SwNode& rMk, xub_StrLen nMkCntnt, - const SwNode& rPt, xub_StrLen nPtCntnt, SwPaM* pRing ) - : Ring( pRing ), aBound1( rMk ), aBound2( rPt ), bIsInFrontOfLabel(FALSE) +SwPaM::SwPaM( const SwNode& rMark , xub_StrLen nMarkCntnt, + const SwNode& rPoint, xub_StrLen nPointCntnt, SwPaM* pRing ) + : Ring( pRing ) + , m_Bound1( rMark ) + , m_Bound2( rPoint ) + , m_pPoint( &m_Bound2 ) + , m_pMark( &m_Bound1 ) + , m_bIsInFrontOfLabel( false ) { - aBound1.nContent.Assign( aBound1.nNode.GetNode().GetCntntNode(), nMkCntnt ); - aBound2.nContent.Assign( aBound2.nNode.GetNode().GetCntntNode(), nPtCntnt ); - pMark = &aBound1; - pPoint = &aBound2; + m_pPoint->nContent.Assign( m_pPoint->nNode.GetNode().GetCntntNode(), + nPointCntnt); + m_pMark ->nContent.Assign( m_pMark ->nNode.GetNode().GetCntntNode(), + nMarkCntnt ); } -SwPaM::SwPaM( const SwNode& rNd, xub_StrLen nCntnt, SwPaM* pRing ) - : Ring( pRing ), aBound1( rNd ), aBound2( rNd ), bIsInFrontOfLabel(FALSE) +SwPaM::SwPaM( const SwNode& rNode, xub_StrLen nCntnt, SwPaM* pRing ) + : Ring( pRing ) + , m_Bound1( rNode ) + , m_Bound2( m_Bound1.nNode.GetNode().GetNodes() ) // default initialize + , m_pPoint( &m_Bound1 ) + , m_pMark( &m_Bound1 ) + , m_bIsInFrontOfLabel( false ) { - aBound1.nContent.Assign( aBound1.nNode.GetNode().GetCntntNode(), nCntnt ); - aBound2.nContent = aBound1.nContent; - pPoint = pMark = &aBound1; + m_pPoint->nContent.Assign( m_pPoint->nNode.GetNode().GetCntntNode(), + nCntnt ); } -SwPaM::SwPaM( const SwNodeIndex& rNd, xub_StrLen nCntnt, SwPaM* pRing ) - : Ring( pRing ), aBound1( rNd ), aBound2( rNd ), bIsInFrontOfLabel(FALSE) +SwPaM::SwPaM( const SwNodeIndex& rNodeIdx, xub_StrLen nCntnt, SwPaM* pRing ) + : Ring( pRing ) + , m_Bound1( rNodeIdx ) + , m_Bound2( rNodeIdx.GetNode().GetNodes() ) // default initialize + , m_pPoint( &m_Bound1 ) + , m_pMark( &m_Bound1 ) + , m_bIsInFrontOfLabel( false ) { - aBound1.nContent.Assign( rNd.GetNode().GetCntntNode(), nCntnt ); - aBound2.nContent = aBound1.nContent; - pPoint = pMark = &aBound1; + m_pPoint->nContent.Assign( rNodeIdx.GetNode().GetCntntNode(), nCntnt ); } SwPaM::~SwPaM() {} // @@@ semantic: no copy ctor. SwPaM::SwPaM( SwPaM &rPam ) - : Ring( &rPam ), - aBound1( *(rPam.pPoint) ), - aBound2( *(rPam.pMark) ), - bIsInFrontOfLabel(FALSE) + : Ring( &rPam ) + , m_Bound1( *(rPam.m_pPoint) ) + , m_Bound2( *(rPam.m_pMark) ) + , m_pPoint( &m_Bound1 ), m_pMark( rPam.HasMark() ? &m_Bound2 : m_pPoint ) + , m_bIsInFrontOfLabel( false ) { - pPoint = &aBound1; - pMark = rPam.HasMark() ? &aBound2 : pPoint; } // @@@ semantic: no copy assignment for super class Ring. SwPaM &SwPaM::operator=( const SwPaM &rPam ) { - *pPoint = *( rPam.pPoint ); - if( rPam.HasMark() ) + *m_pPoint = *( rPam.m_pPoint ); + if ( rPam.HasMark() ) { SetMark(); - *pMark = *( rPam.pMark ); + *m_pMark = *( rPam.m_pMark ); } else + { DeleteMark(); + } return *this; } void SwPaM::SetMark() { - if(pPoint == &aBound1) - pMark = &aBound2; + if (m_pPoint == &m_Bound1) + { + m_pMark = &m_Bound2; + } else - pMark = &aBound1; - (*pMark) = (*pPoint); + { + m_pMark = &m_Bound1; + } + (*m_pMark) = (*m_pPoint); } #ifndef PRODUCT void SwPaM::Exchange() { - if(pPoint != pMark) + if (m_pPoint != m_pMark) { - SwPosition *pTmp = pPoint; - pPoint = pMark; - pMark = pTmp; + SwPosition *pTmp = m_pPoint; + m_pPoint = m_pMark; + m_pMark = pTmp; } } #endif @@ -514,7 +560,7 @@ BOOL SwPaM::Move( SwMoveFn fnMove, SwGoInDoc fnGo ) { BOOL bRet = (*fnGo)( *this, fnMove ); - bIsInFrontOfLabel = FALSE; + m_bIsInFrontOfLabel = false; return bRet; } @@ -545,7 +591,7 @@ SwPaM* SwPaM::MakeRegion( SwMoveFn fnMove, const SwPaM * pOrigRg ) SwPaM* pPam; if( pOrigRg == 0 ) { - pPam = new SwPaM( *pPoint ); + pPam = new SwPaM( *m_pPoint ); pPam->SetMark(); // setze Anfang fest pPam->Move( fnMove, fnGoSection); // an Anfang / Ende vom Node @@ -567,9 +613,11 @@ SwPaM* SwPaM::MakeRegion( SwMoveFn fnMove, const SwPaM * pOrigRg ) SwPaM & SwPaM::Normalize(BOOL bPointFirst) { if (HasMark()) - if ((bPointFirst && *pPoint > *pMark) || - (! bPointFirst && *pPoint < *pMark)) + if ( ( bPointFirst && *m_pPoint > *m_pMark) || + (!bPointFirst && *m_pPoint < *m_pMark) ) + { Exchange(); + } return *this; } @@ -581,7 +629,7 @@ USHORT SwPaM::GetPageNum( BOOL bAtPoint, const Point* pLayPos ) const SwCntntFrm* pCFrm; const SwPageFrm *pPg; const SwCntntNode *pNd ; - const SwPosition* pPos = bAtPoint ? pPoint : pMark; + const SwPosition* pPos = bAtPoint ? m_pPoint : m_pMark; if( 0 != ( pNd = pPos->nNode.GetNode().GetCntntNode() ) && 0 != ( pCFrm = pNd->GetFrm( pLayPos, pPos, FALSE )) && diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index 197bc62c08ba..b7a336b5929c 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -35,13 +35,8 @@ #include <hintids.hxx> #include <svx/protitem.hxx> -#ifndef _COM_SUN_STAR_I18N_WORDTYPE_HDL #include <com/sun/star/i18n/WordType.hdl> -#endif -#ifndef _COM_SUN_STAR_I18N_CHARTYPE_HDL #include <com/sun/star/i18n/CharType.hdl> -#endif - #include <unotools/charclass.hxx> #include <svtools/ctloptions.hxx> @@ -60,9 +55,7 @@ #include <txtfrm.hxx> #include <scriptinfo.hxx> #include <crstate.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <frmatr.hxx> #include <breakit.hxx> #include <crsskip.hxx> @@ -73,8 +66,10 @@ #endif #include <redline.hxx> // SwRedline + using namespace ::com::sun::star::i18n; + static const USHORT coSrchRplcThreshold = 60000; struct _PercentHdl @@ -162,11 +157,20 @@ SwCursor* SwCursor::Create( SwPaM* pRing ) const return new SwCursor( *GetPoint(), pRing, false ); } -SwCursor::operator SwTableCursor* () { return 0; } -SwCursor::operator SwShellCrsr* () { return 0; } -SwCursor::operator SwShellTableCrsr* () { return 0; } -SwCursor::operator SwUnoCrsr* () { return 0; } -SwCursor::operator SwUnoTableCrsr* () { return 0; } +bool SwCursor::IsReadOnlyAvailable() const +{ + return false; +} + +BOOL SwCursor::IsSkipOverHiddenSections() const +{ + return TRUE; +} + +BOOL SwCursor::IsSkipOverProtectSections() const +{ + return !IsReadOnlyAvailable(); +} // Sicher die aktuelle Position, damit ggfs. auf diese zurueck @@ -206,36 +210,41 @@ BOOL SwCursor::IsNoCntnt() const GetDoc()->GetNodes().GetEndOfExtras().GetIndex(); } +bool SwCursor::IsSelOvrCheck(int) +{ + return false; +} + +// extracted from IsSelOvr() +bool SwTableCursor::IsSelOvrCheck(int eFlags) +{ + SwNodes& rNds = GetDoc()->GetNodes(); + // check sections of nodes array + if( (nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION & eFlags) + && HasMark() ) + { + SwNodeIndex aOldPos( rNds, GetSavePos()->nNode ); + if( !CheckNodesRange( aOldPos, GetPoint()->nNode, TRUE )) + { + GetPoint()->nNode = aOldPos; + GetPoint()->nContent.Assign( GetCntntNode(), GetSavePos()->nCntnt ); + return true; + } + } + return SwCursor::IsSelOvrCheck(eFlags); +} BOOL SwCursor::IsSelOvr( int eFlags ) { - SwTableCursor* pTblCrsr = *this; SwDoc* pDoc = GetDoc(); SwNodes& rNds = pDoc->GetNodes(); - BOOL bSkipOverHiddenSections, bSkipOverProtectSections; - SwUnoCrsr* pUnoCrsr = *this; - if( pUnoCrsr ) - { - bSkipOverHiddenSections = pUnoCrsr->IsSkipOverHiddenSections(); - bSkipOverProtectSections = pUnoCrsr->IsSkipOverProtectSections(); - } - else - { - bSkipOverHiddenSections = TRUE; - bSkipOverProtectSections = !IsReadOnlyAvailable(); - } + BOOL bSkipOverHiddenSections = IsSkipOverHiddenSections(); + BOOL bSkipOverProtectSections = IsSkipOverProtectSections(); - // Bereiche vom Nodes-Array ueberpruefen - if( (nsSwCursorSelOverFlags::SELOVER_CHECKNODESSECTION & eFlags) && pTblCrsr && HasMark() ) + if ( IsSelOvrCheck( eFlags ) ) { - SwNodeIndex aOldPos( rNds, pSavePos->nNode ); - if( !CheckNodesRange( aOldPos, GetPoint()->nNode, TRUE )) - { - GetPoint()->nNode = aOldPos; - GetPoint()->nContent.Assign( GetCntntNode(), pSavePos->nCntnt ); - return TRUE; - } + return TRUE; } // neu: Bereiche ueberpruefen @@ -343,7 +352,7 @@ BOOL SwCursor::IsSelOvr( int eFlags ) // neu: Bereiche ueberpruefen const SwNode* pNd = &GetPoint()->nNode.GetNode(); - if( pNd->IsCntntNode() && 0 == (SwUnoCrsr*)*this ) + if( pNd->IsCntntNode() && !dynamic_cast<SwUnoCrsr*>(this) ) { const SwCntntFrm* pFrm = ((SwCntntNode*)pNd)->GetFrm(); if( pFrm && pFrm->IsValid() && 0 == pFrm->Frm().Height() && @@ -419,7 +428,7 @@ BOOL SwCursor::IsSelOvr( int eFlags ) const SwTableNode* pPtNd = pNd->FindTableNode(); if( (pNd = &GetMark()->nNode.GetNode())->IsCntntNode() && - !((SwCntntNode*)pNd)->GetFrm() && 0 == (SwUnoCrsr*)*this ) + !((SwCntntNode*)pNd)->GetFrm() && !dynamic_cast<SwUnoCrsr*>(this) ) { DeleteMark(); RestoreSavePos(); @@ -691,8 +700,10 @@ BOOL SwCursor::IsAtValidPos( BOOL bPoint ) const const SwNode* pNd = &pPos->nNode.GetNode(); if( pNd->IsCntntNode() && !((SwCntntNode*)pNd)->GetFrm() && - 0 == (const SwUnoCrsr*)*this ) + !dynamic_cast<const SwUnoCrsr*>(this) ) + { return FALSE; + } //JP 28.10.97: Bug 45129 - im UI-ReadOnly ist alles erlaubt if( !pDoc->GetDocShell() || !pDoc->GetDocShell()->IsReadOnlyUI() ) @@ -741,8 +752,8 @@ ULONG lcl_FindSelection( SwFindParas& rParas, SwCursor* pCurCrsr, int bSrchBkwrd = fnMove == fnMoveBackward, bEnde = FALSE; SwPaM *pTmpCrsr = pCurCrsr, *pSaveCrsr = pCurCrsr; - // nur beim ShellCrsr einen Prgogressbar erzeugen - BOOL bIsUnoCrsr = 0 != (SwUnoCrsr*)*pCurCrsr; + // only create progress-bar for ShellCrsr + bool bIsUnoCrsr = 0 != dynamic_cast<SwUnoCrsr*>(pCurCrsr); _PercentHdl* pPHdl = 0; USHORT nCrsrCnt = 0; if( FND_IN_SEL & eFndRngs ) @@ -829,16 +840,20 @@ ULONG lcl_FindSelection( SwFindParas& rParas, SwCursor* pCurCrsr, if( *pSttPos == *pEndPos ) // im Bereich, aber am Ende break; // fertig - if( !nCrsrCnt && !bIsUnoCrsr ) + if( !nCrsrCnt && pPHdl ) + { pPHdl->NextPos( *aRegion.GetMark() ); + } } if( bEnde || !( eFndRngs & ( FND_IN_SELALL | FND_IN_SEL )) ) break; pTmpCrsr = ((SwPaM*)pTmpCrsr->GetNext()); - if( nCrsrCnt && !bIsUnoCrsr ) + if( nCrsrCnt && pPHdl ) + { pPHdl->NextPos( ++pPHdl->nActPos ); + } } while( pTmpCrsr != pSaveCrsr ); @@ -1472,60 +1487,71 @@ BOOL SwCursor::GoSentence( SentenceMoveType eMoveType ) return bRet; } -BOOL SwCursor::LeftRight( BOOL bLeft, USHORT nCnt, USHORT nMode, - BOOL bVisualAllowed,BOOL bSkipHidden, BOOL bInsertCrsr ) +BOOL SwTableCursor::LeftRight( BOOL bLeft, USHORT nCnt, USHORT /*nMode*/, + BOOL /*bVisualAllowed*/, BOOL /*bSkipHidden*/, BOOL /*bInsertCrsr*/ ) { - SwTableCursor* pTblCrsr = (SwTableCursor*)*this; - if( pTblCrsr ) - return bLeft ? pTblCrsr->GoPrevCell( nCnt ) - : pTblCrsr->GoNextCell( nCnt ); + return bLeft ? GoPrevCell( nCnt ) + : GoNextCell( nCnt ); +} + +// calculate cursor bidi level: extracted from LeftRight() +const SwCntntFrm* +SwCursor::DoSetBidiLevelLeftRight( + BOOL & io_rbLeft, BOOL bVisualAllowed, BOOL bInsertCrsr) +{ // calculate cursor bidi level const SwCntntFrm* pSttFrm = NULL; SwNode& rNode = GetPoint()->nNode.GetNode(); - const BOOL bDoNotSetBidiLevel = 0 != (SwUnoCrsr*)*this; - if ( !bDoNotSetBidiLevel ) + if( rNode.IsTxtNode() ) { - if( rNode.IsTxtNode() ) + const SwTxtNode& rTNd = *rNode.GetTxtNode(); + SwIndex& rIdx = GetPoint()->nContent; + xub_StrLen nPos = rIdx.GetIndex(); + + const SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions(); + if ( bVisualAllowed && rCTLOptions.IsCTLFontEnabled() && + SvtCTLOptions::MOVEMENT_VISUAL == + rCTLOptions.GetCTLCursorMovement() ) { - const SwTxtNode& rTNd = *rNode.GetTxtNode(); - SwIndex& rIdx = GetPoint()->nContent; - xub_StrLen nPos = rIdx.GetIndex(); - - const SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions(); - if ( bVisualAllowed && rCTLOptions.IsCTLFontEnabled() && - SvtCTLOptions::MOVEMENT_VISUAL == - rCTLOptions.GetCTLCursorMovement() ) + // for visual cursor travelling (used in bidi layout) + // we first have to convert the logic to a visual position + Point aPt; + pSttFrm = rTNd.GetFrm( &aPt, GetPoint() ); + if( pSttFrm ) { - // for visual cursor travelling (used in bidi layout) - // we first have to convert the logic to a visual position - Point aPt; - pSttFrm = rTNd.GetFrm( &aPt, GetPoint() ); - if( pSttFrm ) - { - BYTE nCrsrLevel = GetCrsrBidiLevel(); - sal_Bool bForward = ! bLeft; - ((SwTxtFrm*)pSttFrm)->PrepareVisualMove( nPos, nCrsrLevel, - bForward, bInsertCrsr ); - rIdx = nPos; - SetCrsrBidiLevel( nCrsrLevel ); - bLeft = ! bForward; - } + BYTE nCrsrLevel = GetCrsrBidiLevel(); + sal_Bool bForward = ! io_rbLeft; + ((SwTxtFrm*)pSttFrm)->PrepareVisualMove( nPos, nCrsrLevel, + bForward, bInsertCrsr ); + rIdx = nPos; + SetCrsrBidiLevel( nCrsrLevel ); + io_rbLeft = ! bForward; } - else + } + else + { + const SwScriptInfo* pSI = SwScriptInfo::GetScriptInfo( rTNd ); + if ( pSI ) { - const SwScriptInfo* pSI = SwScriptInfo::GetScriptInfo( rTNd ); - if ( pSI ) - { - const xub_StrLen nMoveOverPos = bLeft ? - ( nPos ? nPos - 1 : 0 ) : - nPos; - SetCrsrBidiLevel( pSI->DirType( nMoveOverPos ) ); - } + const xub_StrLen nMoveOverPos = io_rbLeft ? + ( nPos ? nPos - 1 : 0 ) : + nPos; + SetCrsrBidiLevel( pSI->DirType( nMoveOverPos ) ); } } } + return pSttFrm; +} + +BOOL SwCursor::LeftRight( BOOL bLeft, USHORT nCnt, USHORT nMode, + BOOL bVisualAllowed,BOOL bSkipHidden, BOOL bInsertCrsr ) +{ + // calculate cursor bidi level + SwNode& rNode = GetPoint()->nNode.GetNode(); + const SwCntntFrm* pSttFrm = // may side-effect bLeft! + DoSetBidiLevelLeftRight(bLeft, bVisualAllowed, bInsertCrsr); // kann der Cursor n-mal weiterverschoben werden ? SwCrsrSaveState aSave( *this ); @@ -1650,10 +1676,40 @@ BOOL SwCursor::LeftRight( BOOL bLeft, USHORT nCnt, USHORT nMode, nsSwCursorSelOverFlags::SELOVER_CHANGEPOS ); } +// calculate cursor bidi level: extracted from UpDown() +void SwCursor::DoSetBidiLevelUpDown() +{ + SwNode& rNode = GetPoint()->nNode.GetNode(); + if ( rNode.IsTxtNode() ) + { + const SwScriptInfo* pSI = + SwScriptInfo::GetScriptInfo( (SwTxtNode&)rNode ); + if ( pSI ) + { + SwIndex& rIdx = GetPoint()->nContent; + xub_StrLen nPos = rIdx.GetIndex(); + + if( nPos && nPos < ((SwTxtNode&)rNode).GetTxt().Len() ) + { + const BYTE nCurrLevel = pSI->DirType( nPos ); + const BYTE nPrevLevel = pSI->DirType( nPos - 1 ); + + if ( nCurrLevel % 2 != nPrevLevel % 2 ) + { + // set cursor level to the lower of the two levels + SetCrsrBidiLevel( Min( nCurrLevel, nPrevLevel ) ); + } + else + SetCrsrBidiLevel( nCurrLevel ); + } + } + } +} + BOOL SwCursor::UpDown( BOOL bUp, USHORT nCnt, Point* pPt, long nUpDownX ) { - SwTableCursor* pTblCrsr = (SwTableCursor*)*this; + SwTableCursor* pTblCrsr = dynamic_cast<SwTableCursor*>(this); sal_Bool bAdjustTableCrsr = sal_False; // vom Tabellen Crsr Point/Mark in der gleichen Box ?? @@ -1752,36 +1808,7 @@ BOOL SwCursor::UpDown( BOOL bUp, USHORT nCnt, else *GetPoint() = aOldPos; - // calculate cursor bidi level - const BOOL bDoNotSetBidiLevel = 0 != (SwUnoCrsr*)*this; - - if ( ! bDoNotSetBidiLevel ) - { - SwNode& rNode = GetPoint()->nNode.GetNode(); - if ( rNode.IsTxtNode() ) - { - const SwScriptInfo* pSI = SwScriptInfo::GetScriptInfo( (SwTxtNode&)rNode ); - if ( pSI ) - { - SwIndex& rIdx = GetPoint()->nContent; - xub_StrLen nPos = rIdx.GetIndex(); - - if( nPos && nPos < ((SwTxtNode&)rNode).GetTxt().Len() ) - { - const BYTE nCurrLevel = pSI->DirType( nPos ); - const BYTE nPrevLevel = pSI->DirType( nPos - 1 ); - - if ( nCurrLevel % 2 != nPrevLevel % 2 ) - { - // set cursor level to the lower of the two levels - SetCrsrBidiLevel( Min( nCurrLevel, nPrevLevel ) ); - } - else - SetCrsrBidiLevel( nCurrLevel ); - } - } - } - } + DoSetBidiLevelUpDown(); // calculate cursor bidi level } return bRet; @@ -1895,12 +1922,15 @@ BOOL SwCursor::GoPrevNextCell( BOOL bNext, USHORT nCnt ) return !IsInProtectTable( TRUE ); } +BOOL SwTableCursor::GotoTable( const String& /*rName*/ ) +{ + return FALSE; // invalid action +} + BOOL SwCursor::GotoTable( const String& rName ) { BOOL bRet = FALSE; - // Tabellenselektion oder ueberhaupt Selection ? - // Das ist eine ungueltige Action ! - if( !(SwTableCursor*)*this && !HasMark() ) + if ( !HasMark() ) { SwTable* pTmpTbl = SwTable::FindTable( GetDoc()->FindTblFmtByName( rName ) ); if( pTmpTbl ) @@ -2017,7 +2047,6 @@ SwTableCursor::SwTableCursor( const SwPosition &rPos, SwPaM* pRing ) SwTableCursor::~SwTableCursor() {} -SwTableCursor::operator SwTableCursor* () { return this; } BOOL lcl_SeekEntry( const SwSelBoxes& rTmp, const SwStartNode* pSrch, USHORT& rFndPos ) { diff --git a/sw/source/core/crsr/trvlreg.cxx b/sw/source/core/crsr/trvlreg.cxx index 77387be91fc4..017ea9811f91 100644 --- a/sw/source/core/crsr/trvlreg.cxx +++ b/sw/source/core/crsr/trvlreg.cxx @@ -238,7 +238,7 @@ BOOL GotoCurrRegionAndSkip( SwPaM& rCurCrsr, SwPosRegion fnPosRegion, BOOL SwCursor::MoveRegion( SwWhichRegion fnWhichRegion, SwPosRegion fnPosRegion ) { SwCrsrSaveState aSaveState( *this ); - return !(SwTableCursor*)*this && + return !dynamic_cast<SwTableCursor*>(this) && (*fnWhichRegion)( *this, fnPosRegion, IsReadOnlyAvailable() ) && !IsSelOvr() && ( GetPoint()->nNode.GetIndex() != pSavePos->nNode || diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx index 2599d785d9c2..4546a108b2ec 100644 --- a/sw/source/core/crsr/trvltbl.cxx +++ b/sw/source/core/crsr/trvltbl.cxx @@ -32,9 +32,7 @@ #include "precompiled_sw.hxx" #include <hintids.hxx> -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif #include <svx/protitem.hxx> #include <crsrsh.hxx> #include <doc.hxx> @@ -54,6 +52,7 @@ #include <cellfrm.hxx> #include <rowfrm.hxx> + // setze Crsr in die naechsten/vorherigen Celle BOOL SwCrsrShell::GoNextCell( BOOL bAppendLine ) { @@ -653,7 +652,7 @@ BOOL GotoCurrTable( SwPaM& rCurCrsr, SwPosTable fnPosTbl, BOOL SwCursor::MoveTable( SwWhichTable fnWhichTbl, SwPosTable fnPosTbl ) { BOOL bRet = FALSE; - SwTableCursor* pTblCrsr = (SwTableCursor*)*this; + SwTableCursor* pTblCrsr = dynamic_cast<SwTableCursor*>(this); if( pTblCrsr || !HasMark() ) // nur wenn kein Mark oder ein TblCrsr { diff --git a/sw/source/core/crsr/unocrsr.cxx b/sw/source/core/crsr/unocrsr.cxx index bfc179db489e..aa52f61c8317 100644 --- a/sw/source/core/crsr/unocrsr.cxx +++ b/sw/source/core/crsr/unocrsr.cxx @@ -85,14 +85,21 @@ SwUnoCrsr::~SwUnoCrsr() SwUnoCrsr * SwUnoCrsr::Clone() const { - SwUnoCrsr * pNewCrsr = 0; - - // check if the cursor is a SwUnoTableCrsr, if so clone that type - const SwUnoTableCrsr * pUnoTableCrsr = *this; - if (pUnoTableCrsr) - pNewCrsr = GetDoc()->CreateUnoCrsr( *GetPoint(), sal_True /* create SwUnoTableCrsr */ ); - else - pNewCrsr = GetDoc()->CreateUnoCrsr( *GetPoint() ); + SwUnoCrsr * pNewCrsr = GetDoc()->CreateUnoCrsr( *GetPoint() ); + if (HasMark()) + { + pNewCrsr->SetMark(); + *pNewCrsr->GetMark() = *GetMark(); + } + return pNewCrsr; +} + +SwUnoTableCrsr * SwUnoTableCrsr::Clone() const +{ + SwUnoTableCrsr * pNewCrsr = dynamic_cast<SwUnoTableCrsr*>( + GetDoc()->CreateUnoCrsr( + *GetPoint(), sal_True /* create SwUnoTableCrsr */ ) ); + OSL_ENSURE(pNewCrsr, "Clone: cannot create SwUnoTableCrsr?"); if (HasMark()) { pNewCrsr->SetMark(); @@ -101,8 +108,22 @@ SwUnoCrsr * SwUnoCrsr::Clone() const return pNewCrsr; } -SwUnoCrsr::operator SwUnoCrsr* () { return this; } +bool SwUnoCrsr::IsReadOnlyAvailable() const +{ + return true; +} + +const SwCntntFrm* +SwUnoCrsr::DoSetBidiLevelLeftRight( BOOL &, BOOL, BOOL ) +{ + return 0; // not for uno cursor +} + +void SwUnoCrsr::DoSetBidiLevelUpDown() +{ + return; // not for uno cursor +} BOOL SwUnoCrsr::IsSelOvr( int eFlags ) { @@ -208,9 +229,6 @@ SwUnoTableCrsr::~SwUnoTableCrsr() delete aTblSel.GetNext(); // und loeschen } -SwUnoTableCrsr::operator SwUnoCrsr* () { return this; } -SwUnoTableCrsr::operator SwTableCursor* () { return this; } -SwUnoTableCrsr::operator SwUnoTableCrsr* () { return this; } /* SwCursor* SwUnoTableCrsr::Create( SwPaM* pRing ) const diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index c1e095f38dd9..d03f6e7960eb 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -37,15 +37,9 @@ #include <svtools/svstdarr.hxx> #endif -#ifndef _DIALOG_HXX //autogen #include <vcl/dialog.hxx> -#endif -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <viewopt.hxx> #include <frmtool.hxx> #include <viscrs.hxx> @@ -907,7 +901,11 @@ SwShellCrsr::SwShellCrsr( SwShellCrsr& rICrsr ) SwShellCrsr::~SwShellCrsr() {} -SwShellCrsr::operator SwShellCrsr* () { return this; } + +bool SwShellCrsr::IsReadOnlyAvailable() const +{ + return GetShell()->IsReadOnlyAvailable(); +} void SwShellCrsr::SetMark() { @@ -936,7 +934,7 @@ void SwShellCrsr::Show() SwShellCrsr * pTmp = this; do { pTmp->SwSelPaintRects::Show(); - } while( this != ( pTmp = (SwShellCrsr*)*(SwCursor*)(pTmp->GetNext() ))); + } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) ); SHOWBOOKMARKS1( 1 ) SHOWREDLINES1( 1 ) @@ -948,7 +946,6 @@ void SwShellCrsr::Show() void SwShellCrsr::Invalidate( const SwRect& rRect ) { SwShellCrsr * pTmp = this; - SwCursor* pTmpCrsr; do { @@ -963,9 +960,7 @@ void SwShellCrsr::Invalidate( const SwRect& rRect ) do { pTmpRing = pTmpRing->GetNext(); - pTmpCrsr = dynamic_cast<SwCursor*>(pTmpRing); - if ( pTmpCrsr ) - pTmp = (SwShellCrsr*)*pTmpCrsr; + pTmp = dynamic_cast<SwShellCrsr*>(pTmpRing); } while ( !pTmp ); } @@ -981,7 +976,7 @@ void SwShellCrsr::Hide() SwShellCrsr * pTmp = this; do { pTmp->SwSelPaintRects::Hide(); - } while( this != ( pTmp = (SwShellCrsr*)*(SwCursor*)(pTmp->GetNext() ))); + } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) ); SHOWBOOKMARKS1( 2 ) SHOWREDLINES1( 2 ) @@ -1086,9 +1081,6 @@ SwShellTableCrsr::SwShellTableCrsr( const SwCrsrShell& rCrsrSh, SwShellTableCrsr::~SwShellTableCrsr() {} void SwShellTableCrsr::SetMark() { SwShellCrsr::SetMark(); } -SwShellTableCrsr::operator SwShellCrsr* () { return this; } -SwShellTableCrsr::operator SwTableCursor* () { return this; } -SwShellTableCrsr::operator SwShellTableCrsr* () { return this; } SwCursor* SwShellTableCrsr::Create( SwPaM* pRing ) const { diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index f4c3d3017972..cd0e3e4f93bf 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1332,7 +1332,8 @@ void _SaveCntntIdx(SwDoc* pDoc, aSave.IncCount(); FOREACHPAM_END() - SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ n ]; + SwUnoTableCrsr* pUnoTblCrsr = + dynamic_cast<SwUnoTableCrsr*>(rTbl[ n ]); if( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) @@ -1474,8 +1475,9 @@ void _RestoreCntntIdx(SwDoc* pDoc, if( pPos ) break; - SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ i ]; - if( pUnoTblCrsr ) + SwUnoTableCrsr* pUnoTblCrsr = + dynamic_cast<SwUnoTableCrsr*>(rTbl[ i ]); + if ( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) if( aSave.GetCount() == nCnt ) @@ -1487,7 +1489,7 @@ void _RestoreCntntIdx(SwDoc* pDoc, ++nCnt; FOREACHPAM_END() } - if( pPos ) + if ( pPos ) break; } } @@ -1629,8 +1631,9 @@ void _RestoreCntntIdx(SvULongs& rSaveArr, if( pPos ) break; - SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ i ]; - if( pUnoTblCrsr ) + SwUnoTableCrsr* pUnoTblCrsr = + dynamic_cast<SwUnoTableCrsr*>(rTbl[ i ]); + if ( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) if( aSave.GetCount() == nCnt ) @@ -1642,7 +1645,7 @@ void _RestoreCntntIdx(SvULongs& rSaveArr, ++nCnt; FOREACHPAM_END() } - if( pPos ) + if ( pPos ) break; } } diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx index c7c3e4e69031..8e45afd37247 100644 --- a/sw/source/core/doc/doccorr.cxx +++ b/sw/source/core/doc/doccorr.cxx @@ -183,7 +183,8 @@ void PaMCorrAbs( const SwNodeIndex &rOldNode, lcl_PaMCorrAbs1( PCURCRSR, pOldNode, aNewPos, nOffset ); FOREACHPAM_END() - SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ n ]; + SwUnoTableCrsr* pUnoTblCrsr = + dynamic_cast<SwUnoTableCrsr*>(rTbl[ n ]); if( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) @@ -245,7 +246,8 @@ void PaMCorrAbs( const SwNodeIndex &rStartNode, bChange |= lcl_PaMCorrAbs2(PCURCRSR, aNewPos, nSttNode, nEndNode); FOREACHPAM_END() - SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*pUnoCursor; + SwUnoTableCrsr* pUnoTblCrsr = + dynamic_cast<SwUnoTableCrsr*>(pUnoCursor); if( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) @@ -303,7 +305,8 @@ void PaMCorrAbs( const SwPaM& rRange, lcl_PaMCorrAbs3( PCURCRSR, aStart, aEnd, aNewPos ); FOREACHPAM_END() - SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ n ]; + SwUnoTableCrsr* pUnoTblCrsr = + dynamic_cast<SwUnoTableCrsr*>(rTbl[ n ]); if( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) @@ -402,7 +405,8 @@ void PaMCorrRel( const SwNodeIndex &rOldNode, lcl_PaMCorrRel1( PCURCRSR, pOldNode, aNewPos, nCntIdx ); FOREACHPAM_END() - SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ n ]; + SwUnoTableCrsr* pUnoTblCrsr = + dynamic_cast<SwUnoTableCrsr*>(rTbl[ n ]); if( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 8b4ebe172b6f..8db7bdfcb4e6 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -34,16 +34,12 @@ #include <string.h> // fuer strchr() #include <hintids.hxx> -#ifndef _SOUND_HXX //autogen #include <vcl/sound.hxx> -#endif #include <svx/cscoitem.hxx> #include <svx/brkitem.hxx> #include <linguistic/lngprops.hxx> #include <com/sun/star/beans/XPropertySet.hpp> -#ifndef _COM_SUN_STAR_I18N_WORDTYPE_HDL #include <com/sun/star/i18n/WordType.hdl> -#endif #include <unotools/charclass.hxx> #include <fmtanchr.hxx> #include <fmtcntnt.hxx> @@ -477,16 +473,19 @@ bool lcl_SaveFtn( const SwNodeIndex& rSttNd, const SwNodeIndex& rEndNd, SwNode* pNode = &aIdx.GetNode(); if( pNode->IsTxtNode() ) // Looking for text nodes... { - SwpHints *pHints = ((SwTxtNode*)pNode)->GetpSwpHints(); + SwpHints *pHints = + static_cast<SwTxtNode*>(pNode)->GetpSwpHints(); if( pHints && pHints->HasFtn() ) //...with footnotes { bUpdateFtn = sal_True; // Heureka USHORT nCount = pHints->Count(); for( USHORT i = 0; i < nCount; ++i ) { - SwTxtAttr *pAttr = pHints->GetHt( i ); - if( pAttr->Which() == RES_TXTATR_FTN ) - rSaveArr.Insert( (SwTxtFtn*)pAttr ); + SwTxtAttr *pAttr = pHints->GetTextHint( i ); + if ( pAttr->Which() == RES_TXTATR_FTN ) + { + rSaveArr.Insert( static_cast<SwTxtFtn*>(pAttr) ); + } } } } @@ -1475,7 +1474,12 @@ void lcl_GetJoinFlags( SwPaM& rPam, sal_Bool& rJoinTxt, sal_Bool& rJoinPrev ) bExchange = !bExchange; if( bExchange ) rPam.Exchange(); - rJoinPrev = rJoinTxt && rPam.GetPoint() == pStt; + rJoinPrev = rPam.GetPoint() == pStt; + ASSERT( !pStt->nContent.GetIndex() && + pEndNd->GetTxt().Len() != pEnd->nContent.GetIndex() + ? rPam.GetPoint()->nNode < rPam.GetMark()->nNode + : rPam.GetPoint()->nNode > rPam.GetMark()->nNode, + "lcl_GetJoinFlags"); } } } @@ -1493,6 +1497,9 @@ void lcl_JoinText( SwPaM& rPam, sal_Bool bJoinPrev ) SwDoc* pDoc = rPam.GetDoc(); if( bJoinPrev ) { + // N.B.: we do not need to handle xmlids in this case, because + // it is only invoked if one paragraph is completely empty + // (see lcl_GetJoinFlags) { // falls PageBreaks geloescht / gesetzt werden, darf das // nicht in die Undo-History aufgenommen werden !! @@ -1753,7 +1760,8 @@ bool SwDoc::Delete( SwPaM & rPam ) do { // middle checked loop! if( pCNd ) { - if( pCNd->GetTxtNode() ) + SwTxtNode * pStartTxtNode( pCNd->GetTxtNode() ); + if ( pStartTxtNode ) { // verschiebe jetzt noch den Inhalt in den neuen Node sal_Bool bOneNd = pStt->nNode == pEnd->nNode; @@ -1763,7 +1771,15 @@ bool SwDoc::Delete( SwPaM & rPam ) // falls schon leer, dann nicht noch aufrufen if( nLen ) - ((SwTxtNode*)pCNd)->Erase( pStt->nContent, nLen ); + { + pStartTxtNode->Erase( pStt->nContent, nLen ); + + if( !pStartTxtNode->Len() ) + { + // METADATA: remove reference if empty (consider node deleted) + pStartTxtNode->RemoveMetadataReference(); + } + } if( bOneNd ) // das wars schon break; @@ -1781,13 +1797,20 @@ bool SwDoc::Delete( SwPaM & rPam ) pCNd = pEnd->nNode.GetNode().GetCntntNode(); if( pCNd ) { - if( pCNd->GetTxtNode() ) + SwTxtNode * pEndTxtNode( pCNd->GetTxtNode() ); + if( pEndTxtNode ) { // falls schon leer, dann nicht noch aufrufen if( pEnd->nContent.GetIndex() ) { SwIndex aIdx( pCNd, 0 ); - ((SwTxtNode*)pCNd)->Erase( aIdx, pEnd->nContent.GetIndex() ); + pEndTxtNode->Erase( aIdx, pEnd->nContent.GetIndex() ); + + if( !pEndTxtNode->Len() ) + { + // METADATA: remove reference if empty (consider node deleted) + pEndTxtNode->RemoveMetadataReference(); + } } } else @@ -2202,6 +2225,8 @@ sal_Bool lcl_GetTokenToParaBreak( String& rStr, String& rRet, sal_Bool bRegExpRp return bRet; } +// N.B.: it is possible to call Replace with a PaM that spans 2 paragraphs: +// search with regex for "$", then replace _all_ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) { if( !rPam.HasMark() || *rPam.GetPoint() == *rPam.GetMark() ) diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index ace606ae86ac..8bee61c1da37 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -392,13 +392,13 @@ BOOL SwDoc::SetFlyFrmAttr( SwFrmFmt& rFlyFmt, SfxItemSet& rSet ) if( !rSet.Count() ) return FALSE; - _UndoFmtAttr* pSaveUndo = 0; + ::std::auto_ptr<SwUndoFmtAttrHelper> pSaveUndo; const bool bDoesUndo = DoesUndo(); if( DoesUndo() ) { ClearRedo(); - pSaveUndo = new _UndoFmtAttr( rFlyFmt ); + pSaveUndo.reset( new SwUndoFmtAttrHelper( rFlyFmt ) ); // --> FME 2004-10-13 #i32968# // Inserting columns in the frame causes MakeFrmFmt to put two // objects of type SwUndoFrmFmt on the undo stack. We don't want them. @@ -452,15 +452,16 @@ BOOL SwDoc::SetFlyFrmAttr( SwFrmFmt& rFlyFmt, SfxItemSet& rSet ) if( MAKEFRMS == nMakeFrms ) rFlyFmt.MakeFrms(); - if( pSaveUndo ) + if ( pSaveUndo.get() ) { // --> FME 2004-10-13 #i32968# DoUndo( bDoesUndo ); // <-- - if( pSaveUndo->pUndo ) - AppendUndo( pSaveUndo->pUndo ); - delete pSaveUndo; + if ( pSaveUndo->GetUndo() ) + { + AppendUndo( pSaveUndo->ReleaseUndo() ); + } } SetModified(); diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index caa4987c6f04..bb9f24db8fb0 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -40,9 +40,7 @@ #include <svtools/itemiter.hxx> #include <sfx2/app.hxx> #include <svtools/misccfg.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/eeitem.hxx> #include <svx/langitem.hxx> #include <svx/lrspitem.hxx> @@ -53,9 +51,7 @@ #include <svtools/zforlist.hxx> #endif #include <comphelper/processfactory.hxx> -#ifndef _COM_SUN_STAR_I18N_WORDTYPE_HDL #include <com/sun/star/i18n/WordType.hdl> -#endif #include <fmtpdsc.hxx> #include <fmthdft.hxx> #include <fmtcntnt.hxx> @@ -367,8 +363,8 @@ void SwDoc::RstTxtAttrs(const SwPaM &rRg, BOOL bInclRefToxMark ) if( DoesUndo() ) { ClearRedo(); - SwUndoRstAttr* pUndo = new SwUndoRstAttr( rRg, RES_CHRFMT ); - pHst = pUndo->GetHistory(); + SwUndoResetAttr* pUndo = new SwUndoResetAttr( rRg, RES_CHRFMT ); + pHst = &pUndo->GetHistory(); AppendUndo( pUndo ); } const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End(); @@ -452,11 +448,13 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, if( DoesUndo() ) { ClearRedo(); - SwUndoRstAttr* pUndo = new SwUndoRstAttr( rRg, + SwUndoResetAttr* pUndo = new SwUndoResetAttr( rRg, static_cast<USHORT>(bTxtAttr ? RES_CONDTXTFMTCOLL : RES_TXTFMTCOLL )); if( pAttrs && pAttrs->Count() ) + { pUndo->SetAttrs( *pAttrs ); - pHst = pUndo->GetHistory(); + } + pHst = &pUndo->GetHistory(); AppendUndo( pUndo ); } @@ -505,9 +503,7 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, { if( IsInRange( aCharFmtSetRange, pItem->Which() )) { - - if( !pTNd->pSwpHints ) - pTNd->pSwpHints = new SwpHints; + pTNd->GetOrCreateSwpHints(); aCharSet.Put( *pItem ); @@ -556,14 +552,13 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, { SwTxtAttr* pTAttr = pTNd->MakeTxtAttr( *pItem, 0, pTNd->GetTxt().Len() ); - if( !pTNd->pSwpHints ) - pTNd->pSwpHints = new SwpHints; - pTNd->pSwpHints->SwpHintsArr::Insert( pTAttr ); + SwpHints & rHints = pTNd->GetOrCreateSwpHints(); + rHints.SwpHintsArray::Insert( pTAttr ); if( pHst ) { SwRegHistory aRegH( pTNd, *pTNd, pHst ); pTNd->ResetAttr( pItem->Which() ); - pHst->Add( pTAttr, aTmpEnd.GetIndex(), TRUE ); + pHst->Add( pTAttr, aTmpEnd.GetIndex(), true ); } else pTNd->ResetAttr( pItem->Which() ); @@ -619,22 +614,22 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, const SfxPoolItem* pItem = aIter.FirstItem(); const USHORT nWhich = pItem->Which(); - if ( (RES_CHRATR_BEGIN <= nWhich && nWhich < RES_CHRATR_END) || - RES_TXTATR_CHARFMT == nWhich || - RES_TXTATR_INETFMT == nWhich || - RES_TXTATR_AUTOFMT == nWhich || - (RES_UNKNOWNATR_BEGIN <= nWhich && nWhich < RES_UNKNOWNATR_END) ) + if ( isCHRATR(nWhich) || + (RES_TXTATR_CHARFMT == nWhich) || + (RES_TXTATR_INETFMT == nWhich) || + (RES_TXTATR_AUTOFMT == nWhich) || + isUNKNOWNATR(nWhich) ) { pCharSet = &rChgSet; bCharAttr = true; } - if ( (RES_PARATR_BEGIN <= nWhich && nWhich < RES_PARATR_END) || + if ( isPARATR(nWhich) // --> OD 2008-02-25 #refactorlists# - (RES_PARATR_LIST_BEGIN <= nWhich && nWhich < RES_PARATR_LIST_END) || + || isPARATR_LIST(nWhich) // <-- - (RES_FRMATR_BEGIN <= nWhich && nWhich < RES_FRMATR_END) || - (RES_GRFATR_BEGIN <= nWhich && nWhich < RES_GRFATR_END) ) + || isFRMATR(nWhich) + || isGRFATR(nWhich) ) { pOtherSet = &rChgSet; bOtherAttr = true; @@ -672,7 +667,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, bDelete = true; } - SwHistory* pHistory = pUndo ? pUndo->GetHistory() : 0; + SwHistory* pHistory = pUndo ? &pUndo->GetHistory() : 0; BOOL bRet = FALSE; const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End(); SwCntntNode* pNode = pStt->nNode.GetNode().GetCntntNode(); @@ -1183,13 +1178,17 @@ void SwDoc::SetAttr( const SfxItemSet& rSet, SwFmt& rFmt ) if( DoesUndo() ) { ClearRedo(); - _UndoFmtAttr aTmp( rFmt ); + SwUndoFmtAttrHelper aTmp( rFmt ); rFmt.SetFmtAttr( rSet ); - if( aTmp.pUndo ) - AppendUndo( aTmp.pUndo ); + if ( aTmp.GetUndo() ) + { + AppendUndo( aTmp.ReleaseUndo() ); + } } else + { rFmt.SetFmtAttr( rSet ); + } SetModified(); } @@ -1271,30 +1270,34 @@ void SwDoc::SetDefault( const SfxItemSet& rSet ) GetAttrPool().SetPoolDefaultItem( *pItem ); aNew.Put( GetAttrPool().GetDefaultItem( nWhich ) ); - if( RES_CHRATR_BEGIN <= nWhich && RES_TXTATR_END > nWhich ) + if (isCHRATR(nWhich) || isTXTATR(nWhich)) { aCallMod.Add( pDfltTxtFmtColl ); aCallMod.Add( pDfltCharFmt ); bCheckSdrDflt = 0 != pSdrPool; } - else if ( ( RES_PARATR_BEGIN <= nWhich && RES_PARATR_END > nWhich ) || + else if ( isPARATR(nWhich) || // --> OD 2008-02-25 #refactorlists# - ( RES_PARATR_LIST_BEGIN <= nWhich && nWhich < RES_PARATR_LIST_END ) ) + isPARATR_LIST(nWhich) ) // <-- { aCallMod.Add( pDfltTxtFmtColl ); bCheckSdrDflt = 0 != pSdrPool; } - else if( RES_GRFATR_BEGIN <= nWhich && RES_GRFATR_END > nWhich ) + else if (isGRFATR(nWhich)) + { aCallMod.Add( pDfltGrfFmtColl ); - else if( RES_FRMATR_BEGIN <= nWhich && RES_FRMATR_END > nWhich ) + } + else if (isFRMATR(nWhich)) { aCallMod.Add( pDfltGrfFmtColl ); aCallMod.Add( pDfltTxtFmtColl ); aCallMod.Add( pDfltFrmFmt ); } - else if( RES_BOXATR_BEGIN <= nWhich && RES_BOXATR_END > nWhich ) + else if (isBOXATR(nWhich)) + { aCallMod.Add( pDfltFrmFmt ); + } // copy also the defaults if( bCheckSdrDflt ) @@ -2332,7 +2335,7 @@ void SwDoc::MoveLeftMargin( const SwPaM& rPam, BOOL bRight, BOOL bModulus ) ClearRedo(); SwUndoMoveLeftMargin* pUndo = new SwUndoMoveLeftMargin( rPam, bRight, bModulus ); - pHistory = pUndo->GetHistory(); + pHistory = &pUndo->GetHistory(); AppendUndo( pUndo ); } diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx index d11d846f0856..d9e711bd5fcf 100644 --- a/sw/source/core/doc/docftn.cxx +++ b/sw/source/core/doc/docftn.cxx @@ -74,7 +74,7 @@ SwEndNoteInfo& SwEndNoteInfo::operator=(const SwEndNoteInfo& rInfo) aFmt = rInfo.aFmt; nFtnOffset = rInfo.nFtnOffset; - bEndNote = rInfo.bEndNote; + m_bEndNote = rInfo.m_bEndNote; sPrefix = rInfo.sPrefix; sSuffix = rInfo.sSuffix; return *this; @@ -92,7 +92,7 @@ BOOL SwEndNoteInfo::operator==( const SwEndNoteInfo& rInfo ) const GetFtnTxtColl() == rInfo.GetFtnTxtColl() && aFmt.GetNumberingType() == rInfo.aFmt.GetNumberingType() && nFtnOffset == rInfo.nFtnOffset && - bEndNote == rInfo.bEndNote && + m_bEndNote == rInfo.m_bEndNote && sPrefix == rInfo.sPrefix && sSuffix == rInfo.sSuffix; } @@ -105,7 +105,7 @@ SwEndNoteInfo::SwEndNoteInfo(const SwEndNoteInfo& rInfo) : aAnchorCharFmtDep( this, 0 ), sPrefix( rInfo.sPrefix ), sSuffix( rInfo.sSuffix ), - bEndNote( TRUE ), + m_bEndNote( true ), aFmt( rInfo.aFmt ), nFtnOffset( rInfo.nFtnOffset ) { @@ -125,7 +125,7 @@ SwEndNoteInfo::SwEndNoteInfo(SwTxtFmtColl *pFmt) : aPageDescDep( this, 0 ), aCharFmtDep( this, 0 ), aAnchorCharFmtDep( this, 0 ), - bEndNote( TRUE ), + m_bEndNote( true ), nFtnOffset( 0 ) { aFmt.SetNumberingType(SVX_NUM_ROMAN_LOWER); @@ -136,7 +136,7 @@ SwPageDesc *SwEndNoteInfo::GetPageDesc( SwDoc &rDoc ) const if ( !aPageDescDep.GetRegisteredIn() ) { SwPageDesc *pDesc = rDoc.GetPageDescFromPool( static_cast<sal_uInt16>( - bEndNote ? RES_POOLPAGE_ENDNOTE : RES_POOLPAGE_FOOTNOTE ) ); + m_bEndNote ? RES_POOLPAGE_ENDNOTE : RES_POOLPAGE_FOOTNOTE ) ); pDesc->Add( &((SwClient&)aPageDescDep) ); } return (SwPageDesc*)aPageDescDep.GetRegisteredIn(); @@ -157,7 +157,7 @@ SwCharFmt* SwEndNoteInfo::GetCharFmt(SwDoc &rDoc) const if ( !aCharFmtDep.GetRegisteredIn() ) { SwCharFmt* pFmt = rDoc.GetCharFmtFromPool( static_cast<sal_uInt16>( - bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE ) ); + m_bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE ) ); pFmt->Add( &((SwClient&)aCharFmtDep) ); } return (SwCharFmt*)aCharFmtDep.GetRegisteredIn(); @@ -174,7 +174,7 @@ SwCharFmt* SwEndNoteInfo::GetAnchorCharFmt(SwDoc &rDoc) const if( !aAnchorCharFmtDep.GetRegisteredIn() ) { SwCharFmt* pFmt = rDoc.GetCharFmtFromPool( static_cast<sal_uInt16>( - bEndNote ? RES_POOLCHR_ENDNOTE_ANCHOR : RES_POOLCHR_FOOTNOTE_ANCHOR ) ); + m_bEndNote ? RES_POOLCHR_ENDNOTE_ANCHOR : RES_POOLCHR_FOOTNOTE_ANCHOR ) ); pFmt->Add( &((SwClient&)aAnchorCharFmtDep) ); } return (SwCharFmt*)aAnchorCharFmtDep.GetRegisteredIn(); @@ -203,8 +203,10 @@ void SwEndNoteInfo::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) { SwTxtFtn *pTxtFtn = rFtnIdxs[ nPos ]; const SwFmtFtn &rFtn = pTxtFtn->GetFtn(); - if ( rFtn.IsEndNote() == bEndNote) + if ( rFtn.IsEndNote() == m_bEndNote ) + { pTxtFtn->SetNumber( rFtn.GetNumber(), &rFtn.GetNumStr()); + } } } else @@ -239,7 +241,7 @@ SwFtnInfo::SwFtnInfo(const SwFtnInfo& rInfo) : ePos( rInfo.ePos ), eNum( rInfo.eNum ) { - bEndNote = FALSE; + m_bEndNote = false; } SwFtnInfo::SwFtnInfo(SwTxtFmtColl *pFmt) : @@ -248,7 +250,7 @@ SwFtnInfo::SwFtnInfo(SwTxtFmtColl *pFmt) : eNum( FTNNUM_DOC ) { aFmt.SetNumberingType(SVX_NUM_ARABIC); - bEndNote = FALSE; + m_bEndNote = false; } /*********************** SwDoc ***************************/ @@ -263,7 +265,7 @@ void SwDoc::SetFtnInfo(const SwFtnInfo& rInfo) if( DoesUndo() ) { ClearRedo(); - AppendUndo( new SwUndoFtnInfo( rOld ) ); + AppendUndo( new SwUndoFootNoteInfo( rOld ) ); } BOOL bFtnPos = rInfo.ePos != rOld.ePos; @@ -384,8 +386,8 @@ void SwDoc::SetEndNoteInfo(const SwEndNoteInfo& rInfo) } -BOOL SwDoc::SetCurFtn( const SwPaM& rPam, const String& rNumStr, - USHORT nNumber, BOOL bIsEndNote ) +bool SwDoc::SetCurFtn( const SwPaM& rPam, const String& rNumStr, + sal_uInt16 nNumber, bool bIsEndNote ) { SwFtnIdxs& rFtnArr = GetFtnIdxs(); @@ -398,11 +400,11 @@ BOOL SwDoc::SetCurFtn( const SwPaM& rPam, const String& rNumStr, USHORT nPos; rFtnArr.SeekEntry( pStt->nNode, &nPos ); - SwUndoChgFtn* pUndo = 0; + SwUndoChangeFootNote* pUndo = 0; if( DoesUndo() ) { ClearRedo(); - pUndo = new SwUndoChgFtn( rPam, rNumStr, nNumber, bIsEndNote ); + pUndo = new SwUndoChangeFootNote( rPam, rNumStr, nNumber, bIsEndNote ); } SwTxtFtn* pTxtFtn; @@ -423,8 +425,10 @@ BOOL SwDoc::SetCurFtn( const SwPaM& rPam, const String& rNumStr, rFtn.IsEndNote() != bIsEndNote ) { bChg = TRUE; - if( pUndo ) - pUndo->GetHistory()->Add( *pTxtFtn ); + if ( pUndo ) + { + pUndo->GetHistory().Add( *pTxtFtn ); + } pTxtFtn->SetNumber( nNumber, &rNumStr ); if( rFtn.IsEndNote() != bIsEndNote ) @@ -453,8 +457,10 @@ BOOL SwDoc::SetCurFtn( const SwPaM& rPam, const String& rNumStr, rFtn.IsEndNote() != bIsEndNote ) { bChg = TRUE; - if( pUndo ) - pUndo->GetHistory()->Add( *pTxtFtn ); + if ( pUndo ) + { + pUndo->GetHistory().Add( *pTxtFtn ); + } pTxtFtn->SetNumber( nNumber, &rNumStr ); if( rFtn.IsEndNote() != bIsEndNote ) diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index a0348d84b352..300abf9afd14 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -46,12 +46,8 @@ #include <sfx2/docfile.hxx> #include <sfx2/frame.hxx> -#ifndef _SFXMACITEM_HXX //autogen - #include <svtools/macitem.hxx> -#endif -#ifndef _SVX_SVXIDS_HRC +#include <svtools/macitem.hxx> #include <svx/svxids.hrc> -#endif #include <svx/linkmgr.hxx> #include <svx/forbiddencharacterstable.hxx> #include <svtools/zforlist.hxx> @@ -79,18 +75,12 @@ #include <frmfmt.hxx> #include <rolbck.hxx> // Undo-Attr, SwHistory #include <poolfmt.hxx> // fuer die Pool-Vorlage -#ifndef _DBMGR_HXX #include <dbmgr.hxx> -#endif -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <acorrect.hxx> // fuer die autom. Aufnahme von Ausnahmen #include <visiturl.hxx> // fuer die URL-Change Benachrichtigung #include <docary.hxx> -#ifndef _LINEINFO_HXX #include <lineinfo.hxx> -#endif #include <drawdoc.hxx> #include <linkenum.hxx> #include <fldupde.hxx> @@ -109,9 +99,7 @@ #include <unochart.hxx> -#ifndef _CMDID_H #include <cmdid.h> // fuer den dflt - Printer in SetJob -#endif // --> OD 2006-04-19 #b6375613# @@ -119,7 +107,6 @@ #include <com/sun/star/beans/XPropertyContainer.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> -using namespace ::com::sun::star; // <-- // --> OD 2007-03-16 #i73788# @@ -133,6 +120,10 @@ using namespace ::com::sun::star; #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <sfx2/Metadatable.hxx> + + +using namespace ::com::sun::star; using namespace ::com::sun::star::document; const sal_Char __FAR_DATA sFrmFmtStr[] = "Frameformat"; @@ -271,6 +262,7 @@ SwDoc::SwDoc() : // --> OD 2007-10-31 #i83479# mpListItemsList( new tImplSortedNodeNumList() ), // <-- + m_pXmlIdRegistry(), nUndoPos( 0 ), nUndoSavePos( 0 ), nUndoCnt( 0 ), @@ -1049,3 +1041,15 @@ void SwDoc::SetApplyWorkaroundForB6375613( bool p_bApplyWorkaroundForB6375613 ) } } // <-- + +::sfx2::IXmlIdRegistry& +SwDoc::GetXmlIdRegistry() +{ + // UGLY: this relies on SetClipBoard being called before GetXmlIdRegistry! + if (!m_pXmlIdRegistry.get()) + { + m_pXmlIdRegistry.reset( ::sfx2::createXmlIdRegistry( IsClipBoard() ) ); + } + return *m_pXmlIdRegistry; +} + diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index e23f56bab386..77268d3e318a 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -2678,7 +2678,8 @@ BOOL SwRedlineTbl::InsertWithValidRanges( SwRedlinePtr& p, USHORT* pInsPos ) { // but our Mark was outside the table => Correction do { - *pNew->GetPoint() = *pTab; // We want to be before the table + // We want to be before the table + *pNew->GetPoint() = SwPosition(*pTab); pC = GoPreviousNds( &pNew->GetPoint()->nNode, FALSE ); // here we are. if( pC ) pNew->GetPoint()->nContent.Assign( pC, 0 ); diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index ba65939c5a91..0d9607b290c6 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -195,12 +195,12 @@ void SwDoc::Delete( const SwTOXMark* pTOXMark ) { // fuers Undo die Attribute sichern ClearRedo(); - SwUndoRstAttr* pUndo = new SwUndoRstAttr( *this, SwPosition( rTxtNd, - SwIndex( &rTxtNd, *pTxtTOXMark->GetStart() ) ), - RES_TXTATR_TOXMARK ); + SwUndoResetAttr* pUndo = new SwUndoResetAttr( + SwPosition( rTxtNd, SwIndex( &rTxtNd, *pTxtTOXMark->GetStart() ) ), + RES_TXTATR_TOXMARK ); AppendUndo( pUndo ); - SwRegHistory aRHst( rTxtNd, pUndo->GetHistory() ); + SwRegHistory aRHst( rTxtNd, &pUndo->GetHistory() ); rTxtNd.GetpSwpHints()->Register( &aRHst ); rTxtNd.Delete( const_cast<SwTxtTOXMark*>( pTxtTOXMark ), TRUE ); if( rTxtNd.GetpSwpHints() ) diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 889cb7beb298..e939b7ddec05 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -788,7 +788,7 @@ void SwNoTxtFrm::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) break; default: - if( !pNew || RES_GRFATR_BEGIN > nWhich || nWhich >= RES_GRFATR_END ) + if ( !pNew || !isGRFATR(nWhich) ) return; } diff --git a/sw/source/core/doc/visiturl.cxx b/sw/source/core/doc/visiturl.cxx index 2a909ac3c32f..d5d0832c0a20 100644 --- a/sw/source/core/doc/visiturl.cxx +++ b/sw/source/core/doc/visiturl.cxx @@ -41,9 +41,7 @@ #include <hints.hxx> #include <ndtxt.hxx> #include <editsh.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif SwURLStateChanged::SwURLStateChanged( const SwDoc* pD ) @@ -92,7 +90,7 @@ void SwURLStateChanged::Notify( SfxBroadcaster& , const SfxHint& rHint ) bUnLockView = !pESh->IsViewLocked(); pESh->LockView( TRUE ); } - ((SwTxtINetFmt*)pTxtAttr)->SetValidVis( FALSE ); + const_cast<SwTxtINetFmt*>(pTxtAttr)->SetVisitedValid( false ); const SwTxtAttr* pAttr = pTxtAttr; SwUpdateAttr aUpdateAttr( *pAttr->GetStart(), *pAttr->GetEnd(), diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 3f8280070d37..4022c0d82e1b 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -247,6 +247,9 @@ SwCntntNode* SwTxtNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const SwTxtNode* pTxtNd = pDoc->GetNodes().MakeTxtNode( rIdx, pColl ); + // METADATA: register copy + pTxtNd->RegisterAsCopyOf(*pCpyTxtNd); + // kopiere Attribute/Text if( !pCpyAttrNd->HasSwAttrSet() ) // wurde ein AttrSet fuer die Numerierung angelegt, so loesche diesen! diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 1e1bcd55022a..a832c33ec958 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -50,9 +50,7 @@ #include <fmtfordr.hxx> #include <fmtpdsc.hxx> #include <fmtanchr.hxx> -#ifndef _FMTLSPLT_HXX #include <fmtlsplt.hxx> -#endif #include <frmatr.hxx> #include <charatr.hxx> #include <cellfrm.hxx> @@ -92,9 +90,7 @@ #ifndef _COMCORE_HRC #include <comcore.hrc> #endif -#ifndef _DOCSH_HXX #include "docsh.hxx" -#endif #ifdef LINUX #include <tabcol.hxx> #endif @@ -1549,8 +1545,8 @@ BOOL lcl_DelBox( const SwTableBox*& rpBox, void* pPara ) 0 != ( pCurTxtNd = aDelRg.aStart.GetNode().GetTxtNode() )) { // Join the current text node with the last from the previous box if possible - aDelRg.aStart--; ULONG nNdIdx = aDelRg.aStart.GetIndex(); + aDelRg.aStart--; if( pDelPara->pLastNd == &aDelRg.aStart.GetNode() ) { // Inserting the seperator @@ -1562,7 +1558,7 @@ BOOL lcl_DelBox( const SwTableBox*& rpBox, void* pPara ) SvULongs aBkmkArr( 4, 4 ); xub_StrLen nOldTxtLen = aCntIdx.GetIndex(); - _SaveCntntIdx( pDoc, nNdIdx + 1, pCurTxtNd->GetTxt().Len(), + _SaveCntntIdx( pDoc, nNdIdx, pCurTxtNd->GetTxt().Len(), aBkmkArr ); pDelPara->pLastNd->JoinNext(); @@ -1575,7 +1571,6 @@ BOOL lcl_DelBox( const SwTableBox*& rpBox, void* pPara ) else if( pDelPara->pUndo ) { aDelRg.aStart++; - nNdIdx = aDelRg.aStart.GetIndex(); pDelPara->pUndo->AddBoxPos( *pDoc, nNdIdx, aDelRg.aEnd.GetIndex() ); } } @@ -2544,7 +2539,7 @@ void SwDoc::GetTabCols( SwTabCols &rFill, const SwCursor* pCrsr, return ; Point aPt; - const SwShellCrsr *pShCrsr = *pCrsr; + const SwShellCrsr *pShCrsr = dynamic_cast<const SwShellCrsr*>(pCrsr); if( pShCrsr ) aPt = pShCrsr->GetPtPos(); @@ -2769,7 +2764,7 @@ void SwDoc::SetTabCols( const SwTabCols &rNew, BOOL bCurRowOnly, return ; Point aPt; - const SwShellCrsr *pShCrsr = *pCrsr; + const SwShellCrsr *pShCrsr = dynamic_cast<const SwShellCrsr*>(pCrsr); if( pShCrsr ) aPt = pShCrsr->GetPtPos(); diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index 1a107dbf3014..d6d04062b74f 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -117,7 +117,7 @@ void lcl_GetStartEndCell( const SwCursor& rCrsr, "Tabselection nicht auf Cnt." ); Point aPtPos, aMkPos; - const SwShellCrsr* pShCrsr = rCrsr; + const SwShellCrsr* pShCrsr = dynamic_cast<const SwShellCrsr*>(&rCrsr); if( pShCrsr ) { aPtPos = pShCrsr->GetPtPos(); @@ -138,7 +138,8 @@ void lcl_GetStartEndCell( const SwCursor& rCrsr, BOOL lcl_GetBoxSel( const SwCursor& rCursor, SwSelBoxes& rBoxes, BOOL bAllCrsr = FALSE ) { - const SwTableCursor* pTblCrsr = rCursor; + const SwTableCursor* pTblCrsr = + dynamic_cast<const SwTableCursor*>(&rCursor); if( pTblCrsr ) ::GetTblSelCrs( *pTblCrsr, rBoxes ); else diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx index dfe258def74d..665139b95844 100644 --- a/sw/source/core/edit/acorrect.cxx +++ b/sw/source/core/edit/acorrect.cxx @@ -491,7 +491,7 @@ void SwDontExpandItem::RestoreDontExpandItems( const SwPosition& rPos ) for( n = 0; n < nSize; ++n ) { - SwTxtAttr* pHt = pTxtNd->GetpSwpHints()->GetHt( n ); + SwTxtAttr* pHt = pTxtNd->GetpSwpHints()->GetTextHint( n ); nAttrStart = *pHt->GetStart(); if( nAttrStart > nStart ) // ueber den Bereich hinaus break; diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index b3dc625db9c2..2bf30449f33b 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -172,11 +172,6 @@ BOOL SwEditShell::GetCurAttr( SfxItemSet& rSet, if( aSet.Count() ) aSet.ClearItem(); - -#ifdef JP_NEWCORE - // vieleicht sollte man hier noch erfragen, ob schon alle Attribute - // "DontCare" sind. Dann kann man abbrechen! -#endif } pSet = &aSet; } @@ -251,9 +246,9 @@ BOOL SwEditShell::GetCurFtn( SwFmtFtn* pFillFtn ) } -BOOL SwEditShell::SetCurFtn( const SwFmtFtn& rFillFtn ) +bool SwEditShell::SetCurFtn( const SwFmtFtn& rFillFtn ) { - BOOL bChgd = FALSE; + bool bChgd = false; StartAllAction(); SwPaM* pCrsr = GetCrsr(), *pFirst = pCrsr; @@ -284,7 +279,7 @@ BOOL SwEditShell::SetCurFtn( const SwFmtFtn& rFillFtn ) } */ -BOOL SwEditShell::HasFtns( BOOL bEndNotes ) const +bool SwEditShell::HasFtns( bool bEndNotes ) const { const SwFtnIdxs &rIdxs = pDoc->GetFtnIdxs(); for ( USHORT i = 0; i < rIdxs.Count(); ++i ) @@ -298,7 +293,7 @@ BOOL SwEditShell::HasFtns( BOOL bEndNotes ) const // gebe Liste aller Fussnoten und deren Anfangstexte -USHORT SwEditShell::GetSeqFtnList( SwSeqFldList& rList, BOOL bEndNotes ) +USHORT SwEditShell::GetSeqFtnList( SwSeqFldList& rList, bool bEndNotes ) { if( rList.Count() ) rList.Remove( 0, rList.Count() ); diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx index 7d8eeccb3159..4787877023f0 100644 --- a/sw/source/core/edit/eddel.cxx +++ b/sw/source/core/edit/eddel.cxx @@ -42,12 +42,8 @@ #include <IMark.hxx> #include <docary.hxx> #include <SwRewriter.hxx> -#ifndef _UNOBJ_HXX #include <undobj.hxx> -#endif -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif #include <comcore.hrc> #include <list> @@ -256,7 +252,7 @@ long SwEditShell::Copy( SwEditShell* pDestShell ) if( !GetDoc()->Copy( *PCURCRSR, *pPos )) continue; - SwPaM aInsertPaM(*pPos, aSttNdIdx); + SwPaM aInsertPaM(*pPos, SwPosition(aSttNdIdx)); pDestShell->GetDoc()->MakeUniqueNumRules(aInsertPaM); bRet = TRUE; @@ -321,24 +317,6 @@ BOOL SwEditShell::Replace( const String& rNewStr, BOOL bRegExpRplc ) GetDoc()->StartUndo(UNDO_EMPTY, NULL); FOREACHPAM_START(this) - -//JP 02.12.97: muss das noch sein?? - // sollten mehrere Node selektiert sein, dann loesche diese - // erst, fuege ein Zeichen ein und ersetze dann dieses - if( PCURCRSR->GetPoint()->nNode != PCURCRSR->GetMark()->nNode ) - { - BOOL bForward = PCURCRSR->GetPoint()->nNode.GetIndex() > - PCURCRSR->GetMark()->nNode.GetIndex(); - DeleteSel( *PCURCRSR ); - pDoc->Insert( *PCURCRSR, ' ' ); - PCURCRSR->SetMark(); - if( bForward ) - PCURCRSR->GetMark()->nContent--; - else - PCURCRSR->GetPoint()->nContent--; - } -//JP 02.12.97: muss das noch sein?? - if( PCURCRSR->HasMark() && *PCURCRSR->GetMark() != *PCURCRSR->GetPoint() ) { bRet = GetDoc()->Replace( *PCURCRSR, rNewStr, bRegExpRplc ) || bRet; diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 0a866b3855fb..0035a8880ba9 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -68,9 +68,12 @@ #include <unochart.hxx> #include <numrule.hxx> #include <SwNodeNum.hxx> +#include <unocrsr.hxx> + using namespace com::sun::star; + SV_IMPL_PTRARR(SwGetINetAttrs, SwGetINetAttr*) /****************************************************************************** @@ -123,7 +126,7 @@ void SwEditShell::Insert(const String &rStr) // calculate cursor bidi level SwCursor* pTmpCrsr = _GetCrsr(); const BOOL bDoNotSetBidiLevel = ! pTmpCrsr || - ( 0 != (SwUnoCrsr*)*pTmpCrsr ); + ( 0 != dynamic_cast<SwUnoCrsr*>(pTmpCrsr) ); if ( ! bDoNotSetBidiLevel ) { diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index 3b82b28c6090..ee2eca9722c6 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -804,7 +804,9 @@ void SwFEShell::Insert( const String& rGrfName, const String& rFltName, SwFlyFrmFmt* pFmt = 0; SET_CURR_SHELL( this ); StartAllAction(); - FOREACHCURSOR_START( this ) + SwShellCrsr *pStartCursor = dynamic_cast<SwShellCrsr*>(this->GetSwCrsr()); + SwShellCrsr *pCursor = pStartCursor; + do { // Anker noch nicht oder unvollstaendig gesetzt ? if( pFlyAttrSet ) @@ -820,18 +822,22 @@ void SwFEShell::Insert( const String& rGrfName, const String& rFltName, case FLY_AUTO_CNTNT: // LAYER_IMPL case FLY_IN_CNTNT: if( !pAnchor->GetCntntAnchor() ) - pAnchor->SetAnchor( PCURCRSR->GetPoint() ); + { + pAnchor->SetAnchor( pCursor->GetPoint() ); + } break; case FLY_AT_FLY: if( !pAnchor->GetCntntAnchor() ) - lcl_SetNewFlyPos( *PCURCRSR->GetNode(), - *pAnchor, GetCrsrDocPos() ); + { + lcl_SetNewFlyPos( *pCursor->GetNode(), + *pAnchor, GetCrsrDocPos() ); + } break; case FLY_PAGE: if( !pAnchor->GetPageNum() ) { - pAnchor->SetPageNum( PCURCRSR->GetPageNum( - sal_True, &PCURCRSR->GetPtPos() ) ); + pAnchor->SetPageNum( pCursor->GetPageNum( + sal_True, &pCursor->GetPtPos() ) ); } break; default : @@ -839,13 +845,15 @@ void SwFEShell::Insert( const String& rGrfName, const String& rFltName, } } } - pFmt = GetDoc()->Insert(*PCURCRSR, rGrfName, + pFmt = GetDoc()->Insert(*pCursor, rGrfName, rFltName, pGraphic, pFlyAttrSet, pGrfAttrSet, pFrmFmt ); ASSERT( pFmt, "Doc->Insert(notxt) failed." ); - FOREACHCURSOR_END() + } while( (pCursor = dynamic_cast<SwShellCrsr*>(pCursor->GetNext())) + != pStartCursor ); + EndAllAction(); if( pFmt ) diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 5375078a48e3..ec3ac828d528 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -34,12 +34,8 @@ #include <hintids.hxx> -#ifndef __RSC //autogen #include <tools/errinf.hxx> -#endif -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif #include <basegfx/vector/b2dvector.hxx> #ifndef _SVX_SVXIDS_HRC #include <svx/svxids.hrc> @@ -120,13 +116,6 @@ TblWait::TblWait( USHORT nCnt, SwFrm *pFrm, SwDocShell &rDocShell, USHORT nCnt2) pWait = new SwWait( rDocShell, TRUE ); } -inline const SwCursor& GetShellCursor( const SwCrsrShell& rShell ) -{ - const SwShellCrsr *pCrsr = rShell.GetTableCrsr(); - if( !pCrsr ) - pCrsr = (SwShellCrsr*)*rShell.GetSwCrsr( FALSE ); - return *pCrsr; -} void SwFEShell::ParkCursorInTab() { @@ -803,13 +792,13 @@ void SwFEShell::SetRowSplit( const SwFmtRowSplit& rNew ) { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetRowSplit( GetShellCursor( *this ), rNew ); + GetDoc()->SetRowSplit( *getShellCrsr( false ), rNew ); EndAllActionAndCall(); } void SwFEShell::GetRowSplit( SwFmtRowSplit*& rpSz ) const { - GetDoc()->GetRowSplit( GetShellCursor( *this ), rpSz ); + GetDoc()->GetRowSplit( *getShellCrsr( false ), rpSz ); } @@ -824,7 +813,7 @@ void SwFEShell::SetRowHeight( const SwFmtFrmSize &rNew ) { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetRowHeight( GetShellCursor( *this ), rNew ); + GetDoc()->SetRowHeight( *getShellCrsr( false ), rNew ); EndAllActionAndCall(); } @@ -833,7 +822,7 @@ void SwFEShell::SetRowHeight( const SwFmtFrmSize &rNew ) ******************************************************************************/ void SwFEShell::GetRowHeight( SwFmtFrmSize *& rpSz ) const { - GetDoc()->GetRowHeight( GetShellCursor( *this ), rpSz ); + GetDoc()->GetRowHeight( *getShellCrsr( false ), rpSz ); } BOOL SwFEShell::BalanceRowHeight( BOOL bTstOnly ) @@ -841,7 +830,7 @@ BOOL SwFEShell::BalanceRowHeight( BOOL bTstOnly ) SET_CURR_SHELL( this ); if( !bTstOnly ) StartAllAction(); - BOOL bRet = GetDoc()->BalanceRowHeight( GetShellCursor( *this ), bTstOnly ); + BOOL bRet = GetDoc()->BalanceRowHeight( *getShellCrsr( false ), bTstOnly ); if( !bTstOnly ) EndAllActionAndCall(); return bRet; @@ -854,7 +843,7 @@ void SwFEShell::SetRowBackground( const SvxBrushItem &rNew ) { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetRowBackground( GetShellCursor( *this ), rNew ); + GetDoc()->SetRowBackground( *getShellCrsr( false ), rNew ); EndAllActionAndCall(); } @@ -863,7 +852,7 @@ void SwFEShell::SetRowBackground( const SvxBrushItem &rNew ) ******************************************************************************/ BOOL SwFEShell::GetRowBackground( SvxBrushItem &rToFill ) const { - return GetDoc()->GetRowBackground( GetShellCursor( *this ), rToFill ); + return GetDoc()->GetRowBackground( *getShellCrsr( false ), rToFill ); } /*********************************************************************** @@ -877,7 +866,7 @@ void SwFEShell::SetTabBorders( const SfxItemSet& rSet ) { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetTabBorders( GetShellCursor( *this ), rSet ); + GetDoc()->SetTabBorders( *getShellCrsr( false ), rSet ); EndAllActionAndCall(); } @@ -886,14 +875,14 @@ void SwFEShell::SetTabLineStyle( const Color* pColor, BOOL bSetLine, { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetTabLineStyle( GetShellCursor( *this ), + GetDoc()->SetTabLineStyle( *getShellCrsr( false ), pColor, bSetLine, pBorderLine ); EndAllActionAndCall(); } void SwFEShell::GetTabBorders( SfxItemSet& rSet ) const { - GetDoc()->GetTabBorders( GetShellCursor( *this ), rSet ); + GetDoc()->GetTabBorders( *getShellCrsr( false ), rSet ); } @@ -907,13 +896,13 @@ void SwFEShell::SetBoxBackground( const SvxBrushItem &rNew ) { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetBoxAttr( GetShellCursor( *this ), rNew ); + GetDoc()->SetBoxAttr( *getShellCrsr( false ), rNew ); EndAllActionAndCall(); } BOOL SwFEShell::GetBoxBackground( SvxBrushItem &rToFill ) const { - return GetDoc()->GetBoxAttr( GetShellCursor( *this ), rToFill ); + return GetDoc()->GetBoxAttr( *getShellCrsr( false ), rToFill ); } /*********************************************************************** @@ -926,13 +915,13 @@ void SwFEShell::SetBoxDirection( const SvxFrameDirectionItem& rNew ) { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetBoxAttr( GetShellCursor( *this ), rNew ); + GetDoc()->SetBoxAttr( *getShellCrsr( false ), rNew ); EndAllActionAndCall(); } BOOL SwFEShell::GetBoxDirection( SvxFrameDirectionItem& rToFill ) const { - return GetDoc()->GetBoxAttr( GetShellCursor( *this ), rToFill ); + return GetDoc()->GetBoxAttr( *getShellCrsr( false ), rToFill ); } /*********************************************************************** @@ -945,13 +934,13 @@ void SwFEShell::SetBoxAlign( USHORT nAlign ) { SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetBoxAlign( GetShellCursor( *this ), nAlign ); + GetDoc()->SetBoxAlign( *getShellCrsr( false ), nAlign ); EndAllActionAndCall(); } USHORT SwFEShell::GetBoxAlign() const { - return GetDoc()->GetBoxAlign( GetShellCursor( *this ) ); + return GetDoc()->GetBoxAlign( *getShellCrsr( false ) ); } /*********************************************************************** @@ -1063,7 +1052,7 @@ void SwFEShell::ProtectCells() SET_CURR_SHELL( this ); StartAllAction(); - GetDoc()->SetBoxAttr( GetShellCursor( *this ), aProt ); + GetDoc()->SetBoxAttr( *getShellCrsr( false ), aProt ); if( !IsCrsrReadonly() ) { @@ -1280,7 +1269,7 @@ void SwFEShell::AdjustCellWidth( BOOL bBalance ) //ermitteln laesst wieviel Inhalt betroffen ist. TblWait aWait( USHRT_MAX, 0, *GetDoc()->GetDocShell() ); - GetDoc()->AdjustCellWidth( GetShellCursor( *this ), bBalance ); + GetDoc()->AdjustCellWidth( *getShellCrsr( false ), bBalance ); EndAllActionAndCall(); } diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index f621e60fbc74..ba550304e04a 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -210,11 +210,7 @@ void GetTblSel( const SwCrsrShell& rShell, SwSelBoxes& rBoxes, if ( !rShell.IsTableMode() ) rShell.GetCrsr(); - const SwShellCrsr *pCrsr = rShell.GetTableCrsr(); - if( !pCrsr ) - pCrsr = (SwShellCrsr*)*rShell.GetSwCrsr( FALSE ); - - GetTblSel( *pCrsr, rBoxes, eSearchType ); + GetTblSel( *rShell.getShellCrsr(false), rBoxes, eSearchType ); } void GetTblSel( const SwCursor& rCrsr, SwSelBoxes& rBoxes, @@ -287,7 +283,7 @@ void GetTblSel( const SwCursor& rCrsr, SwSelBoxes& rBoxes, else { Point aPtPos, aMkPos; - const SwShellCrsr* pShCrsr = rCrsr; + const SwShellCrsr* pShCrsr = dynamic_cast<const SwShellCrsr*>(&rCrsr); if( pShCrsr ) { aPtPos = pShCrsr->GetPtPos(); @@ -2066,11 +2062,7 @@ BOOL CheckSplitCells( const SwCrsrShell& rShell, USHORT nDiv, if( !rShell.IsTableMode() ) rShell.GetCrsr(); - const SwShellCrsr *pCrsr = rShell.GetTableCrsr(); - if( !pCrsr ) - pCrsr = (SwShellCrsr*)*rShell.GetSwCrsr( FALSE ); - - return CheckSplitCells( *pCrsr, nDiv, eSearchType ); + return CheckSplitCells( *rShell.getShellCrsr(false), nDiv, eSearchType ); } BOOL CheckSplitCells( const SwCursor& rCrsr, USHORT nDiv, @@ -2083,7 +2075,7 @@ BOOL CheckSplitCells( const SwCursor& rCrsr, USHORT nDiv, //Start- und Endzelle besorgen und den naechsten fragen. Point aPtPos, aMkPos; - const SwShellCrsr* pShCrsr = rCrsr; + const SwShellCrsr* pShCrsr = dynamic_cast<const SwShellCrsr*>(&rCrsr); if( pShCrsr ) { aPtPos = pShCrsr->GetPtPos(); diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 76e877555fe9..b829d201ce03 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -2160,7 +2160,7 @@ BOOL SwFlowFrm::MoveBwd( BOOL &rbReformat ) // --> FME 2004-11-15 #i37084# FindLastCntnt does not necessarily // have to have a result != 0 SwFrm* pRef = 0; - const BOOL bEndnote = pFtn->GetAttr()->GetFtn().IsEndNote(); + const bool bEndnote = pFtn->GetAttr()->GetFtn().IsEndNote(); if( bEndnote && pFtn->IsInSct() ) { SwSectionFrm* pSect = pFtn->FindSctFrm(); diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx index b9663b1418d6..73fdfaabe570 100644 --- a/sw/source/core/layout/ftnfrm.cxx +++ b/sw/source/core/layout/ftnfrm.cxx @@ -852,7 +852,7 @@ SwLayoutFrm *SwFrm::GetPrevFtnLeaf( MakePageType eMakeFtn ) if ( !pRet ) { - BOOL bEndn = pFtn->GetAttr()->GetFtn().IsEndNote(); + bool bEndn = pFtn->GetAttr()->GetFtn().IsEndNote(); SwFrm* pTmpRef = NULL; if( bEndn && pFtn->IsInSct() ) { @@ -1442,7 +1442,7 @@ void SwFtnBossFrm::InsertFtn( SwFtnFrm* pNew ) if( IsInSct() ) { SwSectionFrm* pMySect = ImplFindSctFrm(); - BOOL bEndnt = pNew->GetAttr()->GetFtn().IsEndNote(); + bool bEndnt = pNew->GetAttr()->GetFtn().IsEndNote(); if( bEndnt ) { const SwSectionFmt* pEndFmt = pMySect->GetEndSectFmt(); diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx index 65bfff2ae4b1..ea73a56cd8ca 100644 --- a/sw/source/core/layout/pagedesc.cxx +++ b/sw/source/core/layout/pagedesc.cxx @@ -296,10 +296,11 @@ void SwPageDesc::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) const USHORT nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0; SwModify::Modify( pOld, pNew ); - if( RES_ATTRSET_CHG == nWhich || RES_FMT_CHG == nWhich || - ( nWhich >= RES_CHRATR_BEGIN && nWhich < RES_CHRATR_END ) || - nWhich == RES_PARATR_LINESPACING ) + if ( (RES_ATTRSET_CHG == nWhich) || (RES_FMT_CHG == nWhich) + || isCHRATR(nWhich) || (RES_PARATR_LINESPACING == nWhich) ) + { RegisterChange(); + } } static const SwFrm* lcl_GetFrmOfNode( const SwNode& rNd ) diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index be31859c036d..d991b8202eea 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -129,6 +129,7 @@ SwTabFrm::SwTabFrm( SwTable &rTab ): else delete pNew; } + ASSERT( Lower() && Lower()->IsRowFrm(), "SwTabFrm::SwTabFrm: No rows." ); } SwTabFrm::SwTabFrm( SwTabFrm &rTab ) : diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index 2074adea4df3..4cbb6ffaa7b8 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -961,7 +961,7 @@ USHORT SwRootFrm::SetCurrPage( SwCursor* pToSet, USHORT nPageNum ) pCNd->MakeStartIndex( (SwIndex*)&pToSet->GetPoint()->nContent ); pToSet->GetPoint()->nContent = ((SwTxtFrm*)pCntnt)->GetOfst(); - SwShellCrsr* pSCrsr = (SwShellCrsr*)*pToSet; + SwShellCrsr* pSCrsr = dynamic_cast<SwShellCrsr*>(pToSet); if( pSCrsr ) { Point &rPt = pSCrsr->GetPtPos(); @@ -1868,9 +1868,7 @@ bool SwRootFrm::MakeTblCrsrs( SwTableCursor& rTblCrsr ) Point aPtPt, aMkPt; { - SwShellCrsr* pShCrsr = rTblCrsr.operator SwShellCrsr*(); - // Aufgrund eines CompilerBugs von Linux muss - // der Zeigeroperator explizit gerufen werden + SwShellCrsr* pShCrsr = dynamic_cast<SwShellCrsr*>(&rTblCrsr); if( pShCrsr ) { diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx index eb4148264931..bd9a0b1418d3 100644 --- a/sw/source/core/text/atrstck.cxx +++ b/sw/source/core/text/atrstck.cxx @@ -35,9 +35,7 @@ #include <errhdl.hxx> // ASSERT #include <atrhndl.hxx> #include <svtools/itemiter.hxx> -#ifndef _OUTDEV_HXX //autogen #include <vcl/outdev.hxx> -#endif #include <svx/cmapitem.hxx> #include <svx/colritem.hxx> #include <svx/cntritem.hxx> @@ -56,9 +54,7 @@ #include <svx/akrnitem.hxx> #include <svx/blnkitem.hxx> #include <svx/charrotateitem.hxx> -#ifndef _SVX_EMPHITEM_HXX #include <svx/emphitem.hxx> -#endif #include <svx/charscaleitem.hxx> #include <svx/twolinesitem.hxx> #include <svx/charhiddenitem.hxx> @@ -250,12 +246,14 @@ bool lcl_ChgHyperLinkColor( const SwTxtAttr& rAttr, if ( pColor ) { // take color from character format 'unvisited link' - ((SwTxtINetFmt&)rAttr).SetVisited( FALSE ); + SwTxtINetFmt& rInetAttr( const_cast<SwTxtINetFmt&>( + static_cast<const SwTxtINetFmt&>(rAttr)) ); + rInetAttr.SetVisited( false ); const SwCharFmt* pTmpFmt = ((SwTxtINetFmt&)rAttr).GetCharFmt(); const SfxPoolItem* pItem; pTmpFmt->GetItemState( RES_CHRATR_COLOR, TRUE, &pItem ); *pColor = ((SvxColorItem*)pItem)->GetValue(); - ((SwTxtINetFmt&)rAttr).SetVisited( TRUE ); + rInetAttr.SetVisited( true ); } return true; } @@ -446,7 +444,7 @@ void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAS, while( TRUE ) { nWhich = pItem->Which(); - if( RES_CHRATR_BEGIN <= nWhich && RES_CHRATR_END > nWhich ) + if (isCHRATR(nWhich)) { pDefaultArray[ StackPos[ nWhich ] ] = pItem; FontChg( *pItem, rFnt, sal_True ); diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx index 8a39847705e2..b5a3dff475ae 100644 --- a/sw/source/core/text/frmform.cxx +++ b/sw/source/core/text/frmform.cxx @@ -644,7 +644,7 @@ SwCntntFrm *SwTxtFrm::JoinFrm() { SwFtnBossFrm *pFtnBoss = 0; SwFtnBossFrm *pEndBoss = 0; - for( MSHORT i = 0; i < pHints->Count(); ++i ) + for ( USHORT i = 0; i < pHints->Count(); ++i ) { const SwTxtAttr *pHt = (*pHints)[i]; if( RES_TXTATR_FTN==pHt->Which() && *pHt->GetStart()>=nStart ) @@ -744,7 +744,7 @@ SwCntntFrm *SwTxtFrm::SplitFrm( const xub_StrLen nTxtPos ) { SwFtnBossFrm *pFtnBoss = 0; SwFtnBossFrm *pEndBoss = 0; - for( MSHORT i = 0; i < pHints->Count(); ++i ) + for ( USHORT i = 0; i < pHints->Count(); ++i ) { const SwTxtAttr *pHt = (*pHints)[i]; if( RES_TXTATR_FTN==pHt->Which() && *pHt->GetStart()>=nTxtPos ) diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index c07ff50d57ea..82d88875090d 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -65,9 +65,7 @@ #include <itrtxt.hxx> #include <breakit.hxx> #include <com/sun/star/i18n/WordType.hpp> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif using namespace ::com::sun::star::i18n; using namespace ::com::sun::star; @@ -128,11 +126,11 @@ SwAttrIter::~SwAttrIter() SwTxtAttr *SwAttrIter::GetAttr( const xub_StrLen nPosition ) const { - if( pHints ) + if ( pHints ) { - for( MSHORT i = 0; i < pHints->Count(); ++i ) + for ( USHORT i = 0; i < pHints->Count(); ++i ) { - SwTxtAttr *pPos = pHints->GetHt(i); + SwTxtAttr *pPos = pHints->GetTextHint(i); xub_StrLen nStart = *pPos->GetStart(); if( nPosition < nStart ) return 0; @@ -669,7 +667,7 @@ void SwTxtNode::GetMinMaxSize( ULONG nIndex, ULONG& rMin, ULONG &rMax, SwAttrIter aIter( *(SwTxtNode*)this, aScriptInfo ); xub_StrLen nIdx = 0; aIter.SeekAndChgAttrIter( nIdx, pOut ); - xub_StrLen nLen = aText.Len(); + xub_StrLen nLen = m_Text.Len(); long nAktWidth = 0; MSHORT nAdd = 0; SwMinMaxArgs aArg( pOut, pSh, rMin, rMax, rAbsMin ); @@ -683,7 +681,7 @@ void SwTxtNode::GetMinMaxSize( ULONG nIndex, ULONG& rMin, ULONG &rMax, xub_Unicode cChar = CH_BLANK; nStop = nIdx; while( nStop < nLen && nStop < nNextChg && - CH_TAB != ( cChar = aText.GetChar( nStop ) ) && + CH_TAB != ( cChar = m_Text.GetChar( nStop ) ) && CH_BREAK != cChar && CHAR_HARDBLANK != cChar && CHAR_HARDHYPHEN != cChar && CHAR_SOFTHYPHEN != cChar && !pHint ) @@ -692,8 +690,10 @@ void SwTxtNode::GetMinMaxSize( ULONG nIndex, ULONG& rMin, ULONG &rMax, || ( 0 == ( pHint = aIter.GetAttr( nStop ) ) ) ) ++nStop; } - if( lcl_MinMaxString( aArg, aIter.GetFnt(), aText, nIdx, nStop ) ) + if ( lcl_MinMaxString( aArg, aIter.GetFnt(), m_Text, nIdx, nStop ) ) + { nAdd = 20; + } nIdx = nStop; aIter.SeekAndChgAttrIter( nIdx, pOut ); switch( cChar ) @@ -933,7 +933,7 @@ USHORT SwTxtNode::GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd ) // stop at special characters in [ nIdx, nNextChg ] while( nStop < nEnd && nStop < nNextChg ) { - cChar = aText.GetChar( nStop ); + cChar = m_Text.GetChar( nStop ); if( CH_TAB == cChar || CH_BREAK == cChar || CHAR_HARDBLANK == cChar || CHAR_HARDHYPHEN == cChar || CHAR_SOFTHYPHEN == cChar || diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx index 9b14d52256e7..dc789beb9235 100644 --- a/sw/source/core/text/itrtxt.cxx +++ b/sw/source/core/text/itrtxt.cxx @@ -450,7 +450,7 @@ void SwTxtIter::TruncLines( sal_Bool bNoteFollow ) // examine hints in range nEnd - (nEnd + nRangeChar) for( USHORT i = 0; i < pTmpHints->Count(); i++ ) { - const SwTxtAttr* pHt = pTmpHints->GetHt( i ); + const SwTxtAttr* pHt = pTmpHints->GetTextHint( i ); if( RES_TXTATR_FLYCNT == pHt->Which() ) { // check, if hint is in our range diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index 59788c6395ef..55c905b7e679 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -212,9 +212,9 @@ xub_StrLen SwTxtFrm::CalcFlyPos( SwFrmFmt* pSearch ) if( !pHints ) return STRING_LEN; SwTxtAttr* pFound = NULL; - for( MSHORT i = 0; i < pHints->Count(); i++) + for ( USHORT i = 0; i < pHints->Count(); i++) { - SwTxtAttr *pHt = pHints->GetHt( i ); + SwTxtAttr *pHt = pHints->GetTextHint( i ); if( RES_TXTATR_FLYCNT == pHt->Which() ) { SwFrmFmt* pFrmFmt = pHt->GetFlyCnt().GetFrmFmt(); diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index a9272d077170..0a0a99087fc9 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -45,15 +45,9 @@ #include <porrst.hxx> // SwHangingPortion #include <pormulti.hxx> // SwMultiPortion #include <breakit.hxx> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif -#ifndef _COM_SUN_STAR_I18N_CTLSCRIPTTYPE_HDL_ #include <com/sun/star/i18n/CTLScriptType.hdl> -#endif -#ifndef _COM_SUN_STAR_I18N_WORDTYPE_HDL #include <com/sun/star/i18n/WordType.hdl> -#endif #include <paratr.hxx> #include <svx/adjitem.hxx> #include <svx/scripttypeitem.hxx> @@ -1113,7 +1107,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) // we search for connecting opportunities (kashida) else if ( bAdjustBlock && i18n::ScriptType::COMPLEX == nScript ) { - SwScanner aScanner( rNode, rNode.aText, 0, 0, + SwScanner aScanner( rNode, rNode.GetTxt(), 0, 0, i18n::WordType::DICTIONARY_WORD, nLastKashida, nChg ); diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx index 70d094e53597..c6b100f1b746 100644 --- a/sw/source/core/text/txtdrop.cxx +++ b/sw/source/core/text/txtdrop.cxx @@ -155,7 +155,7 @@ sal_Bool SwTxtSizeInfo::_HasHint( const SwTxtNode* pTxtNode, xub_StrLen nPos ) const SwpHints *pHints = pTxtNode->GetpSwpHints(); if( !pHints ) return sal_False; - for( MSHORT i = 0; i < pHints->Count(); ++i ) + for ( USHORT i = 0; i < pHints->Count(); ++i ) { const SwTxtAttr *pPos = (*pHints)[i]; xub_StrLen nStart = *pPos->GetStart(); diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index 2fe945ef58b4..0e50f7d269e4 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -500,18 +500,4 @@ SwNumberPortion *SwTxtFormatter::NewNumberPortion( SwTxtFormatInfo &rInf ) const } return pRet; } -/* -----------------26.06.2003 13:54----------------- - --------------------------------------------------*/ -void SwTxtFld::NotifyContentChange(SwFmtFld& rFmtFld) -{ - //if not in undo section notify the change - if(pMyTxtNd && pMyTxtNd->GetNodes().IsDocNodes()) - pMyTxtNd->Modify(0, &rFmtFld); -} - -// #111840# -SwPosition * SwTxtFld::GetPosition() const -{ - return GetTxtNode().GetPosition(this); -} diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index e7f0fcd88fb1..7295acf3440a 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -451,9 +451,9 @@ void SwTxtFrm::HideFootnotes( xub_StrLen nStart, xub_StrLen nEnd ) const SwpHints *pHints = GetTxtNode()->GetpSwpHints(); if( pHints ) { - const MSHORT nSize = pHints->Count(); + const USHORT nSize = pHints->Count(); SwPageFrm *pPage = 0; - for( MSHORT i = 0; i < nSize; ++i ) + for ( USHORT i = 0; i < nSize; ++i ) { const SwTxtAttr *pHt = (*pHints)[i]; if ( pHt->Which() == RES_TXTATR_FTN ) @@ -505,9 +505,9 @@ bool lcl_HideObj( const SwTxtFrm& _rFrm, const SwTxtAttr* pHint( 0 ); if( pHints ) { - for( MSHORT i = 0; i < pHints->Count(); ++i ) + for ( USHORT i = 0; i < pHints->Count(); ++i ) { - SwTxtAttr* pPos = pHints->GetHt(i); + SwTxtAttr* pPos = pHints->GetTextHint(i); xub_StrLen nStart = *pPos->GetStart(); if ( _nObjAnchorPos < nStart ) break; @@ -1654,10 +1654,10 @@ void SwTxtFrm::Prepare( const PrepareHint ePrep, const void* pVoid, SwpHints *pHints = GetTxtNode()->GetpSwpHints(); if( pHints ) { - const MSHORT nSize = pHints->Count(); + const USHORT nSize = pHints->Count(); const xub_StrLen nEnd = GetFollow() ? GetFollow()->GetOfst() : STRING_LEN; - for( MSHORT i = 0; i < nSize; ++i ) + for ( USHORT i = 0; i < nSize; ++i ) { const SwTxtAttr *pHt = (*pHints)[i]; const xub_StrLen nStart = *pHt->GetStart(); diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx index b5ce2df1dc75..6981ca472419 100644 --- a/sw/source/core/text/txtftn.cxx +++ b/sw/source/core/text/txtftn.cxx @@ -118,7 +118,7 @@ void SwTxtFrm::CalcFtnFlag( xub_StrLen nStop )//Fuer den Test von SplitFrm if( !pHints ) return; - const MSHORT nSize = pHints->Count(); + const USHORT nSize = pHints->Count(); #ifdef PRODUCT const xub_StrLen nEnd = GetFollow() ? GetFollow()->GetOfst() : STRING_LEN; @@ -127,7 +127,7 @@ void SwTxtFrm::CalcFtnFlag( xub_StrLen nStop )//Fuer den Test von SplitFrm : GetFollow() ? GetFollow()->GetOfst() : STRING_LEN; #endif - for( MSHORT i = 0; i < nSize; ++i ) + for ( USHORT i = 0; i < nSize; ++i ) { const SwTxtAttr *pHt = (*pHints)[i]; if ( pHt->Which() == RES_TXTATR_FTN ) @@ -452,7 +452,7 @@ void SwTxtFrm::RemoveFtn( const xub_StrLen nStart, const xub_StrLen nLen ) return; sal_Bool bRollBack = nLen != STRING_LEN; - MSHORT nSize = pHints->Count(); + USHORT nSize = pHints->Count(); xub_StrLen nEnd; SwTxtFrm* pSource; if( bRollBack ) @@ -476,9 +476,9 @@ void SwTxtFrm::RemoveFtn( const xub_StrLen nStart, const xub_StrLen nLen ) SwFtnBossFrm *pEndBoss = 0; sal_Bool bFtnEndDoc = FTNPOS_CHAPTER == GetNode()->GetDoc()->GetFtnInfo().ePos; - for( MSHORT i = nSize; i; ) + for ( USHORT i = nSize; i; ) { - SwTxtAttr *pHt = pHints->GetHt(--i); + SwTxtAttr *pHt = pHints->GetTextHint(--i); if ( RES_TXTATR_FTN != pHt->Which() ) continue; diff --git a/sw/source/core/text/txtio.cxx b/sw/source/core/text/txtio.cxx index 0df7da5f8494..854d252afed8 100644 --- a/sw/source/core/text/txtio.cxx +++ b/sw/source/core/text/txtio.cxx @@ -276,49 +276,8 @@ void LayOutPut( const SwFrm* pFrm ) SvStream &operator<<( SvStream &rOs, const SwpHints & ) //$ ostream { rOs << " {HINTS:"; -#ifdef JP_NEWCORE - for( MSHORT i = 0; i < rHints.GetSize(); ++i) - { - SwTxtHint *pHint = (SwTxtHint*) rHints[i]; - - if(0 != GetCharWidth(pHint)) - rOs << "CHARWIDTH" << ' '; // << GetCharWidth(pHint)->frCPI; - else if(0 != GetColor(pHint)) - rOs << "COLOR" << ' ' ; // << GetColor(pHint)->aColor; - else if(0 != GetCrossedOut(pHint)) - rOs << "CROSSEDOUT" << ' ' << (MSHORT)(GetCrossedOut(pHint)->nState); - else if(0 != GetAttrFont(pHint)) - rOs << "ATTRFONT" << ' ' << - (const char *)(GetAttrFont(pHint)->sFamilyName) << ',' << - ((MSHORT) GetAttrFont(pHint)->eFamily); - else if(0 != GetPosture(pHint)) - rOs << "POSTURE" << ' ' << GetPosture(pHint)->nPosture; - else if(0 != GetFontSize(pHint)) - rOs << "FONTSIZE" << ' ' << GetFontSize(pHint)->nSize; - else if(0 != GetUnderline(pHint)) - rOs << "UNDERLINE" << ' ' << (MSHORT)(GetUnderline(pHint)->nState); - else if(0 != GetOverline(pHint)) - rOs << "OVERLINE" << ' ' << (MSHORT)(GetOverline(pHint)->nState); - else if(0 != GetWeight(pHint)) - rOs << "WEIGHT" << ' ' << GetWeight(pHint)->nWeight; - else if(0 != GetContour(pHint)) - rOs << "CONTOUR" << ' ' << GetContour(pHint)->nState; - else if(0 != GetShadowed(pHint)) - rOs << "SHADOWED" << ' ' << GetShadowed(pHint)->nState; - else if(0 != GetAutoKern(pHint)) - rOs << "AUTOKERN" << ' ' << GetAutoKern(pHint)->nState; - else if(0 != GetWordLineMode(pHint)) - rOs << "WORDLINEMODE" << ' ' << GetWordLineMode(pHint)->nState; - else - rOs << pHint->Which(); - rOs << ',' << pHint->GetStart()->GetIndex() - << '-' - << (pHint->GetEnd() ? pHint->GetEnd()->GetIndex() : STRING_LEN) - << "\n"; - } -#endif - // JP_NEWCORE +// REMOVED rOs << '}'; return rOs; diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 14ac562f64d9..612a2e11b4d0 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -255,12 +255,12 @@ BOOL SwFmtFld::IsProtect() const |* *************************************************************************/ -SwTxtFld::SwTxtFld( const SwFmtFld& rAttr, xub_StrLen nStartPos ) - : SwTxtAttr( rAttr, nStartPos ), - aExpand( rAttr.GetFld()->Expand() ), - pMyTxtNd( 0 ) +SwTxtFld::SwTxtFld( SwFmtFld& rAttr, xub_StrLen nStartPos ) + : SwTxtAttr( rAttr, nStartPos ) + , m_aExpand( rAttr.GetFld()->Expand() ) + , m_pTxtNode( 0 ) { - ((SwFmtFld&)rAttr).pTxtAttr = this; + rAttr.pTxtAttr = this; } SwTxtFld::~SwTxtFld( ) @@ -280,12 +280,12 @@ SwTxtFld::~SwTxtFld( ) void SwTxtFld::Expand() const { // Wenn das expandierte Feld sich nicht veraendert hat, wird returnt - ASSERT( pMyTxtNd, "wo ist denn mein Node?" ); + ASSERT( m_pTxtNode, "SwTxtFld: where is my TxtNode?" ); const SwField* pFld = GetFld().GetFld(); XubString aNewExpand( pFld->Expand() ); - if( aNewExpand == aExpand ) + if( aNewExpand == m_aExpand ) { // Bei Seitennummernfeldern const USHORT nWhich = pFld->GetTyp()->Which(); @@ -301,16 +301,18 @@ void SwTxtFld::Expand() const // BP: das muesste man noch optimieren! //JP 12.06.97: stimmt, man sollte auf jedenfall eine Status- // aenderung an die Frames posten - if( pMyTxtNd->CalcHiddenParaField() ) - pMyTxtNd->Modify( 0, 0 ); + if( m_pTxtNode->CalcHiddenParaField() ) + { + m_pTxtNode->Modify( 0, 0 ); + } return; } } - aExpand = aNewExpand; + m_aExpand = aNewExpand; - // 0, this fuer Formatieren - pMyTxtNd->Modify( 0, (SfxPoolItem*)&GetFld() ); + // 0, this for formatting + m_pTxtNode->Modify( 0, const_cast<SwFmtFld*>( &GetFld() ) ); } /************************************************************************* @@ -319,11 +321,11 @@ void SwTxtFld::Expand() const void SwTxtFld::CopyFld( SwTxtFld *pDest ) const { - ASSERT( pMyTxtNd, "wo ist denn mein Node?" ); - ASSERT( pDest->pMyTxtNd, "wo ist denn mein Node?" ); + ASSERT( m_pTxtNode, "SwTxtFld: where is my TxtNode?" ); + ASSERT( pDest->m_pTxtNode, "SwTxtFld: where is pDest's TxtNode?" ); - IDocumentFieldsAccess* pIDFA = pMyTxtNd->getIDocumentFieldsAccess(); - IDocumentFieldsAccess* pDestIDFA = pDest->pMyTxtNd->getIDocumentFieldsAccess(); + IDocumentFieldsAccess* pIDFA = m_pTxtNode->getIDocumentFieldsAccess(); + IDocumentFieldsAccess* pDestIDFA = pDest->m_pTxtNode->getIDocumentFieldsAccess(); SwFmtFld& rFmtFld = (SwFmtFld&)pDest->GetFld(); const USHORT nFldWhich = rFmtFld.GetFld()->GetTyp()->Which(); @@ -366,10 +368,27 @@ void SwTxtFld::CopyFld( SwTxtFld *pDest ) const ((SwTblField*)rFmtFld.GetFld())->IsIntrnlName() ) { // erzeuge aus der internen (fuer CORE) die externe (fuer UI) Formel - const SwTableNode* pTblNd = pMyTxtNd->FindTableNode(); + const SwTableNode* pTblNd = m_pTxtNode->FindTableNode(); if( pTblNd ) // steht in einer Tabelle ((SwTblField*)rFmtFld.GetFld())->PtrToBoxNm( &pTblNd->GetTable() ); } } +/* -----------------26.06.2003 13:54----------------- + + --------------------------------------------------*/ +void SwTxtFld::NotifyContentChange(SwFmtFld& rFmtFld) +{ + //if not in undo section notify the change + if (m_pTxtNode && m_pTxtNode->GetNodes().IsDocNodes()) + { + m_pTxtNode->Modify(0, &rFmtFld); + } +} + +// #111840# +SwPosition * SwTxtFld::GetPosition() const +{ + return GetTxtNode().GetPosition(this); +} diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx index b33b90ffa9a8..d738497507a8 100644 --- a/sw/source/core/txtnode/atrflyin.cxx +++ b/sw/source/core/txtnode/atrflyin.cxx @@ -70,10 +70,10 @@ SfxPoolItem* __EXPORT SwFmtFlyCnt::Clone( SfxItemPool* ) const return new SwFmtFlyCnt( pFmt ); } -SwTxtFlyCnt::SwTxtFlyCnt( const SwFmtFlyCnt& rAttr, xub_StrLen nStartPos ) +SwTxtFlyCnt::SwTxtFlyCnt( SwFmtFlyCnt& rAttr, xub_StrLen nStartPos ) : SwTxtAttr( rAttr, nStartPos ) { - ((SwFmtFlyCnt&)rAttr).pTxtAttr = this; + rAttr.pTxtAttr = this; } diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx index 96a4f4d90761..9c4728042d34 100644 --- a/sw/source/core/txtnode/atrftn.cxx +++ b/sw/source/core/txtnode/atrftn.cxx @@ -62,11 +62,11 @@ *************************************************************************/ -SwFmtFtn::SwFmtFtn( BOOL bEN ) +SwFmtFtn::SwFmtFtn( bool bEndNote ) : SfxPoolItem( RES_TXTATR_FTN ), pTxtAttr( 0 ), nNumber( 0 ), - bEndNote( bEN ) + m_bEndNote( bEndNote ) { } @@ -76,7 +76,7 @@ int SwFmtFtn::operator==( const SfxPoolItem& rAttr ) const ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" ); return nNumber == ((SwFmtFtn&)rAttr).nNumber && aNumber == ((SwFmtFtn&)rAttr).aNumber && - bEndNote == ((SwFmtFtn&)rAttr).bEndNote; + m_bEndNote == ((SwFmtFtn&)rAttr).m_bEndNote; } @@ -85,17 +85,19 @@ SfxPoolItem* SwFmtFtn::Clone( SfxItemPool* ) const SwFmtFtn* pNew = new SwFmtFtn; pNew->aNumber = aNumber; pNew->nNumber = nNumber; - pNew->bEndNote = bEndNote; + pNew->m_bEndNote = m_bEndNote; return pNew; } -void SwFmtFtn::SetEndNote( BOOL b ) +void SwFmtFtn::SetEndNote( bool b ) { - if ( b != bEndNote ) + if ( b != m_bEndNote ) { if ( GetTxtFtn() ) + { GetTxtFtn()->DelFrms(); - bEndNote = b; + } + m_bEndNote = b; } } @@ -173,13 +175,13 @@ XubString SwFmtFtn::GetViewNumStr( const SwDoc& rDoc, BOOL bInclStrings ) const * class SwTxt/FmtFnt *************************************************************************/ -SwTxtFtn::SwTxtFtn( const SwFmtFtn& rAttr, xub_StrLen nStartPos ) - : SwTxtAttr( rAttr, nStartPos ), - pStartNode( 0 ), - pMyTxtNd( 0 ), - nSeqNo( USHRT_MAX ) +SwTxtFtn::SwTxtFtn( SwFmtFtn& rAttr, xub_StrLen nStartPos ) + : SwTxtAttr( rAttr, nStartPos ) + , m_pStartNode( 0 ) + , m_pTxtNode( 0 ) + , m_nSeqNo( USHRT_MAX ) { - ((SwFmtFtn&)rAttr).pTxtAttr = this; + rAttr.pTxtAttr = this; } @@ -194,19 +196,25 @@ void SwTxtFtn::SetStartNode( const SwNodeIndex *pNewNode, BOOL bDelNode ) { if( pNewNode ) { - if( !pStartNode ) - pStartNode = new SwNodeIndex( *pNewNode ); + if ( !m_pStartNode ) + { + m_pStartNode = new SwNodeIndex( *pNewNode ); + } else - *pStartNode = *pNewNode; + { + *m_pStartNode = *pNewNode; + } } - else if( pStartNode ) + else if ( m_pStartNode ) { // Zwei Dinge muessen erledigt werden: // 1) Die Fussnoten muessen bei ihren Seiten abgemeldet werden // 2) Die Fussnoten-Sektion in den Inserts muss geloescht werden. SwDoc* pDoc; - if( pMyTxtNd ) - pDoc = pMyTxtNd->GetDoc(); + if ( m_pTxtNode ) + { + pDoc = m_pTxtNode->GetDoc(); + } else { //JP 27.01.97: der sw3-Reader setzt einen StartNode aber das @@ -214,7 +222,7 @@ void SwTxtFtn::SetStartNode( const SwNodeIndex *pNewNode, BOOL bDelNode ) // Wird es geloescht (z.B. bei Datei einfuegen mit // Ftn in einen Rahmen), muss auch der Inhalt // geloescht werden - pDoc = pStartNode->GetNodes().GetDoc(); + pDoc = m_pStartNode->GetNodes().GetDoc(); } // Wir duerfen die Fussnotennodes nicht loeschen @@ -226,7 +234,7 @@ void SwTxtFtn::SetStartNode( const SwNodeIndex *pNewNode, BOOL bDelNode ) { // 1) Die Section fuer die Fussnote wird beseitigt // Es kann sein, dass die Inserts schon geloescht wurden. - pDoc->DeleteSection( &pStartNode->GetNode() ); + pDoc->DeleteSection( &m_pStartNode->GetNode() ); } else // Werden die Nodes nicht geloescht mussen sie bei den Seiten @@ -234,7 +242,7 @@ void SwTxtFtn::SetStartNode( const SwNodeIndex *pNewNode, BOOL bDelNode ) // stehen (Undo loescht sie nicht!) DelFrms(); } - DELETEZ( pStartNode ); + DELETEZ( m_pStartNode ); // loesche die Fussnote noch aus dem Array am Dokument for( USHORT n = 0; n < pDoc->GetFtnIdxs().Count(); ++n ) @@ -264,16 +272,15 @@ void SwTxtFtn::SetNumber( const USHORT nNewNum, const XubString* pStr ) rFtn.aNumber = aEmptyStr; } - ASSERT( pMyTxtNd, "wo ist mein TextNode?" ); - SwNodes &rNodes = pMyTxtNd->GetDoc()->GetNodes(); - pMyTxtNd->Modify( 0, &rFtn ); - if( pStartNode ) + ASSERT( m_pTxtNode, "SwTxtFtn: where is my TxtNode?" ); + SwNodes &rNodes = m_pTxtNode->GetDoc()->GetNodes(); + m_pTxtNode->Modify( 0, &rFtn ); + if ( m_pStartNode ) { - // Wir muessen ueber alle TxtNodes iterieren, wegen der - // Fussnoten, die auf anderen Seiten stehen. + // must iterate over all TxtNodes because of footnotes on other pages SwNode* pNd; - ULONG nSttIdx = pStartNode->GetIndex() + 1, - nEndIdx = pStartNode->GetNode().EndOfSectionIndex(); + ULONG nSttIdx = m_pStartNode->GetIndex() + 1; + ULONG nEndIdx = m_pStartNode->GetNode().EndOfSectionIndex(); for( ; nSttIdx < nEndIdx; ++nSttIdx ) { // Es koennen ja auch Grafiken in der Fussnote stehen ... @@ -286,15 +293,15 @@ void SwTxtFtn::SetNumber( const USHORT nNewNum, const XubString* pStr ) // Die Fussnoten duplizieren void SwTxtFtn::CopyFtn( SwTxtFtn *pDest ) { - if( pStartNode && pDest->GetStartNode() ) + if ( m_pStartNode && pDest->GetStartNode() ) { // die Fussnoten koennen in unterschiedlichen Dokumenten stehen !! - SwDoc* pDstDoc = pDest->pMyTxtNd->GetDoc(); + SwDoc* pDstDoc = pDest->m_pTxtNode->GetDoc(); SwNodes &rDstNodes = pDstDoc->GetNodes(); // Wir kopieren nur den Inhalt der Sektion - SwNodeRange aRg( *pStartNode, 1, - *pStartNode->GetNode().EndOfSectionNode() ); + SwNodeRange aRg( *m_pStartNode, 1, + *m_pStartNode->GetNode().EndOfSectionNode() ); // Wir fuegen auf dem Ende von pDest ein, d.h. die Nodes // werden angehaengt. nDestLen haelt die Anzahl der CntNodes @@ -303,7 +310,7 @@ void SwTxtFtn::CopyFtn( SwTxtFtn *pDest ) SwNodeIndex aEnd( *aStart.GetNode().EndOfSectionNode() ); ULONG nDestLen = aEnd.GetIndex() - aStart.GetIndex() - 1; - pMyTxtNd->GetDoc()->CopyWithFlyInFly( aRg, aEnd, TRUE ); + m_pTxtNode->GetDoc()->CopyWithFlyInFly( aRg, aEnd, TRUE ); // Wenn die Dest-Sektion nicht leer war, so muessen die alten // Nodes geloescht werden: @@ -323,7 +330,7 @@ void SwTxtFtn::CopyFtn( SwTxtFtn *pDest ) // lege eine neue leere TextSection fuer diese Fussnote an void SwTxtFtn::MakeNewTextSection( SwNodes& rNodes ) { - if( pStartNode ) + if ( m_pStartNode ) return; // Nun verpassen wir dem TxtNode noch die Fussnotenvorlage. @@ -347,20 +354,20 @@ void SwTxtFtn::MakeNewTextSection( SwNodes& rNodes ) SwStartNode* pSttNd = rNodes.MakeTextSection( SwNodeIndex( rNodes.GetEndOfInserts() ), SwFootnoteStartNode, pFmtColl ); - pStartNode = new SwNodeIndex( *pSttNd ); + m_pStartNode = new SwNodeIndex( *pSttNd ); } void SwTxtFtn::DelFrms() { - // loesche die Ftn-Frames aus den Seiten - ASSERT( pMyTxtNd, "wo ist mein TextNode?" ); - if( !pMyTxtNd ) - return ; + // delete the FtnFrames from the pages + ASSERT( m_pTxtNode, "SwTxtFtn: where is my TxtNode?" ); + if ( !m_pTxtNode ) + return; BOOL bFrmFnd = FALSE; { - SwClientIter aIter( *pMyTxtNd ); + SwClientIter aIter( *m_pTxtNode ); for( SwCntntFrm* pFnd = (SwCntntFrm*)aIter.First( TYPE( SwCntntFrm )); pFnd; pFnd = (SwCntntFrm*)aIter.Next() ) { @@ -374,10 +381,10 @@ void SwTxtFtn::DelFrms() } //JP 13.05.97: falls das Layout vorm loeschen der Fussnoten entfernt // wird, sollte man das ueber die Fussnote selbst tun - if( !bFrmFnd && pStartNode ) + if ( !bFrmFnd && m_pStartNode ) { - SwNodeIndex aIdx( *pStartNode ); - SwCntntNode* pCNd = pMyTxtNd->GetNodes().GoNext( &aIdx ); + SwNodeIndex aIdx( *m_pStartNode ); + SwCntntNode* pCNd = m_pTxtNode->GetNodes().GoNext( &aIdx ); if( pCNd ) { SwClientIter aIter( *pCNd ); @@ -415,10 +422,10 @@ void SwTxtFtn::DelFrms() USHORT SwTxtFtn::SetSeqRefNo() { - if( !pMyTxtNd ) + if( !m_pTxtNode ) return USHRT_MAX; - SwDoc* pDoc = pMyTxtNd->GetDoc(); + SwDoc* pDoc = m_pTxtNode->GetDoc(); if( pDoc->IsInReading() ) return USHRT_MAX; @@ -431,20 +438,33 @@ USHORT SwTxtFtn::SetSeqRefNo() // bestimmt werden muss. SwTxtFtn* pTxtFtn; for( n = 0; n < nFtnCnt; ++n ) - if( (pTxtFtn = pDoc->GetFtnIdxs()[ n ]) != this ) - aArr.Insert( pTxtFtn->nSeqNo ); + { + pTxtFtn = pDoc->GetFtnIdxs()[ n ]; + if ( pTxtFtn != this ) + { + aArr.Insert( pTxtFtn->m_nSeqNo ); + } + } - // teste erstmal ob die Nummer schon vorhanden ist: - if( USHRT_MAX != nSeqNo ) + // test if number is already in use + if ( USHRT_MAX != m_nSeqNo ) { for( n = 0; n < aArr.Count(); ++n ) - if( aArr[ n ] > nSeqNo ) - return nSeqNo; // nicht vorhanden -> also benutzen - else if( aArr[ n ] == nSeqNo ) - break; // schon vorhanden -> neue erzeugen + { + if ( aArr[ n ] > m_nSeqNo ) + { + return m_nSeqNo; // free -> use + } + else if ( aArr[ n ] == m_nSeqNo ) + { + break; // used -> create new one + } + } - if( n == aArr.Count() ) - return nSeqNo; // nicht vorhanden -> also benutzen + if ( n == aArr.Count() ) + { + return m_nSeqNo; // free -> use + } } // alle Nummern entsprechend geflag, also bestimme die richtige Nummer @@ -452,7 +472,7 @@ USHORT SwTxtFtn::SetSeqRefNo() if( n != aArr[ n ] ) break; - return nSeqNo = n; + return m_nSeqNo = n; } void SwTxtFtn::SetUniqueSeqRefNo( SwDoc& rDoc ) @@ -465,29 +485,45 @@ void SwTxtFtn::SetUniqueSeqRefNo( SwDoc& rDoc ) // dann alle Nummern zusammensammeln die schon existieren SwTxtFtn* pTxtFtn; for( n = 0; n < nFtnCnt; ++n ) - if( USHRT_MAX != (pTxtFtn = rDoc.GetFtnIdxs()[ n ])->nSeqNo ) - aArr.Insert( pTxtFtn->nSeqNo ); + { + pTxtFtn = rDoc.GetFtnIdxs()[ n ]; + if ( USHRT_MAX != pTxtFtn->m_nSeqNo ) + { + aArr.Insert( pTxtFtn->m_nSeqNo ); + } + } for( n = 0; n < nFtnCnt; ++n ) - if( USHRT_MAX == (pTxtFtn = rDoc.GetFtnIdxs()[ n ])->nSeqNo ) + { + pTxtFtn = rDoc.GetFtnIdxs()[ n ]; + if ( USHRT_MAX == pTxtFtn->m_nSeqNo ) { for( ; nStt < aArr.Count(); ++nStt ) - if( nStt != aArr[ nStt ] ) + { + if ( nStt != aArr[ nStt ] ) { - - pTxtFtn->nSeqNo = nStt; + pTxtFtn->m_nSeqNo = nStt; break; } + } - if( USHRT_MAX == pTxtFtn->nSeqNo ) - break; // nichts mehr gefunden + if ( USHRT_MAX == pTxtFtn->m_nSeqNo ) + { + break; // found nothing + } } + } // alle Nummern schon vergeben, also mit nStt++ weitermachen for( ; n < nFtnCnt; ++n ) - if( USHRT_MAX == (pTxtFtn = rDoc.GetFtnIdxs()[ n ])->nSeqNo ) - pTxtFtn->nSeqNo = nStt++; + { + pTxtFtn = rDoc.GetFtnIdxs()[ n ]; + if ( USHRT_MAX == pTxtFtn->m_nSeqNo ) + { + pTxtFtn->m_nSeqNo = nStt++; + } + } } void SwTxtFtn::CheckCondColl() diff --git a/sw/source/core/txtnode/atrref.cxx b/sw/source/core/txtnode/atrref.cxx index 210cd1ab2889..ea427f8e8877 100644 --- a/sw/source/core/txtnode/atrref.cxx +++ b/sw/source/core/txtnode/atrref.cxx @@ -79,25 +79,25 @@ SfxPoolItem* SwFmtRefMark::Clone( SfxItemPool* ) const // Attribut fuer Inhalts-/Positions-Referenzen im Text -SwTxtRefMark::SwTxtRefMark( const SwFmtRefMark& rAttr, - xub_StrLen nStartPos, xub_StrLen* pEnde ) - : SwTxtAttrEnd( rAttr, nStartPos, nStartPos ), - pMyTxtNd( 0 ), - pEnd( 0 ) +SwTxtRefMark::SwTxtRefMark( SwFmtRefMark& rAttr, + xub_StrLen nStartPos, xub_StrLen* pEnd ) + : SwTxtAttrEnd( rAttr, nStartPos, nStartPos ) + , m_pTxtNode( 0 ) + , m_pEnd( 0 ) { - ((SwFmtRefMark&)rAttr).pTxtAttr = this; - if( pEnde ) + rAttr.pTxtAttr = this; + if ( pEnd ) { - nEnd = *pEnde; - pEnd = &nEnd; + m_nEnd = *pEnd; + m_pEnd = & m_nEnd; } - SetDontMergeAttr( TRUE ); - SetDontMoveAttr( TRUE ); - SetOverlapAllowedAttr( TRUE ); + SetDontMergeAttr( true ); + SetDontMoveAttr( true ); + SetOverlapAllowedAttr( true ); } xub_StrLen* SwTxtRefMark::GetEnd() { - return pEnd; + return m_pEnd; } diff --git a/sw/source/core/txtnode/atrtox.cxx b/sw/source/core/txtnode/atrtox.cxx index 5581d891b79a..5cc9388dcbcd 100644 --- a/sw/source/core/txtnode/atrtox.cxx +++ b/sw/source/core/txtnode/atrtox.cxx @@ -38,21 +38,21 @@ #include <tox.hxx> #include <ndtxt.hxx> -SwTxtTOXMark::SwTxtTOXMark( const SwTOXMark& rAttr, - xub_StrLen nStartPos, xub_StrLen* pEnde ) - : SwTxtAttrEnd( rAttr, nStartPos, nStartPos ), - pEnd( 0 ), - pMyTxtNd( 0 ) +SwTxtTOXMark::SwTxtTOXMark( SwTOXMark& rAttr, + xub_StrLen nStartPos, xub_StrLen* pEnd ) + : SwTxtAttrEnd( rAttr, nStartPos, nStartPos ) + , m_pTxtNode( 0 ) + , m_pEnd( 0 ) { - ((SwTOXMark&)rAttr).pTxtAttr = this; - if( !rAttr.GetAlternativeText().Len() ) + rAttr.pTxtAttr = this; + if ( !rAttr.GetAlternativeText().Len() ) { - nEnd = *pEnde; - pEnd = &nEnd; + m_nEnd = *pEnd; + m_pEnd = & m_nEnd; } - SetDontMergeAttr( TRUE ); - SetDontMoveAttr( TRUE ); - SetOverlapAllowedAttr( TRUE ); + SetDontMergeAttr( true ); + SetDontMoveAttr( true ); + SetOverlapAllowedAttr( true ); } SwTxtTOXMark::~SwTxtTOXMark() @@ -61,7 +61,7 @@ SwTxtTOXMark::~SwTxtTOXMark() xub_StrLen* SwTxtTOXMark::GetEnd() { - return pEnd; + return m_pEnd; } void SwTxtTOXMark::CopyTOXMark( SwDoc* pDoc ) diff --git a/sw/source/core/txtnode/ndhints.cxx b/sw/source/core/txtnode/ndhints.cxx index bd7da5b7d1f6..64ca41cf8516 100644 --- a/sw/source/core/txtnode/ndhints.cxx +++ b/sw/source/core/txtnode/ndhints.cxx @@ -237,39 +237,41 @@ BOOL SwpHtEnd::Seek_Entry( const SwTxtAttr *pElement, USHORT *pPos ) const * class SwpHintsArr *************************************************************************/ -void SwpHintsArr::Insert( const SwTxtAttr *pHt ) +void SwpHintsArray::Insert( const SwTxtAttr *pHt ) { Resort(); #ifndef PRODUCT USHORT nPos; - ASSERT(!SwpHtStart::Seek_Entry( pHt, &nPos ), "Insert: hint already in HtStart"); - ASSERT(!aHtEnd.Seek_Entry( pHt, &nPos ), "Insert: hint already in HtEnd"); + ASSERT(!m_HintStarts.Seek_Entry( pHt, &nPos ), + "Insert: hint already in HtStart"); + ASSERT(!m_HintEnds.Seek_Entry( pHt, &nPos ), + "Insert: hint already in HtEnd"); #endif - SwpHtStart::Insert( pHt ); - aHtEnd.Insert( pHt ); + m_HintStarts.Insert( pHt ); + m_HintEnds.Insert( pHt ); #ifndef PRODUCT #ifdef NIE - (aDbstream << "Insert: " ).WriteNumber( long( pHt ) )<< endl; - DumpHints( *this, aHtEnd ); + (aDbstream << "Insert: " ).WriteNumber( long( pHt ) ) << endl; + DumpHints( m_HintStarts, m_HintEnds ); #endif #endif } -void SwpHintsArr::DeleteAtPos( const USHORT nPos ) +void SwpHintsArray::DeleteAtPos( const USHORT nPos ) { - // Optimierung: nPos bezieht sich auf die Position im StartArray, also: - const SwTxtAttr *pHt = SwpHtStart::operator[]( nPos ); - SwpHtStart::Remove( nPos ); + // optimization: nPos is the position in the Starts array + const SwTxtAttr *pHt = m_HintStarts[ nPos ]; + m_HintStarts.Remove( nPos ); Resort(); USHORT nEndPos; - aHtEnd.Seek_Entry( pHt, &nEndPos ); - aHtEnd.Remove( nEndPos ); + m_HintEnds.Seek_Entry( pHt, &nEndPos ); + m_HintEnds.Remove( nEndPos ); #ifndef PRODUCT #ifdef NIE - (aDbstream << "DeleteAtPos: " ).WriteNumber( long( pHt ) )<< endl; - DumpHints( *this, aHtEnd ); + (aDbstream << "DeleteAtPos: " ).WriteNumber( long( pHt ) ) << endl; + DumpHints( m_HintStarts, m_HintEnds ); #endif #endif } @@ -277,7 +279,7 @@ void SwpHintsArr::DeleteAtPos( const USHORT nPos ) #ifndef PRODUCT /************************************************************************* - * SwpHintsArr::Check() + * SwpHintsArray::Check() *************************************************************************/ @@ -285,14 +287,15 @@ void SwpHintsArr::DeleteAtPos( const USHORT nPos ) if(!(cond)) \ { \ ASSERT(!this, text); \ - DumpHints(*(SwpHtStart*)this,aHtEnd); \ - return !((SwpHintsArr*)this)->Resort(); \ + DumpHints(m_HintStarts, m_HintEnds); \ + return !(const_cast<SwpHintsArray*>(this))->Resort(); \ } -BOOL SwpHintsArr::Check() const +bool SwpHintsArray::Check() const { // 1) gleiche Anzahl in beiden Arrays - CHECK_ERR( Count() == aHtEnd.Count(), "HintsCheck: wrong sizes" ); + CHECK_ERR( m_HintStarts.Count() == m_HintEnds.Count(), + "HintsCheck: wrong sizes" ); xub_StrLen nLastStart = 0; xub_StrLen nLastEnd = 0; @@ -304,7 +307,7 @@ BOOL SwpHintsArr::Check() const // --- Start-Kontrolle --- // 2a) gueltiger Pointer? vgl. DELETEFF - const SwTxtAttr *pHt = (*this)[i]; + const SwTxtAttr *pHt = m_HintStarts[i]; CHECK_ERR( 0xFF != *(unsigned char*)pHt, "HintsCheck: start ptr was deleted" ); // 3a) Stimmt die Start-Sortierung? @@ -321,7 +324,7 @@ BOOL SwpHintsArr::Check() const // --- End-Kontrolle --- // 2b) gueltiger Pointer? vgl. DELETEFF - const SwTxtAttr *pHtEnd = aHtEnd[i]; + const SwTxtAttr *pHtEnd = m_HintEnds[i]; CHECK_ERR( 0xFF != *(unsigned char*)pHtEnd, "HintsCheck: end ptr was deleted" ); // 3b) Stimmt die End-Sortierung? @@ -339,47 +342,48 @@ BOOL SwpHintsArr::Check() const // --- Ueberkreuzungen --- // 5) gleiche Pointer in beiden Arrays - if( !Seek_Entry( pHt, &nIdx ) ) + if( !m_HintStarts.Seek_Entry( pHt, &nIdx ) ) nIdx = STRING_LEN; CHECK_ERR( STRING_LEN != nIdx, "HintsCheck: no GetStartOf" ); // 6) gleiche Pointer in beiden Arrays - if( !aHtEnd.Seek_Entry( pHt, &nIdx ) ) + if( !m_HintEnds.Seek_Entry( pHt, &nIdx ) ) nIdx = STRING_LEN; CHECK_ERR( STRING_LEN != nIdx, "HintsCheck: no GetEndOf" ); // 7a) character attributes in array? USHORT nWhich = pHt->Which(); - CHECK_ERR( nWhich < RES_CHRATR_BEGIN || nWhich >= RES_CHRATR_END, - "HintsCheck: Character attribute in start array" ) + CHECK_ERR( !isCHRATR(nWhich), + "HintsCheck: Character attribute in start array" ); // 7b) character attributes in array? nWhich = pHtEnd->Which(); - CHECK_ERR( nWhich < RES_CHRATR_BEGIN || nWhich >= RES_CHRATR_END, - "HintsCheck: Character attribute in end array" ) + CHECK_ERR( !isCHRATR(nWhich), + "HintsCheck: Character attribute in end array" ); // 8) portion check #if OSL_DEBUG_LEVEL > 1 - const SwTxtAttr* pHtThis = (*this)[i]; - const SwTxtAttr* pHtLast = i > 0 ? (*this)[i-1] : 0; + const SwTxtAttr* pHtThis = m_HintStarts[i]; + const SwTxtAttr* pHtLast = i > 0 ? m_HintStarts[i-1] : 0; CHECK_ERR( 0 == i || ( RES_TXTATR_CHARFMT != pHtLast->Which() && RES_TXTATR_AUTOFMT != pHtLast->Which() ) || ( RES_TXTATR_CHARFMT != pHtThis->Which() && RES_TXTATR_AUTOFMT != pHtThis->Which() ) || ( *pHtThis->GetStart() >= *pHtLast->GetEnd() ) || ( *pHtThis->GetStart() == *pHtLast->GetStart() && *pHtThis->GetEnd() == *pHtLast->GetEnd() ) || ( *pHtThis->GetStart() == *pHtThis->GetEnd() ), - "HintsCheck: Portion inconsistency. This can be temporarily ok during undo operations" ) + "HintsCheck: Portion inconsistency. " + "This can be temporarily ok during undo operations" ); #endif } - return TRUE; + return true; } #endif /* PRODUCT */ /************************************************************************* - * SwpHintsArr::Resort() + * SwpHintsArray::Resort() *************************************************************************/ // Resort() wird vor jedem Insert und Delete gerufen. @@ -387,61 +391,61 @@ BOOL SwpHintsArr::Check() const // ndtxt.cxx angepasst. Leider erfolgt noch keine Neusortierung // auf gleichen Positionen. -BOOL SwpHintsArr::Resort() +bool SwpHintsArray::Resort() { - BOOL bResort = FALSE; + bool bResort = false; const SwTxtAttr *pLast = 0; USHORT i; - for( i = 0; i < SwpHtStart::Count(); ++i ) + for ( i = 0; i < m_HintStarts.Count(); ++i ) { - const SwTxtAttr *pHt = (*this)[i]; + const SwTxtAttr *pHt = m_HintStarts[i]; if( pLast && !lcl_IsLessStart( *pLast, *pHt ) ) { #ifdef NIE #ifndef PRODUCT // ASSERT( bResort, "!Resort/Start: correcting hints-array" ); aDbstream << "Resort: Starts" << endl; - DumpHints( *this, aHtEnd ); + DumpHints( m_HintStarts, m_HintEnds ); #endif #endif - SwpHtStart::Remove( i ); - SwpHtStart::Insert( pHt ); - pHt = (*this)[i]; + m_HintStarts.Remove( i ); + m_HintStarts.Insert( pHt ); + pHt = m_HintStarts[i]; if ( pHt != pLast ) --i; - bResort = TRUE; + bResort = true; } pLast = pHt; } pLast = 0; - for( i = 0; i < aHtEnd.Count(); ++i ) + for ( i = 0; i < m_HintEnds.Count(); ++i ) { - const SwTxtAttr *pHt = aHtEnd[i]; + const SwTxtAttr *pHt = m_HintEnds[i]; if( pLast && !lcl_IsLessEnd( *pLast, *pHt ) ) { #ifdef NIE #ifndef PRODUCT aDbstream << "Resort: Ends" << endl; - DumpHints( *this, aHtEnd ); + DumpHints( m_HintStarts, m_HintEnds ); #endif #endif - aHtEnd.Remove( i ); - aHtEnd.Insert( pHt ); - pHt = aHtEnd[i]; // normalerweise == pLast + m_HintEnds.Remove( i ); + m_HintEnds.Insert( pHt ); + pHt = m_HintEnds[i]; // normalerweise == pLast // Wenn die Unordnung etwas groesser ist (24200), // muessen wir Position i erneut vergleichen. if ( pLast != pHt ) --i; - bResort = TRUE; + bResort = true; } pLast = pHt; } #ifndef PRODUCT #ifdef NIE aDbstream << "Resorted:" << endl; - DumpHints( *this, aHtEnd ); + DumpHints( m_HintStarts, m_HintEnds ); #endif #endif return bResort; diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index b9ff68e3d422..99cebfd10102 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -33,9 +33,6 @@ #include <hintids.hxx> #include <hints.hxx> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ -#include <com/sun/star/i18n/ScriptType.hdl> -#endif #include <svx/fontitem.hxx> #include <svx/brkitem.hxx> #include <svx/escpitem.hxx> @@ -95,9 +92,7 @@ #include <numrule.hxx> //--> #outlinelevel added by zhaojianwei -#ifndef _SFXINTITEM_HXX #include <svtools/intitem.hxx> -#endif //<--end #include <swtable.hxx> #include <docsh.hxx> @@ -235,10 +230,10 @@ SwTxtNode::SwTxtNode( const SwNodeIndex &rWhere, SwTxtFmtColl *pTxtColl, const SfxItemSet* pAutoAttr ) : SwCntntNode( rWhere, ND_TEXTNODE, pTxtColl ), - pSwpHints( 0 ), + m_pSwpHints( 0 ), mpNodeNum( 0 ), - bNotifiable( false ), - bLastOutlineState( FALSE ), + m_bLastOutlineState( false ), + m_bNotifiable( false ), //nOutlineLevel( pTxtColl->GetOutlineLevel() )//#outline level, removed by zhaojianwei. // --> OD 2008-11-19 #i70748# mbEmptyListStyleSetDueToSetOutlineLevelAttr( false ), @@ -263,26 +258,26 @@ SwTxtNode::SwTxtNode( const SwNodeIndex &rWhere, // <-- GetNodes().UpdateOutlineNode(*this); - bNotifiable = true; + m_bNotifiable = true; - bContainsHiddenChars = bHiddenCharsHidePara = FALSE; - bRecalcHiddenCharFlags = TRUE; + m_bContainsHiddenChars = m_bHiddenCharsHidePara = false; + m_bRecalcHiddenCharFlags = true; } SwTxtNode::~SwTxtNode() { // delete loescht nur die Pointer, nicht die Arrayelemente! - if( pSwpHints ) + if ( m_pSwpHints ) { // damit Attribute die ihren Inhalt entfernen nicht doppelt // geloescht werden. - SwpHints* pTmpHints = pSwpHints; - pSwpHints = 0; + SwpHints* pTmpHints = m_pSwpHints; + m_pSwpHints = 0; for( USHORT j = pTmpHints->Count(); j; ) // erst muss das Attribut aus dem Array entfernt werden, // denn sonst wuerde es sich selbst loeschen (Felder) !!!! - DestroyAttr( pTmpHints->GetHt( --j ) ); + DestroyAttr( pTmpHints->GetTextHint( --j ) ); delete pTmpHints; } @@ -308,7 +303,7 @@ SwCntntFrm *SwTxtNode::MakeFrm() xub_StrLen SwTxtNode::Len() const { - return aText.Len(); + return m_Text.Len(); } /*--------------------------------------------------------------------------- @@ -330,7 +325,8 @@ void lcl_ChangeFtnRef( SwTxtNode &rNode ) SwFtnFrm* pFirstFtnOfNode = 0; for( USHORT j = pSwpHints->Count(); j; ) { - if( RES_TXTATR_FTN == (pHt = pSwpHints->GetHt(--j))->Which() ) + pHt = pSwpHints->GetTextHint(--j); + if (RES_TXTATR_FTN == pHt->Which()) { if( !pFrm ) { @@ -395,9 +391,21 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) { // lege den Node "vor" mir an xub_StrLen nSplitPos = rPos.nContent.GetIndex(); - xub_StrLen nTxtLen = aText.Len(); + xub_StrLen nTxtLen = m_Text.Len(); SwTxtNode* pNode = _MakeNewTxtNode( rPos.nNode, FALSE, nSplitPos==nTxtLen ); + // the first paragraph gets the XmlId, + // _except_ if it is empty and the second is not empty + if (nSplitPos != 0) { + pNode->RegisterAsCopyOf(*this, true); + if (nSplitPos == nTxtLen) + { + this->RemoveMetadataReference(); + // NB: SwUndoSplitNode will call pNode->JoinNext, + // which is sufficient even in this case! + } + } + // --> OD 2008-03-27 #refactorlists# // // --> OD 2007-07-09 #i77372# // // reset numbering attribute at current node, only if it is numbered. @@ -417,7 +425,7 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) } // <-- - if( GetDepends() && aText.Len() && (nTxtLen / 2) < nSplitPos ) + if ( GetDepends() && m_Text.Len() && (nTxtLen / 2) < nSplitPos ) { // JP 25.04.95: Optimierung fuer SplitNode: // Wird am Ende vom Node gesplittet, dann verschiebe die @@ -428,11 +436,9 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) // werden FlyFrames mit verschoben, so muessen diese nicht ihre // Frames zerstoeren. Im SwTxtFly::SetAnchor wird es abgefragt! - if( pSwpHints ) + if ( HasHints() ) { - if( !pNode->pSwpHints ) - pNode->pSwpHints = new SwpHints; - pNode->pSwpHints->bInSplitNode = TRUE; + pNode->GetOrCreateSwpHints().SetInSplitNode(true); } //Ersten Teil des Inhalts in den neuen Node uebertragen und @@ -455,35 +461,41 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) pNode->SetSmartTags( GetSmartTags()->SplitList( nSplitPos ) ); SetSmartTagDirty( true ); - if( pNode->pSwpHints ) + if ( pNode->HasHints() ) { - if ( pNode->pSwpHints->CanBeDeleted() ) + if ( pNode->m_pSwpHints->CanBeDeleted() ) { - delete pNode->pSwpHints; - pNode->pSwpHints = 0; + delete pNode->m_pSwpHints; + pNode->m_pSwpHints = 0; } else - pNode->pSwpHints->bInSplitNode = FALSE; + { + pNode->m_pSwpHints->SetInSplitNode(false); + } // alle zeichengebundenen Rahmen, die im neuen Absatz laden // muessen aus den alten Frame entfernt werden: // JP 01.10.96: alle leeren und nicht zu expandierenden // Attribute loeschen - if( pSwpHints ) + if ( HasHints() ) { SwTxtAttr* pHt; xub_StrLen* pEnd; - for( USHORT j = pSwpHints->Count(); j; ) - if( RES_TXTATR_FLYCNT == - ( pHt = pSwpHints->GetHt( --j ) )->Which() ) + for ( USHORT j = m_pSwpHints->Count(); j; ) + { + pHt = m_pSwpHints->GetTextHint( --j ); + if ( RES_TXTATR_FLYCNT == pHt ->Which() ) + { pHt->GetFlyCnt().GetFrmFmt()->DelFrms(); + } else if( pHt->DontExpand() && 0 != ( pEnd = pHt->GetEnd() ) && *pHt->GetStart() == *pEnd ) { - // loeschen! - pSwpHints->DeleteAtPos( j ); + // delete it! + m_pSwpHints->DeleteAtPos( j ); DestroyAttr( pHt ); } + } } } @@ -531,8 +543,10 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) pNode->SwModify::Modify( 0, &aHint ); } } - if( pSwpHints ) + if ( HasHints() ) + { MoveTxtAttr_To_AttrSet(); + } pNode->MakeFrms( *this ); // neue Frames anlegen. lcl_ChangeFtnRef( *this ); } @@ -558,18 +572,21 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) // JP 01.10.96: alle leeren und nicht zu expandierenden // Attribute loeschen - if( pSwpHints ) + if ( HasHints() ) { SwTxtAttr* pHt; xub_StrLen* pEnd; - for( USHORT j = pSwpHints->Count(); j; ) - if( ( pHt = pSwpHints->GetHt( --j ) )->DontExpand() && - 0 != ( pEnd = pHt->GetEnd() ) && *pHt->GetStart() == *pEnd ) + for ( USHORT j = m_pSwpHints->Count(); j; ) + { + pHt = m_pSwpHints->GetTextHint( --j ); + pEnd = pHt->GetEnd(); + if ( pHt->DontExpand() && pEnd && (*pHt->GetStart() == *pEnd) ) { - // loeschen! - pSwpHints->DeleteAtPos( j ); + // delete it! + m_pSwpHints->DeleteAtPos( j ); DestroyAttr( pHt ); } + } MoveTxtAttr_To_AttrSet(); } @@ -612,10 +629,10 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) void SwTxtNode::MoveTxtAttr_To_AttrSet() { - ASSERT( pSwpHints, "MoveTxtAttr_To_AttrSet without SwpHints?" ); - for( USHORT i = 0; pSwpHints && i < pSwpHints->Count(); ++i ) + ASSERT( m_pSwpHints, "MoveTxtAttr_To_AttrSet without SwpHints?" ); + for ( USHORT i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { - SwTxtAttr *pHt = pSwpHints->GetHt(i); + SwTxtAttr *pHt = m_pSwpHints->GetTextHint(i); if( *pHt->GetStart() ) break; @@ -625,13 +642,13 @@ void SwTxtNode::MoveTxtAttr_To_AttrSet() if( !pHtEndIdx ) continue; - if( *pHtEndIdx < aText.Len() || pHt->IsCharFmtAttr() ) + if ( *pHtEndIdx < m_Text.Len() || pHt->IsCharFmtAttr() ) break; if( !pHt->IsDontMoveAttr() && SetAttr( pHt->GetAttr() ) ) { - pSwpHints->DeleteAtPos(i); + m_pSwpHints->DeleteAtPos(i); DestroyAttr( pHt ); --i; } @@ -649,7 +666,10 @@ SwCntntNode *SwTxtNode::JoinNext() SvULongs aBkmkArr( 15, 15 ); _SaveCntntIdx( pDoc, aIdx.GetIndex(), USHRT_MAX, aBkmkArr, SAVEFLY ); SwTxtNode *pTxtNode = aIdx.GetNode().GetTxtNode(); - xub_StrLen nOldLen = aText.Len(); + xub_StrLen nOldLen = m_Text.Len(); + + // METADATA: merge + this->JoinMetadatable(*pTxtNode, !this->Len(), !pTxtNode->Len()); SwWrongList *pList = GetWrong(); if( pList ) @@ -857,7 +877,7 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, SetAutoCompleteWordDirty( TRUE ); TmpHints* pCollector = NULL; - if( pSwpHints ) + if ( HasHints() ) { xub_StrLen nPos = aPos.GetIndex(); xub_StrLen* pIdx; @@ -865,10 +885,10 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, if( bNegativ ) { xub_StrLen nMax = nPos + nLen; - for( USHORT n = 0; n < pSwpHints->Count(); ++n ) + for ( USHORT n = 0; n < m_pSwpHints->Count(); ++n ) { BOOL bSttBefore = FALSE; - pHt = pSwpHints->GetHt(n); + pHt = m_pSwpHints->GetTextHint(n); pIdx = pHt->GetStart(); if( *pIdx >= nPos ) { @@ -898,7 +918,7 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, } } - pSwpHints->MergePortions( *this ); + m_pSwpHints->MergePortions( *this ); } else { @@ -913,17 +933,20 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, BOOL aDontExp[ coArrSz ]; memset( &aDontExp, 0, coArrSz * sizeof(BOOL) ); - for( USHORT n = 0; n < pSwpHints->Count(); ++n ) + for ( USHORT n = 0; n < m_pSwpHints->Count(); ++n ) { - pHt = pSwpHints->GetHt(n); + pHt = m_pSwpHints->GetTextHint(n); pIdx = pHt->GetStart(); - if( *pIdx >= nPos ) + pEnd = pHt->GetEnd(); + if ( *pIdx >= nPos ) { *pIdx = *pIdx + nLen; - if( 0 != ( pEnd = pHt->GetEnd() ) ) + if ( pEnd ) + { *pEnd = *pEnd + nLen; + } } - else if( 0 != ( pEnd = pHt->GetEnd() ) && *pEnd >= nPos ) + else if ( pEnd && *pEnd >= nPos ) { if( *pEnd > nPos || IsIgnoreDontExpand() ) { @@ -933,16 +956,19 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, { USHORT nWhPos, nWhich = pHt->Which(); - if( RES_CHRATR_BEGIN <= nWhich && - nWhich < RES_TXTATR_WITHEND_END ) - nWhPos = static_cast<USHORT>(nWhich - RES_CHRATR_BEGIN); - else if( RES_UNKNOWNATR_BEGIN <= nWhich && - nWhich < RES_UNKNOWNATR_END ) + if (isCHRATR(nWhich) || isTXTATR_WITHEND(nWhich)) + { + nWhPos = static_cast<USHORT>(nWhich - + RES_CHRATR_BEGIN); + } + else if (isUNKNOWNATR(nWhich)) + { nWhPos = static_cast<USHORT>( - nWhich - - static_cast<USHORT>(RES_UNKNOWNATR_BEGIN) + - static_cast<USHORT>(RES_TXTATR_WITHEND_END) - - static_cast<USHORT>(RES_CHRATR_BEGIN) ); + nWhich - + static_cast<USHORT>(RES_UNKNOWNATR_BEGIN) + + static_cast<USHORT>(RES_TXTATR_WITHEND_END) - + static_cast<USHORT>(RES_CHRATR_BEGIN) ); + } else continue; @@ -991,7 +1017,9 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, } } if( bResort ) - ((SwpHintsArr*)pSwpHints)->Resort(); + { + m_pSwpHints->Resort(); + } } } @@ -1055,7 +1083,9 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, { USHORT nCount = pCollector->Count(); for( USHORT i = 0; i < nCount; ++i ) - pSwpHints->Insert( (*pCollector)[ i ], *this, FALSE ); + { + m_pSwpHints->Insert( (*pCollector)[ i ], *this, FALSE ); + } delete pCollector; } @@ -1112,21 +1142,23 @@ void SwTxtNode::_ChgTxtCollUpdateNum( const SwTxtFmtColl *pOldColl, // Wenn man sich genau am Ende einer Text- bzw. INetvorlage befindet, // bekommt diese das DontExpand-Flag verpasst -BOOL SwTxtNode::DontExpandFmt( const SwIndex& rIdx, BOOL bFlag, +BOOL SwTxtNode::DontExpandFmt( const SwIndex& rIdx, bool bFlag, BOOL bFmtToTxtAttributes ) { const xub_StrLen nIdx = rIdx.GetIndex(); - if( bFmtToTxtAttributes && nIdx == aText.Len() ) + if ( bFmtToTxtAttributes && nIdx == m_Text.Len() ) + { FmtToTxtAttr( this ); + } BOOL bRet = FALSE; - if( pSwpHints ) + if ( HasHints() ) { - const USHORT nEndCnt = pSwpHints->GetEndCount(); + const USHORT nEndCnt = m_pSwpHints->GetEndCount(); USHORT nPos = nEndCnt; while( nPos ) { - SwTxtAttr *pTmp = pSwpHints->GetEnd( --nPos ); + SwTxtAttr *pTmp = m_pSwpHints->GetEnd( --nPos ); xub_StrLen *pEnd = pTmp->GetEnd(); if( !pEnd || *pEnd > nIdx ) continue; @@ -1136,7 +1168,7 @@ BOOL SwTxtNode::DontExpandFmt( const SwIndex& rIdx, BOOL bFlag, && *pEnd > *pTmp->GetStart()) { bRet = TRUE; - pSwpHints->NoteInHistory( pTmp ); + m_pSwpHints->NoteInHistory( pTmp ); pTmp->SetDontExpand( bFlag ); } } @@ -1158,12 +1190,13 @@ SwTxtAttr* SwTxtNode::GetTxtAttr( const SwIndex& rIdx, USHORT nWhichHt, const SwTxtAttr* pHt = 0; const xub_StrLen *pEndIdx = 0; const xub_StrLen nIdx = rIdx.GetIndex(); - const USHORT nSize = pSwpHints ? pSwpHints->Count() : 0; + const USHORT nSize = m_pSwpHints ? m_pSwpHints->Count() : 0; for( USHORT i = 0; i < nSize; ++i ) { // ist der Attribut-Anfang schon groesser als der Idx ? - if( nIdx < *((pHt = (*pSwpHints)[i])->GetStart()) ) + pHt = (*m_pSwpHints)[i]; + if ( nIdx < *(pHt->GetStart()) ) break; // beenden, kein gueltiges Attribut // ist es das gewuenschte Attribut ? @@ -1323,7 +1356,7 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, const xub_StrLen nOldPos ) { - if( pSwpHints ) // keine Attribute, keine Kekse + if ( HasHints() ) // keine Attribute, keine Kekse { const xub_StrLen *pEndIdx = 0; const SwTxtAttr *pHt = 0; @@ -1335,9 +1368,9 @@ void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, if( pOtherDoc == GetDoc() ) pOtherDoc = 0; - for( USHORT i = 0; i < pSwpHints->Count(); i++ ) + for ( USHORT i = 0; i < m_pSwpHints->Count(); i++ ) { - pHt = (*pSwpHints)[i]; + pHt = (*m_pSwpHints)[i]; if( nTxtStartIdx < ( nAttrStartIdx = *pHt->GetStart() ) ) break; // ueber das Textende, da nLen == 0 @@ -1385,7 +1418,7 @@ void SwTxtNode::Copy( SwTxtNode *pDest, xub_StrLen nLen, const bool bForceCopyOfAllAttrs ) { - SwIndex aIdx( pDest, pDest->aText.Len() ); + SwIndex aIdx( pDest, pDest->m_Text.Len() ); Copy( pDest, aIdx, rStart, nLen, bForceCopyOfAllAttrs ); } // <-- @@ -1436,16 +1469,16 @@ void SwTxtNode::Copy( SwTxtNode *pDest, } // 1. Text kopieren - xub_StrLen i = pDest->aText.Len() - nDestStart; + xub_StrLen i = pDest->m_Text.Len() - nDestStart; //JP 15.02.96: Bug 25537 - Attributbehandlung am Ende fehlt! Darum // ueber die InsertMethode den Text einfuegen und nicht // selbst direkt - pDest->Insert( aText.Copy( nTxtStartIdx, nLen ), rDestStart, - INS_EMPTYEXPAND ); + pDest->Insert( m_Text.Copy( nTxtStartIdx, nLen ), rDestStart, + INS_EMPTYEXPAND ); // um reale Groesse Updaten ! - nLen = pDest->aText.Len() - nDestStart - i; - if( !nLen ) // String nicht gewachsen ?? + nLen = pDest->m_Text.Len() - nDestStart - i; + if ( !nLen ) // string not longer? return; i = 0; @@ -1494,7 +1527,8 @@ void SwTxtNode::Copy( SwTxtNode *pDest, // 2. Attribute kopieren // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu kopierenden Bereich liegt - USHORT nWhich, nSize = pSwpHints ? pSwpHints->Count() : 0; + USHORT nWhich; + USHORT nSize = m_pSwpHints ? m_pSwpHints->Count() : 0; xub_StrLen nAttrStt, nAttrEnd; // wird in sich selbst kopiert, dann kann beim Einfuegen ein @@ -1506,10 +1540,10 @@ void SwTxtNode::Copy( SwTxtNode *pDest, SwpHts aRefMrkArr; //Achtung: kann ungueltig sein!! - while( ( i < nSize ) && - ((nAttrStartIdx = *(*pSwpHints)[i]->GetStart()) < nEnd) ) + while ( ( i < nSize ) && + ((nAttrStartIdx = *(*m_pSwpHints)[i]->GetStart()) < nEnd) ) { - pHt = (*pSwpHints)[i]; + pHt = (*m_pSwpHints)[i]; pNewHt = 0; pEndIdx = pHt->GetEnd(); nWhich = pHt->Which(); @@ -1645,14 +1679,14 @@ void SwTxtNode::Copy( SwTxtNode *pDest, SwTxtNode& SwTxtNode::Insert( const XubString &rStr, const SwIndex &rIdx, const USHORT nMode ) { - ASSERT( rIdx <= aText.Len(), "Array ueberindiziert." ); - ASSERT( (ULONG)aText.Len() + (ULONG)rStr.Len() <= STRING_LEN, - "STRING_LEN ueberschritten." ); + ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::Insert: invalid index." ); + ASSERT( (ULONG)m_Text.Len() + (ULONG)rStr.Len() <= STRING_LEN, + "SwTxtNode::Insert: node text with insertion > STRING_LEN." ); xub_StrLen aPos = rIdx.GetIndex(); - xub_StrLen nLen = aText.Len() - aPos; - aText.Insert( rStr, aPos ); - nLen = aText.Len() - aPos - nLen; + xub_StrLen nLen = m_Text.Len() - aPos; + m_Text.Insert( rStr, aPos ); + nLen = m_Text.Len() - aPos - nLen; if( !nLen ) return *this; Update( rIdx, nLen ); // um reale Groesse Updaten ! @@ -1663,12 +1697,12 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, USHORT i; - if( pSwpHints ) + if ( HasHints() ) { - for( i = 0; i < pSwpHints->Count() && - rIdx >= *(*pSwpHints)[i]->GetStart(); ++i ) + for ( i = 0; i < m_pSwpHints->Count() && + rIdx >= *(*m_pSwpHints)[i]->GetStart(); ++i ) { - SwTxtAttr *pHt = pSwpHints->GetHt( i ); + SwTxtAttr *pHt = m_pSwpHints->GetTextHint( i ); xub_StrLen* pEndIdx = pHt->GetEnd(); if( !pEndIdx ) continue; @@ -1681,7 +1715,7 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, if( rIdx == *pHt->GetStart() ) *pHt->GetStart() = *pHt->GetStart() - nLen; *pEndIdx = *pEndIdx - nLen; - pSwpHints->DeleteAtPos(i); + m_pSwpHints->DeleteAtPos(i); Insert( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); } // leere Hints an rIdx.GetIndex ? @@ -1689,11 +1723,13 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, *pEndIdx == *pHt->GetStart() ) { *pHt->GetStart() = *pHt->GetStart() - nLen; - const USHORT nAktLen = pSwpHints->Count(); - pSwpHints->DeleteAtPos(i); + const USHORT nAktLen = m_pSwpHints->Count(); + m_pSwpHints->DeleteAtPos(i); Insert( pHt/* AUTOSTYLES:, nsSetAttrMode::SETATTR_NOHINTADJUST*/ ); - if( nAktLen > pSwpHints->Count() && i ) + if ( nAktLen > m_pSwpHints->Count() && i ) + { --i; + } continue; } else @@ -1706,13 +1742,12 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, !pHt->IsDontExpandStartAttr() ) { // Kein Feld, am Absatzanfang, HintExpand - pSwpHints->DeleteAtPos(i); + m_pSwpHints->DeleteAtPos(i); *pHt->GetStart() = *pHt->GetStart() - nLen; Insert( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); } } - if ( pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); } if ( GetDepends() ) @@ -1778,7 +1813,7 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, xub_StrLen nTxtStartIdx = rStart.GetIndex(); xub_StrLen nDestStart = rDestStart.GetIndex(); // alte Pos merken - xub_StrLen nInitSize = pDest->aText.Len(); + xub_StrLen nInitSize = pDest->m_Text.Len(); xub_StrLen *pEndIdx = 0; xub_StrLen nAttrStartIdx = 0; @@ -1788,8 +1823,8 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, // wird in sich selbst verschoben, muss es gesondert behandelt werden !! if( pDest == this ) { - aText.Insert( aText, nTxtStartIdx, nLen, nDestStart ); - aText.Erase( nTxtStartIdx + (nDestStart<nTxtStartIdx ? nLen : 0), nLen ); + m_Text.Insert( m_Text, nTxtStartIdx, nLen, nDestStart ); + m_Text.Erase( nTxtStartIdx + (nDestStart<nTxtStartIdx ? nLen : 0), nLen ); xub_StrLen nEnd = rStart.GetIndex() + nLen; USHORT n; @@ -1804,8 +1839,8 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu verschiebenden Bereich liegt USHORT nAttrCnt = 0, nWhich; - while( pSwpHints && nAttrCnt < pSwpHints->Count() && - (nAttrStartIdx = *(pHt = pSwpHints->GetHt(nAttrCnt))-> + while ( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() && + (nAttrStartIdx = *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))-> GetStart()) < nEnd ) { pNewHt = 0; @@ -1831,7 +1866,7 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, if( !pEndIdx || *pEndIdx < nEnd ) { // Attribut verschieben - pSwpHints->Delete( pHt ); + m_pSwpHints->Delete( pHt ); // die Start/End Indicies neu setzen *pHt->GetStart() = nAttrStartIdx - nTxtStartIdx; if( pEndIdx ) @@ -1865,16 +1900,18 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, #ifdef CUTNOEXPAND else // wird am Ende eingefuegt, nur die Attribut-Indizies verschieben - if( 0 < nLen && 0 < nInitSize && pSwpHints ) + if ( 0 < nLen && 0 < nInitSize && m_pSwpHints ) { - // siehe nach, ob an der Einfuegeposition das Ende eines - // Attributes stand. Ist es kein Feld, muss es expandiert werden !!! - for( n = 0; n < pSwpHints->Count(); n++ ) + // check if there was the end of an attribute at the insertion + // position: if it is not a field, it must be expanded + for ( n = 0; n < m_pSwpHints->Count(); n++ ) { - pHt = pSwpHints->GetHt(n); - if( 0 != ( pEndIdx = pHt->GetEnd() ) && - *pEndIdx == nInitSize ) + pHt = m_pSwpHints->GetTextHint(n); + pEndIdx = pHt->GetEnd(); + if ( pEndIdx && (*pEndIdx == nInitSize) ) + { *pEndIdx = *pEndIdx + nLen; + } } } #endif @@ -1902,9 +1939,9 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, else { xub_StrLen i = nInitSize - nDestStart; - pDest->aText.Insert( aText, nTxtStartIdx, nLen, nDestStart ); - aText.Erase( nTxtStartIdx, nLen ); - nLen = pDest->aText.Len() - nDestStart - i; // um reale Groesse Updaten ! + pDest->m_Text.Insert( m_Text, nTxtStartIdx, nLen, nDestStart ); + m_Text.Erase( nTxtStartIdx, nLen ); + nLen = pDest->m_Text.Len() - nDestStart - i; // update w/ current size! if( !nLen ) // String nicht gewachsen ?? return; @@ -1916,16 +1953,18 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, #ifdef CUTNOEXPAND else // wird am Ende eingefuegt, nur die Attribut-Indizies verschieben - if( 0 < nLen && 0 < nInitSize && pDest->pSwpHints ) + if ( 0 < nLen && 0 < nInitSize && pDest->m_pSwpHints ) { - // siehe nach, ob an der Einfuegeposition das Ende eines - // Attributes stand. Ist es kein Feld, muss es expandiert werden !!! - for( USHORT n = 0; n < pDest->pSwpHints->Count(); n++ ) + // check if there was the end of an attribute at the insertion + // position: if it is not a field, it must be expanded + for ( USHORT n = 0; n < pDest->m_pSwpHints->Count(); n++ ) { - pHt = pDest->pSwpHints->GetHt(n); - if( 0 != ( pEndIdx = pHt->GetEnd() ) && - *pEndIdx == nInitSize ) + pHt = pDest->m_pSwpHints->GetTextHint(n); + pEndIdx = pHt->GetEnd(); + if ( pEndIdx && (*pEndIdx == nInitSize) ) + { *pEndIdx = *pEndIdx + nLen; + } } } #endif @@ -1962,8 +2001,8 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu verschiebenden Bereich liegt USHORT nAttrCnt = 0, nWhich; - while( pSwpHints && nAttrCnt < pSwpHints->Count() && - ( (nAttrStartIdx = *(pHt = pSwpHints->GetHt(nAttrCnt))-> + while ( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() && + ( (nAttrStartIdx = *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))-> GetStart()) < nEnd ) ) { pNewHt = 0; @@ -1996,7 +2035,7 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, if ( GetDoc()->GetDocShell() ) GetDoc()->GetDocShell()->Broadcast( SfxSimpleHint(SFX_HINT_USER04)); // Attribut verschieben - pSwpHints->Delete( pHt ); + m_pSwpHints->Delete( pHt ); // die Start/End Indicies neu setzen *pHt->GetStart() = nDestStart + (nAttrStartIdx - nTxtStartIdx); @@ -2032,17 +2071,18 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, // eine hoehere Praezedenz. Also herausholen und das Array updaten. // Die dabei entstehenden leeren Hints werden von den gesicherten // "uebergeplaettet". (Bug: 6977) - if( pSwpHints && nAttrCnt < pSwpHints->Count() ) + if( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() ) { SwpHts aArr( 5 ); - for( ; nAttrCnt < pSwpHints->Count() && - nEnd == *(pHt = pSwpHints->GetHt(nAttrCnt))->GetStart(); + for ( ; nAttrCnt < m_pSwpHints->Count() && + nEnd == *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))->GetStart(); ++nAttrCnt ) { - if( 0 != ( pEndIdx = pHt->GetEnd() ) && *pEndIdx == nEnd ) + pEndIdx = pHt->GetEnd(); + if ( pEndIdx && *pEndIdx == nEnd ) { aArr.C40_INSERT( SwTxtAttr, pHt, aArr.Count() ); - pSwpHints->Delete( pHt ); + m_pSwpHints->Delete( pHt ); --nAttrCnt; } } @@ -2061,8 +2101,7 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, CHECK_SWPHINTS(this); } - if( pSwpHints && pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); // Frames benachrichtigen; SwInsTxt aInsHint( nDestStart, nLen ); @@ -2075,22 +2114,21 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, SwTxtNode& SwTxtNode::Erase(const SwIndex &rIdx, xub_StrLen nCount, const USHORT nMode ) { - ASSERT( rIdx <= aText.Len(), "Array ueberindiziert." ); + ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::Erase: invalid index." ); const xub_StrLen nCnt = STRING_LEN == nCount - ? aText.Len() - rIdx.GetIndex() : nCount; - aText.Erase( rIdx.GetIndex(), nCnt ); + ? m_Text.Len() - rIdx.GetIndex() : nCount; + m_Text.Erase( rIdx.GetIndex(), nCnt ); /* GCAttr(); alle leeren weggwerfen ist zu brutal. * Es duerfen nur die wegggeworfen werden, * die im Bereich liegen und nicht am Ende des Bereiches liegen */ - // Abfrage auf pSwpHints weil TextFelder und FlyFrames Text loeschen - // (Rekursion)!! - for( USHORT i = 0; pSwpHints && i < pSwpHints->Count(); ++i ) + // check m_pSwpHints because fields and FlyFrames delete text (recursion!) + for ( USHORT i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { - SwTxtAttr *pHt = pSwpHints->GetHt(i); + SwTxtAttr *pHt = m_pSwpHints->GetTextHint(i); const xub_StrLen nHtStt = *pHt->GetStart(); @@ -2109,11 +2147,10 @@ SwTxtNode& SwTxtNode::Erase(const SwIndex &rIdx, xub_StrLen nCount, if( !pHtEndIdx ) { - // TxtHints ohne EndIndex werden natuerlich auch geloescht: - if( RES_TXTATR_BEGIN <= nWhich && RES_TXTATR_END > nWhich && - nHtStt >= rIdx.GetIndex() && nHtStt < nEndIdx ) + if (isTXTATR(nWhich) && + (nHtStt >= rIdx.GetIndex()) && (nHtStt < nEndIdx)) { - pSwpHints->DeleteAtPos(i); + m_pSwpHints->DeleteAtPos(i); // Damit im Dtor der TxtAttr ohne End die CH_TXTATR nicht // geloescht werden... *(pHt->GetStart()) = USHRT_MAX; @@ -2140,13 +2177,12 @@ SwTxtNode& SwTxtNode::Erase(const SwIndex &rIdx, xub_StrLen nCount, ) continue; - pSwpHints->DeleteAtPos(i); + m_pSwpHints->DeleteAtPos(i); DestroyAttr( pHt ); --i; } - if ( pSwpHints && pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); Update( rIdx, nCnt, TRUE ); @@ -2182,20 +2218,20 @@ SwTxtNode& SwTxtNode::Erase(const SwIndex &rIdx, xub_StrLen nCount, void SwTxtNode::GCAttr() { - if ( !pSwpHints ) + if ( !HasHints() ) return; const SwTxtAttr *pHt = 0; const xub_StrLen *pEndIdx = 0; BOOL bChanged = FALSE; - USHORT nMin = aText.Len(), + USHORT nMin = m_Text.Len(), nMax = 0; BOOL bAll = nMin != 0; // Bei leeren Absaetzen werden nur die // INet-Formate entfernt. - for ( USHORT i = 0; pSwpHints && i < pSwpHints->Count(); ++i ) + for ( USHORT i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { - pHt = (*pSwpHints)[i]; + pHt = (*m_pSwpHints)[i]; // wenn Ende und Start gleich sind --> loeschen pEndIdx = pHt->GetEnd(); @@ -2205,14 +2241,13 @@ void SwTxtNode::GCAttr() bChanged = TRUE; nMin = Min( nMin, *pHt->GetStart() ); nMax = Max( nMax, *pHt->GetEnd() ); - DestroyAttr( pSwpHints->Cut(i) ); + DestroyAttr( m_pSwpHints->Cut(i) ); --i; } else ((SwTxtAttr*)pHt)->SetDontExpand( FALSE ); } - if ( pSwpHints && pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); if(bChanged) { @@ -2584,11 +2619,11 @@ SwCntntNode* SwTxtNode::AppendNode( const SwPosition & rPos ) SwTxtAttr *SwTxtNode::GetTxtAttr( const xub_StrLen nIdx, const USHORT nWhichHt ) const { - if( pSwpHints ) + if ( HasHints() ) { - for( USHORT i = 0; i < pSwpHints->Count(); ++i ) + for ( USHORT i = 0; i < m_pSwpHints->Count(); ++i ) { - SwTxtAttr *pPos = pSwpHints->GetHt(i); + SwTxtAttr *pPos = m_pSwpHints->GetTextHint(i); const xub_StrLen nStartPos = *pPos->GetStart(); if( nIdx < nStartPos ) return 0; @@ -2937,12 +2972,12 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, nLen = aDestIdx.GetIndex() - nDestStt; // alle FontAttribute mit CHARSET Symbol in dem Bereich setzen - if( pSwpHints ) + if ( HasHints() ) { xub_StrLen nInsPos = nDestStt - nIdx; - for( USHORT i = 0; i < pSwpHints->Count(); i++ ) + for ( USHORT i = 0; i < m_pSwpHints->Count(); i++ ) { - const SwTxtAttr* pHt = (*pSwpHints)[i]; + const SwTxtAttr* pHt = (*m_pSwpHints)[i]; xub_StrLen nAttrStartIdx; USHORT nWhich = pHt->Which(); if( nIdx + nLen <= ( nAttrStartIdx = *pHt->GetStart() ) ) @@ -2982,7 +3017,7 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, break; case RES_TXTATR_HARDBLANK: - rDestNd.aText.SetChar( nInsPos + nAttrStartIdx, + rDestNd.m_Text.SetChar( nInsPos + nAttrStartIdx, ((SwTxtHardBlank*)pHt)->GetChar() ); break; @@ -3059,12 +3094,12 @@ const ModelToViewHelper::ConversionMap* rRetText = rNodeText; ModelToViewHelper::ConversionMap* pConversionMap = 0; - SwpHints* pSwpHints2 = const_cast<SwTxtNode*>(this)->GetpSwpHints(); + const SwpHints* pSwpHints2 = GetpSwpHints(); xub_StrLen nPos = 0; for ( USHORT i = 0; pSwpHints2 && i < pSwpHints2->Count(); ++i ) { - const SwTxtAttr* pAttr = pSwpHints2->GetHt(i); + const SwTxtAttr* pAttr = (*pSwpHints2)[i]; if ( RES_TXTATR_FIELD == pAttr->Which() ) { const XubString aExpand( ((SwTxtFld*)pAttr)->GetFld().GetFld()->Expand() ); @@ -3168,18 +3203,21 @@ XubString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen, void SwTxtNode::Replace( const SwIndex& rStart, xub_Unicode cCh ) { + ASSERT( rStart.GetIndex() < m_Text.Len(), + "SwTxtNode::Replace: invalid index." ); - ASSERT( rStart.GetIndex() < aText.Len(), "ausserhalb des Strings" ); SwTxtAttr* pHt; - if( ( CH_TXTATR_BREAKWORD == aText.GetChar( rStart.GetIndex() ) || - CH_TXTATR_INWORD == aText.GetChar( rStart.GetIndex() )) && + if ( ( CH_TXTATR_BREAKWORD == m_Text.GetChar( rStart.GetIndex() ) || + CH_TXTATR_INWORD == m_Text.GetChar( rStart.GetIndex() )) && 0 != ( pHt = GetTxtAttr( rStart.GetIndex() ) )) { Delete( pHt ); - aText.Insert( cCh, rStart.GetIndex() ); + m_Text.Insert( cCh, rStart.GetIndex() ); } else - aText.SetChar( rStart.GetIndex(), cCh ); + { + m_Text.SetChar( rStart.GetIndex(), cCh ); + } SwDelTxt aDelHint( rStart.GetIndex(), 1 ); SwModify::Modify( 0, &aDelHint ); @@ -3192,22 +3230,24 @@ void SwTxtNode::Replace( const SwIndex& rStart, xub_Unicode cCh ) void SwTxtNode::Replace( const SwIndex& rStart, xub_StrLen nLen, const XubString& rText ) { - ASSERT( rStart.GetIndex() < aText.Len() && - rStart.GetIndex() + nLen <= aText.Len(), + ASSERT( rStart.GetIndex() < m_Text.Len() && + rStart.GetIndex() + nLen <= m_Text.Len(), "ausserhalb des Strings" ); SwTxtAttr* pHt; const xub_StrLen nStartPos = rStart.GetIndex(); xub_StrLen nEnde = nStartPos + nLen; xub_StrLen nDelLen = nLen; for( xub_StrLen nPos = nStartPos; nPos < nEnde; ++nPos ) - if( ( CH_TXTATR_BREAKWORD == aText.GetChar( nPos ) || - CH_TXTATR_INWORD == aText.GetChar( nPos )) && + { + if ( ( CH_TXTATR_BREAKWORD == m_Text.GetChar( nPos ) || + CH_TXTATR_INWORD == m_Text.GetChar( nPos )) && 0 != ( pHt = GetTxtAttr( nPos ) )) { Delete( pHt ); --nEnde; --nLen; } + } BOOL bOldExpFlg = IsIgnoreDontExpand(); SetIgnoreDontExpand( TRUE ); @@ -3216,22 +3256,22 @@ void SwTxtNode::Replace( const SwIndex& rStart, xub_StrLen nLen, { // dann das 1. Zeichen ersetzen den Rest loschen und einfuegen // Dadurch wird die Attributierung des 1. Zeichen expandiert! - aText.SetChar( nStartPos, rText.GetChar( 0 ) ); + m_Text.SetChar( nStartPos, rText.GetChar( 0 ) ); ((SwIndex&)rStart)++; - aText.Erase( rStart.GetIndex(), nLen - 1 ); + m_Text.Erase( rStart.GetIndex(), nLen - 1 ); Update( rStart, nLen - 1, TRUE ); XubString aTmpTxt( rText ); aTmpTxt.Erase( 0, 1 ); - aText.Insert( aTmpTxt, rStart.GetIndex() ); + m_Text.Insert( aTmpTxt, rStart.GetIndex() ); Update( rStart, aTmpTxt.Len(), FALSE ); } else { - aText.Erase( nStartPos, nLen ); + m_Text.Erase( nStartPos, nLen ); Update( rStart, nLen, TRUE ); - aText.Insert( rText, nStartPos ); + m_Text.Insert( rText, nStartPos ); Update( rStart, rText.Len(), FALSE ); } SetIgnoreDontExpand( bOldExpFlg ); @@ -3467,8 +3507,8 @@ namespace { void SwTxtNode::Modify( SfxPoolItem* pOldValue, SfxPoolItem* pNewValue ) { - bool bWasNotifiable = bNotifiable; - bNotifiable = false; + bool bWasNotifiable = m_bNotifiable; + m_bNotifiable = false; // Bug 24616/24617: // Modify ueberladen, damit beim Loeschen von Vorlagen diese @@ -3501,7 +3541,7 @@ void SwTxtNode::Modify( SfxPoolItem* pOldValue, SfxPoolItem* pNewValue ) pDoc->GetNodes().UpdateOutlineNode(*this); } - bNotifiable = bWasNotifiable; + m_bNotifiable = bWasNotifiable; } SwFmtColl* SwTxtNode::ChgFmtColl( SwFmtColl *pNewColl ) @@ -3583,9 +3623,9 @@ SwNumberTree::tNumberVector SwTxtNode::GetNumberVector() const } } -BOOL SwTxtNode::IsOutline() const +bool SwTxtNode::IsOutline() const { - BOOL bResult = FALSE; + bool bResult = false; //if ( GetOutlineLevel() != NO_NUMBERING )//#outline level,removed by zhaojianwei if ( GetAttrOutlineLevel() > 0 ) //<-end,zhaojianwei @@ -3604,14 +3644,14 @@ BOOL SwTxtNode::IsOutline() const return bResult; } -BOOL SwTxtNode::IsOutlineStateChanged() const +bool SwTxtNode::IsOutlineStateChanged() const { - return IsOutline() != bLastOutlineState; + return IsOutline() != m_bLastOutlineState; } void SwTxtNode::UpdateOutlineState() { - bLastOutlineState = IsOutline(); + m_bLastOutlineState = IsOutline(); } //#outline level, zhaojianwei @@ -3823,7 +3863,7 @@ SwNumberTree::tSwNumTreeNumber SwTxtNode::GetActualListStartValue() const bool SwTxtNode::IsNotifiable() const { - return bNotifiable && IsNotificationEnabled(); + return m_bNotifiable && IsNotificationEnabled(); } bool SwTxtNode::IsNotificationEnabled() const @@ -4846,3 +4886,50 @@ USHORT SwTxtNode::ResetAllAttr() return nRet; } // <-- + + +// sw::Metadatable +::sfx2::IXmlIdRegistry& SwTxtNode::GetRegistry() +{ + return GetDoc()->GetXmlIdRegistry(); +} + +bool SwTxtNode::IsInClipboard() const +{ + return GetDoc()->IsClipBoard(); +} + +bool SwTxtNode::IsInUndo() const +{ + return &GetNodes() == GetDoc()->GetUndoNds(); +} + +bool SwTxtNode::IsInContent() const +{ + return !GetDoc()->IsInHeaderFooter( SwNodeIndex(*this) ); +} + +#include <unoobj.hxx> + +::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > +SwTxtNode::MakeUnoObject() +{ + // re-use existing SwXParagraph + SwClientIter iter( *this ); + SwClient * pClient( iter.First( TYPE( SwXParagraph ) ) ); + while (pClient) { + SwXParagraph *pPara( dynamic_cast<SwXParagraph*>(pClient) ); + if (pPara && pPara->GetCoreObject() == this ) { + return pPara; + } + pClient = iter.Next(); + } + + // create new SwXParagraph + SwPosition Pos( *this ); + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent( + SwXTextRange::CreateParentXText( GetDoc(), Pos ) ); + SwXParagraph * pXPara( new SwXParagraph( xParent, this ) ); + return pXPara; +} + diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 74bb3e87e87e..1b5fc81d366f 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -40,9 +40,7 @@ #include <svtools/stylepool.hxx> #include <svx/fontitem.hxx> #include <svx/langitem.hxx> -#ifndef _SVX_EMPHITEM_HXX //autogen #include <svx/emphitem.hxx> -#endif #include <svx/charscaleitem.hxx> #include <svx/charrotateitem.hxx> // --> OD 2008-01-16 #newlistlevelattrs# @@ -97,6 +95,19 @@ using namespace ::com::sun::star::i18n; + +SwpHints::SwpHints() + : m_pHistory(0) + , m_bFontChange(true) + , m_bInSplitNode(false) + , m_bCalcHiddenParaField(false) + , m_bHasHiddenParaField(false) + , m_bFootnote(false) + , m_bDDEFields(false) +{ +} + + // This function takes care for the following text attribute: // RES_TXTATR_CHARFMT, RES_TXTATR_INETFMT, RES_TXTATR_AUTOFMT, and // RES_TXTATR_CJK_RUBY. These attributes have to be handled in a @@ -138,7 +149,7 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod { for ( USHORT i = 0; i < Count(); ++i ) { - SwTxtAttr* pOther = GetHt(i); + SwTxtAttr* pOther = GetTextHint(i); if ( nWhich == pOther->Which() ) { @@ -152,9 +163,9 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), nOtherStart, nThisStart ); aInsDelHints.push_back( pNewAttr ); - if( pHistory ) pHistory->Add( pOther ); + NoteInHistory( pOther ); *pOther->GetStart() = nThisStart; - if( pHistory ) pHistory->Add( pOther, TRUE ); + NoteInHistory( pOther, true ); nOtherStart = nThisStart; } @@ -162,12 +173,13 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Split pOther if necessary: if ( nOtherStart < nThisEnd && nThisEnd < nOtherEnd ) { - SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), nOtherStart, nThisEnd ); + SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), + nOtherStart, nThisEnd ); aInsDelHints.push_back( pNewAttr ); - if( pHistory ) pHistory->Add( pOther ); + NoteInHistory( pOther ); *pOther->GetStart() = nThisEnd; - if( pHistory ) pHistory->Add( pOther, TRUE ); + NoteInHistory( pOther, true ); } } } @@ -196,8 +208,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod } - SwpHintsArr::Insert( *aIter ); - if ( pHistory ) pHistory->Add( *aIter, TRUE ); + SwpHintsArray::Insert( *aIter ); + NoteInHistory( *aIter, true ); } aInsDelHints.clear(); @@ -206,7 +218,7 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // which are fully covered by the new attribute: for ( USHORT i = 0; i < Count(); ++i ) { - SwTxtAttr* pOther = GetHt(i); + SwTxtAttr* pOther = GetTextHint(i); if ( nWhich == pOther->Which() ) { const xub_StrLen nOtherStart = *pOther->GetStart(); @@ -222,9 +234,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod rNode.DestroyAttr( *aIter ); } - SwpHintsArr::Insert( &rNewHint ); - if ( pHistory ) - pHistory->Add( &rNewHint, TRUE ); + SwpHintsArray::Insert( &rNewHint ); + NoteInHistory( &rNewHint, true ); return; } @@ -241,7 +252,7 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod { for ( USHORT i = 0; i < Count(); ++i ) { - SwTxtAttr* pOther = GetHt(i); + SwTxtAttr* pOther = GetTextHint(i); if ( RES_TXTATR_CHARFMT != pOther->Which() && RES_TXTATR_AUTOFMT != pOther->Which() ) @@ -259,9 +270,9 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod static_cast<SwTxtCharFmt*>(pNewAttr)->SetSortNumber( static_cast<SwTxtCharFmt*>(pOther)->GetSortNumber() ); aInsDelHints.push_back( pNewAttr ); - if( pHistory ) pHistory->Add( pOther ); + NoteInHistory( pOther ); *pOther->GetStart() = nThisStart; - if( pHistory ) pHistory->Add( pOther, TRUE ); + NoteInHistory( pOther, true ); nOtherStart = nThisStart; } @@ -275,17 +286,17 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod static_cast<SwTxtCharFmt*>(pNewAttr)->SetSortNumber( static_cast<SwTxtCharFmt*>(pOther)->GetSortNumber() ); aInsDelHints.push_back( pNewAttr ); - if( pHistory ) pHistory->Add( pOther ); + NoteInHistory( pOther ); *pOther->GetStart() = nThisEnd; - if( pHistory ) pHistory->Add( pOther, TRUE ); + NoteInHistory( pOther, true ); } } // Insert the newly created attributes: for ( aIter = aInsDelHints.begin(); aIter != aInsDelHints.end(); ++aIter ) { - SwpHintsArr::Insert( *aIter ); - if ( pHistory ) pHistory->Add( *aIter, TRUE ); + SwpHintsArray::Insert( *aIter ); + NoteInHistory( *aIter, true ); } } @@ -305,7 +316,7 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod { for ( USHORT i = 0; i < Count(); ++i ) { - const SwTxtAttr* pOther = GetHt(i); + const SwTxtAttr* pOther = GetTextHint(i); if ( RES_TXTATR_CHARFMT != pOther->Which() && RES_TXTATR_AUTOFMT != pOther->Which() ) @@ -338,7 +349,7 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Get all hints that are in [nPorStart, nPorEnd[: for ( USHORT i = 0; i < Count(); ++i ) { - SwTxtAttr *pOther = GetHt(i); + SwTxtAttr *pOther = GetTextHint(i); if ( RES_TXTATR_CHARFMT != pOther->Which() && RES_TXTATR_AUTOFMT != pOther->Which() ) @@ -422,9 +433,10 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Create new AutoStyle if ( aNewSet.Count() ) { - pNewAttr = rNode.MakeTxtAttr( aNewSet, nPorStart, nPorEnd ); - SwpHintsArr::Insert( pNewAttr ); - if ( pHistory ) pHistory->Add( pNewAttr, TRUE ); + pNewAttr = rNode.MakeTxtAttr( aNewSet, + nPorStart, nPorEnd ); + SwpHintsArray::Insert( pNewAttr ); + NoteInHistory( pNewAttr, true ); } } ++aIter; @@ -563,9 +575,9 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod if ( pNewAttr ) { - SwpHintsArr::Insert( pNewAttr ); - if ( pHistory /* && bDestroyHint*/ ) - pHistory->Add( pNewAttr, TRUE ); + SwpHintsArray::Insert( pNewAttr ); +// if ( bDestroyHint ) + NoteInHistory( pNewAttr, true ); } if ( !bNoLengthAttribute ) @@ -585,13 +597,13 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod * SwTxtNode::MakeTxtAttr() *************************************************************************/ - // lege ein neues TextAttribut an und fuege es SwpHints-Array ein +// create new text attribute SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, xub_StrLen nStt, xub_StrLen nEnd, bool bRedlineAttr ) { SwDoc* pDoc = GetDoc(); - if ( !bRedlineAttr && RES_CHRATR_BEGIN <= rAttr.Which () && rAttr.Which() < RES_CHRATR_END ) + if ( !bRedlineAttr && isCHRATR(rAttr.Which()) ) { // Somebody wants to build a SwTxtAttr for a character attribute (and // this attribute is not meant for redlining). Sorry, this is not allowed @@ -791,8 +803,8 @@ SwTxtAttr* SwTxtNode::InsertItem( const SfxPoolItem& rAttr, xub_StrLen nStt, xub_StrLen nEnd, USHORT nMode ) { // character attributes will be inserted as automatic styles: - ASSERT( rAttr.Which() < RES_CHRATR_BEGIN || rAttr.Which() >= RES_CHRATR_END, - "AUTOSTYLES - InsertItem should not be called with character attributes" ) + ASSERT( !isCHRATR(rAttr.Which()), "AUTOSTYLES - " + "SwTxtNode::InsertItem should not be called with character attributes"); SwTxtAttr* pNew = MakeTxtAttr( rAttr, nStt, nEnd ); @@ -866,11 +878,11 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) { // loesche das Zeichen aus dem String ! ASSERT( ( CH_TXTATR_BREAKWORD == - aText.GetChar(*pAttr->GetStart() ) || + m_Text.GetChar(*pAttr->GetStart() ) || CH_TXTATR_INWORD == - aText.GetChar(*pAttr->GetStart())), - "where is my attribu character" ); - aText.Erase( *pAttr->GetStart(), 1 ); + m_Text.GetChar(*pAttr->GetStart())), + "where is my attribute character?" ); + m_Text.Erase( *pAttr->GetStart(), 1 ); // Indizies Updaten SwIndex aTmpIdx( this, *pAttr->GetStart() ); Update( aTmpIdx, 1, TRUE ); @@ -904,11 +916,11 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) { // loesche das Zeichen aus dem String ! ASSERT( ( CH_TXTATR_BREAKWORD == - aText.GetChar(*pAttr->GetStart() ) || + m_Text.GetChar(*pAttr->GetStart() ) || CH_TXTATR_INWORD == - aText.GetChar(*pAttr->GetStart())), - "where is my attribu character" ); - aText.Erase( *pAttr->GetStart(), 1 ); + m_Text.GetChar(*pAttr->GetStart())), + "where is my attribute character?" ); + m_Text.Erase( *pAttr->GetStart(), 1 ); // Indizies Updaten SwIndex aTmpIdx( this, *pAttr->GetStart() ); Update( aTmpIdx, 1, TRUE ); @@ -922,7 +934,8 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) if( bNewFtn ) { ((SwTxtFtn*)pAttr)->MakeNewTextSection( GetNodes() ); - SwRegHistory* pHist = GetpSwpHints() ? GetpSwpHints()->getHistory() : 0; + SwRegHistory* pHist = GetpSwpHints() + ? GetpSwpHints()->GetHistory() : 0; if( pHist ) pHist->ChangeNodeIndex( GetIndex() ); } @@ -1014,17 +1027,18 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) ASSERT( *pAttr->GetEnd() <= Len(), "EndIdx hinter Len!" ); } - if ( !pSwpHints ) - pSwpHints = new SwpHints(); + GetOrCreateSwpHints(); // 4263: AttrInsert durch TextInsert => kein Adjust - pSwpHints->Insert( pAttr, *this, nMode ); + m_pSwpHints->Insert( pAttr, *this, nMode ); // 47375: In pSwpHints->Insert wird u.a. Merge gerufen und das Hints-Array // von ueberfluessigen Hints befreit, dies kann u.U. sogar der frisch // eingefuegte Hint pAttr sein, der dann zerstoert wird!! - if( USHRT_MAX == pSwpHints->GetPos( pAttr ) ) + if ( USHRT_MAX == m_pSwpHints->GetPos( pAttr ) ) + { return FALSE; + } if( bHiddenPara ) SetCalcHiddenParaField(); @@ -1039,8 +1053,9 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) void SwTxtNode::Delete( SwTxtAttr *pAttr, BOOL bThisOnly ) { - if ( !pSwpHints ) + if ( !HasHints() ) return; + if( bThisOnly ) { xub_StrLen* pEndIdx = pAttr->GetEnd(); @@ -1056,13 +1071,12 @@ void SwTxtNode::Delete( SwTxtAttr *pAttr, BOOL bThisOnly ) // den MsgHint jetzt fuettern, weil gleich sind // Start und End weg. SwUpdateAttr aHint( *pAttr->GetStart(), *pEndIdx, pAttr->Which() ); - pSwpHints->Delete( pAttr ); + m_pSwpHints->Delete( pAttr ); pAttr->RemoveFromPool( GetDoc()->GetAttrPool() ); delete pAttr; SwModify::Modify( 0, &aHint ); // die Frames benachrichtigen - if( pSwpHints && pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); } return; @@ -1076,16 +1090,16 @@ void SwTxtNode::Delete( SwTxtAttr *pAttr, BOOL bThisOnly ) void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) { - if ( !pSwpHints ) + if ( !HasHints() ) return; const xub_StrLen *pEndIdx; const xub_StrLen *pSttIdx; SwTxtAttr* pTxtHt; - for( USHORT nPos = 0; pSwpHints && nPos < pSwpHints->Count(); nPos++ ) + for ( USHORT nPos = 0; m_pSwpHints && nPos < m_pSwpHints->Count(); nPos++ ) { - pTxtHt = pSwpHints->GetHt( nPos ); + pTxtHt = m_pSwpHints->GetTextHint( nPos ); const USHORT nWhich = pTxtHt->Which(); if( nWhich == nTxtWhich && *( pSttIdx = pTxtHt->GetStart()) == nStt ) @@ -1128,7 +1142,7 @@ void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) // Das CalcVisibleFlag bei HiddenParaFields entfaellt, // da dies das Feld im Dtor selbst erledigt. SwUpdateAttr aHint( *pSttIdx, *pEndIdx, nTxtWhich ); - pSwpHints->DeleteAtPos( nPos ); // gefunden, loeschen, + m_pSwpHints->DeleteAtPos( nPos ); // gefunden, loeschen, pTxtHt->RemoveFromPool( GetDoc()->GetAttrPool() ); delete pTxtHt; SwModify::Modify( 0, &aHint ); // die Frames benachrichtigen @@ -1136,8 +1150,7 @@ void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) } } } - if( pSwpHints && pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); } /************************************************************************* @@ -1148,7 +1161,7 @@ void SwTxtNode::DelSoftHyph( const xub_StrLen nStt, const xub_StrLen nEnd ) { xub_StrLen nFndPos = nStt, nEndPos = nEnd; while( STRING_NOTFOUND != - ( nFndPos = aText.Search( CHAR_SOFTHYPHEN, nFndPos )) && + ( nFndPos = m_Text.Search( CHAR_SOFTHYPHEN, nFndPos )) && nFndPos < nEndPos ) { const SwIndex aIdx( this, nFndPos ); @@ -1170,18 +1183,23 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, SfxItemSet aTxtSet( *rSet.GetPool(), RES_TXTATR_BEGIN, RES_TXTATR_END-1 ); // gesamter Bereich - if( !nStt && nEnd == aText.Len() && !(nMode & nsSetAttrMode::SETATTR_NOFORMATATTR ) ) + if ( !nStt && (nEnd == m_Text.Len()) && + !(nMode & nsSetAttrMode::SETATTR_NOFORMATATTR ) ) { // sind am Node schon Zeichenvorlagen gesetzt, muss man diese Attribute // (rSet) immer als TextAttribute setzen, damit sie angezeigt werden. int bHasCharFmts = FALSE; - if( pSwpHints ) - for( USHORT n = 0; n < pSwpHints->Count(); ++n ) - if( (*pSwpHints)[ n ]->IsCharFmtAttr() ) + if ( HasHints() ) + { + for ( USHORT n = 0; n < m_pSwpHints->Count(); ++n ) + { + if ( (*m_pSwpHints)[ n ]->IsCharFmtAttr() ) { bHasCharFmts = TRUE; break; } + } + } if( !bHasCharFmts ) { @@ -1211,8 +1229,7 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, } } - if ( !pSwpHints ) - pSwpHints = new SwpHints(); + GetOrCreateSwpHints(); SfxItemSet aCharSet( *rSet.GetPool(), aCharAutoFmtSetRange ); @@ -1223,47 +1240,50 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, do { - if( pItem && (SfxPoolItem*)-1 != pItem && - (( RES_CHRATR_BEGIN <= ( nWhich = pItem->Which()) && - RES_CHRATR_END > nWhich ) || - ( RES_TXTATR_BEGIN <= nWhich && RES_TXTATR_END > nWhich ) || - ( RES_UNKNOWNATR_BEGIN <= nWhich && RES_UNKNOWNATR_END > nWhich )) ) + if ( pItem && (reinterpret_cast<SfxPoolItem*>(-1) != pItem)) { - if( RES_TXTATR_CHARFMT == pItem->Which() && - GetDoc()->GetDfltCharFmt()==((SwFmtCharFmt*)pItem)->GetCharFmt()) - { - SwIndex aIndex( this, nStt ); - RstAttr( aIndex, nEnd - nStt, RES_TXTATR_CHARFMT, 0 ); - DontExpandFmt( aIndex ); - } - else + nWhich = pItem->Which(); + if ( isCHRATR(nWhich) || isTXTATR(nWhich) || isUNKNOWNATR(nWhich) ) { - if ( ( RES_CHRATR_BEGIN <= nWhich && RES_CHRATR_END > nWhich ) || - RES_TXTATR_UNKNOWN_CONTAINER == nWhich ) + if ((RES_TXTATR_CHARFMT == nWhich) && + (GetDoc()->GetDfltCharFmt() == + static_cast<const SwFmtCharFmt*>(pItem)->GetCharFmt())) { - aCharSet.Put( *pItem ); + SwIndex aIndex( this, nStt ); + RstAttr( aIndex, nEnd - nStt, RES_TXTATR_CHARFMT, 0 ); + DontExpandFmt( aIndex ); } else { - pNew = MakeTxtAttr( *pItem, nStt, nEnd ); - if( pNew ) + if (isCHRATR(nWhich) || + (RES_TXTATR_UNKNOWN_CONTAINER == nWhich)) { - // Attribut ohne Ende, aber Bereich markiert ? - if( nEnd != nStt && !pNew->GetEnd() ) + aCharSet.Put( *pItem ); + } + else + { + pNew = MakeTxtAttr( *pItem, nStt, nEnd ); + if ( pNew ) { - ASSERT( !this, "Attribut ohne Ende aber Bereich vorgegeben" ); - DestroyAttr( pNew ); // nicht einfuegen + if ( nEnd != nStt && !pNew->GetEnd() ) + { + ASSERT(false, + "Attribut without end, but area marked"); + DestroyAttr( pNew ); // do not insert + } + else if ( Insert( pNew, nMode ) ) + { + ++nCount; + } } - else if( Insert( pNew, nMode )) - ++nCount; } } } } - if( aIter.IsAtEnd() ) + if ( aIter.IsAtEnd() ) break; pItem = aIter.NextItem(); - } while( TRUE ); + } while( true ); if ( aCharSet.Count() ) { @@ -1272,8 +1292,7 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, ++nCount; } - if( pSwpHints && pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); return nCount ? TRUE : FALSE; } @@ -1372,7 +1391,7 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, BOOL bOnlyTxtAttr, BOOL bGetFromChrFmt, const bool bMergeIndentValuesOfNumRule ) const { - if( pSwpHints ) + if( HasHints() ) { /* stelle erstmal fest, welche Text-Attribut in dem Bereich gueltig * sind. Dabei gibt es folgende Faelle: @@ -1403,7 +1422,7 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, // <-- } - const USHORT nSize = pSwpHints->Count(); + const USHORT nSize = m_pSwpHints->Count(); USHORT n; xub_StrLen nAttrStart; const xub_StrLen* pAttrEnd; @@ -1412,7 +1431,7 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, { for( n = 0; n < nSize; ++n ) // { - const SwTxtAttr* pHt = (*pSwpHints)[n]; + const SwTxtAttr* pHt = (*m_pSwpHints)[n]; nAttrStart = *pHt->GetStart(); if( nAttrStart > nEnd ) // ueber den Bereich hinaus break; @@ -1441,7 +1460,7 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, for( n = 0; n < nSize; ++n ) { - const SwTxtAttr* pHt = (*pSwpHints)[n]; + const SwTxtAttr* pHt = (*m_pSwpHints)[n]; nAttrStart = *pHt->GetStart(); if( nAttrStart > nEnd ) // ueber den Bereich hinaus break; @@ -1494,13 +1513,21 @@ BOOL SwTxtNode::GetAttr( SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd, pAttrArr = new std::vector< SwPoolItemEndPair >( coArrSz ); std::vector< SwPoolItemEndPair >::iterator pPrev = pAttrArr->begin(); - if( RES_CHRATR_BEGIN <= nHintWhich && nHintWhich < RES_TXTATR_WITHEND_END ) + if (isCHRATR(nHintWhich) || + isTXTATR_WITHEND(nHintWhich)) + { pPrev += nHintWhich - RES_CHRATR_BEGIN; - else if( RES_UNKNOWNATR_BEGIN <= nHintWhich && nHintWhich < RES_UNKNOWNATR_END ) + } + else if (isUNKNOWNATR(nHintWhich)) + { pPrev += nHintWhich - RES_UNKNOWNATR_BEGIN + ( - static_cast< USHORT >(RES_TXTATR_WITHEND_END) - static_cast< USHORT >(RES_CHRATR_BEGIN) ); + static_cast< USHORT >(RES_TXTATR_WITHEND_END) - + static_cast< USHORT >(RES_CHRATR_BEGIN) ); + } else + { pPrev = pAttrArr->end(); + } #if OSL_DEBUG_LEVEL > 1 SwPoolItemEndPair aTmp = *pPrev; @@ -1627,8 +1654,7 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) if( HasSwAttrSet() && GetpSwAttrSet()->Count() ) aThisSet.Put( *GetpSwAttrSet() ); - if ( !pSwpHints ) - pSwpHints = new SwpHints(); + GetOrCreateSwpHints(); if( pNd == this ) { @@ -1638,11 +1664,11 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) const SfxPoolItem* pItem = aIter.GetCurItem(); std::vector<USHORT> aClearWhichIds; - while( TRUE ) + while ( true ) { - if( lcl_IsNewAttrInSet( *pSwpHints, *pItem, GetTxt().Len() ) ) + if (lcl_IsNewAttrInSet( *m_pSwpHints, *pItem, GetTxt().Len() )) { - pSwpHints->SwpHintsArr::Insert( + m_pSwpHints->SwpHintsArray::Insert( MakeTxtAttr( *pItem, 0, GetTxt().Len() ) ); aClearWhichIds.push_back( pItem->Which() ); } @@ -1661,8 +1687,7 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) if( pNd->HasSwAttrSet() && pNd->GetpSwAttrSet()->Count() ) aNdSet.Put( *pNd->GetpSwAttrSet() ); - if ( !pNd->pSwpHints ) - pNd->pSwpHints = new SwpHints(); + pNd->GetOrCreateSwpHints(); if( aThisSet.Count() ) { @@ -1674,9 +1699,9 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) { if( ( SFX_ITEM_SET != aNdSet.GetItemState( pItem->Which(), FALSE, &pNdItem ) || *pItem != *pNdItem ) && - lcl_IsNewAttrInSet( *pSwpHints, *pItem, GetTxt().Len() ) ) + lcl_IsNewAttrInSet( *m_pSwpHints, *pItem, GetTxt().Len() ) ) { - pSwpHints->SwpHintsArr::Insert( + m_pSwpHints->SwpHintsArray::Insert( MakeTxtAttr( *pItem, 0, GetTxt().Len() ) ); aClearWhichIds.push_back( pItem->Which() ); } @@ -1695,11 +1720,14 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) const SfxPoolItem* pItem = aIter.GetCurItem(); std::vector<USHORT> aClearWhichIds; - while( TRUE ) + while ( true ) { - if( lcl_IsNewAttrInSet( *pNd->pSwpHints, *pItem, pNd->GetTxt().Len() ) ) - pNd->pSwpHints->SwpHintsArr::Insert( + if ( lcl_IsNewAttrInSet( *pNd->m_pSwpHints, *pItem, + pNd->GetTxt().Len() ) ) + { + pNd->m_pSwpHints->SwpHintsArray::Insert( pNd->MakeTxtAttr( *pItem, 0, pNd->GetTxt().Len() ) ); + } aClearWhichIds.push_back( pItem->Which() ); if( aIter.IsAtEnd() ) @@ -1715,8 +1743,7 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) SetCalcHiddenCharFlags(); - if( pNd->pSwpHints->CanBeDeleted() ) - DELETEZ( pNd->pSwpHints ); + pNd->TryDeleteSwpHints(); } /************************************************************************* @@ -1725,15 +1752,16 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) void SwpHints::CalcFlags() { - bDDEFlds = bFtn = FALSE; + m_bDDEFields = m_bFootnote = false; const USHORT nSize = Count(); const SwTxtAttr* pAttr; for( USHORT nPos = 0; nPos < nSize; ++nPos ) + { switch( ( pAttr = (*this)[ nPos ])->Which() ) { case RES_TXTATR_FTN: - bFtn = TRUE; - if( bDDEFlds ) + m_bFootnote = true; + if ( m_bDDEFields ) return; break; case RES_TXTATR_FIELD: @@ -1741,24 +1769,25 @@ void SwpHints::CalcFlags() const SwField* pFld = pAttr->GetFld().GetFld(); if( RES_DDEFLD == pFld->GetTyp()->Which() ) { - bDDEFlds = TRUE; - if( bFtn ) + m_bDDEFields = true; + if ( m_bFootnote ) return; } } break; } + } } /************************************************************************* * SwpHints::CalcVisibleFlag() *************************************************************************/ -BOOL SwpHints::CalcHiddenParaField() +bool SwpHints::CalcHiddenParaField() { - bCalcHiddenParaField = FALSE; - BOOL bOldHasHiddenParaField = bHasHiddenParaField; - BOOL bNewHasHiddenParaField = FALSE; + m_bCalcHiddenParaField = false; + bool bOldHasHiddenParaField = m_bHasHiddenParaField; + bool bNewHasHiddenParaField = false; const USHORT nSize = Count(); const SwTxtAttr *pTxtHt; @@ -1774,11 +1803,13 @@ BOOL SwpHints::CalcHiddenParaField() { if( !((SwHiddenParaField*)rFld.GetFld())->IsHidden() ) { - SetHiddenParaField(FALSE); + SetHiddenParaField(false); return bOldHasHiddenParaField != bNewHasHiddenParaField; } else - bNewHasHiddenParaField = TRUE; + { + bNewHasHiddenParaField = true; + } } } } @@ -1791,10 +1822,9 @@ BOOL SwpHints::CalcHiddenParaField() * SwpHints::NoteInHistory() *************************************************************************/ -void SwpHints::NoteInHistory( SwTxtAttr *pAttr, const BOOL bNew ) +void SwpHints::NoteInHistory( SwTxtAttr *pAttr, const bool bNew ) { - if ( pHistory ) - pHistory->Add( pAttr, bNew ); + if ( m_pHistory ) { m_pHistory->AddHint( pAttr, bNew ); } } /************************************************************************* @@ -1807,7 +1837,7 @@ bool SwpHints::MergePortions( SwTxtNode& rNode ) return false; // sort before merging - SwpHintsArr::Resort(); + SwpHintsArray::Resort(); bool bRet = false; typedef std::multimap< int, SwTxtAttr* > PortionMap; @@ -1819,7 +1849,7 @@ bool SwpHints::MergePortions( SwTxtNode& rNode ) // get portions by start position: for ( i = 0; i < Count(); ++i ) { - SwTxtAttr *pHt = GetHt( i ); + SwTxtAttr *pHt = GetTextHint( i ); if ( RES_TXTATR_CHARFMT != pHt->Which() && RES_TXTATR_AUTOFMT != pHt->Which() ) //&& @@ -1891,9 +1921,9 @@ bool SwpHints::MergePortions( SwTxtNode& rNode ) for ( aIter1 = aRange1.first; aIter1 != aRange1.second; ++aIter1 ) { SwTxtAttr* p1 = (*aIter1).second; - if( pHistory ) pHistory->Add( p1 ); + NoteInHistory( p1 ); *p1->GetEnd() = nNewPortionEnd; - if( pHistory ) pHistory->Add( p1, TRUE ); + NoteInHistory( p1, true ); bRet = true; } } @@ -1905,7 +1935,9 @@ bool SwpHints::MergePortions( SwTxtNode& rNode ) } if ( bRet ) - SwpHintsArr::Resort(); + { + SwpHintsArray::Resort(); + } return bRet; } @@ -2083,12 +2115,12 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) ((SwTxtRefMark*)pHint)->ChgTxtNode( &rNode ); if( rNode.GetNodes().IsDocNodes() ) { - //search for a refernce with the same name + // search for a reference with the same name SwTxtAttr* pTmpHt; xub_StrLen *pTmpHtEnd, *pTmpHintEnd; for( USHORT n = 0, nEnd = Count(); n < nEnd; ++n ) { - if( RES_TXTATR_REFMARK == (pTmpHt = GetHt( n ))->Which() && + if (RES_TXTATR_REFMARK == (pTmpHt = GetTextHint(n))->Which() && pHint->GetAttr() == pTmpHt->GetAttr() && 0 != ( pTmpHtEnd = pTmpHt->GetEnd() ) && 0 != ( pTmpHintEnd = pHint->GetEnd() ) ) @@ -2118,8 +2150,7 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) if( bDelOld ) { - if( pHistory ) - pHistory->Add( pTmpHt ); + NoteInHistory( pTmpHt ); rNode.DestroyAttr( Cut( n-- ) ); --nEnd; } @@ -2155,7 +2186,7 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) xub_StrLen nHtStart = *pHint->GetStart(); if( !pHtEnd ) { - SwpHintsArr::Insert( pHint ); + SwpHintsArray::Insert( pHint ); CalcFlags(); #ifndef PRODUCT if( !rNode.GetDoc()->IsInReading() ) @@ -2232,9 +2263,8 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) lcl_CheckSortNumber( *this, *static_cast<SwTxtCharFmt*>(pHint) ); // <-- - SwpHintsArr::Insert( pHint ); - if ( pHistory ) - pHistory->Add( pHint, TRUE ); + SwpHintsArray::Insert( pHint ); + NoteInHistory( pHint, true ); } } @@ -2259,10 +2289,10 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) void SwpHints::DeleteAtPos( const USHORT nPos ) { - SwTxtAttr *pHint = GetHt(nPos); + SwTxtAttr *pHint = GetTextHint(nPos); // ChainDelete( pHint ); - if( pHistory ) pHistory->Add( pHint ); - SwpHintsArr::DeleteAtPos( nPos ); + NoteInHistory( pHint ); + SwpHintsArray::DeleteAtPos( nPos ); if( RES_TXTATR_FIELD == pHint->Which() ) { @@ -2278,8 +2308,11 @@ void SwpHints::DeleteAtPos( const USHORT nPos ) { const_cast<SwFmtFld&>(((SwTxtFld*)pHint)->GetFld()).Broadcast( SwFmtFldHint( &((SwTxtFld*)pHint)->GetFld(), SWFMTFLD_REMOVED ) ); } - else if( bHasHiddenParaField && RES_HIDDENPARAFLD == pFldTyp->Which() ) - bCalcHiddenParaField = TRUE; + else if ( m_bHasHiddenParaField && + RES_HIDDENPARAFLD == pFldTyp->Which() ) + { + m_bCalcHiddenParaField = true; + } } CalcFlags(); @@ -2300,12 +2333,12 @@ void SwpHints::Delete( SwTxtAttr* pTxtHt ) void SwTxtNode::ClearSwpHintsArr( bool bDelFields ) { - if( pSwpHints ) + if ( HasHints() ) { USHORT nPos = 0; - while( nPos < pSwpHints->Count() ) + while ( nPos < m_pSwpHints->Count() ) { - SwTxtAttr* pDel = pSwpHints->GetHt( nPos ); + SwTxtAttr* pDel = m_pSwpHints->GetTextHint( nPos ); bool bDel = false; switch( pDel->Which() ) @@ -2325,7 +2358,7 @@ void SwTxtNode::ClearSwpHintsArr( bool bDelFields ) if( bDel ) { - pSwpHints->SwpHintsArr::DeleteAtPos( nPos ); + m_pSwpHints->SwpHintsArray::DeleteAtPos( nPos ); DestroyAttr( pDel ); } else @@ -2339,20 +2372,22 @@ USHORT SwTxtNode::GetLang( const xub_StrLen nBegin, const xub_StrLen nLen, { USHORT nRet = LANGUAGE_DONTKNOW; - if ( ! nScript ) - nScript = pBreakIt->GetRealScriptOfText( aText, nBegin ); + if ( ! nScript ) + { + nScript = pBreakIt->GetRealScriptOfText( m_Text, nBegin ); + } // --> FME 2008-09-29 #i91465# hennerdrewes: Consider nScript if pSwpHints == 0 const USHORT nWhichId = GetWhichOfScript( RES_CHRATR_LANGUAGE, nScript ); // <-- - if( pSwpHints ) + if ( HasHints() ) { const xub_StrLen nEnd = nBegin + nLen; - for( USHORT i = 0, nSize = pSwpHints->Count(); i < nSize; ++i ) + for ( USHORT i = 0, nSize = m_pSwpHints->Count(); i < nSize; ++i ) { // ist der Attribut-Anfang schon groesser als der Idx ? - const SwTxtAttr *pHt = pSwpHints->operator[](i); + const SwTxtAttr *pHt = m_pSwpHints->operator[](i); const xub_StrLen nAttrStart = *pHt->GetStart(); if( nEnd < nAttrStart ) break; diff --git a/sw/source/core/txtnode/txatbase.cxx b/sw/source/core/txtnode/txatbase.cxx index 71938961ef7f..17c94a9e20c9 100644 --- a/sw/source/core/txtnode/txatbase.cxx +++ b/sw/source/core/txtnode/txatbase.cxx @@ -37,12 +37,18 @@ #include <fmtfld.hxx> #include <docufld.hxx> -SwTxtAttr::SwTxtAttr( const SfxPoolItem& rAttr, xub_StrLen nStt ) - : pAttr( &rAttr ), nStart( nStt ) +SwTxtAttr::SwTxtAttr( const SfxPoolItem& rAttr, xub_StrLen nStart ) + : m_pAttr( &rAttr ) + , m_nStart( nStart ) + , m_bDontExpand( false ) + , m_bLockExpandFlag( false ) + , m_bDontMergeAttr( false ) + , m_bDontMoveAttr( false ) + , m_bCharFmtAttr( false ) + , m_bOverlapAllowedAttr( false ) + , m_bPriorityAttr( false ) + , m_bDontExpandStart( false ) { - bDontExpand = bLockExpandFlag = bDontMergeAttr = bDontMoveAttr = - bCharFmtAttr = bOverlapAllowedAttr = bPriorityAttr = - bDontExpandStart = FALSE; } SwTxtAttr::~SwTxtAttr( ) @@ -54,12 +60,11 @@ xub_StrLen* SwTxtAttr::GetEnd() return 0; } - // RemoveFromPool muss immer vorm DTOR Aufruf erfolgen!! - // Meldet sein Attribut beim Pool ab +// RemoveFromPool must be called before destructor! void SwTxtAttr::RemoveFromPool( SfxItemPool& rPool ) { rPool.Remove( GetAttr() ); - pAttr = 0; + m_pAttr = 0; } int SwTxtAttr::operator==( const SwTxtAttr& rAttr ) const @@ -67,13 +72,14 @@ int SwTxtAttr::operator==( const SwTxtAttr& rAttr ) const return GetAttr() == rAttr.GetAttr(); } -SwTxtAttrEnd::SwTxtAttrEnd( const SfxPoolItem& rAttr, xub_StrLen nS, - xub_StrLen nE ) - : SwTxtAttr( rAttr, nS ), nEnd( nE ) +SwTxtAttrEnd::SwTxtAttrEnd( const SfxPoolItem& rAttr, + xub_StrLen nStart, xub_StrLen nEnd ) : + SwTxtAttr( rAttr, nStart ), m_nEnd( nEnd ) { } xub_StrLen* SwTxtAttrEnd::GetEnd() { - return &nEnd; + return & m_nEnd; } + diff --git a/sw/source/core/txtnode/txtatr2.cxx b/sw/source/core/txtnode/txtatr2.cxx index d62b1bc31ff5..eca88502f771 100644 --- a/sw/source/core/txtnode/txtatr2.cxx +++ b/sw/source/core/txtnode/txtatr2.cxx @@ -56,10 +56,10 @@ TYPEINIT1(SwTxtRuby,SwClient); *************************************************************************/ SwTxtHardBlank::SwTxtHardBlank( const SwFmtHardBlank& rAttr, xub_StrLen nStt ) - : SwTxtAttr( rAttr, nStt ), - cChar( rAttr.GetChar() ) + : SwTxtAttr( rAttr, nStt ) + , m_Char( rAttr.GetChar() ) { - ASSERT( ' ' != cChar && '-' != cChar, + ASSERT( ' ' != m_Char && '-' != m_Char, "Invalid character for the HardBlank attribute - " "must be a normal unicode character" ); } @@ -69,13 +69,13 @@ SwTxtHardBlank::SwTxtHardBlank( const SwFmtHardBlank& rAttr, xub_StrLen nStt ) * class SwTxtCharFmt *************************************************************************/ -SwTxtCharFmt::SwTxtCharFmt( const SwFmtCharFmt& rAttr, +SwTxtCharFmt::SwTxtCharFmt( SwFmtCharFmt& rAttr, xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ), - pMyTxtNd( 0 ), - mnSortNumber( 0 ) + : SwTxtAttrEnd( rAttr, nStt, nEnde ) + , m_pTxtNode( 0 ) + , m_nSortNumber( 0 ) { - ((SwFmtCharFmt&)rAttr).pTxtAttr = this; + rAttr.pTxtAttr = this; SetCharFmtAttr( TRUE ); } @@ -86,29 +86,27 @@ SwTxtCharFmt::~SwTxtCharFmt( ) void SwTxtCharFmt::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) { USHORT nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0; -#ifndef PRODUCT - if ( (nWhich<RES_CHRATR_BEGIN || nWhich>RES_CHRATR_END) - && (nWhich!=RES_OBJECTDYING) - && (nWhich!=RES_ATTRSET_CHG) - && (nWhich!=RES_FMT_CHG) ) - ASSERT(!this, "SwTxtCharFmt::Modify(): unbekanntes Modify!"); -#endif - - if( pMyTxtNd ) + ASSERT( isCHRATR(nWhich) || (RES_OBJECTDYING == nWhich) + || (RES_ATTRSET_CHG == nWhich) || (RES_FMT_CHG == nWhich), + "SwTxtCharFmt::Modify(): unknown Modify"); + + if ( m_pTxtNode ) { SwUpdateAttr aUpdateAttr( *GetStart(), *GetEnd(), nWhich ); - pMyTxtNd->Modify( &aUpdateAttr, &aUpdateAttr ); + m_pTxtNode->Modify( &aUpdateAttr, &aUpdateAttr ); } } // erfrage vom Modify Informationen BOOL SwTxtCharFmt::GetInfo( SfxPoolItem& rInfo ) const { - if( RES_AUTOFMT_DOCNODE != rInfo.Which() || !pMyTxtNd || - &pMyTxtNd->GetNodes() != ((SwAutoFmtGetDocNode&)rInfo).pNodes ) + if ( RES_AUTOFMT_DOCNODE != rInfo.Which() || !m_pTxtNode || + &m_pTxtNode->GetNodes() != static_cast<SwAutoFmtGetDocNode&>(rInfo).pNodes ) + { return TRUE; + } - ((SwAutoFmtGetDocNode&)rInfo).pCntntNode = pMyTxtNd; + static_cast<SwAutoFmtGetDocNode&>(rInfo).pCntntNode = m_pTxtNode; return FALSE; } @@ -116,14 +114,15 @@ BOOL SwTxtCharFmt::GetInfo( SfxPoolItem& rInfo ) const * class SwTxtINetFmt *************************************************************************/ -SwTxtINetFmt::SwTxtINetFmt( const SwFmtINetFmt& rAttr, +SwTxtINetFmt::SwTxtINetFmt( SwFmtINetFmt& rAttr, xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ), - SwClient( 0 ), - pMyTxtNd( 0 ) + : SwTxtAttrEnd( rAttr, nStt, nEnde ) + , SwClient( 0 ) + , m_pTxtNode( 0 ) + , m_bVisited( false ) + , m_bVisitedValid( false ) { - bValidVis = FALSE; - ((SwFmtINetFmt&)rAttr).pTxtAttr = this; + rAttr.pTxtAttr = this; SetCharFmtAttr( TRUE ); } @@ -139,10 +138,10 @@ SwCharFmt* SwTxtINetFmt::GetCharFmt() if( rFmt.GetValue().Len() ) { const SwDoc* pDoc = GetTxtNode().GetDoc(); - if( !IsValidVis() ) + if( !IsVisitedValid() ) { SetVisited( pDoc->IsVisitedURL( rFmt.GetValue() ) ); - SetValidVis( TRUE ); + SetVisitedValid( true ); } USHORT nId; const String& rStr = IsVisited() ? rFmt.GetVisitedFmt() @@ -184,35 +183,33 @@ SwCharFmt* SwTxtINetFmt::GetCharFmt() void SwTxtINetFmt::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) { USHORT nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0; -#ifndef PRODUCT - if ( (nWhich<RES_CHRATR_BEGIN || nWhich>RES_CHRATR_END) - && (nWhich!=RES_OBJECTDYING) - && (nWhich!=RES_ATTRSET_CHG) - && (nWhich!=RES_FMT_CHG) ) - ASSERT(!this, "SwTxtCharFmt::Modify(): unbekanntes Modify!"); -#endif - - if( pMyTxtNd ) + ASSERT( isCHRATR(nWhich) || (RES_OBJECTDYING == nWhich) + || (RES_ATTRSET_CHG == nWhich) || (RES_FMT_CHG == nWhich), + "SwTxtINetFmt::Modify(): unknown Modify"); + + if ( m_pTxtNode ) { SwUpdateAttr aUpdateAttr( *GetStart(), *GetEnd(), nWhich ); - pMyTxtNd->Modify( &aUpdateAttr, &aUpdateAttr ); + m_pTxtNode->Modify( &aUpdateAttr, &aUpdateAttr ); } } // erfrage vom Modify Informationen BOOL SwTxtINetFmt::GetInfo( SfxPoolItem& rInfo ) const { - if( RES_AUTOFMT_DOCNODE != rInfo.Which() || !pMyTxtNd || - &pMyTxtNd->GetNodes() != ((SwAutoFmtGetDocNode&)rInfo).pNodes ) + if ( RES_AUTOFMT_DOCNODE != rInfo.Which() || !m_pTxtNode || + &m_pTxtNode->GetNodes() != static_cast<SwAutoFmtGetDocNode&>(rInfo).pNodes ) + { return TRUE; + } - ((SwAutoFmtGetDocNode&)rInfo).pCntntNode = pMyTxtNd; + static_cast<SwAutoFmtGetDocNode&>(rInfo).pCntntNode = m_pTxtNode; return FALSE; } BOOL SwTxtINetFmt::IsProtect( ) const { - return pMyTxtNd && pMyTxtNd->IsProtect(); + return m_pTxtNode && m_pTxtNode->IsProtect(); } // ATT_XNLCONTAINERITEM ****************************** @@ -224,20 +221,21 @@ SwTxtXMLAttrContainer::SwTxtXMLAttrContainer( {} +/************************************************************************* + * class SwTxtRuby + *************************************************************************/ -// ****************************** - -SwTxtRuby::SwTxtRuby( const SwFmtRuby& rAttr, - xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ), - SwClient( 0 ), - pMyTxtNd( 0 ) +SwTxtRuby::SwTxtRuby( SwFmtRuby& rAttr, + xub_StrLen nStart, xub_StrLen nEnd ) + : SwTxtAttrEnd( rAttr, nStart, nEnd ) + , SwClient( 0 ) + , m_pTxtNode( 0 ) { - ((SwFmtRuby&)rAttr).pTxtAttr = this; - SetDontExpand( TRUE ); // never expand this attribut - SetLockExpandFlag( TRUE ); - SetDontMergeAttr( TRUE ); - SetDontExpandStartAttr( TRUE ); + rAttr.pTxtAttr = this; + SetDontExpand( true ); // never expand this attribute + SetLockExpandFlag( true ); + SetDontMergeAttr( true ); + SetDontExpandStartAttr( true ); } SwTxtRuby::~SwTxtRuby() @@ -247,28 +245,26 @@ SwTxtRuby::~SwTxtRuby() void SwTxtRuby::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) { USHORT nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0; -#ifndef PRODUCT - if ( (nWhich<RES_CHRATR_BEGIN || nWhich>RES_CHRATR_END) - && (nWhich!=RES_OBJECTDYING) - && (nWhich!=RES_ATTRSET_CHG) - && (nWhich!=RES_FMT_CHG) ) - ASSERT(!this, "SwTxtCharFmt::Modify(): unbekanntes Modify!"); -#endif - - if( pMyTxtNd ) + ASSERT( isCHRATR(nWhich) || (RES_OBJECTDYING == nWhich) + || (RES_ATTRSET_CHG == nWhich) || (RES_FMT_CHG == nWhich), + "SwTxtRuby::Modify(): unknown Modify"); + + if ( m_pTxtNode ) { SwUpdateAttr aUpdateAttr( *GetStart(), *GetEnd(), nWhich ); - pMyTxtNd->Modify( &aUpdateAttr, &aUpdateAttr ); + m_pTxtNode->Modify( &aUpdateAttr, &aUpdateAttr ); } } BOOL SwTxtRuby::GetInfo( SfxPoolItem& rInfo ) const { - if( RES_AUTOFMT_DOCNODE != rInfo.Which() || !pMyTxtNd || - &pMyTxtNd->GetNodes() != ((SwAutoFmtGetDocNode&)rInfo).pNodes ) + if( RES_AUTOFMT_DOCNODE != rInfo.Which() || !m_pTxtNode || + &m_pTxtNode->GetNodes() != static_cast<SwAutoFmtGetDocNode&>(rInfo).pNodes ) + { return TRUE; + } - ((SwAutoFmtGetDocNode&)rInfo).pCntntNode = pMyTxtNd; + static_cast<SwAutoFmtGetDocNode&>(rInfo).pCntntNode = m_pTxtNode; return FALSE; } diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index b00e9c0febcd..51e4963698a7 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -50,12 +50,8 @@ #include <SwSmartTagMgr.hxx> #include <linguistic/lngprops.hxx> #include <com/sun/star/beans/XPropertySet.hpp> -#ifndef _COM_SUN_STAR_I18N_WORDTYPE_HDL #include <com/sun/star/i18n/WordType.hdl> -#endif -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif #include <unotools/transliterationwrapper.hxx> #include <unotools/charclass.hxx> #include <dlelstnr.hxx> @@ -64,9 +60,7 @@ #include <viewopt.hxx> #include <acmplwrd.hxx> #include <doc.hxx> // GetDoc() -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <txtfld.hxx> #include <fmtfld.hxx> #include <txatbase.hxx> @@ -380,25 +374,27 @@ static bool lcl_HaveCommonAttributes( IStyleAccess& rStyleAccess, SwTxtNode& SwTxtNode::Insert( xub_Unicode c, const SwIndex &rIdx ) { - xub_StrLen nOrigLen = aText.Len(); + xub_StrLen nOrigLen = m_Text.Len(); - ASSERT( rIdx <= nOrigLen, "Array ueberindiziert." ); - ASSERT( nOrigLen < STRING_LEN, "USHRT_MAX ueberschritten." ); + ASSERT( rIdx <= nOrigLen, "SwTxtNode::Insert: invalid index." ); + ASSERT( nOrigLen < STRING_LEN, + "SwTxtNode::Insert: node text with insertion > STRING_LEN." ); - if( nOrigLen == aText.Insert( c, rIdx.GetIndex() ).Len() ) + if ( nOrigLen == m_Text.Insert( c, rIdx.GetIndex() ).Len() ) return *this; Update(rIdx,1); // leere Hints und Feldattribute an rIdx.GetIndex suchen - if( pSwpHints ) + if ( HasHints() ) { USHORT* pEndIdx; - for( USHORT i=0; i < pSwpHints->Count() && - rIdx >= *(*pSwpHints)[i]->GetStart(); ++i) + for ( USHORT i=0; i < m_pSwpHints->Count() && + rIdx >= *(*m_pSwpHints)[i]->GetStart(); ++i) { - SwTxtAttr *pHt = pSwpHints->GetHt(i); - if( 0 != ( pEndIdx = pHt->GetEnd()) ) + SwTxtAttr *pHt = m_pSwpHints->GetTextHint(i); + pEndIdx = pHt->GetEnd(); + if ( pEndIdx ) { // leere Hints an rIdx.GetIndex ? BOOL bEmpty = *pEndIdx == *pHt->GetStart() @@ -406,7 +402,7 @@ SwTxtNode& SwTxtNode::Insert( xub_Unicode c, const SwIndex &rIdx ) if( bEmpty ) { - pSwpHints->DeleteAtPos(i); + m_pSwpHints->DeleteAtPos(i); if( bEmpty ) *pHt->GetStart() -= 1; else @@ -415,8 +411,7 @@ SwTxtNode& SwTxtNode::Insert( xub_Unicode c, const SwIndex &rIdx ) } } } - if ( pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); + TryDeleteSwpHints(); } // den Frames Bescheid sagen SwInsChr aHint( rIdx.GetIndex()-1 ); @@ -431,23 +426,22 @@ inline BOOL InRange(xub_StrLen nIdx, xub_StrLen nStart, xub_StrLen nEnd) { /* * void SwTxtNode::RstAttr(const SwIndex &rIdx, USHORT nLen) * - * loescht alle Attribute ab der Position rIdx ueber eine Laenge - * von nLen. + * Deletes all attributes, starting at position rIdx, for length nLen. */ -/* 5 Faelle: - * 1) Das Attribut liegt vollstaendig im Bereich: - * -> loeschen - * 2) Das Attributende liegt im Bereich: - * -> Loeschen, mit neuem Ende einfuegen - * 3) Der Attributanfang liegt im Bereich: - * -> Loeschen, mit neuem Anfang einfuegen - * 4) Das Attrib umfasst den Bereich: - * Aufsplitten, d.h. - * -> Loeschen, mit alten Anfang und Anfang des Bereiches einfuegen - * -> Neues Attribut mit Ende des Bereiches und altem Ende einfuegen - * 5) Das Attribut liegt ausserhalb des Bereiches - * -> nichts tun. +/* 5 cases: + * 1) The attribute is completely in the deletion range: + * -> delete it + * 2) The end of the attribute is in the deletion range: + * -> delete it, then re-insert it with new end + * 3) The start of the attribute is in the deletion range: + * -> delete it, then re-insert it with new start + * 4) The attribute contains the deletion range: + * Split, i.e., + * -> Delete, re-insert from old start to start of deletion range + * -> insert new attribute from end of deletion range to old end + * 5) The attribute is outside the deletion range + * -> nothing to do */ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, @@ -466,8 +460,8 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, BOOL bChanged = FALSE; - // nMin und nMax werden invers auf das Maximum bzw. Minimum gesetzt. - xub_StrLen nMin = aText.Len(); + // nMin and nMax initialized to maximum / minimum (inverse) + xub_StrLen nMin = m_Text.Len(); xub_StrLen nMax = nStt; const BOOL bNoLen = !nMin; @@ -477,16 +471,16 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, // They may not be forgotten inside the "Forget" function //std::vector< const SwTxtAttr* > aNewAttributes; - // durch das Attribute-Array, bis der Anfang des Geltungsbereiches - // des Attributs hinter dem Bereich liegt - while( (i < pSwpHints->Count()) && - ((( nAttrStart = *(*pSwpHints)[i]->GetStart()) < nEnd ) - || nLen==0) ) + // iterate over attribute array until start of attribute is behind + // deletion range + while ((i < m_pSwpHints->Count()) && + ((( nAttrStart = *(*m_pSwpHints)[i]->GetStart()) < nEnd ) || nLen==0) ) { - pHt = pSwpHints->GetHt(i); + pHt = m_pSwpHints->GetTextHint(i); - // Attribute ohne Ende bleiben drin! - if ( 0 == (pAttrEnd=pHt->GetEnd()) ) + // attributes without end stay in! + pAttrEnd = pHt->GetEnd(); + if ( !pAttrEnd ) { i++; continue; @@ -524,10 +518,8 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, RES_TXTATR_TOXMARK == pHt->Which(); } - if( bSkipAttr ) - + if ( bSkipAttr ) { - // Es sollen nur Attribute mit nWhich beachtet werden i++; continue; } @@ -550,7 +542,7 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, { const xub_StrLen nAttrEnd = *pAttrEnd; - pSwpHints->DeleteAtPos(i); + m_pSwpHints->DeleteAtPos(i); DestroyAttr( pHt ); if ( pStyleHandle.get() ) @@ -559,9 +551,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); } - // falls das letzte Attribut ein Field ist, loescht - // dieses das HintsArray !!! - if( !pSwpHints ) + // if the last attribute is a Field, the HintsArray is + // deleted! + if ( !m_pSwpHints ) break; //JP 26.11.96: @@ -576,9 +568,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, } else // Fall: 3 { - pSwpHints->NoteInHistory( pHt ); + m_pSwpHints->NoteInHistory( pHt ); *pHt->GetStart() = nEnd; - pSwpHints->NoteInHistory( pHt, TRUE ); + m_pSwpHints->NoteInHistory( pHt, TRUE ); if ( pStyleHandle.get() && nAttrStart < nEnd ) { @@ -603,9 +595,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, const xub_StrLen nAttrEnd = *pAttrEnd; - pSwpHints->NoteInHistory( pHt ); + m_pSwpHints->NoteInHistory( pHt ); *pAttrEnd = nStt; - pSwpHints->NoteInHistory( pHt, TRUE ); + m_pSwpHints->NoteInHistory( pHt, TRUE ); if ( pStyleHandle.get() ) { @@ -622,9 +614,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, nMax = *pAttrEnd; bChanged = TRUE; xub_StrLen nTmpEnd = *pAttrEnd; - pSwpHints->NoteInHistory( pHt ); + m_pSwpHints->NoteInHistory( pHt ); *pAttrEnd = nStt; - pSwpHints->NoteInHistory( pHt, TRUE ); + m_pSwpHints->NoteInHistory( pHt, TRUE ); if ( pStyleHandle.get() && nStt < nEnd ) { @@ -654,13 +646,12 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, ++i; } - if ( pSwpHints && pSwpHints->CanBeDeleted() ) - DELETEZ( pSwpHints ); - if(bChanged) + TryDeleteSwpHints(); + if (bChanged) { - if ( pSwpHints ) + if ( HasHints() ) { - ((SwpHintsArr*)pSwpHints)->Resort(); + m_pSwpHints->Resort(); } //TxtFrm's reagieren auf aHint, andere auf aNew SwUpdateAttr aHint( nMin, nMax, 0 ); @@ -683,13 +674,12 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, * einen leeren String. *************************************************************************/ - - XubString SwTxtNode::GetCurWord( xub_StrLen nPos ) const { - ASSERT( nPos<=aText.Len() , "SwTxtNode::GetCurWord: Pos hinter String?"); - if (!aText.Len()) - return aText; + ASSERT( nPos <= m_Text.Len(), "SwTxtNode::GetCurWord: invalid index." ); + + if (!m_Text.Len()) + return m_Text; Boundary aBndry; const uno::Reference< XBreakIterator > &rxBreak = pBreakIt->xBreak; @@ -698,16 +688,19 @@ XubString SwTxtNode::GetCurWord( xub_StrLen nPos ) const sal_Int16 nWordType = WordType::DICTIONARY_WORD; lang::Locale aLocale( pBreakIt->GetLocale( GetLang( nPos ) ) ); #ifdef DEBUG - BOOL bBegin = rxBreak->isBeginWord( aText, nPos, aLocale, nWordType ); - BOOL bEnd = rxBreak->isEndWord ( aText, nPos, aLocale, nWordType ); + BOOL bBegin = rxBreak->isBeginWord( m_Text, nPos, aLocale, nWordType ); + BOOL bEnd = rxBreak->isEndWord ( m_Text, nPos, aLocale, nWordType ); (void)bBegin; (void)bEnd; #endif - aBndry = rxBreak->getWordBoundary( aText, nPos, aLocale, nWordType, TRUE ); + aBndry = + rxBreak->getWordBoundary( m_Text, nPos, aLocale, nWordType, TRUE ); // if no word was found use previous word (if any) if (aBndry.startPos == aBndry.endPos) - aBndry = rxBreak->previousWord( aText, nPos, aLocale, nWordType ); + { + aBndry = rxBreak->previousWord( m_Text, nPos, aLocale, nWordType ); + } } // check if word was found and if it uses a symbol font, if so @@ -715,7 +708,7 @@ XubString SwTxtNode::GetCurWord( xub_StrLen nPos ) const if (aBndry.endPos != aBndry.startPos && IsSymbol( (xub_StrLen)aBndry.startPos )) aBndry.endPos = aBndry.startPos; - return aText.Copy( static_cast<xub_StrLen>(aBndry.startPos), + return m_Text.Copy( static_cast<xub_StrLen>(aBndry.startPos), static_cast<xub_StrLen>(aBndry.endPos - aBndry.startPos) ); } @@ -865,19 +858,18 @@ USHORT SwTxtNode::Spell(SwSpellArgs* pArgs) xub_StrLen nBegin, nEnd; // modify string according to redline information and hidden text - const XubString aOldTxt( aText ); + const XubString aOldTxt( m_Text ); const bool bRestoreString = - lcl_MaskRedlinesAndHiddenText( *this, aText, 0, aText.Len() ) > 0; + lcl_MaskRedlinesAndHiddenText( *this, m_Text, 0, m_Text.Len() ) > 0; if ( pArgs->pStartNode != this ) nBegin = 0; else nBegin = pArgs->pStartIdx->GetIndex(); - if ( pArgs->pEndNode != this ) - nEnd = aText.Len(); - else - nEnd = pArgs->pEndIdx->GetIndex(); + nEnd = ( pArgs->pEndNode != this ) + ? m_Text.Len() + : pArgs->pEndIdx->GetIndex(); pArgs->xSpellAlt = NULL; @@ -893,12 +885,16 @@ USHORT SwTxtNode::Spell(SwSpellArgs* pArgs) // Text has been checked but there is an invalid range in the wrong list // // Nothing has to be done for case 1. - if( ( IsWrongDirty() || GetWrong() ) && aText.Len() ) + if ( ( IsWrongDirty() || GetWrong() ) && m_Text.Len() ) { - if( nBegin > aText.Len() ) - nBegin = aText.Len(); - if( nEnd > aText.Len() ) - nEnd = aText.Len(); + if ( nBegin > m_Text.Len() ) + { + nBegin = m_Text.Len(); + } + if ( nEnd > m_Text.Len() ) + { + nEnd = m_Text.Len(); + } // if(!IsWrongDirty()) { @@ -907,7 +903,9 @@ USHORT SwTxtNode::Spell(SwSpellArgs* pArgs) { // reset original text if ( bRestoreString ) - aText = aOldTxt; + { + m_Text = aOldTxt; + } return 0; } if(nTemp > nBegin) @@ -917,7 +915,7 @@ USHORT SwTxtNode::Spell(SwSpellArgs* pArgs) // In case 2. we pass the wrong list to the scanned, because only // the words in the wrong list have to be checked - SwScanner aScanner( *this, aText, 0, 0, + SwScanner aScanner( *this, m_Text, 0, 0, WordType::DICTIONARY_WORD, nBegin, nEnd ); while( !pArgs->xSpellAlt.is() && aScanner.NextWord() ) @@ -970,7 +968,9 @@ USHORT SwTxtNode::Spell(SwSpellArgs* pArgs) // reset original text if ( bRestoreString ) - aText = aOldTxt; + { + m_Text = aOldTxt; + } return pArgs->xSpellAlt.is() ? 1 : 0; } @@ -1025,28 +1025,27 @@ USHORT SwTxtNode::Convert( SwConversionArgs &rArgs ) } else nTextBegin = rArgs.pStartIdx->GetIndex(); - if (nTextBegin > aText.Len()) - nTextBegin = aText.Len(); - // - if ( rArgs.pEndNode != this ) - nTextEnd = aText.Len(); - else - nTextEnd = rArgs.pEndIdx->GetIndex(); - if (nTextEnd > aText.Len()) - nTextEnd = aText.Len(); + if (nTextBegin > m_Text.Len()) + { + nTextBegin = m_Text.Len(); + } + + nTextEnd = ( rArgs.pEndNode != this ) + ? m_Text.Len() + : ::std::min( rArgs.pEndIdx->GetIndex(), m_Text.Len() ); rArgs.aConvText = rtl::OUString(); // modify string according to redline information and hidden text - const XubString aOldTxt( aText ); + const XubString aOldTxt( m_Text ); const bool bRestoreString = - lcl_MaskRedlinesAndHiddenText( *this, aText, 0, aText.Len() ) > 0; + lcl_MaskRedlinesAndHiddenText( *this, m_Text, 0, m_Text.Len() ) > 0; sal_Bool bFound = sal_False; xub_StrLen nBegin = nTextBegin; xub_StrLen nLen = 0; LanguageType nLangFound = LANGUAGE_NONE; - if (!aText.Len()) + if (!m_Text.Len()) { if (rArgs.bAllowImplicitChangesForNotConvertibleText) { @@ -1075,7 +1074,9 @@ USHORT SwTxtNode::Convert( SwConversionArgs &rArgs ) // which becomes 65535 when converted to xub_StrLen, // and thus must be cut to the end of the actual string. if (nChPos == (xub_StrLen) -1) - nChPos = aText.Len(); + { + nChPos = m_Text.Len(); + } nLen = nChPos - nBegin; bFound = bLangOk && nLen > 0; @@ -1114,9 +1115,9 @@ USHORT SwTxtNode::Convert( SwConversionArgs &rArgs ) if (bFound && bInSelection) // convertible text found within selection/range? { - const XubString aTxtPortion = aText.Copy( nBegin, nLen ); - DBG_ASSERT( aText.Len() > 0, "convertible text portion missing!" ); - rArgs.aConvText = aText.Copy( nBegin, nLen ); + const XubString aTxtPortion = m_Text.Copy( nBegin, nLen ); + DBG_ASSERT( m_Text.Len() > 0, "convertible text portion missing!" ); + rArgs.aConvText = m_Text.Copy( nBegin, nLen ); rArgs.nConvTextLang = nLangFound; // position where to start looking in next iteration (after current ends) @@ -1129,7 +1130,9 @@ USHORT SwTxtNode::Convert( SwConversionArgs &rArgs ) // restore original text if ( bRestoreString ) - aText = aOldTxt; + { + m_Text = aOldTxt; + } return rArgs.aConvText.getLength() ? 1 : 0; } @@ -1153,15 +1156,17 @@ SwRect SwTxtFrm::_AutoSpell( const SwCntntNode* pActNode, const SwViewOption& rV SwAutoCompleteWord& rACW = SwDoc::GetAutoCompleteWords(); // modify string according to redline information and hidden text - const XubString aOldTxt( pNode->aText ); + const XubString aOldTxt( pNode->GetTxt() ); const bool bRestoreString = - lcl_MaskRedlinesAndHiddenText( *pNode, pNode->aText, 0, pNode->aText.Len() ) > 0; + lcl_MaskRedlinesAndHiddenText( *pNode, pNode->m_Text, + 0, pNode->GetTxt().Len() ) > 0; // a change of data indicates that at least one word has been modified - const sal_Bool bRedlineChg = ( pNode->aText.GetBuffer() != aOldTxt.GetBuffer() ); + const sal_Bool bRedlineChg = + ( pNode->GetTxt().GetBuffer() != aOldTxt.GetBuffer() ); xub_StrLen nBegin = 0; - xub_StrLen nEnd = pNode->aText.Len(); + xub_StrLen nEnd = pNode->GetTxt().Len(); xub_StrLen nInsertPos = 0; xub_StrLen nChgStart = STRING_LEN; xub_StrLen nChgEnd = 0; @@ -1177,8 +1182,10 @@ SwRect SwTxtFrm::_AutoSpell( const SwCntntNode* pActNode, const SwViewOption& rV if( STRING_LEN != nBegin ) { nEnd = pNode->GetWrong()->GetEndInv(); - if ( nEnd > pNode->aText.Len() ) - nEnd = pNode->aText.Len(); + if ( nEnd > pNode->GetTxt().Len() ) + { + nEnd = pNode->GetTxt().Len(); + } } // get word around nBegin, we start at nBegin - 1 @@ -1188,8 +1195,10 @@ SwRect SwTxtFrm::_AutoSpell( const SwCntntNode* pActNode, const SwViewOption& rV --nBegin; LanguageType eActLang = pNode->GetLang( nBegin ); - Boundary aBound = pBreakIt->xBreak->getWordBoundary( pNode->aText, nBegin, - pBreakIt->GetLocale( eActLang ), WordType::DICTIONARY_WORD, TRUE ); + Boundary aBound = + pBreakIt->xBreak->getWordBoundary( pNode->GetTxt(), nBegin, + pBreakIt->GetLocale( eActLang ), + WordType::DICTIONARY_WORD, TRUE ); nBegin = xub_StrLen(aBound.startPos); } @@ -1216,8 +1225,8 @@ SwRect SwTxtFrm::_AutoSpell( const SwCntntNode* pActNode, const SwViewOption& rV uno::Reference< XSpellChecker1 > xSpell( ::GetSpellChecker() ); SwDoc* pDoc = pNode->GetDoc(); - SwScanner aScanner( *pNode, pNode->aText, 0, 0, WordType::DICTIONARY_WORD, - nBegin, nEnd); + SwScanner aScanner( *pNode, pNode->GetTxt(), 0, 0, + WordType::DICTIONARY_WORD, nBegin, nEnd); while( aScanner.NextWord() ) { @@ -1274,7 +1283,9 @@ SwRect SwTxtFrm::_AutoSpell( const SwCntntNode* pActNode, const SwViewOption& rV // reset original text // i63141 before calling GetCharRect(..) with formatting! if ( bRestoreString ) - pNode->aText = aOldTxt; + { + pNode->m_Text = aOldTxt; + } if( pNode->GetWrong() ) { if( bFresh ) @@ -1443,7 +1454,7 @@ void SwTxtFrm::CollectAutoCmplWrds( SwCntntNode* pActNode, xub_StrLen nActPos ) SwAutoCompleteWord& rACW = SwDoc::GetAutoCompleteWords(); xub_StrLen nBegin = 0; - xub_StrLen nEnd = pNode->aText.Len(); + xub_StrLen nEnd = pNode->GetTxt().Len(); xub_StrLen nLen; BOOL bACWDirty = FALSE, bAnyWrd = FALSE; @@ -1451,8 +1462,8 @@ void SwTxtFrm::CollectAutoCmplWrds( SwCntntNode* pActNode, xub_StrLen nActPos ) if( nBegin < nEnd ) { USHORT nCnt = 200; - SwScanner aScanner( *pNode, pNode->aText, 0, 0, WordType::DICTIONARY_WORD, - nBegin, nEnd ); + SwScanner aScanner( *pNode, pNode->GetTxt(), 0, 0, + WordType::DICTIONARY_WORD, nBegin, nEnd ); while( aScanner.NextWord() ) { nBegin = aScanner.GetBegin(); @@ -1492,8 +1503,8 @@ void SwTxtFrm::CollectAutoCmplWrds( SwCntntNode* pActNode, xub_StrLen nActPos ) BOOL SwTxtNode::Hyphenate( SwInterHyphInfo &rHyphInf ) { // Abkuerzung: am Absatz ist keine Sprache eingestellt: - if( LANGUAGE_NONE == USHORT( GetSwAttrSet().GetLanguage().GetLanguage() ) && - USHRT_MAX == GetLang( 0, aText.Len() ) ) + if ( LANGUAGE_NONE == USHORT( GetSwAttrSet().GetLanguage().GetLanguage() ) + && USHRT_MAX == GetLang( 0, m_Text.Len() ) ) { if( !rHyphInf.IsCheck() ) rHyphInf.SetNoLang( TRUE ); @@ -1642,12 +1653,14 @@ void SwTxtNode::TransliterateText( utl::TransliterationWrapper& rTrans, xub_StrLen nLen = nEndPos - nStt; Sequence <sal_Int32> aOffsets; - String sChgd( rTrans.transliterate( aText, nLang, nStt, nLen, - &aOffsets )); - if( !aText.Equals( sChgd, nStt, nLen ) ) + String sChgd( rTrans.transliterate( m_Text, nLang, nStt, nLen, + &aOffsets )); + if( !m_Text.Equals( sChgd, nStt, nLen ) ) { - if( pUndo ) + if ( pUndo ) + { pUndo->AddChanges( *this, nStt, nLen, aOffsets ); + } ReplaceTextOnly( nStt, nLen, sChgd, aOffsets ); } nStt = nEndPos; @@ -1661,7 +1674,7 @@ void SwTxtNode::ReplaceTextOnly( xub_StrLen nPos, xub_StrLen nLen, const XubString& rText, const Sequence<sal_Int32>& rOffsets ) { - aText.Replace( nPos, nLen, rText ); + m_Text.Replace( nPos, nLen, rText ); xub_StrLen nTLen = rText.Len(); const sal_Int32* pOffsets = rOffsets.getConstArray(); @@ -1721,8 +1734,8 @@ void SwTxtNode::CountWords( SwDocStat& rStat, } else { - String aOldStr( aText ); - String& rCastStr = (String&)aText; + String aOldStr( m_Text ); + String& rCastStr = const_cast<String&>(m_Text); // fills the deleted redlines and hidden ranges with cChar: const xub_Unicode cChar(' '); @@ -1839,53 +1852,59 @@ struct SwParaIdleData_Impl void SwTxtNode::InitSwParaStatistics( bool bNew ) { if ( bNew ) - pParaIdleData_Impl = new SwParaIdleData_Impl; - else if ( pParaIdleData_Impl ) { - delete pParaIdleData_Impl->pWrong; - delete pParaIdleData_Impl->pGrammarCheck; - delete pParaIdleData_Impl->pSmartTags; - delete pParaIdleData_Impl; - pParaIdleData_Impl = 0; + m_pParaIdleData_Impl = new SwParaIdleData_Impl; + } + else if ( m_pParaIdleData_Impl ) + { + delete m_pParaIdleData_Impl->pWrong; + delete m_pParaIdleData_Impl->pGrammarCheck; + delete m_pParaIdleData_Impl->pSmartTags; + delete m_pParaIdleData_Impl; + m_pParaIdleData_Impl = 0; } } void SwTxtNode::SetWrong( SwWrongList* pNew, bool bDelete ) { - if ( pParaIdleData_Impl ) + if ( m_pParaIdleData_Impl ) { if ( bDelete ) - delete pParaIdleData_Impl->pWrong; - pParaIdleData_Impl->pWrong = pNew; + { + delete m_pParaIdleData_Impl->pWrong; + } + m_pParaIdleData_Impl->pWrong = pNew; } } SwWrongList* SwTxtNode::GetWrong() { - return pParaIdleData_Impl ? pParaIdleData_Impl->pWrong : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->pWrong : 0; } // --> OD 2008-05-27 #i71360# const SwWrongList* SwTxtNode::GetWrong() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->pWrong : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->pWrong : 0; } // <-- void SwTxtNode::SetGrammarCheck( SwGrammarMarkUp* pNew, bool bDelete ) { - if ( pParaIdleData_Impl ) + if ( m_pParaIdleData_Impl ) { if ( bDelete ) - delete pParaIdleData_Impl->pGrammarCheck; - pParaIdleData_Impl->pGrammarCheck = pNew; + { + delete m_pParaIdleData_Impl->pGrammarCheck; + } + m_pParaIdleData_Impl->pGrammarCheck = pNew; } } SwGrammarMarkUp* SwTxtNode::GetGrammarCheck() { - return pParaIdleData_Impl ? pParaIdleData_Impl->pGrammarCheck : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->pGrammarCheck : 0; } void SwTxtNode::SetSmartTags( SwWrongList* pNew, bool bDelete ) @@ -1893,81 +1912,97 @@ void SwTxtNode::SetSmartTags( SwWrongList* pNew, bool bDelete ) ASSERT( !pNew || SwSmartTagMgr::Get().IsSmartTagsEnabled(), "Weird - we have a smart tag list without any recognizers?" ) - if ( pParaIdleData_Impl ) + if ( m_pParaIdleData_Impl ) { if ( bDelete ) - delete pParaIdleData_Impl->pSmartTags; - pParaIdleData_Impl->pSmartTags = pNew; + { + delete m_pParaIdleData_Impl->pSmartTags; + } + m_pParaIdleData_Impl->pSmartTags = pNew; } } SwWrongList* SwTxtNode::GetSmartTags() { - return pParaIdleData_Impl ? pParaIdleData_Impl->pSmartTags : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->pSmartTags : 0; } void SwTxtNode::SetParaNumberOfWords( ULONG nNew ) const { - if ( pParaIdleData_Impl ) - pParaIdleData_Impl->nNumberOfWords = nNew; + if ( m_pParaIdleData_Impl ) + { + m_pParaIdleData_Impl->nNumberOfWords = nNew; + } } ULONG SwTxtNode::GetParaNumberOfWords() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->nNumberOfWords : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->nNumberOfWords : 0; } void SwTxtNode::SetParaNumberOfChars( ULONG nNew ) const { - if ( pParaIdleData_Impl ) - pParaIdleData_Impl->nNumberOfChars = nNew; + if ( m_pParaIdleData_Impl ) + { + m_pParaIdleData_Impl->nNumberOfChars = nNew; + } } ULONG SwTxtNode::GetParaNumberOfChars() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->nNumberOfChars : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->nNumberOfChars : 0; } void SwTxtNode::SetWordCountDirty( bool bNew ) const { - if ( pParaIdleData_Impl ) - pParaIdleData_Impl->bWordCountDirty = bNew; + if ( m_pParaIdleData_Impl ) + { + m_pParaIdleData_Impl->bWordCountDirty = bNew; + } } bool SwTxtNode::IsWordCountDirty() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->bWordCountDirty : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->bWordCountDirty : 0; } void SwTxtNode::SetWrongDirty( bool bNew ) const { - if ( pParaIdleData_Impl ) - pParaIdleData_Impl->bWrongDirty = bNew; + if ( m_pParaIdleData_Impl ) + { + m_pParaIdleData_Impl->bWrongDirty = bNew; + } } bool SwTxtNode::IsWrongDirty() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->bWrongDirty : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->bWrongDirty : 0; } void SwTxtNode::SetGrammarCheckDirty( bool bNew ) const { - if ( pParaIdleData_Impl ) - pParaIdleData_Impl->bGrammarCheckDirty = bNew; + if ( m_pParaIdleData_Impl ) + { + m_pParaIdleData_Impl->bGrammarCheckDirty = bNew; + } } bool SwTxtNode::IsGrammarCheckDirty() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->bGrammarCheckDirty : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->bGrammarCheckDirty : 0; } void SwTxtNode::SetSmartTagDirty( bool bNew ) const { - if ( pParaIdleData_Impl ) - pParaIdleData_Impl->bSmartTagDirty = bNew; + if ( m_pParaIdleData_Impl ) + { + m_pParaIdleData_Impl->bSmartTagDirty = bNew; + } } bool SwTxtNode::IsSmartTagDirty() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->bSmartTagDirty : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->bSmartTagDirty : 0; } void SwTxtNode::SetAutoCompleteWordDirty( bool bNew ) const { - if ( pParaIdleData_Impl ) - pParaIdleData_Impl->bAutoComplDirty = bNew; + if ( m_pParaIdleData_Impl ) + { + m_pParaIdleData_Impl->bAutoComplDirty = bNew; + } } bool SwTxtNode::IsAutoCompleteWordDirty() const { - return pParaIdleData_Impl ? pParaIdleData_Impl->bAutoComplDirty : 0; + return m_pParaIdleData_Impl ? m_pParaIdleData_Impl->bAutoComplDirty : 0; } // // Paragraph statistics end diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 776dee62f443..fe8f375f09b6 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -72,41 +72,46 @@ #include <svx/brkitem.hxx> #include <bookmrk.hxx> -SV_IMPL_PTRARR( SwpHstry, SwHstryHintPtr) +SV_IMPL_PTRARR( SwpHstry, SwHistoryHintPtr) -String SwHstryHint::GetDescription() const +String SwHistoryHint::GetDescription() const { return String(); } -SwSetFmtHint::SwSetFmtHint( const SfxPoolItem* pFmtHt, ULONG nNd ) - : SwHstryHint( HSTRY_SETFMTHNT ), - pAttr( pFmtHt->Clone() ), - nNode( nNd ) +SwHistorySetFmt::SwHistorySetFmt( const SfxPoolItem* pFmtHt, ULONG nNd ) + : SwHistoryHint( HSTRY_SETFMTHNT ) + , m_pAttr( pFmtHt->Clone() ) + , m_nNodeIndex( nNd ) { - switch( pAttr->Which() ) + switch ( m_pAttr->Which() ) { - case RES_PAGEDESC: - ((SwFmtPageDesc*)pAttr)->ChgDefinedIn( 0 ); - break; - case RES_PARATR_DROP: - ((SwFmtDrop*)pAttr)->ChgDefinedIn( 0 ); - break; - case RES_BOXATR_FORMULA: + case RES_PAGEDESC: + static_cast<SwFmtPageDesc&>(*m_pAttr).ChgDefinedIn( 0 ); + break; + case RES_PARATR_DROP: + static_cast<SwFmtDrop&>(*m_pAttr).ChgDefinedIn( 0 ); + break; + case RES_BOXATR_FORMULA: { //JP 30.07.98: Bug 54295 - Formeln immer im Klartext speichern - SwTblBoxFormula& rNew = *(SwTblBoxFormula*)pAttr; - if( rNew.IsIntrnlName() ) + SwTblBoxFormula& rNew = static_cast<SwTblBoxFormula&>(*m_pAttr); + if ( rNew.IsIntrnlName() ) { - const SwTblBoxFormula& rOld = *(SwTblBoxFormula*)pFmtHt; + const SwTblBoxFormula& rOld = + *static_cast<const SwTblBoxFormula*>(pFmtHt); const SwNode* pNd = rOld.GetNodeOfFormula(); - if( pNd && 0 != (pNd = pNd->FindTableNode() )) + if ( pNd ) { - SwTableFmlUpdate aMsgHnt( &((SwTableNode*)pNd)->GetTable() ); - aMsgHnt.eFlags = TBL_BOXNAME; - rNew.ChgDefinedIn( rOld.GetDefinedIn() ); - rNew.ChangeState( &aMsgHnt ); + const SwTableNode* pTableNode = pNd->FindTableNode(); + if (pTableNode) + { + SwTableFmlUpdate aMsgHnt( &pTableNode->GetTable() ); + aMsgHnt.eFlags = TBL_BOXNAME; + rNew.ChgDefinedIn( rOld.GetDefinedIn() ); + rNew.ChangeState( &aMsgHnt ); + } } } rNew.ChgDefinedIn( 0 ); @@ -115,15 +120,15 @@ SwSetFmtHint::SwSetFmtHint( const SfxPoolItem* pFmtHt, ULONG nNd ) } } -String SwSetFmtHint::GetDescription() const +String SwHistorySetFmt::GetDescription() const { String aResult ; - USHORT nWhich = pAttr->Which(); + USHORT nWhich = m_pAttr->Which(); switch (nWhich) { case RES_BREAK: - switch (((SvxFmtBreakItem *) pAttr)->GetBreak()) + switch ((static_cast<SvxFmtBreakItem &>(*m_pAttr)).GetBreak()) { case SVX_BREAK_PAGE_BEFORE: case SVX_BREAK_PAGE_AFTER: @@ -148,58 +153,73 @@ String SwSetFmtHint::GetDescription() const return aResult; } -void SwSetFmtHint::SetInDoc( SwDoc* pDoc, BOOL bTmpSet ) +void SwHistorySetFmt::SetInDoc( SwDoc* pDoc, bool bTmpSet ) { - SwNode * pNode = pDoc->GetNodes()[ nNode ]; - if( pNode->IsCntntNode() ) + SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ]; + if ( pNode->IsCntntNode() ) { - ((SwCntntNode*)pNode)->SetAttr( *pAttr ); + static_cast<SwCntntNode*>(pNode)->SetAttr( *m_pAttr ); } - else if( pNode->IsTableNode() ) - ((SwTableNode*)pNode)->GetTable().GetFrmFmt()->SetFmtAttr( *pAttr ); - else if( pNode->IsStartNode() && - SwTableBoxStartNode == ((SwStartNode*)pNode)->GetStartNodeType() ) + else if ( pNode->IsTableNode() ) + { + static_cast<SwTableNode*>(pNode)->GetTable().GetFrmFmt()->SetFmtAttr( + *m_pAttr ); + } + else if ( pNode->IsStartNode() && (SwTableBoxStartNode == + static_cast<SwStartNode*>(pNode)->GetStartNodeType()) ) { SwTableNode* pTNd = pNode->FindTableNode(); - SwTableBox* pBox; - if( pTNd && 0 != ( pBox = pTNd->GetTable().GetTblBox( nNode ))) - pBox->ClaimFrmFmt()->SetFmtAttr( *pAttr ); + if ( pTNd ) + { + SwTableBox* pBox = pTNd->GetTable().GetTblBox( m_nNodeIndex ); + if (pBox) + { + pBox->ClaimFrmFmt()->SetFmtAttr( *m_pAttr ); + } + } } - if( !bTmpSet ) - DELETEZ( pAttr ); + if ( !bTmpSet ) + { + m_pAttr.reset(); + } } -SwSetFmtHint::~SwSetFmtHint() +SwHistorySetFmt::~SwHistorySetFmt() { - delete pAttr; } // --> OD 2008-02-27 #refactorlists# - removed <rDoc> -SwResetFmtHint::SwResetFmtHint( const SfxPoolItem* pFmtHt, ULONG nNodeIdx ) +SwHistoryResetFmt::SwHistoryResetFmt(const SfxPoolItem* pFmtHt, ULONG nNodeIdx) // <-- - : SwHstryHint( HSTRY_RESETFMTHNT ), - nNode( nNodeIdx ), - nWhich( pFmtHt->Which() ) + : SwHistoryHint( HSTRY_RESETFMTHNT ) + , m_nNodeIndex( nNodeIdx ) + , m_nWhich( pFmtHt->Which() ) { } -void SwResetFmtHint::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistoryResetFmt::SetInDoc( SwDoc* pDoc, bool ) { - SwNode * pNode = pDoc->GetNodes()[ nNode ]; + SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ]; if ( pNode->IsCntntNode() ) { - ((SwCntntNode*)pNode)->ResetAttr( nWhich ); + static_cast<SwCntntNode*>(pNode)->ResetAttr( m_nWhich ); + } + else if ( pNode->IsTableNode() ) + { + static_cast<SwTableNode*>(pNode)->GetTable().GetFrmFmt()-> + ResetFmtAttr( m_nWhich ); } - else if( pNode->IsTableNode() ) - ((SwTableNode*)pNode)->GetTable().GetFrmFmt()->ResetFmtAttr( nWhich ); } -SwSetTxtHint::SwSetTxtHint( SwTxtAttr* pTxtHt, ULONG nNodePos ) - : SwHstryHint( HSTRY_SETTXTHNT ) +SwHistorySetTxt::SwHistorySetTxt( SwTxtAttr* pTxtHt, ULONG nNodePos ) + : SwHistoryHint( HSTRY_SETTXTHNT ) + , m_nNodeIndex( nNodePos ) + , m_nStart( *pTxtHt->GetStart() ) + , m_nEnd( *pTxtHt->GetAnyEnd() ) { // !! Achtung: folgende Attribute erzeugen keine FormatAttribute: // - NoLineBreak, NoHypen, Inserted, Deleted @@ -208,354 +228,382 @@ SwSetTxtHint::SwSetTxtHint( SwTxtAttr* pTxtHt, ULONG nNodePos ) // ein bisschen kompliziert, aber ist Ok so: erst vom default // eine Kopie und dann die Werte aus dem Text Attribut zuweisen USHORT nWhich = pTxtHt->Which(); - if( RES_TXTATR_CHARFMT == nWhich ) - pAttr = new SwFmtCharFmt( pTxtHt->GetCharFmt().GetCharFmt() ); + if ( RES_TXTATR_CHARFMT == nWhich ) + { + m_pAttr.reset( new SwFmtCharFmt( pTxtHt->GetCharFmt().GetCharFmt() ) ); + } else - pAttr = pTxtHt->GetAttr().Clone(); - nNode = nNodePos; - nStart = *pTxtHt->GetStart(); - nEnd = *pTxtHt->GetAnyEnd(); + { + m_pAttr.reset( pTxtHt->GetAttr().Clone() ); + } } -SwSetTxtHint::~SwSetTxtHint() +SwHistorySetTxt::~SwHistorySetTxt() { - delete pAttr; } -void SwSetTxtHint::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistorySetTxt::SetInDoc( SwDoc* pDoc, bool ) { - if( !pAttr ) + if ( !m_pAttr.get() ) return; - if( RES_TXTATR_CHARFMT == pAttr->Which() ) + if ( RES_TXTATR_CHARFMT == m_pAttr->Which() ) { - // befrage das Doc, ob das CharFmt noch vorhanden ist ! - if( USHRT_MAX == pDoc->GetCharFmts()->GetPos( - ((SwFmtCharFmt*)pAttr)->GetCharFmt() ) ) - return; // nicht setzen, Format nicht vorhanden + // ask the Doc if the CharFmt still exists + if ( USHRT_MAX == pDoc->GetCharFmts()->GetPos( + (static_cast<SwFmtCharFmt&>(*m_pAttr)).GetCharFmt() ) ) + return; // do not set, format does not exist } - SwTxtNode * pTxtNd = pDoc->GetNodes()[ nNode ]->GetTxtNode(); - ASSERT( pTxtNd, "Undo-TxtAttr: kein TextNode" ); + SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode(); + ASSERT( pTxtNd, "SwHistorySetTxt::SetInDoc: not a TextNode" ); - if( pTxtNd ) - pTxtNd->InsertItem( *pAttr, nStart, nEnd, - nsSetAttrMode::SETATTR_NOTXTATRCHR | nsSetAttrMode::SETATTR_NOHINTADJUST ); + if ( pTxtNd ) + { + pTxtNd->InsertItem( *m_pAttr, m_nStart, m_nEnd, + nsSetAttrMode::SETATTR_NOTXTATRCHR | + nsSetAttrMode::SETATTR_NOHINTADJUST ); + } } -SwSetTxtFldHint::SwSetTxtFldHint( SwTxtFld* pTxtFld, ULONG nNodePos ) - : SwHstryHint( HSTRY_SETTXTFLDHNT ), pFldType( 0 ) +SwHistorySetTxtFld::SwHistorySetTxtFld( SwTxtFld* pTxtFld, ULONG nNodePos ) + : SwHistoryHint( HSTRY_SETTXTFLDHNT ) + , m_pFld( new SwFmtFld( *pTxtFld->GetFld().GetFld() ) ) + , m_pFldType( 0 ) { - pFld = new SwFmtFld( *pTxtFld->GetFld().GetFld() ); - - // nur kopieren wenn kein Sys-FieldType - SwDoc* pDoc = (SwDoc*)pTxtFld->GetTxtNode().GetDoc(); + // only copy if not Sys-FieldType + SwDoc* pDoc = pTxtFld->GetTxtNode().GetDoc(); - nFldWhich = pFld->GetFld()->GetTyp()->Which(); - if( nFldWhich == RES_DBFLD || - nFldWhich == RES_USERFLD || - nFldWhich == RES_SETEXPFLD || - nFldWhich == RES_DDEFLD || - !pDoc->GetSysFldType( nFldWhich )) + m_nFldWhich = m_pFld->GetFld()->GetTyp()->Which(); + if (m_nFldWhich == RES_DBFLD || + m_nFldWhich == RES_USERFLD || + m_nFldWhich == RES_SETEXPFLD || + m_nFldWhich == RES_DDEFLD || + !pDoc->GetSysFldType( m_nFldWhich )) { - pFldType = pFld->GetFld()->GetTyp()->Copy(); - pFld->GetFld()->ChgTyp( pFldType ); // Fieldtype umsetzen + m_pFldType.reset( m_pFld->GetFld()->GetTyp()->Copy() ); + m_pFld->GetFld()->ChgTyp( m_pFldType.get() ); // change field type } - nNode = nNodePos; - nPos = *pTxtFld->GetStart(); + m_nNodeIndex = nNodePos; + m_nPos = *pTxtFld->GetStart(); } -String SwSetTxtFldHint::GetDescription() const +String SwHistorySetTxtFld::GetDescription() const { - return pFld->GetFld()->GetDescription();; + return m_pFld->GetFld()->GetDescription();; } -SwSetTxtFldHint::~SwSetTxtFldHint() +SwHistorySetTxtFld::~SwHistorySetTxtFld() { - delete pFld; - delete pFldType; } -void SwSetTxtFldHint::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistorySetTxtFld::SetInDoc( SwDoc* pDoc, bool ) { - if( !pFld ) + if ( !m_pFld.get() ) return; - SwFieldType* pNewFldType = pFldType; - if( !pNewFldType ) - pNewFldType = pDoc->GetSysFldType( nFldWhich ); + SwFieldType* pNewFldType = m_pFldType.get(); + if ( !pNewFldType ) + { + pNewFldType = pDoc->GetSysFldType( m_nFldWhich ); + } else - // den Type am Dokuement anmelden - pNewFldType = pDoc->InsertFldType( *pFldType ); + { + // register type with the document + pNewFldType = pDoc->InsertFldType( *m_pFldType ); + } - pFld->GetFld()->ChgTyp( pNewFldType ); // Fieldtype umsetzen + m_pFld->GetFld()->ChgTyp( pNewFldType ); // change field type - SwTxtNode * pTxtNd = pDoc->GetNodes()[ nNode ]->GetTxtNode(); - ASSERT( pTxtNd, "Undo-TxtAttr: kein TextNode" ); + SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode(); + ASSERT( pTxtNd, "SwHistorySetTxtFld: no TextNode" ); - if( pTxtNd ) - pTxtNd->InsertItem( *pFld, nPos, nPos, nsSetAttrMode::SETATTR_NOTXTATRCHR ); + if ( pTxtNd ) + { + pTxtNd->InsertItem( *m_pFld, m_nPos, m_nPos, + nsSetAttrMode::SETATTR_NOTXTATRCHR ); + } } -SwSetRefMarkHint::SwSetRefMarkHint( SwTxtRefMark* pTxtHt, ULONG nNodePos ) - : SwHstryHint( HSTRY_SETREFMARKHNT ) +SwHistorySetRefMark::SwHistorySetRefMark( SwTxtRefMark* pTxtHt, ULONG nNodePos ) + : SwHistoryHint( HSTRY_SETREFMARKHNT ) + , m_RefName( pTxtHt->GetRefMark().GetRefName() ) + , m_nNodeIndex( nNodePos ) + , m_nStart( *pTxtHt->GetStart() ) + , m_nEnd( *pTxtHt->GetAnyEnd() ) { - aRefName = pTxtHt->GetRefMark().GetRefName(); - nNode = nNodePos; - nStart = *pTxtHt->GetStart(); - nEnd = *pTxtHt->GetAnyEnd(); } -void SwSetRefMarkHint::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistorySetRefMark::SetInDoc( SwDoc* pDoc, bool ) { - SwTxtNode * pTxtNd = pDoc->GetNodes()[ nNode ]->GetTxtNode(); - ASSERT( pTxtNd, "Undo-TxtAttr: kein TextNode" ); - if( !pTxtNd ) + SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode(); + ASSERT( pTxtNd, "SwHistorySetRefMark: no TextNode" ); + if ( !pTxtNd ) return; - SwFmtRefMark aRefMark( aRefName ); + SwFmtRefMark aRefMark( m_RefName ); - // existiert hier schon eine Referenz-Markierung ohne Ende, so - // darf es nicht eingefuegt werden !! - if( nStart != nEnd || !pTxtNd->GetTxtAttr( nStart, RES_TXTATR_REFMARK ) ) - pTxtNd->InsertItem( aRefMark, nStart, nEnd, nsSetAttrMode::SETATTR_NOTXTATRCHR ); + // if a reference mark without an end already exists here: must not insert! + if ( m_nStart != m_nEnd || + !pTxtNd->GetTxtAttr( m_nStart, RES_TXTATR_REFMARK ) ) + { + pTxtNd->InsertItem( aRefMark, m_nStart, m_nEnd, + nsSetAttrMode::SETATTR_NOTXTATRCHR ); + } } -SwSetTOXMarkHint::SwSetTOXMarkHint( SwTxtTOXMark* pTxtHt, ULONG nNodePos ) - : SwHstryHint( HSTRY_SETTOXMARKHNT ), aTOXMark( pTxtHt->GetTOXMark() ) +SwHistorySetTOXMark::SwHistorySetTOXMark( SwTxtTOXMark* pTxtHt, ULONG nNodePos ) + : SwHistoryHint( HSTRY_SETTOXMARKHNT ) + , m_TOXMark( pTxtHt->GetTOXMark() ) + , m_TOXName( m_TOXMark.GetTOXType()->GetTypeName() ) + , m_eTOXTypes( m_TOXMark.GetTOXType()->GetType() ) + , m_nNodeIndex( nNodePos ) + , m_nStart( *pTxtHt->GetStart() ) + , m_nEnd( *pTxtHt->GetAnyEnd() ) { - aTOXName = aTOXMark.GetTOXType()->GetTypeName(); - eTOXTypes = aTOXMark.GetTOXType()->GetType(); - ((SwModify*)aTOXMark.GetRegisteredIn())->Remove( &aTOXMark ); - - nNode = nNodePos; - nStart = *pTxtHt->GetStart(); - nEnd = *pTxtHt->GetAnyEnd(); + const_cast<SwModify*>(m_TOXMark.GetRegisteredIn())->Remove( &m_TOXMark ); } -void SwSetTOXMarkHint::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistorySetTOXMark::SetInDoc( SwDoc* pDoc, bool ) { - SwTxtNode * pTxtNd = pDoc->GetNodes()[ nNode ]->GetTxtNode(); - ASSERT( pTxtNd, "Undo-TxtAttr: kein TextNode" ); - if( !pTxtNd ) + SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode(); + ASSERT( pTxtNd, "SwHistorySetTOXMark: no TextNode" ); + if ( !pTxtNd ) return; - // suche den entsprechenden Verzeichnistyp - USHORT nCnt = pDoc->GetTOXTypeCount( eTOXTypes ); - const SwTOXType* pToxType = 0; - for( USHORT n = 0; n < nCnt; ++n ) + // search for respective TOX type + USHORT nCnt = pDoc->GetTOXTypeCount( m_eTOXTypes ); + SwTOXType* pToxType = 0; + for ( USHORT n = 0; n < nCnt; ++n ) { - pToxType = pDoc->GetTOXType( eTOXTypes, n ); - if( pToxType->GetTypeName() == aTOXName ) + pToxType = const_cast<SwTOXType*>(pDoc->GetTOXType( m_eTOXTypes, n )); + if ( pToxType->GetTypeName() == m_TOXName ) break; pToxType = 0; } - if( !pToxType ) // Verzeichnistyp nicht gefunden, neu anlegen - pToxType = pDoc->InsertTOXType( SwTOXType( eTOXTypes, aTOXName )); + if ( !pToxType ) // TOX type not found, create new + { + pToxType = const_cast<SwTOXType*>( + pDoc->InsertTOXType( SwTOXType( m_eTOXTypes, m_TOXName ))); + } - SwTOXMark aNew( aTOXMark ); - ((SwTOXType*)pToxType)->Add( &aNew ); + SwTOXMark aNew( m_TOXMark ); + pToxType->Add( &aNew ); - pTxtNd->InsertItem( aNew, nStart, nEnd, nsSetAttrMode::SETATTR_NOTXTATRCHR ); + pTxtNd->InsertItem( aNew, m_nStart, m_nEnd, + nsSetAttrMode::SETATTR_NOTXTATRCHR ); } -int SwSetTOXMarkHint::IsEqual( const SwTOXMark& rCmp ) const +int SwHistorySetTOXMark::IsEqual( const SwTOXMark& rCmp ) const { - return aTOXName == rCmp.GetTOXType()->GetTypeName() && - eTOXTypes == rCmp.GetTOXType()->GetType() && - aTOXMark.GetAlternativeText() == rCmp.GetAlternativeText() && - ( TOX_INDEX == eTOXTypes - ? ( aTOXMark.GetPrimaryKey() == rCmp.GetPrimaryKey() && - aTOXMark.GetSecondaryKey() == rCmp.GetSecondaryKey() ) - : aTOXMark.GetLevel() == rCmp.GetLevel() + return m_TOXName == rCmp.GetTOXType()->GetTypeName() && + m_eTOXTypes == rCmp.GetTOXType()->GetType() && + m_TOXMark.GetAlternativeText() == rCmp.GetAlternativeText() && + ( (TOX_INDEX == m_eTOXTypes) + ? ( m_TOXMark.GetPrimaryKey() == rCmp.GetPrimaryKey() && + m_TOXMark.GetSecondaryKey() == rCmp.GetSecondaryKey() ) + : m_TOXMark.GetLevel() == rCmp.GetLevel() ); } -SwResetTxtHint::SwResetTxtHint( USHORT nWhich, xub_StrLen nAttrStt, - xub_StrLen nAttrEnd, ULONG nNodePos ) - : SwHstryHint( HSTRY_RESETTXTHNT ), - nNode( nNodePos ), nStart( nAttrStt ), nEnd( nAttrEnd ), nAttr( nWhich ) +SwHistoryResetTxt::SwHistoryResetTxt( USHORT nWhich, + xub_StrLen nAttrStart, xub_StrLen nAttrEnd, ULONG nNodePos ) + : SwHistoryHint( HSTRY_RESETTXTHNT ) + , m_nNodeIndex( nNodePos ), m_nStart( nAttrStart ), m_nEnd( nAttrEnd ) + , m_nAttr( nWhich ) { } -void SwResetTxtHint::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistoryResetTxt::SetInDoc( SwDoc* pDoc, bool ) { - SwTxtNode * pTxtNd = pDoc->GetNodes()[ nNode ]->GetTxtNode(); - ASSERT( pTxtNd, "Undo-TxtAttr: kein TextNode" ); - if( pTxtNd ) - pTxtNd->Delete( nAttr, nStart, nEnd ); + SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode(); + ASSERT( pTxtNd, "SwHistoryResetTxt: no TextNode" ); + if ( pTxtNd ) + { + pTxtNd->Delete( m_nAttr, m_nStart, m_nEnd ); + } } -SwSetFtnHint::SwSetFtnHint( SwTxtFtn* pTxtFtn, ULONG nNodePos ) - : SwHstryHint( HSTRY_SETFTNHNT ), - nNode( nNodePos ), nStart( *pTxtFtn->GetStart() ) +SwHistorySetFootnote::SwHistorySetFootnote( SwTxtFtn* pTxtFtn, ULONG nNodePos ) + : SwHistoryHint( HSTRY_SETFTNHNT ) + , m_pUndo( new SwUndoSaveSection ) + , m_FootnoteNumber( pTxtFtn->GetFtn().GetNumStr() ) + , m_nNodeIndex( nNodePos ) + , m_nStart( *pTxtFtn->GetStart() ) + , m_bEndNote( pTxtFtn->GetFtn().IsEndNote() ) { - ASSERT( pTxtFtn->GetStartNode(), "Footnote ohne Section" ); - - aFtnStr = pTxtFtn->GetFtn().GetNumStr(); - bEndNote = pTxtFtn->GetFtn().IsEndNote(); + ASSERT( pTxtFtn->GetStartNode(), + "SwHistorySetFootnote: Footnote without Section" ); // merke die alte NodePos, denn wer weiss was alles in der SaveSection // gespeichert (geloescht) wird - SwDoc* pDoc = (SwDoc*)pTxtFtn->GetTxtNode().GetDoc(); - SwNode* pSaveNd = pDoc->GetNodes()[ nNode ]; + SwDoc* pDoc = const_cast<SwDoc*>(pTxtFtn->GetTxtNode().GetDoc()); + SwNode* pSaveNd = pDoc->GetNodes()[ m_nNodeIndex ]; //Pointer auf StartNode der FtnSection merken und erstmal den Pointer im //Attribut zuruecksetzen -> Damit werden automatisch die Frms vernichtet. SwNodeIndex aSttIdx( *pTxtFtn->GetStartNode() ); pTxtFtn->SetStartNode( 0, FALSE ); - pUndo = new SwUndoSaveSection; - pUndo->SaveSection( pDoc, aSttIdx ); - nNode = pSaveNd->GetIndex(); + m_pUndo->SaveSection( pDoc, aSttIdx ); + m_nNodeIndex = pSaveNd->GetIndex(); } -SwSetFtnHint::SwSetFtnHint( const SwTxtFtn &rTxtFtn ) : - SwHstryHint( HSTRY_SETFTNHNT ), - pUndo( 0 ), - nNode( _SwTxtFtn_GetIndex( (&rTxtFtn) ) ), - nStart( *rTxtFtn.GetStart() ) +SwHistorySetFootnote::SwHistorySetFootnote( const SwTxtFtn &rTxtFtn ) + : SwHistoryHint( HSTRY_SETFTNHNT ) + , m_pUndo( 0 ) + , m_FootnoteNumber( rTxtFtn.GetFtn().GetNumStr() ) + , m_nNodeIndex( _SwTxtFtn_GetIndex( (&rTxtFtn) ) ) + , m_nStart( *rTxtFtn.GetStart() ) + , m_bEndNote( rTxtFtn.GetFtn().IsEndNote() ) { - ASSERT( rTxtFtn.GetStartNode(), "Footnote ohne Section" ); - - aFtnStr = rTxtFtn.GetFtn().GetNumStr(); - bEndNote = rTxtFtn.GetFtn().IsEndNote(); + ASSERT( rTxtFtn.GetStartNode(), + "SwHistorySetFootnote: Footnote without Section" ); } -String SwSetFtnHint::GetDescription() const +String SwHistorySetFootnote::GetDescription() const { return SW_RES(STR_FOOTNOTE); } -SwSetFtnHint::~SwSetFtnHint() +SwHistorySetFootnote::~SwHistorySetFootnote() { - delete pUndo; } -void SwSetFtnHint::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistorySetFootnote::SetInDoc( SwDoc* pDoc, bool ) { - SwTxtNode * pTxtNd = pDoc->GetNodes()[ nNode ]->GetTxtNode(); - ASSERT( pTxtNd, "Undo-TxtAttr: kein TextNode" ); - if( !pTxtNd ) + SwTxtNode * pTxtNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTxtNode(); + ASSERT( pTxtNd, "SwHistorySetFootnote: no TextNode" ); + if ( !pTxtNd ) return; - if ( pUndo ) + if ( m_pUndo.get() ) { - // setze die Fussnote im TextNode - SwFmtFtn aTemp( bEndNote ); - SwFmtFtn& rNew = (SwFmtFtn&)pDoc->GetAttrPool().Put(aTemp); - if( aFtnStr.Len() ) - rNew.SetNumStr( aFtnStr ); - SwTxtFtn* pTxtFtn = new SwTxtFtn( rNew, nStart ); - - // erzeuge schon die Section der Fussnote + // set the footnote in the TextNode + SwFmtFtn aTemp( m_bEndNote ); + SwFmtFtn& rNew = const_cast<SwFmtFtn&>( + static_cast<const SwFmtFtn&>(pDoc->GetAttrPool().Put(aTemp)) ); + if ( m_FootnoteNumber.Len() ) + { + rNew.SetNumStr( m_FootnoteNumber ); + } + SwTxtFtn* pTxtFtn = new SwTxtFtn( rNew, m_nStart ); + + // create the section of the Footnote SwNodeIndex aIdx( *pTxtNd ); - pUndo->RestoreSection( pDoc, &aIdx, SwFootnoteStartNode ); + m_pUndo->RestoreSection( pDoc, &aIdx, SwFootnoteStartNode ); pTxtFtn->SetStartNode( &aIdx ); - if( pUndo->GetHistory() ) - // erst jetzt die Frames anlegen lassen - pUndo->GetHistory()->Rollback( pDoc ); + if ( m_pUndo->GetHistory() ) + { + // create frames only now + m_pUndo->GetHistory()->Rollback( pDoc ); + } pTxtNd->Insert( pTxtFtn ); } else { - SwTxtFtn *pFtn = (SwTxtFtn*)pTxtNd->GetTxtAttr( nStart ); - SwFmtFtn &rFtn = (SwFmtFtn&)pFtn->GetFtn(); - rFtn.SetNumStr( aFtnStr ); - if( rFtn.IsEndNote() != bEndNote ) + SwTxtFtn *pFtn = const_cast<SwTxtFtn*>( + static_cast<const SwTxtFtn*>(pTxtNd->GetTxtAttr( m_nStart ))); + SwFmtFtn &rFtn = const_cast<SwFmtFtn&>(pFtn->GetFtn()); + rFtn.SetNumStr( m_FootnoteNumber ); + if ( rFtn.IsEndNote() != m_bEndNote ) { - rFtn.SetEndNote( bEndNote ); + rFtn.SetEndNote( m_bEndNote ); pFtn->CheckCondColl(); } } } -SwChgFmtColl::SwChgFmtColl( const SwFmtColl* pFmtColl, ULONG nNd, +SwHistoryChangeFmtColl::SwHistoryChangeFmtColl( SwFmtColl* pFmtColl, ULONG nNd, BYTE nNodeWhich ) - : SwHstryHint( HSTRY_CHGFMTCOLL ), - pColl( pFmtColl ), - nNode( nNd ), - nNdWhich( nNodeWhich ) + : SwHistoryHint( HSTRY_CHGFMTCOLL ) + , m_pColl( pFmtColl ) + , m_nNodeIndex( nNd ) + , m_nNodeType( nNodeWhich ) { } -void SwChgFmtColl::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistoryChangeFmtColl::SetInDoc( SwDoc* pDoc, bool ) { - SwCntntNode * pCntntNd = pDoc->GetNodes()[ nNode ]->GetCntntNode(); - ASSERT( pCntntNd, "Undo-ChgFmt: kein ContentNode" ); + SwCntntNode * pCntntNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetCntntNode(); + ASSERT( pCntntNd, "SwHistoryChangeFmtColl: no ContentNode" ); - // prufe vor dem setzen des Formates, ob dieses ueberhaupt noch im - // Dokument vorhanden ist. Wurde es schon geloescht, gibt es kein Undo !! - if( pCntntNd && nNdWhich == pCntntNd->GetNodeType() ) + // before setting the format, check if it is still available in the + // document. if it has been deleted, there is no undo! + if ( pCntntNd && m_nNodeType == pCntntNd->GetNodeType() ) { - if( ND_TEXTNODE == nNdWhich ) + if ( ND_TEXTNODE == m_nNodeType ) { - if( USHRT_MAX != pDoc->GetTxtFmtColls()->GetPos( (SwTxtFmtColl*)pColl )) + if ( USHRT_MAX != pDoc->GetTxtFmtColls()->GetPos( + static_cast<SwTxtFmtColl * const>(m_pColl) )) { - pCntntNd->ChgFmtColl( (SwFmtColl*)pColl ); + pCntntNd->ChgFmtColl( m_pColl ); } } - else if( USHRT_MAX != pDoc->GetGrfFmtColls()->GetPos( (SwGrfFmtColl*)pColl )) - pCntntNd->ChgFmtColl( (SwFmtColl*)pColl ); + else if ( USHRT_MAX != pDoc->GetGrfFmtColls()->GetPos( + static_cast<SwGrfFmtColl * const>(m_pColl) )) + { + pCntntNd->ChgFmtColl( m_pColl ); + } } } -SwHstryTxtFlyCnt::SwHstryTxtFlyCnt( SwTxtFlyCnt* pTxtFly ) - : SwHstryHint( HSTRY_FLYCNT ) +SwHistoryTxtFlyCnt::SwHistoryTxtFlyCnt( SwTxtFlyCnt* pTxtFly ) + : SwHistoryHint( HSTRY_FLYCNT ) + , m_pUndo( new SwUndoDelLayFmt( pTxtFly->GetFlyCnt().GetFrmFmt() ) ) { - ASSERT( pTxtFly->GetFlyCnt().GetFrmFmt(), "FlyCntnt ohne Format" ); - pUndo = new SwUndoDelLayFmt( pTxtFly->GetFlyCnt().GetFrmFmt() ); - pUndo->ChgShowSel( FALSE ); + ASSERT( pTxtFly->GetFlyCnt().GetFrmFmt(), + "SwHistoryTxtFlyCnt: FlyCntnt without Format" ); + m_pUndo->ChgShowSel( FALSE ); } -SwHstryTxtFlyCnt::SwHstryTxtFlyCnt( SwFlyFrmFmt* pFlyFmt ) - : SwHstryHint( HSTRY_FLYCNT ) +SwHistoryTxtFlyCnt::SwHistoryTxtFlyCnt( SwFlyFrmFmt* pFlyFmt ) + : SwHistoryHint( HSTRY_FLYCNT ) + , m_pUndo( new SwUndoDelLayFmt( pFlyFmt ) ) { - ASSERT( pFlyFmt, "kein Format" ); - pUndo = new SwUndoDelLayFmt( pFlyFmt ); - pUndo->ChgShowSel( FALSE ); + ASSERT( pFlyFmt, "SwHistoryTxtFlyCnt: no Format" ); + m_pUndo->ChgShowSel( FALSE ); } -SwHstryTxtFlyCnt::~SwHstryTxtFlyCnt() +SwHistoryTxtFlyCnt::~SwHistoryTxtFlyCnt() { - delete pUndo; } -void SwHstryTxtFlyCnt::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistoryTxtFlyCnt::SetInDoc( SwDoc* pDoc, bool ) { SwPaM aPam( pDoc->GetNodes().GetEndOfPostIts() ); SwUndoIter aUndoIter( &aPam ); - pUndo->Undo( aUndoIter ); + m_pUndo->Undo( aUndoIter ); } -SwHstryBookmark::SwHstryBookmark( +SwHistoryBookmark::SwHistoryBookmark( const ::sw::mark::IMark& rBkmk, bool bSavePos, bool bSaveOtherPos) - : SwHstryHint(HSTRY_BOOKMARK) + : SwHistoryHint(HSTRY_BOOKMARK) , m_aName(rBkmk.GetName()) , m_aShortName() , m_aKeycode() @@ -581,7 +629,7 @@ SwHstryBookmark::SwHstryBookmark( } -void SwHstryBookmark::SetInDoc(SwDoc* pDoc, BOOL) +void SwHistoryBookmark::SetInDoc( SwDoc* pDoc, bool ) { bool bDoesUndo = pDoc->DoesUndo(); pDoc->DoUndo(false); @@ -595,7 +643,7 @@ void SwHstryBookmark::SetInDoc(SwDoc* pDoc, BOOL) { SwCntntNode* const pCntntNd = rNds[m_nNode]->GetCntntNode(); OSL_ENSURE(pCntntNd, - "<SwHstryBookmark::SetInDoc(..)>" + "<SwHistoryBookmark::SetInDoc(..)>" " - wrong node for a mark"); // #111660# don't crash when nNode1 doesn't point to content node. @@ -612,7 +660,7 @@ void SwHstryBookmark::SetInDoc(SwDoc* pDoc, BOOL) { SwCntntNode* const pCntntNd = rNds[m_nOtherNode]->GetCntntNode(); OSL_ENSURE(pCntntNd, - "<SwHstryBookmark::SetInDoc(..)>" + "<SwHistoryBookmark::SetInDoc(..)>" " - wrong node for a mark"); if(pPam.get() != NULL && pCntntNd) @@ -627,7 +675,7 @@ void SwHstryBookmark::SetInDoc(SwDoc* pDoc, BOOL) if(!pMark) pMark = pMarkAccess->findMark(m_aName)->get(); OSL_ENSURE(pMark->IsExpanded(), - "<SwHstryBookmark::SetInDoc(..)>" + "<SwHistoryBookmark::SetInDoc(..)>" " - missing pos on old mark"); pPam->SetMark(); *pPam->GetMark() = pMark->GetOtherMarkPos(); @@ -649,14 +697,14 @@ void SwHstryBookmark::SetInDoc(SwDoc* pDoc, BOOL) } -BOOL SwHstryBookmark::IsEqualBookmark(const ::sw::mark::IMark& rBkmk) +bool SwHistoryBookmark::IsEqualBookmark(const ::sw::mark::IMark& rBkmk) { return m_nNode == rBkmk.GetMarkPos().nNode.GetIndex() && m_nCntnt == rBkmk.GetMarkPos().nContent.GetIndex() && m_aName == rBkmk.GetName(); } -const ::rtl::OUString& SwHstryBookmark::GetName() const +const ::rtl::OUString& SwHistoryBookmark::GetName() const { return m_aName; } @@ -664,65 +712,70 @@ const ::rtl::OUString& SwHstryBookmark::GetName() const /*************************************************************************/ -SwHstrySetAttrSet::SwHstrySetAttrSet( const SfxItemSet& rSet, ULONG nNodePos, - const SvUShortsSort& rSetArr ) - : SwHstryHint( HSTRY_SETATTRSET ), - aOldSet( rSet ), - aResetArr( 0, 4 ), - nNode( nNodePos ), - // --> OD 2007-07-09 #i77372# - //mnNumLvl( MAXLEVEL),//NO_NUMBERING ), - mnNumLvl( MAXLEVEL), //#outline level,zhaojianwei - mbIsRestart( false ), - mnRestartVal( USHRT_MAX ), - mbIsCounted( false ) - // <-- -{ - SfxItemIter aIter( aOldSet ), aOrigIter( rSet ); +SwHistorySetAttrSet::SwHistorySetAttrSet( const SfxItemSet& rSet, + ULONG nNodePos, const SvUShortsSort& rSetArr ) + : SwHistoryHint( HSTRY_SETATTRSET ) + , m_OldSet( rSet ) + , m_ResetArray( 0, 4 ) + , m_nNodeIndex( nNodePos ) +{ + SfxItemIter aIter( m_OldSet ), aOrigIter( rSet ); const SfxPoolItem* pItem = aIter.FirstItem(), * pOrigItem = aOrigIter.FirstItem(); do { if( !rSetArr.Seek_Entry( pOrigItem->Which() )) { - aResetArr.Insert( pOrigItem->Which(), aResetArr.Count() ); - aOldSet.ClearItem( pOrigItem->Which() ); + m_ResetArray.Insert( pOrigItem->Which(), m_ResetArray.Count() ); + m_OldSet.ClearItem( pOrigItem->Which() ); } else { - switch( pItem->Which() ) + switch ( pItem->Which() ) { - case RES_PAGEDESC: - ((SwFmtPageDesc*)pItem)->ChgDefinedIn( 0 ); - break; + case RES_PAGEDESC: + static_cast<SwFmtPageDesc*>( + const_cast<SfxPoolItem*>(pItem))->ChgDefinedIn( 0 ); + break; - case RES_PARATR_DROP: - ((SwFmtDrop*)pItem)->ChgDefinedIn( 0 ); - break; + case RES_PARATR_DROP: + static_cast<SwFmtDrop*>( + const_cast<SfxPoolItem*>(pItem))->ChgDefinedIn( 0 ); + break; - case RES_BOXATR_FORMULA: - { + case RES_BOXATR_FORMULA: + { //JP 20.04.98: Bug 49502 - wenn eine Formel gesetzt ist, nie den // Value mit sichern. Der muss gegebenfalls neu // errechnet werden! //JP 30.07.98: Bug 54295 - Formeln immer im Klartext speichern - aOldSet.ClearItem( RES_BOXATR_VALUE ); + m_OldSet.ClearItem( RES_BOXATR_VALUE ); - SwTblBoxFormula& rNew = *(SwTblBoxFormula*)pItem; - if( rNew.IsIntrnlName() ) - { - const SwTblBoxFormula& rOld = (SwTblBoxFormula&)rSet.Get( RES_BOXATR_FORMULA ); - const SwNode* pNd = rOld.GetNodeOfFormula(); - if( pNd && 0 != (pNd = pNd->FindTableNode() )) + SwTblBoxFormula& rNew = + *static_cast<SwTblBoxFormula*>( + const_cast<SfxPoolItem*>(pItem)); + if ( rNew.IsIntrnlName() ) { - SwTableFmlUpdate aMsgHnt( &((SwTableNode*)pNd)->GetTable() ); - aMsgHnt.eFlags = TBL_BOXNAME; - rNew.ChgDefinedIn( rOld.GetDefinedIn() ); - rNew.ChangeState( &aMsgHnt ); + const SwTblBoxFormula& rOld = + static_cast<const SwTblBoxFormula&>( + rSet.Get( RES_BOXATR_FORMULA )); + const SwNode* pNd = rOld.GetNodeOfFormula(); + if ( pNd ) + { + const SwTableNode* pTableNode + = pNd->FindTableNode(); + if (pTableNode) + { + SwTableFmlUpdate aMsgHnt( + &pTableNode->GetTable() ); + aMsgHnt.eFlags = TBL_BOXNAME; + rNew.ChgDefinedIn( rOld.GetDefinedIn() ); + rNew.ChangeState( &aMsgHnt ); + } + } } + rNew.ChgDefinedIn( 0 ); } - rNew.ChgDefinedIn( 0 ); - } - break; + break; } } @@ -733,24 +786,29 @@ SwHstrySetAttrSet::SwHstrySetAttrSet( const SfxItemSet& rSet, ULONG nNodePos, } while( TRUE ); } -void SwHstrySetAttrSet::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistorySetAttrSet::SetInDoc( SwDoc* pDoc, bool ) { BOOL bDoesUndo = pDoc->DoesUndo(); pDoc->DoUndo( FALSE ); - SwNode * pNode = pDoc->GetNodes()[ nNode ]; - if( pNode->IsCntntNode() ) + SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ]; + if ( pNode->IsCntntNode() ) { - ((SwCntntNode*)pNode)->SetAttr( aOldSet ); - if( aResetArr.Count() ) - ((SwCntntNode*)pNode)->ResetAttr( aResetArr ); + static_cast<SwCntntNode*>(pNode)->SetAttr( m_OldSet ); + if ( m_ResetArray.Count() ) + { + static_cast<SwCntntNode*>(pNode)->ResetAttr( m_ResetArray ); + } } - else if( pNode->IsTableNode() ) + else if ( pNode->IsTableNode() ) { - SwFmt& rFmt = *((SwTableNode*)pNode)->GetTable().GetFrmFmt(); - rFmt.SetFmtAttr( aOldSet ); - if( aResetArr.Count() ) - rFmt.ResetFmtAttr( *aResetArr.GetData() ); + SwFmt& rFmt = + *static_cast<SwTableNode*>(pNode)->GetTable().GetFrmFmt(); + rFmt.SetFmtAttr( m_OldSet ); + if ( m_ResetArray.Count() ) + { + rFmt.ResetFmtAttr( *m_ResetArray.GetData() ); + } } pDoc->DoUndo( bDoesUndo ); @@ -759,11 +817,11 @@ void SwHstrySetAttrSet::SetInDoc( SwDoc* pDoc, BOOL ) /*************************************************************************/ -SwHstryResetAttrSet::SwHstryResetAttrSet( const SfxItemSet& rSet, +SwHistoryResetAttrSet::SwHistoryResetAttrSet( const SfxItemSet& rSet, ULONG nNodePos, xub_StrLen nAttrStt, xub_StrLen nAttrEnd ) - : SwHstryHint( HSTRY_RESETATTRSET ), - nNode( nNodePos ), nStart( nAttrStt ), nEnd( nAttrEnd ), - aArr( (BYTE)rSet.Count() ) + : SwHistoryHint( HSTRY_RESETATTRSET ) + , m_nNodeIndex( nNodePos ), m_nStart( nAttrStt ), m_nEnd( nAttrEnd ) + , m_Array( (BYTE)rSet.Count() ) { SfxItemIter aIter( rSet ); bool bAutoStyle = true; @@ -773,10 +831,14 @@ SwHstryResetAttrSet::SwHstryResetAttrSet( const SfxItemSet& rSet, const USHORT nWhich = aIter.GetCurItem()->Which(); // Character attribute cannot be inserted into the hints array // anymore. Therefore we have to treat them as one RES_TXTATR_AUTOFMT: - if ( RES_CHRATR_BEGIN <= nWhich && RES_CHRATR_END > nWhich ) + if (isCHRATR(nWhich)) + { bAutoStyle = true; + } else - aArr.Insert( aIter.GetCurItem()->Which() ,aArr.Count() ); + { + m_Array.Insert( aIter.GetCurItem()->Which(), m_Array.Count() ); + } if( aIter.IsAtEnd() ) break; @@ -785,32 +847,39 @@ SwHstryResetAttrSet::SwHstryResetAttrSet( const SfxItemSet& rSet, } if ( bAutoStyle ) - aArr.Insert( RES_TXTATR_AUTOFMT, aArr.Count() ); + { + m_Array.Insert( RES_TXTATR_AUTOFMT, m_Array.Count() ); + } } -void SwHstryResetAttrSet::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistoryResetAttrSet::SetInDoc( SwDoc* pDoc, bool ) { BOOL bDoesUndo = pDoc->DoesUndo(); pDoc->DoUndo( FALSE ); - SwCntntNode * pCntntNd = pDoc->GetNodes()[ nNode ]->GetCntntNode(); - ASSERT( pCntntNd, "wo ist mein CntntNode" ); + SwCntntNode * pCntntNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetCntntNode(); + ASSERT( pCntntNd, "SwHistoryResetAttrSet: no CntntNode" ); if (pCntntNd) { - const USHORT* pArr = aArr.GetData(); - if( USHRT_MAX == nEnd && USHRT_MAX == nStart ) + const USHORT* pArr = m_Array.GetData(); + if ( USHRT_MAX == m_nEnd && USHRT_MAX == m_nStart ) { - // kein Bereich also Schnittstelle zum Content-Node - for( USHORT n = aArr.Count(); n; --n, ++pArr ) + // no area: use ContentNode + for ( USHORT n = m_Array.Count(); n; --n, ++pArr ) + { pCntntNd->ResetAttr( *pArr ); + } } else { - // Bereich: also Schnittstelle zum Text-Node - for( USHORT n = aArr.Count(); n; --n, ++pArr ) - ((SwTxtNode*)pCntntNd)->Delete( *pArr, nStart, nEnd ); + // area: use TextNode + for ( USHORT n = m_Array.Count(); n; --n, ++pArr ) + { + static_cast<SwTxtNode*>(pCntntNd)-> + Delete( *pArr, m_nStart, m_nEnd ); + } } } @@ -821,41 +890,47 @@ void SwHstryResetAttrSet::SetInDoc( SwDoc* pDoc, BOOL ) /*************************************************************************/ -SwHstryChgFlyAnchor::SwHstryChgFlyAnchor( const SwFrmFmt& rFmt ) - : SwHstryHint( HSTRY_CHGFLYANCHOR ), - pFmt( (SwFrmFmt*)&rFmt ) +SwHistoryChangeFlyAnchor::SwHistoryChangeFlyAnchor( SwFrmFmt& rFmt ) + : SwHistoryHint( HSTRY_CHGFLYANCHOR ) + , m_rFmt( rFmt ) + , m_nOldNodeIndex( rFmt.GetAnchor().GetCntntAnchor()->nNode.GetIndex() ) + , m_nOldContentIndex( ( FLY_AUTO_CNTNT == rFmt.GetAnchor().GetAnchorId() ) + ? rFmt.GetAnchor().GetCntntAnchor()->nContent.GetIndex() + : STRING_MAXLEN ) { - const SwFmtAnchor& rAnchor = rFmt.GetAnchor(); - nOldPos = rAnchor.GetCntntAnchor()->nNode.GetIndex(); - if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) - nOldCnt = rAnchor.GetCntntAnchor()->nContent.GetIndex(); - else - nOldCnt = STRING_MAXLEN; } -void SwHstryChgFlyAnchor::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistoryChangeFlyAnchor::SetInDoc( SwDoc* pDoc, bool ) { BOOL bDoesUndo = pDoc->DoesUndo(); pDoc->DoUndo( FALSE ); - USHORT nPos = pDoc->GetSpzFrmFmts()->GetPos( pFmt ); - if( USHRT_MAX != nPos ) // Format noch vorhanden + USHORT nPos = pDoc->GetSpzFrmFmts()->GetPos( &m_rFmt ); + if ( USHRT_MAX != nPos ) // Format does still exist { - SwFmtAnchor aTmp( pFmt->GetAnchor() ); + SwFmtAnchor aTmp( m_rFmt.GetAnchor() ); - SwNode* pNd = pDoc->GetNodes()[ nOldPos ]; + SwNode* pNd = pDoc->GetNodes()[ m_nOldNodeIndex ]; + SwCntntNode* pCNd = pNd->GetCntntNode(); SwPosition aPos( *pNd ); - if( STRING_MAXLEN != nOldCnt ) - aPos.nContent.Assign( (SwCntntNode*)pNd, nOldCnt ); + if ( STRING_MAXLEN != m_nOldContentIndex ) + { + ASSERT(pCNd, "SwHistoryChangeFlyAnchor: no ContentNode"); + if (pCNd) + { + aPos.nContent.Assign( pCNd, m_nOldContentIndex ); + } + } aTmp.SetAnchor( &aPos ); - // damit das Layout nicht durcheinander kommt! - SwCntntNode* pCNd = pNd->GetCntntNode(); - if( !pCNd || !pCNd->GetFrm( 0, 0, FALSE ) ) - pFmt->DelFrms(); + // so the Layout does not get confused + if ( !pCNd || !pCNd->GetFrm( 0, 0, FALSE ) ) + { + m_rFmt.DelFrms(); + } - pFmt->SetFmtAttr( aTmp ); + m_rFmt.SetFmtAttr( aTmp ); } pDoc->DoUndo( bDoesUndo ); } @@ -863,55 +938,64 @@ void SwHstryChgFlyAnchor::SetInDoc( SwDoc* pDoc, BOOL ) /*************************************************************************/ -SwHstryChgFlyChain::SwHstryChgFlyChain( const SwFlyFrmFmt& rFmt, +SwHistoryChangeFlyChain::SwHistoryChangeFlyChain( SwFlyFrmFmt& rFmt, const SwFmtChain& rAttr ) - : SwHstryHint( HSTRY_CHGFLYCHAIN ), - pPrevFmt( rAttr.GetPrev() ), - pNextFmt( rAttr.GetNext() ), - pFlyFmt( (SwFlyFrmFmt*)&rFmt ) + : SwHistoryHint( HSTRY_CHGFLYCHAIN ) + , m_pPrevFmt( rAttr.GetPrev() ) + , m_pNextFmt( rAttr.GetNext() ) + , m_pFlyFmt( &rFmt ) { } -void SwHstryChgFlyChain::SetInDoc( SwDoc* pDoc, BOOL ) +void SwHistoryChangeFlyChain::SetInDoc( SwDoc* pDoc, bool ) { - if( USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( pFlyFmt ) ) + if ( USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pFlyFmt ) ) { SwFmtChain aChain; - if( pPrevFmt && USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( pPrevFmt )) + + if ( m_pPrevFmt && + USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pPrevFmt ) ) { - aChain.SetPrev( pPrevFmt ); - SwFmtChain aTmp( pPrevFmt->GetChain() ); - aTmp.SetNext( pFlyFmt ); - pPrevFmt->SetFmtAttr( aTmp ); + aChain.SetPrev( m_pPrevFmt ); + SwFmtChain aTmp( m_pPrevFmt->GetChain() ); + aTmp.SetNext( m_pFlyFmt ); + m_pPrevFmt->SetFmtAttr( aTmp ); } - if( pNextFmt && USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( pNextFmt )) + + if ( m_pNextFmt && + USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pNextFmt ) ) { - aChain.SetNext( pNextFmt ); - SwFmtChain aTmp( pNextFmt->GetChain() ); - aTmp.SetPrev( pFlyFmt ); - pNextFmt->SetFmtAttr( aTmp ); + aChain.SetNext( m_pNextFmt ); + SwFmtChain aTmp( m_pNextFmt->GetChain() ); + aTmp.SetPrev( m_pFlyFmt ); + m_pNextFmt->SetFmtAttr( aTmp ); } - if( aChain.GetNext() || aChain.GetPrev() ) - pFlyFmt->SetFmtAttr( aChain ); + if ( aChain.GetNext() || aChain.GetPrev() ) + { + m_pFlyFmt->SetFmtAttr( aChain ); + } } } // -> #i27615# -SwHstryChgCharFmt::SwHstryChgCharFmt(const SfxItemSet & rSet, - const String & _sFmt) - : SwHstryHint(HSTRY_CHGCHARFMT), aOldSet(rSet), sFmt(_sFmt) +SwHistoryChangeCharFmt::SwHistoryChangeCharFmt(const SfxItemSet & rSet, + const String & sFmt) + : SwHistoryHint(HSTRY_CHGCHARFMT) + , m_OldSet(rSet), m_Fmt(sFmt) { } -void SwHstryChgCharFmt::SetInDoc(SwDoc * pDoc, BOOL ) +void SwHistoryChangeCharFmt::SetInDoc(SwDoc * pDoc, bool ) { - SwCharFmt * pCharFmt = pDoc->FindCharFmtByName(sFmt); + SwCharFmt * pCharFmt = pDoc->FindCharFmtByName(m_Fmt); if (pCharFmt) - pCharFmt->SetFmtAttr(aOldSet); + { + pCharFmt->SetFmtAttr(m_OldSet); + } } // <- #i27615# @@ -919,7 +1003,8 @@ void SwHstryChgCharFmt::SetInDoc(SwDoc * pDoc, BOOL ) SwHistory::SwHistory( USHORT nInitSz, USHORT nGrowSz ) - : SwpHstry( (BYTE)nInitSz, (BYTE)nGrowSz ), nEndDiff( 0 ) + : m_SwpHstry( (BYTE)nInitSz, (BYTE)nGrowSz ) + , m_nEndDiff( 0 ) {} @@ -944,98 +1029,105 @@ void SwHistory::Add( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue, ULONG nNodeIdx ) // <-- { - ASSERT( !nEndDiff, "nach REDO wurde die History noch nicht geloescht" ); + ASSERT( !m_nEndDiff, "History was not deleted after REDO" ); USHORT nWhich = pNewValue->Which(); if( (nWhich >= POOLATTR_END) || (nWhich == RES_TXTATR_FIELD) ) return; - // kein default Attribut ?? - SwHstryHint * pHt; -#ifdef JP_NEWCORE - if( pOldValue && pOldValue->GetFmt() && - ( !pNewValue->GetFmt() || pOldValue->GetFmt()==pNewValue->GetFmt()) ) -#else - if( pOldValue && pOldValue != GetDfltAttr( pOldValue->Which() ) ) -#endif - pHt = new SwSetFmtHint( (SfxPoolItem*)pOldValue, nNodeIdx ); + // no default Attribute? + SwHistoryHint * pHt; + if ( pOldValue && pOldValue != GetDfltAttr( pOldValue->Which() ) ) + { + pHt = new SwHistorySetFmt( pOldValue, nNodeIdx ); + } else - pHt = new SwResetFmtHint( (SfxPoolItem*)pNewValue, nNodeIdx ); - Insert( pHt, Count() ); + { + pHt = new SwHistoryResetFmt( pNewValue, nNodeIdx ); + } + m_SwpHstry.Insert( pHt, Count() ); } -void SwHistory::Add( const SwTxtAttr* pHint, ULONG nNodeIdx, BOOL bNewAttr ) +void SwHistory::Add( SwTxtAttr* pHint, ULONG nNodeIdx, bool bNewAttr ) { + ASSERT( !m_nEndDiff, "History was not deleted after REDO" ); - ASSERT( !nEndDiff, "nach REDO wurde die History noch nicht geloescht" ); - - SwHstryHint * pHt; + SwHistoryHint * pHt; USHORT nAttrWhich = pHint->Which(); if( !bNewAttr ) { switch ( nAttrWhich ) { - case RES_TXTATR_FTN: - pHt = new SwSetFtnHint( (SwTxtFtn*)pHint, nNodeIdx ); - break; - case RES_TXTATR_FLYCNT: - pHt = new SwHstryTxtFlyCnt( (SwTxtFlyCnt*)pHint ); - break; - case RES_TXTATR_FIELD: - pHt = new SwSetTxtFldHint( (SwTxtFld*)pHint, nNodeIdx ); - break; - case RES_TXTATR_TOXMARK: - pHt = new SwSetTOXMarkHint( (SwTxtTOXMark*)pHint, nNodeIdx ); - break; - case RES_TXTATR_REFMARK: - pHt = new SwSetRefMarkHint( (SwTxtRefMark*)pHint, nNodeIdx ); - break; - default: - pHt = new SwSetTxtHint((SwTxtAttr*)pHint, nNodeIdx ); + case RES_TXTATR_FTN: + pHt = new SwHistorySetFootnote( + static_cast<SwTxtFtn*>(pHint), nNodeIdx ); + break; + case RES_TXTATR_FLYCNT: + pHt = new SwHistoryTxtFlyCnt( static_cast<SwTxtFlyCnt*>(pHint) ); + break; + case RES_TXTATR_FIELD: + pHt = new SwHistorySetTxtFld( + static_cast<SwTxtFld*>(pHint), nNodeIdx ); + break; + case RES_TXTATR_TOXMARK: + pHt = new SwHistorySetTOXMark( + static_cast<SwTxtTOXMark*>(pHint), nNodeIdx ); + break; + case RES_TXTATR_REFMARK: + pHt = new SwHistorySetRefMark( + static_cast<SwTxtRefMark*>(pHint), nNodeIdx ); + break; + default: + pHt = new SwHistorySetTxt( + static_cast<SwTxtAttr*>(pHint), nNodeIdx ); } } else { - pHt = new SwResetTxtHint( pHint->Which(), *pHint->GetStart(), + pHt = new SwHistoryResetTxt( pHint->Which(), *pHint->GetStart(), *pHint->GetAnyEnd(), nNodeIdx ); } - Insert( pHt, Count() ); + m_SwpHstry.Insert( pHt, Count() ); } -void SwHistory::Add( const SwFmtColl* pColl, ULONG nNodeIdx, BYTE nWhichNd ) +void SwHistory::Add( SwFmtColl* pColl, ULONG nNodeIdx, BYTE nWhichNd ) { - ASSERT( !nEndDiff, "nach REDO wurde die History noch nicht geloescht" ); - SwHstryHint * pHt = new SwChgFmtColl( pColl, nNodeIdx, nWhichNd ); - Insert( pHt, Count() ); + ASSERT( !m_nEndDiff, "History was not deleted after REDO" ); + + SwHistoryHint * pHt = + new SwHistoryChangeFmtColl( pColl, nNodeIdx, nWhichNd ); + m_SwpHstry.Insert( pHt, Count() ); } void SwHistory::Add(const ::sw::mark::IMark& rBkmk, bool bSavePos, bool bSaveOtherPos) { - ASSERT(!nEndDiff, "nach REDO wurde die History noch nicht geloescht"); - SwHstryHint * pHt = new SwHstryBookmark(rBkmk, bSavePos, bSaveOtherPos); - Insert(pHt, Count()); + ASSERT( !m_nEndDiff, "History was not deleted after REDO" ); + + SwHistoryHint * pHt = new SwHistoryBookmark(rBkmk, bSavePos, bSaveOtherPos); + m_SwpHstry.Insert( pHt, Count() ); } -void SwHistory::Add( const SwFrmFmt& rFmt ) +void SwHistory::Add( SwFrmFmt& rFmt ) { - SwHstryHint * pHt = new SwHstryChgFlyAnchor( rFmt ); - Insert( pHt, Count() ); + SwHistoryHint * pHt = new SwHistoryChangeFlyAnchor( rFmt ); + m_SwpHstry.Insert( pHt, Count() ); } -void SwHistory::Add( const SwFlyFrmFmt& rFmt, USHORT& rSetPos ) +void SwHistory::Add( SwFlyFrmFmt& rFmt, USHORT& rSetPos ) { - ASSERT( !nEndDiff, "nach REDO wurde die History noch nicht geloescht" ); - SwHstryHint * pHint; + ASSERT( !m_nEndDiff, "History was not deleted after REDO" ); + + SwHistoryHint * pHint; const USHORT nWh = rFmt.Which(); if( RES_FLYFRMFMT == nWh || RES_DRAWFRMFMT == nWh ) { - pHint = new SwHstryTxtFlyCnt( (SwFlyFrmFmt*)&rFmt ); - Insert( pHint, Count() ); + pHint = new SwHistoryTxtFlyCnt( &rFmt ); + m_SwpHstry.Insert( pHint, Count() ); const SwFmtChain* pChainItem; if( SFX_ITEM_SET == rFmt.GetItemState( RES_CHAIN, FALSE, @@ -1043,8 +1135,9 @@ void SwHistory::Add( const SwFlyFrmFmt& rFmt, USHORT& rSetPos ) { if( pChainItem->GetNext() || pChainItem->GetPrev() ) { - SwHstryHint * pHt = new SwHstryChgFlyChain( rFmt, *pChainItem ); - Insert( pHt, rSetPos++ ); + SwHistoryHint * pHt = + new SwHistoryChangeFlyChain( rFmt, *pChainItem ); + m_SwpHstry.Insert( pHt, rSetPos++ ); if ( pChainItem->GetNext() ) { SwFmtChain aTmp( pChainItem->GetNext()->GetChain() ); @@ -1058,23 +1151,22 @@ void SwHistory::Add( const SwFlyFrmFmt& rFmt, USHORT& rSetPos ) pChainItem->GetPrev()->SetFmtAttr( aTmp ); } } - ((SwFlyFrmFmt&)rFmt).ResetFmtAttr( RES_CHAIN ); + rFmt.ResetFmtAttr( RES_CHAIN ); } } } void SwHistory::Add( const SwTxtFtn& rFtn ) { - SwHstryHint *pHt = new SwSetFtnHint( rFtn ); - Insert( pHt, Count() ); + SwHistoryHint *pHt = new SwHistorySetFootnote( rFtn ); + m_SwpHstry.Insert( pHt, Count() ); } // #i27615# void SwHistory::Add(const SfxItemSet & rSet, const SwCharFmt & rFmt) { - SwHstryHint * pHt = new SwHstryChgCharFmt(rSet, rFmt.GetName()); - - Insert(pHt, Count()); + SwHistoryHint * pHt = new SwHistoryChangeCharFmt(rSet, rFmt.GetName()); + m_SwpHstry.Insert(pHt, Count()); } /************************************************************************* @@ -1088,69 +1180,80 @@ void SwHistory::Add(const SfxItemSet & rSet, const SwCharFmt & rFmt) *************************************************************************/ -BOOL SwHistory::Rollback( SwDoc* pDoc, USHORT nStart ) +bool SwHistory::Rollback( SwDoc* pDoc, USHORT nStart ) { - if( !Count() ) - return FALSE; + if ( !Count() ) + return false; - SwHstryHint * pHHt; + SwHistoryHint * pHHt; USHORT i; - for( i = Count(); i > nStart ; ) + for ( i = Count(); i > nStart ; ) { - pHHt = operator[]( --i ); - pHHt->SetInDoc( pDoc, FALSE ); + pHHt = m_SwpHstry[ --i ]; + pHHt->SetInDoc( pDoc, false ); delete pHHt; } - SwpHstry::Remove( nStart, Count() - nStart ); - nEndDiff = 0; - return TRUE; + m_SwpHstry.Remove( nStart, Count() - nStart ); + m_nEndDiff = 0; + return true; } -BOOL SwHistory::TmpRollback( SwDoc* pDoc, USHORT nStart, BOOL bToFirst ) +bool SwHistory::TmpRollback( SwDoc* pDoc, USHORT nStart, bool bToFirst ) { - USHORT nEnd = Count() - nEndDiff; - if( !Count() || !nEnd || nStart >= nEnd ) - return FALSE; + USHORT nEnd = Count() - m_nEndDiff; + if ( !Count() || !nEnd || nStart >= nEnd ) + return false; - SwHstryHint * pHHt; - if( bToFirst ) - for( ; nEnd > nStart; ++nEndDiff ) + SwHistoryHint * pHHt; + if ( bToFirst ) + { + for ( ; nEnd > nStart; ++m_nEndDiff ) { - pHHt = operator[]( --nEnd ); - pHHt->SetInDoc( pDoc, TRUE ); + pHHt = m_SwpHstry[ --nEnd ]; + pHHt->SetInDoc( pDoc, true ); } + } else - for( ; nStart < nEnd; ++nEndDiff, ++nStart ) + { + for ( ; nStart < nEnd; ++m_nEndDiff, ++nStart ) { - pHHt = operator[]( nStart ); - pHHt->SetInDoc( pDoc, TRUE ); + pHHt = m_SwpHstry[ nStart ]; + pHHt->SetInDoc( pDoc, true ); } - return TRUE; + } + return true; } void SwHistory::Delete( USHORT nStart ) { - for( USHORT n = Count(); n > nStart; ) - SwpHstry::DeleteAndDestroy( --n, 1 ); - nEndDiff = 0; + for ( USHORT n = Count(); n > nStart; ) + { + m_SwpHstry.DeleteAndDestroy( --n, 1 ); + } + m_nEndDiff = 0; } USHORT SwHistory::SetTmpEnd( USHORT nNewTmpEnd ) { - ASSERT( nNewTmpEnd <= Count(), "das temp. Ende ist zu gross" ); + ASSERT( nNewTmpEnd <= Count(), "SwHistory::SetTmpEnd: out of bounds" ); - USHORT nOld = Count() - nEndDiff; - nEndDiff = Count() - nNewTmpEnd; + USHORT nOld = Count() - m_nEndDiff; + m_nEndDiff = Count() - nNewTmpEnd; - // rufe bei allen SwHstryFlyCnt das Redo vom UndoObject auf. Dadurch - // werden die Formate der Fly gesichert !! - for( USHORT n = nOld; n < nNewTmpEnd; n++ ) - if( HSTRY_FLYCNT == (*this)[ n ]->Which() ) - ((SwHstryTxtFlyCnt*)(*this)[ n ])->GetUDelLFmt()->Redo(); + // for every SwHistoryFlyCnt, call the Redo of its UndoObject. + // this saves the formats of the flys! + for ( USHORT n = nOld; n < nNewTmpEnd; n++ ) + { + if ( HSTRY_FLYCNT == (*this)[ n ]->Which() ) + { + static_cast<SwHistoryTxtFlyCnt*>((*this)[ n ]) + ->GetUDelLFmt()->Redo(); + } + } return nOld; } @@ -1173,21 +1276,21 @@ void SwHistory::CopyFmtAttr( const SfxItemSet& rSet, ULONG nNodeIdx ) } } -void SwHistory::CopyAttr( const SwpHints* pHts, ULONG nNodeIdx, - xub_StrLen nStt, xub_StrLen nEnd, BOOL bFields ) +void SwHistory::CopyAttr( SwpHints* pHts, ULONG nNodeIdx, + xub_StrLen nStart, xub_StrLen nEnd, bool bFields ) { if( !pHts ) return; - // kopiere alle Attribute aus dem TextNode die - // im Bereich von Position nStt bis Len liegen - const SwTxtAttr* pHt; + // copy all attributes of the TextNode in the area from nStart to nEnd + SwTxtAttr* pHt; xub_StrLen nAttrStt; const xub_StrLen * pEndIdx; for( USHORT n = 0; n < pHts->Count(); n++ ) { // BP: nAttrStt muss auch bei !pEndIdx gesetzt werden - nAttrStt = *(pHt = (*pHts)[n])->GetStart(); + pHt = pHts->GetTextHint(n); + nAttrStt = *pHt->GetStart(); // JP: ???? wieso nAttrStt >= nEnd // if( 0 != ( pEndIdx = pHt->GetEnd() ) && nAttrStt >= nEnd ) if( 0 != ( pEndIdx = pHt->GetEnd() ) && nAttrStt > nEnd ) @@ -1212,17 +1315,21 @@ void SwHistory::CopyAttr( const SwpHints* pHts, ULONG nNodeIdx, if( bNextAttr ) continue; - // alle Attribute, die irgendwie in diesem Bereich liegen speichern - if( nStt <= nAttrStt ) + // save all attributes that are somehow in this area + if ( nStart <= nAttrStt ) { - if( nEnd > nAttrStt + if ( nEnd > nAttrStt // JP: ???? wieso nAttrStt >= nEnd // || (nEnd == nAttrStt && (!pEndIdx || nEnd == pEndIdx->GetIndex())) ) - Add( pHt, nNodeIdx, FALSE ); + { + Add( pHt, nNodeIdx, false ); + } + } + else if ( pEndIdx && nStart < *pEndIdx ) + { + Add( pHt, nNodeIdx, false ); } - else if( pEndIdx && nStt < *pEndIdx ) - Add( pHt, nNodeIdx, FALSE ); } } @@ -1232,74 +1339,79 @@ void SwHistory::CopyAttr( const SwpHints* pHts, ULONG nNodeIdx, // Klasse zum Registrieren der History am Node, Format, HintsArray, ... SwRegHistory::SwRegHistory( SwHistory* pHst ) - : SwClient( 0 ), - pHstry( pHst ), - nNodeIdx( ULONG_MAX ) + : SwClient( 0 ) + , m_pHistory( pHst ) + , m_nNodeIndex( ULONG_MAX ) { - if( pHst ) - _MakeSetWhichIds(); + _MakeSetWhichIds(); } SwRegHistory::SwRegHistory( SwModify* pRegIn, const SwNode& rNd, SwHistory* pHst ) - : SwClient( pRegIn ), - pHstry( pHst ), - nNodeIdx( rNd.GetIndex() ) + : SwClient( pRegIn ) + , m_pHistory( pHst ) + , m_nNodeIndex( rNd.GetIndex() ) { - if( pHst ) - _MakeSetWhichIds(); + _MakeSetWhichIds(); } SwRegHistory::SwRegHistory( const SwNode& rNd, SwHistory* pHst ) - : SwClient( 0 ), - pHstry( pHst ), - nNodeIdx( rNd.GetIndex() ) + : SwClient( 0 ) + , m_pHistory( pHst ) + , m_nNodeIndex( rNd.GetIndex() ) { - if( pHstry ) - _MakeSetWhichIds(); + _MakeSetWhichIds(); } void SwRegHistory::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) { - // Attribut erfragen ?? ( mal sehen ) - if( pHstry && ( pOld || pNew ) ) + if ( m_pHistory && ( pOld || pNew ) ) { - if( pNew->Which() < POOLATTR_END ) - pHstry->Add( pOld, pNew, nNodeIdx ); - else if( RES_ATTRSET_CHG == pNew->Which() ) + if ( pNew->Which() < POOLATTR_END ) { - SwHstryHint* pNewHstr; - const SfxItemSet& rSet = *((SwAttrSetChg*)pOld)->GetChgSet(); - if( 1 < rSet.Count() ) - pNewHstr = new SwHstrySetAttrSet( rSet, nNodeIdx, - aSetWhichIds ); + m_pHistory->Add( pOld, pNew, m_nNodeIndex ); + } + else if ( RES_ATTRSET_CHG == pNew->Which() ) + { + SwHistoryHint* pNewHstr; + const SfxItemSet& rSet = + *static_cast<SwAttrSetChg*>(pOld)->GetChgSet(); + if ( 1 < rSet.Count() ) + { + pNewHstr = + new SwHistorySetAttrSet( rSet, m_nNodeIndex, m_WhichIdSet ); + } else { const SfxPoolItem* pItem = SfxItemIter( rSet ).FirstItem(); - if( aSetWhichIds.Seek_Entry( pItem->Which() ) ) - pNewHstr = new SwSetFmtHint( pItem, nNodeIdx ); + if ( m_WhichIdSet.Seek_Entry( pItem->Which() ) ) + { + pNewHstr = new SwHistorySetFmt( pItem, m_nNodeIndex ); + } else - pNewHstr = new SwResetFmtHint( pItem, nNodeIdx ); + { + pNewHstr = new SwHistoryResetFmt( pItem, m_nNodeIndex ); + } } - pHstry->Insert( pNewHstr, pHstry->Count() ); + m_pHistory->m_SwpHstry.Insert( pNewHstr, m_pHistory->Count() ); } } } -void SwRegHistory::Add( SwTxtAttr* pHt, const BOOL bNew ) +void SwRegHistory::AddHint( SwTxtAttr* pHt, const bool bNew ) { - pHstry->Add( pHt, nNodeIdx, bNew ); + m_pHistory->Add( pHt, m_nNodeIndex, bNew ); } SwRegHistory::SwRegHistory( SwTxtNode* pTxtNode, const SfxItemSet& rSet, xub_StrLen nStart, xub_StrLen nEnd, USHORT nFlags, SwHistory* pHst ) - : SwClient( pTxtNode ), - pHstry( pHst ), - nNodeIdx( pTxtNode->GetIndex() ) + : SwClient( pTxtNode ) + , m_pHistory( pHst ) + , m_nNodeIndex( pTxtNode->GetIndex() ) { if( !rSet.Count() ) return; @@ -1322,45 +1434,57 @@ SwRegHistory::SwRegHistory( SwTxtNode* pTxtNode, const SfxItemSet& rSet, if( pHst && bInsert ) { - SwHstryHint* pNewHstr = new SwHstryResetAttrSet( rSet, + SwHistoryHint* pNewHstr = new SwHistoryResetAttrSet( rSet, pTxtNode->GetIndex(), nStart, nEnd ); // der NodeIndex kann verschoben sein !! - pHst->Insert( pNewHstr, pHst->Count() ); + pHst->m_SwpHstry.Insert( pNewHstr, pHst->Count() ); } } void SwRegHistory::RegisterInModify( SwModify* pRegIn, const SwNode& rNd ) { - if( pHstry && pRegIn ) + if ( m_pHistory && pRegIn ) { pRegIn->Add( this ); - nNodeIdx = rNd.GetIndex(); + m_nNodeIndex = rNd.GetIndex(); _MakeSetWhichIds(); } - else if( aSetWhichIds.Count() ) - aSetWhichIds.Remove( 0, aSetWhichIds.Count() ); + else if ( m_WhichIdSet.Count() ) + { + m_WhichIdSet.Remove( 0, m_WhichIdSet.Count() ); + } } void SwRegHistory::_MakeSetWhichIds() { - if( aSetWhichIds.Count() ) - aSetWhichIds.Remove( 0, aSetWhichIds.Count() ); + if (!m_pHistory) return; + + if ( m_WhichIdSet.Count() ) + { + m_WhichIdSet.Remove( 0, m_WhichIdSet.Count() ); + } if( GetRegisteredIn() ) { const SfxItemSet* pSet = 0; if( GetRegisteredIn()->ISA( SwCntntNode ) ) - pSet = ((SwCntntNode*)GetRegisteredIn())->GetpSwAttrSet(); - else if( GetRegisteredIn()->ISA( SwFmt ) ) - pSet = &((SwFmt*)GetRegisteredIn())->GetAttrSet(); + { + pSet = static_cast<SwCntntNode*>( + const_cast<SwModify*>(GetRegisteredIn()))->GetpSwAttrSet(); + } + else if ( GetRegisteredIn()->ISA( SwFmt ) ) + { + pSet = &static_cast<SwFmt*>( + const_cast<SwModify*>(GetRegisteredIn()))->GetAttrSet(); + } if( pSet && pSet->Count() ) { SfxItemIter aIter( *pSet ); USHORT nW = aIter.FirstItem()->Which(); while( TRUE ) { - aSetWhichIds.Insert( nW ); + m_WhichIdSet.Insert( nW ); if( aIter.IsAtEnd() ) break; nW = aIter.NextItem()->Which(); @@ -1368,3 +1492,4 @@ void SwRegHistory::_MakeSetWhichIds() } } } + diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index df7c138481d4..7177a622e21b 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -37,9 +37,7 @@ #define _SVSTDARR_USHORTSSORT #include <hintids.hxx> #include <svx/svdmodel.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/svdpage.hxx> #include <svtools/itemiter.hxx> @@ -66,38 +64,48 @@ #include <ftninfo.hxx> #include <redline.hxx> #include <section.hxx> +#include <charfmt.hxx> + + inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } // ----------------------------------------------------- -_UndoFmtAttr::_UndoFmtAttr( SwFmt& rFmt, BOOL bSvDrwPt ) - : SwClient( &rFmt ), pUndo( 0 ), bSaveDrawPt( bSvDrwPt ) +SwUndoFmtAttrHelper::SwUndoFmtAttrHelper( SwFmt& rFmt, bool bSvDrwPt ) + : SwClient( &rFmt ) + , m_pUndo( 0 ) + , m_bSaveDrawPt( bSvDrwPt ) { } -void _UndoFmtAttr::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) +void SwUndoFmtAttrHelper::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) { if( pOld && pNew ) { if( POOLATTR_END >= pOld->Which() ) { - if( pUndo ) - pUndo->PutAttr( *pOld ); + if ( GetUndo() ) + { + m_pUndo->PutAttr( *pOld ); + } else - pUndo = new SwUndoFmtAttr( *pOld, *(SwFmt*)pRegisteredIn, - bSaveDrawPt ); + { + m_pUndo.reset( new SwUndoFmtAttr( *pOld, + *static_cast<SwFmt*>(pRegisteredIn), m_bSaveDrawPt ) ); + } } - else if( RES_ATTRSET_CHG == pOld->Which() ) + else if ( RES_ATTRSET_CHG == pOld->Which() ) { - if( pUndo ) + if ( GetUndo() ) { - SfxItemIter aIter( *((SwAttrSetChg*)pOld)->GetChgSet() ); + SfxItemIter aIter( + *(static_cast<SwAttrSetChg*>(pOld))->GetChgSet() ); const SfxPoolItem* pItem = aIter.GetCurItem(); - while( pItem ) + while ( pItem ) { - pUndo->PutAttr( *pItem ); + m_pUndo->PutAttr( *pItem ); if( aIter.IsAtEnd() ) break; pItem = aIter.NextItem(); @@ -105,8 +113,9 @@ void _UndoFmtAttr::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) } else { - pUndo = new SwUndoFmtAttr( *((SwAttrSetChg*)pOld)->GetChgSet(), - *(SwFmt*)pRegisteredIn, bSaveDrawPt ); + m_pUndo.reset( new SwUndoFmtAttr( + *static_cast<SwAttrSetChg*>(pOld)->GetChgSet(), + *static_cast<SwFmt*>(pRegisteredIn), m_bSaveDrawPt ) ); } } else @@ -116,91 +125,77 @@ void _UndoFmtAttr::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) SwClient::Modify( pOld, pNew ); } -// --> OD 2007-07-11 #i56253# -struct TxtNodeNumberingAttrs -{ - TxtNodeNumberingAttrs( ULONG nTxtNodeIdx, - int nNumLvl, - bool bIsRestart, - SwNumberTree::tSwNumTreeNumber nRestartVal, - bool bIsCounted ) - : mnTxtNodeIdx( nTxtNodeIdx ), - mnNumLvl( nNumLvl ), - mbIsRestart( bIsRestart ), - mnRestartVal( nRestartVal ), - mbIsCounted( bIsCounted ) - {} - - ULONG mnTxtNodeIdx; - int mnNumLvl; - bool mbIsRestart; - SwNumberTree::tSwNumTreeNumber mnRestartVal; - bool mbIsCounted; -}; -// <-- +// ----------------------------------------------------- SwUndoFmtAttr::SwUndoFmtAttr( const SfxItemSet& rOldSet, SwFmt& rChgFmt, - BOOL bSvDrwPt ) - : SwUndo( UNDO_INSFMTATTR ), - pFmt( &rChgFmt ), + bool bSaveDrawPt ) + : SwUndo( UNDO_INSFMTATTR ) + , m_pFmt( &rChgFmt ) // --> OD 2007-07-11 #i56253# - pOldSet( 0 ), + , m_pOldSet( new SfxItemSet( rOldSet ) ) // <-- - nNode( 0 ), - nFmtWhich( rChgFmt.Which() ), - bSaveDrawPt( bSvDrwPt ) + , m_nNodeIndex( 0 ) + , m_nFmtWhich( rChgFmt.Which() ) + , m_bSaveDrawPt( bSaveDrawPt ) { - pOldSet = new SfxItemSet( rOldSet ); Init(); } SwUndoFmtAttr::SwUndoFmtAttr( const SfxPoolItem& rItem, SwFmt& rChgFmt, - BOOL bSvDrwPt ) - : SwUndo( UNDO_INSFMTATTR ), - pFmt( &rChgFmt ), - nNode( 0 ), - nFmtWhich( rChgFmt.Which() ), - bSaveDrawPt( bSvDrwPt ) + bool bSaveDrawPt ) + : SwUndo( UNDO_INSFMTATTR ) + , m_pFmt( &rChgFmt ) + , m_pOldSet( m_pFmt->GetAttrSet().Clone( FALSE ) ) + , m_nNodeIndex( 0 ) + , m_nFmtWhich( rChgFmt.Which() ) + , m_bSaveDrawPt( bSaveDrawPt ) { - pOldSet = pFmt->GetAttrSet().Clone( FALSE ); - pOldSet->Put( rItem ); + m_pOldSet->Put( rItem ); Init(); } void SwUndoFmtAttr::Init() { - // Ankerwechsel gesondert behandeln - if( SFX_ITEM_SET == pOldSet->GetItemState( RES_ANCHOR, FALSE )) - SaveFlyAnchor( bSaveDrawPt ); - else if( RES_FRMFMT == nFmtWhich ) + // treat change of anchor specially + if ( SFX_ITEM_SET == m_pOldSet->GetItemState( RES_ANCHOR, FALSE )) + { + SaveFlyAnchor( m_bSaveDrawPt ); + } + else if ( RES_FRMFMT == m_nFmtWhich ) { - SwDoc* pDoc = pFmt->GetDoc(); - if( USHRT_MAX != - pDoc->GetTblFrmFmts()->GetPos( (const SwFrmFmtPtr)pFmt )) + SwDoc* pDoc = m_pFmt->GetDoc(); + if (USHRT_MAX != pDoc->GetTblFrmFmts()->GetPos( + static_cast<const SwFrmFmtPtr>(m_pFmt))) + { + // Table Format: save table position, table formats are volatile! + SwTable * pTbl = static_cast<SwTable*>( + SwClientIter( *m_pFmt ).First( TYPE( SwTable )) ); + if ( pTbl ) + { + m_nNodeIndex = pTbl->GetTabSortBoxes()[ 0 ]->GetSttNd() + ->FindTableNode()->GetIndex(); + } + } + else if (USHRT_MAX != pDoc->GetSections().GetPos( + static_cast<const SwSectionFmtPtr>(m_pFmt))) { - // TabellenFormat -> Tabellen Index Position merken, TabellenFormate - // sind fluechtig! - SwClient* pTbl = SwClientIter( *pFmt ).First( TYPE( SwTable )); - if( pTbl ) - nNode = ((SwTable*)pTbl)->GetTabSortBoxes()[ 0 ]-> - GetSttNd()->FindTableNode()->GetIndex(); + m_nNodeIndex = m_pFmt->GetCntnt().GetCntntIdx()->GetIndex(); } - else if( USHRT_MAX != - pDoc->GetSections().GetPos( (const SwSectionFmtPtr)pFmt )) - nNode = pFmt->GetCntnt().GetCntntIdx()->GetIndex(); - else if( 0 != dynamic_cast< SwTableBoxFmt* >( pFmt ) ) + else if ( 0 != dynamic_cast< SwTableBoxFmt* >( m_pFmt ) ) { - SwClient* pTblBox = SwClientIter( *pFmt ).First( TYPE( SwTableBox )); - if( pTblBox ) - nNode = static_cast< SwTableBox* >(pTblBox)->GetSttIdx(); + SwTableBox* pTblBox = static_cast< SwTableBox* >( + SwClientIter( *m_pFmt ).First( TYPE( SwTableBox ))); + if ( pTblBox ) + { + m_nNodeIndex = pTblBox->GetSttIdx(); + } } } } SwUndoFmtAttr::~SwUndoFmtAttr() { - delete pOldSet; } void SwUndoFmtAttr::Undo( SwUndoIter& rUndoIter) @@ -208,14 +203,14 @@ void SwUndoFmtAttr::Undo( SwUndoIter& rUndoIter) // OD 2004-10-26 #i35443# // Important note: <Undo(..)> also called by <ReDo(..)> - if( !pOldSet || !pFmt || !IsFmtInDoc( &rUndoIter.GetDoc() )) + if ( !m_pOldSet.get() || !m_pFmt || !IsFmtInDoc( &rUndoIter.GetDoc() )) return; // --> OD 2004-10-26 #i35443# - If anchor attribute has been successfull // restored, all other attributes are also restored. // Thus, keep track of its restoration bool bAnchorAttrRestored( false ); - if ( SFX_ITEM_SET == pOldSet->GetItemState( RES_ANCHOR, FALSE )) + if ( SFX_ITEM_SET == m_pOldSet->GetItemState( RES_ANCHOR, FALSE )) { bAnchorAttrRestored = RestoreFlyAnchor( rUndoIter ); if ( bAnchorAttrRestored ) @@ -228,105 +223,115 @@ void SwUndoFmtAttr::Undo( SwUndoIter& rUndoIter) { // Anchor attribute not restored due to invalid anchor position. // Thus, delete anchor attribute. - pOldSet->ClearItem( RES_ANCHOR ); + m_pOldSet->ClearItem( RES_ANCHOR ); } } if ( !bAnchorAttrRestored ) // <-- { - _UndoFmtAttr aTmp( *pFmt, bSaveDrawPt ); - pFmt->SetFmtAttr( *pOldSet ); - if( aTmp.pUndo ) + SwUndoFmtAttrHelper aTmp( *m_pFmt, m_bSaveDrawPt ); + m_pFmt->SetFmtAttr( *m_pOldSet ); + if ( aTmp.GetUndo() ) { - delete pOldSet; - pOldSet = aTmp.pUndo->pOldSet; - aTmp.pUndo->pOldSet = 0; // den Pointer auf 0 setzen (nicht - // doppelt loeschen) !! - delete aTmp.pUndo; // Undo-Object wieder loeschen + // transfer ownership of helper object's old set + m_pOldSet = aTmp.GetUndo()->m_pOldSet; } else - pOldSet->ClearItem(); + { + m_pOldSet->ClearItem(); + } - if( RES_FLYFRMFMT == nFmtWhich || RES_DRAWFRMFMT == nFmtWhich ) - rUndoIter.pSelFmt = (SwFrmFmt*)pFmt; + if ( RES_FLYFRMFMT == m_nFmtWhich || RES_DRAWFRMFMT == m_nFmtWhich ) + { + rUndoIter.pSelFmt = static_cast<SwFrmFmt*>(m_pFmt); + } } } -int SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc ) +bool SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc ) { - // suche im Dokument nach dem Format. Ist es nicht mehr vorhanden - // so wird das Attribut nicht mehr gesetzt ! + // search for the Format in the Document; if it does not exist any more, + // the attribute is not restored! USHORT nPos = USHRT_MAX; - switch( nFmtWhich ) + switch ( m_nFmtWhich ) { - case RES_TXTFMTCOLL: - nPos = pDoc->GetTxtFmtColls()->GetPos( - (const SwTxtFmtCollPtr)pFmt ); - break; + case RES_TXTFMTCOLL: + nPos = pDoc->GetTxtFmtColls()->GetPos( + static_cast<const SwTxtFmtCollPtr>(m_pFmt) ); + break; - case RES_GRFFMTCOLL: - nPos = pDoc->GetGrfFmtColls()->GetPos( - (const SwGrfFmtCollPtr)pFmt ); - break; - case RES_CHRFMT: - nPos = pDoc->GetCharFmts()->GetPos( - (const SwCharFmtPtr)pFmt ); - break; + case RES_GRFFMTCOLL: + nPos = pDoc->GetGrfFmtColls()->GetPos( + static_cast<const SwGrfFmtCollPtr>(m_pFmt) ); + break; - case RES_FRMFMT: - if( nNode && nNode < pDoc->GetNodes().Count() ) - { - SwNode* pNd = pDoc->GetNodes()[ nNode ]; - if( pNd->IsTableNode() ) - { - pFmt = ((SwTableNode*)pNd)->GetTable().GetFrmFmt(); - nPos = 0; - break; - } - else if( pNd->IsSectionNode() ) - { - pFmt = ((SwSectionNode*)pNd)->GetSection().GetFmt(); - nPos = 0; - break; - } - else if( pNd->IsStartNode() && SwTableBoxStartNode == - static_cast< SwStartNode* >(pNd)->GetStartNodeType() ) + case RES_CHRFMT: + nPos = pDoc->GetCharFmts()->GetPos( + static_cast<SwCharFmtPtr>(m_pFmt) ); + break; + + case RES_FRMFMT: + if ( m_nNodeIndex && (m_nNodeIndex < pDoc->GetNodes().Count()) ) { - SwTableNode* pTblNode = pNd->FindTableNode(); - if( pTblNode ) + SwNode* pNd = pDoc->GetNodes()[ m_nNodeIndex ]; + if ( pNd->IsTableNode() ) + { + m_pFmt = + static_cast<SwTableNode*>(pNd)->GetTable().GetFrmFmt(); + nPos = 0; + break; + } + else if ( pNd->IsSectionNode() ) + { + m_pFmt = + static_cast<SwSectionNode*>(pNd)->GetSection().GetFmt(); + nPos = 0; + break; + } + else if ( pNd->IsStartNode() && (SwTableBoxStartNode == + static_cast< SwStartNode* >(pNd)->GetStartNodeType()) ) { - SwTableBox* pBox = pTblNode->GetTable().GetTblBox( nNode ); - if( pBox ) + SwTableNode* pTblNode = pNd->FindTableNode(); + if ( pTblNode ) { - pFmt = pBox->GetFrmFmt(); - nPos = 0; - break; + SwTableBox* pBox = + pTblNode->GetTable().GetTblBox( m_nNodeIndex ); + if ( pBox ) + { + m_pFmt = pBox->GetFrmFmt(); + nPos = 0; + break; + } } } } - } - // kein break! - case RES_DRAWFRMFMT: - case RES_FLYFRMFMT: - if( USHRT_MAX == ( nPos = pDoc->GetSpzFrmFmts()->GetPos( - (const SwFrmFmtPtr)pFmt )) ) - nPos = pDoc->GetFrmFmts()->GetPos( - (const SwFrmFmtPtr)pFmt ); - break; + // no break! + case RES_DRAWFRMFMT: + case RES_FLYFRMFMT: + nPos = pDoc->GetSpzFrmFmts()->GetPos( + static_cast<const SwFrmFmtPtr>(m_pFmt) ); + if ( USHRT_MAX == nPos ) + { + nPos = pDoc->GetFrmFmts()->GetPos( + static_cast<const SwFrmFmtPtr>(m_pFmt) ); + } + break; } - // Format nicht mehr vorhanden, zurueck - if( USHRT_MAX == nPos ) - pFmt = 0; + if ( USHRT_MAX == nPos ) + { + // Format does not exist; reset + m_pFmt = 0; + } - return 0 != pFmt; + return 0 != m_pFmt; } // prueft, ob es noch im Doc ist! SwFmt* SwUndoFmtAttr::GetFmt( SwDoc& rDoc ) { - return pFmt && IsFmtInDoc( &rDoc ) ? pFmt : 0; + return m_pFmt && IsFmtInDoc( &rDoc ) ? m_pFmt : 0; } void SwUndoFmtAttr::Redo( SwUndoIter& rUndoIter) @@ -339,23 +344,29 @@ void SwUndoFmtAttr::Redo( SwUndoIter& rUndoIter) void SwUndoFmtAttr::Repeat( SwUndoIter& rUndoIter) { - if( !pOldSet ) + if ( !m_pOldSet.get() ) return; - SwUndoFmtAttr* pLast; - if( UNDO_INSFMTATTR == rUndoIter.GetLastUndoId() && - ( pLast = ((SwUndoFmtAttr*)rUndoIter.pLastUndoObj))->pOldSet && - pLast->pFmt ) - return; + if ( UNDO_INSFMTATTR == rUndoIter.GetLastUndoId()) + { + SwUndoFmtAttr* pLast + = static_cast<SwUndoFmtAttr*>(rUndoIter.pLastUndoObj); + if (pLast->m_pOldSet.get() && pLast->m_pFmt) + { + return; + } + } - switch( nFmtWhich ) + switch ( m_nFmtWhich ) { case RES_GRFFMTCOLL: { SwNoTxtNode * pNd = rUndoIter.pAktPam->GetNode()->GetNoTxtNode(); if( pNd ) - rUndoIter.GetDoc().SetAttr( pFmt->GetAttrSet(), + { + rUndoIter.GetDoc().SetAttr( m_pFmt->GetAttrSet(), *pNd->GetFmtColl() ); + } } break; @@ -363,8 +374,10 @@ void SwUndoFmtAttr::Repeat( SwUndoIter& rUndoIter) { SwTxtNode * pNd = rUndoIter.pAktPam->GetNode()->GetTxtNode(); if( pNd ) - rUndoIter.GetDoc().SetAttr( pFmt->GetAttrSet(), + { + rUndoIter.GetDoc().SetAttr( m_pFmt->GetAttrSet(), *pNd->GetFmtColl() ); + } } break; @@ -381,15 +394,18 @@ void SwUndoFmtAttr::Repeat( SwUndoIter& rUndoIter) if( pFly ) { // Bug 43672: es duerfen nicht alle Attribute gesetzt werden! - if( SFX_ITEM_SET == pFmt->GetAttrSet().GetItemState( RES_CNTNT )) + if (SFX_ITEM_SET == + m_pFmt->GetAttrSet().GetItemState( RES_CNTNT )) { - SfxItemSet aTmpSet( pFmt->GetAttrSet() ); + SfxItemSet aTmpSet( m_pFmt->GetAttrSet() ); aTmpSet.ClearItem( RES_CNTNT ); if( aTmpSet.Count() ) rUndoIter.GetDoc().SetAttr( aTmpSet, *pFly ); } else - rUndoIter.GetDoc().SetAttr( pFmt->GetAttrSet(), *pFly ); + { + rUndoIter.GetDoc().SetAttr( m_pFmt->GetAttrSet(), *pFly ); + } } break; } @@ -402,30 +418,34 @@ SwRewriter SwUndoFmtAttr::GetRewriter() const { SwRewriter aRewriter; - if (pFmt) - aRewriter.AddRule(UNDO_ARG1, pFmt->GetName()); + if (m_pFmt) + { + aRewriter.AddRule(UNDO_ARG1, m_pFmt->GetName()); + } return aRewriter; } void SwUndoFmtAttr::PutAttr( const SfxPoolItem& rItem ) { - pOldSet->Put( rItem ); - if( RES_ANCHOR == rItem.Which() ) - SaveFlyAnchor( bSaveDrawPt ); + m_pOldSet->Put( rItem ); + if ( RES_ANCHOR == rItem.Which() ) + { + SaveFlyAnchor( m_bSaveDrawPt ); + } } -void SwUndoFmtAttr::SaveFlyAnchor( BOOL bSvDrwPt ) +void SwUndoFmtAttr::SaveFlyAnchor( bool bSvDrwPt ) { // das Format ist gueltig, sonst wuerde man gar bis hier kommen if( bSvDrwPt ) { - if( RES_DRAWFRMFMT == pFmt->Which() ) + if ( RES_DRAWFRMFMT == m_pFmt->Which() ) { - Point aPt( ((SwFrmFmt*)pFmt)->FindSdrObject()->GetRelativePos() ); - // den alten Wert als zwischenspeichern. Attribut dafuer benutzen, - // dadurch bleibt der SwUndoFmtAttr klein. - pOldSet->Put( SwFmtFrmSize( ATT_VAR_SIZE, aPt.X(), aPt.Y() ) ); + Point aPt( static_cast<SwFrmFmt*>(m_pFmt)->FindSdrObject() + ->GetRelativePos() ); + // store old value as attribute, to keep SwUndoFmtAttr small + m_pOldSet->Put( SwFmtFrmSize( ATT_VAR_SIZE, aPt.X(), aPt.Y() ) ); } /* else { @@ -434,8 +454,8 @@ void SwUndoFmtAttr::SaveFlyAnchor( BOOL bSvDrwPt ) } */ } - const SwFmtAnchor& rAnchor = (SwFmtAnchor&)pOldSet->Get( - RES_ANCHOR, FALSE ); + const SwFmtAnchor& rAnchor = + static_cast<const SwFmtAnchor&>( m_pOldSet->Get( RES_ANCHOR, FALSE ) ); if( !rAnchor.GetCntntAnchor() ) return; @@ -447,14 +467,14 @@ void SwUndoFmtAttr::SaveFlyAnchor( BOOL bSvDrwPt ) nCntnt = rAnchor.GetCntntAnchor()->nContent.GetIndex(); case FLY_AT_CNTNT: case FLY_AT_FLY: - nNode = rAnchor.GetCntntAnchor()->nNode.GetIndex(); + m_nNodeIndex = rAnchor.GetCntntAnchor()->nNode.GetIndex(); break; default: return; } SwFmtAnchor aAnchor( rAnchor.GetAnchorId(), nCntnt ); - pOldSet->Put( aAnchor ); + m_pOldSet->Put( aAnchor ); } // --> OD 2004-10-26 #i35443# - Add return value, type <bool>. @@ -464,18 +484,19 @@ void SwUndoFmtAttr::SaveFlyAnchor( BOOL bSvDrwPt ) bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) { SwDoc* pDoc = &rIter.GetDoc(); - SwFlyFrmFmt* pFrmFmt = (SwFlyFrmFmt*)pFmt; - const SwFmtAnchor& rAnchor = (SwFmtAnchor&)pOldSet->Get( - RES_ANCHOR, FALSE ); + SwFlyFrmFmt* pFrmFmt = static_cast<SwFlyFrmFmt*>(m_pFmt); + const SwFmtAnchor& rAnchor = + static_cast<const SwFmtAnchor&>( m_pOldSet->Get( RES_ANCHOR, FALSE ) ); SwFmtAnchor aNewAnchor( rAnchor.GetAnchorId() ); if( FLY_PAGE != rAnchor.GetAnchorId() ) { - SwNode* pNd = pDoc->GetNodes()[ nNode ]; + SwNode* pNd = pDoc->GetNodes()[ m_nNodeIndex ]; - if( FLY_AT_FLY == rAnchor.GetAnchorId() ? ( !pNd->IsStartNode() || - SwFlyStartNode != ((SwStartNode*)pNd)->GetStartNodeType() ) : - !pNd->IsTxtNode() ) + if ( (FLY_AT_FLY == rAnchor.GetAnchorId()) + ? ( !pNd->IsStartNode() || (SwFlyStartNode != + static_cast<SwStartNode*>(pNd)->GetStartNodeType()) ) + : !pNd->IsTxtNode() ) { // --> OD 2004-10-26 #i35443# - invalid position. // Thus, anchor attribute not restored @@ -488,7 +509,8 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) { aPos.nContent.Assign( (SwTxtNode*)pNd, rAnchor.GetPageNum() ); - if( aPos.nContent.GetIndex() > ((SwTxtNode*)pNd)->GetTxt().Len() ) + if ( aPos.nContent.GetIndex() > + static_cast<SwTxtNode*>(pNd)->GetTxt().Len() ) { // --> OD 2004-10-26 #i35443# - invalid position. // Thus, anchor attribute not restored @@ -507,11 +529,11 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) if( RES_DRAWFRMFMT == pFrmFmt->Which() ) { // den alten zwischengespeicherten Wert herausholen. - const SwFmtFrmSize& rOldSize = (const SwFmtFrmSize&) - pOldSet->Get( RES_FRM_SIZE ); + const SwFmtFrmSize& rOldSize = static_cast<const SwFmtFrmSize&>( + m_pOldSet->Get( RES_FRM_SIZE ) ); aDrawSavePt.X() = rOldSize.GetWidth(); aDrawSavePt.Y() = rOldSize.GetHeight(); - pOldSet->ClearItem( RES_FRM_SIZE ); + m_pOldSet->ClearItem( RES_FRM_SIZE ); // den akt. wieder zwischenspeichern aDrawOldPt = pFrmFmt->FindSdrObject()->GetRelativePos(); @@ -519,7 +541,9 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) // pCont->DisconnectFromLayout(); } else - pFrmFmt->DelFrms(); // Frms vernichten. + { + pFrmFmt->DelFrms(); // delete Frms + } } const SwFmtAnchor &rOldAnch = pFrmFmt->GetAnchor(); @@ -543,7 +567,7 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFrmFmt, "Wrong TxtFlyCnt-Hint." ); #endif - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); //Die Verbindung ist geloest, jetzt muss noch das Attribut vernichtet //werden. @@ -551,25 +575,25 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) } { - pOldSet->Put( aNewAnchor ); - _UndoFmtAttr aTmp( *pFmt, bSaveDrawPt ); - pFmt->SetFmtAttr( *pOldSet ); - if( aTmp.pUndo ) + m_pOldSet->Put( aNewAnchor ); + SwUndoFmtAttrHelper aTmp( *m_pFmt, m_bSaveDrawPt ); + m_pFmt->SetFmtAttr( *m_pOldSet ); + if ( aTmp.GetUndo() ) { - delete pOldSet; - nNode = aTmp.pUndo->nNode; - pOldSet = aTmp.pUndo->pOldSet; - aTmp.pUndo->pOldSet = 0; // den Pointer auf 0 setzen (nicht - // doppelt loeschen) !! - delete aTmp.pUndo; // Undo-Object wieder loeschen + m_nNodeIndex = aTmp.GetUndo()->m_nNodeIndex; + // transfer ownership of helper object's old set + m_pOldSet = aTmp.GetUndo()->m_pOldSet; } else - pOldSet->ClearItem(); + { + m_pOldSet->ClearItem(); + } } - if( RES_DRAWFRMFMT == pFrmFmt->Which() ) + if ( RES_DRAWFRMFMT == pFrmFmt->Which() ) { - SwDrawContact *pCont = (SwDrawContact*)pFrmFmt->FindContactObj(); + SwDrawContact *pCont = + static_cast<SwDrawContact*>(pFrmFmt->FindContactObj()); // das Draw-Model hat auch noch ein Undo-Object fuer die // richtige Position vorbereitet; dieses ist aber relativ. // Darum verhinder hier, das durch setzen des Ankers das @@ -586,7 +610,8 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) pObj->SetRelativePos( aDrawSavePt ); // den alten Wert wieder zwischenspeichern. - pOldSet->Put( SwFmtFrmSize( ATT_VAR_SIZE, aDrawOldPt.X(), aDrawOldPt.Y() ) ); + m_pOldSet->Put( + SwFmtFrmSize( ATT_VAR_SIZE, aDrawOldPt.X(), aDrawOldPt.Y() ) ); } if( FLY_IN_CNTNT == aNewAnchor.GetAnchorId() ) @@ -608,73 +633,75 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) // <-- } +// ----------------------------------------------------- + // --> OD 2008-02-12 #newlistlevelattrs# SwUndoFmtResetAttr::SwUndoFmtResetAttr( SwFmt& rChangedFormat, const USHORT nWhichId ) - : SwUndo( UNDO_RESETATTR ), - mpChangedFormat( &rChangedFormat ), - mnWhichId( nWhichId ), - mpOldItem( 0 ) + : SwUndo( UNDO_RESETATTR ) + , m_pChangedFormat( &rChangedFormat ) + , m_nWhichId( nWhichId ) + , m_pOldItem( 0 ) { const SfxPoolItem* pItem = 0; - if ( rChangedFormat.GetItemState( nWhichId, FALSE, &pItem ) == SFX_ITEM_SET ) + if (rChangedFormat.GetItemState( nWhichId, FALSE, &pItem ) == SFX_ITEM_SET) { - mpOldItem = pItem->Clone(); + m_pOldItem.reset( pItem->Clone() ); } } SwUndoFmtResetAttr::~SwUndoFmtResetAttr() { - delete mpOldItem; } void SwUndoFmtResetAttr::Undo( SwUndoIter& ) { - if ( mpOldItem ) + if ( m_pOldItem.get() ) { - mpChangedFormat->SetFmtAttr( *mpOldItem ); + m_pChangedFormat->SetFmtAttr( *m_pOldItem ); } } void SwUndoFmtResetAttr::Redo( SwUndoIter& ) { - if ( mpOldItem ) + if ( m_pOldItem.get() ) { - mpChangedFormat->ResetFmtAttr( mnWhichId ); + m_pChangedFormat->ResetFmtAttr( m_nWhichId ); } } // <-- -/* */ +// ----------------------------------------------------- -SwUndoRstAttr::SwUndoRstAttr( const SwPaM& rRange, USHORT nFmt ) - : SwUndo( UNDO_RESETATTR ), SwUndRng( rRange ), - pHistory( new SwHistory ), nFmtId( nFmt ) +SwUndoResetAttr::SwUndoResetAttr( const SwPaM& rRange, USHORT nFmtId ) + : SwUndo( UNDO_RESETATTR ), SwUndRng( rRange ) + , m_pHistory( new SwHistory ) + , m_nFormatId( nFmtId ) { } -SwUndoRstAttr::SwUndoRstAttr( const SwDoc& , const SwPosition& rPos, - USHORT nWhich ) - : SwUndo( UNDO_RESETATTR ), pHistory( new SwHistory ), nFmtId( nWhich ) +SwUndoResetAttr::SwUndoResetAttr( const SwPosition& rPos, USHORT nFmtId ) + : SwUndo( UNDO_RESETATTR ) + , m_pHistory( new SwHistory ) + , m_nFormatId( nFmtId ) { nSttNode = nEndNode = rPos.nNode.GetIndex(); nSttCntnt = nEndCntnt = rPos.nContent.GetIndex(); } -SwUndoRstAttr::~SwUndoRstAttr() +SwUndoResetAttr::~SwUndoResetAttr() { - delete pHistory; } -void SwUndoRstAttr::Undo( SwUndoIter& rUndoIter ) +void SwUndoResetAttr::Undo( SwUndoIter& rUndoIter ) { - // die alten Werte wieder zurueck + // reset old values SwDoc& rDoc = rUndoIter.GetDoc(); - pHistory->TmpRollback( &rDoc, 0 ); - pHistory->SetTmpEnd( pHistory->Count() ); + m_pHistory->TmpRollback( &rDoc, 0 ); + m_pHistory->SetTmpEnd( m_pHistory->Count() ); - if( RES_CONDTXTFMTCOLL == nFmtId && nSttNode == nEndNode && - nSttCntnt == nEndCntnt ) + if ((RES_CONDTXTFMTCOLL == m_nFormatId) && + (nSttNode == nEndNode) && (nSttCntnt == nEndCntnt)) { SwTxtNode* pTNd = rDoc.GetNodes()[ nSttNode ]->GetTxtNode(); if( pTNd ) @@ -688,15 +715,15 @@ void SwUndoRstAttr::Undo( SwUndoIter& rUndoIter ) SetPaM( rUndoIter ); } -void SwUndoRstAttr::Redo( SwUndoIter& rUndoIter ) +void SwUndoResetAttr::Redo( SwUndoIter& rUndoIter ) { // setze Attribut in dem Bereich: SetPaM( rUndoIter ); SwDoc& rDoc = rUndoIter.GetDoc(); rUndoIter.pLastUndoObj = 0; - SvUShortsSort* pIdArr = aIds.Count() ? &aIds : 0; + SvUShortsSort* pIdArr = m_Ids.Count() ? &m_Ids : 0; - switch( nFmtId ) + switch ( m_nFormatId ) { case RES_CHRFMT: rUndoIter.GetDoc().RstTxtAttrs( *rUndoIter.pAktPam ); @@ -709,7 +736,7 @@ void SwUndoRstAttr::Redo( SwUndoIter& rUndoIter ) break; case RES_TXTATR_TOXMARK: - // Sonderbehandlung fuer TOXMarks + // special treatment for TOXMarks { SwTOXMarks aArr; SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode ); @@ -721,17 +748,19 @@ void SwUndoRstAttr::Redo( SwUndoIter& rUndoIter ) { if( 1 < nCnt ) { - // dann den richtigen suchen - SwHstryHint* pHHint = (*GetHistory())[ 0 ]; + // search for the right one + SwHistoryHint* pHHint = (GetHistory())[ 0 ]; if( pHHint && HSTRY_SETTOXMARKHNT == pHHint->Which() ) { while( nCnt ) - if( ((SwSetTOXMarkHint*)pHHint)->IsEqual( - *aArr[ --nCnt ] ) ) + { + if ( static_cast<SwHistorySetTOXMark*>(pHHint) + ->IsEqual( *aArr[ --nCnt ] ) ) { ++nCnt; break; } + } } else nCnt = 0; @@ -746,15 +775,18 @@ void SwUndoRstAttr::Redo( SwUndoIter& rUndoIter ) rUndoIter.pLastUndoObj = 0; } -void SwUndoRstAttr::Repeat( SwUndoIter& rUndoIter ) +void SwUndoResetAttr::Repeat( SwUndoIter& rUndoIter ) { - if( RES_FMT_BEGIN > nFmtId || - ( UNDO_RESETATTR == rUndoIter.GetLastUndoId() && - nFmtId == ((SwUndoRstAttr*)rUndoIter.pLastUndoObj)->nFmtId )) + if ( (RES_FMT_BEGIN > m_nFormatId) || + ( (UNDO_RESETATTR == rUndoIter.GetLastUndoId()) && + (m_nFormatId == static_cast<SwUndoResetAttr*>(rUndoIter.pLastUndoObj) + ->m_nFormatId) ) ) + { return; + } - SvUShortsSort* pIdArr = aIds.Count() ? &aIds : 0; - switch( nFmtId ) + SvUShortsSort* pIdArr = m_Ids.Count() ? &m_Ids : 0; + switch ( m_nFormatId ) { case RES_CHRFMT: rUndoIter.GetDoc().RstTxtAttrs( *rUndoIter.pAktPam ); @@ -770,59 +802,69 @@ void SwUndoRstAttr::Repeat( SwUndoIter& rUndoIter ) } -void SwUndoRstAttr::SetAttrs( const SvUShortsSort& rArr ) +void SwUndoResetAttr::SetAttrs( const SvUShortsSort& rArr ) { - if( aIds.Count() ) - aIds.Remove( 0, aIds.Count() ); - aIds.Insert( &rArr ); + if ( m_Ids.Count() ) + { + m_Ids.Remove( 0, m_Ids.Count() ); + } + m_Ids.Insert( &rArr ); } // ----------------------------------------------------- - SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxPoolItem& rAttr, USHORT nFlags ) - : SwUndo( UNDO_INSATTR ), SwUndRng( rRange ), - aSet( rRange.GetDoc()->GetAttrPool(), rAttr.Which(), rAttr.Which() ), - pHistory( new SwHistory ), - pRedlData( 0 ), pRedlSaveData( 0 ), - nNdIdx( ULONG_MAX ), nInsFlags( nFlags ) + : SwUndo( UNDO_INSATTR ), SwUndRng( rRange ) + , m_AttrSet( rRange.GetDoc()->GetAttrPool(), rAttr.Which(), rAttr.Which() ) + , m_pHistory( new SwHistory ) + , m_pRedlineData( 0 ) + , m_pRedlineSaveData( 0 ) + , m_nNodeIndex( ULONG_MAX ) + , m_nInsertFlags( nFlags ) { - aSet.Put( rAttr ); + m_AttrSet.Put( rAttr ); } SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxItemSet& rSet, USHORT nFlags ) - : SwUndo( UNDO_INSATTR ), SwUndRng( rRange ), aSet( rSet ), - pHistory( new SwHistory ), - pRedlData( 0 ), pRedlSaveData( 0 ), - nNdIdx( ULONG_MAX ), nInsFlags( nFlags ) + : SwUndo( UNDO_INSATTR ), SwUndRng( rRange ) + , m_AttrSet( rSet ) + , m_pHistory( new SwHistory ) + , m_pRedlineData( 0 ) + , m_pRedlineSaveData( 0 ) + , m_nNodeIndex( ULONG_MAX ) + , m_nInsertFlags( nFlags ) { } SwUndoAttr::~SwUndoAttr() { - delete pHistory; - delete pRedlData; - delete pRedlSaveData; } void SwUndoAttr::SaveRedlineData( const SwPaM& rPam, BOOL bIsCntnt ) { SwDoc* pDoc = rPam.GetDoc(); - if( pDoc->IsRedlineOn() ) - pRedlData = new SwRedlineData( bIsCntnt ? nsRedlineType_t::REDLINE_INSERT - : nsRedlineType_t::REDLINE_FORMAT, - pDoc->GetRedlineAuthor() ); + if ( pDoc->IsRedlineOn() ) + { + m_pRedlineData.reset( new SwRedlineData( bIsCntnt + ? nsRedlineType_t::REDLINE_INSERT + : nsRedlineType_t::REDLINE_FORMAT, + pDoc->GetRedlineAuthor() ) ); + } - pRedlSaveData = new SwRedlineSaveDatas; - if( !FillSaveDataForFmt( rPam, *pRedlSaveData )) - delete pRedlSaveData, pRedlSaveData = 0; + m_pRedlineSaveData.reset( new SwRedlineSaveDatas ); + if ( !FillSaveDataForFmt( rPam, *m_pRedlineSaveData )) + { + m_pRedlineSaveData.reset(0); + } SetRedlineMode( pDoc->GetRedlineMode() ); - if( bIsCntnt ) - nNdIdx = rPam.GetPoint()->nNode.GetIndex(); + if ( bIsCntnt ) + { + m_nNodeIndex = rPam.GetPoint()->nNode.GetIndex(); + } } void SwUndoAttr::Undo( SwUndoIter& rUndoIter ) @@ -834,10 +876,10 @@ void SwUndoAttr::Undo( SwUndoIter& rUndoIter ) if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) ) { SwPaM& rPam = *rUndoIter.pAktPam; - if( ULONG_MAX != nNdIdx ) + if ( ULONG_MAX != m_nNodeIndex ) { rPam.DeleteMark(); - rPam.GetPoint()->nNode = nNdIdx; + rPam.GetPoint()->nNode = m_nNodeIndex; rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nSttCntnt ); rPam.SetMark(); rPam.GetPoint()->nContent++; @@ -848,20 +890,22 @@ void SwUndoAttr::Undo( SwUndoIter& rUndoIter ) // alle Format-Redlines entfernen, werden ggfs. neu gesetzt SetPaM( rUndoIter ); pDoc->DeleteRedline( rPam, false, nsRedlineType_t::REDLINE_FORMAT ); - if( pRedlSaveData ) - SetSaveData( *pDoc, *pRedlSaveData ); + if ( m_pRedlineSaveData.get() ) + { + SetSaveData( *pDoc, *m_pRedlineSaveData ); + } } } - BOOL bToLast = 1 == aSet.Count() && - RES_TXTATR_FIELD <= *aSet.GetRanges() && - *aSet.GetRanges() <= RES_TXTATR_HARDBLANK; + const bool bToLast = (1 == m_AttrSet.Count()) + && (RES_TXTATR_FIELD <= *m_AttrSet.GetRanges()) + && (*m_AttrSet.GetRanges() <= RES_TXTATR_HARDBLANK); - // die alten Werte wieder zurueck - pHistory->TmpRollback( pDoc, 0, !bToLast ); - pHistory->SetTmpEnd( pHistory->Count() ); + // restore old values + m_pHistory->TmpRollback( pDoc, 0, !bToLast ); + m_pHistory->SetTmpEnd( m_pHistory->Count() ); - // setze noch den Cursor auf den Undo-Bereich + // set cursor onto Undo area SetPaM( rUndoIter ); } @@ -889,22 +933,30 @@ int lcl_HasEqualItems( const SfxItemSet& rSet1, const SfxItemSet& rSet2 ) void SwUndoAttr::Repeat( SwUndoIter& rUndoIter ) { - SwUndoAttr* pLast; - if( UNDO_INSATTR == rUndoIter.GetLastUndoId() && - ( pLast = ((SwUndoAttr*)rUndoIter.pLastUndoObj))->aSet.Count() == - aSet.Count() && pLast->nInsFlags == nInsFlags && - lcl_HasEqualItems( aSet, pLast->aSet )) - return; + if ( UNDO_INSATTR == rUndoIter.GetLastUndoId() ) + { + SwUndoAttr* pLast = static_cast<SwUndoAttr*>(rUndoIter.pLastUndoObj); + if ((pLast->m_AttrSet.Count() == m_AttrSet.Count()) && + (pLast->m_nInsertFlags == m_nInsertFlags ) && + lcl_HasEqualItems( m_AttrSet, pLast->m_AttrSet )) + { + return; + } + } - // RefMarks sind nicht repeatfaehig - if( SFX_ITEM_SET != aSet.GetItemState( RES_TXTATR_REFMARK, FALSE ) ) - rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, aSet, nInsFlags ); - else if( 1 < aSet.Count() ) + // RefMarks are not repeat capable + if ( SFX_ITEM_SET != m_AttrSet.GetItemState( RES_TXTATR_REFMARK, FALSE ) ) { - SfxItemSet aTmpSet( aSet ); + rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, + m_AttrSet, m_nInsertFlags ); + } + else if ( 1 < m_AttrSet.Count() ) + { + SfxItemSet aTmpSet( m_AttrSet ); aTmpSet.ClearItem( RES_TXTATR_REFMARK ); - rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, aTmpSet, nInsFlags ); + rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, + aTmpSet, m_nInsertFlags ); } rUndoIter.pLastUndoObj = this; } @@ -916,26 +968,35 @@ void SwUndoAttr::Redo( SwUndoIter& rUndoIter ) SwPaM& rPam = *rUndoIter.pAktPam; SwDoc& rDoc = rUndoIter.GetDoc(); - if( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) ) + if ( m_pRedlineData.get() && + IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) ) { RedlineMode_t eOld = rDoc.GetRedlineMode(); - rDoc.SetRedlineMode_intern((RedlineMode_t)(eOld & ~nsRedlineMode_t::REDLINE_IGNORE)); - rDoc.Insert( rPam, aSet, nInsFlags ); + rDoc.SetRedlineMode_intern(static_cast<RedlineMode_t>( + eOld & ~nsRedlineMode_t::REDLINE_IGNORE)); + rDoc.Insert( rPam, m_AttrSet, m_nInsertFlags ); - if( ULONG_MAX != nNdIdx ) + if ( ULONG_MAX != m_nNodeIndex ) { rPam.SetMark(); - if( rPam.Move( fnMoveBackward ) ) - rDoc.AppendRedline( new SwRedline( *pRedlData, rPam ), true); + if ( rPam.Move( fnMoveBackward ) ) + { + rDoc.AppendRedline( new SwRedline( *m_pRedlineData, rPam ), + true); + } rPam.DeleteMark(); } else - rDoc.AppendRedline( new SwRedline( *pRedlData, rPam ), true); + { + rDoc.AppendRedline( new SwRedline( *m_pRedlineData, rPam ), true); + } rDoc.SetRedlineMode_intern( eOld ); } else - rDoc.Insert( rPam, aSet, nInsFlags ); + { + rDoc.Insert( rPam, m_AttrSet, m_nInsertFlags ); + } rUndoIter.pLastUndoObj = 0; } @@ -943,38 +1004,52 @@ void SwUndoAttr::Redo( SwUndoIter& rUndoIter ) void SwUndoAttr::RemoveIdx( SwDoc& rDoc ) { - if( SFX_ITEM_SET != aSet.GetItemState( RES_TXTATR_FTN, FALSE )) + if ( SFX_ITEM_SET != m_AttrSet.GetItemState( RES_TXTATR_FTN, FALSE )) return ; - SwHstryHint* pHstHnt; + SwHistoryHint* pHstHnt; SwNodes& rNds = rDoc.GetNodes(); - for( USHORT n = 0; n < pHistory->Count(); ++n ) + for ( USHORT n = 0; n < m_pHistory->Count(); ++n ) { xub_StrLen nCntnt = 0; ULONG nNode = 0; - switch( ( pHstHnt = (*pHistory)[ n ] )->Which() ) + pHstHnt = (*m_pHistory)[ n ]; + switch ( pHstHnt->Which() ) { - case HSTRY_RESETTXTHNT: - if( RES_TXTATR_FTN == ((SwResetTxtHint*)pHstHnt)->GetWhich() ) - { - nNode = ((SwResetTxtHint*)pHstHnt)->GetNode(); - nCntnt = ((SwResetTxtHint*)pHstHnt)->GetCntnt(); - } - break; - case HSTRY_RESETATTRSET: - if( STRING_MAXLEN != ( nCntnt = - ((SwHstryResetAttrSet*)pHstHnt)->GetCntnt() )) - { - const SvUShorts& rArr = ((SwHstryResetAttrSet*)pHstHnt)->GetArr(); - for( USHORT i = rArr.Count(); i; ) - if( RES_TXTATR_FTN == rArr[ --i ] ) + case HSTRY_RESETTXTHNT: + { + SwHistoryResetTxt * pHistoryHint + = static_cast<SwHistoryResetTxt*>(pHstHnt); + if ( RES_TXTATR_FTN == pHistoryHint->GetWhich() ) { - nNode = ((SwHstryResetAttrSet*)pHstHnt)->GetNode(); - break; + nNode = pHistoryHint->GetNode(); + nCntnt = pHistoryHint->GetCntnt(); } - } - break; - default: break; + } + break; + + case HSTRY_RESETATTRSET: + { + SwHistoryResetAttrSet * pHistoryHint + = static_cast<SwHistoryResetAttrSet*>(pHstHnt); + nCntnt = pHistoryHint->GetCntnt(); + if ( STRING_MAXLEN != nCntnt ) + { + const SvUShorts& rArr = pHistoryHint->GetArr(); + for ( USHORT i = rArr.Count(); i; ) + { + if ( RES_TXTATR_FTN == rArr[ --i ] ) + { + nNode = pHistoryHint->GetNode(); + break; + } + } + } + } + break; + + default: + break; } if( nNode ) @@ -987,7 +1062,7 @@ void SwUndoAttr::RemoveIdx( SwDoc& rDoc ) if( pTxtHt ) { // ok, dann hole mal die Werte - SwTxtFtn* pFtn = (SwTxtFtn*)pTxtHt; + SwTxtFtn* pFtn = static_cast<SwTxtFtn*>(pTxtHt); RemoveIdxFromSection( rDoc, pFtn->GetStartNode()->GetIndex() ); return ; } @@ -996,55 +1071,54 @@ void SwUndoAttr::RemoveIdx( SwDoc& rDoc ) } } -/* */ +// ----------------------------------------------------- SwUndoDefaultAttr::SwUndoDefaultAttr( const SfxItemSet& rSet ) - : SwUndo( UNDO_SETDEFTATTR ), pOldSet( 0 ), pTabStop( 0 ) + : SwUndo( UNDO_SETDEFTATTR ) + , m_pOldSet( 0 ) + , m_pTabStop( 0 ) { const SfxPoolItem* pItem; if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_TABSTOP, FALSE, &pItem ) ) { - pTabStop = (SvxTabStopItem*)pItem->Clone(); // gesondert merken, aendert sich !!! - if( 1 != rSet.Count() ) // gibts noch mehr Attribute ? - pOldSet = new SfxItemSet( rSet ); + // store separately, because it may change! + m_pTabStop.reset( static_cast<SvxTabStopItem*>(pItem->Clone()) ); + if ( 1 != rSet.Count() ) // are there more attributes? + { + m_pOldSet.reset( new SfxItemSet( rSet ) ); + } } else - pOldSet = new SfxItemSet( rSet ); + { + m_pOldSet.reset( new SfxItemSet( rSet ) ); + } } SwUndoDefaultAttr::~SwUndoDefaultAttr() { - if( pOldSet ) - delete pOldSet; - if( pTabStop ) - delete pTabStop; } void SwUndoDefaultAttr::Undo( SwUndoIter& rUndoIter) { SwDoc& rDoc = rUndoIter.GetDoc(); - if( pOldSet ) + if ( m_pOldSet.get() ) { - _UndoFmtAttr aTmp( *(SwTxtFmtColl*)rDoc.GetDfltTxtFmtColl() ); - rDoc.SetDefault( *pOldSet ); - delete pOldSet; - if( aTmp.pUndo ) + SwUndoFmtAttrHelper aTmp( + *const_cast<SwTxtFmtColl*>(rDoc.GetDfltTxtFmtColl()) ); + rDoc.SetDefault( *m_pOldSet ); + m_pOldSet.reset( 0 ); + if ( aTmp.GetUndo() ) { - pOldSet = aTmp.pUndo->pOldSet; - aTmp.pUndo->pOldSet = 0; // den Pointer auf 0 setzen (nicht - // doppelt loeschen) !! - delete aTmp.pUndo; // Undo-Object wieder loeschen + // transfer ownership of helper object's old set + m_pOldSet = aTmp.GetUndo()->m_pOldSet; } - else - pOldSet = 0; } - if( pTabStop ) + if ( m_pTabStop.get() ) { - SvxTabStopItem* pOld = (SvxTabStopItem*)rDoc.GetDefault( - RES_PARATR_TABSTOP ).Clone(); - rDoc.SetDefault( *pTabStop ); - delete pTabStop; - pTabStop = pOld; + SvxTabStopItem* pOld = static_cast<SvxTabStopItem*>( + rDoc.GetDefault( RES_PARATR_TABSTOP ).Clone() ); + rDoc.SetDefault( *m_pTabStop ); + m_pTabStop.reset( pOld ); } } @@ -1053,19 +1127,19 @@ void SwUndoDefaultAttr::Redo( SwUndoIter& rUndoIter) Undo( rUndoIter ); } -/* */ +// ----------------------------------------------------- -SwUndoMoveLeftMargin::SwUndoMoveLeftMargin( const SwPaM& rPam, BOOL bFlag, - BOOL bMod ) - : SwUndo( bFlag ? UNDO_INC_LEFTMARGIN : UNDO_DEC_LEFTMARGIN ), - SwUndRng( rPam ), bModulus( bMod ) +SwUndoMoveLeftMargin::SwUndoMoveLeftMargin( + const SwPaM& rPam, BOOL bFlag, BOOL bMod ) + : SwUndo( bFlag ? UNDO_INC_LEFTMARGIN : UNDO_DEC_LEFTMARGIN ) + , SwUndRng( rPam ) + , m_pHistory( new SwHistory ) + , m_bModulus( bMod ) { - pHistory = new SwHistory; } SwUndoMoveLeftMargin::~SwUndoMoveLeftMargin() { - delete pHistory; } void SwUndoMoveLeftMargin::Undo( SwUndoIter& rIter ) @@ -1074,9 +1148,9 @@ void SwUndoMoveLeftMargin::Undo( SwUndoIter& rIter ) BOOL bUndo = pDoc->DoesUndo(); pDoc->DoUndo( FALSE ); - // die alten Werte wieder zurueck - pHistory->TmpRollback( pDoc, 0 ); - pHistory->SetTmpEnd( pHistory->Count() ); + // restore old values + m_pHistory->TmpRollback( pDoc, 0 ); + m_pHistory->SetTmpEnd( m_pHistory->Count() ); pDoc->DoUndo( bUndo ); SetPaM( rIter ); @@ -1086,32 +1160,36 @@ void SwUndoMoveLeftMargin::Redo( SwUndoIter& rIter ) { SwDoc* pDoc = &rIter.GetDoc(); SetPaM( rIter ); - pDoc->MoveLeftMargin( *rIter.pAktPam, GetId() == UNDO_INC_LEFTMARGIN, bModulus ); + pDoc->MoveLeftMargin( *rIter.pAktPam, GetId() == UNDO_INC_LEFTMARGIN, + m_bModulus ); } void SwUndoMoveLeftMargin::Repeat( SwUndoIter& rIter ) { SwDoc* pDoc = &rIter.GetDoc(); - pDoc->MoveLeftMargin( *rIter.pAktPam, GetId() == UNDO_INC_LEFTMARGIN, bModulus ); + pDoc->MoveLeftMargin( *rIter.pAktPam, GetId() == UNDO_INC_LEFTMARGIN, + m_bModulus ); rIter.pLastUndoObj = this; } -/* */ +// ----------------------------------------------------- -SwUndoChgFtn::SwUndoChgFtn( const SwPaM& rRange, const String& rTxt, - USHORT nNum, BOOL bIsEndNote ) - : SwUndo( UNDO_CHGFTN ), SwUndRng( rRange ), - pHistory( new SwHistory() ), - sTxt( rTxt ), nNo( nNum ), bEndNote( bIsEndNote ) +SwUndoChangeFootNote::SwUndoChangeFootNote( + const SwPaM& rRange, const String& rTxt, + USHORT nNum, bool bIsEndNote ) + : SwUndo( UNDO_CHGFTN ), SwUndRng( rRange ) + , m_pHistory( new SwHistory() ) + , m_Text( rTxt ) + , m_nNumber( nNum ) + , m_bEndNote( bIsEndNote ) { } -SwUndoChgFtn::~SwUndoChgFtn() +SwUndoChangeFootNote::~SwUndoChangeFootNote() { - delete pHistory; } -void SwUndoChgFtn::Undo( SwUndoIter& rIter ) +void SwUndoChangeFootNote::Undo( SwUndoIter& rIter ) { SwDoc& rDoc = rIter.GetDoc(); SetPaM( rIter ); @@ -1119,8 +1197,8 @@ void SwUndoChgFtn::Undo( SwUndoIter& rIter ) BOOL bUndo = rDoc.DoesUndo(); rDoc.DoUndo( FALSE ); - pHistory->TmpRollback( &rDoc, 0 ); - pHistory->SetTmpEnd( pHistory->Count() ); + m_pHistory->TmpRollback( &rDoc, 0 ); + m_pHistory->SetTmpEnd( m_pHistory->Count() ); rDoc.GetFtnIdxs().UpdateAllFtn(); @@ -1128,89 +1206,85 @@ void SwUndoChgFtn::Undo( SwUndoIter& rIter ) rDoc.DoUndo( bUndo ); } -void SwUndoChgFtn::Redo( SwUndoIter& rIter ) +void SwUndoChangeFootNote::Redo( SwUndoIter& rIter ) { SetPaM( rIter ); - rIter.GetDoc().SetCurFtn( *rIter.pAktPam, sTxt, nNo, bEndNote ); + rIter.GetDoc().SetCurFtn( *rIter.pAktPam, m_Text, m_nNumber, m_bEndNote ); SetPaM( rIter ); } -void SwUndoChgFtn::Repeat( SwUndoIter& rIter ) +void SwUndoChangeFootNote::Repeat( SwUndoIter& rIter ) { SwDoc& rDoc = rIter.GetDoc(); - rDoc.SetCurFtn( *rIter.pAktPam, sTxt, nNo, bEndNote ); + rDoc.SetCurFtn( *rIter.pAktPam, m_Text, m_nNumber, m_bEndNote ); rIter.pLastUndoObj = this; } -/* */ +// ----------------------------------------------------- -SwUndoFtnInfo::SwUndoFtnInfo( const SwFtnInfo &rInfo ) : - SwUndo( UNDO_FTNINFO ), - pFtnInfo( new SwFtnInfo( rInfo ) ) +SwUndoFootNoteInfo::SwUndoFootNoteInfo( const SwFtnInfo &rInfo ) + : SwUndo( UNDO_FTNINFO ) + , m_pFootNoteInfo( new SwFtnInfo( rInfo ) ) { } -SwUndoFtnInfo::~SwUndoFtnInfo() +SwUndoFootNoteInfo::~SwUndoFootNoteInfo() { - delete pFtnInfo; } -void SwUndoFtnInfo::Undo( SwUndoIter &rIter ) +void SwUndoFootNoteInfo::Undo( SwUndoIter &rIter ) { SwDoc &rDoc = rIter.GetDoc(); SwFtnInfo *pInf = new SwFtnInfo( rDoc.GetFtnInfo() ); - rDoc.SetFtnInfo( *pFtnInfo ); - delete pFtnInfo; - pFtnInfo = pInf; + rDoc.SetFtnInfo( *m_pFootNoteInfo ); + m_pFootNoteInfo.reset( pInf ); } -void SwUndoFtnInfo::Redo( SwUndoIter &rIter ) +void SwUndoFootNoteInfo::Redo( SwUndoIter &rIter ) { SwDoc &rDoc = rIter.GetDoc(); SwFtnInfo *pInf = new SwFtnInfo( rDoc.GetFtnInfo() ); - rDoc.SetFtnInfo( *pFtnInfo ); - delete pFtnInfo; - pFtnInfo = pInf; + rDoc.SetFtnInfo( *m_pFootNoteInfo ); + m_pFootNoteInfo.reset( pInf ); } -/* */ -SwUndoEndNoteInfo::SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo ) : - SwUndo( UNDO_FTNINFO ), - pEndNoteInfo( new SwEndNoteInfo( rInfo ) ) +// ----------------------------------------------------- + +SwUndoEndNoteInfo::SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo ) + : SwUndo( UNDO_FTNINFO ) + , m_pEndNoteInfo( new SwEndNoteInfo( rInfo ) ) { } SwUndoEndNoteInfo::~SwUndoEndNoteInfo() { - delete pEndNoteInfo; } void SwUndoEndNoteInfo::Undo( SwUndoIter &rIter ) { SwDoc &rDoc = rIter.GetDoc(); SwEndNoteInfo *pInf = new SwEndNoteInfo( rDoc.GetEndNoteInfo() ); - rDoc.SetEndNoteInfo( *pEndNoteInfo ); - delete pEndNoteInfo; - pEndNoteInfo = pInf; + rDoc.SetEndNoteInfo( *m_pEndNoteInfo ); + m_pEndNoteInfo.reset( pInf ); } void SwUndoEndNoteInfo::Redo( SwUndoIter &rIter ) { SwDoc &rDoc = rIter.GetDoc(); SwEndNoteInfo *pInf = new SwEndNoteInfo( rDoc.GetEndNoteInfo() ); - rDoc.SetEndNoteInfo( *pEndNoteInfo ); - delete pEndNoteInfo; - pEndNoteInfo = pInf; + rDoc.SetEndNoteInfo( *m_pEndNoteInfo ); + m_pEndNoteInfo.reset( pInf ); } -/* */ +// ----------------------------------------------------- SwUndoDontExpandFmt::SwUndoDontExpandFmt( const SwPosition& rPos ) - : SwUndo( UNDO_DONTEXPAND ), - nNode( rPos.nNode.GetIndex() ), nCntnt( rPos.nContent.GetIndex() ) + : SwUndo( UNDO_DONTEXPAND ) + , m_nNodeIndex( rPos.nNode.GetIndex() ) + , m_nContentIndex( rPos.nContent.GetIndex() ) { } @@ -1220,8 +1294,8 @@ void SwUndoDontExpandFmt::Undo( SwUndoIter& rIter ) SwDoc* pDoc = pPam->GetDoc(); SwPosition& rPos = *pPam->GetPoint(); - rPos.nNode = nNode; - rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), nCntnt ); + rPos.nNode = m_nNodeIndex; + rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), m_nContentIndex); pDoc->DontExpandFmt( rPos, FALSE ); } @@ -1232,8 +1306,8 @@ void SwUndoDontExpandFmt::Redo( SwUndoIter& rIter ) SwDoc* pDoc = pPam->GetDoc(); SwPosition& rPos = *pPam->GetPoint(); - rPos.nNode = nNode; - rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), nCntnt ); + rPos.nNode = m_nNodeIndex; + rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), m_nContentIndex); pDoc->DontExpandFmt( rPos ); } @@ -1244,5 +1318,3 @@ void SwUndoDontExpandFmt::Repeat( SwUndoIter& rIter ) pDoc->DontExpandFmt( *pPam->GetPoint() ); } - - diff --git a/sw/source/core/undo/unbkmk.cxx b/sw/source/core/undo/unbkmk.cxx index 86a7797fe494..f49cea5ac7d3 100644 --- a/sw/source/core/undo/unbkmk.cxx +++ b/sw/source/core/undo/unbkmk.cxx @@ -43,51 +43,54 @@ #include "SwRewriter.hxx" + inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } -SwUndoBookmark::SwUndoBookmark( SwUndoId nUndoId, const ::sw::mark::IMark& rBkmk ) +SwUndoBookmark::SwUndoBookmark( SwUndoId nUndoId, + const ::sw::mark::IMark& rBkmk ) : SwUndo( nUndoId ) + , m_pHistoryBookmark(new SwHistoryBookmark(rBkmk, true, rBkmk.IsExpanded())) { - pHBookmark = new SwHstryBookmark(rBkmk, true, rBkmk.IsExpanded()); } - - SwUndoBookmark::~SwUndoBookmark() { - delete pHBookmark; } - void SwUndoBookmark::SetInDoc( SwDoc* pDoc ) { - pHBookmark->SetInDoc( pDoc, FALSE ); + m_pHistoryBookmark->SetInDoc( pDoc, false ); } void SwUndoBookmark::ResetInDoc( SwDoc* pDoc ) { IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); - for(IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->getMarksBegin(); - ppBkmk != pMarkAccess->getMarksEnd(); - ppBkmk++) - if( pHBookmark->IsEqualBookmark( **ppBkmk )) + for (IDocumentMarkAccess::const_iterator_t ppBkmk = + pMarkAccess->getMarksBegin(); + ppBkmk != pMarkAccess->getMarksEnd(); + ++ppBkmk) + { + if ( m_pHistoryBookmark->IsEqualBookmark( **ppBkmk ) ) { - pMarkAccess->deleteMark( ppBkmk ); - break; + pMarkAccess->deleteMark( ppBkmk ); + break; } + } } SwRewriter SwUndoBookmark::GetRewriter() const { SwRewriter aResult; - aResult.AddRule(UNDO_ARG1, pHBookmark->GetName()); + aResult.AddRule(UNDO_ARG1, m_pHistoryBookmark->GetName()); return aResult; } +//---------------------------------------------------------------------- + SwUndoDelBookmark::SwUndoDelBookmark( const ::sw::mark::IMark& rBkmk ) : SwUndoBookmark( UNDO_DELBOOKMARK, rBkmk ) { diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index e3ad5aa726f3..0ed447d8204f 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -371,11 +371,10 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, xub_StrLen nLen = bOneNode ? nEndCntnt - nSttCntnt : pSttTxtNd->GetTxt().Len() - nSttCntnt; SwRegHistory aRHst( *pSttTxtNd, pHistory ); - // immer alle TextAttribute sichern; ist fuers Undo mit voll- - // staendiger Attributierung am besten, wegen den evt. - // Ueberlappenden Bereichen von An/Aus. + // always save all text atttibutes because of possibly overlapping + // areas of on/off pHistory->CopyAttr( pSttTxtNd->GetpSwpHints(), nNdIdx, - 0, pSttTxtNd->GetTxt().Len(), TRUE ); + 0, pSttTxtNd->GetTxt().Len(), true ); if( !bOneNode && pSttTxtNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pSttTxtNd->GetpSwAttrSet(), nNdIdx ); @@ -383,6 +382,7 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, nLen = ( bOneNode ? pEnd->nContent.GetIndex() : pSttTxtNd->GetTxt().Len() ) - pStt->nContent.GetIndex(); + // loesche jetzt noch den Text (alle Attribut-Aenderungen kommen in // die Undo-History pSttStr = (String*)new String( pSttTxtNd->GetTxt().Copy( nSttCntnt, nLen )); @@ -390,6 +390,13 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, if( pSttTxtNd->GetpSwpHints() ) pSttTxtNd->GetpSwpHints()->DeRegister(); + // METADATA: store + bool emptied( pSttStr->Len() && !pSttTxtNd->Len() ); + if (!bOneNode || emptied) // merging may overwrite xmlids... + { + m_pMetadataUndoStart = pSttTxtNd->CreateUndo( emptied ); + } + if( bOneNode ) return FALSE; // keine Nodes mehr verschieben } @@ -402,15 +409,15 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, nNdIdx = pEnd->nNode.GetIndex(); SwRegHistory aRHst( *pEndTxtNd, pHistory ); - // immer alle TextAttribute sichern; ist fuers Undo mit voll- - // staendiger Attributierung am besten, wegen den evt. - // Ueberlappenden Bereichen von An/Aus. + // always save all text atttibutes because of possibly overlapping + // areas of on/off pHistory->CopyAttr( pEndTxtNd->GetpSwpHints(), nNdIdx, 0, - pEndTxtNd->GetTxt().Len(), TRUE ); + pEndTxtNd->GetTxt().Len(), true ); if( pEndTxtNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pEndTxtNd->GetpSwAttrSet(), nNdIdx ); + // loesche jetzt noch den Text (alle Attribut-Aenderungen kommen in // die Undo-History pEndStr = (String*)new String( pEndTxtNd->GetTxt().Copy( 0, @@ -418,6 +425,10 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, pEndTxtNd->Erase( aEndIdx, pEnd->nContent.GetIndex() ); if( pEndTxtNd->GetpSwpHints() ) pEndTxtNd->GetpSwpHints()->DeRegister(); + + // METADATA: store + bool emptied( pEndStr->Len() && !pEndTxtNd->Len() ); + m_pMetadataUndoEnd = pEndTxtNd->CreateUndo( emptied ); } // sind es nur zwei Nodes, dann ist schon alles erledigt. @@ -698,8 +709,12 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) lcl_ReAnchorAtCntntFlyFrames( *pDoc->GetSpzFrmFmts(), aPos, nOldIdx ); pTxtNd = aPos.nNode.GetNode().GetTxtNode(); } - if( pTxtNd ) // Robust + if( pTxtNd ) + { pTxtNd->Insert( *pEndStr, aPos.nContent, INS_NOHINTEXPAND ); + // METADATA: restore + pTxtNd->RestoreMetadata(m_pMetadataUndoEnd); + } } else if( pSttStr && bNodeMove ) { @@ -757,7 +772,7 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) } else { - aPos = aCopyIndex; + aPos = SwPosition( aCopyIndex ); nMoveIndex = aPos.nNode.GetIndex() + nReplaceDummy + 1; } SwNodeIndex aMvIdx( pDoc->GetNodes(), nMoveIndex ); @@ -790,12 +805,14 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) // -> im StartNode steht noch der Rest vom Join => loeschen aPos.nContent.Assign( pTxtNd, nSttCntnt ); pTxtNd->Insert( *pSttStr, aPos.nContent, INS_NOHINTEXPAND ); + // METADATA: restore + pTxtNd->RestoreMetadata(m_pMetadataUndoStart); } } if( pHistory ) { - pHistory->TmpRollback( pDoc, nSetPos, FALSE ); + pHistory->TmpRollback( pDoc, nSetPos, false ); if( nSetPos ) // es gab Fussnoten/FlyFrames { // gibts ausser diesen noch andere ? diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index 1b7f97b70a20..ae9535ced2f7 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -540,7 +540,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, SwTxtAttr* pFtnHnt = pTxtNd->GetTxtAttr( nFtnSttIdx ); ASSERT( pFtnHnt, "kein FtnAttribut" ); SwIndex aIdx( pTxtNd, nFtnSttIdx ); - pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), FALSE ); + pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), false ); pTxtNd->Erase( aIdx, 1 ); } @@ -563,7 +563,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, SwTxtAttr* pFtnHnt = pTxtNd->GetTxtAttr( nFtnSttIdx ); ASSERT( pFtnHnt, "kein FtnAttribut" ); SwIndex aIdx( pTxtNd, nFtnSttIdx ); - pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), FALSE ); + pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), false ); pTxtNd->Erase( aIdx, 1 ); } } @@ -600,7 +600,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, SwTxtNode* pTxtNd = pDoc->GetNodes()[ pAPos->nNode]->GetTxtNode(); SwTxtAttr* pFlyHnt = pTxtNd->GetTxtAttr( pAPos->nContent.GetIndex()); ASSERT( pFlyHnt, "kein FlyAttribut" ); - pHistory->Add( pFlyHnt, 0, FALSE ); + pHistory->Add( pFlyHnt, 0, false ); // n wieder zurueck, damit nicht ein Format uebesprungen wird ! n = n >= rSpzArr.Count() ? rSpzArr.Count() : n+1; } diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index 41a9ef71647c..1335844c7ff9 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -66,11 +66,14 @@ using namespace ::com::sun::star; class _UnReplaceData : private SwUndoSaveCntnt { - String sOld, sIns; - ULONG nSttNd, nEndNd, nOffset; - xub_StrLen nSttCnt, nEndCnt, nSetPos, nSelEnd; - BOOL bSplitNext : 1; - BOOL bRegExp : 1; + String m_sOld, m_sIns; + ULONG m_nSttNd, m_nEndNd, m_nOffset; + xub_StrLen m_nSttCnt, m_nEndCnt, m_nSetPos, m_nSelEnd; + BOOL m_bSplitNext : 1; + BOOL m_bRegExp : 1; + // metadata references for paragraph and following para (if m_bSplitNext) + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart; + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd; public: _UnReplaceData( const SwPaM& rPam, const String& rIns, BOOL bRegExp ); @@ -80,8 +83,8 @@ public: void Redo( SwUndoIter& rIter ); void SetEnd( const SwPaM& rPam ); - const String & GetOld() const { return sOld; } - const String & GetIns() const { return sIns; } + const String & GetOld() const { return m_sOld; } + const String & GetIns() const { return m_sIns; } }; @@ -626,20 +629,18 @@ void SwUndoReplace::SetEntryEnd( const SwPaM& rPam ) _UnReplaceData::_UnReplaceData( const SwPaM& rPam, const String& rIns, BOOL bRgExp ) - : sIns( rIns ), nOffset( 0 ) + : m_sIns( rIns ), m_nOffset( 0 ) { - bRegExp = bRgExp; + m_bRegExp = bRgExp; - const SwPosition *pStt = rPam.Start(), - *pEnd = rPam.GetPoint() == pStt - ? rPam.GetMark() - : rPam.GetPoint(); + const SwPosition * pStt( rPam.Start() ); + const SwPosition * pEnd( rPam.End() ); - nSttNd = nEndNd = pStt->nNode.GetIndex(); - nSttCnt = pStt->nContent.GetIndex(); - nSelEnd = nEndCnt = pEnd->nContent.GetIndex(); + m_nSttNd = m_nEndNd = pStt->nNode.GetIndex(); + m_nSttCnt = pStt->nContent.GetIndex(); + m_nSelEnd = m_nEndCnt = pEnd->nContent.GetIndex(); - bSplitNext = nSttNd != pEnd->nNode.GetIndex(); + m_bSplitNext = m_nSttNd != pEnd->nNode.GetIndex(); SwTxtNode* pNd = pStt->nNode.GetNode().GetTxtNode(); ASSERT( pNd, "wo ist der TextNode" ); @@ -647,16 +648,18 @@ _UnReplaceData::_UnReplaceData( const SwPaM& rPam, const String& rIns, pHistory = new SwHistory; DelCntntIndex( *rPam.GetMark(), *rPam.GetPoint() ); - nSetPos = pHistory->Count(); + m_nSetPos = pHistory->Count(); ULONG nNewPos = pStt->nNode.GetIndex(); - nOffset = nSttNd - nNewPos; + m_nOffset = m_nSttNd - nNewPos; - if( pNd->GetpSwpHints() ) + if ( pNd->GetpSwpHints() ) + { pHistory->CopyAttr( pNd->GetpSwpHints(), nNewPos, 0, - pNd->GetTxt().Len(), TRUE ); + pNd->GetTxt().Len(), true ); + } - if( bSplitNext ) + if ( m_bSplitNext ) { if( pNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pNd->GetpSwAttrSet(), nNewPos ); @@ -665,17 +668,21 @@ _UnReplaceData::_UnReplaceData( const SwPaM& rPam, const String& rIns, SwTxtNode* pNext = pEnd->nNode.GetNode().GetTxtNode(); ULONG nTmp = pNext->GetIndex(); pHistory->CopyAttr( pNext->GetpSwpHints(), nTmp, 0, - pNext->GetTxt().Len(), TRUE ); + pNext->GetTxt().Len(), true ); if( pNext->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pNext->GetpSwAttrSet(), nTmp ); pHistory->Add( pNext->GetTxtColl(),nTmp, ND_TEXTNODE ); + // METADATA: store + m_pMetadataUndoStart = pNd ->CreateUndo(); + m_pMetadataUndoEnd = pNext->CreateUndo(); } if( !pHistory->Count() ) delete pHistory, pHistory = 0; - xub_StrLen nECnt = bSplitNext ? pNd->GetTxt().Len() : pEnd->nContent.GetIndex(); - sOld = pNd->GetTxt().Copy( nSttCnt, nECnt - nSttCnt ); + xub_StrLen nECnt = m_bSplitNext ? pNd->GetTxt().Len() + : pEnd->nContent.GetIndex(); + m_sOld = pNd->GetTxt().Copy( m_nSttCnt, nECnt - m_nSttCnt ); } _UnReplaceData::~_UnReplaceData() @@ -688,72 +695,68 @@ void _UnReplaceData::Undo( SwUndoIter& rIter ) SwPaM& rPam = *rIter.pAktPam; rPam.DeleteMark(); - SwTxtNode* pNd = pDoc->GetNodes()[ nSttNd - nOffset ]->GetTxtNode(); + SwTxtNode* pNd = pDoc->GetNodes()[ m_nSttNd - m_nOffset ]->GetTxtNode(); ASSERT( pNd, "Wo ist der TextNode geblieben?" ) SwAutoCorrExceptWord* pACEWord = pDoc->GetAutoCorrExceptWord(); if( pACEWord ) { - if( 1 == sIns.Len() && 1 == sOld.Len() ) + if( 1 == m_sIns.Len() && 1 == m_sOld.Len() ) { - SwPosition aPos( *pNd ); aPos.nContent.Assign( pNd, nSttCnt ); - pACEWord->CheckChar( aPos, sOld.GetChar( 0 ) ); + SwPosition aPos( *pNd ); aPos.nContent.Assign( pNd, m_nSttCnt ); + pACEWord->CheckChar( aPos, m_sOld.GetChar( 0 ) ); } pDoc->SetAutoCorrExceptWord( 0 ); } - SwIndex aIdx( pNd, nSttCnt ); - if( nSttNd == nEndNd ) + SwIndex aIdx( pNd, m_nSttCnt ); + if( m_nSttNd == m_nEndNd ) { - pNd->Erase( aIdx, sIns.Len() ); -/* if( bSplitNext ) - { - SwPosition aPos( *pNd, aIdx ); - pDoc->SplitNode( aPos, FALSE ); - pNd = pDoc->GetNodes()[ nSttNd - nOffset ]->GetTxtNode(); - aIdx.Assign( pNd, nSttCnt ); - } -*/ } + pNd->Erase( aIdx, m_sIns.Len() ); + } else { rPam.GetPoint()->nNode = *pNd; - rPam.GetPoint()->nContent.Assign( pNd, nSttCnt ); + rPam.GetPoint()->nContent.Assign( pNd, m_nSttCnt ); rPam.SetMark(); - rPam.GetPoint()->nNode = nEndNd - nOffset; - rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nEndCnt ); + rPam.GetPoint()->nNode = m_nEndNd - m_nOffset; + rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), m_nEndCnt ); pDoc->DeleteAndJoin( rPam ); rPam.DeleteMark(); pNd = rPam.GetNode()->GetTxtNode(); ASSERT( pNd, "Wo ist der TextNode geblieben?" ); - aIdx.Assign( pNd, nSttCnt ); + aIdx.Assign( pNd, m_nSttCnt ); } - if( bSplitNext ) + if( m_bSplitNext ) { SwPosition aPos( *pNd, aIdx ); pDoc->SplitNode( aPos, false ); - pNd = pDoc->GetNodes()[ nSttNd - nOffset ]->GetTxtNode(); - aIdx.Assign( pNd, nSttCnt ); + pNd->RestoreMetadata(m_pMetadataUndoEnd); + pNd = pDoc->GetNodes()[ m_nSttNd - m_nOffset ]->GetTxtNode(); + aIdx.Assign( pNd, m_nSttCnt ); + // METADATA: restore + pNd->RestoreMetadata(m_pMetadataUndoStart); } - if( sOld.Len() ) - pNd->Insert( sOld, aIdx ); + if( m_sOld.Len() ) + pNd->Insert( m_sOld, aIdx ); if( pHistory ) { if( pNd->GetpSwpHints() ) pNd->ClearSwpHintsArr( true ); - pHistory->TmpRollback( pDoc, nSetPos, FALSE ); - if( nSetPos ) // es gab Fussnoten/FlyFrames + pHistory->TmpRollback( pDoc, m_nSetPos, false ); + if ( m_nSetPos ) // there were footnotes/FlyFrames { // gibts ausser diesen noch andere ? - if( nSetPos < pHistory->Count() ) + if( m_nSetPos < pHistory->Count() ) { // dann sicher die Attribute anderen Attribute SwHistory aHstr; - aHstr.Move( 0, pHistory, nSetPos ); + aHstr.Move( 0, pHistory, m_nSetPos ); pHistory->Rollback( pDoc ); pHistory->Move( 0, &aHstr ); } @@ -765,7 +768,7 @@ void _UnReplaceData::Undo( SwUndoIter& rIter ) } } - rPam.GetPoint()->nNode = nSttNd; + rPam.GetPoint()->nNode = m_nSttNd; rPam.GetPoint()->nContent = aIdx; } @@ -777,18 +780,18 @@ void _UnReplaceData::Redo( SwUndoIter& rIter ) SwPaM& rPam = *rIter.pAktPam; rPam.DeleteMark(); - rPam.GetPoint()->nNode = nSttNd; + rPam.GetPoint()->nNode = m_nSttNd; SwTxtNode* pNd = rPam.GetPoint()->nNode.GetNode().GetTxtNode(); ASSERT( pNd, "Wo ist der TextNode geblieben?" ) - rPam.GetPoint()->nContent.Assign( pNd, nSttCnt ); + rPam.GetPoint()->nContent.Assign( pNd, m_nSttCnt ); rPam.SetMark(); - if( bSplitNext ) + if( m_bSplitNext ) { - rPam.GetPoint()->nNode = nSttNd + 1; + rPam.GetPoint()->nNode = m_nSttNd + 1; pNd = rPam.GetPoint()->nNode.GetNode().GetTxtNode(); } - rPam.GetPoint()->nContent.Assign( pNd, nSelEnd ); + rPam.GetPoint()->nContent.Assign( pNd, m_nSelEnd ); if( pHistory ) { @@ -796,7 +799,7 @@ void _UnReplaceData::Redo( SwUndoIter& rIter ) SwHistory aHst; pHistory = &aHst; DelCntntIndex( *rPam.GetMark(), *rPam.GetPoint() ); - nSetPos = pHistory->Count(); + m_nSetPos = pHistory->Count(); pHistory = pSave; pHistory->Move( 0, &aHst ); @@ -805,12 +808,12 @@ void _UnReplaceData::Redo( SwUndoIter& rIter ) { pHistory = new SwHistory; DelCntntIndex( *rPam.GetMark(), *rPam.GetPoint() ); - nSetPos = pHistory->Count(); - if( !nSetPos ) + m_nSetPos = pHistory->Count(); + if( !m_nSetPos ) delete pHistory, pHistory = 0; } - rDoc.Replace( rPam, sIns, bRegExp ); + rDoc.Replace( rPam, m_sIns, m_bRegExp ); rPam.DeleteMark(); rDoc.DoUndo( bUndo ); } @@ -821,8 +824,8 @@ void _UnReplaceData::SetEnd( const SwPaM& rPam ) { // es wurden mehrere Absaetze eingefuegt const SwPosition* pEnd = rPam.End(); - nEndNd = nOffset + pEnd->nNode.GetIndex(); - nEndCnt = pEnd->nContent.GetIndex(); + m_nEndNd = m_nOffset + pEnd->nNode.GetIndex(); + m_nEndCnt = pEnd->nContent.GetIndex(); } } @@ -1087,10 +1090,12 @@ void SwUndoInsertLabel::SetFlys( SwFrmFmt& rOldFly, SfxItemSet& rChgSet, { if( LTYPE_OBJECT == eType || LTYPE_DRAW == eType ) { - _UndoFmtAttr aTmp( rOldFly, FALSE ); + SwUndoFmtAttrHelper aTmp( rOldFly, false ); rOldFly.SetFmtAttr( rChgSet ); - if( aTmp.pUndo ) - OBJECT.pUndoAttr = aTmp.pUndo; + if ( aTmp.GetUndo() ) + { + OBJECT.pUndoAttr = aTmp.ReleaseUndo(); + } OBJECT.pUndoFly = new SwUndoInsLayFmt( &rNewFly,0,0 ); } } diff --git a/sw/source/core/undo/unmove.cxx b/sw/source/core/undo/unmove.cxx index 067f6fda63c1..269f8de3cd63 100644 --- a/sw/source/core/undo/unmove.cxx +++ b/sw/source/core/undo/unmove.cxx @@ -62,18 +62,22 @@ SwUndoMove::SwUndoMove( const SwPaM& rRange, const SwPosition& rMvPos ) if( pTxtNd ) { pHistory->Add( pTxtNd->GetTxtColl(), nSttNode, ND_TEXTNODE ); - if( pTxtNd->GetpSwpHints() ) + if ( pTxtNd->GetpSwpHints() ) + { pHistory->CopyAttr( pTxtNd->GetpSwpHints(), nSttNode, - 0, pTxtNd->GetTxt().Len(), FALSE ); + 0, pTxtNd->GetTxt().Len(), false ); + } if( pTxtNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pTxtNd->GetpSwAttrSet(), nSttNode ); } if( pEndTxtNd && pEndTxtNd != pTxtNd ) { pHistory->Add( pEndTxtNd->GetTxtColl(), nEndNode, ND_TEXTNODE ); - if( pEndTxtNd->GetpSwpHints() ) + if ( pEndTxtNd->GetpSwpHints() ) + { pHistory->CopyAttr( pEndTxtNd->GetpSwpHints(), nEndNode, - 0, pEndTxtNd->GetTxt().Len(), FALSE ); + 0, pEndTxtNd->GetTxt().Len(), false ); + } if( pEndTxtNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pEndTxtNd->GetpSwAttrSet(), nEndNode ); } @@ -81,9 +85,11 @@ SwUndoMove::SwUndoMove( const SwPaM& rRange, const SwPosition& rMvPos ) if( 0 != (pTxtNd = rRange.GetDoc()->GetNodes()[ rMvPos.nNode ]->GetTxtNode() )) { pHistory->Add( pTxtNd->GetTxtColl(), nMvDestNode, ND_TEXTNODE ); - if( pTxtNd->GetpSwpHints() ) + if ( pTxtNd->GetpSwpHints() ) + { pHistory->CopyAttr( pTxtNd->GetpSwpHints(), nMvDestNode, - 0, pTxtNd->GetTxt().Len(), FALSE ); + 0, pTxtNd->GetTxt().Len(), false ); + } if( pTxtNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pTxtNd->GetpSwAttrSet(), nMvDestNode ); } diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx index a1d126e751cf..e01c2debaf56 100644 --- a/sw/source/core/undo/unovwr.cxx +++ b/sw/source/core/undo/unovwr.cxx @@ -97,7 +97,7 @@ SwUndoOverwrite::SwUndoOverwrite( SwDoc* pDoc, SwPosition& rPos, pHistory = new SwHistory; SwRegHistory aRHst( *pTxtNd, pHistory ); pHistory->CopyAttr( pTxtNd->GetpSwpHints(), nSttNode, 0, - nTxtNdLen, FALSE ); + nTxtNdLen, false ); rPos.nContent++; bInsChar = FALSE; } @@ -254,7 +254,7 @@ void SwUndoOverwrite::Undo( SwUndoIter& rUndoIter ) { if( pTxtNd->GetpSwpHints() ) pTxtNd->ClearSwpHintsArr( false ); - pHistory->TmpRollback( pDoc, 0, FALSE ); + pHistory->TmpRollback( pDoc, 0, false ); } if( pAktPam->GetMark()->nContent.GetIndex() != nSttCntnt ) @@ -420,7 +420,7 @@ void SwUndoTransliterate::Repeat( SwUndoIter& rUndoIter ) rUndoIter.pLastUndoObj = this; } -void SwUndoTransliterate::AddChanges( const SwTxtNode& rTNd, +void SwUndoTransliterate::AddChanges( SwTxtNode& rTNd, xub_StrLen nStart, xub_StrLen nLen, uno::Sequence <sal_Int32>& rOffsets ) { @@ -485,7 +485,7 @@ void SwUndoTransliterate::AddChanges( const SwTxtNode& rTNd, pNew->pHistory = new SwHistory; SwRegHistory aRHst( rTNd, pNew->pHistory ); pNew->pHistory->CopyAttr( rTNd.GetpSwpHints(), - pNew->nNdIdx, 0, rTNd.GetTxt().Len(), FALSE ); + pNew->nNdIdx, 0, rTNd.GetTxt().Len(), false ); } break; } @@ -511,7 +511,7 @@ void _UndoTransliterate_Data::SetChangeAtNode( SwDoc& rDoc ) { if( pTNd->GetpSwpHints() ) pTNd->ClearSwpHintsArr( false ); - pHistory->TmpRollback( &rDoc, 0, FALSE ); + pHistory->TmpRollback( &rDoc, 0, false ); pHistory->SetTmpEnd( pHistory->Count() ); } } diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx index 36f5f549562b..f26643a09352 100644 --- a/sw/source/core/undo/unsect.cxx +++ b/sw/source/core/undo/unsect.cxx @@ -167,8 +167,10 @@ void SwUndoInsSection::Undo( SwUndoIter& rUndoIter ) if( bSplitAtEnd ) Join( rDoc, nEndNode ); - if( pHistory ) - pHistory->TmpRollback( &rDoc, 0, FALSE ); + if ( pHistory ) + { + pHistory->TmpRollback( &rDoc, 0, false ); + } if( bUpdateFtn ) rDoc.GetFtnIdxs().UpdateFtn( aIdx ); @@ -265,7 +267,7 @@ void SwUndoInsSection::SaveSplitNode( SwTxtNode* pTxtNd, BOOL bAtStt ) if( !pHistory ) pHistory = new SwHistory; pHistory->CopyAttr( pTxtNd->GetpSwpHints(), pTxtNd->GetIndex(), 0, - pTxtNd->GetTxt().Len(), FALSE ); + pTxtNd->GetTxt().Len(), false ); } if( bAtStt ) diff --git a/sw/source/core/undo/unspnd.cxx b/sw/source/core/undo/unspnd.cxx index 96b0daf6a5df..31d2243c6b6c 100644 --- a/sw/source/core/undo/unspnd.cxx +++ b/sw/source/core/undo/unspnd.cxx @@ -66,7 +66,7 @@ SwUndoSplitNode::SwUndoSplitNode( SwDoc* pDoc, const SwPosition& rPos, { pHistory = new SwHistory; pHistory->CopyAttr( pTxtNd->GetpSwpHints(), nNode, 0, - pTxtNd->GetTxt().Len(), FALSE ); + pTxtNd->GetTxt().Len(), false ); if( !pHistory->Count() ) DELETEZ( pHistory ); } @@ -155,7 +155,7 @@ void SwUndoSplitNode::Undo( SwUndoIter& rUndoIter ) rPam.GetPoint()->nContent = pTNd->GetTxt().Len(); pDoc->RstTxtAttrs( rPam, TRUE ); - pHistory->TmpRollback( pDoc, 0, FALSE ); + pHistory->TmpRollback( pDoc, 0, false ); } } } diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index cbe7d97cd05b..93f6daf2c445 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -63,11 +63,10 @@ #include <node2lay.hxx> #include <tblrwcl.hxx> #include <fmtanchr.hxx> -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif #include <unochart.hxx> + #ifdef PRODUCT #define CHECK_TABLE(t) #else @@ -215,13 +214,16 @@ So we need to remember not only the start node position but the end node positio struct SwTblToTxtSave { - ULONG nNode; - ULONG nEndNd; - xub_StrLen nCntnt; - SwHistory* pHstry; + ULONG m_nSttNd; + ULONG m_nEndNd; + xub_StrLen m_nCntnt; + SwHistory* m_pHstry; + // metadata references for first and last paragraph in cell + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart; + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd; SwTblToTxtSave( SwDoc& rDoc, ULONG nNd, ULONG nEndIdx, xub_StrLen nCntnt ); - ~SwTblToTxtSave() { delete pHstry; } + ~SwTblToTxtSave() { delete m_pHstry; } }; SV_IMPL_PTRARR( SfxItemSets, SfxItemSetPtr ) @@ -387,26 +389,41 @@ SwRewriter SwUndoInsTbl::GetRewriter() const // ----------------------------------------------------- SwTblToTxtSave::SwTblToTxtSave( SwDoc& rDoc, ULONG nNd, ULONG nEndIdx, xub_StrLen nCnt ) - : nNode( nNd ), nEndNd( nEndIdx), nCntnt( nCnt ), pHstry( 0 ) + : m_nSttNd( nNd ), m_nEndNd( nEndIdx), m_nCntnt( nCnt ), m_pHstry( 0 ) { // Attributierung des gejointen Node merken. - if( USHRT_MAX != nCnt ) - ++nNd; - SwTxtNode* pNd = rDoc.GetNodes()[ nNd ]->GetTxtNode(); if( pNd ) { - pHstry = new SwHistory; + m_pHstry = new SwHistory; - pHstry->Add( pNd->GetTxtColl(), nNd, ND_TEXTNODE ); - if( pNd->GetpSwpHints() ) - pHstry->CopyAttr( pNd->GetpSwpHints(), nNd, 0, - pNd->GetTxt().Len(), FALSE ); + m_pHstry->Add( pNd->GetTxtColl(), nNd, ND_TEXTNODE ); + if ( pNd->GetpSwpHints() ) + { + m_pHstry->CopyAttr( pNd->GetpSwpHints(), nNd, 0, + pNd->GetTxt().Len(), false ); + } if( pNd->HasSwAttrSet() ) - pHstry->CopyFmtAttr( *pNd->GetpSwAttrSet(), nNd ); + m_pHstry->CopyFmtAttr( *pNd->GetpSwAttrSet(), nNd ); + + if( !m_pHstry->Count() ) + delete m_pHstry, m_pHstry = 0; + + // METADATA: store + m_pMetadataUndoStart = pNd->CreateUndo(); + } - if( !pHstry->Count() ) - delete pHstry, pHstry = 0; + // we also need to store the metadata reference of the _last_ paragraph + // we subtract 1 to account for the removed cell start/end node pair + // (after SectionUp, the end of the range points to the node after the cell) + if ( nEndIdx - 1 > nNd ) + { + SwTxtNode* pLastNode( rDoc.GetNodes()[ nEndIdx - 1 ]->GetTxtNode() ); + if( pLastNode ) + { + // METADATA: store + m_pMetadataUndoEnd = pLastNode->CreateUndo(); + } } } @@ -433,7 +450,7 @@ SwUndoTblToTxt::SwUndoTblToTxt( const SwTable& rTbl, sal_Unicode cCh ) for( USHORT n = 0; n < rFrmFmtTbl.Count(); ++n ) { const SwPosition* pAPos; - const SwFrmFmt* pFmt = rFrmFmtTbl[ n ]; + SwFrmFmt* pFmt = rFrmFmtTbl[ n ]; const SwFmtAnchor* pAnchor = &pFmt->GetAnchor(); if( 0 != ( pAPos = pAnchor->GetCntntAnchor()) && ( FLY_AUTO_CNTNT == pAnchor->GetAnchorId() || @@ -562,22 +579,24 @@ SwTableNode* SwNodes::UndoTableToText( ULONG nSttNd, ULONG nEndNd, for( USHORT n = rSavedData.Count(); n; ) { SwTblToTxtSave* pSave = rSavedData[ --n ]; - aSttIdx = pSave->nNode; + // if the start node was merged with last from prev. cell, + // subtract 1 from index to get the merged paragraph, and split that + aSttIdx = pSave->m_nSttNd - ( ( USHRT_MAX != pSave->m_nCntnt ) ? 1 : 0); SwTxtNode* pTxtNd = aSttIdx.GetNode().GetTxtNode(); - if( USHRT_MAX != pSave->nCntnt ) + if( USHRT_MAX != pSave->m_nCntnt ) { // an der ContentPosition splitten, das vorherige Zeichen // loeschen (ist der Trenner!) ASSERT( pTxtNd, "Wo ist der TextNode geblieben?" ); - SwIndex aCntPos( pTxtNd, pSave->nCntnt - 1 ); + SwIndex aCntPos( pTxtNd, pSave->m_nCntnt - 1 ); pTxtNd->Erase( aCntPos, 1 ); SwCntntNode* pNewNd = pTxtNd->SplitCntntNode( SwPosition( aSttIdx, aCntPos )); if( aBkmkArr.Count() ) - _RestoreCntntIdx( aBkmkArr, *pNewNd, pSave->nCntnt, - pSave->nCntnt + 1 ); + _RestoreCntntIdx( aBkmkArr, *pNewNd, pSave->m_nCntnt, + pSave->m_nCntnt + 1 ); } else { @@ -590,6 +609,8 @@ SwTableNode* SwNodes::UndoTableToText( ULONG nSttNd, ULONG nEndNd, if( pTxtNd ) { + // METADATA: restore + pTxtNd->GetTxtNode()->RestoreMetadata(pSave->m_pMetadataUndoStart); if( pTxtNd->HasSwAttrSet() ) pTxtNd->ResetAllAttr(); @@ -597,14 +618,25 @@ SwTableNode* SwNodes::UndoTableToText( ULONG nSttNd, ULONG nEndNd, pTxtNd->ClearSwpHintsArr( false ); } - if( pSave->pHstry ) + if( pSave->m_pHstry ) + { + USHORT nTmpEnd = pSave->m_pHstry->GetTmpEnd(); + pSave->m_pHstry->TmpRollback( GetDoc(), 0 ); + pSave->m_pHstry->SetTmpEnd( nTmpEnd ); + } + + // METADATA: restore + // end points to node after cell + if ( pSave->m_nEndNd - 1 > pSave->m_nSttNd ) { - USHORT nTmpEnd = pSave->pHstry->GetTmpEnd(); - pSave->pHstry->TmpRollback( GetDoc(), 0 ); - pSave->pHstry->SetTmpEnd( nTmpEnd ); + SwTxtNode* pLastNode = (*this)[ pSave->m_nEndNd - 1 ]->GetTxtNode(); + if (pLastNode) + { + pLastNode->RestoreMetadata(pSave->m_pMetadataUndoEnd); + } } - aEndIdx = pSave->nEndNd; + aEndIdx = pSave->m_nEndNd; SwStartNode* pSttNd = new SwStartNode( aSttIdx, ND_STARTNODE, SwTableBoxStartNode ); pSttNd->pStartOfSection = pTblNd; @@ -2229,11 +2261,10 @@ SwUndoTblNumFmt::SwUndoTblNumFmt( const SwTableBox& rBox, pHistory = new SwHistory; SwRegHistory aRHst( *rBox.GetSttNd(), pHistory ); - // immer alle TextAttribute sichern; ist fuers Undo mit voll- - // staendiger Attributierung am besten, wegen den evt. - // Ueberlappenden Bereichen von An/Aus. + // always save all text atttibutes because of possibly overlapping + // areas of on/off pHistory->CopyAttr( pTNd->GetpSwpHints(), nNdPos, 0, - pTNd->GetTxt().Len(), TRUE ); + pTNd->GetTxt().Len(), true ); if( pTNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pTNd->GetpSwAttrSet(), nNdPos ); @@ -2827,7 +2858,8 @@ SwUndo* SwUndoTblCpyTbl::PrepareRedline( SwDoc* pDoc, const SwTableBox& rBox, } else if( !rJoin ) // If the old part is empty and joined, we are finished { // if it is not joined, we have to delete this empty paragraph - aCellEnd = SwNodeIndex( *rBox.GetSttNd()->EndOfSectionNode() ); + aCellEnd = SwPosition( + SwNodeIndex( *rBox.GetSttNd()->EndOfSectionNode() )); SwPaM aTmpPam( aDeleteStart, aCellEnd ); pUndo = new SwUndoDelete( aTmpPam, TRUE ); } diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index 73e6151869b5..dbe76f8a16fd 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -59,7 +59,7 @@ SwUndoInserts::SwUndoInserts( SwUndoId nUndoId, const SwPaM& rPam ) { pTxtFmtColl = pTxtNd->GetTxtColl(); pHistory->CopyAttr( pTxtNd->GetpSwpHints(), nSttNode, - 0, pTxtNd->GetTxt().Len(), FALSE ); + 0, pTxtNd->GetTxt().Len(), false ); if( pTxtNd->HasSwAttrSet() ) pHistory->CopyFmtAttr( *pTxtNd->GetpSwAttrSet(), nSttNode ); @@ -264,7 +264,7 @@ void SwUndoInserts::Undo( SwUndoIter& rUndoIter ) pTxtFmtColl = (SwTxtFmtColl*)pTxtNode->ChgFmtColl( pTxtFmtColl ); pHistory->SetTmpEnd( nSetPos ); - pHistory->TmpRollback( pDoc, 0, FALSE ); + pHistory->TmpRollback( pDoc, 0, false ); } } @@ -288,7 +288,7 @@ void SwUndoInserts::Redo( SwUndoIter& rUndoIter ) pSavTxtFmtColl = ((SwTxtNode*)pCNd)->GetTxtColl(); pHistory->SetTmpEnd( nSetPos ); - pHistory->TmpRollback( pDoc, 0, FALSE ); + pHistory->TmpRollback( pDoc, 0, false ); // alte Anfangs-Position fuers Rollback zurueckholen if( ( nSttNode != nEndNode || nSttCntnt != nEndCntnt ) && pPos ) diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index b89163f60a3e..b09f4196d396 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -35,12 +35,8 @@ #include <algorithm> -#ifndef _COM_SUN_STAR_CHART_DATAROWSOURCE_HPP_ #include <com/sun/star/chart/ChartDataRowSource.hpp> -#endif -#ifndef _COM_SUN_STAR_CHART_DATAROWSOURCE_HPP_ #include <com/sun/star/chart2/data/LabelOrigin.hpp> -#endif #include <cppuhelper/interfacecontainer.hxx> #include <vos/mutex.hxx> #include <osl/mutex.hxx> @@ -283,11 +279,9 @@ static String GetCellRangeName( SwFrmFmt &rTblFmt, SwUnoCrsr &rTblCrsr ) //!! see also SwXTextTableCursor::getRangeName - SwUnoTableCrsr* pUnoTblCrsr = rTblCrsr; -#if OSL_DEBUG_LEVEL > 1 + SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<SwUnoTableCrsr*>(&rTblCrsr); if (!pUnoTblCrsr) return String(); -#endif pUnoTblCrsr->MakeBoxSels(); const SwStartNode* pStart; @@ -491,7 +485,8 @@ static void GetFormatAndCreateCursorFromRangeRep( pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = *pUnoCrsr; + SwUnoTableCrsr* pCrsr = + dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); if (ppUnoCrsr) @@ -2064,9 +2059,8 @@ SwChartDataSequence::SwChartDataSequence( // check if it can properly convert into a SwUnoTableCrsr // which is required for some functions - SwUnoTableCrsr* pUnoTblCrsr = *pTblCrsr; - if (!pUnoTblCrsr) - pUnoTblCrsr = *pTblCrsr; + SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr); + DBG_ASSERT(pUnoTblCrsr, "SwChartDataSequence: cursor not SwUnoTableCrsr"); #endif } @@ -2115,9 +2109,8 @@ SwChartDataSequence::SwChartDataSequence( const SwChartDataSequence &rObj ) : // check if it can properly convert into a SwUnoTableCrsr // which is required for some functions - SwUnoTableCrsr* pUnoTblCrsr = *pTblCrsr; - if (!pUnoTblCrsr) - pUnoTblCrsr = *pTblCrsr; + SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr); + DBG_ASSERT(pUnoTblCrsr, "SwChartDataSequence: cursor not SwUnoTableCrsr"); #endif } @@ -2779,7 +2772,7 @@ bool SwChartDataSequence::ExtendTo( bool bExtendCol, { bool bChanged = false; - SwUnoTableCrsr* pUnoTblCrsr = *pTblCrsr; + SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr); //pUnoTblCrsr->MakeBoxSels(); const SwStartNode *pStartNd = 0; diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index b17cf48f5d9f..475438ec8d83 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1650,9 +1650,9 @@ Sequence< OUString > SwXFootnotes::getSupportedServiceNames(void) throw( Runtime /*-- 14.01.99 09:03:52--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXFootnotes::SwXFootnotes(sal_Bool bEnd, SwDoc* _pDoc) : - SwUnoCollection(_pDoc), - bEndnote(bEnd) +SwXFootnotes::SwXFootnotes(sal_Bool bEnd, SwDoc* _pDoc) + : SwUnoCollection(_pDoc) + , m_bEndnote(bEnd) { } /*-- 14.01.99 09:03:52--------------------------------------------------- @@ -1676,7 +1676,7 @@ sal_Int32 SwXFootnotes::getCount(void) throw( uno::RuntimeException ) { pTxtFtn = GetDoc()->GetFtnIdxs()[ n ]; const SwFmtFtn& rFtn = pTxtFtn->GetFtn(); - if ( rFtn.IsEndNote() != bEndnote ) + if ( rFtn.IsEndNote() != m_bEndnote ) continue; nCount++; } @@ -1700,7 +1700,7 @@ uno::Any SwXFootnotes::getByIndex(sal_Int32 nIndex) { pTxtFtn = GetDoc()->GetFtnIdxs()[ n ]; const SwFmtFtn& rFtn = pTxtFtn->GetFtn(); - if( rFtn.IsEndNote() != bEndnote ) + if ( rFtn.IsEndNote() != m_bEndnote ) continue; if(nCount == nIndex) diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index f7b5fe716a59..8d754eca0879 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1020,12 +1020,10 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: throw beans::PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); SwDoc* pDoc = pFmt->GetDoc(); - if( eType == FLYCNTTYPE_GRF && - (pEntry->nWID >= RES_GRFATR_BEGIN && - pEntry->nWID < RES_GRFATR_END)|| - pEntry->nWID == FN_PARAM_COUNTOUR_PP || - pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR || - pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR ) + if ((eType == FLYCNTTYPE_GRF) && isGRFATR(pEntry->nWID) || + (FN_PARAM_COUNTOUR_PP == pEntry->nWID) || + (FN_UNO_IS_AUTOMATIC_CONTOUR == pEntry->nWID) || + (FN_UNO_IS_PIXEL_CONTOUR == pEntry->nWID) ) { const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); if(pIdx) @@ -1468,8 +1466,7 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName) { if( ((eType == FLYCNTTYPE_GRF) || (eType == FLYCNTTYPE_OLE)) && pEntry && - ((pEntry->nWID >= RES_GRFATR_BEGIN && - pEntry->nWID < RES_GRFATR_END )|| + (isGRFATR(pEntry->nWID) || pEntry->nWID == FN_PARAM_COUNTOUR_PP || pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR || pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR )) @@ -1758,13 +1755,13 @@ uno::Sequence< beans::PropertyState > SwXFrame::getPropertyStates( FN_UNO_GRAPHIC_FILTER == pEntry->nWID|| FN_UNO_ACTUAL_SIZE == pEntry->nWID|| FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID) + { pStates[i] = beans::PropertyState_DIRECT_VALUE; + } else { - if(eType == FLYCNTTYPE_GRF && - pEntry && - (pEntry->nWID >= RES_GRFATR_BEGIN && - pEntry->nWID <= RES_GRFATR_END)) + if ((eType == FLYCNTTYPE_GRF) && + pEntry && isGRFATR(pEntry->nWID)) { const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); if(pIdx) @@ -1817,9 +1814,7 @@ void SwXFrame::setPropertyToDefault( const OUString& rPropertyName ) pEntry->nWID != FN_UNO_ANCHOR_TYPES && pEntry->nWID != FN_PARAM_LINK_DISPLAY_NAME) { - if( eType == FLYCNTTYPE_GRF && - (pEntry->nWID >= RES_GRFATR_BEGIN && - pEntry->nWID < RES_GRFATR_END)) + if ( (eType == FLYCNTTYPE_GRF) && isGRFATR(pEntry->nWID) ) { const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); if(pIdx) diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 00b907ad0674..9b2bebb67977 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -150,30 +150,6 @@ uno::Sequence< sal_Int8 > CreateUnoTunnelId() Hilfsklassen ****************************************************************************/ -SwParaSelection::SwParaSelection(SwUnoCrsr* pCrsr) : - pUnoCrsr(pCrsr) -{ - if(pUnoCrsr->HasMark()) - pUnoCrsr->DeleteMark(); - // steht er schon am Anfang? - if(pUnoCrsr->GetPoint()->nContent != 0) - pUnoCrsr->MovePara(fnParaCurr, fnParaStart); - // oder gleichzeitig am Ende? - if(pUnoCrsr->GetPoint()->nContent != pUnoCrsr->GetCntntNode()->Len()) - { - pUnoCrsr->SetMark(); - pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); - } -} - -SwParaSelection::~SwParaSelection() -{ - if(pUnoCrsr->GetPoint()->nContent != 0) - { - pUnoCrsr->DeleteMark(); - pUnoCrsr->MovePara(fnParaCurr, fnParaStart); - } -} /* -----------------13.05.98 12:15------------------- * * --------------------------------------------------*/ diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index e49e69ea5cdf..ae9f94fcc464 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -65,9 +65,7 @@ #include <fmtfld.hxx> #include <fmtpdsc.hxx> #include <pagedesc.hxx> -#ifndef _POOLFMT_HRC #include <poolfmt.hrc> -#endif #include <poolfmt.hxx> #include <edimp.hxx> #include <fchrfmt.hxx> @@ -620,7 +618,8 @@ uno::Reference< XEnumeration > SwXTextCursor::createEnumeration(void) throw( Ru *pNewCrsr->GetMark() = *pUnoCrsr->GetMark(); } CursorType eSetType = eType == CURSOR_TBLTEXT ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - SwXParagraphEnumeration *pEnum = new SwXParagraphEnumeration(pParentText, *pNewCrsr, eSetType); + SwXParagraphEnumeration *pEnum = + new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); uno::Reference< XEnumeration > xRet = pEnum; if (eType == CURSOR_TBLTEXT) { @@ -1078,8 +1077,9 @@ uno::Reference< XTextContent > SAL_CALL SwXParagraphEnumeration::NextElement_Imp } else { - SwUnoCrsr* pNewCrsr = pUnoCrsr->GetDoc()->CreateUnoCrsr(*pStart, sal_False); - aRef = (XTextContent*)new SwXParagraph((SwXText*)pText, pNewCrsr, nFirstContent, nLastContent); + aRef = new SwXParagraph(static_cast<SwXText*>(pText), + pStart->nNode.GetNode().GetTxtNode(), + nFirstContent, nLastContent); } } } @@ -1170,56 +1170,17 @@ Sequence< OUString > SwXTextRange::getSupportedServiceNames(void) throw( Runtime return aRet; } -SwXTextRange::SwXTextRange(SwPaM& rPam, const uno::Reference< XText > & rxParent) : - eRangePosition(RANGE_IN_TEXT), +SwXTextRange::SwXTextRange(SwPaM& rPam, + const uno::Reference< XText > & rxParent, enum RangePosition eRange) : + eRangePosition(eRange), pDoc(rPam.GetDoc()), pBox(0), pBoxStartNode(0), aObjectDepend(this, 0), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), + m_pPropSet(aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_CURSOR)), xParentText(rxParent), pMark(NULL) { - //Bookmark an der anlegen - _CreateNewBookmark(rPam); -} - -SwXTextRange::SwXTextRange(SwFrmFmt& rFmt, SwPaM& rPam) : - eRangePosition(RANGE_IN_FRAME), - pDoc(rPam.GetDoc()), - pBox(0), - pBoxStartNode(0), - aObjectDepend(this, &rFmt), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - pMark(NULL) -{ - //Bookmark an der anlegen - _CreateNewBookmark(rPam); -} - -SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt, SwTableBox& rTblBox, SwPaM& rPam) : - eRangePosition(RANGE_IN_CELL), - pDoc(rPam.GetDoc()), - pBox(&rTblBox), - pBoxStartNode(0), - aObjectDepend(this, &rTblFmt), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - pMark(NULL) -{ - //Bookmark an der anlegen - _CreateNewBookmark(rPam); -} - -SwXTextRange::SwXTextRange(SwFrmFmt& rTblFmt, const SwStartNode& rStartNode, SwPaM& rPam) : - eRangePosition(RANGE_IN_CELL), - pDoc(rPam.GetDoc()), - pBox(0), - pBoxStartNode(&rStartNode), - aObjectDepend(this, &rTblFmt), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR)), - pMark(NULL) -{ - //Bookmark an der anlegen _CreateNewBookmark(rPam); } @@ -1287,50 +1248,22 @@ void SwXTextRange::DeleteAndInsert(const String& rText) uno::Reference< XText > SwXTextRange::getText(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!xParentText.is()) + if (!xParentText.is()) { - if(eRangePosition == RANGE_IN_FRAME && - aObjectDepend.GetRegisteredIn()) - { - SwFrmFmt* pFrmFmt = (SwFrmFmt*)aObjectDepend.GetRegisteredIn(); - SwXTextFrame* pxFrm = (SwXTextFrame*)SwClientIter( *pFrmFmt ). - First( TYPE( SwXTextFrame )); - if(pxFrm) - ((SwXTextRange*)this)->xParentText = pxFrm; - else - ((SwXTextRange*)this)->xParentText = new SwXTextFrame(*pFrmFmt); - ((SwModify*)aObjectDepend.GetRegisteredIn())-> - Remove(&((SwXTextRange*)this)->aObjectDepend); - - } - else if(eRangePosition == RANGE_IN_CELL && - aObjectDepend.GetRegisteredIn()) - { - const SwStartNode* pSttNd = pBoxStartNode ? pBoxStartNode : pBox->GetSttNd(); - const SwTableNode* pTblNode = pSttNd->FindTableNode(); - const SwFrmFmt* pTableFmt = pTblNode->GetTable().GetFrmFmt(); - ((SwXTextRange*)this)->xParentText = - pBox ? SwXCell::CreateXCell((SwFrmFmt*)pTableFmt, pBox) - : new SwXCell( (SwFrmFmt*)pTableFmt, *pBoxStartNode ); - ((SwModify*)aObjectDepend.GetRegisteredIn())-> - Remove(&((SwXTextRange*)this)->aObjectDepend); - } - else if(eRangePosition == RANGE_IS_TABLE && + if (eRangePosition == RANGE_IS_TABLE && aObjectDepend.GetRegisteredIn() ) { SwFrmFmt* pTblFmt = (SwFrmFmt*)aObjectDepend.GetRegisteredIn(); SwTable* pTable = SwTable::FindTable( pTblFmt ); SwTableNode* pTblNode = pTable->GetTableNode(); SwPosition aPosition( *pTblNode ); - uno::Reference< XTextRange > xRange = SwXTextRange::CreateTextRangeFromPosition(pDoc, - aPosition, 0); + uno::Reference< XTextRange > xRange = + SwXTextRange::CreateTextRangeFromPosition(pDoc, aPosition, 0); xParentText = xRange->getText(); } else { - // jetzt noch alle Faelle finden, die nicht abgedeckt sind - // (Body, Kopf-/Fusszeilen, Fussnotentext ) - DBG_WARNING("not implemented"); + OSL_ENSURE(false, "SwXTextRange::getText: no text"); } } return xParentText; @@ -1491,34 +1424,32 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, } else { - SwDoc* pDoc = 0; - const SwPaM* pUnoCrsr = 0; if (pPara) { - pUnoCrsr = pPara->GetCrsr(); - if (pUnoCrsr) - pDoc = pUnoCrsr->GetDoc(); + const SwTxtNode * pTxtNode( pPara->GetTxtNode() ); + + if (pTxtNode) { + bRet = sal_True; + *rToFill.GetPoint() = SwPosition( *pTxtNode ); + // set selection to the whole paragraph + rToFill.SetMark(); + rToFill.GetMark()->nContent = pTxtNode->GetTxt().Len(); + } } else { - pDoc = pCursor ? pCursor->GetDoc() : NULL; + const SwPaM* pUnoCrsr = 0; + SwDoc* pDoc = pCursor ? pCursor->GetDoc() : NULL; + if ( !pDoc ) pDoc = pPortion ? pPortion->GetCrsr()->GetDoc() : NULL; pUnoCrsr = pCursor ? pCursor->GetPaM() : pPortion ? pPortion->GetCrsr() : 0; - } - if(pUnoCrsr && pDoc == rToFill.GetDoc()) + if (pUnoCrsr && pDoc == rToFill.GetDoc()) { DBG_ASSERT((SwPaM*)pUnoCrsr->GetNext() == pUnoCrsr, "was machen wir mit Ringen?" ); bRet = sal_True; *rToFill.GetPoint() = *pUnoCrsr->GetPoint(); - if(pPara) - { - // set selection to the whole paragraph - rToFill.SetMark(); - rToFill.GetMark()->nContent = - pUnoCrsr->GetNode()->GetTxtNode()->GetTxt().Len(); - } - else if(pUnoCrsr->HasMark()) + if (pUnoCrsr->HasMark()) { rToFill.SetMark(); *rToFill.GetMark() = *pUnoCrsr->GetMark(); @@ -1526,6 +1457,7 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, else rToFill.DeleteMark(); } + } } return bRet; } @@ -1555,18 +1487,28 @@ sal_Bool lcl_IsStartNodeInFormat(sal_Bool bHeader, SwStartNode* pSttNode, return bRet; } -uno::Reference< XTextRange > SwXTextRange::CreateTextRangeFromPosition(SwDoc* pDoc, - const SwPosition& rPos, const SwPosition* pMark) +uno::Reference< XTextRange > SwXTextRange::CreateTextRangeFromPosition( + SwDoc* pDoc, const SwPosition& rPos, const SwPosition* pMark) { - uno::Reference< XTextRange > aRet; - SwUnoCrsr* pNewCrsr = pDoc->CreateUnoCrsr(rPos, sal_False); + uno::Reference< XText > xParentText( CreateParentXText(pDoc, rPos) ); + std::auto_ptr<SwUnoCrsr> pNewCrsr( pDoc->CreateUnoCrsr(rPos, sal_False) ); if(pMark) { pNewCrsr->SetMark(); *pNewCrsr->GetMark() = *pMark; } - uno::Reference< XText > xParentText; - //jetzt besorgen wir uns mal den Parent: + bool isCell( dynamic_cast<SwXCell*>(xParentText.get()) ); + uno::Reference< XTextRange > xRet( + new SwXTextRange(*pNewCrsr, xParentText, + isCell ? RANGE_IN_CELL : RANGE_IN_TEXT) ); + return xRet; + +} + +uno::Reference< XText > SwXTextRange::CreateParentXText(SwDoc* pDoc, + const SwPosition& rPos) +{ + uno::Reference< XText > xParentText; SwStartNode* pSttNode = rPos.nNode.GetNode().StartOfSectionNode(); while(pSttNode && pSttNode->IsSectionNode()) { @@ -1581,19 +1523,19 @@ uno::Reference< XTextRange > SwXTextRange::CreateTextRangeFromPosition(SwDoc* pD SwFrmFmt* pTableFmt = (SwFrmFmt*)pTblNode->GetTable().GetFrmFmt(); SwTableBox* pBox = pSttNode->GetTblBox(); - if( pBox ) - aRet = new SwXTextRange(*pTableFmt, *pBox, *pNewCrsr); - else - aRet = new SwXTextRange(*pTableFmt, *pSttNode, *pNewCrsr); + xParentText = pBox + ? SwXCell::CreateXCell( pTableFmt, pBox ) + : new SwXCell( pTableFmt, *pSttNode ); } break; case SwFlyStartNode: { - SwFrmFmt* pFmt; - if(0 != (pFmt = pSttNode->GetFlyFmt())) + SwFrmFmt* pFmt = pSttNode->GetFlyFmt(); + if (0 != pFmt) { - aRet = new SwXTextRange(*pFmt, *pNewCrsr); - + SwXTextFrame* pFrame( static_cast<SwXTextFrame*>( + SwClientIter( *pFmt ).First( TYPE( SwXTextFrame ) ) ) ); + xParentText = pFrame ? pFrame : new SwXTextFrame( *pFmt ); } } break; @@ -1640,13 +1582,15 @@ uno::Reference< XTextRange > SwXTextRange::CreateTextRangeFromPosition(SwDoc* pD (void)pTmpSttNode; #endif - if(pSttNode == pTxtFtn->GetStartNode()->GetNode(). + if (pSttNode == pTxtFtn->GetStartNode()->GetNode(). FindSttNodeByType(SwFootnoteStartNode)) { xParentText = ((SwUnoCallBack*)pDoc->GetUnoCallBack())-> GetFootnote(rFtn); - if(!xParentText.is()) + if (!xParentText.is()) + { xParentText = new SwXFootnote(pDoc, rFtn); + } break; } } @@ -1654,17 +1598,16 @@ uno::Reference< XTextRange > SwXTextRange::CreateTextRangeFromPosition(SwDoc* pD break; default: { - // dann ist es der Body-Text - uno::Reference<frame::XModel> xModel = pDoc->GetDocShell()->GetBaseModel(); + // then it is the body text + uno::Reference<frame::XModel> xModel = + pDoc->GetDocShell()->GetBaseModel(); uno::Reference< XTextDocument > xDoc( xModel, uno::UNO_QUERY); xParentText = xDoc->getText(); } } - if(!aRet.is()) - aRet = new SwXTextRange(*pNewCrsr, xParentText); - delete pNewCrsr; - return aRet; + OSL_ENSURE(xParentText.is(), "no parent text?"); + return xParentText; } uno::Reference< XEnumeration > SAL_CALL SwXTextRange::createContentEnumeration( @@ -1707,7 +1650,8 @@ uno::Reference< XEnumeration > SwXTextRange::createEnumeration(void) throw( Runt } DBG_ASSERT(pParentText, "parent is not a SwXText"); CursorType eSetType = RANGE_IN_CELL == eRangePosition ? CURSOR_SELECTION_IN_TABLE : CURSOR_SELECTION; - uno::Reference< XEnumeration > xRet = new SwXParagraphEnumeration(pParentText, *pNewCrsr, eSetType); + uno::Reference< XEnumeration > xRet = + new SwXParagraphEnumeration(pParentText, pNewCrsr, eSetType); return xRet; } @@ -2090,23 +2034,25 @@ Sequence< OUString > SwXParaFrameEnumeration::getSupportedServiceNames(void) thr /*-- 23.03.99 13:22:29--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwUnoCrsr& rUnoCrsr, +SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, sal_uInt8 nParaFrameMode, SwFrmFmt* pFmt) { - SwDoc* pDoc = rUnoCrsr.GetDoc(); - SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(*rUnoCrsr.GetPoint(), sal_False); - if(rUnoCrsr.HasMark()) + SwDoc* pDoc = rPaM.GetDoc(); + SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(*rPaM.GetPoint(), sal_False); + if (rPaM.HasMark()) { pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *rUnoCrsr.GetMark(); + *pUnoCrsr->GetMark() = *rPaM.GetMark(); } pUnoCrsr->Add(this); - if(PARAFRAME_PORTION_PARAGRAPH == nParaFrameMode) - ::CollectFrameAtNode( *this, rUnoCrsr.GetPoint()->nNode, + if (PARAFRAME_PORTION_PARAGRAPH == nParaFrameMode) + { + ::CollectFrameAtNode( *this, rPaM.GetPoint()->nNode, aFrameArr, FALSE ); - else if(pFmt) + } + else if (pFmt) { //jetzt einen SwDepend anlegen und in das Array einfuegen SwDepend* pNewDepend = new SwDepend(this, pFmt); diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 7662df99afed..6cd922d18080 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -33,9 +33,7 @@ #include <cmdid.h> -#ifndef _UNOMID_H #include <unomid.h> -#endif #include <unoobj.hxx> #include <unomap.hxx> #include <unocrsr.hxx> @@ -45,29 +43,77 @@ #include <ndtxt.hxx> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> +#include <docsh.hxx> #define _SVSTDARR_USHORTS #define _SVSTDARR_USHORTSSORT #include <svtools/svstdarr.hxx> +<<<<<<< .working #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp> #include <com/sun/star/beans/GetPropertyTolerantResult.hpp> #include <com/sun/star/beans/TolerantPropertySetResultType.hpp> #ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_ +======= +//#include <com/sun/star/beans/SetPropertyTolerantFailed.hpp> +//#include <com/sun/star/beans/GetPropertyTolerantResult.hpp> +//#include <com/sun/star/beans/TolerantPropertySetResultType.hpp> +>>>>>>> .merge-right.r273569 #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif #include <com/sun/star/text/WrapTextMode.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> using namespace ::com::sun::star; using ::rtl::OUString; + +/* -----------------------------01.12.00 18:09-------------------------------- + + ---------------------------------------------------------------------------*/ +class SwParaSelection +{ + SwCursor* m_pCursor; +public: + SwParaSelection(SwCursor* pPam); + ~SwParaSelection(); +}; + +SwParaSelection::SwParaSelection(SwCursor* pCursor) + : m_pCursor(pCursor) +{ + if (m_pCursor->HasMark()) + { + m_pCursor->DeleteMark(); + } + // is it at the start? + if (m_pCursor->GetPoint()->nContent != 0) + { + m_pCursor->MovePara(fnParaCurr, fnParaStart); + } + // or at the end already? + if (m_pCursor->GetPoint()->nContent != m_pCursor->GetCntntNode()->Len()) + { + m_pCursor->SetMark(); + m_pCursor->MovePara(fnParaCurr, fnParaEnd); + } +} + +SwParaSelection::~SwParaSelection() +{ + if (m_pCursor->GetPoint()->nContent != 0) + { + m_pCursor->DeleteMark(); + m_pCursor->MovePara(fnParaCurr, fnParaStart); + } +} + + /****************************************************************** * forward declarations ******************************************************************/ beans::PropertyState lcl_SwXParagraph_getPropertyState( - SwUnoCrsr& rUnoCrsr, + const SwTxtNode& rTxtNode, const SwAttrSet** ppSet, const SfxItemPropertySimpleEntry& rEntry, sal_Bool &rAttrSetFetched ) @@ -76,6 +122,9 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( /****************************************************************** * SwXParagraph ******************************************************************/ + +TYPEINIT1(SwXParagraph, SwClient); + /* -----------------------------11.07.00 12:10-------------------------------- ---------------------------------------------------------------------------*/ @@ -164,9 +213,9 @@ SwXParagraph::SwXParagraph() : /*-- 11.12.98 08:12:47--------------------------------------------------- -----------------------------------------------------------------------*/ -SwXParagraph::SwXParagraph(SwXText* pParent, SwUnoCrsr* pCrsr, sal_Int32 nSelStart, sal_Int32 nSelEnd) : - SwClient(pCrsr), - xParentText(pParent), +SwXParagraph::SwXParagraph(uno::Reference< text::XText > const & i_xParent, SwTxtNode * i_pTxtNode, sal_Int32 nSelStart, sal_Int32 nSelEnd) : + SwClient(i_pTxtNode), + xParentText(i_xParent), aLstnrCntnr( (text::XTextRange*)this), m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH)), nSelectionStartPos(nSelStart), @@ -179,10 +228,6 @@ SwXParagraph::SwXParagraph(SwXText* pParent, SwUnoCrsr* pCrsr, sal_Int32 nSelSta -----------------------------------------------------------------------*/ SwXParagraph::~SwXParagraph() { - vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - delete pUnoCrsr; } /* -----------------------------11.07.00 14:48-------------------------------- @@ -247,14 +292,15 @@ void SAL_CALL SwXParagraph::SetPropertyValues_Impl( throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + if (GetTxtNode()) { + SwPosition aPos( *GetTxtNode() ); + SwCursor aCursor( aPos, 0, false ); const OUString* pPropertyNames = rPropertyNames.getConstArray(); const uno::Any* pValues = rValues.getConstArray(); const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); OUString sTmp; - SwParaSelection aParaSel(pUnoCrsr); + SwParaSelection aParaSel( & aCursor ); for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) { const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pPropertyNames[nProp] ); @@ -265,8 +311,14 @@ void SAL_CALL SwXParagraph::SetPropertyValues_Impl( if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); +<<<<<<< .working SwXTextCursor::SetPropertyValue(*pUnoCrsr, *m_pPropSet, sTmp, pValues[nProp]); +======= + SwXTextCursor::SetPropertyValue(aCursor, aPropSet, + sTmp, pValues[nProp], pMap); + pMap++; +>>>>>>> .merge-right.r273569 } } } @@ -304,14 +356,15 @@ uno::Sequence< uno::Any > SAL_CALL SwXParagraph::GetPropertyValues_Impl( throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) { uno::Sequence< uno::Any > aValues(rPropertyNames.getLength()); - SwUnoCrsr* pUnoCrsr = ((SwXParagraph*)this)->GetCrsr(); - if(pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { + SwPosition aPos( *pTxtNode ); + SwPaM aPam( aPos ); uno::Any* pValues = aValues.getArray(); const OUString* pPropertyNames = rPropertyNames.getConstArray(); const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); - SwNode& rTxtNode = pUnoCrsr->GetPoint()->nNode.GetNode(); - const SwAttrSet& rAttrSet = ((SwTxtNode&)rTxtNode).GetSwAttrSet(); + const SwAttrSet& rAttrSet( pTxtNode->GetSwAttrSet() ); for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) { const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pPropertyNames[nProp] ); @@ -323,7 +376,11 @@ uno::Sequence< uno::Any > SAL_CALL SwXParagraph::GetPropertyValues_Impl( BOOL bDone = FALSE; beans::PropertyState eTemp; bDone = SwUnoCursorHelper::getCrsrPropertyValue( +<<<<<<< .working *pEntry, *pUnoCrsr, &(pValues[nProp]), eTemp, rTxtNode.GetTxtNode() ); +======= + pMap, aPam, &(pValues[nProp]), eTemp, pTxtNode ); +>>>>>>> .merge-right.r273569 if(!bDone) m_pPropSet->getPropertyValue(*pEntry, rAttrSet, pValues[nProp]); } @@ -677,7 +734,8 @@ void SwXParagraph::removeVetoableChangeListener(const OUString& /*PropertyName*/ } //----------------------------------------------------------------------------- beans::PropertyState lcl_SwXParagraph_getPropertyState( - SwUnoCrsr& rUnoCrsr, +// SwUnoCrsr& rUnoCrsr, + const SwTxtNode& rTxtNode, const SwAttrSet** ppSet, const SfxItemPropertySimpleEntry& rEntry, sal_Bool &rAttrSetFetched ) @@ -687,15 +745,20 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( if(!(*ppSet) && !rAttrSetFetched ) { - SwNode& rTxtNode = rUnoCrsr.GetPoint()->nNode.GetNode(); - (*ppSet) = ((SwTxtNode&)rTxtNode).GetpSwAttrSet(); + (*ppSet) = rTxtNode.GetpSwAttrSet(); rAttrSetFetched = sal_True; } +<<<<<<< .working switch( rEntry.nWID ) +======= + SwPosition aPos( rTxtNode ); + SwPaM aPam( aPos ); + switch( rMap.nWID ) +>>>>>>> .merge-right.r273569 { case FN_UNO_NUM_RULES: - //wenn eine Numerierung gesetzt ist, dann hier herausreichen, sonst nichts tun - SwUnoCursorHelper::getNumberingProperty( rUnoCrsr, eRet, NULL ); + // if numbering is set, return it; else do nothing + SwUnoCursorHelper::getNumberingProperty( aPam, eRet, NULL ); break; case FN_UNO_ANCHOR_TYPES: break; @@ -711,7 +774,11 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( case FN_UNO_PARA_CONDITIONAL_STYLE_NAME: { SwFmtColl* pFmt = SwXTextCursor::GetCurTxtFmtColl( +<<<<<<< .working rUnoCrsr, rEntry.nWID == FN_UNO_PARA_CONDITIONAL_STYLE_NAME); +======= + aPam, rMap.nWID == FN_UNO_PARA_CONDITIONAL_STYLE_NAME); +>>>>>>> .merge-right.r273569 eRet = pFmt ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE; } @@ -719,7 +786,7 @@ beans::PropertyState lcl_SwXParagraph_getPropertyState( case FN_UNO_PAGE_STYLE: { String sVal; - SwUnoCursorHelper::GetCurPageStyle( rUnoCrsr, sVal ); + SwUnoCursorHelper::GetCurPageStyle( aPam, sVal ); eRet = sVal.Len() ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE; } @@ -741,16 +808,21 @@ beans::PropertyState SwXParagraph::getPropertyState(const OUString& rPropertyNam { vos::OGuard aGuard(Application::GetSolarMutex()); beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; - SwUnoCrsr* pUnoCrsr = ((SwXParagraph*)this)->GetCrsr(); - if( pUnoCrsr ) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { const SwAttrSet* pSet = 0; const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); if(!pEntry) throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); sal_Bool bDummy = sal_False; +<<<<<<< .working eRet = lcl_SwXParagraph_getPropertyState( *pUnoCrsr, &pSet, *pEntry, bDummy ); +======= + eRet = lcl_SwXParagraph_getPropertyState( *pTxtNode, &pSet, *pMap, + bDummy ); +>>>>>>> .merge-right.r273569 } else throw uno::RuntimeException(); @@ -769,10 +841,16 @@ uno::Sequence< beans::PropertyState > SwXParagraph::getPropertyStates( uno::Sequence< beans::PropertyState > aRet(PropertyNames.getLength()); beans::PropertyState* pStates = aRet.getArray(); +<<<<<<< .working SwUnoCrsr* pUnoCrsr = ((SwXParagraph*)this)->GetCrsr(); const SfxItemPropertyMap* pMap = m_pPropSet->getPropertyMap(); if( pUnoCrsr ) +======= + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) +>>>>>>> .merge-right.r273569 { + const SfxItemPropertyMap* pMap = aPropSet.getPropertyMap(); const SwAttrSet* pSet = 0; sal_Bool bAttrSetFetched = sal_False; for(sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd; i++,++pStates,++pNames ) @@ -780,12 +858,24 @@ uno::Sequence< beans::PropertyState > SwXParagraph::getPropertyStates( const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( *pNames ); if(!pEntry) throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + *pNames, static_cast < cppu::OWeakObject * > ( this ) ); +<<<<<<< .working if (bAttrSetFetched && !pSet && pEntry->nWID >= RES_CHRATR_BEGIN && pEntry->nWID <= RES_UNKNOWNATR_END ) *pStates = beans::PropertyState_DEFAULT_VALUE; else *pStates = lcl_SwXParagraph_getPropertyState( *pUnoCrsr, &pSet,*pEntry, bAttrSetFetched ); +======= + if (bAttrSetFetched && !pSet && isATR(pMap->nWID)) + { + *pStates = beans::PropertyState_DEFAULT_VALUE; + } + else + { + *pStates = lcl_SwXParagraph_getPropertyState( + *pTxtNode, &pSet, *pMap, bAttrSetFetched ); + } +>>>>>>> .merge-right.r273569 } } else @@ -800,16 +890,18 @@ void SwXParagraph::setPropertyToDefault(const OUString& rPropertyName) throw( beans::UnknownPropertyException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { + SwPosition aPos( *pTxtNode ); + SwCursor aCursor( aPos, 0, false ); if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)) || rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPES)) || rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_TEXT_WRAP))) return; - // Absatz selektieren - SwParaSelection aParaSel(pUnoCrsr); + // select paragraph + SwParaSelection aParaSel( & aCursor ); const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName ); if(pEntry) { @@ -821,14 +913,17 @@ void SwXParagraph::setPropertyToDefault(const OUString& rPropertyName) SvUShortsSort aWhichIds; aWhichIds.Insert(pEntry->nWID); if(pEntry->nWID < RES_PARATR_BEGIN) - pUnoCrsr->GetDoc()->ResetAttrs(*pUnoCrsr, sal_True, &aWhichIds); + { + aCursor.GetDoc()->ResetAttrs(aCursor, sal_True, &aWhichIds); + } else { - //fuer Absatzattribute muss die Selektion jeweils auf - //Absatzgrenzen erweitert werden - SwPosition aStart = *pUnoCrsr->Start(); - SwPosition aEnd = *pUnoCrsr->End(); - SwUnoCrsr* pTemp = pUnoCrsr->GetDoc()->CreateUnoCrsr(aStart, sal_False); + // for paragraph attributes the selection must be extended + // to paragraph boundaries + SwPosition aStart( *aCursor.Start() ); + SwPosition aEnd ( *aCursor.End() ); + std::auto_ptr<SwUnoCrsr> pTemp( + aCursor.GetDoc()->CreateUnoCrsr(aStart, sal_False) ); if(!SwUnoCursorHelper::IsStartOfPara(*pTemp)) { pTemp->MovePara(fnParaCurr, fnParaStart); @@ -842,6 +937,7 @@ void SwXParagraph::setPropertyToDefault(const OUString& rPropertyName) pTemp->MovePara(fnParaCurr, fnParaEnd); } pTemp->GetDoc()->ResetAttrs(*pTemp, sal_True, &aWhichIds); +<<<<<<< .working delete pTemp; } } @@ -849,6 +945,16 @@ void SwXParagraph::setPropertyToDefault(const OUString& rPropertyName) SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, *pUnoCrsr); } else +======= + } + } + else + { + SwUnoCursorHelper::resetCrsrPropertyValue(pMap, aCursor); + } + } + else +>>>>>>> .merge-right.r273569 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); } else @@ -861,8 +967,8 @@ uno::Any SwXParagraph::getPropertyDefault(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) { uno::Any aRet; - SwUnoCrsr* pUnoCrsr = ((SwXParagraph*)this)->GetCrsr(); - if(pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { if(SwXParagraph::getDefaultTextContentValue(aRet, rPropertyName)) return aRet; @@ -873,8 +979,13 @@ uno::Any SwXParagraph::getPropertyDefault(const OUString& rPropertyName) if(pEntry->nWID < RES_FRMATR_END) { const SfxPoolItem& rDefItem = +<<<<<<< .working pUnoCrsr->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); rDefItem.QueryValue(aRet, pEntry->nMemberId); +======= + pTxtNode->GetDoc()->GetAttrPool().GetDefaultItem(pMap->nWID); + rDefItem.QueryValue(aRet, pMap->nMemberId); +>>>>>>> .merge-right.r273569 } } else @@ -904,12 +1015,14 @@ uno::Reference< text::XTextRange > SwXParagraph::getAnchor(void) throw( uno::Ru { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > aRet; - SwUnoCrsr* pUnoCrsr = ((SwXParagraph*)this)->GetCrsr(); - if(pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { - // Absatz selektieren - SwParaSelection aSelection(pUnoCrsr); - aRet = new SwXTextRange(*pUnoCrsr, xParentText); + SwPosition aPos( *pTxtNode ); + SwCursor aCursor( aPos, 0, false ); + // select paragraph + SwParaSelection aParaSel( & aCursor ); + aRet = new SwXTextRange(aCursor, xParentText); } else throw uno::RuntimeException(); @@ -921,16 +1034,16 @@ uno::Reference< text::XTextRange > SwXParagraph::getAnchor(void) throw( uno::Ru void SwXParagraph::dispose(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXParagraph*)this)->GetCrsr(); - if(pUnoCrsr) + SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { - // Absatz selektieren + SwCursor aCursor( SwPosition( *pTxtNode ), 0, false ); + // select paragraph { - SwParaSelection aSelection(pUnoCrsr); - pUnoCrsr->GetDoc()->DelFullPara(*pUnoCrsr); + SwParaSelection aParaSel( & aCursor ); + pTxtNode->GetDoc()->DelFullPara(aCursor); } aLstnrCntnr.Disposing(); - delete pUnoCrsr; } else throw uno::RuntimeException(); @@ -959,9 +1072,14 @@ uno::Reference< container::XEnumeration > SwXParagraph::createEnumeration(void) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< container::XEnumeration > aRef; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - aRef = new SwXTextPortionEnumeration(*pUnoCrsr, xParentText, nSelectionStartPos, nSelectionEndPos); + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) + { + SwPosition aPos( *pTxtNode ); + SwPaM aPam ( aPos ); + aRef = new SwXTextPortionEnumeration(aPam, xParentText, + nSelectionStartPos, nSelectionEndPos); + } else throw uno::RuntimeException(); return aRef; @@ -980,10 +1098,7 @@ uno::Type SwXParagraph::getElementType(void) throw( uno::RuntimeException ) sal_Bool SwXParagraph::hasElements(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(((SwXParagraph*)this)->GetCrsr()) - return sal_True; - else - return sal_False; + return (GetTxtNode()) ? sal_True : sal_False; } /*-- 11.12.98 08:12:55--------------------------------------------------- @@ -999,11 +1114,13 @@ uno::Reference< text::XTextRange > SwXParagraph::getStart(void) throw( uno::Run { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if( pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { - SwParaSelection aSelection(pUnoCrsr); - SwPaM aPam(*pUnoCrsr->Start()); + SwPosition aPos( *pTxtNode ); + SwCursor aCursor( aPos, 0, false ); + SwParaSelection aParaSel( &aCursor ); + SwPaM aPam( *aCursor.Start() ); uno::Reference< text::XText > xParent = getText(); xRet = new SwXTextRange(aPam, xParent); } @@ -1018,11 +1135,13 @@ uno::Reference< text::XTextRange > SwXParagraph::getEnd(void) throw( uno::Runti { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if( pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { - SwParaSelection aSelection(pUnoCrsr); - SwPaM aPam(*pUnoCrsr->End()); + SwPosition aPos( *pTxtNode ); + SwCursor aCursor( aPos, 0, false ); + SwParaSelection aParaSel( &aCursor ); + SwPaM aPam( *aCursor.End() ); uno::Reference< text::XText > xParent = getText(); xRet = new SwXTextRange(aPam, xParent); } @@ -1037,11 +1156,13 @@ OUString SwXParagraph::getString(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); OUString aRet; - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if( pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { - SwParaSelection aSelection(pUnoCrsr); - SwXTextCursor::getTextFromPam(*pUnoCrsr, aRet); + SwPosition aPos( *pTxtNode ); + SwCursor aCursor( aPos, 0, false ); + SwParaSelection aParaSel( & aCursor ); + SwXTextCursor::getTextFromPam(aCursor, aRet); } else if(IsDescriptor()) aRet = m_sText; @@ -1055,17 +1176,21 @@ OUString SwXParagraph::getString(void) throw( uno::RuntimeException ) void SwXParagraph::setString(const OUString& aString) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) { - if(!SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr)) - pUnoCrsr->MovePara(fnParaCurr, fnParaStart); - SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); - if(pUnoCrsr->GetNode()->GetTxtNode()->GetTxt().Len()) - pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); - SwXTextCursor::SetString(*pUnoCrsr, aString); - SwXTextCursor::SelectPam(*pUnoCrsr, sal_False); + SwPosition aPos( *pTxtNode ); + SwCursor aCursor( aPos, 0, false ); + if (!SwUnoCursorHelper::IsStartOfPara(aCursor)) { + aCursor.MovePara(fnParaCurr, fnParaStart); + } + SwXTextCursor::SelectPam(aCursor, sal_True); + if (pTxtNode->GetTxt().Len()) { + aCursor.MovePara(fnParaCurr, fnParaEnd); + } + SwXTextCursor::SetString(aCursor, aString); + SwXTextCursor::SelectPam(aCursor, sal_False); } else if(IsDescriptor()) m_sText = aString; @@ -1079,11 +1204,14 @@ void SwXParagraph::setString(const OUString& aString) throw( uno::RuntimeExcepti uno::Reference< container::XEnumeration > SwXParagraph::createContentEnumeration(const OUString& rServiceName) throw( uno::RuntimeException ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if( !pUnoCrsr || COMPARE_EQUAL != rServiceName.compareToAscii("com.sun.star.text.TextContent") ) + const SwTxtNode * pTxtNode( GetTxtNode() ); + if(!pTxtNode || !rServiceName.equalsAscii("com.sun.star.text.TextContent")) throw uno::RuntimeException(); - uno::Reference< container::XEnumeration > xRet = new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_PARAGRAPH); + SwPosition aPos( *pTxtNode ); + SwPaM aPam( aPos ); + uno::Reference< container::XEnumeration > xRet = + new SwXParaFrameEnumeration(aPam, PARAFRAME_PORTION_PARAGRAPH); return xRet; } /* -----------------23.03.99 12:49------------------- @@ -1106,3 +1234,33 @@ void SwXParagraph::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) aLstnrCntnr.Disposing(); } +const SwTxtNode * SwXParagraph::GetTxtNode() const +{ + return static_cast<const SwTxtNode*>(GetRegisteredIn()); +} + +SwTxtNode * SwXParagraph::GetTxtNode() +{ + return static_cast<SwTxtNode*>(pRegisteredIn); +} + +::sfx2::Metadatable* SwXParagraph::GetCoreObject() +{ + SwTxtNode * pTxtNode( GetTxtNode() ); + return pTxtNode; +} + +uno::Reference<frame::XModel> SwXParagraph::GetModel() +{ + SwTxtNode * pTxtNode( GetTxtNode() ); + if (pTxtNode) + { + const SwDocShell * pShell( pTxtNode->GetDoc()->GetDocShell() ); + return (pShell) ? pShell->GetModel() : 0; + } + else + { + return 0; + } +} + diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index 6fcff2505136..4aa2d1a27d6f 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -86,7 +86,7 @@ SwFmtFld* SwXTextPortion::GetFldFmt(sal_Bool bInit) -----------------------------------------------------------------------*/ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, - uno::Reference< text::XText > & rParent, + uno::Reference< text::XText > const& rParent, SwTextPortionType eType) : aLstnrCntnr( (text::XTextRange*)this), m_pPropSet(aSwMapProvider.GetPropertySet( @@ -121,8 +121,9 @@ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, /* -----------------24.03.99 16:30------------------- * * --------------------------------------------------*/ -SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, uno::Reference< text::XText > & rParent, - SwFrmFmt& rFmt ) : +SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, + uno::Reference< text::XText > const& rParent, + SwFrmFmt& rFmt ) : aLstnrCntnr( (text::XTextRange*)this), m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXTPORTION_EXTENSIONS)), xParentText(rParent), @@ -1072,7 +1073,7 @@ void SwXTextPortion::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) ---------------------------------------------------------------------------*/ SwXRubyPortion::SwXRubyPortion(const SwUnoCrsr* pPortionCrsr, SwTxtRuby& rAttr, - uno::Reference< text::XText > & rParent, + uno::Reference< text::XText > const& rParent, sal_Bool bEnd ) : SwXTextPortion(pPortionCrsr, rParent, bEnd ? PORTION_RUBY_END : PORTION_RUBY_START ) { diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index eee230794051..8b4736f51339 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -57,12 +57,14 @@ #include <boost/shared_ptr.hpp> #include <boost/bind.hpp> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::text; using ::rtl::OUString; using namespace ::std; + namespace { static const BYTE BKM_TYPE_START = 0; @@ -165,6 +167,7 @@ namespace } } + /****************************************************************** * SwXTextPortionEnumeration ******************************************************************/ @@ -284,7 +287,8 @@ uno::Any SwXTextPortionEnumeration::nextElement(void) ---------------------------------------------------------------------------*/ void lcl_InsertRefMarkPortion( - XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, Reference<XText>& rParent, SwTxtAttr* pAttr, BOOL bEnd) + XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, + Reference<XText> const& rParent, SwTxtAttr* pAttr, BOOL bEnd) { SwDoc* pDoc = pUnoCrsr->GetDoc(); SwFmtRefMark& rRefMark = ((SwFmtRefMark&)pAttr->GetAttr()); @@ -311,18 +315,17 @@ void lcl_InsertRefMarkPortion( } //----------------------------------------------------------------------------- void lcl_InsertRubyPortion( XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, - Reference<XText>& rParent, SwTxtAttr* pAttr, BOOL bEnd) + Reference<XText> const& rParent, SwTxtAttr* pAttr, BOOL bEnd) { - SwXRubyPortion* pPortion = 0; - rArr.Insert( - new Reference< XTextRange >(pPortion = new SwXRubyPortion(*pUnoCrsr, *(SwTxtRuby*)pAttr, rParent, - bEnd)), - rArr.Count()); + SwXRubyPortion* pPortion = + new SwXRubyPortion(pUnoCrsr, *(SwTxtRuby*)pAttr, rParent, bEnd); + rArr.Insert( new Reference< XTextRange >(pPortion), rArr.Count() ); pPortion->SetCollapsed(pAttr->GetEnd() ? FALSE : TRUE); } //----------------------------------------------------------------------------- void lcl_InsertTOXMarkPortion( - XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, Reference<XText>& rParent, SwTxtAttr* pAttr, BOOL bEnd) + XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, Reference<XText> const& rParent, + SwTxtAttr* pAttr, BOOL bEnd) { SwDoc* pDoc = pUnoCrsr->GetDoc(); SwTOXMark& rTOXMark = ((SwTOXMark&)pAttr->GetAttr()); @@ -455,20 +458,17 @@ typedef std::multiset < SwXRedlinePortion_ImplSharedPtr, RedlineCompareStruct > //----------------------------------------------------------------------------- Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, - XTextRangeArr& rPortionArr, - SwUnoCrsr* pUnoCrsr, - Reference<XText> & rParent, - const xub_StrLen nCurrentIndex, - SwTextPortionType& ePortionType, - const xub_StrLen& nFirstFrameIndex, - SwXBookmarkPortion_ImplList& aBkmArr, - SwXRedlinePortion_ImplList& aRedArr, - SwSoftPageBreakList& aBreakArr, - sal_Int32 nEndPos ) + XTextRangeArr& rPortionArr, + SwUnoCrsr* pUnoCrsr, + const Reference<XText> & rParent, + const xub_StrLen nCurrentIndex, + SwTextPortionType & rePortionType, + bool & io_rbRightMoveForbidden, + sal_Int32 & o_rNextAttrPosition ) { Reference<XTextRange> xRef; SwDoc* pDoc = pUnoCrsr->GetDoc(); - sal_Bool bAttrFound = sal_False; + bool bAlreadyMoved = false; //search for special text attributes - first some ends sal_uInt16 nEndIndex = 0; sal_uInt16 nNextEnd = 0; @@ -490,29 +490,25 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, case RES_TXTATR_TOXMARK: lcl_InsertTOXMarkPortion( rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; break; case RES_TXTATR_REFMARK: lcl_InsertRefMarkPortion( rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; break; case RES_TXTATR_CJK_RUBY: lcl_InsertRubyPortion( rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; break; } } } nEndIndex++; } - //#111716# the cursor must not move right at the end position of a selection! - BOOL bRightMoveForbidden = FALSE; - if(nEndPos > 0 && nCurrentIndex >= nEndPos) - bRightMoveForbidden = TRUE; - //then som starts + // then some starts sal_uInt16 nStartIndex = 0; sal_uInt16 nNextStart = 0; while(nStartIndex < pHints->GetStartCount() && @@ -529,29 +525,29 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, switch( nAttrWhich ) { case RES_TXTATR_FIELD: - if(!bRightMoveForbidden) + if(!io_rbRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) break; - bAttrFound = sal_True; - ePortionType = PORTION_FIELD; + bAlreadyMoved = true; + rePortionType = PORTION_FIELD; } break; case RES_TXTATR_FLYCNT : - if(!bRightMoveForbidden) + if(!io_rbRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) break; // Robust #i81708 content in covered cells pUnoCrsr->Exchange(); - bAttrFound = sal_True; - ePortionType = PORTION_FRAME; + bAlreadyMoved = true; + rePortionType = PORTION_FRAME; } break; case RES_TXTATR_FTN : { - if(!bRightMoveForbidden) + if(!io_rbRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) @@ -563,8 +559,8 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, SwXFootnotes::GetObject(*pDoc, pAttr->SwTxtAttr::GetFtn()), UNO_QUERY); pPortion->SetFootnote(xContent); - bAttrFound = sal_True; - ePortionType = PORTION_TEXT; + bAlreadyMoved = true; + rePortionType = PORTION_TEXT; } } break; @@ -577,12 +573,12 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, pUnoCrsr, rParent, PORTION_CONTROL_CHAR)), rPortionArr.Count()); pPortion->SetControlChar(3); - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; } break; case RES_TXTATR_HARDBLANK: { - ePortionType = PORTION_CONTROL_CHAR; + rePortionType = PORTION_CONTROL_CHAR; SwXTextPortion* pPortion = 0; rPortionArr.Insert( new Reference< XTextRange >( @@ -594,26 +590,26 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, pPortion->SetControlChar(2);//HARD_HYPHEN else pPortion->SetControlChar(4);//HARD_SPACE - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; } break; case RES_TXTATR_TOXMARK: lcl_InsertTOXMarkPortion( rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; break; case RES_TXTATR_REFMARK: - if(!bRightMoveForbidden || pAttr->GetEnd()) + if(!io_rbRightMoveForbidden || pAttr->GetEnd()) { if(!pAttr->GetEnd()) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); - bAttrFound = sal_True; + bAlreadyMoved = true; } lcl_InsertRefMarkPortion( rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; if(!pAttr->GetEnd()) { if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) @@ -627,7 +623,7 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, { lcl_InsertRubyPortion( rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - ePortionType = PORTION_TEXT; + rePortionType = PORTION_TEXT; } break; default: @@ -638,7 +634,7 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, nStartIndex++; } - if(!bAttrFound) + if (!bAlreadyMoved) { // search for attribute changes behind the current cursor position // break up at frames, bookmarks, redlines @@ -654,37 +650,54 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, while(nEndIndex < pHints->GetEndCount() && nCurrentIndex >= (nNextEnd = (*pHints->GetEnd(nEndIndex)->GetAnyEnd()))) nEndIndex++; - //nMovePos legt die neue EndPosition fest - sal_uInt16 nMovePos = nNextStart > nCurrentIndex && nNextStart < nNextEnd ? nNextStart : nNextEnd; - if (nMovePos <= nCurrentIndex) - nMovePos = pUnoCrsr->GetCntntNode()->Len(); - if(nEndPos >= 0 && nMovePos > nEndPos) - nMovePos = (USHORT)nEndPos; - - if(aBkmArr.size() && (*aBkmArr.begin())->getIndex() < nMovePos) - { - DBG_ASSERT((*aBkmArr.begin())->getIndex() > nCurrentIndex, - "forgotten bookmark(s)"); - nMovePos = (sal_uInt16)(*aBkmArr.begin())->getIndex(); - } - // break up portions for redlines - if (aRedArr.size() && (*aRedArr.begin())->getRealIndex() < nMovePos) + sal_Int32 nNextPos = + ((nNextStart > nCurrentIndex) && (nNextStart < nNextEnd)) + ? nNextStart : nNextEnd; + if (nNextPos > nCurrentIndex) { - nMovePos = (sal_uInt16)(*aRedArr.begin())->getRealIndex(); + o_rNextAttrPosition = nNextPos; } - // break up portions for soft page breaks - if (aBreakArr.size() && *aBreakArr.begin() < nMovePos) - { - nMovePos = *aBreakArr.begin(); - } - // break up if the destination is behind a frame - if(nFirstFrameIndex != STRING_MAXLEN && nMovePos > nFirstFrameIndex) - nMovePos = nFirstFrameIndex; + } + else + { + io_rbRightMoveForbidden = true; + } + return xRef; +} + +void lcl_MoveCursor( SwUnoCrsr* pUnoCrsr, + const xub_StrLen nCurrentIndex, + const sal_Int32 nNextFrameIndex, const sal_Int32 nNextPortionIndex, + const sal_Int32 nNextAttrIndex, const sal_Int32 nEndPos ) +{ + sal_Int32 nMovePos = pUnoCrsr->GetCntntNode()->Len(); + + if ((nEndPos >= 0) && (nEndPos < nMovePos)) + { + nMovePos = nEndPos; + } + + if ((nNextFrameIndex >= 0) && (nNextFrameIndex < nMovePos)) + { + nMovePos = nNextFrameIndex; + } - if(nMovePos > nCurrentIndex) + if ((nNextPortionIndex >= 0) && (nNextPortionIndex < nMovePos)) + { + nMovePos = nNextPortionIndex; + } + + if ((nNextAttrIndex >= 0) && (nNextAttrIndex < nMovePos)) + { + nMovePos = nNextAttrIndex; + } + + if (nMovePos > nCurrentIndex) + { // pUnoCrsr->Right(nMovePos - nCurrentIndex); - pUnoCrsr->GetPoint()->nContent = nMovePos; + pUnoCrsr->GetPoint()->nContent = static_cast<USHORT>(nMovePos); + } else if(nEndPos < 0 || nCurrentIndex < nEndPos) { // ensure proper exit: move to paragraph end @@ -696,8 +709,6 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, "may only happen at paragraph end"); pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); } - } - return xRef; } //----------------------------------------------------------------------------- @@ -757,8 +768,7 @@ void lcl_ExportRedline( { rPortionArr.Insert( new Reference< XTextRange >( new SwXRedlinePortion( - pPtr->pRedline, *pUnoCrsr, rParent, - pPtr->bStart)), + pPtr->pRedline, pUnoCrsr, rParent, pPtr->bStart)), rPortionArr.Count()); rRedlineArr.erase ( aIter++ ); } @@ -823,6 +833,7 @@ void SwXTextPortionEnumeration::CreatePortions() DBG_ASSERT(pUnoCrsr->Start()->nNode.GetNode().GetTxtNode() && nStartPos <= pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()->GetTxt().Len(), "Incorrect start position" ); + // ??? should this be nStartPos - current position ? pUnoCrsr->Right((xub_StrLen)nStartPos,CRSR_SKIP_CHARS,FALSE,FALSE); } if(pUnoCrsr /*&& !bAtEnd*/) @@ -932,58 +943,34 @@ void SwXTextPortionEnumeration::CreatePortions() } if(!xRef.is()) { - lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr, nCurrentIndex, pUnoCrsr, xParent, aPortionArr); - if(pHints) - { - xRef = lcl_ExportHints(pHints, - aPortionArr, - pUnoCrsr, - xParent, - nCurrentIndex, - ePortionType, - nFirstFrameIndex, - aBkmArr, - aRedArr, - aBreakArr, - nEndPos); - } - else if(USHRT_MAX != nFirstFrameIndex) + lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr, + nCurrentIndex, pUnoCrsr, xParent, aPortionArr); + sal_Int32 nNextAttrIndex = -1; + sal_Int32 nNextPortionIndex = + lcl_GetNextIndex(aBkmArr, aRedArr, aBreakArr); + // #111716# the cursor must not move right at the + // end position of a selection! + bool bRightMoveForbidden = + ((nEndPos > 0) && (nCurrentIndex >= nEndPos)); + if (pHints) { - pUnoCrsr->Right(nFirstFrameIndex - nCurrentIndex,CRSR_SKIP_CHARS,FALSE,FALSE); + // N.B.: side-effects bRightMoveForbidden + // and nNextAttrIndex + xRef = lcl_ExportHints(pHints, aPortionArr, + pUnoCrsr, xParent, nCurrentIndex, ePortionType, + bRightMoveForbidden, nNextAttrIndex); } - else + if (!bRightMoveForbidden) { - sal_Int32 nNextIndex = lcl_GetNextIndex(aBkmArr, aRedArr, aBreakArr); - DBG_ASSERT( nNextIndex <= pCNd->Len(), "illegal next index" ); - if( nNextIndex > pCNd->Len() ) - { - nNextIndex = pCNd->Len(); - bAtEnd = sal_True; - } - if(nEndPos >= 0 && (nNextIndex > nEndPos || nNextIndex < 0)) - { - nNextIndex = nEndPos; - bAtEnd = sal_True; - } - if(nNextIndex < 0) - { - // a text portion should stay within it's paragraph (#i56165) - //sal_Bool bMove = pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); - pUnoCrsr->GetPoint()->nContent = pCNd->Len(); - bAtEnd = sal_True; - } - else - { - DBG_ASSERT(nNextIndex > nCurrentIndex || nNextIndex == nEndPos, - "wrong move index"); - pUnoCrsr->Right((sal_uInt16)(nNextIndex - nCurrentIndex),CRSR_SKIP_CHARS,FALSE,FALSE); - } + lcl_MoveCursor(pUnoCrsr, nCurrentIndex, + nFirstFrameIndex, nNextPortionIndex, + nNextAttrIndex, nEndPos); } } if(!xRef.is() && pUnoCrsr->HasMark() ) { //flr: maybe its a good idea to add a special hint to the hints array and rely on the hint segmentation.... - xub_StrLen start=pUnoCrsr->GetMark()->nContent.GetIndex(); - xub_StrLen end=pUnoCrsr->GetPoint()->nContent.GetIndex(); + xub_StrLen start=pUnoCrsr->Start()->nContent.GetIndex(); + xub_StrLen end=pUnoCrsr->End()->nContent.GetIndex(); ASSERT(start<=end, "hmm --- why is this different"); xub_StrLen startMarkerPos=pTxtNode->GetTxt().Search(CH_TXT_ATR_FIELDSTART, start); xub_StrLen endMarkerPos=pTxtNode->GetTxt().Search(CH_TXT_ATR_FIELDEND, start); @@ -1082,17 +1069,15 @@ void SwXTextPortionEnumeration::CreatePortions() if(pHints) { SwTextPortionType ePortionType = PORTION_TEXT; + bool bDummy = false; + sal_Int32 nDummy = -1; Reference<XTextRange> xRef = lcl_ExportHints(pHints, aPortionArr, pUnoCrsr, xParent, static_cast< xub_StrLen >(nLocalEnd), ePortionType, - STRING_MAXLEN, - aBkmArr, - aRedArr, - aBreakArr, - nEndPos); + bDummy, nDummy); if(xRef.is()) aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count()); } diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index e4aed674e7ae..20dde56ead7d 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -79,9 +79,7 @@ #include <com/sun/star/style/PageStyleLayout.hpp> #include <com/sun/star/style/BreakType.hpp> #include <com/sun/star/style/GraphicLocation.hpp> -#ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif #include <com/sun/star/chart/XChartDataChangeEventListener.hpp> #include <com/sun/star/chart/ChartDataChangeEvent.hpp> #include <com/sun/star/chart2/data/XDataSequence.hpp> @@ -1600,7 +1598,7 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt* pFmt, SwTableBox* pBox) : SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(aPos, sal_True); pUnoCrsr->Move( fnMoveForward, fnGoNode ); pUnoCrsr->Add(&aCrsrDepend); - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pTblCrsr->MakeBoxSels(); } /*-- 11.12.98 12:16:14--------------------------------------------------- @@ -1618,12 +1616,12 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt& rTableFmt, const SwTableCursor* *pUnoCrsr->GetMark() = *pTableSelection->GetMark(); } const SwSelBoxes& rBoxes = pTableSelection->GetBoxes(); - SwTableCursor* pTableCrsr = (SwTableCursor*) *pUnoCrsr; + SwTableCursor* pTableCrsr = dynamic_cast<SwTableCursor*>(pUnoCrsr); for(sal_uInt16 i = 0; i < rBoxes.Count(); i++) pTableCrsr->InsertBox( *rBoxes.GetObject(i) ); pUnoCrsr->Add(&aCrsrDepend); - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pTblCrsr->MakeBoxSels(); } /*-- 11.12.98 12:16:14--------------------------------------------------- @@ -1648,7 +1646,7 @@ OUString SwXTextTableCursor::getRangeName(void) throw( uno::RuntimeException ) //!! see also SwChartDataSequence::getSourceRangeRepresentation if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pTblCrsr->MakeBoxSels(); const SwStartNode* pNode = pTblCrsr->GetPoint()->nNode.GetNode().FindTableBoxStartNode(); const SwTable* pTable = SwTable::FindTable( GetFrmFmt() ); @@ -1689,7 +1687,7 @@ sal_Bool SwXTextTableCursor::gotoCellByName(const OUString& CellName, sal_Bool E SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); lcl_CrsrSelect( pTblCrsr, Expand ); String sCellName(CellName); bRet = pTblCrsr->GotoTblBox(sCellName); @@ -1706,7 +1704,7 @@ sal_Bool SwXTextTableCursor::goLeft(sal_Int16 Count, sal_Bool Expand) throw( uno SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); lcl_CrsrSelect( pTblCrsr, Expand ); bRet = pTblCrsr->Left( Count,CRSR_SKIP_CHARS, FALSE, FALSE); } @@ -1722,7 +1720,7 @@ sal_Bool SwXTextTableCursor::goRight(sal_Int16 Count, sal_Bool Expand) throw( un SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); lcl_CrsrSelect( pTblCrsr, Expand ); bRet = pTblCrsr->Right( Count, CRSR_SKIP_CHARS, FALSE, FALSE); } @@ -1738,7 +1736,7 @@ sal_Bool SwXTextTableCursor::goUp(sal_Int16 Count, sal_Bool Expand) throw( uno:: SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); lcl_CrsrSelect( pTblCrsr, Expand ); bRet = pTblCrsr->UpDown(sal_True, Count, 0, 0); } @@ -1754,7 +1752,7 @@ sal_Bool SwXTextTableCursor::goDown(sal_Int16 Count, sal_Bool Expand) throw( uno SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); lcl_CrsrSelect( pTblCrsr, Expand ); bRet = pTblCrsr->UpDown(sal_False, Count, 0, 0); } @@ -1769,7 +1767,7 @@ void SwXTextTableCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); lcl_CrsrSelect( pTblCrsr, Expand ); pTblCrsr->MoveTable(fnTableCurr, fnTableStart); } @@ -1783,7 +1781,7 @@ void SwXTextTableCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException ) SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); lcl_CrsrSelect( pTblCrsr, Expand ); pTblCrsr->MoveTable(fnTableCurr, fnTableEnd); } @@ -1802,7 +1800,7 @@ sal_Bool SwXTextTableCursor::mergeRange(void) throw( uno::RuntimeException ) // hier muessen die Actions aufgehoben werden UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc()); } - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pTblCrsr->MakeBoxSels(); { @@ -1835,7 +1833,7 @@ sal_Bool SwXTextTableCursor::splitRange(sal_Int16 Count, sal_Bool Horizontal) th // hier muessen die Actions aufgehoben werden UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc()); } - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pTblCrsr->MakeBoxSels(); { UnoActionContext aContext(pUnoCrsr->GetDoc()); @@ -1877,7 +1875,7 @@ void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, SwStartNode* pSttNode = pUnoCrsr->GetNode()->StartOfSectionNode(); const SwTableNode* pTblNode = pSttNode->FindTableNode(); lcl_FormatTable((SwFrmFmt*)pTblNode->GetTable().GetFrmFmt()); - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); if(pEntry) @@ -1936,7 +1934,7 @@ uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName) SwStartNode* pSttNode = pUnoCrsr->GetNode()->StartOfSectionNode(); const SwTableNode* pTblNode = pSttNode->FindTableNode(); lcl_FormatTable((SwFrmFmt*)pTblNode->GetTable().GetFrmFmt()); - SwUnoTableCrsr* pTblCrsr = *pUnoCrsr; + SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); if(pEntry) @@ -2648,7 +2646,7 @@ uno::Reference< table::XCellRange > SwXTextTable::GetRangeByName(SwFrmFmt* pFmt pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = *pUnoCrsr; + SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); // pUnoCrsr wird uebergeben und nicht geloescht SwXCellRange* pCellRange = new SwXCellRange(pUnoCrsr, *pFmt, rDesc); @@ -3322,7 +3320,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = *pUnoCrsr; + SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); SfxItemSet aSet(pDoc->GetAttrPool(), @@ -3517,7 +3515,7 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName) throw( be pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = *pUnoCrsr; + SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); SfxItemSet aSet(pDoc->GetAttrPool(), @@ -4011,7 +4009,7 @@ uno::Reference< table::XCellRange > SwXCellRange::getCellRangeByPosition( pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = *pUnoCrsr; + SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); // pUnoCrsr wird uebergeben und nicht geloescht SwXCellRange* pCellRange = new SwXCellRange(pUnoCrsr, *pFmt, aNewDesc); @@ -4081,7 +4079,7 @@ void SwXCellRange::setPropertyValue(const OUString& rPropertyName, // remove actions to enable box selection UnoActionRemoveContext aRemoveContext(pDoc); } - SwUnoTableCrsr* pCrsr = *pTblCrsr; + SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr); pCrsr->MakeBoxSels(); switch(pEntry->nWID ) { @@ -4243,7 +4241,7 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName) throw( be RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, 0L); // erstmal die Attribute des Cursors - SwUnoTableCrsr* pCrsr = *pTblCrsr; + SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr); SwXTextCursor::GetCrsrAttr(pCrsr->GetSelRing(), aSet); m_pPropSet->getPropertyValue(*pEntry, aSet, aRet); } @@ -4459,7 +4457,7 @@ SwUnoCrsr * lcl_CreateCursor( SwFrmFmt &rTblFmt, pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pEndBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr *pCrsr = *pUnoCrsr; + SwUnoTableCrsr *pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); } return pUnoCrsr; @@ -4891,7 +4889,7 @@ void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rD if(pFmt && SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) { - SwUnoTableCrsr* pTableCrsr = *pTblCrsr; + SwUnoTableCrsr* pTableCrsr = dynamic_cast<SwUnoTableCrsr*>(pTblCrsr); pTableCrsr->MakeBoxSels(); UnoActionContext aContext( pFmt->GetDoc() ); pFmt->GetDoc()->SortTbl(pTableCrsr->GetBoxes(), aSortOpt); @@ -5152,7 +5150,8 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount) throw( uno: pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pBLBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = *pUnoCrsr; + SwUnoTableCrsr* pCrsr = + dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); { // Die Klammer ist wichtig UnoActionContext aAction(pFrmFmt->GetDoc()); @@ -5384,7 +5383,8 @@ void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount) throw( u pUnoCrsr->SetMark(); pUnoCrsr->GetPoint()->nNode = *pTRBox->GetSttNd(); pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = *pUnoCrsr; + SwUnoTableCrsr* pCrsr = + dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); pCrsr->MakeBoxSels(); { // Die Klammer ist wichtig UnoActionContext aAction(pFrmFmt->GetDoc()); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 7c921808b908..0511065e3bce 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -35,9 +35,7 @@ #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/text/ControlCharacter.hpp> -#ifndef _CMDID_H #include <cmdid.h> -#endif #include <vos/mutex.hxx> #include <vcl/svapp.hxx> #include <rtl/uuid.h> @@ -1411,8 +1409,9 @@ uno::Reference< text::XTextRange > SwXText::finishOrAppendParagraph( throw aEx; } } - SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(*aPam.Start(), sal_False); - xRet = new SwXParagraph(this, pUnoCrsr); + SwTxtNode * pTxtNode( aPam.Start()->nNode.GetNode().GetTxtNode() ); + OSL_ENSURE(pTxtNode, "no SwTxtNode?"); + xRet = new SwXParagraph(this, pTxtNode); } return xRet; diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 873c2d2bda24..493af14d8200 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -36,9 +36,7 @@ #include <sfx2/printer.hxx> #include <sfx2/objsh.hxx> -#ifndef _INTN_HXX //autogen // #include <tools/intn.hxx> -#endif #include <sfx2/progress.hxx> #include <sfx2/app.hxx> #include <sfx2/prnmon.hxx> @@ -770,9 +768,11 @@ SwDoc * ViewShell::CreatePrtDoc( SfxPrinter* pPrt, SfxObjectShellRef &rDocShellR pPrtDoc->ReplaceStyles( *GetDoc() ); SwShellCrsr *pActCrsr = pFESh->_GetCrsr(); - SwShellCrsr *pFirstCrsr = (SwShellCrsr*)*((SwCursor*)pActCrsr->GetNext()); + SwShellCrsr *pFirstCrsr = dynamic_cast<SwShellCrsr*>(pActCrsr->GetNext()); if( !pActCrsr->HasMark() ) // bei Multiselektion kann der aktuelle Cursor leer sein - pActCrsr = (SwShellCrsr*)*((SwCursor*)pActCrsr->GetPrev()); + { + pActCrsr = dynamic_cast<SwShellCrsr*>(pActCrsr->GetPrev()); + } // Die Y-Position der ersten Selektion const Point aSelPoint = pFESh->IsTableMode() ? @@ -858,9 +858,11 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) pPrtDoc->ReplaceStyles( *GetDoc() ); SwShellCrsr *pActCrsr = pFESh->_GetCrsr(); - SwShellCrsr *pFirstCrsr = (SwShellCrsr*)*((SwCursor*)pActCrsr->GetNext()); + SwShellCrsr *pFirstCrsr = dynamic_cast<SwShellCrsr*>(pActCrsr->GetNext()); if( !pActCrsr->HasMark() ) // bei Multiselektion kann der aktuelle Cursor leer sein - pActCrsr = (SwShellCrsr*)*((SwCursor*)pActCrsr->GetPrev()); + { + pActCrsr = dynamic_cast<SwShellCrsr*>(pActCrsr->GetPrev()); + } // Die Y-Position der ersten Selektion // Die Y-Position der ersten Selektion diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 5c459e9bd0f2..aa42977d9a02 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -2303,7 +2303,7 @@ BOOL SwHTMLParser::AppendTxtNode( SwHTMLAppendMode eMode, BOOL bUpdateNum ) SwpHints& rHints = pTxtNd->GetSwpHints(); for( sal_uInt16 i=0; i < nCntAttr; i++ ) { - SwTxtAttr *pHt = rHints.GetHt( i ); + SwTxtAttr *pHt = rHints.GetTextHint( i ); sal_uInt16 nWhich = pHt->Which(); sal_Int16 nIdx = -1; if( RES_CHRATR_CJK_FONT <= nWhich && @@ -2613,8 +2613,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, ( !pAttr->IsLikePara() && nEndParaIdx == rEndIdx.GetIndex() && pAttr->GetEndCnt() < nEndCnt && - RES_CHRATR_BEGIN <= nWhich && - RES_TXTATR_WITHEND_END > nWhich ) || + (isCHRATR(nWhich) || isTXTATR_WITHEND(nWhich)) ) || ( bBeforeTable && nEndParaIdx == rEndIdx.GetIndex() && !pAttr->GetEndCnt() ); @@ -2663,9 +2662,8 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, { // durch die elende Loescherei von Nodes kann auch mal // ein Index auf einen End-Node zeigen :-( - if( pAttr->GetSttPara() == pAttr->GetEndPara() && - (nWhich < RES_TXTATR_NOEND_BEGIN || - nWhich >= RES_TXTATR_NOEND_END) ) + if ( (pAttr->GetSttPara() == pAttr->GetEndPara()) && + !isTXTATR_NOEND(nWhich) ) { // wenn der End-Index auch auf den Node zeigt // brauchen wir auch kein Attribut mehr zu setzen, @@ -2696,9 +2694,8 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, pAttrPam->GetPoint()->nContent.Assign( pCNd, pAttr->nSttCntnt ); pAttrPam->SetMark(); - if( pAttr->GetSttPara() != pAttr->GetEndPara() && - (nWhich < RES_TXTATR_NOEND_BEGIN || - nWhich >= RES_TXTATR_NOEND_END) ) + if ( (pAttr->GetSttPara() != pAttr->GetEndPara()) && + !isTXTATR_NOEND(nWhich) ) { pCNd = pDoc->GetNodes()[ pAttr->nEndPara ]->GetCntntNode(); if( !pCNd ) @@ -2738,8 +2735,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, // muessen wir es im Node davor beenden oder wegschmeissen, // wenn es erst in dem Node beginnt if( nWhich != RES_BREAK && nWhich != RES_PAGEDESC && - (nWhich < RES_TXTATR_NOEND_BEGIN || - nWhich >= RES_TXTATR_NOEND_END) ) + !isTXTATR_NOEND(nWhich) ) { if( pAttrPam->GetMark()->nNode.GetIndex() != rEndIdx.GetIndex() ) diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index f22145b4ce62..09d43495f51f 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -1650,7 +1650,8 @@ void fixKeepAndSplitAttributes(SwTableNode *pTableNode) SwTableLine* pSplitLine = rLns[ nLines-2 ]; SwTableBox* pSplitBox = pSplitLine->GetTabBoxes()[ 0 ]; SwNodeIndex aSplitIdx( *pSplitBox->GetSttNd() ); - pDoc->SplitTable( aSplitIdx, HEADLINE_NONE, !isTableKeep ); + pDoc->SplitTable( SwPosition(aSplitIdx), HEADLINE_NONE, + !isTableKeep ); SwTable& rSplitTable=aSplitIdx.GetNode().FindTableNode()->GetTable(); aSplitIdx-=2; pDoc->GetNodes().Delete(aSplitIdx); @@ -1668,7 +1669,7 @@ void fixKeepAndSplitAttributes(SwTableNode *pTableNode) if (isTableKeep) { SwNodeIndex aTmpIdx( *pBox->GetSttNd() ); - pDoc->SplitTable( aTmpIdx, HEADLINE_NONE, FALSE ); + pDoc->SplitTable( SwPosition(aTmpIdx), HEADLINE_NONE, FALSE ); SwTable& rSplitTable=aTmpIdx.GetNode().FindTableNode()->GetTable(); aTmpIdx-=2; pDoc->GetNodes().Delete(aTmpIdx); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 884426f129c5..4dd95cf0414d 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -284,7 +284,7 @@ void SwWW8Writer::ExportPoolItemsToCHP(sw::PoolItems &rItems, USHORT nScript) USHORT nWhich = pItem->Which(); if (FnAttrOut pOut = aWW8AttrFnTab[nWhich - RES_CHRATR_BEGIN]) { - if (nWhich < RES_CHRATR_BEGIN || nWhich >= RES_TXTATR_END) + if (!isCHRATR(nWhich) && !isTXTATR(nWhich)) continue; if (SwWW8Writer::CollapseScriptsforWordOk(nScript, nWhich)) (*pOut)(*this, *pItem); diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 5e5759923e71..b6dbdbcfba7a 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -2307,14 +2307,12 @@ WW8DupProperties::WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStk) const SwFltStackEntry* pEntry = (*pCtrlStck)[ i ]; if(pEntry->bLocked) { - if (pEntry->pAttr->Which() > RES_CHRATR_BEGIN && - pEntry->pAttr->Which() < RES_CHRATR_END) + if (isCHRATR(pEntry->pAttr->Which())) { aChrSet.Put( *pEntry->pAttr ); } - else if (pEntry->pAttr->Which() > RES_PARATR_BEGIN && - pEntry->pAttr->Which() < RES_PARATR_END) + else if (isPARATR(pEntry->pAttr->Which())) { aParSet.Put( *pEntry->pAttr ); } diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index 2536b9bf57e3..abe69df298d6 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -54,6 +54,7 @@ #include <com/sun/star/io/XActiveDataSource.hpp> #include <com/sun/star/packages/zip/ZipIOException.hpp> #include <com/sun/star/packages/WrongPasswordException.hpp> +#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> #include <svtools/svstdarr.hxx> #include <sfx2/docfile.hxx> #include <svtools/sfxecode.hxx> @@ -70,16 +71,12 @@ #include <errhdl.hxx> #include <fltini.hxx> #include <doc.hxx> -#ifndef _DOCSH_HXX //autogen wg. SwDoc #include <docsh.hxx> -#endif #include <unoobj.hxx> #include <swmodule.hxx> #include <SwXMLSectionList.hxx> -#ifndef _STATSTR_HRC #include <statstr.hrc> -#endif // --> OD 2005-09-06 #i44177# #include <SwStyleNameMapper.hxx> @@ -103,6 +100,8 @@ #include <istyleaccess.hxx> #define LOGFILE_AUTHOR "mb93740" +#include <sfx2/DocumentMetadataAccess.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -516,6 +515,7 @@ void lcl_ConvertSdrOle2ObjsToSdrGrafObjs( SwDoc& _rDoc ) } // <-- + ULONG XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const String & rName ) { // Get service factory @@ -810,23 +810,25 @@ ULONG XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const S xInfoSet->setPropertyValue( sPropName, makeAny( aBaseURL ) ); // TODO/LATER: separate links from usual embedded objects + ::rtl::OUString StreamPath; if( SFX_CREATE_MODE_EMBEDDED == rDoc.GetDocShell()->GetCreateMode() ) { - OUString aName; if ( pMedDescrMedium && pMedDescrMedium->GetItemSet() ) { const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>( pMedDescrMedium->GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) ); if ( pDocHierarchItem ) - aName = pDocHierarchItem->GetValue(); + StreamPath = pDocHierarchItem->GetValue(); } else - aName = ::rtl::OUString::createFromAscii( "dummyObjectName" ); + { + StreamPath = ::rtl::OUString::createFromAscii( "dummyObjectName" ); + } - if( aName.getLength() ) + if( StreamPath.getLength() ) { sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath")); - xInfoSet->setPropertyValue( sPropName, makeAny( aName ) ); + xInfoSet->setPropertyValue( sPropName, makeAny( StreamPath ) ); } } @@ -869,6 +871,38 @@ ULONG XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const S makeAny( bTextDocInOOoFileFormat ) ); } // <-- + + sal_uInt32 nWarnRDF = 0; + // RDF metadata - must be read before styles/content + // N.B.: embedded documents have their own manifest.rdf! + try + { + const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(xModelComp, + uno::UNO_QUERY_THROW); + const uno::Reference<rdf::XURI> xBaseURI( ::sfx2::createBaseURI( + aContext.getUNOContext(), xStorage, aBaseURL, StreamPath) ); + const uno::Reference<task::XInteractionHandler> xHandler( + pDocSh->GetMedium()->GetInteractionHandler() ); + xDMA->loadMetadataFromStorage(xStorage, xBaseURI, xHandler); + } + catch (lang::WrappedTargetException & e) + { + ucb::InteractiveAugmentedIOException iaioe; + if (e.TargetException >>= iaioe) + { + // import error that was not ignored by InteractionHandler! + nWarnRDF = ERR_SWG_READ_ERROR; + } + else + { + nWarnRDF = WARN_SWG_FEATURES_LOST; // uhh... something went wrong? + } + } + catch (uno::Exception &) + { + nWarnRDF = WARN_SWG_FEATURES_LOST; // uhh... something went wrong? + } + sal_uInt32 nWarn = 0; sal_uInt32 nWarn2 = 0; // read storage streams @@ -924,13 +958,7 @@ ULONG XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const S else if ( rDoc.IsOLEPrtNotifyPending() ) rDoc.PrtOLENotify( TRUE ); - if( !nRet ) - { - if( nWarn ) - nRet = nWarn; - else if( nWarn2 ) - nRet = nWarn2; - } + nRet = nRet ? nRet : (nWarn ? nWarn : (nWarn2 ? nWarn2 : nWarnRDF ) ); aOpt.ResetAllFmtsOnly(); diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx index e944ad81aba7..09b7bdd8ed30 100644 --- a/sw/source/filter/xml/wrtxml.cxx +++ b/sw/source/filter/xml/wrtxml.cxx @@ -54,19 +54,18 @@ #include <pam.hxx> #include <doc.hxx> #include <docstat.hxx> -#ifndef _DOCSH_HXX //autogen wg. SwDoc #include <docsh.hxx> -#endif #include <unotools/ucbstreamhelper.hxx> #include <errhdl.hxx> #include <swerror.h> #include <wrtxml.hxx> -#ifndef _STATSTR_HRC #include <statstr.hrc> -#endif #include <rtl/logfile.hxx> +#include <comphelper/documentconstants.hxx> +#include <comphelper/makesequence.hxx> +#include <com/sun/star/rdf/XDocumentMetadataAccess.hpp> using ::rtl::OUString; using namespace ::com::sun::star; @@ -366,6 +365,35 @@ pGraphicHelper = SvXMLGraphicHelper::Create( xStg, sal_Bool bWarn = sal_False, bErr = sal_False; String sWarnFile, sErrFile; + // RDF metadata: export if ODF >= 1.2 + // N.B.: embedded documents have their own manifest.rdf! + if ( bOASIS ) + { + const uno::Reference<beans::XPropertySet> xPropSet(xStg, + uno::UNO_QUERY_THROW); + const ::rtl::OUString VersionProp( + ::rtl::OUString::createFromAscii("Version")); + try + { + ::rtl::OUString Version; + // ODF >= 1.2 + if ((xPropSet->getPropertyValue(VersionProp) >>= Version) + && !Version.equals(ODFVER_010_TEXT) + && !Version.equals(ODFVER_011_TEXT)) + { + const uno::Reference<rdf::XDocumentMetadataAccess> xDMA( + xModelComp, uno::UNO_QUERY_THROW); + xDMA->storeMetadataToStorage(xStg); + } + } + catch (beans::UnknownPropertyException &) + { /* ignore */ } + catch (uno::Exception &) + { + bWarn = sal_True; + } + } + sal_Bool bStoreMeta = ( SFX_CREATE_MODE_EMBEDDED != pDoc->GetDocShell()->GetCreateMode() ); if ( !bStoreMeta ) { diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index 6ae1bf52931c..444646a6281d 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -45,9 +45,7 @@ #include <xmloff/xmltkmap.hxx> #include <xmloff/nmspmap.hxx> -#ifndef _XMLOFF_FAMILIES_HXX #include <xmloff/families.hxx> -#endif #include <xmloff/xmluconv.hxx> #include <xmloff/i18nmap.hxx> #include <svx/protitem.hxx> @@ -98,6 +96,7 @@ enum SwXMLTableElemTokens enum SwXMLTableCellAttrTokens { + XML_TOK_TABLE_XMLID, XML_TOK_TABLE_STYLE_NAME, XML_TOK_TABLE_NUM_COLS_SPANNED, XML_TOK_TABLE_NUM_ROWS_SPANNED, @@ -137,6 +136,7 @@ static __FAR_DATA SvXMLTokenMapEntry aTableElemTokenMap[] = static __FAR_DATA SvXMLTokenMapEntry aTableCellAttrTokenMap[] = { + { XML_NAMESPACE_XML, XML_ID, XML_TOK_TABLE_XMLID }, { XML_NAMESPACE_TABLE, XML_STYLE_NAME, XML_TOK_TABLE_STYLE_NAME }, { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED, XML_TOK_TABLE_NUM_COLS_SPANNED }, { XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED, XML_TOK_TABLE_NUM_ROWS_SPANNED }, @@ -174,6 +174,8 @@ class SwXMLTableCell_Impl { OUString aStyleName; + OUString mXmlId; + OUString sFormula; // cell formula; valid if length > 0 double dValue; // formula value @@ -206,7 +208,8 @@ public: sal_Bool bHasValue = sal_False, sal_Bool mbCovered = sal_False, double dVal = 0.0, - sal_Bool mbTextValue = sal_False ); + sal_Bool mbTextValue = sal_False, + OUString const& i_rXmlId = OUString()); sal_Bool IsUsed() const { return pStartNode!=0 || xSubTable.Is() || bProtected;} @@ -221,6 +224,7 @@ public: sal_Bool IsProtected() const { return bProtected; } sal_Bool IsCovered() const { return mbCovered; } sal_Bool HasTextValue() const { return mbTextValue; } + const OUString& GetXmlId() const { return mXmlId; } const SwStartNode *GetStartNode() const { return pStartNode; } inline void SetStartNode( const SwStartNode *pSttNd ); @@ -239,7 +243,8 @@ inline void SwXMLTableCell_Impl::Set( const OUString& rStyleName, sal_Bool bHasVal, sal_Bool bCov, double dVal, - sal_Bool bTextVal ) + sal_Bool bTextVal, + OUString const& i_rXmlId ) { aStyleName = rStyleName; nRowSpan = nRSpan; @@ -252,6 +257,11 @@ inline void SwXMLTableCell_Impl::Set( const OUString& rStyleName, mbTextValue = bTextVal; bProtected = bProtect; + if (!mbCovered) // ensure uniqueness + { + mXmlId = i_rXmlId; + } + // set formula, if valid if (pFormula != NULL) { @@ -286,6 +296,7 @@ class SwXMLTableRow_Impl { OUString aStyleName; OUString aDfltCellStyleName; + OUString mXmlId; SwXMLTableCells_Impl aCells; @@ -294,13 +305,15 @@ class SwXMLTableRow_Impl public: SwXMLTableRow_Impl( const OUString& rStyleName, sal_uInt32 nCells, - const OUString *pDfltCellStyleName = 0 ); + const OUString *pDfltCellStyleName = 0, + const OUString& i_rXmlId = OUString() ); ~SwXMLTableRow_Impl() {} inline SwXMLTableCell_Impl *GetCell( sal_uInt32 nCol ) const; inline void Set( const OUString& rStyleName, - const OUString& rDfltCellStyleName ); + const OUString& rDfltCellStyleName, + const OUString& i_rXmlId ); void Expand( sal_uInt32 nCells, sal_Bool bOneCell ); @@ -309,14 +322,17 @@ public: const OUString& GetStyleName() const { return aStyleName; } const OUString& GetDefaultCellStyleName() const { return aDfltCellStyleName; } + const OUString& GetXmlId() const { return mXmlId; } void Dispose(); }; SwXMLTableRow_Impl::SwXMLTableRow_Impl( const OUString& rStyleName, sal_uInt32 nCells, - const OUString *pDfltCellStyleName ) : + const OUString *pDfltCellStyleName, + const OUString& i_rXmlId ) : aStyleName( rStyleName ), + mXmlId( i_rXmlId ), bSplitable( sal_False ) { if( pDfltCellStyleName ) @@ -365,10 +381,12 @@ void SwXMLTableRow_Impl::Expand( sal_uInt32 nCells, sal_Bool bOneCell ) } inline void SwXMLTableRow_Impl::Set( const OUString& rStyleName, - const OUString& rDfltCellStyleName ) + const OUString& rDfltCellStyleName, + const OUString& i_rXmlId ) { aStyleName = rStyleName; aDfltCellStyleName = rDfltCellStyleName; + mXmlId = i_rXmlId; } void SwXMLTableRow_Impl::Dispose() @@ -384,6 +402,7 @@ class SwXMLTableCellContext_Impl : public SvXMLImportContext OUString aStyleName; OUString sFormula; OUString sSaveParaDefault; + OUString mXmlId; SvXMLImportContextRef xMyTable; @@ -456,6 +475,9 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl( GetSwImport().GetTableCellAttrTokenMap(); switch( rTokenMap.Get( nPrefix, aLocalName ) ) { + case XML_TOK_TABLE_XMLID: + mXmlId = rValue; + break; case XML_TOK_TABLE_STYLE_NAME: aStyleName = rValue; GetImport().GetTextImport()->sCellParaStyleDefault = rValue; @@ -550,6 +572,7 @@ inline void SwXMLTableCellContext_Impl::_InsertContent() { GetTable()->InsertCell( aStyleName, nRowSpan, nColSpan, GetTable()->InsertTableSection(), + mXmlId, NULL, bProtect, &sFormula, bHasValue, fValue, bHasTextValue ); } @@ -569,7 +592,7 @@ inline void SwXMLTableCellContext_Impl::InsertContentIfNotThere() inline void SwXMLTableCellContext_Impl::InsertContent( SwXMLTableContext *pTable ) { - GetTable()->InsertCell( aStyleName, nRowSpan, nColSpan, 0, pTable, bProtect ); + GetTable()->InsertCell( aStyleName, nRowSpan, nColSpan, 0, mXmlId, pTable, bProtect ); bHasTableContent = sal_True; } @@ -580,11 +603,12 @@ SvXMLImportContext *SwXMLTableCellContext_Impl::CreateChildContext( { SvXMLImportContext *pContext = 0; + OUString sXmlId; sal_Bool bSubTable = sal_False; if( XML_NAMESPACE_TABLE == nPrefix && IsXMLToken( rLocalName, XML_TABLE ) ) { - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; for( sal_Int16 i=0; i < nAttrCount; i++ ) { const OUString& rAttrName = xAttrList->getNameByIndex( i ); @@ -596,7 +620,15 @@ SvXMLImportContext *SwXMLTableCellContext_Impl::CreateChildContext( if( XML_NAMESPACE_TABLE == nPrefix2 && IsXMLToken( aLocalName, XML_IS_SUB_TABLE ) && IsXMLToken( xAttrList->getValueByIndex( i ), XML_TRUE ) ) + { bSubTable = sal_True; + } + else if ( (XML_NAMESPACE_XML == nPrefix2) && + IsXMLToken( aLocalName, XML_ID ) ) + { + sXmlId = xAttrList->getValueByIndex( i ); + } +//FIXME: RDFa } } @@ -606,7 +638,7 @@ SvXMLImportContext *SwXMLTableCellContext_Impl::CreateChildContext( { SwXMLTableContext *pTblContext = new SwXMLTableContext( GetSwImport(), nPrefix, rLocalName, - xAttrList, GetTable() ); + xAttrList, GetTable(), sXmlId ); pContext = pTblContext; if( GetTable()->IsValid() ) InsertContent( pTblContext ); @@ -638,7 +670,7 @@ void SwXMLTableCellContext_Impl::EndElement() GetImport().GetTextImport()->DeleteParagraph(); if( nColRepeat > 1 && nColSpan == 1 ) { - // The original text is is invalid after deleting the last + // The original text is invalid after deleting the last // paragraph Reference < XTextCursor > xSrcTxtCursor = GetImport().GetTextImport()->GetText()->createTextCursor(); @@ -738,6 +770,12 @@ SwXMLTableColContext_Impl::SwXMLTableColContext_Impl( else if( IsXMLToken( aLocalName, XML_DEFAULT_CELL_STYLE_NAME ) ) aDfltCellStyleName = rValue; } + else if ( (XML_NAMESPACE_XML == nPrefix) && + IsXMLToken( aLocalName, XML_ID ) ) + { + (void) rValue; +//FIXME where to put this??? columns do not actually exist in writer... + } } sal_Int32 nWidth = MINLAY; @@ -870,6 +908,7 @@ SwXMLTableRowContext_Impl::SwXMLTableRowContext_Impl( SwXMLImport& rImport, nRowRepeat( 1 ) { OUString aStyleName, aDfltCellStyleName; + OUString sXmlId; sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; for( sal_Int16 i=0; i < nAttrCount; i++ ) @@ -898,9 +937,15 @@ SwXMLTableRowContext_Impl::SwXMLTableRowContext_Impl( SwXMLImport& rImport, aDfltCellStyleName = rValue; } } + else if ( (XML_NAMESPACE_XML == nPrefix) && + IsXMLToken( aLocalName, XML_ID ) ) + { + sXmlId = rValue; + } } if( GetTable()->IsValid() ) - GetTable()->InsertRow( aStyleName, aDfltCellStyleName, bInHead ); + GetTable()->InsertRow( aStyleName, aDfltCellStyleName, bInHead, + sXmlId ); } void SwXMLTableRowContext_Impl::EndElement() @@ -1269,6 +1314,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport, nWidth( 0UL ) { OUString aName; + OUString sXmlId; // this method will modify the document directly -> lock SolarMutex vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1292,6 +1338,11 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport, else if( IsXMLToken( aLocalName, XML_DEFAULT_CELL_STYLE_NAME ) ) aDfltCellStyleName = rValue; } + else if ( (XML_NAMESPACE_XML == nPrefix) && + IsXMLToken( aLocalName, XML_ID ) ) + { + sXmlId = rValue; + } } SwDoc *pDoc = SwImport::GetDocFromXMLImport( GetSwImport() ); @@ -1343,6 +1394,10 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport, if( xTable.is() ) { +//FIXME + // xml:id for RDF metadata + GetImport().SetXmlId(xTable, sXmlId); + Reference<XUnoTunnel> xTableTunnel( xTable, UNO_QUERY); if( xTableTunnel.is() ) { @@ -1381,8 +1436,10 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const Reference< xml::sax::XAttributeList > &, - SwXMLTableContext *pTable ) : + SwXMLTableContext *pTable, + OUString const & i_rXmlId ) : XMLTextTableContext( rImport, nPrfx, rLName ), + mXmlId( i_rXmlId ), pColumnDefaultCellStyleNames( 0 ), pRows( new SwXMLTableRows_Impl ), pTableNode( pTable->pTableNode ), @@ -1529,6 +1586,7 @@ OUString SwXMLTableContext::GetColumnDefaultCellStyleName( sal_uInt32 nCol ) con void SwXMLTableContext::InsertCell( const OUString& rStyleName, sal_uInt32 nRowSpan, sal_uInt32 nColSpan, const SwStartNode *pStartNode, + const OUString & i_rXmlId, SwXMLTableContext *pTable, sal_Bool bProtect, const OUString* pFormula, @@ -1629,7 +1687,8 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName, const bool bCovered = i != nColSpan || j != nRowSpan; GetCell( nRowsReq-j, nColsReq-i ) ->Set( sStyleName, j, i, pStartNode, - pTable, bProtect, pFormula, bHasValue, bCovered, fValue, bTextValue); + pTable, bProtect, pFormula, bHasValue, bCovered, fValue, + bTextValue, i_rXmlId ); } } @@ -1641,7 +1700,8 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName, void SwXMLTableContext::InsertRow( const OUString& rStyleName, const OUString& rDfltCellStyleName, - sal_Bool bInHead ) + sal_Bool bInHead, + const OUString & i_rXmlId ) { ASSERT( nCurRow < USHRT_MAX, "SwXMLTableContext::InsertRow: no space left" ); @@ -1656,13 +1716,14 @@ void SwXMLTableContext::InsertRow( const OUString& rStyleName, { // The current row has already been inserted because of a row span // of a previous row. - (*pRows)[(sal_uInt16)nCurRow]->Set( rStyleName, rDfltCellStyleName ); + (*pRows)[(sal_uInt16)nCurRow]->Set( + rStyleName, rDfltCellStyleName, i_rXmlId ); } else { // add a new row pRows->Insert( new SwXMLTableRow_Impl( rStyleName, GetColumnCount(), - &rDfltCellStyleName ), + &rDfltCellStyleName, i_rXmlId ), pRows->Count() ); } @@ -1692,7 +1753,9 @@ void SwXMLTableContext::InsertRepRows( sal_uInt32 nCount ) GetCell( nCurRow-1, nCurCol ); InsertCell( pSrcCell->GetStyleName(), 1U, pSrcCell->GetColSpan(), - InsertTableSection(), 0, pSrcCell->IsProtected(), + InsertTableSection(), + OUString(), + 0, pSrcCell->IsProtected(), &pSrcCell->GetFormula(), pSrcCell->HasValue(), pSrcCell->GetValue(), pSrcCell->HasTextValue() ); @@ -1892,6 +1955,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox( SwTableLine *pUpper, sal_uInt32 nBottomRow, sal_uInt32 nRightCol ) { +//FIXME: here would be a great place to handle XmlId for cell SwTableBox *pBox = new SwTableBox( pBoxFmt, 0, pUpper ); sal_uInt32 nColSpan = nRightCol - nLeftCol; @@ -1990,6 +2054,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox( sal_uInt32 /*nTopRow*/, sal_uInt32 nLeftCol, sal_uInt32 /*nBottomRow*/, sal_uInt32 nRightCol ) { +//FIXME: here would be a great place to handle XmlId for cell SwTableBox *pBox; sal_uInt32 nColSpan = nRightCol - nLeftCol; sal_Int32 nColWidth = GetColumnWidth( nLeftCol, nColSpan ); @@ -2151,6 +2216,7 @@ SwTableLine *SwXMLTableContext::MakeTableLine( SwTableBox *pUpper, sal_uInt32 nBottomRow, sal_uInt32 nRightCol ) { +//FIXME: here would be a great place to handle XmlId for row SwTableLine *pLine; if( !pUpper && 0UL==nTopRow ) { @@ -2618,6 +2684,17 @@ void SwXMLTableContext::MakeTable() // those don't need to be locked separately. vos::OGuard aGuard(Application::GetSolarMutex()); + // #i97274# handle invalid tables + if (!pRows || !pRows->Count() || !GetColumnCount()) + { + ASSERT(false, "invalid table: no cells; deleting..."); + pTableNode->GetDoc()->DeleteSection( pTableNode ); + pTableNode = 0; + pBox1 = 0; + pSttNd1 = 0; + return; + } + SwXMLImport& rSwImport = GetSwImport(); SwFrmFmt *pFrmFmt = pTableNode->GetTable().GetFrmFmt(); @@ -2742,7 +2819,7 @@ void SwXMLTableContext::MakeTable() if( bSetHoriOrient ) pFrmFmt->SetFmtAttr( SwFmtHoriOrient( 0, eHoriOrient ) ); - // This must be bahind the call to _MakeTable, because nWidth might be + // This must be after the call to _MakeTable, because nWidth might be // changed there. pFrmFmt->LockModify(); SwFmtFrmSize aSize( ATT_VAR_SIZE, nWidth ); @@ -2773,6 +2850,7 @@ void SwXMLTableContext::MakeTable() pTableNode->SetNewTable(pDDETable, FALSE); } + // ??? this is always false: root frame is only created in ViewShell::Init if( pTableNode->GetDoc()->GetRootFrm() ) { pTableNode->DelFrms(); @@ -2783,6 +2861,7 @@ void SwXMLTableContext::MakeTable() void SwXMLTableContext::MakeTable( SwTableBox *pBox, sal_Int32 nW ) { +//FIXME: here would be a great place to handle XmlId for subtable pLineFmt = GetParentTable()->pLineFmt; pBoxFmt = GetParentTable()->pBoxFmt; nWidth = nW; diff --git a/sw/source/filter/xml/xmltbli.hxx b/sw/source/filter/xml/xmltbli.hxx index 6cbef964a324..b9f903ba14a9 100644 --- a/sw/source/filter/xml/xmltbli.hxx +++ b/sw/source/filter/xml/xmltbli.hxx @@ -31,9 +31,7 @@ #ifndef _XMLTBLI_HXX #define _XMLTBLI_HXX -#ifndef _XMLOFF_XMLTEXTTABLECONTEXT_HXX #include <xmloff/XMLTextTableContext.hxx> -#endif // STL include #include <hash_map> @@ -69,6 +67,8 @@ class SwXMLTableContext : public XMLTextTableContext { ::rtl::OUString aStyleName; ::rtl::OUString aDfltCellStyleName; + /// NB: this contains the xml:id only if this table is a subtable! + ::rtl::OUString mXmlId; SvUShorts aColumnWidths; SvBools aColumnRelWidths; @@ -154,7 +154,8 @@ public: const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList, - SwXMLTableContext *pTable ); + SwXMLTableContext *pTable, + const ::rtl::OUString& i_rXmlId ); virtual ~SwXMLTableContext(); @@ -180,6 +181,7 @@ public: void InsertCell( const ::rtl::OUString& rStyleName, sal_uInt32 nRowSpan=1U, sal_uInt32 nColSpan=1U, const SwStartNode *pStNd=0, + const ::rtl::OUString & i_rXmlId = ::rtl::OUString(), SwXMLTableContext *pTable=0, sal_Bool bIsProtected = sal_False, const ::rtl::OUString *pFormula=0, @@ -188,7 +190,8 @@ public: sal_Bool bTextValue = sal_False ); void InsertRow( const ::rtl::OUString& rStyleName, const ::rtl::OUString& rDfltCellStyleName, - sal_Bool bInHead ); + sal_Bool bInHead, + const ::rtl::OUString & i_rXmlId = ::rtl::OUString() ); void FinishRow(); void InsertRepRows( sal_uInt32 nCount ); SwXMLTableCell_Impl *GetCell( sal_uInt32 nRow, sal_uInt32 nCol ) const; diff --git a/sw/source/ui/app/apphdl.cxx b/sw/source/ui/app/apphdl.cxx index 8f9a6b8eb71d..7fe0d349e8a7 100644 --- a/sw/source/ui/app/apphdl.cxx +++ b/sw/source/ui/app/apphdl.cxx @@ -57,12 +57,8 @@ #include <svtools/stritem.hxx> #include <svtools/ctloptions.hxx> #include <svtools/useroptions.hxx> -#ifndef _VCL_MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif -#ifndef _VCL_WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <svx/insctrl.hxx> #include <svx/selctrl.hxx> #include <com/sun/star/document/UpdateDocMode.hpp> @@ -73,46 +69,32 @@ #include <sfx2/objface.hxx> #include <sfx2/app.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <pview.hxx> -#ifndef _SRCVIEW_HXX #include <srcview.hxx> -#endif #include <wrtsh.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #ifndef _CMDID_H #include <cmdid.h> // Funktion-Ids #endif #include <initui.hxx> #include <uitool.hxx> #include <swmodule.hxx> -#ifndef _WDOCSH_HXX #include <wdocsh.hxx> -#endif -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <usrpref.hxx> #include <gloslst.hxx> // SwGlossaryList #include <glosdoc.hxx> // SwGlossaryList #include <doc.hxx> #include <cfgitems.hxx> #include <prtopt.hxx> -#ifndef _MODCFG_HXX #include <modcfg.hxx> -#endif #include <globals.h> // globale Konstanten z.B. #ifndef _APP_HRC #include <app.hrc> #endif #include <fontcfg.hxx> -#ifndef _BARCFG_HXX #include <barcfg.hxx> -#endif #include <uinums.hxx> #include <dbconfig.hxx> #include <mmconfigitem.hxx> @@ -155,7 +137,7 @@ using namespace ::com::sun::star; #define PrintSettings #define _ExecAddress ExecOther #define _StateAddress StateOther -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include <svx/svxslots.hxx> #include "swslots.hxx" #include <cfgid.h> diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx index 837b3e72dc44..d7e2450dbebf 100644 --- a/sw/source/ui/app/docsh.cxx +++ b/sw/source/ui/app/docsh.cxx @@ -30,17 +30,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> #include <rtl/logfile.hxx> -#ifndef _MSGBOX_HXX #include <vcl/msgbox.hxx> -#endif -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <vcl/jobset.hxx> #include <tools/urlobj.hxx> #include <svtools/whiter.hxx> @@ -53,9 +48,7 @@ #include <sfx2/app.hxx> #include <sfx2/request.hxx> #include <svtools/misccfg.hxx> -#ifndef _PASSWD_HXX #include <sfx2/passwd.hxx> -#endif #include <sfx2/bindings.hxx> #include <sfx2/docfile.hxx> #include <sfx2/evntconf.hxx> @@ -70,9 +63,7 @@ #include <sot/clsids.hxx> #include <basic/basmgr.hxx> #include <basic/sbmod.hxx> -//#ifndef _SB_SBJSMOD_HXX //autogen //#include <basic/sbjsmod.hxx> -//#endif #include <swevent.hxx> #include <fmtpdsc.hxx> #include <fmtfsize.hxx> @@ -81,41 +72,27 @@ #include <swwait.hxx> #include <swprtopt.hxx> #include <frmatr.hxx> -#ifndef _VIEW_HXX #include <view.hxx> // fuer die aktuelle Sicht -#endif #include <edtwin.hxx> #include <PostItMgr.hxx> #include <postit.hxx> #include <wrtsh.hxx> // Verbindung zur Core -#ifndef _DOCSH_HXX #include <docsh.hxx> // Dokumenterzeugung -#endif -#ifndef _BASESH_HXX #include <basesh.hxx> -#endif #include <viewopt.hxx> -#ifndef _WDOCSH_HXX #include <wdocsh.hxx> -#endif #include <swmodule.hxx> -#ifndef _GLOBDOC_HXX #include <globdoc.hxx> -#endif #include <usrpref.hxx> #include <shellio.hxx> // I/O #include <docstyle.hxx> #include <doc.hxx> #include <docstat.hxx> #include <pagedesc.hxx> -#ifndef _PVIEW_HXX #include <pview.hxx> -#endif #include <mdiexp.hxx> #include <swbaslnk.hxx> -#ifndef _SRCVIEW_HXX #include <srcview.hxx> -#endif #include <ndindex.hxx> #include <ndole.hxx> #include <swcli.hxx> @@ -127,18 +104,10 @@ #include <docary.hxx> // <-- #include <swerror.h> // Fehlermeldungen -#ifndef _HELPID_H #include <helpid.h> -#endif -#ifndef _CMDID_H -#include <cmdid.h> // -#endif -#ifndef _GLOBALS_HRC +#include <cmdid.h> #include <globals.hrc> -#endif -#ifndef _APP_HRC #include <app.hrc> -#endif #include "warnpassword.hxx" #include <cfgid.h> @@ -150,12 +119,8 @@ #include <comphelper/storagehelper.hxx> #define SwDocShell -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif #include <com/sun/star/document/UpdateDocMode.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> @@ -163,6 +128,9 @@ #include <unomid.h> +#include <sfx2/Metadatable.hxx> + + using rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -1416,4 +1384,8 @@ BOOL SwTmpPersist::SaveCompleted( SvStorage * pStor ) return FALSE; } */ +const ::sfx2::IXmlIdRegistry* SwDocShell::GetXmlIdRegistry() const +{ + return pDoc ? &pDoc->GetXmlIdRegistry() : 0; +} diff --git a/sw/source/ui/fldui/flddinf.hxx b/sw/source/ui/fldui/flddinf.hxx index 7f1b16c7abc1..2b72b1aec33a 100644 --- a/sw/source/ui/fldui/flddinf.hxx +++ b/sw/source/ui/fldui/flddinf.hxx @@ -45,7 +45,7 @@ /*-------------------------------------------------------------------- Beschreibung: --------------------------------------------------------------------*/ -class SfxDocumentInfoItem; + class SwFldDokInfPage : public SwFldPage { FixedText aTypeFT; diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index 24c025fb55d8..b288d51cf520 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -265,7 +265,7 @@ void SwFldRefPage::Reset(const SfxItemSet& ) } // Endnoten: - if( pSh->HasFtns(TRUE) ) + if ( pSh->HasFtns(true) ) { nPos = aTypeLB.InsertEntry(sEndnoteTxt); aTypeLB.SetEntryData(nPos, (void*)REFFLDFLAG_ENDNOTE); @@ -576,7 +576,7 @@ void SwFldRefPage::UpdateSubType() { aSelectionLB.SetStyle(aSelectionLB.GetStyle() & ~WB_SORT); SwSeqFldList aArr; - USHORT nCnt = pSh->GetSeqFtnList( aArr, TRUE ); + USHORT nCnt = pSh->GetSeqFtnList( aArr, true ); for( USHORT n = 0; n < nCnt; ++n ) { @@ -936,7 +936,7 @@ BOOL SwFldRefPage::FillItemSet(SfxItemSet& ) nSubType = REF_ENDNOTE; aName.Erase(); - if (pSh->GetSeqFtnList(aArr, TRUE) && aArr.SeekEntry(aElem, &nPos)) + if (pSh->GetSeqFtnList(aArr, true) && aArr.SeekEntry(aElem, &nPos)) { aVal = String::CreateFromInt32( aArr[nPos]->nSeqNo ); diff --git a/sw/source/ui/inc/itemdef.hxx b/sw/source/ui/inc/itemdef.hxx deleted file mode 100644 index c73a429e0fee..000000000000 --- a/sw/source/ui/inc/itemdef.hxx +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: itemdef.hxx,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef ITEMDEF_HXX -#define ITEMDEF_HXX - - -#include <sfx2/msg.hxx> - -SFX_DECL_TYPE(10); //SwElemItem -SFX_DECL_TYPE(13); //SwAddPrinterItem -SFX_DECL_TYPE(16); //SwDocDisplayItem - -#endif diff --git a/sw/source/ui/misc/glshell.cxx b/sw/source/ui/misc/glshell.cxx index 4ad5311307c9..a79e67eec31c 100644 --- a/sw/source/ui/misc/glshell.cxx +++ b/sw/source/ui/misc/glshell.cxx @@ -49,12 +49,8 @@ #include <sfx2/viewfrm.hxx> #include <uitool.hxx> #include <wrtsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif -#ifndef _GLSHELL_HXX #include <glshell.hxx> -#endif #include <doc.hxx> #include <glosdoc.hxx> #include <shellio.hxx> @@ -72,12 +68,8 @@ #define SwWebGlosDocShell #define SwGlosDocShell -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif using namespace ::com::sun::star; diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx index b4a4491c220d..054220be6707 100755 --- a/sw/source/ui/shells/annotsh.cxx +++ b/sw/source/ui/shells/annotsh.cxx @@ -138,7 +138,7 @@ using namespace ::com::sun::star::i18n; #define SwAnnotationShell -#include <itemdef.hxx> +#include <sfx2/msg.hxx> #include <swslots.hxx> SFX_IMPL_INTERFACE(SwAnnotationShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT)) diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx index 66276be3e4ff..f2f760156d04 100644 --- a/sw/source/ui/shells/basesh.cxx +++ b/sw/source/ui/shells/basesh.cxx @@ -41,33 +41,22 @@ #include <svx/linkmgr.hxx> #include <svx/htmlmode.hxx> #include <svx/imapdlg.hxx> -#ifndef _SFX_DISPATCH_HXX //autogen #include <sfx2/dispatch.hxx> -#endif #include <sfx2/docfile.hxx> -#ifndef _SFX_VIEWFRM_HXX //autogen #include <sfx2/viewfrm.hxx> -#endif #include <sfx2/request.hxx> #include <svtools/whiter.hxx> #include <svtools/visitem.hxx> #include <sfx2/objitem.hxx> -#ifndef _SFX_DISPATCH_HXX //autogen -#include <sfx2/dispatch.hxx> -#endif #include <svtools/filter.hxx> #include <svx/gallery.hxx> #include <svx/langitem.hxx> #include <svx/clipfmtitem.hxx> #include <svx/contdlg.hxx> -#ifndef _GRAPH_HXX //autogen #include <vcl/graph.hxx> -#endif #include <svx/impgrf.hxx> #include <svtools/slstitm.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svtools/ptitem.hxx> #include <svtools/itemiter.hxx> #include <svtools/stritem.hxx> @@ -86,20 +75,14 @@ #include <fmturl.hxx> #include <fmthdft.hxx> #include <fmtclds.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <wrtsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <swmodule.hxx> #include <swundo.hxx> #include <fldbas.hxx> #include <uitool.hxx> -#ifndef _BASESH_HXX #include <basesh.hxx> -#endif #include <viewopt.hxx> #include <fontcfg.hxx> #include <docstat.hxx> @@ -171,7 +154,7 @@ static BYTE nFooterPos; #define SwBaseShell #define Shadow -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" #define SWCONTOURDLG(rView) ( (SvxContourDlg*) ( rView.GetViewFrame()->GetChildWindow( \ @@ -2082,14 +2065,22 @@ void SwBaseShell::ExecTxtCtrl( SfxRequest& rReq ) if( pArgs ) { - SwTxtFmtColl* pColl; - if( (!(RES_CHRATR_BEGIN <= nWhich && nWhich < RES_CHRATR_END ) || - ( rSh.HasSelection() && rSh.IsSelFullPara() ) ) && - 0 != (pColl = rSh.GetCurTxtFmtColl()) && - pColl->IsAutoUpdateFmt() ) - rSh.AutoUpdatePara( pColl, *pArgs ); - else + bool bAuto = false; + if ( !isCHRATR(nWhich) || + ( rSh.HasSelection() && rSh.IsSelFullPara() ) ) + { + SwTxtFmtColl * pColl = rSh.GetCurTxtFmtColl(); + if ( pColl && pColl->IsAutoUpdateFmt() ) + { + rSh.AutoUpdatePara( pColl, *pArgs ); + bAuto = true; + } + } + + if (!bAuto) + { rSh.SetAttr( *pArgs ); + } } delete pSSetItem; } diff --git a/sw/source/ui/shells/beziersh.cxx b/sw/source/ui/shells/beziersh.cxx index b6bc159e7ecd..cc3493fe5120 100644 --- a/sw/source/ui/shells/beziersh.cxx +++ b/sw/source/ui/shells/beziersh.cxx @@ -52,7 +52,7 @@ #include "popup.hrc" #include "shells.hrc" #define SwBezierShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" #include <unomid.h> diff --git a/sw/source/ui/shells/drawsh.cxx b/sw/source/ui/shells/drawsh.cxx index ed7d60e84e6f..4da015e2d586 100644 --- a/sw/source/ui/shells/drawsh.cxx +++ b/sw/source/ui/shells/drawsh.cxx @@ -69,7 +69,7 @@ #include "drawsh.hxx" #define SwDrawShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" #include "swabstdlg.hxx" //CHINA001 #include "misc.hrc" diff --git a/sw/source/ui/shells/drformsh.cxx b/sw/source/ui/shells/drformsh.cxx index 254d01ccb960..97cac7006b98 100644 --- a/sw/source/ui/shells/drformsh.cxx +++ b/sw/source/ui/shells/drformsh.cxx @@ -60,14 +60,12 @@ #include "drwbassh.hxx" #include "drformsh.hxx" #include <svtools/urihelper.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <sfx2/docfile.hxx> #include <docsh.hxx> #define SwDrawFormShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" #include <unomid.h> diff --git a/sw/source/ui/shells/drwbassh.cxx b/sw/source/ui/shells/drwbassh.cxx index 725d5239e6fe..339c332c9135 100644 --- a/sw/source/ui/shells/drwbassh.cxx +++ b/sw/source/ui/shells/drwbassh.cxx @@ -41,9 +41,7 @@ #include <sfx2/bindings.hxx> #include <svtools/aeitem.hxx> #include <svx/svdview.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svx/srchitem.hxx> #include <svtools/whiter.hxx> #include <svx/swframevalidation.hxx> @@ -56,20 +54,14 @@ #endif #include <swmodule.hxx> #include <wrtsh.hxx> -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <edtwin.hxx> #include <viewopt.hxx> #include <dcontact.hxx> #include <frmfmt.hxx> #include <wrap.hxx> -#ifndef _DRAWBASE_HXX #include <drawbase.hxx> -#endif -#ifndef _DRWBASSH_HXX #include <drwbassh.hxx> -#endif #include <swdtflvr.hxx> #include <svx/svdogrp.hxx> #include <svx/svdpage.hxx> @@ -77,12 +69,8 @@ #include <shells.hrc> #define SwDrawBaseShell -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif #include <svx/svxdlg.hxx> #include <svx/dialogs.hrc> #include "swabstdlg.hxx" diff --git a/sw/source/ui/shells/drwtxtsh.cxx b/sw/source/ui/shells/drwtxtsh.cxx index a0f38300fba2..99a2bf71bca7 100644 --- a/sw/source/ui/shells/drwtxtsh.cxx +++ b/sw/source/ui/shells/drwtxtsh.cxx @@ -59,15 +59,11 @@ #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <swtypes.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <wrtsh.hxx> #include <viewopt.hxx> #include <initui.hxx> // fuer SpellPointer -#ifndef _DRWTXTSH_HXX #include <drwtxtsh.hxx> -#endif #include <swundo.hxx> #include <breakit.hxx> @@ -85,19 +81,13 @@ #endif #define SwDrawTextShell -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif #ifndef _POPUP_HRC #include <popup.hrc> #endif #include <uitool.hxx> -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <swmodule.hxx> #include <svx/xtable.hxx> diff --git a/sw/source/ui/shells/frmsh.cxx b/sw/source/ui/shells/frmsh.cxx index 4df31175e1aa..3f61bab9a20e 100644 --- a/sw/source/ui/shells/frmsh.cxx +++ b/sw/source/ui/shells/frmsh.cxx @@ -57,9 +57,7 @@ #include <fmtcnct.hxx> #include <swmodule.hxx> #include <wrtsh.hxx> -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <frmatr.hxx> #include <uitool.hxx> #include <frmfmt.hxx> @@ -104,7 +102,7 @@ const SwFrmFmt* lcl_GetFrmFmtByName(SwWrtShell& rSh, const String& rName) } #define SwFrameShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" SFX_IMPL_INTERFACE(SwFrameShell, SwBaseShell, SW_RES(STR_SHELLNAME_FRAME)) diff --git a/sw/source/ui/shells/grfsh.cxx b/sw/source/ui/shells/grfsh.cxx index 026e22a228c4..1ecf506d19c2 100644 --- a/sw/source/ui/shells/grfsh.cxx +++ b/sw/source/ui/shells/grfsh.cxx @@ -39,9 +39,7 @@ #endif #include <hintids.hxx> #include <tools/urlobj.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svtools/stritem.hxx> #include <svtools/whiter.hxx> #include <svtools/urihelper.hxx> @@ -64,21 +62,15 @@ #include <svx/grfflt.hxx> #include <svx/tbxcolor.hxx> #include <fmturl.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <wrtsh.hxx> #include <viewopt.hxx> #include <swmodule.hxx> #include <frmatr.hxx> #include <swundo.hxx> #include <uitool.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif -#ifndef _GRFSH_HXX #include <grfsh.hxx> -#endif #include <frmmgr.hxx> #include <frmdlg.hxx> #include <frmfmt.hxx> @@ -90,7 +82,7 @@ #include <popup.hrc> #define SwGrfShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" #include "swabstdlg.hxx" diff --git a/sw/source/ui/shells/listsh.cxx b/sw/source/ui/shells/listsh.cxx index c1c8435bd12f..34f349befbc9 100644 --- a/sw/source/ui/shells/listsh.cxx +++ b/sw/source/ui/shells/listsh.cxx @@ -65,7 +65,7 @@ #include "edtwin.hxx" #define SwListShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" #include <IDocumentOutlineNodes.hxx> diff --git a/sw/source/ui/shells/mediash.cxx b/sw/source/ui/shells/mediash.cxx index 933d7254bb8a..ae1ed883cb8b 100644 --- a/sw/source/ui/shells/mediash.cxx +++ b/sw/source/ui/shells/mediash.cxx @@ -39,9 +39,7 @@ #endif #include <hintids.hxx> #include <tools/urlobj.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svtools/stritem.hxx> #include <svtools/whiter.hxx> #include <svtools/urihelper.hxx> @@ -60,21 +58,15 @@ #include <svx/brshitem.hxx> #include <svx/grfflt.hxx> #include <fmturl.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <wrtsh.hxx> #include <viewopt.hxx> #include <swmodule.hxx> #include <frmatr.hxx> #include <swundo.hxx> #include <uitool.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif -#ifndef _MEDIASH_HXX #include <mediash.hxx> -#endif #include <frmmgr.hxx> #include <frmdlg.hxx> #include <frmfmt.hxx> @@ -95,7 +87,7 @@ #include <avmedia/mediaitem.hxx> #define SwMediaShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" #include "swabstdlg.hxx" diff --git a/sw/source/ui/shells/olesh.cxx b/sw/source/ui/shells/olesh.cxx index 6d6f1985e56b..2bf523d27e3b 100644 --- a/sw/source/ui/shells/olesh.cxx +++ b/sw/source/ui/shells/olesh.cxx @@ -37,9 +37,7 @@ #include <sfx2/objface.hxx> #include <sfx2/objitem.hxx> #include <wrtsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #ifndef _HELPID_H #include <helpid.h> #endif @@ -63,12 +61,8 @@ #define SwOleShell -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif SFX_IMPL_INTERFACE(SwOleShell, SwFrameShell, SW_RES(STR_SHELLNAME_OBJECT)) diff --git a/sw/source/ui/shells/slotadd.cxx b/sw/source/ui/shells/slotadd.cxx index 804b6127de4f..333128a18db9 100644 --- a/sw/source/ui/shells/slotadd.cxx +++ b/sw/source/ui/shells/slotadd.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: slotadd.cxx,v $ - * $Revision: 1.30 $ + * $Revision: 1.30.124.1 $ * * This file is part of OpenOffice.org. * @@ -147,7 +147,7 @@ #define avmedia_MediaItem ::avmedia::MediaItem #define SFX_TYPEMAP -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" diff --git a/sw/source/ui/shells/tabsh.cxx b/sw/source/ui/shells/tabsh.cxx index 3c1d84666c7a..2beb89f0458b 100644 --- a/sw/source/ui/shells/tabsh.cxx +++ b/sw/source/ui/shells/tabsh.cxx @@ -57,9 +57,7 @@ #include <svx/svxdlg.hxx> #include <svtools/zformat.hxx> #include <sfx2/bindings.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <sfx2/request.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/objface.hxx> @@ -72,28 +70,20 @@ #include <fmtfsize.hxx> #include <swmodule.hxx> #include <wrtsh.hxx> -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <frmatr.hxx> #include <uitool.hxx> -#ifndef _INPUTWIN_HXX #include <inputwin.hxx> -#endif #include <uiitems.hxx> #include <usrpref.hxx> -#ifndef _TABSH_HXX #include <tabsh.hxx> -#endif #include "swtablerep.hxx" #include <tablemgr.hxx> #include <cellatr.hxx> #include <frmfmt.hxx> #include <swundo.hxx> #include <swtable.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <tblsel.hxx> #include <dialog.hrc> @@ -130,12 +120,8 @@ #include <unoobj.hxx> #define SwTableShell -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif #include "swabstdlg.hxx" #include <table.hrc> diff --git a/sw/source/ui/shells/textsh.cxx b/sw/source/ui/shells/textsh.cxx index f0874a954b97..742e93b646c2 100644 --- a/sw/source/ui/shells/textsh.cxx +++ b/sw/source/ui/shells/textsh.cxx @@ -46,18 +46,14 @@ #include <svtools/ptitem.hxx> #include <svtools/stritem.hxx> #include <svtools/moduleoptions.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <sfx2/fcontnr.hxx> #include <svx/hlnkitem.hxx> #include <svx/srchitem.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/docfile.hxx> #include <svtools/urihelper.hxx> -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include <basic/sbxvar.hxx> -#endif #include <svtools/whiter.hxx> #include <sfx2/request.hxx> #include <svx/opaqitem.hxx> @@ -71,9 +67,7 @@ #include <svx/htmlmode.hxx> #include <svx/pfiledlg.hxx> #include <svx/htmlcfg.hxx> -#ifndef _COM_SUN_STAR_I18N_TRANSLITERATIONMODULES_HDL_ #include <com/sun/star/i18n/TransliterationModules.hdl> -#endif #include <sot/clsids.hxx> #include <svx/acorrcfg.hxx> @@ -84,12 +78,8 @@ #include <fmtfsize.hxx> #include <swmodule.hxx> #include <wrtsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <doc.hxx> #include <uitool.hxx> #ifndef _CMDID_H @@ -99,9 +89,7 @@ #include <globals.hrc> #endif #include <frmmgr.hxx> -#ifndef _TEXTSH_HXX #include <textsh.hxx> -#endif #include <frmfmt.hxx> #include <tablemgr.hxx> #include <swundo.hxx> // fuer Undo-IDs @@ -137,12 +125,8 @@ #define HyphenZone #define TextFont #define DropCap -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif #include <SwRewriter.hxx> #include <undobj.hxx> #ifndef _COMCORE_HRC diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index c3ee9a18ccf0..8fe6b9511f8f 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -39,9 +39,7 @@ #include <vcl/fixed.hxx> #include <vcl/help.hxx> #include <vcl/cmdevt.hxx> -#ifndef _SV_BUTTON_HXX //autogen #include <vcl/button.hxx> -#endif #include <svtools/printdlg.hxx> #include <svtools/whiter.hxx> #include <svtools/stritem.hxx> @@ -71,20 +69,12 @@ #include <swmodule.hxx> #include <modcfg.hxx> #include <wrtsh.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <viewopt.hxx> #include <doc.hxx> -#ifndef _PVIEW_HXX #include <pview.hxx> -#endif -#ifndef _VIEW_HXX #include <view.hxx> -#endif -#ifndef _TEXTSH_HXX #include <textsh.hxx> -#endif #include <scroll.hxx> #include <swprtopt.hxx> #include <docstat.hxx> @@ -109,12 +99,8 @@ #endif #define SwPagePreView -#ifndef _ITEMDEF_HXX -#include <itemdef.hxx> -#endif -#ifndef _SWSLOTS_HXX +#include <sfx2/msg.hxx> #include <swslots.hxx> -#endif // OD 12.12.2002 #103492# #include <pagepreviewlayout.hxx> diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx index 7898e4db1cb2..34cfebe663a1 100644 --- a/sw/source/ui/uiview/srcview.cxx +++ b/sw/source/ui/uiview/srcview.cxx @@ -76,7 +76,7 @@ #include <srcview.hxx> #include <viewfunc.hxx> #include <doc.hxx> -#include <itemdef.hxx> +#include <sfx2/msg.hxx> #include <shellio.hxx> #include <cmdid.h> // FN_ ... diff --git a/sw/source/ui/uiview/view0.cxx b/sw/source/ui/uiview/view0.cxx index 2e9a3bc783e7..38f885657450 100644 --- a/sw/source/ui/uiview/view0.cxx +++ b/sw/source/ui/uiview/view0.cxx @@ -49,9 +49,7 @@ #include <svx/srchdlg.hxx> #include <sfx2/templdlg.hxx> #include <uivwimp.hxx> -#ifndef _AVMEDIA_MEDIAPPLAYER_HXX #include <avmedia/mediaplayer.hxx> -#endif #include <swmodule.hxx> #include <sfx2/objface.hxx> @@ -92,7 +90,7 @@ #define WebListInText #define WebListInTable #define TextPage -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include <svx/svxslots.hxx> #include "swslots.hxx" #include <PostItMgr.hxx> diff --git a/sw/source/ui/uno/unomod.cxx b/sw/source/ui/uno/unomod.cxx index 57a2a8ec6c1f..19d0faa0bfce 100644 --- a/sw/source/ui/uno/unomod.cxx +++ b/sw/source/ui/uno/unomod.cxx @@ -50,13 +50,13 @@ #include <com/sun/star/text/NotePrintMode.hpp> #include <doc.hxx> #include <comphelper/TypeGeneration.hxx> -#ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif +#include <com/sun/star/view/DocumentZoomType.hpp> #include <comphelper/ChainablePropertySetInfo.hxx> #include <edtwin.hxx> #include <rtl/ustrbuf.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; @@ -726,23 +726,28 @@ void SwXViewSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, c if(!(rValue >>= nZoom)) throw IllegalArgumentException(); SvxZoomType eZoom = (SvxZoomType)USHRT_MAX; - switch(nZoom) + switch (nZoom) { - case /*DocumentZoomType_OPTIMAL */0: + case view::DocumentZoomType::OPTIMAL: eZoom = SVX_ZOOM_OPTIMAL; break; - case /*DocumentZoomType_PAGE_WIDTH */ 1: + case view::DocumentZoomType::PAGE_WIDTH: eZoom = SVX_ZOOM_PAGEWIDTH; break; - case /*DocumentZoomType_ENTIRE_PAGE */ 2: + case view::DocumentZoomType::ENTIRE_PAGE: eZoom = SVX_ZOOM_WHOLEPAGE; break; - case /*DocumentZoomType_BY_VALUE */ 3: + case view::DocumentZoomType::BY_VALUE: eZoom = SVX_ZOOM_PERCENT; break; - case /*DocumentZoomType_PAGE_WIDTH_EXACT */ 4: + case view::DocumentZoomType::PAGE_WIDTH_EXACT: eZoom = SVX_ZOOM_PAGEWIDTH_NOBORDER; break; + default: + throw IllegalArgumentException( + ::rtl::OUString::createFromAscii( + "SwXViewSettings: invalid zoom type"), 0, 0); + break; } if(eZoom < USHRT_MAX) { @@ -915,23 +920,27 @@ void SwXViewSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, u case HANDLE_VIEWSET_ZOOM_TYPE: { bBool = FALSE; - sal_Int16 nRet; - switch(mpConstViewOption->GetZoomType()) + sal_Int16 nRet(0); + switch (mpConstViewOption->GetZoomType()) { case SVX_ZOOM_OPTIMAL: - nRet = /*DocumentZoomType_OPTIMAL*/ 0; + nRet = view::DocumentZoomType::OPTIMAL; break; case SVX_ZOOM_PAGEWIDTH: - nRet = /*DocumentZoomType_PAGE_WIDTH */1; + nRet = view::DocumentZoomType::PAGE_WIDTH; break; case SVX_ZOOM_WHOLEPAGE: - nRet = /*DocumentZoomType_ENTIRE_PAGE */ 2; + nRet = view::DocumentZoomType::ENTIRE_PAGE; break; case SVX_ZOOM_PERCENT: - nRet = /*DocumentZoomType_BY_VALUE */ 3; + nRet = view::DocumentZoomType::BY_VALUE; + break; + case SVX_ZOOM_PAGEWIDTH_NOBORDER: + nRet = view::DocumentZoomType::PAGE_WIDTH_EXACT; break; default: - ; + OSL_ENSURE(false, "SwXViewSettings: invalid zoom type"); + break; } rValue <<= nRet; } diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index eaba514a6e6a..6197bb489d61 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -38,9 +38,7 @@ #include <hintids.hxx> #include <docsh.hxx> #include <rubylist.hxx> -#ifndef _SWDOC_HXX //autogen #include <doc.hxx> -#endif #include <unotxvw.hxx> #include <unodispatch.hxx> #include <unomap.hxx> @@ -1442,9 +1440,9 @@ void SwXTextViewCursor::gotoRange( const ::sw::mark::IMark* const pBkmk = pRange->GetBookmark(); pSrcNode = &(pBkmk->GetMarkPos().nNode.GetNode()); } - else if (pPara && pPara->GetCrsr()) + else if (pPara && pPara->GetTxtNode()) { - pSrcNode = pPara->GetCrsr()->GetNode(); + pSrcNode = pPara->GetTxtNode(); } const SwStartNode* pTmp = pSrcNode ? pSrcNode->FindSttNodeByType(eSearchNodeType) : 0; diff --git a/sw/source/ui/web/wdocsh.cxx b/sw/source/ui/web/wdocsh.cxx index 9f7eff770172..dbfdf87dc94d 100644 --- a/sw/source/ui/web/wdocsh.cxx +++ b/sw/source/ui/web/wdocsh.cxx @@ -43,7 +43,7 @@ #include <sot/clsids.hxx> #include <sfx2/objface.hxx> -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "cfgid.h" #include "cmdid.h" #include "swtypes.hxx" diff --git a/sw/source/ui/web/wformsh.cxx b/sw/source/ui/web/wformsh.cxx index 8a629fbfeac2..ed9a84667c79 100644 --- a/sw/source/ui/web/wformsh.cxx +++ b/sw/source/ui/web/wformsh.cxx @@ -33,7 +33,7 @@ -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #ifndef _SVX_SVXIDS_HRC #include <svx/svxids.hrc> diff --git a/sw/source/ui/web/wfrmsh.cxx b/sw/source/ui/web/wfrmsh.cxx index e43a0e2d7850..ee2f61884000 100644 --- a/sw/source/ui/web/wfrmsh.cxx +++ b/sw/source/ui/web/wfrmsh.cxx @@ -50,7 +50,7 @@ // STATIC DATA ----------------------------------------------------------- #define SwWebFrameShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" diff --git a/sw/source/ui/web/wgrfsh.cxx b/sw/source/ui/web/wgrfsh.cxx index 5a935bb9e2e1..00a21da8e1b7 100644 --- a/sw/source/ui/web/wgrfsh.cxx +++ b/sw/source/ui/web/wgrfsh.cxx @@ -32,8 +32,7 @@ #include "precompiled_sw.hxx" - -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include <svx/srchitem.hxx> #include <sfx2/app.hxx> diff --git a/sw/source/ui/web/wlistsh.cxx b/sw/source/ui/web/wlistsh.cxx index a505928134b9..fc3f0635b54d 100644 --- a/sw/source/ui/web/wlistsh.cxx +++ b/sw/source/ui/web/wlistsh.cxx @@ -32,9 +32,7 @@ #include "precompiled_sw.hxx" -#include "itemdef.hxx" - - +#include <sfx2/msg.hxx> #include <sfx2/app.hxx> #include <sfx2/objface.hxx> #include <svx/srchitem.hxx> diff --git a/sw/source/ui/web/wolesh.cxx b/sw/source/ui/web/wolesh.cxx index 481c9405e439..131b6d72da10 100644 --- a/sw/source/ui/web/wolesh.cxx +++ b/sw/source/ui/web/wolesh.cxx @@ -32,8 +32,7 @@ #include "precompiled_sw.hxx" - -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include <sfx2/app.hxx> #include <sfx2/objface.hxx> #include <svx/srchitem.hxx> diff --git a/sw/source/ui/web/wtabsh.cxx b/sw/source/ui/web/wtabsh.cxx index 7af0bef34232..c47541214d58 100644 --- a/sw/source/ui/web/wtabsh.cxx +++ b/sw/source/ui/web/wtabsh.cxx @@ -51,7 +51,7 @@ #include "wtabsh.hxx" #define SwWebTableShell -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "svx/svxids.hrc" #include "swslots.hxx" diff --git a/sw/source/ui/web/wtextsh.cxx b/sw/source/ui/web/wtextsh.cxx index 2bbf79cfab94..abdcee987840 100644 --- a/sw/source/ui/web/wtextsh.cxx +++ b/sw/source/ui/web/wtextsh.cxx @@ -37,9 +37,7 @@ #include <sfx2/objface.hxx> #include <sfx2/app.hxx> #include <svx/srchitem.hxx> //*** -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include <basic/sbxvar.hxx> -#endif #ifndef _SVX_SVXIDS_HRC //autogen #include <svx/svxids.hrc> #endif @@ -63,7 +61,7 @@ #define HyphenZone #define TextFont #define DropCap -#include "itemdef.hxx" +#include <sfx2/msg.hxx> #include "swslots.hxx" diff --git a/sw/source/ui/web/wview.cxx b/sw/source/ui/web/wview.cxx index 6d1b0ca68c03..34ccd8f72378 100644 --- a/sw/source/ui/web/wview.cxx +++ b/sw/source/ui/web/wview.cxx @@ -32,7 +32,7 @@ #include "precompiled_sw.hxx" -#include <itemdef.hxx> +#include <sfx2/msg.hxx> #include <svx/srchitem.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/templdlg.hxx> diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx index 6624668fcd8a..42cfb1c3d64d 100644 --- a/sw/source/ui/wrtsh/wrtsh2.cxx +++ b/sw/source/ui/wrtsh/wrtsh2.cxx @@ -30,12 +30,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> // define ITEMIDs #include <svtools/macitem.hxx> #include <sfx2/frame.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svtools/urihelper.hxx> #include <svtools/eitem.hxx> #include <svtools/stritem.hxx> @@ -47,9 +46,7 @@ #include <frmatr.hxx> #include <swtypes.hxx> // SET_CURR_SHELL #include <wrtsh.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <fldbas.hxx> // Felder #include <expfld.hxx> #include <ddefld.hxx> @@ -61,9 +58,7 @@ #include <frmfmt.hxx> // fuer UpdateTable #include <swtable.hxx> // fuer UpdateTable #include <mdiexp.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <swevent.hxx> #include <poolfmt.hxx> #include <section.hxx> @@ -71,12 +66,8 @@ #include <navipi.hxx> #include <crsskip.hxx> #include <txtinet.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _WRTSH_HRC #include <wrtsh.hrc> -#endif #include "swabstdlg.hxx" #include "fldui.hrc" @@ -355,8 +346,8 @@ void SwWrtShell::ClickToINetAttr( const SwFmtINetFmt& rItem, USHORT nFilter ) const SwTxtINetFmt* pTxtAttr = rItem.GetTxtINetFmt(); if( pTxtAttr ) { - ((SwTxtINetFmt*)pTxtAttr)->SetVisited( sal_True ); - ((SwTxtINetFmt*)pTxtAttr)->SetValidVis( sal_True ); + const_cast<SwTxtINetFmt*>(pTxtAttr)->SetVisited( true ); + const_cast<SwTxtINetFmt*>(pTxtAttr)->SetVisitedValid( true ); } bIsInClickToEdit = FALSE; |