diff options
Diffstat (limited to 'sw/source/core')
-rwxr-xr-x[-rw-r--r--] | sw/source/core/crsr/swcrsr.cxx | 11 | ||||
-rw-r--r-- | sw/source/core/doc/doclay.cxx | 18 | ||||
-rwxr-xr-x[-rw-r--r--] | sw/source/core/doc/tblafmt.cxx | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | sw/source/core/edit/acorrect.cxx | 20 | ||||
-rw-r--r-- | sw/source/core/edit/autofmt.cxx | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | sw/source/core/inc/acorrect.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/text/txttab.cxx | 112 | ||||
-rw-r--r-- | sw/source/core/txtnode/atrref.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/txtnode/atrtox.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/txtnode/fmtatr2.cxx | 85 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 26 | ||||
-rw-r--r-- | sw/source/core/txtnode/thints.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/txtnode/txtatr2.cxx | 18 | ||||
-rwxr-xr-x[-rw-r--r--] | sw/source/core/txtnode/txtedt.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/unocore/unorefmk.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unotext.cxx | 55 |
16 files changed, 223 insertions, 155 deletions
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index b7106ade751c..63aae63019d3 100644..100755 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -973,7 +973,7 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas, { // Cursor als Kopie vom akt. und in den Ring aufnehmen // Verkettung zeigt immer auf den zuerst erzeugten, also vorwaerts - SwCursor* pSav = Create( this ); // sicher den aktuellen Crsr + std::auto_ptr< SwCursor > pSav( Create( this ) ); // save the current cursor // wenn schon ausserhalb vom Bodytext, suche von der Position, // ansonsten beginne mit der 1. GrundSection @@ -1004,8 +1004,8 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas, DeleteMark(); return 0; } + pSav.release(); - delete pSav; if( !( FND_IN_SELALL & eFndRngs )) { // es sollte nur einer gesucht werden, also fuege in dazu @@ -1031,7 +1031,7 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas, } else if( FND_IN_SELALL & eFndRngs ) { - SwCursor* pSav = Create( this ); // sicher den aktuellen Crsr + ::std::auto_ptr< SwCursor> pSav( Create( this ) ); // save the current cursor const SwNode* pSttNd = ( FND_IN_BODYONLY & eFndRngs ) ? rNds.GetEndOfContent().StartOfSectionNode() @@ -1058,10 +1058,7 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas, DeleteMark(); return 0; } - // es wurde ein- bis mehrmals gefunden. Das steht alles - // im neuen Crsr-Ring. Darum hebe erstmal den alten Ring auf - delete pSav; - + pSav.release(); while( GetNext() != this ) delete GetNext(); diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 98179bd1d8ea..d5e7354df745 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -1312,6 +1312,17 @@ lcl_InsertLabel(SwDoc & rDoc, SwTxtFmtColls *const pTxtFmtCollTbl, //Erstmal das Format zum Fly besorgen und das Layout entkoppeln. SwFrmFmt *pOldFmt = rDoc.GetNodes()[nNdIdx]->GetFlyFmt(); ASSERT( pOldFmt, "Format des Fly nicht gefunden." ); + // --> OD #i115719# + // <title> and <description> attributes are lost when calling <DelFrms()>. + // Thus, keep them and restore them after the calling <MakeFrms()> + const bool bIsSwFlyFrmFmtInstance( dynamic_cast<SwFlyFrmFmt*>(pOldFmt) != 0 ); + const String sTitle( bIsSwFlyFrmFmtInstance + ? static_cast<SwFlyFrmFmt*>(pOldFmt)->GetObjTitle() + : String() ); + const String sDescription( bIsSwFlyFrmFmtInstance + ? static_cast<SwFlyFrmFmt*>(pOldFmt)->GetObjDescription() + : String() ); + // <-- pOldFmt->DelFrms(); pNewFmt = rDoc.MakeFlyFrmFmt( rDoc.GetUniqueFrameName(), @@ -1449,6 +1460,13 @@ lcl_InsertLabel(SwDoc & rDoc, SwTxtFmtColls *const pTxtFmtCollTbl, //Nun nur noch die Flys erzeugen lassen. Das ueberlassen //wir vorhanden Methoden (insb. fuer InCntFlys etwas aufwendig). pNewFmt->MakeFrms(); + // --> OD #i115719# + if ( bIsSwFlyFrmFmtInstance ) + { + static_cast<SwFlyFrmFmt*>(pOldFmt)->SetObjTitle( sTitle ); + static_cast<SwFlyFrmFmt*>(pOldFmt)->SetObjDescription( sDescription ); + } + // <-- } break; diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index 647acfe9d9a4..3d4a21584f9a 100644..100755 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -336,7 +336,7 @@ sal_Bool SwBoxAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVersions, s READ( aFont, SvxFontItem , rVersions.nFontVersion) if( rStream.GetStreamCharSet() == aFont.GetCharSet() ) - aFont.GetCharSet() = ::gsl_getSystemTextEncoding(); + aFont.SetCharSet(::gsl_getSystemTextEncoding()); READ( aHeight, SvxFontHeightItem , rVersions.nFontHeightVersion) READ( aWeight, SvxWeightItem , rVersions.nWeightVersion) @@ -424,7 +424,7 @@ sal_Bool SwBoxAutoFmt::LoadOld( SvStream& rStream, sal_uInt16 aLoadVer[] ) READ( aFont, SvxFontItem , 0) if( rStream.GetStreamCharSet() == aFont.GetCharSet() ) - aFont.GetCharSet() = ::gsl_getSystemTextEncoding(); + aFont.SetCharSet(::gsl_getSystemTextEncoding()); READ( aHeight, SvxFontHeightItem , 1) READ( aWeight, SvxWeightItem , 2) diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx index dad951e3848a..d018b0731e43 100644..100755 --- a/sw/source/core/edit/acorrect.cxx +++ b/sw/source/core/edit/acorrect.cxx @@ -157,6 +157,10 @@ sal_Bool SwAutoCorrDoc::Insert( xub_StrLen nPos, const String& rTxt ) sal_Bool SwAutoCorrDoc::Replace( xub_StrLen nPos, const String& rTxt ) { + return ReplaceRange( nPos, rTxt.Len(), rTxt ); +} +sal_Bool SwAutoCorrDoc::ReplaceRange( xub_StrLen nPos, xub_StrLen nSourceLength, const String& rTxt ) +{ SwPaM* pPam = &rCrsr; if( pPam->GetPoint()->nContent.GetIndex() != nPos ) { @@ -204,14 +208,26 @@ sal_Bool SwAutoCorrDoc::Replace( xub_StrLen nPos, const String& rTxt ) pPam->SetMark(); pPam->GetPoint()->nContent = Min( pNd->GetTxt().Len(), - xub_StrLen( nPos + rTxt.Len() )); + xub_StrLen( nPos + nSourceLength )); pDoc->ReplaceRange( *pPam, rTxt, false ); pPam->Exchange(); pPam->DeleteMark(); } } else - pDoc->Overwrite( *pPam, rTxt ); + { + if( nSourceLength != rTxt.Len() ) + { + pPam->SetMark(); + pPam->GetPoint()->nContent = Min( pNd->GetTxt().Len(), + xub_StrLen( nPos + nSourceLength )); + pDoc->ReplaceRange( *pPam, rTxt, false ); + pPam->Exchange(); + pPam->DeleteMark(); + } + else + pDoc->Overwrite( *pPam, rTxt ); + } // pDoc->SetRedlineMode_intern( eOld ); if( bUndoIdInitialized ) diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 828adb14ff10..0f9113445646 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -1542,6 +1542,9 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) aFmt.SetBulletFont( pBullFnt ); aFmt.SetBulletChar( cBullChar ); aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL); + // #i93908# clear suffix for bullet lists + aFmt.SetPrefix(::rtl::OUString()); + aFmt.SetSuffix(::rtl::OUString()); aFmt.SetFirstLineOffset( lBullFirstLineOffset ); aFmt.SetAbsLSpace( nAbsPos ); if( !aFmt.GetCharFmt() ) diff --git a/sw/source/core/inc/acorrect.hxx b/sw/source/core/inc/acorrect.hxx index d52d3a70f4b5..d90b57b13b50 100644..100755 --- a/sw/source/core/inc/acorrect.hxx +++ b/sw/source/core/inc/acorrect.hxx @@ -68,6 +68,7 @@ public: virtual sal_Bool Delete( xub_StrLen nStt, xub_StrLen nEnd ); virtual sal_Bool Insert( xub_StrLen nPos, const String& rTxt ); virtual sal_Bool Replace( xub_StrLen nPos, const String& rTxt ); + virtual sal_Bool ReplaceRange( xub_StrLen nPos, xub_StrLen nLen, const String& rTxt ); virtual sal_Bool SetAttr( xub_StrLen nStt, xub_StrLen nEnd, sal_uInt16 nSlotId, SfxPoolItem& ); diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx index a83fe42c265d..9e482a63f4b3 100644 --- a/sw/source/core/text/txttab.cxx +++ b/sw/source/core/text/txttab.cxx @@ -84,7 +84,6 @@ sal_uInt16 SwLineInfo::NumberOfTabStops() const /************************************************************************* * SwTxtFormatter::NewTabPortion() *************************************************************************/ - SwTabPortion *SwTxtFormatter::NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto ) const { SwTabPortion *pTabPor = 0; @@ -216,63 +215,74 @@ SwTabPortion *SwTxtFormatter::NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto ) cFill = 0; eAdj = SVX_TAB_ADJUST_LEFT; } - // --> OD 2008-02-07 #newlistlevelattrs# - long nForced = 0; - if ( !bTabsRelativeToIndent ) + + // --> OD #i115705# - correction and refactoring: + // overrule determined next tab stop position in order to apply + // a tab stop at the left margin under the following conditions: + // - the new tab portion is inside the hanging indent + // - a tab stop at the left margin is allowed + // - the determined next tab stop is a default tab stop position OR + // the determined next tab stop is beyond the left margin { - if ( bRTL ) + long nLeftMarginTabPos = 0; { - Point aPoint( Left(), 0 ); - pFrm->SwitchLTRtoRTL( aPoint ); - nForced = pFrm->Frm().Right() - aPoint.X(); + if ( !bTabsRelativeToIndent ) + { + if ( bRTL ) + { + Point aPoint( Left(), 0 ); + pFrm->SwitchLTRtoRTL( aPoint ); + nLeftMarginTabPos = pFrm->Frm().Right() - aPoint.X(); + } + else + { + nLeftMarginTabPos = Left() - pFrm->Frm().Left(); + } + } + if( pCurr->HasForcedLeftMargin() ) + { + SwLinePortion* pPor = pCurr->GetPortion(); + while( pPor && !pPor->IsFlyPortion() ) + { + pPor = pPor->GetPortion(); + } + if ( pPor ) + { + nLeftMarginTabPos += pPor->Width(); + } + } } - else + const bool bNewTabPortionInsideHangingIndent = + bRTL ? nCurrentAbsPos > nTabLeft - nLeftMarginTabPos + : nCurrentAbsPos < nTabLeft + nLeftMarginTabPos; + if ( bNewTabPortionInsideHangingIndent ) { - nForced = Left() - pFrm->Frm().Left(); + // If the paragraph is not inside a list having a list tab stop following + // the list label or no further tab stop found in such a paragraph or + // the next tab stop position does not equal the list tab stop, + // a tab stop at the left margin can be applied. If this condition is + // not hold, it is overruled by compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST. + const bool bTabAtLeftMarginAllowed = + ( !aLineInf.IsListTabStopIncluded() || + !pTabStop || + nNextPos != aLineInf.GetListTabStopPosition() ) || + // compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: + pFrm->GetTxtNode()->getIDocumentSettingAccess()-> + get(IDocumentSettingAccess::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST); + if ( bTabAtLeftMarginAllowed ) + { + if ( !pTabStop || eAdj == SVX_TAB_ADJUST_DEFAULT || + ( nNextPos > nLeftMarginTabPos ) ) + { + eAdj = SVX_TAB_ADJUST_DEFAULT; + cFill = 0; + nNextPos = nLeftMarginTabPos; + } + } } } - if( pCurr->HasForcedLeftMargin() ) - { - SwLinePortion* pPor = pCurr->GetPortion(); - while( pPor && !pPor->IsFlyPortion() ) - pPor = pPor->GetPortion(); - if( pPor ) - nForced += pPor->Width(); - } - // <-- - // --> OD 2009-04-03 #i100732# - // correction of condition, when a tab stop at the left margin can - // be applied: - // If the paragraph is not inside a list having a list tab stop following - // the list label or no further tab stop found in such a paragraph or - // the next tab stop position does not equal the list tab stop, - // a tab stop at the left margin can be applied. If this condition is - // not hold, it is overruled by compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST. - const bool bTabAtLeftMargin = - ( !aLineInf.IsListTabStopIncluded() || - !pTabStop || - nNextPos != aLineInf.GetListTabStopPosition() ) || - // compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: - pFrm->GetTxtNode()->getIDocumentSettingAccess()-> - get(IDocumentSettingAccess::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST); - if ( bTabAtLeftMargin && - // <-- - ( ( bRTL && nCurrentAbsPos > nTabLeft - nForced ) || - ( !bRTL && nCurrentAbsPos < nTabLeft + nForced ) ) && - // --> OD 2009-07-21 #i103685# - // adjust condition: - // - back to pre OOo 3.0 condition, if tab stops are relative to indent - // - further checks needed, if tab stops are not relative to indent - ( nNextPos > 0 && - ( bTabsRelativeToIndent || - ( !pTabStop || nNextPos > nForced ) ) ) ) - // <-- - { - eAdj = SVX_TAB_ADJUST_DEFAULT; - cFill = 0; - nNextPos = nForced; - } + nNextPos += bRTL ? nLinePos - nTabLeft : nTabLeft - nLinePos; ASSERT( nNextPos >= 0, "GetTabStop: Don't go back!" ); nNewTabPos = KSHORT(nNextPos); diff --git a/sw/source/core/txtnode/atrref.cxx b/sw/source/core/txtnode/atrref.cxx index 979a810b018b..ba2c3fce60c6 100644 --- a/sw/source/core/txtnode/atrref.cxx +++ b/sw/source/core/txtnode/atrref.cxx @@ -77,7 +77,7 @@ SfxPoolItem* SwFmtRefMark::Clone( SfxItemPool* ) const // Attribut fuer Inhalts-/Positions-Referenzen im Text SwTxtRefMark::SwTxtRefMark( SwFmtRefMark& rAttr, - xub_StrLen nStartPos, xub_StrLen* pEnd ) + xub_StrLen const nStartPos, xub_StrLen const*const pEnd) : SwTxtAttrEnd( rAttr, nStartPos, nStartPos ) , m_pTxtNode( 0 ) , m_pEnd( 0 ) diff --git a/sw/source/core/txtnode/atrtox.cxx b/sw/source/core/txtnode/atrtox.cxx index 8c64e4b2bd29..8b7e54813171 100644 --- a/sw/source/core/txtnode/atrtox.cxx +++ b/sw/source/core/txtnode/atrtox.cxx @@ -36,7 +36,7 @@ #include <ndtxt.hxx> SwTxtTOXMark::SwTxtTOXMark( SwTOXMark& rAttr, - xub_StrLen nStartPos, xub_StrLen* pEnd ) + xub_StrLen const nStartPos, xub_StrLen const*const pEnd) : SwTxtAttrEnd( rAttr, nStartPos, nStartPos ) , m_pTxtNode( 0 ) , m_pEnd( 0 ) diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 236a0bab3d72..bf4116cc91f9 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -613,6 +613,7 @@ SwFmtMeta::~SwFmtMeta() { if (m_pMeta && (m_pMeta->GetFmtMeta() == this)) { + NotifyChangeTxtNode(0); m_pMeta->SetFmtMeta(0); } } @@ -633,16 +634,24 @@ SfxPoolItem * SwFmtMeta::Clone( SfxItemPool * /*pPool*/ ) const void SwFmtMeta::SetTxtAttr(SwTxtMeta * const i_pTxtAttr) { - ASSERT(!(m_pTxtAttr && i_pTxtAttr), + OSL_ENSURE(!(m_pTxtAttr && i_pTxtAttr), "SwFmtMeta::SetTxtAttr: already has text attribute?"); - ASSERT( m_pTxtAttr || i_pTxtAttr , + OSL_ENSURE( m_pTxtAttr || i_pTxtAttr , "SwFmtMeta::SetTxtAttr: no attribute to remove?"); m_pTxtAttr = i_pTxtAttr; - ASSERT(m_pMeta, "inserted SwFmtMeta has no sw::Meta?"); + OSL_ENSURE(m_pMeta, "inserted SwFmtMeta has no sw::Meta?"); // the sw::Meta must be able to find the current text attribute! - if (i_pTxtAttr && m_pMeta) + if (m_pMeta) { - m_pMeta->SetFmtMeta(this); + if (i_pTxtAttr) + { + m_pMeta->SetFmtMeta(this); + } + else if (m_pMeta->GetFmtMeta() == this) + { // text attribute gone => de-register from text node! + NotifyChangeTxtNode(0); + m_pMeta->SetFmtMeta(0); + } } } @@ -650,36 +659,22 @@ void SwFmtMeta::NotifyChangeTxtNode(SwTxtNode *const pTxtNode) { // N.B.: do not reset m_pTxtAttr here: see call in nodes.cxx, // where the hint is not deleted! - ASSERT(m_pMeta, "NotifyRemoval: no meta ?"); - if (m_pMeta) - { - if (!pTxtNode) - { - SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, - &static_cast<SwModify&>(*m_pMeta) ); // cast to base class! - m_pMeta->Modify(&aMsgHint, &aMsgHint); - } - else - { // do not call Modify, that would call SwXMeta::Modify! - m_pMeta->NotifyChangeTxtNode(); - } + OSL_ENSURE(m_pMeta, "SwFmtMeta::NotifyChangeTxtNode: no Meta?"); + if (m_pMeta && (m_pMeta->GetFmtMeta() == this)) + { // do not call Modify, that would call SwXMeta::Modify! + m_pMeta->NotifyChangeTxtNode(pTxtNode); } } -// UGLY: this really awful method fixes up an inconsistent state, -// and if it is not called when copying, total chaos will undoubtedly ensue -void SwFmtMeta::DoCopy(SwFmtMeta & rOriginalMeta) +// this SwFmtMeta has been cloned and points at the same sw::Meta as the source +// this method copies the sw::Meta +void SwFmtMeta::DoCopy(::sw::MetaFieldManager & i_rTargetDocManager, + SwTxtNode & i_rTargetTxtNode) { - ASSERT(m_pMeta, "DoCopy called for SwFmtMeta with no sw::Meta?"); + OSL_ENSURE(m_pMeta, "DoCopy called for SwFmtMeta with no sw::Meta?"); if (m_pMeta) { const ::boost::shared_ptr< ::sw::Meta> pOriginal( m_pMeta ); - // UGLY: original sw::Meta now points at _this_ due to being already - // inserted via MakeTxtAttr! so fix it up to point at the original item - // (maybe would be better to tell MakeTxtAttr that it creates a copy?) - pOriginal->SetFmtMeta(&rOriginalMeta); - // force pOriginal to register in original text node! - pOriginal->NotifyChangeTxtNode(); if (RES_TXTATR_META == Which()) { m_pMeta.reset( new ::sw::Meta(this) ); @@ -688,14 +683,13 @@ void SwFmtMeta::DoCopy(SwFmtMeta & rOriginalMeta) { ::sw::MetaField *const pMetaField( static_cast< ::sw::MetaField* >(pOriginal.get())); - SwDoc * const pTargetDoc( GetTxtAttr()->GetTxtNode()->GetDoc() ); - m_pMeta = pTargetDoc->GetMetaFieldManager().makeMetaField( this, + m_pMeta = i_rTargetDocManager.makeMetaField( this, pMetaField->m_nNumberFormat, pMetaField->IsFixedLanguage() ); } + // Meta must have a text node before calling RegisterAsCopyOf + m_pMeta->NotifyChangeTxtNode(& i_rTargetTxtNode); // this cannot be done in Clone: a Clone is not necessarily a copy! m_pMeta->RegisterAsCopyOf(*pOriginal); - // force copy Meta to register in target text node! - m_pMeta->NotifyChangeTxtNode(); } } @@ -724,27 +718,36 @@ SwTxtMeta * Meta::GetTxtAttr() const SwTxtNode * Meta::GetTxtNode() const { - SwTxtMeta * const pTxtAttr( GetTxtAttr() ); - return (pTxtAttr) ? pTxtAttr->GetTxtNode() : 0; + return m_pTxtNode; } -void Meta::NotifyChangeTxtNode() +void Meta::NotifyChangeTxtNodeImpl() { - SwTxtNode * const pTxtNode( GetTxtNode() ); - if (pTxtNode && (GetRegisteredIn() != pTxtNode)) + if (m_pTxtNode && (GetRegisteredIn() != m_pTxtNode)) { - pTxtNode->Add(this); + m_pTxtNode->Add(this); } - else if (!pTxtNode && GetRegisteredIn()) + else if (!m_pTxtNode && GetRegisteredIn()) { const_cast<SwModify *>(GetRegisteredIn())->Remove(this); } } +void Meta::NotifyChangeTxtNode(SwTxtNode *const pTxtNode) +{ + m_pTxtNode = pTxtNode; + NotifyChangeTxtNodeImpl(); + if (!pTxtNode) // text node gone? invalidate UNO object! + { + SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, + &static_cast<SwModify&>(*this) ); // cast to base class! + this->Modify(&aMsgHint, &aMsgHint); + } +} + // SwClient void Meta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) { - NotifyChangeTxtNode(); SwModify::Modify(pOld, pNew); if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which())) { // invalidate cached uno object @@ -752,7 +755,7 @@ void Meta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) } } -// sw::Metadatable +// sfx2::Metadatable ::sfx2::IXmlIdRegistry& Meta::GetRegistry() { SwTxtNode * const pTxtNode( GetTxtNode() ); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 9a2767977d84..fa7b72271826 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -1435,15 +1435,10 @@ void lcl_CopyHint( const sal_uInt16 nWhich, const SwTxtAttr * const pHt, } case RES_TXTATR_META: case RES_TXTATR_METAFIELD: - ASSERT(pNewHt, "copying META should not fail! cannot call DoCopy"); - ASSERT(pDest && (CH_TXTATR_INWORD == + OSL_ENSURE(pNewHt, "copying Meta should not fail!"); + OSL_ENSURE(pDest && (CH_TXTATR_INWORD == pDest->GetTxt().GetChar(*pNewHt->GetStart())), "missing CH_TXTATR?"); - if (pNewHt) - { - SwFmtMeta & rMeta(static_cast<SwFmtMeta&>(pNewHt->GetAttr())); - rMeta.DoCopy( const_cast<SwFmtMeta&>(pHt->GetMeta()) ); - } break; } } @@ -1484,7 +1479,8 @@ void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, { // attribute in the area => copy SwTxtAttr *const pNewHt = pDest->InsertItem( - pHt->GetAttr(), nOldPos, nOldPos ); + pHt->GetAttr(), nOldPos, nOldPos, + nsSetAttrMode::SETATTR_IS_COPY); if ( pNewHt ) { lcl_CopyHint( nWhich, pHt, pNewHt, @@ -1495,7 +1491,8 @@ void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, : 0 == pOtherDoc->GetRefMark( pHt->GetRefMark().GetRefName() ) ) { - pDest->InsertItem( pHt->GetAttr(), nOldPos, nOldPos ); + pDest->InsertItem( pHt->GetAttr(), nOldPos, nOldPos, + nsSetAttrMode::SETATTR_IS_COPY); } } } @@ -1718,9 +1715,9 @@ void SwTxtNode::CopyText( SwTxtNode *const pDest, if( pDest == this ) { - // die Daten kopieren + // copy the hint here, but insert it later pNewHt = MakeTxtAttr( *GetDoc(), pHt->GetAttr(), - nAttrStt, nAttrEnd ); + nAttrStt, nAttrEnd, COPY, pDest ); lcl_CopyHint(nWhich, pHt, pNewHt, 0, pDest); aArr.C40_INSERT( SwTxtAttr, pNewHt, aArr.Count() ); @@ -1728,7 +1725,9 @@ void SwTxtNode::CopyText( SwTxtNode *const pDest, else { pNewHt = pDest->InsertItem( pHt->GetAttr(), nAttrStt - nDeletedDummyChars, - nAttrEnd - nDeletedDummyChars, nsSetAttrMode::SETATTR_NOTXTATRCHR ); + nAttrEnd - nDeletedDummyChars, + nsSetAttrMode::SETATTR_NOTXTATRCHR + | nsSetAttrMode::SETATTR_IS_COPY); if (pNewHt) { lcl_CopyHint( nWhich, pHt, pNewHt, pOtherDoc, pDest ); @@ -2208,7 +2207,8 @@ void SwTxtNode::CutImpl( SwTxtNode * const pDest, const SwIndex & rDestStart, { const bool bSuccess( pDest->InsertHint( pNewHt, nsSetAttrMode::SETATTR_NOTXTATRCHR - | nsSetAttrMode::SETATTR_DONTREPLACE ) ); + | nsSetAttrMode::SETATTR_DONTREPLACE + | nsSetAttrMode::SETATTR_IS_COPY) ); if (bSuccess) { lcl_CopyHint( nWhich, pHt, pNewHt, pOtherDoc, pDest ); diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index d0be32e61953..4d0dd116e5cd 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -996,7 +996,8 @@ SwTxtAttr* MakeRedlineTxtAttr( SwDoc & rDoc, SfxPoolItem & rAttr ) // create new text attribute SwTxtAttr* MakeTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnd ) + xub_StrLen const nStt, xub_StrLen const nEnd, + CopyOrNew_t const bIsCopy, SwTxtNode *const pTxtNode) { if ( isCHRATR(rAttr.Which()) ) { @@ -1077,7 +1078,8 @@ SwTxtAttr* MakeTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr, break; case RES_TXTATR_META: case RES_TXTATR_METAFIELD: - pNew = new SwTxtMeta( static_cast<SwFmtMeta&>(rNew), nStt, nEnd ); + pNew = SwTxtMeta::CreateTxtMeta( rDoc.GetMetaFieldManager(), pTxtNode, + static_cast<SwFmtMeta&>(rNew), nStt, nEnd, bIsCopy ); break; default: ASSERT(RES_TXTATR_AUTOFMT == rNew.Which(), "unknown attribute"); @@ -1211,7 +1213,8 @@ SwTxtNode::InsertItem( SfxPoolItem& rAttr, ASSERT( !isCHRATR(rAttr.Which()), "AUTOSTYLES - " "SwTxtNode::InsertItem should not be called with character attributes"); - SwTxtAttr* const pNew = MakeTxtAttr( *GetDoc(), rAttr, nStart, nEnd ); + SwTxtAttr *const pNew = MakeTxtAttr( *GetDoc(), rAttr, nStart, nEnd, + (nMode & nsSetAttrMode::SETATTR_IS_COPY) ? COPY : NEW, this ); if ( pNew ) { diff --git a/sw/source/core/txtnode/txtatr2.cxx b/sw/source/core/txtnode/txtatr2.cxx index f6dcfc520eae..90b5b984a8d1 100644 --- a/sw/source/core/txtnode/txtatr2.cxx +++ b/sw/source/core/txtnode/txtatr2.cxx @@ -308,10 +308,25 @@ SwCharFmt* SwTxtRuby::GetCharFmt() * class SwTxtMeta *************************************************************************/ +SwTxtMeta * +SwTxtMeta::CreateTxtMeta( + ::sw::MetaFieldManager & i_rTargetDocManager, + SwTxtNode *const i_pTargetTxtNode, + SwFmtMeta & i_rAttr, + xub_StrLen const i_nStart, xub_StrLen const i_nEnd, bool const i_bIsCopy) +{ + if (COPY == i_bIsCopy) + { // i_rAttr is already cloned, now call DoCopy to copy the sw::Meta + OSL_ENSURE(i_pTargetTxtNode, "cannot copy Meta without target node"); + i_rAttr.DoCopy(i_rTargetDocManager, *i_pTargetTxtNode); + } + SwTxtMeta *const pTxtMeta(new SwTxtMeta(i_rAttr, i_nStart, i_nEnd)); + return pTxtMeta; +} + SwTxtMeta::SwTxtMeta( SwFmtMeta & i_rAttr, const xub_StrLen i_nStart, const xub_StrLen i_nEnd ) : SwTxtAttrNesting( i_rAttr, i_nStart, i_nEnd ) - , m_pTxtNode( 0 ) { i_rAttr.SetTxtAttr( this ); SetHasDummyChar(true); @@ -328,7 +343,6 @@ SwTxtMeta::~SwTxtMeta() void SwTxtMeta::ChgTxtNode(SwTxtNode * const pNode) { - m_pTxtNode = pNode; // before Notify! SwFmtMeta & rFmtMeta( static_cast<SwFmtMeta &>(GetAttr()) ); if (rFmtMeta.GetTxtAttr() == this) { diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 4b99670b865c..b3d93e8eb0a7 100644..100755 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -966,11 +966,11 @@ void SwTxtNode::SetLanguageAndFont( const SwPaM &rPaM, if (pFont) { SvxFontItem aFontItem = (SvxFontItem&) aSet.Get( nFontWhichId ); - aFontItem.GetFamilyName() = pFont->GetName(); - aFontItem.GetFamily() = pFont->GetFamily(); - aFontItem.GetStyleName() = pFont->GetStyleName(); - aFontItem.GetPitch() = pFont->GetPitch(); - aFontItem.GetCharSet() = pFont->GetCharSet(); + aFontItem.SetFamilyName( pFont->GetName()); + aFontItem.SetFamily( pFont->GetFamily()); + aFontItem.SetStyleName( pFont->GetStyleName()); + aFontItem.SetPitch( pFont->GetPitch()); + aFontItem.SetCharSet( pFont->GetCharSet() ); aSet.Put( aFontItem ); } diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 1bb59d0eee65..90d5dac1c315 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -886,7 +886,7 @@ bool SwXMeta::SetContentRange( SwTxtMeta const * const pTxtAttr( pMeta->GetTxtAttr() ); if (pTxtAttr) { - rpNode = pTxtAttr->GetTxtNode(); + rpNode = pMeta->GetTxtNode(); if (rpNode) { // rStart points at the first position _within_ the meta! diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 875d0e23235d..323eedffc9b0 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1857,32 +1857,6 @@ static bool lcl_SimilarPosition( const sal_Int32 nPos1, const sal_Int32 nPos2 ) return abs( nPos1 - nPos2 ) < COL_POS_FUZZY; } -void SwXText::copyText( - const uno::Reference< text::XTextCopy >& xSource ) - throw ( uno::RuntimeException ) -{ - uno::Reference< lang::XUnoTunnel > xTTunnel( xSource, uno::UNO_QUERY_THROW ); - SwXText* pText = 0; - pText = reinterpret_cast< SwXText* >( - sal::static_int_cast< sal_IntPtr >( xTTunnel->getSomething( SwXText::getUnoTunnelId()) )); - - uno::Reference< text::XText > xText( xSource, uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextCursor > xCursor = xText->createTextCursor( ); - xCursor->gotoEnd( sal_True ); - - uno::Reference< lang::XUnoTunnel > xTunnel( xCursor, uno::UNO_QUERY_THROW ); - - OTextCursorHelper* pCursor = 0; - pCursor = reinterpret_cast< OTextCursorHelper* >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); - if ( pCursor ) - { - SwNodeIndex rNdIndex( *GetStartNode( ), 1 ); - SwPosition rPos( rNdIndex ); - m_pImpl->m_pDoc->CopyRange( *pCursor->GetPaM( ), rPos, false ); - } -} - void SwXText::Impl::ConvertCell( const bool bFirstCell, const uno::Sequence< uno::Reference< text::XTextRange > > & rCell, @@ -2387,6 +2361,35 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) return xRet; } + +void SAL_CALL +SwXText::copyText( + const uno::Reference< text::XTextCopy >& xSource ) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + uno::Reference< text::XText > const xText(xSource, uno::UNO_QUERY_THROW); + uno::Reference< text::XTextCursor > const xCursor = + xText->createTextCursor(); + xCursor->gotoEnd( sal_True ); + + uno::Reference< lang::XUnoTunnel > const xCursorTunnel(xCursor, + uno::UNO_QUERY_THROW); + + OTextCursorHelper *const pCursor = + ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xCursorTunnel); + if (!pCursor) + { + throw uno::RuntimeException(); + } + + SwNodeIndex rNdIndex( *GetStartNode( ), 1 ); + SwPosition rPos( rNdIndex ); + m_pImpl->m_pDoc->CopyRange( *pCursor->GetPaM(), rPos, false ); +} + + /****************************************************************** * SwXBodyText ******************************************************************/ |