diff options
Diffstat (limited to 'sw/source')
254 files changed, 8107 insertions, 4369 deletions
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 5d786e50bc..a48e36d134 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -668,8 +668,8 @@ sal_Bool SwAccessibleParagraph::GetWordBoundary( // now ask the Break-Iterator for the word DBG_ASSERT( pBreakIt != NULL, "We always need a break." ); - DBG_ASSERT( pBreakIt->xBreak.is(), "No break-iterator." ); - if( pBreakIt->xBreak.is() ) + DBG_ASSERT( pBreakIt->GetBreakIter().is(), "No break-iterator." ); + if( pBreakIt->GetBreakIter().is() ) { // get locale for this position USHORT nModelPos = GetPortionData().GetModelPosition( nPos ); @@ -681,7 +681,7 @@ sal_Bool SwAccessibleParagraph::GetWordBoundary( const USHORT nWordType = WordType::ANY_WORD; // get word boundary, as the Break-Iterator sees fit. - rBound = pBreakIt->xBreak->getWordBoundary( + rBound = pBreakIt->GetBreakIter()->getWordBoundary( rText, nPos, aLocale, nWordType, sal_True ); // It's a word if the first character is an alpha-numeric character. @@ -748,8 +748,8 @@ sal_Bool SwAccessibleParagraph::GetGlyphBoundary( // ask the Break-Iterator for the glyph by moving one cell // forward, and then one cell back DBG_ASSERT( pBreakIt != NULL, "We always need a break." ); - DBG_ASSERT( pBreakIt->xBreak.is(), "No break-iterator." ); - if( pBreakIt->xBreak.is() ) + DBG_ASSERT( pBreakIt->GetBreakIter().is(), "No break-iterator." ); + if( pBreakIt->GetBreakIter().is() ) { // get locale for this position USHORT nModelPos = GetPortionData().GetModelPosition( nPos ); @@ -759,9 +759,9 @@ sal_Bool SwAccessibleParagraph::GetGlyphBoundary( // get word boundary, as the Break-Iterator sees fit. const USHORT nIterMode = CharacterIteratorMode::SKIPCELL; sal_Int32 nDone = 0; - rBound.endPos = pBreakIt->xBreak->nextCharacters( + rBound.endPos = pBreakIt->GetBreakIter()->nextCharacters( rText, nPos, aLocale, nIterMode, 1, nDone ); - rBound.startPos = pBreakIt->xBreak->previousCharacters( + rBound.startPos = pBreakIt->GetBreakIter()->previousCharacters( rText, rBound.endPos, aLocale, nIterMode, 1, nDone ); DBG_ASSERT( rBound.startPos <= nPos, "start pos too high" ); diff --git a/sw/source/core/access/accportions.cxx b/sw/source/core/access/accportions.cxx index fb80f040bd..48f4b23136 100644 --- a/sw/source/core/access/accportions.cxx +++ b/sw/source/core/access/accportions.cxx @@ -489,8 +489,8 @@ void SwAccessiblePortionData::GetSentenceBoundary( if( pSentences == NULL ) { DBG_ASSERT( pBreakIt != NULL, "We always need a break." ); - DBG_ASSERT( pBreakIt->xBreak.is(), "No break-iterator." ); - if( pBreakIt->xBreak.is() ) + DBG_ASSERT( pBreakIt->GetBreakIter().is(), "No break-iterator." ); + if( pBreakIt->GetBreakIter().is() ) { pSentences = new Positions_t(); pSentences->reserve(10); @@ -505,7 +505,7 @@ void SwAccessiblePortionData::GetSentenceBoundary( USHORT nModelPos = GetModelPosition( nCurrent ); - sal_Int32 nNew = pBreakIt->xBreak->endOfSentence( + sal_Int32 nNew = pBreakIt->GetBreakIter()->endOfSentence( sAccessibleString, nCurrent, pBreakIt->GetLocale(pTxtNode->GetLang(nModelPos)) ) + 1; diff --git a/sw/source/core/bastyp/breakit.cxx b/sw/source/core/bastyp/breakit.cxx index 1dd1616df3..9541707ea9 100644 --- a/sw/source/core/bastyp/breakit.cxx +++ b/sw/source/core/bastyp/breakit.cxx @@ -74,18 +74,18 @@ SwBreakIt::SwBreakIt( aForbiddenLang( LANGUAGE_DONTKNOW) { DBG_ASSERT( m_xMSF.is(), "SwBreakIt: no MultiServiceFactory" ); - if ( m_xMSF.is() ) - { - xBreak = uno::Reference< i18n::XBreakIterator >( - m_xMSF->createInstance( - rtl::OUString::createFromAscii( "com.sun.star.i18n.BreakIterator" ) ), - uno::UNO_QUERY); - - xCTLDetect = uno::Reference< i18n::XScriptTypeDetector >( - m_xMSF->createInstance( - rtl::OUString::createFromAscii( "com.sun.star.i18n.ScriptTypeDetector" ) ), - uno::UNO_QUERY); - } + //if ( m_xMSF.is() ) + //{ + // xBreak = uno::Reference< i18n::XBreakIterator >( + // m_xMSF->createInstance( + // rtl::OUString::createFromAscii( "com.sun.star.i18n.BreakIterator" ) ), + // uno::UNO_QUERY); + + // xCTLDetect = uno::Reference< i18n::XScriptTypeDetector >( + // m_xMSF->createInstance( + // rtl::OUString::createFromAscii( "com.sun.star.i18n.ScriptTypeDetector" ) ), + // uno::UNO_QUERY); + // } } SwBreakIt::~SwBreakIt() @@ -93,7 +93,16 @@ SwBreakIt::~SwBreakIt() delete m_pLocale; delete m_pForbidden; } - +void SwBreakIt::createBreakIterator() const +{ + if ( m_xMSF.is() && !xBreak.is() ) + xBreak.set(m_xMSF->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.BreakIterator"))),uno::UNO_QUERY); +} +void SwBreakIt::createScriptTypeDetector() +{ + if ( m_xMSF.is() && !xCTLDetect.is() ) + xCTLDetect.set(m_xMSF->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.i18n.ScriptTypeDetector" ))),uno::UNO_QUERY); +} void SwBreakIt::_GetLocale( const LanguageType aLang ) { aLast = aLang; @@ -113,6 +122,7 @@ void SwBreakIt::_GetForbidden( const LanguageType aLang ) USHORT SwBreakIt::GetRealScriptOfText( const String& rTxt, xub_StrLen nPos ) const { + createBreakIterator(); USHORT nScript = i18n::ScriptType::WEAK; if( xBreak.is() && rTxt.Len() ) { @@ -151,6 +161,7 @@ USHORT SwBreakIt::GetAllScriptsOfText( const String& rTxt ) const const USHORT coAllScripts = ( SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX ); + createBreakIterator(); USHORT nRet = 0, nScript; if( !xBreak.is() ) nRet = coAllScripts; diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx index 487df0ac87..bb81f9116c 100644 --- a/sw/source/core/bastyp/calc.cxx +++ b/sw/source/core/bastyp/calc.cxx @@ -273,7 +273,7 @@ SwCalc::SwCalc( SwDoc& rD ) : aErrExpr( aEmptyStr, SwSbxValue(), 0 ), rDoc( rD ), - pLclData( &GetAppLocaleData() ), + pLclData( &SvtSysLocale().GetLocaleData() ), pCharClass( &GetAppCharClass() ), nListPor( 0 ), eError( CALC_NOERR ) @@ -422,7 +422,7 @@ SwCalc::~SwCalc() { for( USHORT n = 0; n < TBLSZ; ++n ) delete VarTable[n]; - if( pLclData != &GetAppLocaleData() ) + if( pLclData != &SvtSysLocale().GetLocaleData() ) delete pLclData; if( pCharClass != &GetAppCharClass() ) delete pCharClass; @@ -1622,7 +1622,7 @@ BOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos, { const LocaleDataWrapper* pLclD = pLclData; if( !pLclD ) - pLclD = &GetAppLocaleData(); + pLclD = &SvtSysLocale().GetLocaleData(); const xub_Unicode nCurrCmdPos = rCommandPos; rtl_math_ConversionStatus eStatus; @@ -1634,7 +1634,7 @@ BOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos, &eStatus, &pEnd ); rCommandPos = static_cast<xub_StrLen>(pEnd - rCommand.GetBuffer()); - if( !pLclData && pLclD != &GetAppLocaleData() ) + if( !pLclData && pLclD != &SvtSysLocale().GetLocaleData() ) delete (LocaleDataWrapper*)pLclD; return rtl_math_ConversionStatus_Ok == eStatus && nCurrCmdPos != rCommandPos; @@ -1643,7 +1643,7 @@ BOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos, BOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos, double& rVal, SwDoc* pDoc ) { - const LocaleDataWrapper* pLclD = &GetAppLocaleData(); + const LocaleDataWrapper* pLclD = &SvtSysLocale().GetLocaleData(); if( pDoc ) { @@ -1664,7 +1664,7 @@ BOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos, &eStatus, &pEnd ); rCommandPos = static_cast<xub_StrLen>(pEnd - rCommand.GetBuffer()); - if( pLclD != &GetAppLocaleData() ) + if( pLclD != &SvtSysLocale().GetLocaleData() ) delete (LocaleDataWrapper*)pLclD; return rtl_math_ConversionStatus_Ok == eStatus && nCurrCmdPos != rCommandPos; diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx index 6cf6ef4d23..d05cf8d72a 100644 --- a/sw/source/core/bastyp/index.cxx +++ b/sw/source/core/bastyp/index.cxx @@ -328,10 +328,10 @@ SwIndexReg::~SwIndexReg() -void SwIndexReg::Update( const SwIndex& rIdx, xub_StrLen nDiff, BOOL bNeg, - BOOL /* argument is only used in derived class*/ ) +void SwIndexReg::Update( SwIndex const & rIdx, const xub_StrLen nDiff, + const bool bNeg, const bool /* argument is only used in derived class*/ ) { - SwIndex* pStt = (SwIndex*)&rIdx; + SwIndex* pStt = const_cast<SwIndex*>(&rIdx); xub_StrLen nNewVal = rIdx.nIndex; if( bNeg ) { diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx index 592067e1f5..2e54dcbc8c 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -46,9 +46,7 @@ #include <svx/shaditem.hxx> #include <svx/prntitem.hxx> #include <svx/brkitem.hxx> -#ifndef _SVX_TSTPITEM_HXX #include <svx/tstpitem.hxx> -#endif #include <svx/langitem.hxx> #include <svx/wrlmitem.hxx> #include <svx/kernitem.hxx> @@ -62,13 +60,9 @@ #include <svx/lspcitem.hxx> #include <svx/blnkitem.hxx> #include <svx/akrnitem.hxx> -#ifndef _SVX_EMPHITEM_HXX #include <svx/emphitem.hxx> -#endif #include <svx/twolinesitem.hxx> -#ifndef _SVX_SCRIPSPACEITEM_HXX #include <svx/scriptspaceitem.hxx> -#endif #include <svx/hngpnctitem.hxx> #include <svx/cmapitem.hxx> #include <svx/charscaleitem.hxx> @@ -94,7 +88,6 @@ #include <unotools/transliterationwrapper.hxx> #include <svx/acorrcfg.hxx> #include <vcl/svapp.hxx> -#include <fmthbsh.hxx> #include <fmtanchr.hxx> #include <fmtornt.hxx> #include <fmtsrnd.hxx> @@ -116,9 +109,7 @@ #include <fmtautofmt.hxx> #include <fmtinfmt.hxx> #include <fmtcnct.hxx> -#ifndef _FMTLINE_HXX #include <fmtline.hxx> -#endif #include <fmtftntx.hxx> #include <fmtruby.hxx> #include <fmtautofmt.hxx> @@ -137,9 +128,7 @@ #include <doc.hxx> #include <acmplwrd.hxx> #include <fmtclbl.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif #include <breakit.hxx> #include <checkit.hxx> #include <swcalwrp.hxx> @@ -150,6 +139,9 @@ // OD 2004-05-05 #i28701# #include <fmtwrapinfluenceonobjpos.hxx> +#include <fmtmeta.hxx> + + using namespace ::com::sun::star; extern void _FrmFinit(); @@ -327,14 +319,14 @@ SfxItemInfo __FAR_DATA aSlotTab[] = { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY5 { SID_ATTR_CHAR_CJK_RUBY, 0 }, // RES_TXTATR_CJK_RUBY, { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_UNKNOWN_CONTAINER, - { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY6, - { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY7, + { 0, 0 }, // RES_TXTATR_META, + { 0, 0 }, // RES_TXTATR_METAFIELD, { 0, 0 }, // RES_TXTATR_FIELD { 0, 0 }, // RES_TXTATR_FLYCNT { 0, 0 }, // RES_TXTATR_FTN - { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_SOFTHYPH - { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_HARDBLANK + { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY4 + { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY3 { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY1 { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY2 @@ -467,14 +459,18 @@ SwAutoCompleteWord* SwDoc::pACmpltWords = 0; SwCheckIt* pCheckIt = 0; CharClass* pAppCharClass = 0; -SwCalendarWrapper* pCalendarWrapper = 0; + CollatorWrapper* pCollator = 0, *pCaseCollator = 0; ::utl::TransliterationWrapper* pTransWrp = 0; /****************************************************************************** * void _InitCore() ******************************************************************************/ - +salhelper::SingletonRef<SwCalendarWrapper>* s_getCalendarWrapper() +{ + static salhelper::SingletonRef<SwCalendarWrapper> aCalendarWrapper; + return &aCalendarWrapper; +} void _InitCore() { SfxPoolItem* pItem; @@ -540,19 +536,19 @@ void _InitCore() aAttrTab[ RES_TXTATR_CHARFMT- POOLATTR_BEGIN ] = new SwFmtCharFmt( 0 ); aAttrTab[ RES_TXTATR_CJK_RUBY - POOLATTR_BEGIN ] = new SwFmtRuby( aEmptyStr ); aAttrTab[ RES_TXTATR_UNKNOWN_CONTAINER - POOLATTR_BEGIN ] = new SvXMLAttrContainerItem( RES_TXTATR_UNKNOWN_CONTAINER ); + aAttrTab[ RES_TXTATR_META - POOLATTR_BEGIN ] = SwFmtMeta::CreatePoolDefault(RES_TXTATR_META); + aAttrTab[ RES_TXTATR_METAFIELD - POOLATTR_BEGIN ] = SwFmtMeta::CreatePoolDefault(RES_TXTATR_METAFIELD); aAttrTab[ RES_TXTATR_FIELD- POOLATTR_BEGIN ] = new SwFmtFld; aAttrTab[ RES_TXTATR_FLYCNT - POOLATTR_BEGIN ] = new SwFmtFlyCnt( 0 ); aAttrTab[ RES_TXTATR_FTN - POOLATTR_BEGIN ] = new SwFmtFtn; - aAttrTab[ RES_TXTATR_SOFTHYPH- POOLATTR_BEGIN ] = new SwFmtSoftHyph; - aAttrTab[ RES_TXTATR_HARDBLANK- POOLATTR_BEGIN ] = new SwFmtHardBlank( ' ', FALSE ); // TextAttr - Dummies + aAttrTab[ RES_TXTATR_DUMMY4 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY4 ); + aAttrTab[ RES_TXTATR_DUMMY3 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY3 ); aAttrTab[ RES_TXTATR_DUMMY1 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY1 ); aAttrTab[ RES_TXTATR_DUMMY2 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY2 ); aAttrTab[ RES_TXTATR_DUMMY5 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY5 ); - aAttrTab[ RES_TXTATR_DUMMY6 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY6 ); - aAttrTab[ RES_TXTATR_DUMMY7 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY7 ); // TextAttr - Dummies aAttrTab[ RES_PARATR_LINESPACING- POOLATTR_BEGIN ] = new SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT, RES_PARATR_LINESPACING ); @@ -740,9 +736,9 @@ void _InitCore() SwBreakIt::_Create( xMSF ); pCheckIt = NULL; - pAppCharClass = new CharClass( - xMSF, SwBreakIt::Get()->GetLocale( (LanguageType)GetAppLanguage() )); - pCalendarWrapper = new SwCalendarWrapper( xMSF ); + /*pAppCharClass = new CharClass( + xMSF, SwBreakIt::Get()->GetLocale( (LanguageType)GetAppLanguage() ));*/ + //pCalendarWrapper = new SwCalendarWrapper( xMSF ); _FrmInit(); _TextInit(); @@ -773,7 +769,6 @@ void _FinitCore() SwBreakIt::_Delete(); delete pCheckIt; delete pAppCharClass; - delete pCalendarWrapper; delete pCollator; delete pCaseCollator; @@ -856,16 +851,15 @@ void _FinitCore() // returns the APP - CharClass instance - used for all ToUpper/ToLower/... CharClass& GetAppCharClass() { + if ( !pAppCharClass ) + { + uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); + pAppCharClass = new CharClass( + xMSF, SwBreakIt::Get()->GetLocale( (LanguageType)GetAppLanguage() )); + } return *pAppCharClass; } -LocaleDataWrapper& GetAppLocaleData() -{ - SvtSysLocale aSysLocale; - return (LocaleDataWrapper&)aSysLocale.GetLocaleData(); -} - - void SwCalendarWrapper::LoadDefaultCalendar( USHORT eLang ) { sUniqueId.Erase(); diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 5e9c7aa75d..8918058c31 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -42,8 +42,10 @@ #include <svx/linkmgr.hxx> #include <swtypes.hxx> #include <undobj.hxx> +#include <unoobj.hxx> #include <rtl/random.h> + SV_IMPL_REF( SwServerObject ) using namespace ::sw::mark; @@ -85,9 +87,13 @@ namespace const SwPaM aEndPaM(rEnd); io_pDoc->StartUndo(UNDO_UI_REPLACE, NULL); if(ch_start != aStartMark) - io_pDoc->Insert(aStartPaM, aStartMark); + { + io_pDoc->InsertString(aStartPaM, aStartMark); + } if(aEndMark && ch_end != aEndMark) - io_pDoc->Insert(aEndPaM, aEndMark); + { + io_pDoc->InsertString(aEndPaM, aEndMark); + } io_pDoc->EndUndo(UNDO_UI_REPLACE, NULL); }; } @@ -190,6 +196,7 @@ namespace sw { namespace mark const ::rtl::OUString& rName, const ::rtl::OUString& rShortName) : DdeBookmark(aPaM) + , ::sfx2::Metadatable() , m_aCode(rCode) , m_sShortName(rShortName) { @@ -206,6 +213,54 @@ namespace sw { namespace mark io_pDoc->SetModified(); } + // ::sfx2::Metadatable + ::sfx2::IXmlIdRegistry& Bookmark::GetRegistry() + { + SwDoc *const pDoc( GetMarkPos().GetDoc() ); + OSL_ENSURE(pDoc, "Bookmark::MakeUnoObject: no doc?"); + return pDoc->GetXmlIdRegistry(); + } + + bool Bookmark::IsInClipboard() const + { + SwDoc *const pDoc( GetMarkPos().GetDoc() ); + OSL_ENSURE(pDoc, "Bookmark::IsInClipboard: no doc?"); + return pDoc->IsClipBoard(); + } + + bool Bookmark::IsInUndo() const + { + return false; + } + + bool Bookmark::IsInContent() const + { + SwDoc *const pDoc( GetMarkPos().GetDoc() ); + OSL_ENSURE(pDoc, "Bookmark::IsInContent: no doc?"); + return !pDoc->IsInHeaderFooter( SwNodeIndex(GetMarkPos().nNode) ); + } + + ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > + Bookmark::MakeUnoObject() + { + // re-use existing SwXBookmark + SwClientIter iter( *this ); + SwClient * pClient( iter.First( TYPE( SwXBookmark ) ) ); + while (pClient) { + SwXBookmark *const pBookmark( dynamic_cast<SwXBookmark*>(pClient) ); + if (pBookmark && pBookmark->GetCoreObject() == this) { + return pBookmark; + } + pClient = iter.Next(); + } + + // create new SwXBookmark + SwDoc *const pDoc( GetMarkPos().GetDoc() ); + OSL_ENSURE(pDoc, "Bookmark::MakeUnoObject: no doc?"); + return new SwXBookmark(this, pDoc); + } + + Fieldmark::Fieldmark(const SwPaM& rPaM) : MarkBase(rPaM, MarkBase::GenerateNewName(our_sNamePrefix)) { diff --git a/sw/source/core/crsr/callnk.cxx b/sw/source/core/crsr/callnk.cxx index 8aaa93cf56..8c26aeb6eb 100644 --- a/sw/source/core/crsr/callnk.cxx +++ b/sw/source/core/crsr/callnk.cxx @@ -171,12 +171,12 @@ SwCallLink::~SwCallLink() } } - if( pBreakIt->xBreak.is() ) + if( pBreakIt->GetBreakIter().is() ) { const String& rTxt = ((SwTxtNode*)pCNd)->GetTxt(); if( !nCmp || - pBreakIt->xBreak->getScriptType( rTxt, nCmp ) - != pBreakIt->xBreak->getScriptType( rTxt, nCmp - 1 )) + pBreakIt->GetBreakIter()->getScriptType( rTxt, nCmp ) + != pBreakIt->GetBreakIter()->getScriptType( rTxt, nCmp - 1 )) { rShell.CallChgLnk(); return; diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 257727315e..2c20c18ce9 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -1124,8 +1124,8 @@ BOOL SwCrsrShell::GetContentAtPos( const Point& rPt, if( !bRet && ( SwContentAtPos::SW_FIELD | SwContentAtPos::SW_CLICKFIELD ) & rCntntAtPos.eCntntAtPos && !aTmpState.bFtnNoInfo ) { - pTxtAttr = pTxtNd->GetTxtAttr( aPos.nContent.GetIndex(), - RES_TXTATR_FIELD ); + pTxtAttr = pTxtNd->GetTxtAttrForCharAt( + aPos.nContent.GetIndex(), RES_TXTATR_FIELD ); const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0; @@ -1190,7 +1190,7 @@ BOOL SwCrsrShell::GetContentAtPos( const Point& rPt, if( bRet ) rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FTN; } - else if( 0 != ( pTxtAttr = pTxtNd->GetTxtAttr( + else if ( 0 != ( pTxtAttr = pTxtNd->GetTxtAttrForCharAt( aPos.nContent.GetIndex(), RES_TXTATR_FTN )) ) { bRet = TRUE; @@ -1526,9 +1526,8 @@ const SwPostItField* SwCrsrShell::GetPostItFieldAtCursor() const const SwTxtNode* pTxtNd = pCursorPos->nNode.GetNode().GetTxtNode(); if ( pTxtNd ) { - SwTxtAttr* pTxtAttr = - pTxtNd->GetTxtAttr( pCursorPos->nContent.GetIndex(), - RES_TXTATR_FIELD ); + SwTxtAttr* pTxtAttr = pTxtNd->GetTxtAttrForCharAt( + pCursorPos->nContent.GetIndex(), RES_TXTATR_FIELD ); const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0; if ( pFld && pFld->Which()== RES_POSTITFLD ) { @@ -1766,7 +1765,7 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) if( n < aFPos.nColumnCnt ) { *pCurCrsr->GetPoint() = aPos; - GetDoc()->Insert( *pCurCrsr, + GetDoc()->InsertPoolItem( *pCurCrsr, SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE, RES_BREAK ), 0); } } @@ -1792,7 +1791,7 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) if( SVX_ADJUST_LEFT != rAdj.GetAdjust() ) aSet.Put( SvxAdjustItem( SVX_ADJUST_LEFT, RES_PARATR_ADJUST ) ); - GetDoc()->Insert( *pCurCrsr, aSet, 0 ); + GetDoc()->InsertItemSet( *pCurCrsr, aSet, 0 ); } else { ASSERT( !this, "wo ist mein CntntNode?" ); @@ -1812,7 +1811,9 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) sInsert += sSpace; } if( sInsert.Len() ) - GetDoc()->Insert( *pCurCrsr, sInsert, true ); + { + GetDoc()->InsertString( *pCurCrsr, sInsert ); + } } // kein break - Ausrichtung muss noch gesetzt werden case FILL_MARGIN: @@ -1830,7 +1831,7 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) default: break; } - GetDoc()->Insert( *pCurCrsr, aAdj, 0 ); + GetDoc()->InsertPoolItem( *pCurCrsr, aAdj, 0 ); } break; } diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx index 981767e30a..61fefca669 100644 --- a/sw/source/core/crsr/findattr.cxx +++ b/sw/source/core/crsr/findattr.cxx @@ -1189,7 +1189,8 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion, if( bReplaceTxt ) { - int bRegExp = SearchAlgorithms_REGEXP == pSearchOpt->algorithmType; + const bool bRegExp( + SearchAlgorithms_REGEXP == pSearchOpt->algorithmType); SwIndex& rSttCntIdx = pCrsr->Start()->nContent; xub_StrLen nSttCnt = rSttCntIdx.GetIndex(); @@ -1202,12 +1203,11 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion, ((Ring*)pRegion)->MoveRingTo( &rCursor ); } - String *pRepl = bRegExp ? ReplaceBackReferences( *pSearchOpt, pCrsr ) : 0; - if( pRepl ) - rCursor.GetDoc()->Replace( *pCrsr, *pRepl, bRegExp ); - else - rCursor.GetDoc()->Replace( *pCrsr, pSearchOpt->replaceString, bRegExp ); - delete pRepl; + ::std::auto_ptr<String> pRepl( (bRegExp) ? + ReplaceBackReferences( *pSearchOpt, pCrsr ) : 0 ); + rCursor.GetDoc()->ReplaceRange( *pCrsr, + (pRepl.get()) ? *pRepl : String(pSearchOpt->replaceString), + bRegExp ); rCursor.SaveTblBoxCntnt( pCrsr->GetPoint() ); if( bRegExp ) @@ -1235,7 +1235,9 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion, // ReplaceSet angegeben, auf Default zurueck gesetzt if( !pSet->Count() ) - pCrsr->GetDoc()->Insert( *pCrsr, *pReplSet, 0 ); + { + pCrsr->GetDoc()->InsertItemSet( *pCrsr, *pReplSet, 0 ); + } else { SfxItemPool* pPool = pReplSet->GetPool(); @@ -1255,7 +1257,7 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion, pItem = aIter.NextItem(); } aSet.Put( *pReplSet ); - pCrsr->GetDoc()->Insert( *pCrsr, aSet, 0 ); + pCrsr->GetDoc()->InsertItemSet( *pCrsr, aSet, 0 ); } #endif return FIND_NO_RING; diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx index e483aa44a0..ab93dee334 100644 --- a/sw/source/core/crsr/findtxt.cxx +++ b/sw/source/core/crsr/findtxt.cxx @@ -126,7 +126,7 @@ String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart, if ( bNewHint ) { const SwTxtAttr* pHt = (*pHts)[n]; - if ( !pHt->GetEnd() && nStt >= nStart ) + if ( pHt->HasDummyChar() && (nStt >= nStart) ) { //JP 17.05.00: Task 75806 ask for ">=" and not for ">" switch( pHt->Which() ) @@ -136,7 +136,9 @@ String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart, case RES_TXTATR_FIELD: case RES_TXTATR_REFMARK: case RES_TXTATR_TOXMARK: - { + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + { // JP 06.05.98: mit Bug 50100 werden sie als Trenner erwuenscht und nicht // mehr zum Wort dazu gehoerend. // MA 23.06.98: mit Bug 51215 sollen sie konsequenterweise auch am @@ -161,9 +163,6 @@ String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart, } } break; - case RES_TXTATR_HARDBLANK: - rRet.SetChar( nAkt, ((SwTxtHardBlank*)pHt)->GetChar() ); - break; default: ASSERT( false, "unknown case in lcl_CleanStr" ) break; @@ -456,7 +455,7 @@ bool SwPaM::DoSearch( const SearchOptions& rSearchOpt, utl::TextSearch& rSTxt, USHORT nCurrScript = 0; if ( SearchAlgorithms_APPROXIMATE == rSearchOpt.algorithmType && - pBreakIt->xBreak.is() ) + pBreakIt->GetBreakIter().is() ) { pScriptIter = new SwScriptIterator( sCleanStr, nStart, bSrchForward ); nSearchScript = pBreakIt->GetRealScriptOfText( rSearchOpt.searchString, 0 ); @@ -593,7 +592,7 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove, if( bFnd && bReplace ) // String ersetzen ?? { // Replace-Methode vom SwDoc benutzen - int bRegExp = SearchAlgorithms_REGEXP == rSearchOpt.algorithmType; + const bool bRegExp(SearchAlgorithms_REGEXP == rSearchOpt.algorithmType); SwIndex& rSttCntIdx = pCrsr->Start()->nContent; xub_StrLen nSttCnt = rSttCntIdx.GetIndex(); // damit die Region auch verschoben wird, in den Shell-Cursr-Ring @@ -605,12 +604,11 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove, ((Ring*)pRegion)->MoveRingTo( &rCursor ); } - String *pRepl = bRegExp ? ReplaceBackReferences( rSearchOpt, pCrsr ) : 0; - if( pRepl ) - rCursor.GetDoc()->Replace( *pCrsr, *pRepl, bRegExp ); - else - rCursor.GetDoc()->Replace( *pCrsr, rSearchOpt.replaceString, bRegExp ); - delete pRepl; + ::std::auto_ptr<String> pRepl( (bRegExp) + ? ReplaceBackReferences( rSearchOpt, pCrsr ) : 0 ); + rCursor.GetDoc()->ReplaceRange( *pCrsr, + (pRepl.get()) ? *pRepl : String(rSearchOpt.replaceString), + bRegExp ); rCursor.SaveTblBoxCntnt( pCrsr->GetPoint() ); if( bRegExp ) diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index 3b38547d90..d7823ec532 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -198,7 +198,12 @@ SwComparePosition ComparePosition( nRet = POS_INSIDE; } else - nRet = POS_OVERLAP_BEHIND; + { + if (rStt1 == rStt2) + nRet = POS_OUTSIDE; + else + nRet = POS_OVERLAP_BEHIND; + } } else if( rEnd2 == rStt1 ) nRet = POS_COLLIDE_START; @@ -237,7 +242,12 @@ SwComparePosition ComparePosition( nRet = POS_INSIDE; } else - nRet = POS_OVERLAP_BEHIND; + { + if (nStt1 == nStt2) + nRet = POS_OUTSIDE; + else + nRet = POS_OVERLAP_BEHIND; + } } else if( nEnd2 == nStt1 ) nRet = POS_COLLIDE_START; diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index d32eaf667e..749046780b 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -1188,10 +1188,10 @@ BOOL SwCursor::IsStartWordWT( sal_Int16 nWordType ) const { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); - bRet = pBreakIt->xBreak->isBeginWord( + bRet = pBreakIt->GetBreakIter()->isBeginWord( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos )), nWordType ); @@ -1203,10 +1203,10 @@ BOOL SwCursor::IsEndWordWT( sal_Int16 nWordType ) const { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); - bRet = pBreakIt->xBreak->isEndWord( + bRet = pBreakIt->GetBreakIter()->isEndWord( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ), nWordType ); @@ -1219,10 +1219,10 @@ BOOL SwCursor::IsInWordWT( sal_Int16 nWordType ) const { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); - Boundary aBoundary = pBreakIt->xBreak->getWordBoundary( + Boundary aBoundary = pBreakIt->GetBreakIter()->getWordBoundary( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ), nWordType, @@ -1261,11 +1261,11 @@ BOOL SwCursor::GoStartWordWT( sal_Int16 nWordType ) { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { SwCrsrSaveState aSave( *this ); xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); - nPtPos = (xub_StrLen)pBreakIt->xBreak->getWordBoundary( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->getWordBoundary( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ), nWordType, @@ -1285,11 +1285,11 @@ BOOL SwCursor::GoEndWordWT( sal_Int16 nWordType ) { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { SwCrsrSaveState aSave( *this ); xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); - nPtPos = (xub_StrLen)pBreakIt->xBreak->getWordBoundary( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->getWordBoundary( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ), nWordType, @@ -1310,12 +1310,12 @@ BOOL SwCursor::GoNextWordWT( sal_Int16 nWordType ) { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { SwCrsrSaveState aSave( *this ); xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); - nPtPos = (xub_StrLen)pBreakIt->xBreak->nextWord( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->nextWord( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos, 1 ) ), nWordType ).startPos; @@ -1334,7 +1334,7 @@ BOOL SwCursor::GoPrevWordWT( sal_Int16 nWordType ) { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { SwCrsrSaveState aSave( *this ); xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); @@ -1342,7 +1342,7 @@ BOOL SwCursor::GoPrevWordWT( sal_Int16 nWordType ) if( nPtPos ) --nPtPos; - nPtPos = (xub_StrLen)pBreakIt->xBreak->previousWord( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->previousWord( pTxtNd->GetTxt(), nPtStart, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos, 1 ) ), nWordType ).startPos; @@ -1373,10 +1373,10 @@ BOOL SwCursor::SelectWordWT( sal_Int16 nWordType, const Point* pPt ) } const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); - Boundary aBndry( pBreakIt->xBreak->getWordBoundary( + Boundary aBndry( pBreakIt->GetBreakIter()->getWordBoundary( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ), nWordType, @@ -1408,7 +1408,7 @@ BOOL SwCursor::GoSentence( SentenceMoveType eMoveType ) { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { //mask deleted redlines String sNodeText(pTxtNd->GetTxt()); @@ -1438,14 +1438,14 @@ BOOL SwCursor::GoSentence( SentenceMoveType eMoveType ) switch ( eMoveType ) { case END_SENT: - nPtPos = (xub_StrLen)pBreakIt->xBreak->endOfSentence( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfSentence( sNodeText, nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) )); break; case NEXT_SENT: { - nPtPos = (xub_StrLen)pBreakIt->xBreak->endOfSentence( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfSentence( sNodeText, nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) )); @@ -1455,20 +1455,20 @@ BOOL SwCursor::GoSentence( SentenceMoveType eMoveType ) break; } case START_SENT: - nPtPos = (xub_StrLen)pBreakIt->xBreak->beginOfSentence( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfSentence( sNodeText, nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) )); break; case PREV_SENT: - nPtPos = (xub_StrLen)pBreakIt->xBreak->beginOfSentence( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfSentence( sNodeText, nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) )); if (nPtPos == 0) return FALSE; // the previous sentence is not in this paragraph if (nPtPos > 0) - nPtPos = (xub_StrLen)pBreakIt->xBreak->beginOfSentence( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfSentence( sNodeText, nPtPos - 1, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) )); diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx index 17b13bbdcd..936c966b58 100644 --- a/sw/source/core/doc/dbgoutsw.cxx +++ b/sw/source/core/doc/dbgoutsw.cxx @@ -173,13 +173,13 @@ map<USHORT,String,CompareUShort> & GetItemWhichMap() aItemWhichMap[RES_TXTATR_DUMMY5] = String("TXTATR_DUMMY5", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_CJK_RUBY] = String("TXTATR_CJK_RUBY", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_UNKNOWN_CONTAINER] = String("TXTATR_UNKNOWN_CONTAINER", RTL_TEXTENCODING_ASCII_US); - aItemWhichMap[RES_TXTATR_DUMMY6] = String("TXTATR_DUMMY6", RTL_TEXTENCODING_ASCII_US); - aItemWhichMap[RES_TXTATR_DUMMY7] = String("TXTATR_DUMMY7", RTL_TEXTENCODING_ASCII_US); + aItemWhichMap[RES_TXTATR_META] = String("TXTATR_META", RTL_TEXTENCODING_ASCII_US); + aItemWhichMap[RES_TXTATR_METAFIELD] = String("TXTATR_METAFIELD", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_FIELD] = String("TXTATR_FIELD", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_FLYCNT] = String("TXTATR_FLYCNT", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_FTN] = String("TXTATR_FTN", RTL_TEXTENCODING_ASCII_US); - aItemWhichMap[RES_TXTATR_SOFTHYPH] = String("TXTATR_SOFTHYPH", RTL_TEXTENCODING_ASCII_US); - aItemWhichMap[RES_TXTATR_HARDBLANK] = String("TXTATR_HARDBLANK", RTL_TEXTENCODING_ASCII_US); + aItemWhichMap[RES_TXTATR_DUMMY4] = String("TXTATR_DUMMY4", RTL_TEXTENCODING_ASCII_US); + aItemWhichMap[RES_TXTATR_DUMMY3] = String("TXTATR_DUMMY3", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_DUMMY1] = String("TXTATR_DUMMY1", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_DUMMY2] = String("TXTATR_DUMMY2", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_PARATR_LINESPACING] = String("PARATR_LINESPACING", RTL_TEXTENCODING_ASCII_US); @@ -542,7 +542,7 @@ String lcl_dbg_out(const SwNode & rNode) String aTmpStr; aTmpStr += String("<node ", RTL_TEXTENCODING_ASCII_US); - aTmpStr += String("index =\"", RTL_TEXTENCODING_ASCII_US); + aTmpStr += String("index=\"", RTL_TEXTENCODING_ASCII_US); aTmpStr += String::CreateFromInt32(rNode.GetIndex()); aTmpStr += String("\"", RTL_TEXTENCODING_ASCII_US); @@ -672,7 +672,15 @@ String lcl_dbg_out(const SwNode & rNode) } } else if (rNode.IsStartNode()) - aTmpStr += String("<start/>", RTL_TEXTENCODING_ASCII_US); + { + aTmpStr += String("<start end=\"", RTL_TEXTENCODING_ASCII_US); + + const SwStartNode * pStartNode = dynamic_cast<const SwStartNode *> (&rNode); + if (pStartNode != NULL) + aTmpStr += String::CreateFromInt32(pStartNode->EndOfSectionNode()->GetIndex()); + + aTmpStr += String("\"/>", RTL_TEXTENCODING_ASCII_US); + } else if (rNode.IsEndNode()) aTmpStr += String("<end/>", RTL_TEXTENCODING_ASCII_US); @@ -722,25 +730,68 @@ BOOL lcl_dbg_add_node(const SwNodePtr & pNode, void * pArgs) return TRUE; } -String lcl_dbg_out(SwNodes & rNodes) +void lcl_dbg_nodes_inner(String & aStr, SwNodes & rNodes, ULONG & nIndex) { - String aStr("<nodes>", RTL_TEXTENCODING_ASCII_US); - - for (ULONG i = 0; i < rNodes.Count(); i++) - { - SwNode * pNode = rNodes[i]; - - if (pNode->IsEndNode()) - aStr += String("</nodes>\n", RTL_TEXTENCODING_ASCII_US); - - aStr += lcl_dbg_out(*pNode); - aStr += String("\n", RTL_TEXTENCODING_ASCII_US); + SwNode * pNode = rNodes[nIndex]; + SwStartNode * pStartNode = dynamic_cast<SwStartNode *> (pNode); + + SwNode * pEndNode = NULL; + if (pStartNode != NULL) + pEndNode = pStartNode->EndOfSectionNode(); + + ULONG nCount = rNodes.Count(); + ULONG nStartIndex = nIndex; + + bool bDone = false; + + String aTag; + if (pNode->IsTableNode()) + aTag += String("table", RTL_TEXTENCODING_ASCII_US); + else if (pNode->IsSectionNode()) + aTag += String("section", RTL_TEXTENCODING_ASCII_US); + else + aTag += String("nodes", RTL_TEXTENCODING_ASCII_US); + + aStr += String("<", RTL_TEXTENCODING_ASCII_US); + aStr += aTag; + aStr += String(">", RTL_TEXTENCODING_ASCII_US); + + while (! bDone) + { + if (pNode->IsStartNode() && nIndex != nStartIndex) + lcl_dbg_nodes_inner(aStr, rNodes, nIndex); + else + { + aStr += lcl_dbg_out(*pNode); + aStr += String("\n", RTL_TEXTENCODING_ASCII_US); - if (pNode->IsStartNode()) - aStr += String("<nodes>", RTL_TEXTENCODING_ASCII_US); + nIndex++; + } + + if (pNode == pEndNode || nIndex >= nCount) + bDone = true; + else + pNode = rNodes[nIndex]; } + + aStr += String("</", RTL_TEXTENCODING_ASCII_US); + aStr += aTag; + aStr += String(">\n", RTL_TEXTENCODING_ASCII_US); +} - aStr += String("</nodes>\n", RTL_TEXTENCODING_ASCII_US); +String lcl_dbg_out(SwNodes & rNodes) +{ + String aStr("<nodes-array>", RTL_TEXTENCODING_ASCII_US); + + ULONG nIndex = 0; + ULONG nCount = rNodes.Count(); + + while (nIndex < nCount) + { + lcl_dbg_nodes_inner(aStr, rNodes, nIndex); + } + + aStr += String("</nodes-array>\n", RTL_TEXTENCODING_ASCII_US); return aStr; } @@ -1028,5 +1079,24 @@ SW_DLLPUBLIC const char * dbg_out(const SwFormTokens & rTokens) { return dbg_out(lcl_dbg_out(rTokens)); } + +String lcl_dbg_out(const SwNodeRange & rRange) +{ + String aStr("[", RTL_TEXTENCODING_ASCII_US); + + aStr += lcl_dbg_out(rRange.aStart); + aStr += String(", ", RTL_TEXTENCODING_ASCII_US); + aStr += lcl_dbg_out(rRange.aEnd); + + aStr += String("]" , RTL_TEXTENCODING_ASCII_US); + + return aStr; +} + +SW_DLLPUBLIC const char * dbg_out(const SwNodeRange & rRange) +{ + return dbg_out(lcl_dbg_out(rRange)); +} + #endif // DEBUG diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index cf8c7cdd09..3eb6ffbf62 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -627,7 +627,7 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) { SwCntntNode *pNode = rPos.nNode.GetNode().GetCntntNode(); if(0 == pNode) - return FALSE; + return false; { // Bug 26675: DataChanged vorm loeschen verschicken, dann bekommt @@ -642,7 +642,10 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) ClearRedo(); // einfuegen vom Undo-Object, z.Z. nur beim TextNode if( pNode->IsTxtNode() ) - AppendUndo( pUndo = new SwUndoSplitNode( this, rPos, bChkTableStart )); + { + pUndo = new SwUndoSplitNode( this, rPos, bChkTableStart ); + AppendUndo(pUndo); + } } //JP 28.01.97: Sonderfall fuer SplitNode am Tabellenanfang: @@ -712,7 +715,7 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) if( pUndo ) pUndo->SetTblFlag(); SetModified(); - return TRUE; + return true; } } } @@ -721,7 +724,10 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) SvULongs aBkmkArr( 15, 15 ); _SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), aBkmkArr, SAVEFLY_SPLIT ); - if( 0 != ( pNode = pNode->SplitCntntNode( rPos ) )) + // FIXME: only SwTxtNode has a valid implementation of SplitCntntNode! + ASSERT(pNode->IsTxtNode(), "splitting non-text node?"); + pNode = pNode->SplitCntntNode( rPos ); + if (pNode) { // verschiebe noch alle Bookmarks/TOXMarks/FlyAtCnt if( aBkmkArr.Count() ) @@ -740,7 +746,7 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) } SetModified(); - return TRUE; + return true; } bool SwDoc::AppendTxtNode( SwPosition& rPos ) @@ -783,73 +789,86 @@ bool SwDoc::AppendTxtNode( SwPosition& rPos ) return TRUE; } -bool SwDoc::Insert( const SwPaM &rRg, const String &rStr, bool bHintExpand ) +bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr, + const enum InsertFlags nInsertMode ) { if( DoesUndo() ) + { ClearRedo(); + } - const SwPosition* pPos = rRg.GetPoint(); + const SwPosition& rPos = *rRg.GetPoint(); if( pACEWord ) // Aufnahme in die Autokorrektur { if( 1 == rStr.Len() && pACEWord->IsDeleted() ) - pACEWord->CheckChar( *pPos, rStr.GetChar( 0 ) ); + { + pACEWord->CheckChar( rPos, rStr.GetChar( 0 ) ); + } delete pACEWord, pACEWord = 0; } - SwTxtNode *pNode = pPos->nNode.GetNode().GetTxtNode(); + SwTxtNode *const pNode = rPos.nNode.GetNode().GetTxtNode(); if(!pNode) - return FALSE; + { + return false; + } - const USHORT nInsMode = bHintExpand ? INS_EMPTYEXPAND - : INS_NOHINTEXPAND; SwDataChanged aTmp( rRg, 0 ); if( !DoesUndo() || !DoesGroupUndo() ) { - pNode->Insert( rStr, pPos->nContent, nInsMode ); + pNode->InsertText( rStr, rPos.nContent, nInsertMode ); if( DoesUndo() ) - AppendUndo( new SwUndoInsert( pPos->nNode, - pPos->nContent.GetIndex(), rStr.Len() )); + { + SwUndoInsert * const pUndo( new SwUndoInsert( + rPos.nNode, rPos.nContent.GetIndex(), rStr.Len(), nInsertMode)); + AppendUndo(pUndo); + } } else { // ist Undo und Gruppierung eingeschaltet, ist alles anders ! - USHORT nUndoSize = pUndos->Count(); - xub_StrLen nInsPos = pPos->nContent.GetIndex(); SwUndoInsert * pUndo = NULL; // #111827# - CharClass& rCC = GetAppCharClass(); + // don't group the start if hints at the start should be expanded + if (!(nInsertMode & IDocumentContentOperations::INS_FORCEHINTEXPAND)) // -> #111827# - bool bNewUndo = false; - if( 0 == nUndoSize) - bNewUndo = true; - else { - pUndo = (SwUndoInsert*)(*pUndos)[ --nUndoSize ]; - - switch (pUndo->GetId()) + USHORT const nUndoSize = pUndos->Count(); + if (0 != nUndoSize) { - case UNDO_INSERT: - case UNDO_TYPING: - bNewUndo = !pUndo->CanGrouping( *pPos ); + SwUndo * const pLastUndo = (*pUndos)[ nUndoSize - 1 ]; - break; + switch (pLastUndo->GetId()) + { + case UNDO_INSERT: + case UNDO_TYPING: + if (static_cast<SwUndoInsert*>(pLastUndo) + ->CanGrouping( rPos )) + { + pUndo = static_cast<SwUndoInsert*>(pLastUndo); + } + break; - default: - bNewUndo = true; + default: + break; + } } } // <- #111827# - if (bNewUndo) + CharClass const& rCC = GetAppCharClass(); + xub_StrLen nInsPos = rPos.nContent.GetIndex(); + + if (!pUndo) { - pUndo = new SwUndoInsert( pPos->nNode, nInsPos, 0, + pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 0, nInsertMode, !rCC.isLetterNumeric( rStr, 0 ) ); AppendUndo( pUndo ); } - pNode->Insert( rStr, pPos->nContent, nInsMode ); + pNode->InsertText( rStr, rPos.nContent, nInsertMode ); for( xub_StrLen i = 0; i < rStr.Len(); ++i ) { @@ -857,7 +876,7 @@ bool SwDoc::Insert( const SwPaM &rRg, const String &rStr, bool bHintExpand ) // wenn CanGrouping() TRUE returnt, ist schon alles erledigt if( !pUndo->CanGrouping( rStr.GetChar( i ) )) { - pUndo = new SwUndoInsert( pPos->nNode, nInsPos, 1, + pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 1, nInsertMode, !rCC.isLetterNumeric( rStr, i ) ); AppendUndo( pUndo ); } @@ -866,16 +885,21 @@ bool SwDoc::Insert( const SwPaM &rRg, const String &rStr, bool bHintExpand ) if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() )) { - SwPaM aPam( pPos->nNode, aTmp.GetCntnt(), - pPos->nNode, pPos->nContent.GetIndex()); + SwPaM aPam( rPos.nNode, aTmp.GetCntnt(), + rPos.nNode, rPos.nContent.GetIndex()); if( IsRedlineOn() ) - AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); + { + AppendRedline( + new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); + } else + { SplitRedline( aPam ); + } } SetModified(); - return TRUE; + return true; } SwFlyFrmFmt* SwDoc::_InsNoTxtNode( const SwPosition& rPos, SwNoTxtNode* pNode, @@ -1506,7 +1530,7 @@ BOOL SwDoc::RemoveInvisibleContent() ( 1 == pTxtNd->EndOfSectionIndex() - pTxtNd->GetIndex() && !GetNodes()[ pTxtNd->GetIndex() - 1 ]->GetTxtNode() ) ) { - Delete( aPam ); + DeleteRange( aPam ); } else { @@ -1542,7 +1566,7 @@ BOOL SwDoc::RemoveInvisibleContent() ( 1 == pTxtNd->EndOfSectionIndex() - pTxtNd->GetIndex() && !GetNodes()[ pTxtNd->GetIndex() - 1 ]->GetTxtNode() ) ) { - Delete( aPam ); + DeleteRange( aPam ); } else { @@ -1628,7 +1652,7 @@ BOOL SwDoc::RemoveInvisibleContent() &aPam.GetPoint()->nNode ); aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); - Delete( aPam ); + DeleteRange( aPam ); } else { @@ -1712,7 +1736,8 @@ BOOL SwDoc::ConvertFieldsToText() //now remove the field and insert the string SwPaM aPam1(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); aPam1.Move(); - Insert( aPam1, sText, true );//insert first to keep the field's attributes + //insert first to keep the field's attributes + InsertString( aPam1, sText ); SwPaM aPam2(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); aPam2.SetMark(); aPam2.Move(); @@ -1918,24 +1943,19 @@ String SwDoc::GetPaMDescr(const SwPaM & rPam) const // -> #111840# SwField * SwDoc::GetField(const SwPosition & rPos) { - SwField * pResult = NULL; - - SwTxtFld * pAttr = rPos.nNode.GetNode().GetTxtNode()-> - GetTxtFld(rPos.nContent); - - if (pAttr) - pResult = (SwField *) pAttr->GetFld().GetFld(); + SwTxtFld * const pAttr = GetTxtFld(rPos); - return pResult; + return (pAttr) ? const_cast<SwField *>( pAttr->GetFld().GetFld() ) : 0; } SwTxtFld * SwDoc::GetTxtFld(const SwPosition & rPos) { - SwTxtNode *pNode = rPos.nNode.GetNode().GetTxtNode(); - if( pNode ) - return pNode->GetTxtFld( rPos.nContent ); - else - return 0; + SwTxtNode * const pNode = rPos.nNode.GetNode().GetTxtNode(); + + return (pNode) + ? static_cast<SwTxtFld*>( pNode->GetTxtAttrForCharAt( + rPos.nContent.GetIndex(), RES_TXTATR_FIELD) ) + : 0; } // <- #111840# diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 836cbf0c37..80973abeca 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -995,6 +995,14 @@ SaveBookmark::SaveBookmark( { m_aShortName = pBookmark->GetShortName(); m_aCode = pBookmark->GetKeyCode(); + + ::sfx2::Metadatable * const pMetadatable( + const_cast< ::sfx2::Metadatable * >( // CreateUndo should be const? + dynamic_cast< ::sfx2::Metadatable const* >(pBookmark))); + if (pMetadatable) + { + m_pMetadataUndo = pMetadatable->CreateUndo(); + } } m_nNode1 = rBkmk.GetMarkPos().nNode.GetIndex(); m_nCntnt1 = rBkmk.GetMarkPos().nContent.GetIndex(); @@ -1073,6 +1081,16 @@ void SaveBookmark::SetInDoc( { pBookmark->SetKeyCode(m_aCode); pBookmark->SetShortName(m_aShortName); + if (m_pMetadataUndo) + { + ::sfx2::Metadatable * const pMeta( + dynamic_cast< ::sfx2::Metadatable* >(pBookmark)); + OSL_ENSURE(pMeta, "metadata undo, but not metadatable?"); + if (pMeta) + { + pMeta->RestoreMetadata(m_pMetadataUndo); + } + } } } } diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index 1a80dd6431..5fa7731fcb 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -1196,7 +1196,8 @@ BOOL SwCompareLine::ChangesInLine( const SwCompareLine& rLine, SwPaM aCpyPam( rSrcNd, nStt ); aCpyPam.SetMark(); aCpyPam.GetPoint()->nContent = nSEnd; - aCpyPam.GetDoc()->Copy( aCpyPam, *aPam.GetPoint(), false ); + aCpyPam.GetDoc()->CopyRange( aCpyPam, *aPam.GetPoint(), + false ); pDoc->DoUndo( bUndo ); } @@ -1624,7 +1625,9 @@ USHORT _SaveMergeRedlines::InsertRedline( FNInsUndo pFn ) RedlineMode_t eOld = pDoc->GetRedlineMode(); pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); - pSrcRedl->GetDoc()->Copy( *(SwPaM*)pSrcRedl, *pDestRedl->GetPoint(), false ); + pSrcRedl->GetDoc()->CopyRange( + *const_cast<SwPaM*>(static_cast<const SwPaM*>(pSrcRedl)), + *pDestRedl->GetPoint(), false ); pDoc->SetRedlineMode_intern( eOld ); pDoc->DoUndo( bUndo ); diff --git a/sw/source/core/doc/docdde.cxx b/sw/source/core/doc/docdde.cxx index 02edef612c..2454a26602 100644 --- a/sw/source/core/doc/docdde.cxx +++ b/sw/source/core/doc/docdde.cxx @@ -62,16 +62,18 @@ using namespace ::com::sun::star; namespace { - static ::sw::mark::DdeBookmark* lcl_FindDdeBookmark(const IDocumentMarkAccess& rMarkAccess, const String& rName) + static ::sw::mark::DdeBookmark* lcl_FindDdeBookmark(const IDocumentMarkAccess& rMarkAccess, const String& rName, bool bCaseSensitive) { //Iterating over all bookmarks, checking DdeBookmarks - const String sNameLc = GetAppCharClass().lower(rName); + const ::rtl::OUString sNameLc = bCaseSensitive ? rName : GetAppCharClass().lower(rName); for(IDocumentMarkAccess::const_iterator_t ppMark = rMarkAccess.getMarksBegin(); ppMark != rMarkAccess.getMarksEnd(); ppMark++) { ::sw::mark::DdeBookmark* const pBkmk = dynamic_cast< ::sw::mark::DdeBookmark*>(ppMark->get()); - if(pBkmk && GetAppCharClass().lower(pBkmk->GetName()) == sNameLc) + if(pBkmk && + (bCaseSensitive && (pBkmk->GetName() == sNameLc)) || + (!bCaseSensitive && GetAppCharClass().lower(pBkmk->GetName()) == String( sNameLc ))) return pBkmk; } return NULL; @@ -89,13 +91,14 @@ struct _FindItem {} }; -BOOL lcl_FindSection( const SwSectionFmtPtr& rpSectFmt, void* pArgs ) +BOOL lcl_FindSection( const SwSectionFmtPtr& rpSectFmt, void* pArgs, bool bCaseSensitive ) { SwSection* pSect = rpSectFmt->GetSection(); if( pSect ) { - String sNm( GetAppCharClass().lower( pSect->GetName() )); - if( sNm.Equals( ((_FindItem*)pArgs)->rItem )) + String sNm( bCaseSensitive ? pSect->GetName() : GetAppCharClass().lower( pSect->GetName() )); + String sCompare( bCaseSensitive ? ((_FindItem*)pArgs)->rItem : GetAppCharClass().lower( ((_FindItem*)pArgs)->rItem )); + if( sNm == sCompare ) { // gefunden, als erfrage die Daten const SwNodeIndex* pIdx; @@ -112,6 +115,14 @@ BOOL lcl_FindSection( const SwSectionFmtPtr& rpSectFmt, void* pArgs ) } return TRUE; // dann weiter } +BOOL lcl_FindSectionCaseSensitive( const SwSectionFmtPtr& rpSectFmt, void* pArgs ) +{ + return lcl_FindSection( rpSectFmt, pArgs, true ); +} +BOOL lcl_FindSectionCaseInsensitive( const SwSectionFmtPtr& rpSectFmt, void* pArgs ) +{ + return lcl_FindSection( rpSectFmt, pArgs, false ); +} @@ -143,20 +154,30 @@ BOOL lcl_FindTable( const SwFrmFmtPtr& rpTableFmt, void* pArgs ) bool SwDoc::GetData( const String& rItem, const String& rMimeType, uno::Any & rValue ) const { - ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem); - if(pBkmk) return SwServerObject(*pBkmk).GetData(rValue, rMimeType); - - // haben wir ueberhaupt das Item vorraetig? - String sItem(GetAppCharClass().lower(rItem)); - _FindItem aPara( sItem ); - ((SwSectionFmts&)*pSectionFmtTbl).ForEach( 0, pSectionFmtTbl->Count(), - lcl_FindSection, &aPara ); - if( aPara.pSectNd ) + //search for bookmarks and sections case senstive at first. If nothing is found then try again case insensitive + bool bCaseSensitive = true; + while( true ) { - // gefunden, als erfrage die Daten - return SwServerObject( *aPara.pSectNd ).GetData( rValue, rMimeType ); + ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem, bCaseSensitive); + if(pBkmk) + return SwServerObject(*pBkmk).GetData(rValue, rMimeType); + + // haben wir ueberhaupt das Item vorraetig? + String sItem( bCaseSensitive ? rItem : GetAppCharClass().lower(rItem)); + _FindItem aPara( sItem ); + ((SwSectionFmts&)*pSectionFmtTbl).ForEach( 0, pSectionFmtTbl->Count(), + bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara ); + if( aPara.pSectNd ) + { + // gefunden, als erfrage die Daten + return SwServerObject( *aPara.pSectNd ).GetData( rValue, rMimeType ); + } + if( !bCaseSensitive ) + break; + bCaseSensitive = false; } + _FindItem aPara( GetAppCharClass().lower( rItem )); ((SwFrmFmts*)pTblFrmFmtTbl)->ForEach( 0, pTblFrmFmtTbl->Count(), lcl_FindTable, &aPara ); if( aPara.pTblNd ) @@ -172,19 +193,30 @@ bool SwDoc::GetData( const String& rItem, const String& rMimeType, bool SwDoc::SetData( const String& rItem, const String& rMimeType, const uno::Any & rValue ) { - ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem); - if(pBkmk) return SwServerObject(*pBkmk).SetData(rMimeType, rValue); - - // haben wir ueberhaupt das Item vorraetig? - String sItem(GetAppCharClass().lower(rItem)); - _FindItem aPara( sItem ); - pSectionFmtTbl->ForEach( 0, pSectionFmtTbl->Count(), lcl_FindSection, &aPara ); - if( aPara.pSectNd ) + //search for bookmarks and sections case senstive at first. If nothing is found then try again case insensitive + bool bCaseSensitive = true; + while( true ) { - // gefunden, als erfrage die Daten - return SwServerObject( *aPara.pSectNd ).SetData( rMimeType, rValue ); + ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem, bCaseSensitive); + if(pBkmk) + return SwServerObject(*pBkmk).SetData(rMimeType, rValue); + + // haben wir ueberhaupt das Item vorraetig? + String sItem( bCaseSensitive ? rItem : GetAppCharClass().lower(rItem)); + _FindItem aPara( sItem ); + pSectionFmtTbl->ForEach( 0, pSectionFmtTbl->Count(), bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara ); + if( aPara.pSectNd ) + { + // gefunden, als erfrage die Daten + return SwServerObject( *aPara.pSectNd ).SetData( rMimeType, rValue ); + } + if( !bCaseSensitive ) + break; + bCaseSensitive = false; } + String sItem(GetAppCharClass().lower(rItem)); + _FindItem aPara( sItem ); pTblFrmFmtTbl->ForEach( 0, pTblFrmFmtTbl->Count(), lcl_FindTable, &aPara ); if( aPara.pTblNd ) { @@ -200,31 +232,42 @@ bool SwDoc::SetData( const String& rItem, const String& rMimeType, { SwServerObject* pObj = NULL; - // bookmarks - ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem); - if(pBkmk && pBkmk->IsExpanded() - && (0 == (pObj = pBkmk->GetRefObject()))) + //search for bookmarks and sections case senstive at first. If nothing is found then try again case insensitive + bool bCaseSensitive = true; + while( true ) { - // mark found, but no link yet -> create hotlink - pObj = new SwServerObject(*pBkmk); - pBkmk->SetRefObject(pObj); - GetLinkManager().InsertServer(pObj); - } - if(pObj) return pObj; - - _FindItem aPara(GetAppCharClass().lower(rItem)); - // sections - ((SwSectionFmts&)*pSectionFmtTbl).ForEach(0, pSectionFmtTbl->Count(), lcl_FindSection, &aPara); - if(aPara.pSectNd - && (0 == (pObj = aPara.pSectNd->GetSection().GetObject()))) - { - // section found, but no link yet -> create hotlink - pObj = new SwServerObject( *aPara.pSectNd ); - aPara.pSectNd->GetSection().SetRefObject( pObj ); - GetLinkManager().InsertServer(pObj); + // bookmarks + ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem, bCaseSensitive); + if(pBkmk && pBkmk->IsExpanded() + && (0 == (pObj = pBkmk->GetRefObject()))) + { + // mark found, but no link yet -> create hotlink + pObj = new SwServerObject(*pBkmk); + pBkmk->SetRefObject(pObj); + GetLinkManager().InsertServer(pObj); + } + if(pObj) + return pObj; + + _FindItem aPara(bCaseSensitive ? rItem : GetAppCharClass().lower(rItem)); + // sections + ((SwSectionFmts&)*pSectionFmtTbl).ForEach(0, pSectionFmtTbl->Count(), bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara); + if(aPara.pSectNd + && (0 == (pObj = aPara.pSectNd->GetSection().GetObject()))) + { + // section found, but no link yet -> create hotlink + pObj = new SwServerObject( *aPara.pSectNd ); + aPara.pSectNd->GetSection().SetRefObject( pObj ); + GetLinkManager().InsertServer(pObj); + } + if(pObj) + return pObj; + if( !bCaseSensitive ) + break; + bCaseSensitive = false; } - if(pObj) return pObj; + _FindItem aPara( GetAppCharClass().lower(rItem) ); // tables ((SwFrmFmts*)pTblFrmFmtTbl)->ForEach(0, pTblFrmFmtTbl->Count(), lcl_FindTable, &aPara); if(aPara.pTblNd @@ -329,31 +372,39 @@ BOOL SwDoc::SelectServerObj( const String& rStr, SwPaM*& rpPam, return FALSE; } - ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, sItem); - if(pBkmk) + //search for bookmarks and sections case senstive at first. If nothing is found then try again case insensitive + bool bCaseSensitive = true; + while( true ) { - if(pBkmk->IsExpanded()) - rpPam = new SwPaM( - pBkmk->GetMarkPos(), - pBkmk->GetOtherMarkPos()); - return static_cast<bool>(rpPam); - } + ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, sItem, bCaseSensitive); + if(pBkmk) + { + if(pBkmk->IsExpanded()) + rpPam = new SwPaM( + pBkmk->GetMarkPos(), + pBkmk->GetOtherMarkPos()); + return static_cast<bool>(rpPam); + } - // alte "Mechanik" - rCC.toLower( sItem ); - _FindItem aPara( sItem ); + // + _FindItem aPara( bCaseSensitive ? sItem : rCC.lower( sItem ) ); - if( pSectionFmtTbl->Count() ) - { - ((SwSectionFmts&)*pSectionFmtTbl).ForEach( 0, pSectionFmtTbl->Count(), - lcl_FindSection, &aPara ); - if( aPara.pSectNd ) + if( pSectionFmtTbl->Count() ) { - rpRange = new SwNodeRange( *aPara.pSectNd, 1, - *aPara.pSectNd->EndOfSectionNode() ); - return TRUE; + ((SwSectionFmts&)*pSectionFmtTbl).ForEach( 0, pSectionFmtTbl->Count(), + bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara ); + if( aPara.pSectNd ) + { + rpRange = new SwNodeRange( *aPara.pSectNd, 1, + *aPara.pSectNd->EndOfSectionNode() ); + return TRUE; + } } + if( !bCaseSensitive ) + break; + bCaseSensitive = false; } return FALSE; } + diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx index 477d70e6af..88176f79c8 100644 --- a/sw/source/core/doc/docdesc.cxx +++ b/sw/source/core/doc/docdesc.cxx @@ -70,7 +70,7 @@ #include <fldbas.hxx> #include <swwait.hxx> #include <GetMetricVal.hxx> - +#include <svtools/syslocale.hxx> #ifndef _STATSTR_HRC #include <statstr.hrc> #endif @@ -111,7 +111,7 @@ static void lcl_DefaultPageFmt( sal_uInt16 nPoolFmtId, nMinRight = nMinTop = nMinBottom = GetMetricVal( CM_1 ); nMinLeft = nMinRight * 2; } - else if( MEASURE_METRIC == GetAppLocaleData().getMeasurementSystemEnum() ) + else if( MEASURE_METRIC == SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ) { nMinTop = nMinBottom = nMinLeft = nMinRight = 1134; //2 Zentimeter } diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 620424ac8a..f741f2fc04 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -163,24 +163,11 @@ SV_DECL_PTRARR_DEL( _SaveRedlines, _SaveRedline*, 0, 4 ) SV_IMPL_VARARR( _SaveFlyArr, _SaveFly ) SV_IMPL_PTRARR( _SaveRedlines, _SaveRedline* ) -sal_Bool lcl_MayOverwrite( const SwTxtNode *pNode, const xub_StrLen nPos ) +bool lcl_MayOverwrite( const SwTxtNode *pNode, const xub_StrLen nPos ) { - sal_Bool bRet = sal_True; - const SwTxtAttr *pHt; sal_Unicode cChr = pNode->GetTxt().GetChar( nPos ); - if( ( CH_TXTATR_BREAKWORD == cChr || CH_TXTATR_INWORD == cChr ) && - 0 != (pHt = pNode->GetTxtAttr( nPos )) ) - switch( pHt->Which() ) - { - case RES_TXTATR_FLYCNT: - case RES_TXTATR_FTN: - case RES_TXTATR_FIELD: - case RES_TXTATR_REFMARK: - case RES_TXTATR_TOXMARK: - bRet = sal_False; - break; - } - return bRet; + return !( ( CH_TXTATR_BREAKWORD == cChr || CH_TXTATR_INWORD == cChr ) && + (0 != pNode->GetTxtAttrForCharAt( nPos ) ) ); } void lcl_SkipAttr( const SwTxtNode *pNode, SwIndex &rIdx, xub_StrLen &rStart ) @@ -421,7 +408,7 @@ bool lcl_SaveFtn( const SwNodeIndex& rSttNd, const SwNodeIndex& rEndNd, { SwTxtNode& rTxtNd = (SwTxtNode&)pSrch->GetTxtNode(); SwIndex aIdx( &rTxtNd, nFtnSttIdx ); - rTxtNd.Erase( aIdx, 1 ); + rTxtNd.EraseText( aIdx, 1 ); } else { @@ -449,7 +436,7 @@ bool lcl_SaveFtn( const SwNodeIndex& rSttNd, const SwNodeIndex& rEndNd, // dann weg damit SwTxtNode& rTxtNd = (SwTxtNode&)pSrch->GetTxtNode(); SwIndex aIdx( &rTxtNd, nFtnSttIdx ); - rTxtNd.Erase( aIdx, 1 ); + rTxtNd.EraseText( aIdx, 1 ); } else { @@ -764,64 +751,6 @@ void SwDoc::DeleteSection( SwNode *pNode ) } - -/************************************************************************* -|* SwDoc::Insert(char) -|* Beschreibung Zeichen einfuegen -*************************************************************************/ - -bool SwDoc::Insert( const SwPaM &rRg, sal_Unicode c ) -{ - if( DoesUndo() ) - ClearRedo(); - - const SwPosition & rPos = *rRg.GetPoint(); - - if( pACEWord ) // Aufnahme in die Autokorrektur - { - if( pACEWord->IsDeleted() ) - pACEWord->CheckChar( rPos, c ); - delete pACEWord, pACEWord = 0; - } - SwTxtNode *pNode = rPos.nNode.GetNode().GetTxtNode(); - if(!pNode) - return sal_False; - sal_Bool bInsOneChar = sal_True; - - SwDataChanged aTmp( rRg, 0 ); - - pNode->Insert( c, rPos.nContent ); - - if ( DoesUndo() ) - { - sal_uInt16 nUndoSize = pUndos->Count(); - SwUndo * pUndo; - if( DoesGroupUndo() && bInsOneChar && nUndoSize-- && - UNDO_INSERT == ( pUndo = (*pUndos)[ nUndoSize ])->GetId() && - ((SwUndoInsert*)pUndo)->CanGrouping( rPos, c )) - ; // wenn CanGrouping() sal_True returnt, ist schon alles erledigt - else - AppendUndo( new SwUndoInsert( rPos.nNode, - rPos.nContent.GetIndex(), 1, - !GetAppCharClass().isLetterNumeric( - pNode->GetTxt(), - rPos.nContent.GetIndex() - 1 ))); - } - - if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() )) - { - SwPaM aPam( rPos.nNode, rPos.nContent.GetIndex() - 1, - rPos.nNode, rPos.nContent.GetIndex() ); - if( IsRedlineOn() ) - AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); - else - SplitRedline( aPam ); - } - - SetModified(); - return sal_True; -} - void SwDoc::SetModified(SwPaM &rPaM) { SwDataChanged aTmp( rPaM, 0 ); @@ -829,91 +758,8 @@ void SwDoc::SetModified(SwPaM &rPaM) } /************************************************************************* -|* SwDoc::Overwrite(char) -|* Beschreibung Zeichen ueberschreiben -*************************************************************************/ - -bool SwDoc::Overwrite( const SwPaM &rRg, sal_Unicode c ) -{ - SwPosition& rPt = *(SwPosition*)rRg.GetPoint(); - if( pACEWord ) // Aufnahme in die Autokorrektur - { - pACEWord->CheckChar( rPt, c ); - delete pACEWord, pACEWord = 0; - } - - SwTxtNode *pNode = rPt.nNode.GetNode().GetTxtNode(); - if(!pNode) - return sal_False; - - sal_uInt16 nOldAttrCnt = pNode->GetpSwpHints() - ? pNode->GetpSwpHints()->Count() : 0; - SwDataChanged aTmp( rRg, 0 ); - SwIndex& rIdx = rPt.nContent; - xub_StrLen nStart = rIdx.GetIndex(); - - // hinter das Zeichen (zum aufspannen der Attribute !!) - if( nStart < pNode->GetTxt().Len() ) - lcl_SkipAttr( pNode, rIdx, nStart ); - - if( DoesUndo() ) - { - ClearRedo(); - sal_uInt16 nUndoSize = pUndos->Count(); - SwUndo * pUndo; - if( DoesGroupUndo() && nUndoSize-- && - UNDO_OVERWRITE == ( pUndo = (*pUndos)[ nUndoSize ])->GetId() && - ((SwUndoOverwrite*)pUndo)->CanGrouping( this, rPt, c )) - ;// wenn CanGrouping() sal_True returnt, ist schon alles erledigt - else - AppendUndo( new SwUndoOverwrite( this, rPt, c )); - } - else - { - BOOL bOldExpFlg = pNode->IsIgnoreDontExpand(); - pNode->SetIgnoreDontExpand( TRUE ); - - // hinter das Zeichen (zum aufspannen der Attribute !!) - if( nStart < pNode->GetTxt().Len() ) - rIdx++; - pNode->Insert( c, rIdx ); - if( nStart+1 < rIdx.GetIndex() ) - { - rIdx = nStart; - pNode->Erase( rIdx, 1 ); - rIdx++; - } - pNode->SetIgnoreDontExpand( bOldExpFlg ); - } - - sal_uInt16 nNewAttrCnt = pNode->GetpSwpHints() - ? pNode->GetpSwpHints()->Count() : 0; - if( nOldAttrCnt != nNewAttrCnt ) - { - SwUpdateAttr aHint( 0, 0, 0 ); - SwClientIter aIter( *pNode ); - SwClient* pGTO = aIter.First(TYPE( SwCrsrShell )); - while( pGTO ) - { - pGTO->Modify( 0, &aHint ); - pGTO = aIter.Next(); - } - } - - if( !DoesUndo() && !IsIgnoreRedline() && GetRedlineTbl().Count() ) - { - SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() ); - DeleteRedline( aPam, true, USHRT_MAX ); - } - else if( IsRedlineOn() ) - { - SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() ); - AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); - } - - SetModified(); - return sal_True; -} + * SwDoc::Overwrite() + ************************************************************************/ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) { @@ -949,8 +795,11 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) for( xub_StrLen nCnt = 0; nCnt < rStr.Len(); ++nCnt ) { // hinter das Zeichen (zum aufspannen der Attribute !!) - if( (nStart = rIdx.GetIndex()) < pNode->GetTxt().Len() ) + nStart = rIdx.GetIndex(); + if ( nStart < pNode->GetTxt().Len() ) + { lcl_SkipAttr( pNode, rIdx, nStart ); + } c = rStr.GetChar( nCnt ); if( DoesUndo() ) { @@ -969,11 +818,11 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) // hinter das Zeichen (zum Aufspannen der Attribute !!) if( nStart < pNode->GetTxt().Len() ) rIdx++; - pNode->Insert( c, rIdx ); + pNode->InsertText( c, rIdx, INS_EMPTYEXPAND ); if( nStart+1 < rIdx.GetIndex() ) { rIdx = nStart; - pNode->Erase( rIdx, 1 ); + pNode->EraseText( rIdx, 1 ); rIdx++; } } @@ -1001,6 +850,8 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) } else if( IsRedlineOn() ) { + // FIXME: this redline is WRONG: there is no DELETE, and the skipped + // characters are also included in aPam SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() ); AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); } @@ -1017,7 +868,7 @@ bool SwDoc::MoveAndJoin( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) sal_Bool bOneNode = rPaM.GetPoint()->nNode == rPaM.GetMark()->nNode; aIdx--; // vor den Move Bereich !! - sal_Bool bRet = Move( rPaM, rPos, eMvFlags ); + bool bRet = MoveRange( rPaM, rPos, eMvFlags ); if( bRet && !bOneNode ) { if( bJoinTxt ) @@ -1036,12 +887,15 @@ bool SwDoc::MoveAndJoin( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) return bRet; } -bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) +// mst: it seems that this is mostly used by SwDoc internals; the only +// way to call this from the outside seems to be the special case in +// SwDoc::CopyRange (but i have not managed to actually hit that case) +bool SwDoc::MoveRange( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) { // keine Moves-Abfangen const SwPosition *pStt = rPaM.Start(), *pEnd = rPaM.End(); if( !rPaM.HasMark() || *pStt >= *pEnd || (*pStt <= rPos && rPos < *pEnd)) - return sal_False; + return false; // sicher die absatzgebundenen Flys, damit sie verschoben werden koennen. _SaveFlyArr aSaveFlyArr; @@ -1088,7 +942,7 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) } sal_Bool bSplit = sal_False; - SwPaM * pSavePam = new SwPaM( rPos, rPos ); + SwPaM aSavePam( rPos, rPos ); // stelle den SPoint an den Anfang vom Bereich (Definition) if( rPaM.GetPoint() == pEnd ) @@ -1116,7 +970,7 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) _SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), aBkmkArr, SAVEFLY_SPLIT ); - pTNd = (SwTxtNode*)pTNd->SplitCntntNode( rPos ); + pTNd = static_cast<SwTxtNode*>(pTNd->SplitCntntNode( rPos )); if( aBkmkArr.Count() ) _RestoreCntntIdx( this, aBkmkArr, rPos.nNode.GetIndex()-1, 0, sal_True ); @@ -1132,9 +986,11 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) // setze den Pam um einen "Inhalt" zurueck; dadurch steht er immer // ausserhalb des manipulierten Bereiches. Falls kein Inhalt mehr vor- // handen, dann auf den StartNode (es ist immer einer vorhanden !!!) - sal_Bool bNullCntnt = !pSavePam->Move( fnMoveBackward, fnGoCntnt ); + sal_Bool bNullCntnt = !aSavePam.Move( fnMoveBackward, fnGoCntnt ); if( bNullCntnt ) - pSavePam->GetPoint()->nNode--; + { + aSavePam.GetPoint()->nNode--; + } // kopiere alle Bookmarks, die im Move Bereich stehen in ein // Array, das alle Angaben auf die Position als Offset speichert. @@ -1151,31 +1007,33 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) // Bereich mehr existiert, ist das immernoch ein gueltiger Move! if( *rPaM.GetPoint() != *rPaM.GetMark() ) { - // jetzt kommt das eigentliche Verschieben - GetNodes().Move( rPaM, rPos, GetNodes() ); + // now do the actual move + GetNodes().MoveRange( rPaM, rPos, GetNodes() ); - if( rPaM.HasMark() ) // es wurde kein Move ausgefuehrt !! + // after a MoveRange() the Mark is deleted + if ( rPaM.HasMark() ) // => no Move occurred! { - delete pSavePam; delete pUndoMove; - return sal_False; // Nach einem Move() ist der GetMark geloescht + return false; } } else rPaM.DeleteMark(); - ASSERT( *pSavePam->GetMark() == rPos || - ( pSavePam->GetMark()->nNode.GetNode().GetCntntNode() == NULL ), + ASSERT( *aSavePam.GetMark() == rPos || + ( aSavePam.GetMark()->nNode.GetNode().GetCntntNode() == NULL ), "PaM wurde nicht verschoben, am Anfang/Ende keine ContentNodes?" ); - *pSavePam->GetMark() = rPos; + *aSavePam.GetMark() = rPos; rPaM.SetMark(); // um den neuen Bereich eine Sel. aufspannen - pTNd = pSavePam->GetNode()->GetTxtNode(); + pTNd = aSavePam.GetNode()->GetTxtNode(); if( DoesUndo() ) { // korrigiere erstmal den Content vom SavePam if( bNullCntnt ) - pSavePam->GetPoint()->nContent = 0; + { + aSavePam.GetPoint()->nContent = 0; + } // die Methode SwEditShell::Move() fuegt nach dem Move den Text-Node // zusammen, in dem der rPaM steht. Wurde der Inhalt nach hinten @@ -1189,7 +1047,7 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) bCorrSavePam = bCorrSavePam && 0 != ( pPamTxtNd = rPaM.GetNode()->GetTxtNode() ) && pPamTxtNd->CanJoinNext() - && *rPaM.GetPoint() <= *pSavePam->GetPoint(); + && (*rPaM.GetPoint() <= *aSavePam.GetPoint()); // muessen am SavePam 2 Nodes zusammengefasst werden ?? if( bJoin && pTNd->CanJoinNext() ) @@ -1198,16 +1056,20 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) // kein temp. sdbcx::Index bei && // es sollten wohl nur die Indexwerte verglichen werden. if( bCorrSavePam && rPaM.GetPoint()->nNode.GetIndex()+1 == - pSavePam->GetPoint()->nNode.GetIndex() ) - pSavePam->GetPoint()->nContent += pPamTxtNd->Len(); + aSavePam.GetPoint()->nNode.GetIndex() ) + { + aSavePam.GetPoint()->nContent += pPamTxtNd->Len(); + } bJoin = sal_False; } // else if( !bCorrSavePam && !pSavePam->Move( fnMoveForward, fnGoCntnt )) - else if( !pSavePam->Move( fnMoveForward, fnGoCntnt )) - pSavePam->GetPoint()->nNode++; + else if ( !aSavePam.Move( fnMoveForward, fnGoCntnt ) ) + { + aSavePam.GetPoint()->nNode++; + } // zwischen SPoint und GetMark steht jetzt der neu eingefuegte Bereich - pUndoMove->SetDestRange( *pSavePam, *rPaM.GetPoint(), + pUndoMove->SetDestRange( aSavePam, *rPaM.GetPoint(), bJoin, bCorrSavePam ); AppendUndo( pUndoMove ); } @@ -1229,15 +1091,17 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) } if( bNullCntnt ) { - pSavePam->GetPoint()->nNode++; - pSavePam->GetPoint()->nContent.Assign( pSavePam->GetCntntNode(), 0 ); + aSavePam.GetPoint()->nNode++; + aSavePam.GetPoint()->nContent.Assign( aSavePam.GetCntntNode(), 0 ); } else if( bRemove ) // No move forward after joining with next paragraph - pSavePam->Move( fnMoveForward, fnGoCntnt ); + { + aSavePam.Move( fnMoveForward, fnGoCntnt ); + } } // setze jetzt wieder die text::Bookmarks in das Dokument - *rPaM.GetMark() = *pSavePam->Start(); + *rPaM.GetMark() = *aSavePam.Start(); for( ::std::vector< ::sw::mark::SaveBookmark>::iterator pBkmk = aSaveBkmks.begin(); pBkmk != aSaveBkmks.end(); @@ -1246,15 +1110,16 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) this, rPaM.GetMark()->nNode, &rPaM.GetMark()->nContent); - *rPaM.GetPoint() = *pSavePam->End(); + *rPaM.GetPoint() = *aSavePam.End(); // verschiebe die Flys an die neue Position _RestFlyInRange( aSaveFlyArr, rPaM.Start()->nNode, &(rPos.nNode) ); // restore redlines (if DOC_MOVEREDLINES is used) if( aSaveRedl.Count() ) - lcl_RestoreRedlines( this, *pSavePam->Start(), aSaveRedl ); - delete pSavePam; // Better to delete an object _after_ the last use + { + lcl_RestoreRedlines( this, *aSavePam.Start(), aSaveRedl ); + } if( bUpdateFtn ) { @@ -1268,10 +1133,11 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) } SetModified(); - return sal_True; + return true; } -bool SwDoc::Move( SwNodeRange& rRange, SwNodeIndex& rPos, SwMoveFlags eMvFlags ) +bool SwDoc::MoveNodeRange( SwNodeRange& rRange, SwNodeIndex& rPos, + SwMoveFlags eMvFlags ) { // bewegt alle Nodes an die neue Position. Dabei werden die // text::Bookmarks mit verschoben !! (zur Zeit ohne Undo) @@ -1539,7 +1405,7 @@ void lcl_JoinText( SwPaM& rPam, sal_Bool bJoinPrev ) pOldTxtNd->Len(), aBkmkArr ); SwIndex aAlphaIdx(pTxtNd); - pOldTxtNd->Cut( pTxtNd, aAlphaIdx, SwIndex(pOldTxtNd), + pOldTxtNd->CutText( pTxtNd, aAlphaIdx, SwIndex(pOldTxtNd), pOldTxtNd->Len() ); SwPosition aAlphaPos( aIdx, aAlphaIdx ); pDoc->CorrRel( rPam.GetPoint()->nNode, aAlphaPos, 0, sal_True ); @@ -1609,14 +1475,85 @@ void lcl_JoinText( SwPaM& rPam, sal_Bool bJoinPrev ) } } -// OD 2009-08-20 #i100466# -// Add handling of new optional parameter <bForceJoinNext> -bool SwDoc::DeleteAndJoin( SwPaM & rPam, - const bool bForceJoinNext ) +static void +lcl_CalcBreaks( ::std::vector<xub_StrLen> & rBreaks, SwPaM const & rPam ) { - if( lcl_StrLenOverFlow( rPam ) ) - return sal_False; - if( IsRedlineOn() ) + SwTxtNode const * const pTxtNode( + rPam.End()->nNode.GetNode().GetTxtNode() ); + if (!pTxtNode) + return; // left-overlap only possible at end of selection... + + const xub_StrLen nStart(rPam.Start()->nContent.GetIndex()); + const xub_StrLen nEnd (rPam.End ()->nContent.GetIndex()); + if (nEnd == pTxtNode->Len()) + return; // paragraph selected until the end + + for (xub_StrLen i = nStart; i < nEnd; ++i) + { + const sal_Unicode c(pTxtNode->GetTxt().GetChar(i)); + if ((CH_TXTATR_INWORD == c) || (CH_TXTATR_BREAKWORD == c)) + { + SwTxtAttr const * const pAttr( pTxtNode->GetTxtAttrForCharAt(i) ); + if (pAttr && pAttr->GetEnd() && (*pAttr->GetEnd() > nEnd)) + { + ASSERT(pAttr->HasDummyChar(), "GetTxtAttrForCharAt broken?"); + rBreaks.push_back(i); + } + } + } +} + +bool lcl_DoWithBreaks(SwDoc & rDoc, SwPaM & rPam, + bool (SwDoc::*pFunc)(SwPaM&, bool), const bool bForceJoinNext = false) +{ + ::std::vector<xub_StrLen> Breaks; + + lcl_CalcBreaks(Breaks, rPam); + + if (!Breaks.size()) + { + return (rDoc.*pFunc)(rPam, bForceJoinNext); + } + + // N.B.: deletion must be split into several parts if the text node + // contains a text attribute with end and with dummy character + // and the selection does not contain the text attribute completely, + // but overlaps its start (left), where the dummy character is. + + SwPosition const & rSelectionEnd( *rPam.End() ); + + bool bRet( true ); + // iterate from end to start, to avoid invalidating the offsets! + ::std::vector<xub_StrLen>::reverse_iterator iter( Breaks.rbegin() ); + SwPaM aPam( rSelectionEnd, rSelectionEnd ); // end node! + SwPosition & rEnd( *aPam.End() ); + SwPosition & rStart( *aPam.Start() ); + + while (iter != Breaks.rend()) + { + rStart.nContent = *iter + 1; + if (rEnd.nContent > rStart.nContent) // check if part is empty + { + bRet &= (rDoc.*pFunc)(aPam, bForceJoinNext); + } + rEnd.nContent = *iter; + ++iter; + } + + rStart = *rPam.Start(); // set to original start + if (rEnd.nContent > rStart.nContent) // check if part is empty + { + bRet &= (rDoc.*pFunc)(aPam, bForceJoinNext); + } + + return bRet; +} + + +bool SwDoc::DeleteAndJoinWithRedlineImpl( SwPaM & rPam, const bool ) +{ + ASSERT( IsRedlineOn(), "DeleteAndJoinWithRedline: redline off" ); + { sal_uInt16 nUndoSize = 0; SwUndoRedlineDelete* pUndo = 0; @@ -1656,9 +1593,13 @@ bool SwDoc::DeleteAndJoin( SwPaM & rPam, //JP 06.01.98: MUSS noch optimiert werden!!! SetRedlineMode( eOld ); } - return sal_True; + return true; } +} +bool SwDoc::DeleteAndJoinImpl( SwPaM & rPam, + const bool bForceJoinNext ) +{ sal_Bool bJoinTxt, bJoinPrev; lcl_GetJoinFlags( rPam, bJoinTxt, bJoinPrev ); // --> OD 2009-08-20 #i100466# @@ -1674,8 +1615,9 @@ SetRedlineMode( eOld ); SwPaM aDelPam( *rPam.GetMark(), *rPam.GetPoint() ); ::PaMCorrAbs( aDelPam, *aDelPam.GetPoint() ); - if( !Delete( aDelPam ) ) - return sal_False; + const bool bSuccess( DeleteRangeImpl( aDelPam ) ); + if (!bSuccess) + return false; *rPam.GetPoint() = *aDelPam.GetPoint(); } @@ -1685,15 +1627,15 @@ SetRedlineMode( eOld ); lcl_JoinText( rPam, bJoinPrev ); } - return sal_True; + return true; } -bool SwDoc::Delete( SwPaM & rPam ) +bool SwDoc::DeleteRangeImpl( SwPaM & rPam, const bool ) { SwPosition *pStt = (SwPosition*)rPam.Start(), *pEnd = (SwPosition*)rPam.End(); if( !rPam.HasMark() || *pStt >= *pEnd ) - return sal_False; + return false; if( pACEWord ) { @@ -1748,7 +1690,7 @@ bool SwDoc::Delete( SwPaM & rPam ) SetModified(); - return sal_True; + return true; } if( !IsIgnoreRedline() && GetRedlineTbl().Count() ) @@ -1782,7 +1724,7 @@ bool SwDoc::Delete( SwPaM & rPam ) // falls schon leer, dann nicht noch aufrufen if( nLen ) { - pStartTxtNode->Erase( pStt->nContent, nLen ); + pStartTxtNode->EraseText( pStt->nContent, nLen ); if( !pStartTxtNode->Len() ) { @@ -1814,7 +1756,7 @@ bool SwDoc::Delete( SwPaM & rPam ) if( pEnd->nContent.GetIndex() ) { SwIndex aIdx( pCNd, 0 ); - pEndTxtNode->Erase( aIdx, pEnd->nContent.GetIndex() ); + pEndTxtNode->EraseText( aIdx, pEnd->nContent.GetIndex() ); if( !pEndTxtNode->Len() ) { @@ -1859,9 +1801,29 @@ bool SwDoc::Delete( SwPaM & rPam ) CompressRedlines(); SetModified(); - return sal_True; + return true; +} + +// OD 2009-08-20 #i100466# +// Add handling of new optional parameter <bForceJoinNext> +bool SwDoc::DeleteAndJoin( SwPaM & rPam, + const bool bForceJoinNext ) +{ + if ( lcl_StrLenOverFlow( rPam ) ) + return false; + + return lcl_DoWithBreaks( *this, rPam, (IsRedlineOn()) + ? &SwDoc::DeleteAndJoinWithRedlineImpl + : &SwDoc::DeleteAndJoinImpl, + bForceJoinNext ); } +bool SwDoc::DeleteRange( SwPaM & rPam ) +{ + return lcl_DoWithBreaks( *this, rPam, &SwDoc::DeleteRangeImpl ); +} + + void lcl_syncGrammarError( SwTxtNode &rTxtNode, linguistic2::ProofreadingResult& rResult, xub_StrLen /*nBeginGrammarCheck*/, const ModelToViewHelper::ConversionMap* pConversionMap ) { @@ -2235,12 +2197,86 @@ sal_Bool lcl_GetTokenToParaBreak( String& rStr, String& rRet, sal_Bool bRegExpRp return bRet; } +bool SwDoc::ReplaceRange( SwPaM& rPam, const String& rStr, + const bool bRegExReplace ) +{ + // unfortunately replace works slightly differently from delete, + // so we cannot use lcl_DoWithBreaks here... + + ::std::vector<xub_StrLen> Breaks; + + SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() ); + aPam.Normalize(FALSE); + if (aPam.GetPoint()->nNode != aPam.GetMark()->nNode) + { + aPam.Move(fnMoveBackward); + } + ASSERT((aPam.GetPoint()->nNode == aPam.GetMark()->nNode), "invalid pam?"); + + lcl_CalcBreaks(Breaks, aPam); + + while (!Breaks.empty() // skip over prefix of dummy chars + && (aPam.GetMark()->nContent.GetIndex() == *Breaks.begin()) ) + { + // skip! + ++aPam.GetMark()->nContent; // always in bounds if Breaks valid + Breaks.erase(Breaks.begin()); + } + *rPam.Start() = *aPam.GetMark(); // update start of original pam w/ prefix + + if (!Breaks.size()) + { + return ReplaceRangeImpl(rPam, rStr, bRegExReplace); // original pam! + } + + // N.B.: deletion must be split into several parts if the text node + // contains a text attribute with end and with dummy character + // and the selection does not contain the text attribute completely, + // but overlaps its start (left), where the dummy character is. + + bool bRet( true ); + // iterate from end to start, to avoid invalidating the offsets! + ::std::vector<xub_StrLen>::reverse_iterator iter( Breaks.rbegin() ); + ASSERT(aPam.GetPoint() == aPam.End(), "wrong!"); + SwPosition & rEnd( *aPam.End() ); + SwPosition & rStart( *aPam.Start() ); + + // set end of temp pam to original end (undo Move backward above) + rEnd = *rPam.End(); + // after first deletion, rEnd will point into the original text node again! + + while (iter != Breaks.rend()) + { + rStart.nContent = *iter + 1; + if (rEnd.nContent != rStart.nContent) // check if part is empty + { + bRet &= (IsRedlineOn()) + ? DeleteAndJoinWithRedlineImpl(aPam) + : DeleteAndJoinImpl(aPam, false); + } + rEnd.nContent = *iter; + ++iter; + } + + rStart = *rPam.Start(); // set to original start + ASSERT(rEnd.nContent > rStart.nContent, "replace part empty!"); + if (rEnd.nContent > rStart.nContent) // check if part is empty + { + bRet &= ReplaceRangeImpl(aPam, rStr, bRegExReplace); + } + + rPam = aPam; // update original pam (is this required?) + + return bRet; +} + // N.B.: it is possible to call Replace with a PaM that spans 2 paragraphs: // search with regex for "$", then replace _all_ -bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) +bool SwDoc::ReplaceRangeImpl( SwPaM& rPam, const String& rStr, + const bool bRegExReplace ) { if( !rPam.HasMark() || *rPam.GetPoint() == *rPam.GetMark() ) - return sal_False; + return false; sal_Bool bJoinTxt, bJoinPrev; lcl_GetJoinFlags( rPam, bJoinTxt, bJoinPrev ); @@ -2257,7 +2293,7 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) ASSERT( pStt->nNode == pEnd->nNode || ( pStt->nNode.GetIndex() + 1 == pEnd->nNode.GetIndex() && !pEnd->nContent.GetIndex() ), - "Point & Mark zeigen auf verschiedene Nodes" ); + "invalid range: Point and Mark on different nodes" ); sal_Bool bOneNode = pStt->nNode == pEnd->nNode; // eigenes Undo ???? @@ -2304,6 +2340,10 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) aSet.ClearItem( RES_TXTATR_REFMARK ); aSet.ClearItem( RES_TXTATR_TOXMARK ); + aSet.ClearItem( RES_TXTATR_CJK_RUBY ); + aSet.ClearItem( RES_TXTATR_INETFMT ); + aSet.ClearItem( RES_TXTATR_META ); + aSet.ClearItem( RES_TXTATR_METAFIELD ); if( aDelPam.GetPoint() != aDelPam.End() ) aDelPam.Exchange(); @@ -2314,9 +2354,9 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) sal_Bool bFirst = sal_True; String sIns; - while( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExpRplc )) + while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) ) { - Insert( aDelPam, sIns, true ); + InsertString( aDelPam, sIns ); if( bFirst ) { SwNodeIndex aMkNd( aDelPam.GetMark()->nNode, -1 ); @@ -2334,7 +2374,9 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) SplitNode( *aDelPam.GetPoint(), false ); } if( sIns.Len() ) - Insert( aDelPam, sIns, true ); + { + InsertString( aDelPam, sIns ); + } SwPaM aTmpRange( *aDelPam.GetPoint() ); aTmpRange.SetMark(); @@ -2346,7 +2388,7 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) *aTmpRange.GetMark() = *aDelPam.GetPoint(); RstTxtAttrs( aTmpRange ); - Insert( aTmpRange, aSet, 0 ); + InsertItemSet( aTmpRange, aSet, 0 ); } if( DoesUndo() ) @@ -2396,7 +2438,7 @@ SetRedlineMode( eOld ); pUndoRpl = new SwUndoReplace(); AppendUndo( pUndoRpl ); } - pUndoRpl->AddEntry( aDelPam, sRepl, bRegExpRplc ); + pUndoRpl->AddEntry( aDelPam, sRepl, bRegExReplace ); DoUndo( sal_False ); } @@ -2414,12 +2456,16 @@ SetRedlineMode( eOld ); sal_Bool bFirst = sal_True; String sIns; - while( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExpRplc )) + while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) ) { if( !bFirst || nStt == pTxtNd->GetTxt().Len() ) - Insert( aDelPam, sIns, true ); + { + InsertString( aDelPam, sIns ); + } else if( nStt < nEnd || sIns.Len() ) - pTxtNd->Replace( pStt->nContent, nEnd - nStt, sIns ); + { + pTxtNd->ReplaceText( pStt->nContent, nEnd - nStt, sIns ); + } SplitNode( *pStt, false); bFirst = sal_False; } @@ -2427,9 +2473,13 @@ SetRedlineMode( eOld ); if( bFirst || sIns.Len() ) { if( !bFirst || nStt == pTxtNd->GetTxt().Len() ) - Insert( aDelPam, sIns, true ); + { + InsertString( aDelPam, sIns ); + } else if( nStt < nEnd || sIns.Len() ) - pTxtNd->Replace( pStt->nContent, nEnd - nStt, sIns ); + { + pTxtNd->ReplaceText( pStt->nContent, nEnd - nStt, sIns ); + } } *rPam.GetMark() = *aDelPam.GetMark(); @@ -2453,7 +2503,7 @@ SetRedlineMode( eOld ); lcl_JoinText( rPam, bJoinPrev ); SetModified(); - return sal_True; + return true; } // speicher die akt. Werte fuer die automatische Aufnahme von Ausnahmen @@ -2619,8 +2669,8 @@ void SwDoc::TransliterateText( const SwPaM& rPaM, if( pStt == pEnd && pTNd ) // no region ? { Boundary aBndry; - if( pBreakIt->xBreak.is() ) - aBndry = pBreakIt->xBreak->getWordBoundary( + if( pBreakIt->GetBreakIter().is() ) + aBndry = pBreakIt->GetBreakIter()->getWordBoundary( pTNd->GetTxt(), nSttCnt, pBreakIt->GetLocale( pTNd->GetLang( nSttCnt ) ), WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/, @@ -2750,7 +2800,7 @@ void SwDoc::RemoveLeadingWhiteSpace(const SwPosition & rPos ) aPam.GetPoint()->nContent = 0; aPam.SetMark(); aPam.GetMark()->nContent = nIdx; - Delete( aPam ); + DeleteRange( aPam ); } } } diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index 6d6d5a3100..970d24c9b9 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -274,18 +274,17 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); -#ifdef DBG_UTIL + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( nIdx, RES_TXTATR_FLYCNT ); ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == &rFmt, "Wrong TxtFlyCnt-Hint." ); -#endif - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); //Die Verbindung ist geloest, jetzt muss noch das Attribut vernichtet //werden. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx ); } //Endlich kann das Attribut gesetzt werden. Es muss das erste Attribut @@ -305,8 +304,8 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms SwTxtNode *pNd = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pNd, "Crsr steht nicht auf TxtNode." ); - pNd->InsertItem( SwFmtFlyCnt( (SwFlyFrmFmt*)&rFmt ), - pPos->nContent.GetIndex(), 0 ); + SwFmtFlyCnt aFmt( static_cast<SwFlyFrmFmt*>(&rFmt) ); + pNd->InsertItem( aFmt, pPos->nContent.GetIndex(), 0 ); } if( SFX_ITEM_SET != rSet.GetItemState( RES_VERT_ORIENT, FALSE, &pItem )) @@ -830,10 +829,10 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, // 'center to baseline' SetAttr( SwFmtVertOrient( 0, text::VertOrientation::CENTER, text::RelOrientation::FRAME ), *pContact->GetFmt() ); SwTxtNode *pNd = aPos.nNode.GetNode().GetTxtNode(); - ASSERT( pNd, "Crsr steht nicht auf TxtNode." ); + ASSERT( pNd, "Cursor not positioned at TxtNode." ); - pNd->InsertItem( SwFmtFlyCnt( pContact->GetFmt() ), - aPos.nContent.GetIndex(), 0 ); + SwFmtFlyCnt aFmt( pContact->GetFmt() ); + pNd->InsertItem( aFmt, aPos.nContent.GetIndex(), 0 ); } break; default: @@ -880,12 +879,13 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, SwTxtNode* pTxtNode( pOldAsCharAnchorPos->nNode.GetNode().GetTxtNode() ); ASSERT( pTxtNode, "<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object" ); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); - SwTxtAttr* pHnt = pTxtNode->GetTxtAttr( nIndx, RES_TXTATR_FLYCNT ); - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( nIndx, RES_TXTATR_FLYCNT ); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); //Die Verbindung ist geloest, jetzt muss noch das Attribut vernichtet //werden. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIndx, nIndx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIndx, nIndx ); delete pOldAsCharAnchorPos; } // <-- diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index db943cad23..f885456bfa 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -411,8 +411,8 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, else { Boundary aBndry; - if( pBreakIt->xBreak.is() ) - aBndry = pBreakIt->xBreak->getWordBoundary( + if( pBreakIt->GetBreakIter().is() ) + aBndry = pBreakIt->GetBreakIter()->getWordBoundary( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ), WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/, @@ -461,6 +461,7 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, const SwPosition *pStt = pPam->Start(), *pEnd = pPam->End(); ParaRstFmt aPara( pStt, pEnd, pHst ); + // mst: not including META here; it seems attrs with CH_TXTATR are omitted USHORT __FAR_DATA aResetableSetRange[] = { RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_CHRATR_BEGIN, RES_CHRATR_END-1, @@ -524,12 +525,15 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, { if ( pHst ) { - SwRegHistory( pTNd, aCharSet, 0, pTNd->GetTxt().Len(), nsSetAttrMode::SETATTR_NOFORMATATTR, pHst ); + SwRegHistory history( pTNd, *pTNd, pHst ); + history.InsertItems( aCharSet, 0, pTNd->GetTxt().Len(), + nsSetAttrMode::SETATTR_NOFORMATATTR ); } else { - SwTxtAttr* pNew = pTNd->MakeTxtAttr( aCharSet, 0, pTNd->GetTxt().Len() ); - pTNd->Insert( pNew ); + SwTxtAttr* pNew = + MakeTxtAttr( *this, aCharSet, 0, pTNd->GetTxt().Len() ); + pTNd->InsertHint( pNew ); } } } @@ -550,11 +554,12 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, { if( IsInRange( aCharFmtSetRange, pItem->Which() )) { - SwTxtAttr* pTAttr = pTNd->MakeTxtAttr( *pItem, 0, - pTNd->GetTxt().Len() ); + SwTxtAttr* pTAttr = MakeTxtAttr( *this, + const_cast<SfxPoolItem&>(*pItem), + 0, pTNd->GetTxt().Len() ); SwpHints & rHints = pTNd->GetOrCreateSwpHints(); rHints.SwpHintsArray::Insert( pTAttr ); - if( pHst ) + if ( pHst ) { SwRegHistory aRegH( pTNd, *pTNd, pHst ); pTNd->ResetAttr( pItem->Which() ); @@ -597,8 +602,9 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, // Einfuegen der Hints nach Inhaltsformen; // wird in SwDoc::Insert(..., SwFmtHint &rHt) benutzt -BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, - USHORT nFlags, SwUndoAttr* pUndo ) +static bool +lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, + const SetAttrMode nFlags, SwUndoAttr *const pUndo) { // teil die Sets auf (fuer Selektion in Nodes) const SfxItemSet* pCharSet = 0; @@ -668,7 +674,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, } SwHistory* pHistory = pUndo ? &pUndo->GetHistory() : 0; - BOOL bRet = FALSE; + bool bRet = false; const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End(); SwCntntNode* pNode = pStt->nNode.GetNode().GetCntntNode(); @@ -686,7 +692,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, ASSERT( false, "<InsAttr(..)> - PaM in front of label, but text node has no numbering rule set. This is a serious defect, please inform OD." ); DELETECHARSETS - return FALSE; + return false; } // <-- @@ -704,7 +710,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, } DELETECHARSETS - return TRUE; + return true; } // <- #i27615# @@ -718,12 +724,12 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, aTxtSet.Put( rChgSet ); if( aTxtSet.Count() ) { - SwRegHistory( (SwTxtNode*)pNode, aTxtSet, rSt.GetIndex(), - rSt.GetIndex(), nFlags, pHistory ); - bRet = TRUE; + SwRegHistory history( pNode, *pNode, pHistory ); + bRet = history.InsertItems( + aTxtSet, rSt.GetIndex(), rSt.GetIndex(), nFlags ) || bRet; - if( pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline() && - pDoc->GetRedlineTbl().Count() )) + if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline() + && pDoc->GetRedlineTbl().Count()))) { SwPaM aPam( pStt->nNode, pStt->nContent.GetIndex()-1, pStt->nNode, pStt->nContent.GetIndex() ); @@ -757,12 +763,12 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, USHORT nEnd = pStt->nNode == pEnd->nNode ? pEnd->nContent.GetIndex() : pNode->Len(); - SwRegHistory( (SwTxtNode*)pNode, aTxtSet, nInsCnt, - nEnd, nFlags, pHistory ); - bRet = TRUE; + SwRegHistory history( pNode, *pNode, pHistory ); + bRet = history.InsertItems( aTxtSet, nInsCnt, nEnd, nFlags ) + || bRet; - if( pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline() && - pDoc->GetRedlineTbl().Count() ) ) + if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline() + && pDoc->GetRedlineTbl().Count()))) { // wurde Text-Inhalt eingefuegt? (RefMark/TOXMarks ohne Ende) BOOL bTxtIns = nInsCnt != rSt.GetIndex(); @@ -784,7 +790,6 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, // bei PageDesc's, die am Node gesetzt werden, muss immer das // Auto-Flag gesetzt werden!! - const SvxLRSpaceItem* pLRSpace = 0; if( pOtherSet && pOtherSet->Count() ) { SwTableNode* pTblNd; @@ -811,11 +816,12 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, SwFrmFmt* pFmt = pTblNd->GetTable().GetFrmFmt(); SwRegHistory aRegH( pFmt, *pTblNd, pHistory ); pFmt->SetFmtAttr( aNew ); + bRet = true; } else { SwRegHistory aRegH( pNode, *pNode, pHistory ); - pNode->SetAttr( aNew ); + bRet = pNode->SetAttr( aNew ) || bRet; } } @@ -823,13 +829,13 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, // we know, that there is only one attribute in pOtherSet. We cannot // perform the following operations, instead we return: if ( bOtherAttr ) - return TRUE; + return bRet; const_cast<SfxItemSet*>(pOtherSet)->ClearItem( RES_PAGEDESC ); if( !pOtherSet->Count() ) { DELETECHARSETS - return TRUE; + return bRet; } } @@ -848,25 +854,22 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, SwFrmFmt* pFmt = pTblNd->GetTable().GetFrmFmt(); SwRegHistory aRegH( pFmt, *pTblNd, pHistory ); pFmt->SetFmtAttr( *pBreak ); + bRet = true; // bOtherAttr = true means that pOtherSet == rChgSet. In this case // we know, that there is only one attribute in pOtherSet. We cannot // perform the following operations, instead we return: if ( bOtherAttr ) - return TRUE; + return bRet; const_cast<SfxItemSet*>(pOtherSet)->ClearItem( RES_BREAK ); if( !pOtherSet->Count() ) { DELETECHARSETS - return TRUE; + return bRet; } } - // fuer Sonderbehandlung von LR-Space innerhalb einer Numerierung !!! - pOtherSet->GetItemState( RES_LR_SPACE, FALSE, - (const SfxPoolItem**)&pLRSpace ); - { // wenns eine PoolNumRule ist, diese ggfs. anlegen const SwNumRuleItem* pRule; @@ -891,7 +894,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() ) { - SwTxtNode* pTxtNd = (SwTxtNode*)pNode; + SwTxtNode* pTxtNd = static_cast<SwTxtNode*>(pNode); const SwIndex& rSt = pStt->nContent; USHORT nMkPos, nPtPos = rSt.GetIndex(); const String& rStr = pTxtNd->GetTxt(); @@ -909,8 +912,8 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, else { Boundary aBndry; - if( pBreakIt->xBreak.is() ) - aBndry = pBreakIt->xBreak->getWordBoundary( + if( pBreakIt->GetBreakIter().is() ) + aBndry = pBreakIt->GetBreakIter()->getWordBoundary( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ), WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/, @@ -946,10 +949,10 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, pTxtNd->RstAttr( aSt, nPtPos, 0, pCharSet ); } - // eintragen des Attributes im Node erledigt die SwRegHistory !! - SwRegHistory( (SwTxtNode*)pNode, *pCharSet, - nMkPos, nPtPos, nFlags, pHistory ); - bRet = TRUE; + // the SwRegHistory inserts the attribute into the TxtNode! + SwRegHistory history( pNode, *pNode, pHistory ); + bRet = history.InsertItems( *pCharSet, nMkPos, nPtPos, nFlags ) + || bRet; if( pDoc->IsRedlineOn() ) { @@ -963,8 +966,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, if( pOtherSet && pOtherSet->Count() ) { SwRegHistory aRegH( pNode, *pNode, pHistory ); - pNode->SetAttr( *pOtherSet ); - bRet = TRUE; + bRet = pNode->SetAttr( *pOtherSet ) || bRet; } DELETECHARSETS @@ -993,25 +995,26 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, if( pStt->nContent.GetIndex() != 0 || aCntEnd.GetIndex() != nLen ) { - // eintragen des Attributes im Node erledigt die SwRegHistory !! + // the SwRegHistory inserts the attribute into the TxtNode! if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() ) { - SwRegHistory( (SwTxtNode*)pNode, *pCharSet, - pStt->nContent.GetIndex(), aCntEnd.GetIndex(), - nFlags, pHistory ); + SwRegHistory history( pNode, *pNode, pHistory ); + bRet = history.InsertItems(*pCharSet, + pStt->nContent.GetIndex(), aCntEnd.GetIndex(), nFlags) + || bRet; } if( pOtherSet && pOtherSet->Count() ) { SwRegHistory aRegH( pNode, *pNode, pHistory ); - pNode->SetAttr( *pOtherSet ); + bRet = pNode->SetAttr( *pOtherSet ) || bRet; } // lediglich Selektion in einem Node. if( pStt->nNode == pEnd->nNode ) { DELETECHARSETS - return TRUE; + return bRet; } ++nNodes; aSt.Assign( pStt->nNode.GetNode(), +1 ); @@ -1036,11 +1039,12 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, USHORT nLen = pNode->Len(); if( aCntEnd.GetIndex() != nLen ) { - // eintragen des Attributes im Node erledigt die SwRegHistory !! + // the SwRegHistory inserts the attribute into the TxtNode! if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() ) { - SwRegHistory( (SwTxtNode*)pNode, *pCharSet, - 0, aCntEnd.GetIndex(), nFlags, pHistory ); + SwRegHistory history( pNode, *pNode, pHistory ); + history.InsertItems(*pCharSet, + 0, aCntEnd.GetIndex(), nFlags); } if( pOtherSet && pOtherSet->Count() ) @@ -1113,14 +1117,14 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, } DELETECHARSETS - return nNodes != 0; + return (nNodes != 0) || bRet; } -bool SwDoc::Insert( const SwPaM &rRg, const SfxPoolItem &rHt, USHORT nFlags ) +bool SwDoc::InsertPoolItem( const SwPaM &rRg, const SfxPoolItem &rHt, + const SetAttrMode nFlags ) { SwDataChanged aTmp( rRg, 0 ); - BOOL bRet; SwUndoAttr* pUndoAttr = 0; if( DoesUndo() ) { @@ -1130,7 +1134,7 @@ bool SwDoc::Insert( const SwPaM &rRg, const SfxPoolItem &rHt, USHORT nFlags ) SfxItemSet aSet( GetAttrPool(), rHt.Which(), rHt.Which() ); aSet.Put( rHt ); - bRet = InsAttr( this, rRg, aSet, nFlags, pUndoAttr ); + bool bRet = lcl_InsAttr( this, rRg, aSet, nFlags, pUndoAttr ); if( DoesUndo() ) AppendUndo( pUndoAttr ); @@ -1140,17 +1144,18 @@ bool SwDoc::Insert( const SwPaM &rRg, const SfxPoolItem &rHt, USHORT nFlags ) return bRet; } -bool SwDoc::Insert( const SwPaM &rRg, const SfxItemSet &rSet, USHORT nFlags ) +bool SwDoc::InsertItemSet ( const SwPaM &rRg, const SfxItemSet &rSet, + const SetAttrMode nFlags ) { SwDataChanged aTmp( rRg, 0 ); SwUndoAttr* pUndoAttr = 0; if( DoesUndo() ) { ClearRedo(); - pUndoAttr = new SwUndoAttr( rRg, rSet ); + pUndoAttr = new SwUndoAttr( rRg, rSet, nFlags ); } - BOOL bRet = InsAttr( this, rRg, rSet, nFlags, pUndoAttr ); + bool bRet = lcl_InsAttr( this, rRg, rSet, nFlags, pUndoAttr ); if( DoesUndo() ) AppendUndo( pUndoAttr ); @@ -2096,7 +2101,7 @@ void SwDoc::CopyFmtArr( const SvPtrarr& rSourceArr, } } -void SwDoc::_CopyPageDescHeaderFooter( BOOL bCpyHeader, +void SwDoc::CopyPageDescHeaderFooterImpl( bool bCpyHeader, const SwFrmFmt& rSrcFmt, SwFrmFmt& rDestFmt ) { // jetzt noch Header-/Footer-Attribute richtig behandeln @@ -2139,7 +2144,7 @@ void SwDoc::_CopyPageDescHeaderFooter( BOOL bCpyHeader, aTmpIdx = *pSttNd->EndOfSectionNode(); rSrcNds._Copy( aRg, aTmpIdx ); aTmpIdx = *pSttNd; - rSrcFmt.GetDoc()->_CopyFlyInFly( aRg, 0, aTmpIdx ); + rSrcFmt.GetDoc()->CopyFlyInFlyImpl( aRg, 0, aTmpIdx ); pNewFmt->SetFmtAttr( SwFmtCntnt( pSttNd )); } else @@ -2499,7 +2504,7 @@ void SwDoc::SetTxtFmtCollByAutoFmt( const SwPosition& rPos, USHORT nPoolId, { aPam.SetMark(); aPam.GetMark()->nContent.Assign( pTNd, pTNd->GetTxt().Len() ); - Insert( aPam, *pSet, 0 ); + InsertItemSet( aPam, *pSet, 0 ); } } @@ -2541,7 +2546,7 @@ void SwDoc::SetFmtItemByAutoFmt( const SwPaM& rPam, const SfxItemSet& rSet ) SetRedlineMode_intern( (RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); } - Insert( rPam, rSet, nsSetAttrMode::SETATTR_DONTEXPAND ); + InsertItemSet( rPam, rSet, nsSetAttrMode::SETATTR_DONTEXPAND ); SetRedlineMode_intern( eOld ); } diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index 5e77a8596b..1d39e35de2 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -307,7 +307,7 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, pDoc->GetNodes().Delete( aIdx, 1 ); // alle Flys in dem Bereich - _CopyFlyInFly( aRg, 0, aIdx ); + CopyFlyInFlyImpl( aRg, 0, aIdx ); // und noch alle Bookmarks @@ -653,7 +653,7 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, int nOutlineLevel ) pDoc->GetNodes().Delete( aIdx, 1 ); // alle Flys in dem Bereich - _CopyFlyInFly( aRg, 0, aIdx ); + CopyFlyInFlyImpl( aRg, 0, aIdx ); // und noch alle Bookmarks diff --git a/sw/source/core/doc/docglos.cxx b/sw/source/core/doc/docglos.cxx index a357946c7b..39b1065201 100644 --- a/sw/source/core/doc/docglos.cxx +++ b/sw/source/core/doc/docglos.cxx @@ -183,7 +183,7 @@ BOOL SwDoc::InsertGlossary( SwTextBlocks& rBlock, const String& rEntry, SwDontExpandItem aACD; aACD.SaveDontExpandItems( rInsPos ); - pGDoc->Copy( aCpyPam, rInsPos, false ); + pGDoc->CopyRange( aCpyPam, rInsPos, false ); aACD.RestoreDontExpandItems( rInsPos ); if( pShell ) diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 0bd8da15ae..ef6bb27d4d 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -362,17 +362,20 @@ void SwDoc::DelLayoutFmt( SwFrmFmt *pFmt ) { const SwPosition* pPos = rAnchor.GetCntntAnchor(); SwTxtNode *pTxtNd = pPos->nNode.GetNode().GetTxtNode(); - SwTxtFlyCnt* pAttr; - // Attribut steht noch im TextNode, loeschen - if( pTxtNd && 0 != ( pAttr = ((SwTxtFlyCnt*)pTxtNd->GetTxtAttr( - pPos->nContent.GetIndex() ))) && - pAttr->GetFlyCnt().GetFrmFmt() == pFmt ) + // attribute is still in text node, delete it + if ( pTxtNd ) { - // Pointer auf 0, nicht loeschen - ((SwFmtFlyCnt&)pAttr->GetFlyCnt()).SetFlyFmt(); - SwIndex aIdx( pPos->nContent ); - pTxtNd->Erase( aIdx, 1 ); + SwTxtFlyCnt* const pAttr = static_cast<SwTxtFlyCnt*>( + pTxtNd->GetTxtAttrForCharAt( pPos->nContent.GetIndex(), + RES_TXTATR_FLYCNT )); + if ( pAttr && (pAttr->GetFlyCnt().GetFrmFmt() == pFmt) ) + { + // dont delete, set pointer to 0 + const_cast<SwFmtFlyCnt&>(pAttr->GetFlyCnt()).SetFlyFmt(); + SwIndex aIdx( pPos->nContent ); + pTxtNd->EraseText( aIdx, 1 ); + } } } @@ -550,9 +553,10 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource, if( bSetTxtFlyAtt && FLY_IN_CNTNT == rNewAnchor.GetAnchorId() ) { - SwPosition* pPos = (SwPosition*)rNewAnchor.GetCntntAnchor(); - pPos->nNode.GetNode().GetTxtNode()->InsertItem(SwFmtFlyCnt( pDest ), - pPos->nContent.GetIndex(), 0 ); + const SwPosition* pPos = rNewAnchor.GetCntntAnchor(); + SwFmtFlyCnt aFmt( pDest ); + pPos->nNode.GetNode().GetTxtNode()->InsertItem( + aFmt, pPos->nContent.GetIndex(), 0 ); } if( bMakeFrms ) @@ -698,7 +702,10 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, ASSERT(pTxtNode!= 0, "There should be a SwTxtNode!"); if (pTxtNode != NULL) - pTxtNode->InsertItem(SwFmtFlyCnt( pFmt ), nStt, nStt ); + { + SwFmtFlyCnt aFmt( pFmt ); + pTxtNode->InsertItem( aFmt, nStt, nStt ); + } } if( SFX_ITEM_SET != pFmt->GetAttrSet().GetItemState( RES_FRM_SIZE )) @@ -844,7 +851,7 @@ SwFlyFrmFmt* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet, GetNodes().MakeTxtNode( aRg.aStart, (SwTxtFmtColl*)GetDfltTxtFmtColl() ); - Move( aRg, aPos.nNode, DOC_MOVEDEFAULT ); + MoveNodeRange( aRg, aPos.nNode, DOC_MOVEDEFAULT ); } else { @@ -885,8 +892,11 @@ if( DoesUndo() ) // werden erstmal alle Undo - Objecte geloescht. do { if( pTmp->HasMark() && *pTmp->GetPoint() != *pTmp->GetMark() ) - Copy( *pTmp, aPos, false ); - } while( &rPam != ( pTmp = (SwPaM*)pTmp->GetNext() ) ); + { + CopyRange( *pTmp, aPos, false ); + } + pTmp = static_cast<SwPaM*>(pTmp->GetNext()); + } while ( &rPam != pTmp ); mbCopyIsMove = bOldFlag; mbUndo = bOldUndo; @@ -894,8 +904,11 @@ if( DoesUndo() ) // werden erstmal alle Undo - Objecte geloescht. do { if( pTmp->HasMark() && *pTmp->GetPoint() != *pTmp->GetMark() ) + { DeleteAndJoin( *pTmp ); - } while( &rPam != ( pTmp = (SwPaM*)pTmp->GetNext() ) ); + } + pTmp = static_cast<SwPaM*>(pTmp->GetNext()); + } while ( &rPam != pTmp ); } } while( sal_False ); } @@ -982,8 +995,9 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, if( FLY_IN_CNTNT == eAnchorId ) { xub_StrLen nStt = rRg.GetPoint()->nContent.GetIndex(); + SwFmtFlyCnt aFmt( pFmt ); rRg.GetPoint()->nNode.GetNode().GetTxtNode()->InsertItem( - SwFmtFlyCnt( pFmt ), nStt, nStt ); + aFmt, nStt, nStt ); } SwDrawContact* pContact = new SwDrawContact( pFmt, &rDrawObj ); @@ -1379,16 +1393,16 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr *pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt(nIdx, RES_TXTATR_FLYCNT); -#ifdef DBG_UTIL ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); - ASSERT( pHnt && ((SwFmtFlyCnt&)pHnt->GetFlyCnt()). - GetFrmFmt() == pOldFmt, + ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pOldFmt, "Wrong TxtFlyCnt-Hint." ); -#endif - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt( pNewFmt ); + + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt( + pNewFmt ); } @@ -1466,7 +1480,7 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co //String einfuegen SwIndex aIdx( pNew, 0 ); - pNew->Insert( aTxt, aIdx ); + pNew->InsertText( aTxt, aIdx ); // //Feld einfuegen @@ -1475,7 +1489,8 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co SwSetExpField aFld( (SwSetExpFieldType*)pType, aEmptyStr, SVX_NUM_ARABIC); if( bOrderNumberingFirst ) nIdx = 0; - pNew->InsertItem( SwFmtFld( aFld ), nIdx, nIdx ); + SwFmtFld aFmt( aFld ); + pNew->InsertItem( aFmt, nIdx, nIdx ); if(rCharacterStyle.Len()) { SwCharFmt* pCharFmt = FindCharFmtByName( rCharacterStyle ); @@ -1484,9 +1499,12 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co const USHORT nMyId = SwStyleNameMapper::GetPoolIdFromUIName(rCharacterStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT); pCharFmt = GetCharFmtFromPool( nMyId ); } - if(pCharFmt) - pNew->InsertItem( SwFmtCharFmt( pCharFmt ), 0, - nSepIdx + 1, nsSetAttrMode::SETATTR_DONTEXPAND ); + if (pCharFmt) + { + SwFmtCharFmt aCharFmt( pCharFmt ); + pNew->InsertItem( aCharFmt, 0, + nSepIdx + 1, nsSetAttrMode::SETATTR_DONTEXPAND ); + } } } @@ -1672,7 +1690,8 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr *pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( nIdx, RES_TXTATR_FLYCNT ); #ifdef DBG_UTIL ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, @@ -1681,7 +1700,7 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, GetFrmFmt() == (SwFrmFmt*)pOldFmt, "Wrong TxtFlyCnt-Hint." ); #endif - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt( pNewFmt ); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt( pNewFmt ); } @@ -1751,7 +1770,7 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, // insert text SwIndex aIdx( pNew, 0 ); - pNew->Insert( aTxt, aIdx ); + pNew->InsertText( aTxt, aIdx ); // insert field if ( pType ) @@ -1759,7 +1778,8 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, SwSetExpField aFld( (SwSetExpFieldType*)pType, aEmptyStr, SVX_NUM_ARABIC ); if( bOrderNumberingFirst ) nIdx = 0; - pNew->InsertItem( SwFmtFld( aFld ), nIdx, nIdx ); + SwFmtFld aFmt( aFld ); + pNew->InsertItem( aFmt, nIdx, nIdx ); if ( rCharacterStyle.Len() ) { SwCharFmt* pCharFmt = FindCharFmtByName( rCharacterStyle ); @@ -1769,7 +1789,11 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, pCharFmt = GetCharFmtFromPool( nMyId ); } if ( pCharFmt ) - pNew->InsertItem( SwFmtCharFmt( pCharFmt ), 0, nSepIdx + 1, nsSetAttrMode::SETATTR_DONTEXPAND ); + { + SwFmtCharFmt aCharFmt( pCharFmt ); + pNew->InsertItem( aCharFmt, 0, nSepIdx + 1, + nsSetAttrMode::SETATTR_DONTEXPAND ); + } } } } diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 446847a32b..dc519495cd 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -123,6 +123,7 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <sfx2/Metadatable.hxx> +#include <fmtmeta.hxx> // MetaFieldManager using namespace ::com::sun::star; @@ -206,6 +207,7 @@ SwDoc::SwDoc() : aUndoNodes( this ), mpAttrPool(new SwAttrPool(this)), pMarkManager(new ::sw::mark::MarkManager(*this)), + m_pMetaFieldManager(new ::sw::MetaFieldManager()), pDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ), pEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, pDfltFrmFmt ) ), pColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, pDfltFrmFmt ) ), @@ -1039,6 +1041,12 @@ SwDoc::GetXmlIdRegistry() return *m_pXmlIdRegistry; } +::sw::MetaFieldManager & +SwDoc::GetMetaFieldManager() +{ + return *m_pMetaFieldManager; +} + void SwDoc::InitTOXTypes() { ShellResource* pShellRes = ViewShell::GetShellRes(); @@ -1379,7 +1387,7 @@ void SwDoc::Paste( const SwDoc& rSource ) aIndexBefore--; - rSource.Copy( aCpyPam, rInsPos, true ); + rSource.CopyRange( aCpyPam, rInsPos, true ); { aIndexBefore++; diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 97333d063e..a3bca434cc 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -1031,12 +1031,14 @@ void SwDoc::SetNumRule( const SwPaM& rPam, "<SwDoc::SetNumRule(..)> - could not create new list. Serious defect -> please inform OD." ); sListId = pNewList->GetListId(); } - Insert( rPam, SfxStringItem( RES_PARATR_LIST_ID, sListId ), 0 ); + InsertPoolItem( rPam, + SfxStringItem( RES_PARATR_LIST_ID, sListId ), 0 ); } else if ( sContinuedListId.Len() > 0 ) { // apply given list id - Insert( rPam, SfxStringItem( RES_PARATR_LIST_ID, sContinuedListId ), 0 ); + InsertPoolItem( rPam, + SfxStringItem( RES_PARATR_LIST_ID, sContinuedListId ), 0 ); } } // <-- @@ -1084,7 +1086,7 @@ void SwDoc::SetNumRule( const SwPaM& rPam, if ( bSetItem ) // <-- { - Insert( rPam, SwNumRuleItem( pNew->GetName() ), 0 ); + InsertPoolItem( rPam, SwNumRuleItem( pNew->GetName() ), 0 ); } // --> OD 2008-02-08 #newlistlevelattrs# @@ -1124,33 +1126,34 @@ void SwDoc::SetCounted(const SwPaM & rPam, bool bCounted) } else { - Insert( rPam, SfxBoolItem( RES_PARATR_LIST_ISCOUNTED, FALSE ), 0 ); + InsertPoolItem( rPam, + SfxBoolItem( RES_PARATR_LIST_ISCOUNTED, FALSE ), 0 ); } } -void SwDoc::ReplaceNumRule(const SwPaM & rPaM, const SwNumRule & rNumRule) -{ - if (DoesUndo()) - StartUndo(UNDO_START, NULL); +//void SwDoc::ReplaceNumRule(const SwPaM & rPaM, const SwNumRule & rNumRule) +//{ +// if (DoesUndo()) +// StartUndo(UNDO_START, NULL); - ULONG nStt = rPaM.Start()->nNode.GetIndex(); - ULONG nEnd = rPaM.End()->nNode.GetIndex(); +// ULONG nStt = rPaM.Start()->nNode.GetIndex(); +// ULONG nEnd = rPaM.End()->nNode.GetIndex(); - for (ULONG n = nStt; n <= nEnd; n++) - { - SwTxtNode * pCNd = GetNodes()[n]->GetTxtNode(); +// for (ULONG n = nStt; n <= nEnd; n++) +// { +// SwTxtNode * pCNd = GetNodes()[n]->GetTxtNode(); - if (pCNd && NULL != pCNd->GetNumRule()) - { - SwPaM aPam(*pCNd); +// if (pCNd && NULL != pCNd->GetNumRule()) +// { +// SwPaM aPam(*pCNd); - Insert(aPam, SwNumRuleItem(rNumRule.GetName()), 0); - } - } +// InsertPoolItem(aPam, SwNumRuleItem(rNumRule.GetName()), 0); +// } +// } - if (DoesUndo()) - EndUndo(UNDO_START, NULL); -} +// if (DoesUndo()) +// EndUndo(UNDO_START, NULL); +//} void SwDoc::SetNumRuleStart( const SwPosition& rPos, BOOL bFlag ) { @@ -1544,8 +1547,8 @@ void SwDoc::MakeUniqueNumRules(const SwPaM & rPaM) SwPosition aPos(*pCNd); aListStyleData.pReplaceNumRule = const_cast<SwNumRule *> - (SearchNumRule( aPos, FALSE, pCNd->HasNumber(), - FALSE, 0, + (SearchNumRule( aPos, false, pCNd->HasNumber(), + false, 0, aListStyleData.sListId, true )); } @@ -1668,7 +1671,7 @@ void SwDoc::DelNumRules( const SwPaM& rPam ) pTNd->ChkCondColl(); //else if( !pOutlNd && NO_NUMBERING != //#outline level,zhaojianwei // ((SwTxtFmtColl*)pTNd->GetFmtColl())->GetOutlineLevel() ) - else if( !pOutlNd && + else if( !pOutlNd && ((SwTxtFmtColl*)pTNd->GetFmtColl())->IsAssignedToListLevelOfOutlineStyle() )//<-end,zhaojianwei pOutlNd = pTNd; } @@ -1849,13 +1852,13 @@ BOOL SwDoc::GotoNextNum( SwPosition& rPos, BOOL bOverUpper, // -> #i23731# // --> OD 2008-03-18 #refactorlists# - add output parameter <sListId> -const SwNumRule * SwDoc::SearchNumRule(SwPosition & rPos, - BOOL bForward, - BOOL bNum, - BOOL bOutline, +const SwNumRule * SwDoc::SearchNumRule(const SwPosition & rPos, + const bool bForward, + const bool bNum, + const bool bOutline, int nNonEmptyAllowed, String& sListId, - bool _bInvestigateStartNode) + const bool bInvestigateStartNode) { const SwNumRule * pResult = NULL; SwTxtNode * pTxtNd = rPos.nNode.GetNode().GetTxtNode(); @@ -1871,7 +1874,7 @@ const SwNumRule * SwDoc::SearchNumRule(SwPosition & rPos, do { // --> OD 2005-10-20 #i55391# - if ( !_bInvestigateStartNode ) + if ( !bInvestigateStartNode ) { if (bForward) aIdx++; @@ -1886,9 +1889,9 @@ const SwNumRule * SwDoc::SearchNumRule(SwPosition & rPos, const SwNumRule * pNumRule = pTxtNd->GetNumRule(); if (pNumRule) { - if (pNumRule->IsOutlineRule() == bOutline && // #115901# - ( (bNum && pNumRule->Get(0).IsEnumeration()) || - (!bNum && pNumRule->Get(0).IsItemize()) )) // #i22362#, #i29560# + if ( ( pNumRule->IsOutlineRule() == ( bOutline ? TRUE : FALSE ) ) && // #115901# + ( ( bNum && pNumRule->Get(0).IsEnumeration()) || + ( !bNum && pNumRule->Get(0).IsItemize() ) ) ) // #i22362#, #i29560# { pResult = pTxtNd->GetNumRule(); // --> OD 2008-03-18 #refactorlists# @@ -1911,7 +1914,7 @@ const SwNumRule * SwDoc::SearchNumRule(SwPosition & rPos, } // --> OD 2005-10-20 #i55391# - if ( _bInvestigateStartNode ) + if ( bInvestigateStartNode ) { if (bForward) aIdx++; @@ -2275,7 +2278,7 @@ BOOL SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, BOOL bIsOutlMv ) } } - Copy( aPam, aInsPos, false ); + CopyRange( aPam, aInsPos, false ); if( bDelLastPara ) { // dann muss der letzte leere Node wieder entfernt werden @@ -2361,7 +2364,7 @@ SetRedlineMode( eOld ); } - Move( aMvRg, aIdx, DOC_MOVEREDLINES ); + MoveNodeRange( aMvRg, aIdx, DOC_MOVEREDLINES ); if( pUndo ) { diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 4618cb3b56..a52f49be86 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -1725,7 +1725,7 @@ BOOL lcl_AcceptRedline( SwRedlineTbl& rArr, USHORT& rPos, rDoc.DeleteAndJoin( aPam ); else { - rDoc.Delete( aPam ); + rDoc.DeleteRange( aPam ); if( pCSttNd && !pCEndNd ) { @@ -1835,7 +1835,7 @@ BOOL lcl_RejectRedline( SwRedlineTbl& rArr, USHORT& rPos, rDoc.DeleteAndJoin( aPam ); else { - rDoc.Delete( aPam ); + rDoc.DeleteRange( aPam ); if( pCSttNd && !pCEndNd ) { @@ -2899,10 +2899,12 @@ void SwRedlineExtraData_FmtColl::Reject( SwPaM& rPam ) const // nicht angefasst. SfxItemSet aTmp( *pSet ); aTmp.Differentiate( *pTNd->GetpSwAttrSet() ); - pDoc->Insert( rPam, aTmp, 0 ); + pDoc->InsertItemSet( rPam, aTmp, 0 ); } else - pDoc->Insert( rPam, *pSet, 0 ); + { + pDoc->InsertItemSet( rPam, *pSet, 0 ); + } } rPam.DeleteMark(); } @@ -2964,7 +2966,10 @@ void SwRedlineExtraData_Format::Reject( SwPaM& rPam ) const // eigentlich muesste hier das Attribut zurueck gesetzt werden!!! for( USHORT n = 0, nEnd = aWhichIds.Count(); n < nEnd; ++n ) - pDoc->Insert( rPam, *GetDfltAttr( aWhichIds[ n ] ), nsSetAttrMode::SETATTR_DONTEXPAND ); + { + pDoc->InsertPoolItem( rPam, *GetDfltAttr( aWhichIds[ n ] ), + nsSetAttrMode::SETATTR_DONTEXPAND ); + } pDoc->SetRedlineMode_intern( eOld ); } @@ -3359,7 +3364,8 @@ void SwRedline::MoveToSection() { if( pCSttNd && !pCEndNd ) bDelLastPara = TRUE; - pDoc->Move( aPam, aPos, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveRange( aPam, aPos, + IDocumentContentOperations::DOC_MOVEDEFAULT ); } } else @@ -3368,7 +3374,8 @@ void SwRedline::MoveToSection() SwNormalStartNode ); SwPosition aPos( *pSttNd->EndOfSectionNode() ); - pDoc->Move( aPam, aPos, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveRange( aPam, aPos, + IDocumentContentOperations::DOC_MOVEDEFAULT ); } pCntntSect = new SwNodeIndex( *pSttNd ); @@ -3419,7 +3426,7 @@ void SwRedline::CopyToSection() SwNodeIndex aNdIdx( *pSttNd, 1 ); SwTxtNode* pTxtNd = aNdIdx.GetNode().GetTxtNode(); SwPosition aPos( aNdIdx, SwIndex( pTxtNd )); - pDoc->Copy( *this, aPos, false ); + pDoc->CopyRange( *this, aPos, false ); // JP 08.10.98: die Vorlage vom EndNode ggfs. mit uebernehmen // - ist im Doc::Copy nicht erwuenscht @@ -3444,7 +3451,7 @@ void SwRedline::CopyToSection() if( pCEndNd ) { SwPosition aPos( *pSttNd->EndOfSectionNode() ); - pDoc->Copy( *this, aPos, false ); + pDoc->CopyRange( *this, aPos, false ); } else { @@ -3498,7 +3505,7 @@ void SwRedline::DelCopyOfSection() { if( pCSttNd && !pCEndNd ) bDelLastPara = TRUE; - pDoc->Delete( aPam ); + pDoc->DeleteRange( aPam ); if( bDelLastPara ) { @@ -3539,7 +3546,9 @@ void SwRedline::DelCopyOfSection() } } else - pDoc->Delete( aPam ); + { + pDoc->DeleteRange( aPam ); + } if( pStt == GetPoint() ) Exchange(); @@ -3622,7 +3631,10 @@ void SwRedline::MoveFromSection() pDoc->AppendTxtNode( aPos ); } else - pDoc->Move( aPam, aPos, IDocumentContentOperations::DOC_MOVEALLFLYS ); + { + pDoc->MoveRange( aPam, aPos, + IDocumentContentOperations::DOC_MOVEALLFLYS ); + } SetMark(); *GetPoint() = aPos; diff --git a/sw/source/core/doc/docruby.cxx b/sw/source/core/doc/docruby.cxx index 6a03378ff3..37d743c0d3 100644 --- a/sw/source/core/doc/docruby.cxx +++ b/sw/source/core/doc/docruby.cxx @@ -147,16 +147,20 @@ USHORT SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList, { // set/reset the attribut if( pEntry->GetRubyAttr().GetText().Len() ) - Insert( aPam, pEntry->GetRubyAttr(), 0 ); + { + InsertPoolItem( aPam, pEntry->GetRubyAttr(), 0 ); + } else + { ResetAttrs( aPam, TRUE, &aDelArr ); + } } if( aCheckEntry.GetText() != pEntry->GetText() && pEntry->GetText().Len() ) { // text is changed, so replace the original - Replace( aPam, pEntry->GetText(), FALSE ); + ReplaceRange( aPam, pEntry->GetText(), false ); } aPam.DeleteMark(); } @@ -176,10 +180,11 @@ USHORT SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList, if( pEntry->GetRubyAttr().GetText().Len() && pEntry->GetText().Len() ) { - Insert( aPam, pEntry->GetText(), true ); + InsertString( aPam, pEntry->GetText() ); aPam.SetMark(); aPam.GetMark()->nContent -= pEntry->GetText().Len(); - Insert( aPam, pEntry->GetRubyAttr(), nsSetAttrMode::SETATTR_DONTEXPAND ); + InsertPoolItem( aPam, pEntry->GetRubyAttr(), + nsSetAttrMode::SETATTR_DONTEXPAND ); } else break; @@ -246,7 +251,7 @@ BOOL SwDoc::_SelectNextRubyChars( SwPaM& rPam, SwRubyListEntry& rEntry, USHORT ) if( !bHasMark && nStart && ( !pAttr || nStart != *pAttr->GetStart()) ) { // skip to the word begin! - long nWordStt = pBreakIt->xBreak->getWordBoundary( + long nWordStt = pBreakIt->GetBreakIter()->getWordBoundary( *pTxt, nStart, pBreakIt->GetLocale( pTNd->GetLang( nStart )), WordType::ANYWORD_IGNOREWHITESPACES, @@ -335,10 +340,10 @@ BOOL SwDoc::_SelectNextRubyChars( SwPaM& rPam, SwRubyListEntry& rEntry, USHORT ) { rPam.SetMark(); bAlphaNum = bIsAlphaNum; - if( bChkNxtWrd && pBreakIt->xBreak.is() ) + if( bChkNxtWrd && pBreakIt->GetBreakIter().is() ) { // search the end of this word - nWordEnd = pBreakIt->xBreak->getWordBoundary( + nWordEnd = pBreakIt->GetBreakIter()->getWordBoundary( *pTxt, nStart, pBreakIt->GetLocale( pTNd->GetLang( nStart )), WordType::ANYWORD_IGNOREWHITESPACES, diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index d69863980f..5414b72869 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -452,7 +452,8 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) aRg.aEnd = aRg.aStart.GetIndex() + 1; // Nodes verschieben - Move( aRg, aStart, IDocumentContentOperations::DOC_MOVEDEFAULT ); + MoveNodeRange( aRg, aStart, + IDocumentContentOperations::DOC_MOVEDEFAULT ); // Undo Verschiebungen einpflegen if(pUndoSort) @@ -777,7 +778,8 @@ void MoveCell(SwDoc* pDoc, const SwTableBox* pSource, const SwTableBox* pTar, // Einfuegen der Source SwNodeIndex aIns( *pTar->GetSttNd()->EndOfSectionNode() ); - pDoc->Move( aRg, aIns, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveNodeRange( aRg, aIns, + IDocumentContentOperations::DOC_MOVEDEFAULT ); // Falls erster Node leer -> weg damit if(bDelFirst) diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 50ba887043..57ce88fec8 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -182,7 +182,7 @@ USHORT SwDoc::GetCurTOXMark( const SwPosition& rPos, Beschreibung: Marke loeschen --------------------------------------------------------------------*/ -void SwDoc::Delete( const SwTOXMark* pTOXMark ) +void SwDoc::DeleteTOXMark( const SwTOXMark* pTOXMark ) { // hole den TextNode und const SwTxtTOXMark* pTxtTOXMark = pTOXMark->GetTxtTOXMark(); @@ -202,12 +202,15 @@ void SwDoc::Delete( const SwTOXMark* pTOXMark ) SwRegHistory aRHst( rTxtNd, &pUndo->GetHistory() ); rTxtNd.GetpSwpHints()->Register( &aRHst ); - rTxtNd.Delete( const_cast<SwTxtTOXMark*>( pTxtTOXMark ), TRUE ); + } + + rTxtNd.DeleteAttribute( const_cast<SwTxtTOXMark*>(pTxtTOXMark) ); + + if ( DoesUndo() ) + { if( rTxtNd.GetpSwpHints() ) rTxtNd.GetpSwpHints()->DeRegister(); } - else - rTxtNd.Delete( const_cast<SwTxtTOXMark*>( pTxtTOXMark ), TRUE ); SetModified(); } @@ -372,7 +375,7 @@ const SwTOXBaseSection* SwDoc::InsertTableOf( const SwPosition& rPos, pNew->SetTOXName(sSectNm); pNew->SwSection::SetName(sSectNm); SwPaM aPam( rPos ); - SwSection* pSect = Insert( aPam, *pNew, pSet, FALSE ); + SwSection* pSect = InsertSwSection( aPam, *pNew, pSet, false ); if( pSect ) { SwSectionNode* pSectNd = pSect->GetFmt()->GetSectionNode(); @@ -956,7 +959,7 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr, SwTxtNode* pHeadNd = pDoc->GetNodes().MakeTxtNode( aIdx, GetTxtFmtColl( FORM_TITLE ) ); - pHeadNd->Insert( GetTitle(), SwIndex( pHeadNd )); + pHeadNd->InsertText( GetTitle(), SwIndex( pHeadNd ) ); String sNm( GetTOXName() ); // ??Resource @@ -1245,7 +1248,7 @@ void SwTOXBaseSection::UpdateMarks( const SwTOXInternational& rIntl, { // Stichwortverzeichnismarkierung lang::Locale aLocale; - if ( pBreakIt->xBreak.is() ) + if ( pBreakIt->GetBreakIter().is() ) { aLocale = pBreakIt->GetLocale( pTOXSrc->GetLang( *pTxtMark->GetStart() ) ); @@ -1939,9 +1942,12 @@ void SwTOXBaseSection::GenerateText( USHORT nArrayIdx, else pCharFmt = pDoc->FindCharFmtByName( aToken.sCharStyleName); - if(pCharFmt) - pTOXNd->InsertItem( SwFmtCharFmt( pCharFmt ), nStartCharStyle, - rTxt.Len(), nsSetAttrMode::SETATTR_DONTEXPAND ); + if (pCharFmt) + { + SwFmtCharFmt aFmt( pCharFmt ); + pTOXNd->InsertItem( aFmt, nStartCharStyle, + rTxt.Len(), nsSetAttrMode::SETATTR_DONTEXPAND ); + } } aIt++; // #i21237# @@ -2139,7 +2145,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, break; } } - pNd->Erase(aPos, nEndPos - nStartPos + 2); + pNd->EraseText(aPos, nEndPos - nStartPos + 2); for( i = 1; i < rNums.Count(); ++i) { @@ -2213,7 +2219,8 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, GetNumType() ).GetNumStr( nBeg+nCount ); } } - pNd->Insert( aNumStr, aPos, INS_EMPTYEXPAND ); + pNd->InsertText( aNumStr, aPos, + IDocumentContentOperations::INS_EMPTYEXPAND ); if(pPageNoCharFmt) { SwFmtCharFmt aCharFmt( pPageNoCharFmt ); diff --git a/sw/source/core/doc/extinput.cxx b/sw/source/core/doc/extinput.cxx index 2715f39843..8cd8229f74 100644 --- a/sw/source/core/doc/extinput.cxx +++ b/sw/source/core/doc/extinput.cxx @@ -89,7 +89,7 @@ SwExtTextInput::~SwExtTextInput() if ( bLang ) { SvxLanguageItem aLangItem( eInputLanguage, nWhich ); - pDoc->Insert(*this, aLangItem, 0 ); + pDoc->InsertPoolItem(*this, aLangItem, 0 ); } } rIdx = nSttCnt; @@ -100,9 +100,9 @@ SwExtTextInput::~SwExtTextInput() if( nLen > sOverwriteText.Len() ) { rIdx += sOverwriteText.Len(); - pTNd->Erase( rIdx, nLen - sOverwriteText.Len() ); + pTNd->EraseText( rIdx, nLen - sOverwriteText.Len() ); rIdx = nSttCnt; - pTNd->Replace( rIdx, sOverwriteText.Len(), + pTNd->ReplaceText( rIdx, sOverwriteText.Len(), sOverwriteText ); if( bInsText ) { @@ -110,13 +110,15 @@ SwExtTextInput::~SwExtTextInput() pDoc->StartUndo( UNDO_OVERWRITE, NULL ); pDoc->Overwrite( *this, sTxt.Copy( 0, sOverwriteText.Len() )); - pDoc->Insert( *this, sTxt.Copy( sOverwriteText.Len() ), true); + pDoc->InsertString( *this, + sTxt.Copy( sOverwriteText.Len() ) ); pDoc->EndUndo( UNDO_OVERWRITE, NULL ); } } else { - pTNd->Replace( rIdx, nLen, sOverwriteText.Copy( 0, nLen )); + pTNd->ReplaceText( rIdx, nLen, + sOverwriteText.Copy( 0, nLen )); if( bInsText ) { rIdx = nSttCnt; @@ -126,10 +128,12 @@ SwExtTextInput::~SwExtTextInput() } else { - pTNd->Erase( rIdx, nEndCnt - nSttCnt ); + pTNd->EraseText( rIdx, nEndCnt - nSttCnt ); if( bInsText ) - pDoc->Insert( *this, sTxt, true ); + { + pDoc->InsertString( *this, sTxt ); + } } } } @@ -159,7 +163,7 @@ void SwExtTextInput::SetInputData( const CommandExtTextInputData& rData ) // some characters nReplace = nReplace - rNewStr.Len(); aIdx += rNewStr.Len(); - pTNd->Replace( aIdx, nReplace, + pTNd->ReplaceText( aIdx, nReplace, sOverwriteText.Copy( rNewStr.Len(), nReplace )); aIdx = nSttCnt; nReplace = rNewStr.Len(); @@ -168,14 +172,14 @@ void SwExtTextInput::SetInputData( const CommandExtTextInputData& rData ) { nReplace = nReplace - sOverwriteText.Len(); aIdx += sOverwriteText.Len(); - pTNd->Erase( aIdx, nReplace ); + pTNd->EraseText( aIdx, nReplace ); aIdx = nSttCnt; nReplace = sOverwriteText.Len(); } else if( (nReplace = sOverwriteText.Len()) > rNewStr.Len() ) nReplace = rNewStr.Len(); - pTNd->Replace( aIdx, nReplace, rNewStr ); + pTNd->ReplaceText( aIdx, nReplace, rNewStr ); if( !HasMark() ) SetMark(); GetMark()->nContent = aIdx; @@ -183,9 +187,12 @@ void SwExtTextInput::SetInputData( const CommandExtTextInputData& rData ) else { if( nSttCnt < nEndCnt ) - pTNd->Erase( aIdx, nEndCnt - nSttCnt ); + { + pTNd->EraseText( aIdx, nEndCnt - nSttCnt ); + } - pTNd->Insert( rNewStr, aIdx, INS_EMPTYEXPAND ); + pTNd->InsertText( rNewStr, aIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); if( !HasMark() ) SetMark(); } diff --git a/sw/source/core/doc/makefile.mk b/sw/source/core/doc/makefile.mk index 9e01f6ff1e..c7459cd164 100644 --- a/sw/source/core/doc/makefile.mk +++ b/sw/source/core/doc/makefile.mk @@ -49,6 +49,7 @@ EXCEPTIONSFILES = \ $(SLO)$/docbm.obj \ $(SLO)$/doccomp.obj \ $(SLO)$/docdraw.obj \ + $(SLO)$/docedt.obj \ $(SLO)$/docfmt.obj \ $(SLO)$/docglbl.obj \ $(SLO)$/docglos.obj \ @@ -70,7 +71,6 @@ SLOFILES = $(EXCEPTIONSFILES) \ $(SLO)$/doccorr.obj \ $(SLO)$/docdde.obj \ $(SLO)$/docdesc.obj \ - $(SLO)$/docedt.obj \ $(SLO)$/docfld.obj \ $(SLO)$/docfly.obj \ $(SLO)$/docftn.obj \ diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 67c6e6eb32..8784290172 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -36,6 +36,7 @@ #include <tools/urlobj.hxx> #include <vcl/print.hxx> #include <vcl/virdev.hxx> +#include <vcl/svapp.hxx> #include <svtools/imapobj.hxx> #include <svtools/imap.hxx> #include <svtools/urihelper.hxx> @@ -1027,8 +1028,9 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons //TODO/LATER: is it a problem that the JopSetup isn't used? //xRef->DoDraw( pOut, aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(), *pJobSetup ); + // get hi-contrast image, but never for printing Graphic* pGraphic = NULL; - if ( pOut && ( pOut->GetDrawMode() & DRAWMODE_SETTINGSFILL ) ) + if (pOut && !bPrn && Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) pGraphic = pOLENd->GetHCGraphic(); // when it is not possible to get HC-representation, the original image should be used diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx index a70fb9a709..a5419368d0 100644 --- a/sw/source/core/doc/poolfmt.cxx +++ b/sw/source/core/doc/poolfmt.cxx @@ -1719,7 +1719,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) 283, 567, 850, 1134, 1417, 1701, 1984, 2268, 2551, 2835 }; const USHORT* pArr = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace : aAbsSpaceInch; #else @@ -1773,7 +1773,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) }; const USHORT* pArr = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace : aAbsSpaceInch; #else @@ -1876,7 +1876,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) 283, 567, 850, 1134, 1417, 1701, 1984, 2268, 2551, 2835 }; const USHORT* pArr = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace : aAbsSpaceInch; #else @@ -1930,7 +1930,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) 347, 1194 }; const USHORT* pArr0to2 = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace0to2 : aAbsSpaceInch0to2; #else @@ -2070,7 +2070,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268 }; const USHORT* pArr = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace : aAbsSpaceInch; #else @@ -2131,7 +2131,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) 170, 340, 510, 680, 850, 1020, 1191, 1361, 1531, 1701 }; const USHORT* pArr = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace : aAbsSpaceInch; #else @@ -2236,7 +2236,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268 }; const USHORT* pArr = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace : aAbsSpaceInch; #else @@ -2303,7 +2303,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268 }; const USHORT* pArr = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace : aAbsSpaceInch; #else diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 293beff1af..f7897bed15 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -203,6 +203,14 @@ namespace pNewBookmark->SetKeyCode(pOldBookmark->GetKeyCode()); pNewBookmark->SetShortName(pOldBookmark->GetShortName()); } + ::sfx2::Metadatable const*const pMetadatable( + dynamic_cast< ::sfx2::Metadatable const* >(pMark)); + ::sfx2::Metadatable *const pNewMetadatable( + dynamic_cast< ::sfx2::Metadatable * >(pNewMark)); + if (pMetadatable && pNewMetadatable) + { + pNewMetadatable->RegisterAsCopyOf(*pMetadatable); + } } pDestDoc->DoUndo(bDoesUndo); } @@ -271,7 +279,8 @@ SwCntntNode* SwTxtNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const // ??? reicht das ??? was ist mit PostIts/Feldern/FeldTypen ??? // --> OD 2008-11-18 #i96213# - force copy of all attributes - pCpyTxtNd->Copy( pTxtNd, SwIndex( pCpyTxtNd ), pCpyTxtNd->GetTxt().Len(), true ); + pCpyTxtNd->CopyText( pTxtNd, SwIndex( pCpyTxtNd ), + pCpyTxtNd->GetTxt().Len(), true ); // <-- //FEATURE::CONDCOLL @@ -673,7 +682,8 @@ void lcl_DeleteRedlines( const SwNodeRange& rRg, SwNodeRange& rCpyRg ) // Kopieren eines Bereiches im oder in ein anderes Dokument ! -bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const +bool +SwDoc::CopyRange( SwPaM& rPam, SwPosition& rPos, const bool bCopyAll ) const { const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End(); @@ -682,7 +692,7 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const // kein Copy abfangen. if( !rPam.HasMark() || ( *pStt >= *pEnd && !bColumnSel ) ) - return FALSE; + return false; // verhinder das Kopieren in Fly's, die im Bereich verankert sind. if( pDoc == this ) @@ -699,7 +709,9 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const --nEnd, --nDiff; if( nDiff && lcl_ChkFlyFly( pDoc, nStt, nEnd, rPos.nNode.GetIndex() ) ) - return FALSE; + { + return false; + } } SwPaM* pRedlineRange = 0; @@ -709,20 +721,25 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const RedlineMode_t eOld = pDoc->GetRedlineMode(); - BOOL bRet = FALSE; + bool bRet = false; if( pDoc != this ) - bRet = _Copy( rPam, rPos, TRUE, bCopyAll, pRedlineRange ); // nur normales Kopieren + { // ordinary copy + bRet = CopyImpl( rPam, rPos, true, bCopyAll, pRedlineRange ); + } // Copy in sich selbst (ueber mehrere Nodes wird hier gesondert // behandelt; in einem TextNode wird normal behandelt) else if( ! ( *pStt <= rPos && rPos < *pEnd && ( pStt->nNode != pEnd->nNode || !pStt->nNode.GetNode().IsTxtNode() )) ) - bRet = _Copy( rPam, rPos, TRUE, bCopyAll, pRedlineRange ); // nur normales Kopieren - + { // ordinary copy + bRet = CopyImpl( rPam, rPos, true, bCopyAll, pRedlineRange ); + } else { ASSERT( this == pDoc, " falscher Copy-Zweig!" ); + ASSERT(false, "mst: i thought this could be dead code;" + "please tell me what you did to get here!"); pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); BOOL bDoUndo = pDoc->DoesUndo(); @@ -742,7 +759,8 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const SwStartNode* pSttNd = pDoc->GetNodes().MakeEmptySection( SwNodeIndex( GetNodes().GetEndOfAutotext() )); aPam.GetPoint()->nNode = *pSttNd->EndOfSectionNode(); - pDoc->_Copy( rPam, *aPam.GetPoint(), FALSE, bCopyAll, 0 ); // kopieren ohne Frames + // copy without Frames + pDoc->CopyImpl( rPam, *aPam.GetPoint(), false, bCopyAll, 0 ); aPam.GetPoint()->nNode = pDoc->GetNodes().GetEndOfAutotext(); aPam.SetMark(); @@ -752,7 +770,8 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const aPam.GetPoint()->nNode = *aPam.GetNode()->StartOfSectionNode(); pNode = pDoc->GetNodes().GoNext( &aPam.GetPoint()->nNode ); pNode->MakeStartIndex( &aPam.GetPoint()->nContent ); - pDoc->Move( aPam, rPos, DOC_MOVEDEFAULT ); // auf gewuenschte Position moven + // move to desired position + pDoc->MoveRange( aPam, rPos, DOC_MOVEDEFAULT ); pNode = aPam.GetCntntNode(); *aPam.GetPoint() = rPos; // Cursor umsetzen fuers Undo ! @@ -776,7 +795,7 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const } pDoc->SetModified(); - bRet = TRUE; + bRet = true; } pDoc->SetRedlineMode_intern( eOld ); @@ -795,42 +814,79 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const // Kopieren eines Bereiches im oder in ein anderes Dokument ! // Die Position darf nicht im Bereich liegen !! -BOOL lcl_MarksWholeNode(const SwPaM & rPam) +bool lcl_MarksWholeNode(const SwPaM & rPam) { - BOOL bResult = FALSE; - const SwPosition * pStt = rPam.Start(), * pEnd = rPam.End(); + bool bResult = false; + const SwPosition* pStt = rPam.Start(); + const SwPosition* pEnd = rPam.End(); if (NULL != pStt && NULL != pEnd) { - SwTxtNode * pSttNd = pStt->nNode.GetNode().GetTxtNode(); - SwTxtNode * pEndNd = pEnd->nNode.GetNode().GetTxtNode(); + const SwTxtNode* pSttNd = pStt->nNode.GetNode().GetTxtNode(); + const SwTxtNode* pEndNd = pEnd->nNode.GetNode().GetTxtNode(); if (NULL != pSttNd && NULL != pEndNd && pStt->nContent.GetIndex() == 0 && pEnd->nContent.GetIndex() == pEndNd->Len()) { - bResult = TRUE; + bResult = true; } } return bResult; } -BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, - BOOL bMakeNewFrms, bool bCopyAll, SwPaM* pCpyRange ) const +// --> OD 2009-08-25 #i86492# +bool lcl_ContainsOnlyParagraphsInList( const SwPaM& rPam ) +{ + bool bRet = false; + + const SwTxtNode* pTxtNd = rPam.Start()->nNode.GetNode().GetTxtNode(); + const SwTxtNode* pEndTxtNd = rPam.End()->nNode.GetNode().GetTxtNode(); + if ( pTxtNd && pTxtNd->IsInList() && + pEndTxtNd && pEndTxtNd->IsInList() ) + { + bRet = true; + SwNodeIndex aIdx(rPam.Start()->nNode); + + do + { + aIdx++; + pTxtNd = aIdx.GetNode().GetTxtNode(); + + if ( !pTxtNd || !pTxtNd->IsInList() ) + { + bRet = false; + break; + } + } while ( pTxtNd && pTxtNd != pEndTxtNd ); + } + + + return bRet; +} +// <-- + +bool SwDoc::CopyImpl( SwPaM& rPam, SwPosition& rPos, + const bool bMakeNewFrms, const bool bCopyAll, + SwPaM *const pCpyRange ) const { SwDoc* pDoc = rPos.nNode.GetNode().GetDoc(); - bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection(); + const bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection(); + + SwPosition* pStt = rPam.Start(); + SwPosition* pEnd = rPam.End(); - SwPosition *pStt = rPam.Start(), *pEnd = rPam.End(); // kein Copy abfangen. if( !rPam.HasMark() || ( *pStt >= *pEnd && !bColumnSel ) || //JP 29.6.2001: 88963 - dont copy if inspos is in region of start to end //JP 15.11.2001: don't test inclusive the end, ever exclusive ( pDoc == this && *pStt <= rPos && rPos < *pEnd )) - return FALSE; + { + return false; + } - BOOL bEndEqualIns = pDoc == this && rPos == *pEnd; + const bool bEndEqualIns = pDoc == this && rPos == *pEnd; // falls Undo eingeschaltet, erzeuge das UndoCopy-Objekt SwUndoCpyDoc* pUndo = 0; @@ -858,43 +914,63 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, SwNodeRange aRg( pStt->nNode, pEnd->nNode ); SwNodeIndex aInsPos( rPos.nNode ); - BOOL bOneNode = pStt->nNode == pEnd->nNode; - SwTxtNode* pSttNd = pStt->nNode.GetNode().GetTxtNode(); - SwTxtNode* pEndNd = pEnd->nNode.GetNode().GetTxtNode(); - SwTxtNode* pDestNd = aInsPos.GetNode().GetTxtNode(); - BOOL bCopyCollFmt = !pDoc->IsInsOnlyTextGlossary() && ( - ( pDestNd && !pDestNd->GetTxt().Len() ) || - ( !bOneNode && !rPos.nContent.GetIndex() )); - BOOL bCopyBookmarks = TRUE; - BOOL bStartIsTxtNode = 0 != pSttNd; - - // --> OD 2008-03-18 #refactorlists# - String aDummy; - const SwNumRule * pNumRuleToPropagate = - pDoc->SearchNumRule(rPos, FALSE, FALSE, TRUE, 0, aDummy); + const bool bOneNode = pStt->nNode == pEnd->nNode; + SwTxtNode* pSttTxtNd = pStt->nNode.GetNode().GetTxtNode(); + SwTxtNode* pEndTxtNd = pEnd->nNode.GetNode().GetTxtNode(); + SwTxtNode* pDestTxtNd = aInsPos.GetNode().GetTxtNode(); + bool bCopyCollFmt = !pDoc->IsInsOnlyTextGlossary() && + ( ( pDestTxtNd && !pDestTxtNd->GetTxt().Len() ) || + ( !bOneNode && !rPos.nContent.GetIndex() ) ); + bool bCopyBookmarks = true; + BOOL bStartIsTxtNode = 0 != pSttTxtNd; + + // --> OD 2009-08-25 #i86492# + // Correct the search for a previous list: + // First search for non-outline numbering list. Then search for non-outline + // bullet list. + // Keep also the <ListId> value for possible propagation. + String aListIdToPropagate; + const SwNumRule* pNumRuleToPropagate = + pDoc->SearchNumRule( rPos, false, true, false, 0, aListIdToPropagate, true ); + if ( !pNumRuleToPropagate ) + { + pNumRuleToPropagate = + pDoc->SearchNumRule( rPos, false, false, false, 0, aListIdToPropagate, true ); + } + // <-- + // --> OD 2009-08-25 #i86492# + // Do not propagate previous found list, if + // - destination is an empty paragraph which is not in a list and + // - source contains at least one paragraph which is not in a list + if ( pNumRuleToPropagate && + pDestTxtNd && !pDestTxtNd->GetTxt().Len() && !pDestTxtNd->IsInList() && + !lcl_ContainsOnlyParagraphsInList( rPam ) ) + { + pNumRuleToPropagate = 0; + } // <-- // Block, damit aus diesem gesprungen werden kann !! do { - if( pSttNd ) + if( pSttTxtNd ) { // den Anfang nicht komplett kopieren ? if( !bCopyCollFmt || bColumnSel || pStt->nContent.GetIndex() ) { SwIndex aDestIdx( rPos.nContent ); BOOL bCopyOk = FALSE; - if( !pDestNd ) + if( !pDestTxtNd ) { if( pStt->nContent.GetIndex() || bOneNode ) - pDestNd = pDoc->GetNodes().MakeTxtNode( aInsPos, + pDestTxtNd = pDoc->GetNodes().MakeTxtNode( aInsPos, pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD)); else { - pDestNd = (SwTxtNode*)pSttNd->MakeCopy( pDoc, aInsPos ); + pDestTxtNd = static_cast<SwTxtNode*>(pSttTxtNd->MakeCopy( pDoc, aInsPos )); bCopyOk = TRUE; } - aDestIdx.Assign( pDestNd, 0 ); - bCopyCollFmt = TRUE; + aDestIdx.Assign( pDestTxtNd, 0 ); + bCopyCollFmt = true; } else if( !bOneNode || bColumnSel ) { @@ -911,8 +987,8 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, aCpyPam.Move( fnMoveBackward, fnGoCntnt ); } - pDestNd = pDoc->GetNodes()[ aInsPos.GetIndex()-1 ]->GetTxtNode(); - aDestIdx.Assign( pDestNd, pDestNd->GetTxt().Len() ); + pDestTxtNd = pDoc->GetNodes()[ aInsPos.GetIndex()-1 ]->GetTxtNode(); + aDestIdx.Assign( pDestTxtNd, pDestTxtNd->GetTxt().Len() ); // korrigiere den Bereich wieder !! if( bEndEqualIns ) @@ -925,59 +1001,84 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, rPam.Exchange(); aRg.aEnd = pEnd->nNode; - pEndNd = pEnd->nNode.GetNode().GetTxtNode(); + pEndTxtNd = pEnd->nNode.GetNode().GetTxtNode(); } else if( rPos == *pEnd ) // Wurde das Ende auch verschoben { pEnd->nNode--; - pEnd->nContent.Assign( pDestNd, nCntntEnd ); + pEnd->nContent.Assign( pDestTxtNd, nCntntEnd ); aRg.aEnd = pEnd->nNode; - pEndNd = pEnd->nNode.GetNode().GetTxtNode(); + pEndTxtNd = pEnd->nNode.GetNode().GetTxtNode(); } } - const SfxPoolItem * pItem = NULL; - const SfxItemSet * pAttrSet = pDestNd->GetpSwAttrSet(); - /* #107213#: Safe numrule item at destination. */ - int aState = SFX_ITEM_UNKNOWN; + // --> OD 2009-08-25 #i86492# + // Safe also <ListId> item of destination. + int aNumRuleState = SFX_ITEM_UNKNOWN; SwNumRuleItem aNumRuleItem; - - if (pAttrSet != NULL) + int aListIdState = SFX_ITEM_UNKNOWN; + SfxStringItem aListIdItem( RES_PARATR_LIST_ID, String() ); { - aState = - pAttrSet->GetItemState(RES_PARATR_NUMRULE, FALSE, &pItem); - - if (SFX_ITEM_SET == aState) - aNumRuleItem = *((SwNumRuleItem *) pItem); + const SfxItemSet * pAttrSet = pDestTxtNd->GetpSwAttrSet(); + if (pAttrSet != NULL) + { + const SfxPoolItem * pItem = NULL; + aNumRuleState = pAttrSet->GetItemState(RES_PARATR_NUMRULE, FALSE, &pItem); + if (SFX_ITEM_SET == aNumRuleState) + aNumRuleItem = *((SwNumRuleItem *) pItem); + + aListIdState = + pAttrSet->GetItemState(RES_PARATR_LIST_ID, FALSE, &pItem); + if (SFX_ITEM_SET == aListIdState) + { + aListIdItem.SetValue( static_cast<const SfxStringItem*>(pItem)->GetValue() ); + } + } } + // <-- /* #107213# */ if( !bCopyOk ) { - xub_StrLen nCpyLen = ( bOneNode ? pEnd->nContent.GetIndex() - : pSttNd->GetTxt().Len() ) - - pStt->nContent.GetIndex(); - pSttNd->Copy( pDestNd, aDestIdx, pStt->nContent, nCpyLen ); + const xub_StrLen nCpyLen = ( (bOneNode) + ? pEnd->nContent.GetIndex() + : pSttTxtNd->GetTxt().Len() ) + - pStt->nContent.GetIndex(); + pSttTxtNd->CopyText( pDestTxtNd, aDestIdx, + pStt->nContent, nCpyLen ); if( bEndEqualIns ) pEnd->nContent -= nCpyLen; } if( bOneNode ) { - // ist der DestinationNode leer, kopiere die Vorlage mit if( bCopyCollFmt ) { - pSttNd->CopyCollFmt( *pDestNd ); + pSttTxtNd->CopyCollFmt( *pDestTxtNd ); /* #107213# If only a part of one paragraph is copied restore the numrule at the destination. */ - if (! lcl_MarksWholeNode(rPam)) + // --> OD 2009-08-25 #i86492# + // restore also <ListId> item + if ( !lcl_MarksWholeNode(rPam) ) { - if (SFX_ITEM_SET == aState) - pDestNd->SetAttr(aNumRuleItem); + if (SFX_ITEM_SET == aNumRuleState) + { + pDestTxtNd->SetAttr(aNumRuleItem); + } + else + { + pDestTxtNd->ResetAttr(RES_PARATR_NUMRULE); + } + if (SFX_ITEM_SET == aListIdState) + { + pDestTxtNd->SetAttr(aListIdItem); + } else - pDestNd->ResetAttr(RES_PARATR_NUMRULE); + { + pDestTxtNd->ResetAttr(RES_PARATR_LIST_ID); + } } } @@ -987,13 +1088,13 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, aRg.aStart++; } } - else if( pDestNd ) + else if( pDestTxtNd ) { // Problems with insertion of table selections into "normal" text solved. // We have to set the correct PaM for Undo, if this PaM starts in a textnode, // the undo operation will try to merge this node after removing the table. // If we didn't split a textnode, the PaM should start at the inserted table node - if( rPos.nContent.GetIndex() == pDestNd->Len() ) + if( rPos.nContent.GetIndex() == pDestTxtNd->Len() ) { // Insertion at the last position of a textnode (empty or not) aInsPos++; // The table will be inserted behind the text node } @@ -1040,15 +1141,15 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, } } - pDestNd = aInsPos.GetNode().GetTxtNode(); - if( pEndNd ) + pDestTxtNd = aInsPos.GetNode().GetTxtNode(); + if( pEndTxtNd ) { SwIndex aDestIdx( rPos.nContent ); - if( !pDestNd ) + if( !pDestTxtNd ) { - pDestNd = pDoc->GetNodes().MakeTxtNode( aInsPos, + pDestTxtNd = pDoc->GetNodes().MakeTxtNode( aInsPos, pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD)); - aDestIdx.Assign( pDestNd, 0 ); + aDestIdx.Assign( pDestTxtNd, 0 ); aInsPos--; // #112756# #98130# if we have to insert an extra text node @@ -1060,42 +1161,66 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, bStartIsTxtNode = TRUE; } - const SfxPoolItem * pItem = NULL; - const SfxItemSet* pAttrSet = pDestNd->GetpSwAttrSet(); - /* #107213# Save numrule at destination */ - int aState = SFX_ITEM_UNKNOWN; + // --> OD 2009-08-25 #i86492# + // Safe also <ListId> item of destination. + int aNumRuleState = SFX_ITEM_UNKNOWN; SwNumRuleItem aNumRuleItem; - - if (pAttrSet != NULL) + int aListIdState = SFX_ITEM_UNKNOWN; + SfxStringItem aListIdItem( RES_PARATR_LIST_ID, String() ); { - aState = - pAttrSet->GetItemState(RES_PARATR_NUMRULE, FALSE, &pItem); + const SfxItemSet* pAttrSet = pDestTxtNd->GetpSwAttrSet(); + if (pAttrSet != NULL) + { + const SfxPoolItem * pItem = NULL; - if (SFX_ITEM_SET == aState) - aNumRuleItem = *((SwNumRuleItem *) pItem); + aNumRuleState = + pAttrSet->GetItemState(RES_PARATR_NUMRULE, FALSE, &pItem); + if (SFX_ITEM_SET == aNumRuleState) + aNumRuleItem = *((SwNumRuleItem *) pItem); + + aListIdState = + pAttrSet->GetItemState(RES_PARATR_LIST_ID, FALSE, &pItem); + if (SFX_ITEM_SET == aListIdState) + aListIdItem.SetValue( static_cast<const SfxStringItem*>(pItem)->GetValue() ); + } } + // <-- /* #107213# */ - BOOL bEmptyDestNd = 0 == pDestNd->GetTxt().Len(); - pEndNd->Copy( pDestNd, aDestIdx, SwIndex( pEndNd ), + const bool bEmptyDestNd = 0 == pDestTxtNd->GetTxt().Len(); + pEndTxtNd->CopyText( pDestTxtNd, aDestIdx, SwIndex( pEndTxtNd ), pEnd->nContent.GetIndex() ); // auch alle FormatVorlagen kopieren if( bCopyCollFmt && ( bOneNode || bEmptyDestNd )) { - pEndNd->CopyCollFmt( *pDestNd ); + pEndTxtNd->CopyCollFmt( *pDestTxtNd ); - if (bOneNode) + if ( bOneNode ) { /* #107213# If only a part of one paragraph is copied restore the numrule at the destination. */ - if ( ! lcl_MarksWholeNode(rPam)) + // --> OD 2009-08-25 #i86492# + // restore also <ListId> item + if ( !lcl_MarksWholeNode(rPam) ) { - if (SFX_ITEM_SET == aState) - pDestNd->SetAttr(aNumRuleItem); + if (SFX_ITEM_SET == aNumRuleState) + { + pDestTxtNd->SetAttr(aNumRuleItem); + } else - pDestNd->ResetAttr(RES_PARATR_NUMRULE); + { + pDestTxtNd->ResetAttr(RES_PARATR_NUMRULE); + } + if (SFX_ITEM_SET == aListIdState) + { + pDestTxtNd->SetAttr(aListIdItem); + } + else + { + pDestTxtNd->ResetAttr(RES_PARATR_LIST_ID); + } } } } @@ -1104,13 +1229,13 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, if( bCopyAll || aRg.aStart != aRg.aEnd ) { SfxItemSet aBrkSet( pDoc->GetAttrPool(), aBreakSetRange ); - if( pSttNd && bCopyCollFmt && pDestNd->HasSwAttrSet() ) + if( pSttTxtNd && bCopyCollFmt && pDestTxtNd->HasSwAttrSet() ) { - aBrkSet.Put( *pDestNd->GetpSwAttrSet() ); + aBrkSet.Put( *pDestTxtNd->GetpSwAttrSet() ); if( SFX_ITEM_SET == aBrkSet.GetItemState( RES_BREAK, FALSE ) ) - pDestNd->ResetAttr( RES_BREAK ); + pDestTxtNd->ResetAttr( RES_BREAK ); if( SFX_ITEM_SET == aBrkSet.GetItemState( RES_PAGEDESC, FALSE ) ) - pDestNd->ResetAttr( RES_PAGEDESC ); + pDestTxtNd->ResetAttr( RES_PAGEDESC ); } if( aInsPos == pEnd->nNode ) @@ -1124,13 +1249,13 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, else CopyWithFlyInFly( aRg, pEnd->nContent.GetIndex(), aInsPos, bMakeNewFrms, FALSE ); - bCopyBookmarks = FALSE; + bCopyBookmarks = false; // harte Umbrueche wieder in den ersten Node setzen - if( aBrkSet.Count() && 0 != ( pDestNd = pDoc->GetNodes()[ + if( aBrkSet.Count() && 0 != ( pDestTxtNd = pDoc->GetNodes()[ aCpyPam.GetPoint()->nNode.GetIndex()+1 ]->GetTxtNode() ) ) { - pDestNd->SetAttr( aBrkSet ); + pDestTxtNd->SetAttr( aBrkSet ); } } } while( FALSE ); @@ -1169,19 +1294,25 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, *pCpyRange->GetMark() = *aCpyPam.GetMark(); } - if (pNumRuleToPropagate) - pDoc->ReplaceNumRule(aCpyPam, *pNumRuleToPropagate); + if ( pNumRuleToPropagate ) + { + // --> OD 2009-08-25 #i86492# + // use <SwDoc::SetNumRule(..)>, because it also handles the <ListId> +// pDoc->ReplaceNumRule(aCpyPam, *pNumRuleToPropagate); + pDoc->SetNumRule( aCpyPam, *pNumRuleToPropagate, false, + aListIdToPropagate, sal_True, true ); + } pDoc->SetRedlineMode_intern( eOld ); pDoc->SetModified(); - return TRUE; + return true; } // ----- Copy-Methode vom SwDoc - "kopiere Fly's in Fly's" ------ -void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, +void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, const SwNodeIndex& rInsPos, BOOL bMakeNewFrms, BOOL bDelRedlines, BOOL bCopyFlyAtFly ) const { @@ -1220,7 +1351,7 @@ void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndConte // Undo abschalten BOOL bUndo = pDest->DoesUndo(); pDest->DoUndo( FALSE ); - _CopyFlyInFly( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly ); + CopyFlyInFlyImpl( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly ); pDest->DoUndo( bUndo ); SwNodeRange aCpyRange( aSavePos, rInsPos ); @@ -1256,14 +1387,15 @@ void lcl_ChainFmts( SwFlyFrmFmt *pSrc, SwFlyFrmFmt *pDest ) } } -void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, const SwNodeIndex& rSttIdx, - BOOL bCopyFlyAtFly ) const +void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, + const xub_StrLen nEndContentIndex, const SwNodeIndex& rStartIdx, + const bool bCopyFlyAtFly ) const { // Bug 22727: suche erst mal alle Flys zusammen, sortiere sie entsprechend // ihrer Ordnungsnummer und kopiere sie erst dann. Damit wird // die Ordnungsnummer (wird nur im DrawModel verwaltet) // beibehalten. - SwDoc* pDest = rSttIdx.GetNode().GetDoc(); + SwDoc *const pDest = rStartIdx.GetNode().GetDoc(); _ZSortFlys aArr; USHORT nArrLen = GetSpzFrmFmts()->Count(); USHORT n; @@ -1324,11 +1456,11 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentI { if( bAtCntnt ) bAdd = nEndContentIndex > 0; - else + else bAdd = pAPos->nContent <= nEndContentIndex; } } - if( bAdd ) + if( bAdd ) aArr.Insert( _ZSortFly( pFmt, pAnchor, nArrLen + aArr.Count() )); } } @@ -1380,10 +1512,10 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentI nAnchorTxtNdNumInRange = 1; } // Second, search corresponding text node in destination document - // by counting forward from start insert position <rSttIdx> the + // by counting forward from start insert position <rStartIdx> the // determined number of text nodes. - aIdx = rSttIdx; - SwNodeIndex aAnchorNdIdx( rSttIdx ); + aIdx = rStartIdx; + SwNodeIndex aAnchorNdIdx( rStartIdx ); const SwNode& aEndOfContentNd = aIdx.GetNode().GetNodes().GetEndOfContent(); while ( nAnchorTxtNdNumInRange > 0 && @@ -1403,7 +1535,7 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentI // text node in the destination document. ASSERT( false, "<SwDoc::_CopyFlyInFly(..)> - found anchor node index isn't a text node" ); - aAnchorNdIdx = rSttIdx; + aAnchorNdIdx = rStartIdx; while ( !aAnchorNdIdx.GetNode().IsTxtNode() ) { ++aAnchorNdIdx; @@ -1415,7 +1547,7 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentI else { long nOffset = pNewPos->nNode.GetIndex() - rRg.aStart.GetIndex(); - SwNodeIndex aIdx( rSttIdx, nOffset ); + SwNodeIndex aIdx( rStartIdx, nOffset ); pNewPos->nNode = aIdx; } // <-- @@ -1440,8 +1572,8 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentI const SwStartNode* pSNd; if( rCntnt.GetCntntIdx() && 0 != ( pSNd = rCntnt.GetCntntIdx()->GetNode().GetStartNode() ) && - pSNd->GetIndex() < rSttIdx.GetIndex() && - rSttIdx.GetIndex() < pSNd->EndOfSectionIndex() ) + pSNd->GetIndex() < rStartIdx.GetIndex() && + rStartIdx.GetIndex() < pSNd->EndOfSectionIndex() ) { bMakeCpy = FALSE; aArr.Remove( n, 1 ); diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index a6363a209b..5da8c44c3a 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -158,8 +158,8 @@ void lcl_CheckEmptyLayFrm( SwNodes& rNds, SwSection& rSect, } } -SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, - const SfxItemSet* pAttr, BOOL bUpdate ) +SwSection* SwDoc::InsertSwSection( const SwPaM& rRange, const SwSection& rNew, + const SfxItemSet* pAttr, bool bUpdate ) { const SwNode* pPrvNd = 0; USHORT nRegionRet = 0; @@ -178,10 +178,11 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, if( !pStt->nContent.GetIndex() && pEnd->nNode.GetNode().GetCntntNode()->Len() == pEnd->nContent.GetIndex() ) - - ::lcl_CheckEmptyLayFrm( GetNodes(), (SwSection&)rNew, + { + ::lcl_CheckEmptyLayFrm( GetNodes(), const_cast<SwSection&>(rNew), pStt->nNode.GetNode(), pEnd->nNode.GetNode() ); + } } SwUndoInsSection* pUndoInsSect = 0; @@ -193,9 +194,11 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, DoUndo( FALSE ); } - SwSectionFmt* pFmt = MakeSectionFmt( 0 ); - if( pAttr ) + SwSectionFmt* const pFmt = MakeSectionFmt( 0 ); + if ( pAttr ) + { pFmt->SetFmtAttr( *pAttr ); + } SwSectionNode* pNewSectNode = 0; @@ -222,16 +225,27 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, { if( pUndoInsSect ) { - SwTxtNode* pTNd; if( !( pPrvNd && 1 == nRegionRet ) && - pSttPos->nContent.GetIndex() && - 0 != ( pTNd = pSttPos->nNode.GetNode().GetTxtNode() )) - pUndoInsSect->SaveSplitNode( pTNd, TRUE ); - - if( !( pPrvNd && 2 == nRegionRet ) && - 0 != ( pTNd = pEndPos->nNode.GetNode().GetTxtNode() ) && - pTNd->GetTxt().Len() != pEndPos->nContent.GetIndex() ) - pUndoInsSect->SaveSplitNode( pTNd, FALSE ); + pSttPos->nContent.GetIndex() ) + { + SwTxtNode* const pTNd = + pSttPos->nNode.GetNode().GetTxtNode(); + if (pTNd) + { + pUndoInsSect->SaveSplitNode( pTNd, TRUE ); + } + } + + if ( !( pPrvNd && 2 == nRegionRet ) ) + { + SwTxtNode *const pTNd = + pEndPos->nNode.GetNode().GetTxtNode(); + if (pTNd && + (pTNd->GetTxt().Len() != pEndPos->nContent.GetIndex())) + { + pUndoInsSect->SaveSplitNode( pTNd, FALSE ); + } + } } const SwCntntNode* pCNd; @@ -241,7 +255,9 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, pSttPos->nContent.Assign( pSttPos->nNode.GetNode().GetCntntNode(), 0 ); } else if( pSttPos->nContent.GetIndex() ) + { SplitNode( *pSttPos, false ); + } if( pPrvNd && 2 == nRegionRet ) { @@ -293,7 +309,9 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, else { if( pUndoInsSect && pCNd->IsTxtNode() ) + { pUndoInsSect->SaveSplitNode( (SwTxtNode*)pCNd, TRUE ); + } SplitNode( *pPos, false ); pNewSectNode = GetNodes().InsertSection( pPos->nNode, *pFmt, rNew, 0, TRUE ); } @@ -309,9 +327,13 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, { SwPaM aPam( *pNewSectNode->EndOfSectionNode(), *pNewSectNode, 1 ); if( IsRedlineOn() ) + { AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); + } else + { SplitRedline( aPam ); + } } // ist eine Condition gesetzt @@ -320,7 +342,9 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, // dann berechne bis zu dieser Position SwCalc aCalc( *this ); if( ! IsInReading() ) + { FldsToCalc( aCalc, pNewSectNode->GetIndex(), USHRT_MAX ); + } SwSection& rNewSect = pNewSectNode->GetSection(); rNewSect.SetCondHidden( aCalc.Calculate( rNewSect.GetCondition() ).GetBool() ); } @@ -335,7 +359,9 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, ( FTNEND_ATTXTEND_OWNNUMSEQ == ( nVal = ((SwFmtEndAtTxtEnd&) pAttr->Get( RES_END_AT_TXTEND )).GetValue() ) || FTNEND_ATTXTEND_OWNNUMANDFMT == nVal )) + { bUpdateFtn = TRUE; + } } if( pUndoInsSect ) @@ -346,10 +372,14 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, } if( rNew.IsLinkType() ) + { pNewSectNode->GetSection().CreateLink( bUpdate ? CREATE_UPDATE : CREATE_CONNECT ); + } if( bUpdateFtn ) + { GetFtnIdxs().UpdateFtn( SwNodeIndex( *pNewSectNode )); + } SetModified(); return &pNewSectNode->GetSection(); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index e179a6d5c3..dd82c6abc8 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -1034,7 +1034,7 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh, nChPos + 1 ); // Trennzeichen loeschen und SuchString korrigieren - pTxtNd->Erase( aCntPos.nContent, 1 ); + pTxtNd->EraseText( aCntPos.nContent, 1 ); pTxt = pTxtNd->GetTxt().GetBuffer(); nChPos = 0; --nChPos, --pTxt; // for the ++ in the for loop !!! @@ -1551,7 +1551,8 @@ BOOL lcl_DelBox( const SwTableBox*& rpBox, void* pPara ) { // Inserting the seperator SwIndex aCntIdx( pDelPara->pLastNd, pDelPara->pLastNd->GetTxt().Len()); - pDelPara->pLastNd->Insert( pDelPara->cCh, aCntIdx ); + pDelPara->pLastNd->InsertText( pDelPara->cCh, aCntIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); if( pDelPara->pUndo ) pDelPara->pUndo->AddBoxPos( *pDoc, nNdIdx, aDelRg.aEnd.GetIndex(), aCntIdx.GetIndex() ); diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 6629d2cdc6..a5b49971ce 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1249,13 +1249,13 @@ BOOL SwCntntNode::GoNext(SwIndex * pIdx, USHORT nMode ) const { const SwTxtNode& rTNd = *GetTxtNode(); xub_StrLen nPos = pIdx->GetIndex(); - if( pBreakIt->xBreak.is() ) + if( pBreakIt->GetBreakIter().is() ) { sal_Int32 nDone = 0; sal_uInt16 nItrMode = ( CRSR_SKIP_CELLS & nMode ) ? CharacterIteratorMode::SKIPCELL : CharacterIteratorMode::SKIPCONTROLCHARACTER; - nPos = (xub_StrLen)pBreakIt->xBreak->nextCharacters( rTNd.GetTxt(), nPos, + nPos = (xub_StrLen)pBreakIt->GetBreakIter()->nextCharacters( rTNd.GetTxt(), nPos, pBreakIt->GetLocale( rTNd.GetLang( nPos ) ), nItrMode, 1, nDone ); @@ -1297,13 +1297,13 @@ BOOL SwCntntNode::GoPrevious(SwIndex * pIdx, USHORT nMode ) const { const SwTxtNode& rTNd = *GetTxtNode(); xub_StrLen nPos = pIdx->GetIndex(); - if( pBreakIt->xBreak.is() ) + if( pBreakIt->GetBreakIter().is() ) { sal_Int32 nDone = 0; sal_uInt16 nItrMode = ( CRSR_SKIP_CELLS & nMode ) ? CharacterIteratorMode::SKIPCELL : CharacterIteratorMode::SKIPCONTROLCHARACTER; - nPos = (xub_StrLen)pBreakIt->xBreak->previousCharacters( rTNd.GetTxt(), nPos, + nPos = (xub_StrLen)pBreakIt->GetBreakIter()->previousCharacters( rTNd.GetTxt(), nPos, pBreakIt->GetLocale( rTNd.GetLang( nPos ) ), nItrMode, 1, nDone ); diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index 9753bd8a84..85ed6749e3 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -47,6 +47,7 @@ #include <ddefld.hxx> #include <swddetbl.hxx> #include <frame.hxx> +#include <fmtmeta.hxx> #include <docsh.hxx> #include <svtools/smplhint.hxx> @@ -288,7 +289,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, SwTxtNode* pTxtNd = pCNd->GetTxtNode(); if( pTxtNd ) { - const SwpHints* pHts = pTxtNd->GetpSwpHints(); + SwpHints * const pHts = pTxtNd->GetpSwpHints(); // setze die OultineNodes im neuen Nodes-Array //if( bInsOutlineIdx && NO_NUMBERING != //#outline level,removed by zhaojianwei // pTxtNd->GetTxtColl()->GetOutlineLevel() ) @@ -306,16 +307,17 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, // Sonderbehandlung fuer die Felder! if( pHts && pHts->Count() ) { - const SwTxtAttr* pAttr; int bToUndo = &pDestDoc->GetNodes() != &rNds; for( USHORT i = pHts->Count(); i; ) { USHORT nDelMsg = 0; - switch( (pAttr = (*pHts)[ --i ])->Which() ) + SwTxtAttr * const pAttr = pHts->GetTextHint( --i ); + switch ( pAttr->Which() ) { case RES_TXTATR_FIELD: { - SwTxtFld* pTxtFld = (SwTxtFld*)pAttr; + SwTxtFld* pTxtFld = + static_cast<SwTxtFld*>(pAttr); rNds.GetDoc()->InsDelFldInFldLst( !bToUndo, *pTxtFld ); const SwFieldType* pTyp = pTxtFld->GetFld().GetFld()->GetTyp(); @@ -345,6 +347,15 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, case RES_TXTATR_REFMARK: nDelMsg = RES_REFMARK_DELETED; break; + + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + static_cast<SwFmtMeta&>(pAttr->GetAttr()) + .NotifyRemoval(); + break; + + default: + break; } if( nDelMsg && bToUndo ) { @@ -450,7 +461,7 @@ BOOL SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, ( (pAktNode = &aIndex.GetNode())->GetStartNode() && !pAktNode->StartOfSectionIndex() )) return FALSE; - + SwNodeRange aRg( aRange ); // "einfache" StartNodes oder EndNodes ueberspringen @@ -912,7 +923,7 @@ BOOL SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, ASSERT( FALSE, "was ist das fuer ein Node??" ); break; } - + if( nInsPos ) // kopiere den Rest { // der Rest muesste so stimmen @@ -1762,10 +1773,10 @@ USHORT HighestLevel( SwNodes & rNodes, const SwNodeRange & rRange ) |* Letzte Aenderung JP 09.07.92 |* *************************************************************************/ -void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, - BOOL ) +void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) { - SwPosition *pStt = (SwPosition*)rPam.Start(), *pEnd = (SwPosition*)rPam.End(); + SwPosition * const pStt = rPam.Start(); + SwPosition * const pEnd = rPam.End(); if( !rPam.HasMark() || *pStt >= *pEnd ) return; @@ -1775,10 +1786,9 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, SwNodeIndex aEndIdx( pEnd->nNode ); SwNodeIndex aSttIdx( pStt->nNode ); - SwTxtNode* pSrcNd = (*this)[ aSttIdx ]->GetTxtNode(); + SwTxtNode* const pSrcNd = (*this)[ aSttIdx ]->GetTxtNode(); SwTxtNode* pDestNd = rNodes[ rPos.nNode ]->GetTxtNode(); BOOL bSplitDestNd = TRUE; - BOOL bSttTxtNd = 0 != pSrcNd; BOOL bCopyCollFmt = pDestNd && !pDestNd->GetTxt().Len(); if( pSrcNd ) @@ -1792,67 +1802,74 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, rPos.nContent.Assign( pDestNd, 0 ); bCopyCollFmt = TRUE; } -/*!NOSPLIT bSplitDestNd = !bSplitNd && - ( pDestNd->Len() > rPos.nContent.GetIndex() || - !aEndIdx.GetNode().IsTxtNode() ); -*/ -// ASSERT( bSplitNd, "Move mit bSplitNode = FALSE" ); bSplitDestNd = pDestNd->Len() > rPos.nContent.GetIndex() || pEnd->nNode.GetNode().IsTxtNode(); // verschiebe jetzt noch den Inhalt in den neuen Node BOOL bOneNd = pStt->nNode == pEnd->nNode; - xub_StrLen nLen = ( bOneNd ? pEnd->nContent.GetIndex() : pSrcNd->Len() ) - - pStt->nContent.GetIndex(); + const xub_StrLen nLen = + ( (bOneNd) ? pEnd->nContent.GetIndex() : pSrcNd->Len() ) + - pStt->nContent.GetIndex(); if( !pEnd->nNode.GetNode().IsCntntNode() ) { bOneNd = TRUE; - ULONG nSttNdIdx = pStt->nNode.GetIndex() + 1, - nEndNdIdx = pEnd->nNode.GetIndex(); + ULONG nSttNdIdx = pStt->nNode.GetIndex() + 1; + const ULONG nEndNdIdx = pEnd->nNode.GetIndex(); for( ; nSttNdIdx < nEndNdIdx; ++nSttNdIdx ) + { if( (*this)[ nSttNdIdx ]->IsCntntNode() ) { bOneNd = FALSE; break; } + } } // das kopieren / setzen der Vorlagen darf erst nach // dem Splitten erfolgen -//!NOSPLIT if( !bOneNd && ( bSplitNd || bSplitDestNd )) if( !bOneNd && bSplitDestNd ) { if( !rPos.nContent.GetIndex() ) + { bCopyCollFmt = TRUE; + } if( rNodes.IsDocNodes() ) { - SwDoc* pInsDoc = pDestNd->GetDoc(); - BOOL bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( FALSE ); + SwDoc* const pInsDoc = pDestNd->GetDoc(); + const bool bIsUndo = pInsDoc->DoesUndo(); + pInsDoc->DoUndo( false ); pInsDoc->SplitNode( rPos, false ); pInsDoc->DoUndo( bIsUndo ); } else + { pDestNd->SplitCntntNode( rPos ); + } if( rPos.nNode == aEndIdx ) + { aEndIdx--; + } bSplitDestNd = TRUE; pDestNd = rNodes[ rPos.nNode.GetIndex() - 1 ]->GetTxtNode(); if( nLen ) - pSrcNd->Cut( pDestNd, SwIndex( pDestNd, pDestNd->Len()), + { + pSrcNd->CutText( pDestNd, SwIndex( pDestNd, pDestNd->Len()), pStt->nContent, nLen ); + } + } + else if ( nLen ) + { + pSrcNd->CutText( pDestNd, rPos.nContent, pStt->nContent, nLen ); } - else if( nLen ) - pSrcNd->Cut( pDestNd, rPos.nContent, pStt->nContent, nLen ); if( bCopyCollFmt ) { - SwDoc* pInsDoc = pDestNd->GetDoc(); - BOOL bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( FALSE ); + SwDoc* const pInsDoc = pDestNd->GetDoc(); + const bool bIsUndo = pInsDoc->DoesUndo(); + pInsDoc->DoUndo( false ); pSrcNd->CopyCollFmt( *pDestNd ); pInsDoc->DoUndo( bIsUndo ); bCopyCollFmt = FALSE; @@ -1865,7 +1882,8 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, // wird aufgehoben ! pEnd->nContent = pStt->nContent; rPam.DeleteMark(); - GetDoc()->GetDocShell()->Broadcast( SwFmtFldHint( 0, rNodes.IsDocNodes() ? SWFMTFLD_INSERTED : SWFMTFLD_REMOVED ) ); + GetDoc()->GetDocShell()->Broadcast( SwFmtFldHint( 0, + rNodes.IsDocNodes() ? SWFMTFLD_INSERTED : SWFMTFLD_REMOVED ) ); return; } @@ -1875,106 +1893,117 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, { if( rPos.nContent.GetIndex() ) { -//!NOSPLIT if( !bSplitNd && rPos.nContent.GetIndex() == pDestNd->Len() ) if( rPos.nContent.GetIndex() == pDestNd->Len() ) + { rPos.nNode++; + } else if( rPos.nContent.GetIndex() ) { // falls im EndNode gesplittet wird, dann muss der EndIdx // korrigiert werden !! - BOOL bCorrEnde = aEndIdx == rPos.nNode; + const bool bCorrEnd = aEndIdx == rPos.nNode; // es wird kein Text an den TextNode angehaengt, also splitte ihn if( rNodes.IsDocNodes() ) { - SwDoc* pInsDoc = pDestNd->GetDoc(); - BOOL bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( FALSE ); + SwDoc* const pInsDoc = pDestNd->GetDoc(); + const bool bIsUndo = pInsDoc->DoesUndo(); + pInsDoc->DoUndo( false ); pInsDoc->SplitNode( rPos, false ); pInsDoc->DoUndo( bIsUndo ); } else + { pDestNd->SplitCntntNode( rPos ); + } pDestNd = rPos.nNode.GetNode().GetTxtNode(); - if( bCorrEnde ) + if ( bCorrEnd ) + { aEndIdx--; + } } } // am Ende steht noch ein leerer Text Node herum. bSplitDestNd = TRUE; } - pSrcNd = (*this)[ aEndIdx ]->GetTxtNode(); - if( pSrcNd ) + SwTxtNode* const pEndSrcNd = (*this)[ aEndIdx ]->GetTxtNode(); + if ( pEndSrcNd ) { -// if( pEnd->nContent.GetIndex() ? TRUE : aEndIdx != pStt->nNode ) { // am Bereichsende entsteht ein neuer TextNode if( !bSplitDestNd ) { if( rPos.nNode < rNodes.GetEndOfContent().GetIndex() ) + { rPos.nNode++; + } - pDestNd = rNodes.MakeTxtNode( rPos.nNode, pSrcNd->GetTxtColl() ); + pDestNd = + rNodes.MakeTxtNode( rPos.nNode, pEndSrcNd->GetTxtColl() ); rPos.nNode--; rPos.nContent.Assign( pDestNd, 0 ); } else + { pDestNd = rNodes[ rPos.nNode ]->GetTxtNode(); + } if( pDestNd && pEnd->nContent.GetIndex() ) { // verschiebe jetzt noch den Inhalt in den neuen Node - SwIndex aIdx( pSrcNd, 0 ); - pSrcNd->Cut( pDestNd, rPos.nContent, aIdx, + SwIndex aIdx( pEndSrcNd, 0 ); + pEndSrcNd->CutText( pDestNd, rPos.nContent, aIdx, pEnd->nContent.GetIndex()); } if( bCopyCollFmt ) { - SwDoc* pInsDoc = pDestNd->GetDoc(); - BOOL bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( FALSE ); - pSrcNd->CopyCollFmt( *pDestNd ); + SwDoc* const pInsDoc = pDestNd->GetDoc(); + const bool bIsUndo = pInsDoc->DoesUndo(); + pInsDoc->DoUndo( false ); + pEndSrcNd->CopyCollFmt( *pDestNd ); pInsDoc->DoUndo( bIsUndo ); } } } else { - if( bSttTxtNd && aEndIdx.GetNode().IsCntntNode() ) + if ( pSrcNd && aEndIdx.GetNode().IsCntntNode() ) + { aEndIdx++; -//!NOSPLIT + } if( !bSplitDestNd ) { rPos.nNode++; rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), 0 ); } -//!NOSPLIT } if( aEndIdx != aSttIdx ) { // verschiebe jetzt die Nodes in das NodesArary - SwNodeIndex aPrvIdx( rPos.nNode, -1 ); - ULONG nSttDiff = aSttIdx.GetIndex() - pStt->nNode.GetIndex(); + const ULONG nSttDiff = aSttIdx.GetIndex() - pStt->nNode.GetIndex(); SwNodeRange aRg( aSttIdx, aEndIdx ); _MoveNodes( aRg, rNodes, rPos.nNode ); // falls ins gleiche Nodes-Array verschoben wurde, stehen die // Indizies jetzt auch an der neuen Position !!!! // (also alles wieder umsetzen) if( &rNodes == this ) + { pStt->nNode = aRg.aEnd.GetIndex() - nSttDiff; + } } // falls der Start-Node verschoben wurde, in dem der Cursor stand, so // muss der Content im akt. Content angemeldet werden !!! - if( &pStt->nNode.GetNode() == &GetEndOfContent() && - !GoPrevious( &pStt->nNode )) + if ( &pStt->nNode.GetNode() == &GetEndOfContent() ) { - ASSERT( FALSE, "Move() - kein ContentNode mehr vorhanden" ); + const bool bSuccess = GoPrevious( &pStt->nNode ); + ASSERT( bSuccess, "Move() - no ContentNode here" ); + (void) bSuccess; } pStt->nContent.Assign( (*this)[ pStt->nNode ]->GetCntntNode(), pStt->nContent.GetIndex() ); @@ -1983,7 +2012,8 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, // wird aufgehoben ! *pEnd = *pStt; rPam.DeleteMark(); - GetDoc()->GetDocShell()->Broadcast( SwFmtFldHint( 0, rNodes.IsDocNodes() ? SWFMTFLD_INSERTED : SWFMTFLD_REMOVED ) ); + GetDoc()->GetDocShell()->Broadcast( SwFmtFldHint( 0, + rNodes.IsDocNodes() ? SWFMTFLD_INSERTED : SWFMTFLD_REMOVED ) ); } diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index a10833f03b..23dffa13ac 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -1414,7 +1414,10 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType, if( pSrcDoc != pDoc || pCpyPam->Start()->nNode > rInsPos || rInsPos >= pCpyPam->End()->nNode ) - pSrcDoc->Copy( *pCpyPam, *pPam->GetPoint(), false ); + { + pSrcDoc->CopyRange( *pCpyPam, *pPam->GetPoint(), + false ); + } delete pCpyPam; } if( pCpyRg && pSrcDoc == pDoc && diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx index ede1df3978..29b3968c34 100644 --- a/sw/source/core/edit/acorrect.cxx +++ b/sw/source/core/edit/acorrect.cxx @@ -42,7 +42,6 @@ #include <fmtinfmt.hxx> #include <txtatr.hxx> #include <txtinet.hxx> -#include <fmthbsh.hxx> #include <editsh.hxx> #include <doc.hxx> #include <pam.hxx> @@ -125,7 +124,9 @@ void SwAutoCorrDoc::DeleteSel( SwPaM& rDelPam ) pDoc->DeleteAndJoin( rDelPam ); } else - pDoc->Delete( rDelPam ); + { + pDoc->DeleteRange( rDelPam ); + } } BOOL SwAutoCorrDoc::Delete( xub_StrLen nStt, xub_StrLen nEnd ) @@ -143,7 +144,7 @@ BOOL SwAutoCorrDoc::Delete( xub_StrLen nStt, xub_StrLen nEnd ) BOOL SwAutoCorrDoc::Insert( xub_StrLen nPos, const String& rTxt ) { SwPaM aPam( rCrsr.GetPoint()->nNode.GetNode(), nPos ); - rEditSh.GetDoc()->Insert( aPam, rTxt, true ); + rEditSh.GetDoc()->InsertString( aPam, rTxt ); if( !bUndoIdInitialized ) { bUndoIdInitialized = true; @@ -163,23 +164,27 @@ BOOL SwAutoCorrDoc::Replace( xub_StrLen nPos, const String& rTxt ) pPam->GetPoint()->nContent = nPos; } - BOOL bChg = TRUE; - SwTxtNode* pNd = pPam->GetNode()->GetTxtNode(); - if( pNd ) + SwTxtNode * const pNd = pPam->GetNode()->GetTxtNode(); + if ( !pNd ) { - // TextAttribute ohne Ende duerfen nie ersetzt werden! - sal_Unicode cChr; - for( xub_StrLen n = 0, nLen = rTxt.Len(); n < nLen; ++n ) - if( ( CH_TXTATR_BREAKWORD == (cChr = pNd->GetTxt(). - GetChar( n + nPos )) || CH_TXTATR_INWORD == cChr ) && - pNd->GetTxtAttr( n + nPos ) ) - { - bChg = FALSE; - break; - } + return FALSE; + } + + // text attributes with dummy characters must not be replaced! + bool bDoReplace = true; + xub_StrLen const nLen = rTxt.Len(); + for ( xub_StrLen n = 0; n < nLen; ++n ) + { + sal_Unicode const Char = pNd->GetTxt().GetChar( n + nPos ); + if ( ( CH_TXTATR_BREAKWORD == Char || CH_TXTATR_INWORD == Char ) + && pNd->GetTxtAttrForCharAt( n + nPos ) ) + { + bDoReplace = false; + break; + } } - if( bChg ) + if ( bDoReplace ) { SwDoc* pDoc = rEditSh.GetDoc(); @@ -190,7 +195,9 @@ BOOL SwAutoCorrDoc::Replace( xub_StrLen nPos, const String& rTxt ) if( pDoc->IsAutoFmtRedline() ) { if( nPos == pNd->GetTxt().Len() ) // am Ende erfolgt ein Insert - pDoc->Insert( *pPam, rTxt, true ); + { + pDoc->InsertString( *pPam, rTxt ); + } else { _PaMIntoCrsrShellRing aTmp( rEditSh, rCrsr, *pPam ); @@ -198,7 +205,7 @@ BOOL SwAutoCorrDoc::Replace( xub_StrLen nPos, const String& rTxt ) pPam->SetMark(); pPam->GetPoint()->nContent = Min( pNd->GetTxt().Len(), xub_StrLen( nPos + rTxt.Len() )); - pDoc->Replace( *pPam, rTxt, FALSE ); + pDoc->ReplaceRange( *pPam, rTxt, false ); pPam->Exchange(); pPam->DeleteMark(); } @@ -333,7 +340,7 @@ BOOL SwAutoCorrDoc::ChgAutoCorrWord( xub_StrLen & rSttPos, xub_StrLen nEndPos, '.' != pFnd->GetLong().GetChar( pFnd->GetLong().Len() - 1 ) ) { // replace the selection - pDoc->Replace( aPam, pFnd->GetLong(), false); + pDoc->ReplaceRange( aPam, pFnd->GetLong(), false); bRet = TRUE; } } @@ -374,7 +381,7 @@ BOOL SwAutoCorrDoc::ChgAutoCorrWord( xub_StrLen & rSttPos, xub_StrLen nEndPos, SwDontExpandItem aExpItem; aExpItem.SaveDontExpandItems( *aPam.GetPoint() ); - pAutoDoc->Copy( aCpyPam, *aPam.GetPoint(), false ); + pAutoDoc->CopyRange( aCpyPam, *aPam.GetPoint(), false ); aExpItem.RestoreDontExpandItems( *aPam.GetPoint() ); diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 9622075cd1..114ae919a1 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -44,9 +44,7 @@ #include <svx/lrspitem.hxx> #include <svx/brkitem.hxx> #include <svx/adjitem.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/fontitem.hxx> #include <svx/langitem.hxx> #include <svx/cscoitem.hxx> @@ -74,7 +72,6 @@ #include <acorrect.hxx> #include <shellres.hxx> #include <section.hxx> -#include <fmthbsh.hxx> #include <frmatr.hxx> #include <charatr.hxx> #include <mdiexp.hxx> @@ -645,7 +642,7 @@ BOOL SwAutoFormat::DoUnderline() aBox.SetLine( &aLine, BOX_LINE_BOTTOM ); aBox.SetDistance( 42 ); // ~0,75 mm aSet.Put(aBox); - pDoc->Insert( aDelPam, aSet, 0 ); + pDoc->InsertItemSet( aDelPam, aSet, 0 ); aDelPam.DeleteMark(); } @@ -1300,7 +1297,9 @@ void SwAutoFormat::DelMoreLinesBlanks( BOOL bWithLineBreaks ) BOOL bHasBlnks = HasSelBlanks( *pNxt ); DeleteSel( *pNxt ); if( !bHasBlnks ) - pDoc->Insert( *pNxt, ' ' ); + { + pDoc->InsertString( *pNxt, sal_Unicode(' ') ); + } } if( pNxt == &aDelPam ) @@ -1357,7 +1356,9 @@ void SwAutoFormat::BuildIndent() IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() )) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; pNxtNd = GetNextNode(); @@ -1396,7 +1397,9 @@ void SwAutoFormat::BuildTextIndent() bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() ) ) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; pNxtNd = GetNextNode(); @@ -1430,7 +1433,9 @@ void SwAutoFormat::BuildText() bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() ) ) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; const SwTxtNode* pCurrNode = pNxtNd; @@ -1705,7 +1710,7 @@ void SwAutoFormat::BuildEnum( USHORT nLvl, USHORT nDigitLevel ) String sChgStr( '\t' ); if( bChgBullet ) sChgStr.Insert( aFlags.cBullet, 0 ); - pDoc->Insert( aDelPam, sChgStr, true ); + pDoc->InsertString( aDelPam, sChgStr ); SfxItemSet aSet( pDoc->GetAttrPool(), aTxtNodeSetRange ); if( bChgBullet ) @@ -1745,7 +1750,9 @@ void SwAutoFormat::BuildEnum( USHORT nLvl, USHORT nDigitLevel ) bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() ) ) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; const SwTxtNode* pCurrNode = pNxtNd; @@ -1813,7 +1820,9 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces ) aDelPam.GetMark()->nContent = nSpaceStt; DeleteSel( aDelPam ); if( bInsTab ) - pDoc->Insert( aDelPam, '\t' ); + { + pDoc->InsertString( aDelPam, sal_Unicode('\t') ); + } } } @@ -1831,7 +1840,9 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces ) IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() ) ) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; pNxtNd = GetNextNode(); @@ -1942,7 +1953,7 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos ) sReplace.Erase( 1 ); bSetHardBlank = TRUE; } - pDoc->Replace( aDelPam, sReplace, FALSE ); + pDoc->ReplaceRange( aDelPam, sReplace, false ); if( aFlags.bWithRedlining ) { @@ -1957,7 +1968,7 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos ) aDelPam.DeleteMark(); if( bSetHardBlank ) { - pDoc->Insert( aDelPam, CHAR_HARDBLANK ); + pDoc->InsertString( aDelPam, CHAR_HARDBLANK ); ++nPos; } } @@ -1994,7 +2005,7 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos ) aDelPam.SetMark(); aDelPam.GetPoint()->nContent = nPos+1; - pDoc->Replace( aDelPam, sReplace, FALSE ); + pDoc->ReplaceRange( aDelPam, sReplace, false ); if( aFlags.bWithRedlining ) { @@ -2012,7 +2023,7 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos ) if( bSetHardBlank ) { aDelPam.GetPoint()->nContent = nPos; - pDoc->Insert( aDelPam, CHAR_HARDBLANK ); + pDoc->InsertString( aDelPam, CHAR_HARDBLANK ); aDelPam.GetPoint()->nContent = ++nPos; } } diff --git a/sw/source/core/edit/edatmisc.cxx b/sw/source/core/edit/edatmisc.cxx index 1913da57a9..0c8952ff81 100644 --- a/sw/source/core/edit/edatmisc.cxx +++ b/sw/source/core/edit/edatmisc.cxx @@ -141,7 +141,9 @@ void SwEditShell::SetAttr( const SfxPoolItem& rHint, USHORT nFlags ) FOREACHPAM_START(this) if( PCURCRSR->HasMark() && ( bIsTblMode || *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() )) - GetDoc()->Insert(*PCURCRSR, rHint, nFlags ); + { + GetDoc()->InsertPoolItem(*PCURCRSR, rHint, nFlags ); + } FOREACHPAM_END() GetDoc()->EndUndo(UNDO_INSATTR, NULL); @@ -150,7 +152,7 @@ void SwEditShell::SetAttr( const SfxPoolItem& rHint, USHORT nFlags ) { if( !HasSelection() ) UpdateAttr(); - GetDoc()->Insert( *pCrsr, rHint, nFlags ); + GetDoc()->InsertPoolItem( *pCrsr, rHint, nFlags ); } EndAllAction(); } @@ -169,7 +171,9 @@ void SwEditShell::SetAttr( const SfxItemSet& rSet, USHORT nFlags ) FOREACHPAM_START(this) if( PCURCRSR->HasMark() && ( bIsTblMode || *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() )) - GetDoc()->Insert(*PCURCRSR, rSet, nFlags ); + { + GetDoc()->InsertItemSet(*PCURCRSR, rSet, nFlags ); + } FOREACHPAM_END() GetDoc()->EndUndo(UNDO_INSATTR, NULL); @@ -178,7 +182,7 @@ void SwEditShell::SetAttr( const SfxItemSet& rSet, USHORT nFlags ) { if( !HasSelection() ) UpdateAttr(); - GetDoc()->Insert( *pCrsr, rSet, nFlags ); + GetDoc()->InsertItemSet( *pCrsr, rSet, nFlags ); } EndAllAction(); } diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index 259cb34f1c..f12766f6ae 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -452,17 +452,21 @@ BOOL lcl_IsNoEndTxtAttrAtPos( const SwTxtNode& rTNd, xub_StrLen nPos, } // and fields - const SwTxtAttr* pTFld; - if( CH_TXTATR_BREAKWORD == rTxt.GetChar( nPos ) && - 0 != ( pTFld = rTNd.GetTxtAttr( nPos ) ) ) + if ( CH_TXTATR_BREAKWORD == rTxt.GetChar( nPos ) ) { - bRet = TRUE; // all other then fields can be - // defined as weak-script ? - const SwField* pFld; - if( RES_TXTATR_FIELD == pTFld->Which() && - 0 != (pFld = pTFld->GetFld().GetFld() ) ) + const SwTxtAttr* const pAttr = rTNd.GetTxtAttrForCharAt( nPos ); + if (pAttr) { - sExp += pFld->Expand(); + bRet = TRUE; // all other than fields can be + // defined as weak-script ? + if ( RES_TXTATR_FIELD == pAttr->Which() ) + { + const SwField* const pFld = pAttr->GetFld().GetFld(); + if (pFld) + { + sExp += pFld->Expand(); + } + } } } @@ -474,14 +478,14 @@ BOOL lcl_IsNoEndTxtAttrAtPos( const SwTxtNode& rTNd, xub_StrLen nPos, { USHORT nScript; for( n = 0; n < nEnd; n = (xub_StrLen) - pBreakIt->xBreak->endOfScript( sExp, n, nScript )) + pBreakIt->GetBreakIter()->endOfScript( sExp, n, nScript )) { - nScript = pBreakIt->xBreak->getScriptType( sExp, n ); + nScript = pBreakIt->GetBreakIter()->getScriptType( sExp, n ); rScrpt |= lcl_SetScriptFlags( nScript ); } } else - rScrpt |= lcl_SetScriptFlags( pBreakIt->xBreak-> + rScrpt |= lcl_SetScriptFlags( pBreakIt->GetBreakIter()-> getScriptType( sExp, nEnd-1 )); } @@ -493,7 +497,7 @@ BOOL lcl_IsNoEndTxtAttrAtPos( const SwTxtNode& rTNd, xub_StrLen nPos, USHORT SwEditShell::GetScriptType() const { USHORT nRet = 0; - if( pBreakIt->xBreak.is() ) + //if( pBreakIt->GetBreakIter().is() ) { FOREACHPAM_START(this) @@ -525,7 +529,7 @@ USHORT SwEditShell::GetScriptType() const { nScript = pScriptInfo ? pScriptInfo->ScriptType( nPos ) : - pBreakIt->xBreak->getScriptType( pTNd->GetTxt(), nPos ); + pBreakIt->GetBreakIter()->getScriptType( pTNd->GetTxt(), nPos ); } else nScript = GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage() ); @@ -534,7 +538,7 @@ USHORT SwEditShell::GetScriptType() const nRet |= lcl_SetScriptFlags( nScript ); } } - else + else if ( pBreakIt->GetBreakIter().is() ) { ULONG nEndIdx = pEnd->nNode.GetIndex(); SwNodeIndex aIdx( pStt->nNode ); @@ -563,7 +567,7 @@ USHORT SwEditShell::GetScriptType() const { nScript = pScriptInfo ? pScriptInfo->ScriptType( nChg ) : - pBreakIt->xBreak->getScriptType( + pBreakIt->GetBreakIter()->getScriptType( rTxt, nChg ); if( !lcl_IsNoEndTxtAttrAtPos( *pTNd, nChg, nRet, TRUE, @@ -578,7 +582,7 @@ USHORT SwEditShell::GetScriptType() const nChg = pScriptInfo ? pScriptInfo->NextScriptChg( nChg ) : - (xub_StrLen)pBreakIt->xBreak->endOfScript( + (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( rTxt, nChg, nScript ); nFldPos = rTxt.Search( diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx index f3942ff6c3..823dee6054 100644 --- a/sw/source/core/edit/eddel.cxx +++ b/sw/source/core/edit/eddel.cxx @@ -249,7 +249,8 @@ long SwEditShell::Copy( SwEditShell* pDestShell ) bFirstMove = FALSE; } - if( !GetDoc()->Copy( *PCURCRSR, *pPos, false )) + const bool bSuccess( GetDoc()->CopyRange( *PCURCRSR, *pPos, false ) ); + if (!bSuccess) continue; SwPaM aInsertPaM(*pPos, SwPosition(aSttNdIdx)); @@ -319,7 +320,8 @@ BOOL SwEditShell::Replace( const String& rNewStr, BOOL bRegExpRplc ) FOREACHPAM_START(this) if( PCURCRSR->HasMark() && *PCURCRSR->GetMark() != *PCURCRSR->GetPoint() ) { - bRet = GetDoc()->Replace( *PCURCRSR, rNewStr, bRegExpRplc ) || bRet; + bRet = GetDoc()->ReplaceRange( *PCURCRSR, rNewStr, bRegExpRplc ) + || bRet; SaveTblBoxCntnt( PCURCRSR->GetPoint() ); } FOREACHPAM_END() diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx index 310def985d..82e915cdfe 100644 --- a/sw/source/core/edit/edfld.cxx +++ b/sw/source/core/edit/edfld.cxx @@ -232,8 +232,8 @@ void SwEditShell::FieldToText( SwFieldType* pType ) String aEntry( pFmtFld->GetFld()->Expand() ); pPaM->SetMark(); pPaM->Move( fnMoveForward ); - GetDoc()->Delete( *pPaM ); - GetDoc()->Insert( *pPaM, aEntry, true ); + GetDoc()->DeleteRange( *pPaM ); + GetDoc()->InsertString( *pPaM, aEntry ); } else if( bDDEFld ) { @@ -258,17 +258,20 @@ void SwEditShell::FieldToText( SwFieldType* pType ) |* Quelle: vgl. SwEditShell::Insert( String ) |* *************************************************************************/ -void SwEditShell::Insert(SwField& rFld) +void SwEditShell::Insert2(SwField& rFld, const bool bForceExpandHints) { SET_CURR_SHELL( this ); StartAllAction(); SwFmtFld aFld( rFld ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND + : nsSetAttrMode::SETATTR_DEFAULT; + FOREACHPAM_START(this) // fuer jeden PaM - if( !GetDoc()->Insert( *PCURCRSR, aFld, 0 ) ) - { - ASSERT( FALSE, "Doc->Insert(Field) failed") - } + bool bSuccess(GetDoc()->InsertPoolItem(*PCURCRSR, aFld, nInsertFlags)); + ASSERT( bSuccess, "Doc->Insert(Field) failed"); + (void) bSuccess; FOREACHPAM_END() // fuer jeden PaM EndAllAction(); @@ -285,11 +288,11 @@ void SwEditShell::Insert(SwField& rFld) inline SwTxtFld *GetDocTxtFld( const SwPosition* pPos ) { - SwTxtNode *pNode = pPos->nNode.GetNode().GetTxtNode(); - if( pNode ) - return pNode->GetTxtFld( pPos->nContent ); - else - return 0; + SwTxtNode * const pNode = pPos->nNode.GetNode().GetTxtNode(); + return (pNode) + ? static_cast<SwTxtFld*>( pNode->GetTxtAttrForCharAt( + pPos->nContent.GetIndex(), RES_TXTATR_FIELD )) + : 0; } SwField* SwEditShell::GetCurFld() const diff --git a/sw/source/core/edit/edglbldc.cxx b/sw/source/core/edit/edglbldc.cxx index d26acf1f53..5e87946247 100644 --- a/sw/source/core/edit/edglbldc.cxx +++ b/sw/source/core/edit/edglbldc.cxx @@ -343,7 +343,10 @@ BOOL SwEditShell::MoveGlobalDocContent( const SwGlblDocContents& rArr , else aInsPos = pMyDoc->GetNodes().GetEndOfContent(); - BOOL bRet = pMyDoc->Move( aRg, aInsPos, IDocumentContentOperations::DOC_MOVEALLFLYS ); + bool bRet = pMyDoc->MoveNodeRange( aRg, aInsPos, + static_cast<IDocumentContentOperations::SwMoveFlags>( + IDocumentContentOperations::DOC_MOVEALLFLYS + | IDocumentContentOperations::DOC_CREATEUNDOOBJ )); EndAllAction(); return bRet; diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 0196844442..41879086d0 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -168,7 +168,7 @@ USHORT SwEditShell::SaveGlossaryDoc( SwTextBlocks& rBlock, aStt = pGDoc->GetNodes().GetEndOfExtras(); pCntntNd = pGDoc->GetNodes().GoNext( &aStt ); SwPosition aInsPos( aStt, SwIndex( pCntntNd )); - pMyDoc->Copy( aCpyPam, aInsPos, false ); + pMyDoc->CopyRange( aCpyPam, aInsPos, false ); nRet = rBlock.PutDoc(); } @@ -250,13 +250,16 @@ BOOL SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd ) { PCURCRSR->SetMark(); PCURCRSR->Move( fnMoveForward, fnGoCntnt ); - bRet = GetDoc()->Copy( *PCURCRSR, aPos, false ) || bRet; + bRet = GetDoc()->CopyRange( *PCURCRSR, aPos, false ) + || bRet; PCURCRSR->Exchange(); PCURCRSR->DeleteMark(); } } else - bRet = GetDoc()->Copy( *PCURCRSR, aPos, false ) || bRet; + { + bRet = GetDoc()->CopyRange( *PCURCRSR, aPos, false ) || bRet; + } FOREACHPAM_END() } diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 6e6d9a8303..c1e368a0b8 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -86,10 +86,9 @@ void SwEditShell::Insert( sal_Unicode c, BOOL bOnlyCurrCrsr ) StartAllAction(); FOREACHPAM_START(this) - if( !GetDoc()->Insert(*PCURCRSR, c) ) - { - ASSERT( FALSE, "Doc->Insert(c) failed." ) - } + const bool bSuccess = GetDoc()->InsertString(*PCURCRSR, c); + ASSERT( bSuccess, "Doc->Insert() failed." ); + (void) bSuccess; SaveTblBoxCntnt( PCURCRSR->GetPoint() ); if( bOnlyCurrCrsr ) @@ -106,17 +105,24 @@ void SwEditShell::Insert( sal_Unicode c, BOOL bOnlyCurrCrsr ) ******************************************************************************/ -void SwEditShell::Insert(const String &rStr) +void SwEditShell::Insert2(const String &rStr, const bool bForceExpandHints ) { StartAllAction(); { + const enum IDocumentContentOperations::InsertFlags nInsertFlags = + (bForceExpandHints) + ? static_cast<IDocumentContentOperations::InsertFlags>( + IDocumentContentOperations::INS_FORCEHINTEXPAND | + IDocumentContentOperations::INS_EMPTYEXPAND) + : IDocumentContentOperations::INS_EMPTYEXPAND; + SwPaM *_pStartCrsr = getShellCrsr( true ), *__pStartCrsr = _pStartCrsr; do { //OPT: GetSystemCharSet - if( !GetDoc()->Insert( *_pStartCrsr, rStr, true ) ) - { - ASSERT( FALSE, "Doc->Insert(Str) failed." ) - } + const bool bSuccess = + GetDoc()->InsertString(*_pStartCrsr, rStr, nInsertFlags); + ASSERT( bSuccess, "Doc->Insert() failed." ); + (void) bSuccess; SaveTblBoxCntnt( _pStartCrsr->GetPoint() ); @@ -778,7 +784,7 @@ BOOL SwEditShell::InsertURL( const SwFmtINetFmt& rFmt, const String& rStr, BOOL if( bInsTxt ) { - Insert( rStr ); + Insert2( rStr ); SetMark(); ExtendSelection( FALSE, rStr.Len() ); } diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx index 052937fb5e..c10370979a 100644 --- a/sw/source/core/edit/edlingu.cxx +++ b/sw/source/core/edit/edlingu.cxx @@ -49,7 +49,6 @@ #include <svx/langitem.hxx> #include <svx/SpellPortions.hxx> #include <svx/scripttypeitem.hxx> -#include <fmthbsh.hxx> #include <charatr.hxx> #include <editsh.hxx> #include <doc.hxx> @@ -70,6 +69,8 @@ #include <redline.hxx> // SwRedline #include <docary.hxx> // SwRedlineTbl #include <docsh.hxx> +#include <txatbase.hxx> + using namespace ::svx; using namespace ::com::sun::star; @@ -682,7 +683,7 @@ void SwHyphIter::InsertSoftHyph( const xub_StrLen nHyphPos ) DelSoftHyph( *pCrsr ); pSttPos->nContent += nHyphPos; SwPaM aRg( *pSttPos ); - pDoc->Insert( aRg, CHAR_SOFTHYPHEN ); + pDoc->InsertString( aRg, CHAR_SOFTHYPHEN ); // Durch das Einfuegen des SoftHyphs ist ein Zeichen hinzugekommen //JP 18.07.95: warum, ist doch ein SwIndex, dieser wird doch mitverschoben !! // pSttPos->nContent++; @@ -1342,7 +1343,7 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, // ... and apply language if necessary if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage) SetAttr( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId), nLangWhichId ); - pDoc->Insert(*pCrsr, aCurrentNewPortion->sText, true); + pDoc->InsertString(*pCrsr, aCurrentNewPortion->sText); } else if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage) { @@ -1388,7 +1389,7 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, if(rLang.GetLanguage() != aCurrentNewPortion->eLanguage) SetAttr( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId) ); //insert the new string - pDoc->Insert(*pCrsr, aCurrentNewPortion->sText, true); + pDoc->InsertString(*pCrsr, aCurrentNewPortion->sText); //set the cursor to the end of the inserted string *pCrsr->Start() = *pCrsr->End(); @@ -1819,20 +1820,18 @@ void SwSpellIter::AddPortion(uno::Reference< XSpellAlternatives > xAlt, xub_Unicode cChar = pTxtNode->GetTxt().GetChar( pCrsr->GetMark()->nContent.GetIndex() ); if( CH_TXTATR_BREAKWORD == cChar || CH_TXTATR_INWORD == cChar) { - const SwTxtAttr* pTxtAttr = pTxtNode->GetTxtAttr( - pCrsr->GetMark()->nContent.GetIndex(), RES_TXTATR_FIELD ); - bField = 0 != pTxtAttr; - if(!bField) - { - const SwTxtAttr* pTmpTxtAttr = pTxtNode->GetTxtAttr( - pCrsr->GetMark()->nContent.GetIndex(), RES_TXTATR_FTN ); - bField = 0 != pTmpTxtAttr; - } - if(!bField) + const SwTxtAttr* pTxtAttr = pTxtNode->GetTxtAttrForCharAt( + pCrsr->GetMark()->nContent.GetIndex() ); + const USHORT nWhich = pTxtAttr + ? pTxtAttr->Which() + : static_cast<USHORT>(RES_TXTATR_END); + switch (nWhich) { - const SwTxtAttr* pTmpTxtAttr = pTxtNode->GetTxtAttr( - pCrsr->GetMark()->nContent.GetIndex(), RES_TXTATR_FLYCNT ); - bField = 0 != pTmpTxtAttr; + case RES_TXTATR_FIELD: + case RES_TXTATR_FTN: + case RES_TXTATR_FLYCNT: + bField = true; + break; } } diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx index 620289d66e..e04d62c4f5 100644 --- a/sw/source/core/edit/ednumber.cxx +++ b/sw/source/core/edit/ednumber.cxx @@ -825,9 +825,9 @@ USHORT SwEditShell::GetNodeNumStart() const -----------------------------------------------------------------------*/ // --> OD 2008-03-18 #refactorlists# -const SwNumRule * SwEditShell::SearchNumRule( BOOL bForward, - BOOL bNum, - BOOL bOutline, +const SwNumRule * SwEditShell::SearchNumRule( const bool bForward, + const bool bNum, + const bool bOutline, int nNonEmptyAllowed, String& sListId ) { diff --git a/sw/source/core/edit/edsect.cxx b/sw/source/core/edit/edsect.cxx index fbf0d38ff5..ad36b898fd 100644 --- a/sw/source/core/edit/edsect.cxx +++ b/sw/source/core/edit/edsect.cxx @@ -56,8 +56,8 @@ const SwSection* SwEditShell::InsertSection( const SwSection& rNew, GetDoc()->StartUndo( UNDO_INSSECTION, NULL ); FOREACHPAM_START(this) - const SwSection* pNew = GetDoc()->Insert( *PCURCRSR, - rNew, pAttr ); + const SwSection* const pNew = + GetDoc()->InsertSwSection( *PCURCRSR, rNew, pAttr ); if( !pRet ) pRet = pNew; FOREACHPAM_END() diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx index 0b72c6fcf1..c4b81facd8 100644 --- a/sw/source/core/edit/edtox.cxx +++ b/sw/source/core/edit/edtox.cxx @@ -82,10 +82,13 @@ void SwEditShell::Insert(const SwTOXMark& rMark) if( bInsAtPos ) { SwPaM aTmp( *pStt ); - GetDoc()->Insert( aTmp, rMark, 0 ); + GetDoc()->InsertPoolItem( aTmp, rMark, 0 ); } else if( *pEnd != *pStt ) - GetDoc()->Insert( *PCURCRSR, rMark, nsSetAttrMode::SETATTR_DONTEXPAND ); + { + GetDoc()->InsertPoolItem( *PCURCRSR, rMark, + nsSetAttrMode::SETATTR_DONTEXPAND ); + } FOREACHPAM_END() EndAllAction(); @@ -98,7 +101,7 @@ void SwEditShell::DeleteTOXMark( SwTOXMark* pMark ) SET_CURR_SHELL( this ); StartAllAction(); - pDoc->Delete( pMark ); + pDoc->DeleteTOXMark( pMark ); EndAllAction(); } diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx index 41e671ca65..a62957faa5 100644 --- a/sw/source/core/fields/cellfml.cxx +++ b/sw/source/core/fields/cellfml.cxx @@ -159,13 +159,13 @@ double SwTableBox::GetValue( SwTblCalcPara& rCalcPara ) const // beginnt an erster Position ein "RechenFeld", dann erfrage den Wert // von diesem - sal_Unicode cChr; - if( nSttPos < rTxt.Len() && - ( CH_TXTATR_BREAKWORD == ( cChr = rTxt.GetChar(nSttPos)) || - CH_TXTATR_INWORD == cChr )) + sal_Unicode const Char = rTxt.GetChar(nSttPos); + if ( nSttPos < rTxt.Len() && + ( CH_TXTATR_BREAKWORD == Char || CH_TXTATR_INWORD == Char ) ) { SwIndex aIdx( pTxtNd, nSttPos ); - SwTxtFld* pTxtFld = pTxtNd->GetTxtFld( aIdx ); + SwTxtFld * const pTxtFld = static_cast<SwTxtFld*>( + pTxtNd->GetTxtAttrForCharAt(aIdx.GetIndex(), RES_TXTATR_FIELD)); if( !pTxtFld ) break; diff --git a/sw/source/core/fields/ddetbl.cxx b/sw/source/core/fields/ddetbl.cxx index 10d78c6188..ba496601c6 100644 --- a/sw/source/core/fields/ddetbl.cxx +++ b/sw/source/core/fields/ddetbl.cxx @@ -131,8 +131,8 @@ void SwDDETable::ChangeContent() SwTxtNode* pTxtNode = aNdIdx.GetNode().GetTxtNode(); ASSERT( pTxtNode, "Kein Node" ); SwIndex aCntIdx( pTxtNode, 0 ); - pTxtNode->Erase( aCntIdx ); - pTxtNode->Insert( aLine.GetToken( i, '\t' ), aCntIdx ); + pTxtNode->EraseText( aCntIdx ); + pTxtNode->InsertText( aLine.GetToken( i, '\t' ), aCntIdx ); SwTableBoxFmt* pBoxFmt = (SwTableBoxFmt*)pBox->GetFrmFmt(); pBoxFmt->LockModify(); diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index 55c8bd2d14..2e31d1d43e 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -66,6 +66,7 @@ #endif #include <svtools/urihelper.hxx> #include <svtools/useroptions.hxx> +#include <svtools/syslocale.hxx> #include <tools/time.hxx> #include <tools/datetime.hxx> @@ -931,10 +932,11 @@ SwFieldType* SwDocInfoFieldType::Copy() const } void lcl_GetLocalDataWrapper( ULONG nLang, - LocaleDataWrapper **ppAppLocalData, - LocaleDataWrapper **ppLocalData ) + const LocaleDataWrapper **ppAppLocalData, + const LocaleDataWrapper **ppLocalData ) { - *ppAppLocalData = &GetAppLocaleData(); + SvtSysLocale aLocale; + *ppAppLocalData = &aLocale.GetLocaleData(); *ppLocalData = *ppAppLocalData; if( nLang != SvxLocaleToLanguage( (*ppLocalData)->getLocale() ) ) *ppLocalData = new LocaleDataWrapper( @@ -949,7 +951,7 @@ String SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, sal_uInt16 nLang, const String& rName ) const { String aStr; - LocaleDataWrapper *pAppLocalData = 0, *pLocalData = 0; + const LocaleDataWrapper *pAppLocalData = 0, *pLocalData = 0; SwDocShell *pDocShell(GetDoc()->GetDocShell()); DBG_ASSERT(pDocShell, "no SwDocShell"); if (!pDocShell) { return aStr; } diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index ae3ead27fd..3dd5cd089f 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -611,7 +611,7 @@ SwFieldType* SwValueField::ChgTyp( SwFieldType* pNewType ) sal_uInt32 SwValueField::GetSystemFormat(SvNumberFormatter* pFormatter, sal_uInt32 nFmt) { const SvNumberformat* pEntry = pFormatter->GetEntry(nFmt); - USHORT nLng = SvxLocaleToLanguage( GetAppLocaleData().getLocale() ); + USHORT nLng = SvxLocaleToLanguage( SvtSysLocale().GetLocaleData().getLocale() ); if (pEntry && nLng != pEntry->GetLanguage()) { diff --git a/sw/source/core/fields/postithelper.cxx b/sw/source/core/fields/postithelper.cxx index de3fc1f8a9..9a4542b628 100644 --- a/sw/source/core/fields/postithelper.cxx +++ b/sw/source/core/fields/postithelper.cxx @@ -64,8 +64,9 @@ SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos( std::vector< SwLa if( !pTxtFrm->IsFollow() ) { pTxtFrm = ((SwTxtFrm*)pTxtFrm)->GetFrmAtPos( rPos ); - SwPageFrm *pPage = pTxtFrm ? pTxtFrm->FindPageFrm() : 0; - if( pPage ) + SwPageFrm *pPage = pTxtFrm ? pTxtFrm->FindPageFrm() : 0; + // #i103490# + if ( pPage && !pPage->IsInvalid() && !pPage->IsInvalidFly() ) { SwLayoutInfo aInfo; pTxtFrm->GetCharRect( aInfo.mPosition, rPos, 0 ); diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 2f2c6c4a26..7204947d1a 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -331,8 +331,8 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) case REF_ONLYCAPTION: { - const SwTxtAttr* pTxtAttr = pTxtNd->GetTxtAttr( nStt, - RES_TXTATR_FIELD ); + const SwTxtAttr* const pTxtAttr = + pTxtNd->GetTxtAttrForCharAt(nStt, RES_TXTATR_FIELD); if( pTxtAttr ) nStt = SwGetExpField::GetReferenceTextPos( pTxtAttr->GetFld(), *pDoc ); diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index bc2467e74c..bc66235cde 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -34,13 +34,7 @@ #include <hintids.hxx> -#ifdef WIN -#define NEEDED_BY_FESHVIEW -#endif - -#ifndef _GRAPH_HXX #include <vcl/graph.hxx> -#endif #include <sot/formats.hxx> #include <sot/storage.hxx> #include <svtools/pathoptions.hxx> @@ -58,9 +52,7 @@ #include <svx/svdogrp.hxx> #include <svx/xoutbmp.hxx> #include <svx/svdoole2.hxx> -#ifndef _FM_FMMODEL_HXX #include <svx/fmmodel.hxx> -#endif #include <svx/unomodel.hxx> // --> OD 2005-08-03 #i50824# #include <svx/svditer.hxx> @@ -93,9 +85,7 @@ #include <dview.hxx> #include <dcontact.hxx> #include <dflyobj.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <pagedesc.hxx> #include <mvsave.hxx> #include <vcl/virdev.hxx> @@ -145,7 +135,7 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) // benutzen. if( pNewClpTxt ) { - pTxtNd->Insert( *pNewClpTxt, SwIndex( pTxtNd ) ); + pTxtNd->InsertText( *pNewClpTxt, SwIndex( pTxtNd ) ); return TRUE; // das wars. } @@ -198,7 +188,7 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) if( pTxtFly ) { ((SwFmtFlyCnt&)pTxtFly->GetFlyCnt()).SetFlyFmt( 0 ); - pTxtNd->Erase( rIdx, 1 ); + pTxtNd->EraseText( rIdx, 1 ); } } bRet = TRUE; @@ -840,7 +830,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) { SwNodeIndex aIndexBefore(rInsPos.nNode); aIndexBefore--; - pClpDoc->Copy( rCopy, rInsPos, false ); + pClpDoc->CopyRange( rCopy, rInsPos, false ); { aIndexBefore++; SwPaM aPaM(SwPosition(aIndexBefore, 0), @@ -1069,7 +1059,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) aIndexBefore--; - pClpDoc->Copy( aCpyPam, rInsPos, false ); + pClpDoc->CopyRange( aCpyPam, rInsPos, false ); { aIndexBefore++; diff --git a/sw/source/core/frmedt/fedesc.cxx b/sw/source/core/frmedt/fedesc.cxx index 293ac21502..8cca232fb4 100644 --- a/sw/source/core/frmedt/fedesc.cxx +++ b/sw/source/core/frmedt/fedesc.cxx @@ -127,7 +127,7 @@ void SwFEShell::ChgCurPageDesc( const SwPageDesc& rDesc ) else { SwPaM aPaM( *((SwCntntFrm*)pFlow)->GetNode() ); - GetDoc()->Insert( aPaM, aNew, 0 ); + GetDoc()->InsertPoolItem( aPaM, aNew, 0 ); } EndAllActionAndCall(); } diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index 72f9ff0796..e8c849cee0 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -34,7 +34,6 @@ #include "hintids.hxx" #ifdef WIN -#define NEEDED_BY_FESHVIEW #define _FESHVIEW_ONLY_INLINE_NEEDED #endif @@ -1874,7 +1873,8 @@ BOOL SwFEShell::ImpEndCreate() { ASSERT( aAnch.GetAnchorId() == FLY_IN_CNTNT, "wrong AnchorType" ); SwTxtNode *pNd = aAnch.GetCntntAnchor()->nNode.GetNode().GetTxtNode(); - pNd->InsertItem( SwFmtFlyCnt( pFmt ), + SwFmtFlyCnt aFmt( pFmt ); + pNd->InsertItem(aFmt, aAnch.GetCntntAnchor()->nContent.GetIndex(), 0 ); SwFmtVertOrient aVertical( pFmt->GetVertOrient() ); aVertical.SetVertOrient( text::VertOrientation::LINE_CENTER ); diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx index 2140311c3c..4485ba99f6 100644 --- a/sw/source/core/frmedt/fews.cxx +++ b/sw/source/core/frmedt/fews.cxx @@ -411,7 +411,9 @@ void lcl_SetAPageOffset( USHORT nOffset, SwPageFrm* pPage, SwFEShell* pThis ) if ( pFrm->IsInTab() ) pThis->GetDoc()->SetAttr( aDesc, *pFrm->FindTabFrm()->GetFmt() ); else - pThis->GetDoc()->Insert( *pThis->GetCrsr(), aDesc, 0 ); + { + pThis->GetDoc()->InsertPoolItem( *pThis->GetCrsr(), aDesc, 0 ); + } pThis->EndAllAction(); } diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 4719448b3e..26eed5bdf8 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -1462,7 +1462,10 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, if( pUndo ) pUndo->MoveBoxCntnt( pDoc, aRg, rInsPosNd ); else - pDoc->Move( aRg, rInsPosNd, IDocumentContentOperations::DOC_MOVEDEFAULT ); + { + pDoc->MoveNodeRange( aRg, rInsPosNd, + IDocumentContentOperations::DOC_MOVEDEFAULT ); + } // wo steht jetzt aInsPos ?? if( bCalcWidth ) diff --git a/sw/source/core/inc/GetMetricVal.hxx b/sw/source/core/inc/GetMetricVal.hxx index 14277471fa..1759e46a23 100644 --- a/sw/source/core/inc/GetMetricVal.hxx +++ b/sw/source/core/inc/GetMetricVal.hxx @@ -39,7 +39,7 @@ inline USHORT GetMetricVal( int n ) { #ifdef USE_MEASUREMENT - USHORT nVal = MEASURE_METRIC == GetAppLocaleData().getMeasurementSystemEnum() + USHORT nVal = MEASURE_METRIC == SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? 567 // 1 cm : 770; // 1/2 Inch #else diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx index ef1cc12149..415deffa24 100644 --- a/sw/source/core/inc/bookmrk.hxx +++ b/sw/source/core/inc/bookmrk.hxx @@ -32,6 +32,8 @@ #define _BOOKMRK_HXX #include <IMark.hxx> +#include <sfx2/Metadatable.hxx> + #include <boost/scoped_ptr.hpp> #include <boost/noncopyable.hpp> @@ -144,6 +146,7 @@ namespace sw { namespace mark class Bookmark : virtual public IBookmark , public DdeBookmark + , public ::sfx2::Metadatable { public: Bookmark(const SwPaM& rPaM, @@ -160,6 +163,15 @@ namespace sw { namespace mark { m_sShortName = rShortName; } virtual void SetKeyCode(const KeyCode& rCode) { m_aCode = rCode; } + + // ::sfx2::Metadatable + virtual ::sfx2::IXmlIdRegistry& GetRegistry(); + virtual bool IsInClipboard() const; + virtual bool IsInUndo() const; + virtual bool IsInContent() const; + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable > MakeUnoObject(); + private: KeyCode m_aCode; ::rtl::OUString m_sShortName; diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index 584c22ec09..199be26f58 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -518,21 +518,26 @@ inline BOOL SwBorderAttrs::IsLine() const OD 2004-03-10 #i28701# Values only provided for flow frames (table, section or text frames) Note: line spacing value is only determined for text frames + OD 2009-08-28 #i102458# + Add output parameter <obIsLineSpacingProportional> - @param _rFrm + @param rFrm input parameter - frame, for which the spacing values are determined. - @param _roPrevLowerSpacing + @param onPrevLowerSpacing output parameter - lower spacing of the frame in SwTwips - @param _roPrevLineSpacing + @param onPrevLineSpacing output parameter - line spacing of the frame in SwTwips + @param obIsLineSpacingProportional + @author OD */ -void GetSpacingValuesOfFrm( const SwFrm& _rFrm, - SwTwips& _roLowerSpacing, - SwTwips& _roLineSpacing ); +void GetSpacingValuesOfFrm( const SwFrm& rFrm, + SwTwips& onLowerSpacing, + SwTwips& onLineSpacing, + bool& obIsLineSpacingProportional ); /** method to get the content of the table cell diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx index e6c864f93e..dac9783874 100644 --- a/sw/source/core/inc/mvsave.hxx +++ b/sw/source/core/inc/mvsave.hxx @@ -39,6 +39,10 @@ #include <IDocumentMarkAccess.hxx> #include <vector> +namespace sfx2 { + class MetadatableUndo; +} + class SvNumberFormatter; class SvULongs; class SwDoc; @@ -80,6 +84,7 @@ namespace sw { namespace mark ULONG m_nNode2; xub_StrLen m_nCntnt1; xub_StrLen m_nCntnt2; + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo; }; }} diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx index 6160ed2777..9cd9e16ac7 100644 --- a/sw/source/core/inc/swfont.hxx +++ b/sw/source/core/inc/swfont.hxx @@ -141,6 +141,7 @@ class SwFont Color aOverColor; // color of the overlining BYTE nToxCnt; // Zaehlt die Schachtelungstiefe der Tox BYTE nRefCnt; // Zaehlt die Schachtelungstiefe der Refs + BYTE m_nMetaCount; // count META/METAFIELD BYTE nActual; // actual font (Latin, CJK or CTL) // Schalter fuer die Font-Extensions @@ -245,6 +246,9 @@ public: inline BYTE &GetRef() { return nRefCnt; } inline BYTE GetRef() const { return nRefCnt; } inline BOOL IsRef() const { return ( 0 != nRefCnt ); } + inline BYTE &GetMeta() { return m_nMetaCount; } + inline BYTE GetMeta() const { return m_nMetaCount; } + inline bool IsMeta() const { return (0 != m_nMetaCount); } inline void SetURL( const BOOL bURL ); inline BOOL IsURL() const { return bURL; } inline void SetGreyWave( const BOOL bNew ); diff --git a/sw/source/core/inc/txttypes.hxx b/sw/source/core/inc/txttypes.hxx index 89bb356aed..eaa9a95a9c 100644 --- a/sw/source/core/inc/txttypes.hxx +++ b/sw/source/core/inc/txttypes.hxx @@ -64,6 +64,7 @@ #define POR_ISOTOX 0x808a #define POR_REF 0x808b #define POR_ISOREF 0x808c +#define POR_META 0x808d #define POR_EXP 0xc080 #define POR_BLANK 0xc081 diff --git a/sw/source/core/inc/unometa.hxx b/sw/source/core/inc/unometa.hxx new file mode 100644 index 0000000000..1dc1985f7d --- /dev/null +++ b/sw/source/core/inc/unometa.hxx @@ -0,0 +1,345 @@ +/************************************************************************* + * + * 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: unometa.hxx,v $ + * $Revision: 1.1 $ + * + * 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 SW_UNOMETA_HXX +#define SW_UNOMETA_HXX + +#include "calbck.hxx" + +#include <sfx2/Metadatable.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase5.hxx> + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/text/XTextContent.hpp> +#include <com/sun/star/text/XTextField.hpp> + +#include <deque> + + +typedef ::std::deque< + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > > + TextRangeList_t; + +class SwXTextRange; +class SwPaM; +class SwTxtMeta; +namespace sw { + class Meta; + class MetaField; +} + +typedef +::cppu::ImplInheritanceHelper5 +< ::sfx2::MetadatableMixin +, ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::text::XTextContent +, ::com::sun::star::text::XText +, ::com::sun::star::container::XEnumerationAccess +> SwXMetaBaseClass; + +class SwXMeta + : public SwXMetaBaseClass + , public SwClient + , private ::boost::noncopyable +{ +private: + struct Impl; + ::std::auto_ptr<Impl> m_pImpl; + +protected: + virtual ~SwXMeta(); + +public: + SwXMeta(SwDoc *const pDoc, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> const& + xParentText, + TextRangeList_t * const pPortions, SwTxtMeta * const pHint); + SwXMeta(SwDoc *const pDoc); + + TYPEINFO(); + + static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& Identifier ) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + + // XTextRange + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + SAL_CALL getText() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getStart() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual rtl::OUString SAL_CALL getString() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(const rtl::OUString& rString) + throw (::com::sun::star::uno::RuntimeException); + + // XSimpleText + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursor() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursorByRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextPosition) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertString( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + const rtl::OUString& aString, sal_Bool bAbsorb) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertControlCharacter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XText + virtual void SAL_CALL insertTextContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > & xContent, + sal_Bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeTextContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > & xContent) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // MetadatableMixin + virtual ::sfx2::Metadatable * GetCoreObject(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + GetModel(); + + // SwClient + virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); + + /// init params with position of the attribute content (w/out CH_TXTATR) + bool SetContentRange( + SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd) const; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + GetParentText() const; + + bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, + const SwPaM* const pPam, bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + +protected: + virtual void SAL_CALL AttachImpl( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange, + const USHORT nWhich) + throw ( ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException ); + +private: + inline const ::sw::Meta * GetMeta() const; + +}; + + +typedef +::cppu::ImplInheritanceHelper2 +< SwXMeta +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::text::XTextField +> SwXMetaFieldBaseClass; + +class SwXMetaField + : public SwXMetaFieldBaseClass +{ +private: + virtual ~SwXMetaField(); + +private: + inline const ::sw::MetaField * GetMetaField() const; + +public: + SwXMetaField(SwDoc *const pDoc, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> const& + xParentText, + TextRangeList_t * const pPortions, SwTxtMeta * const pHint); + SwXMetaField(SwDoc *const pDoc); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& ServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames( ) + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw ( ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL + getPropertyValue(const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XTextField + virtual rtl::OUString SAL_CALL getPresentation(sal_Bool bShowCommand) + throw (::com::sun::star::uno::RuntimeException); + +}; + +/// get prefix/suffix from the RDF repository. @throws RuntimeException +void getPrefixAndSuffix( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel>& xModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable>& xMetaField, + ::rtl::OUString *const o_pPrefix, ::rtl::OUString *const o_pSuffix); + +#endif // SW_UNOMETA_HXX + diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index ba9f0f9b99..4968601e7a 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -1514,7 +1514,12 @@ SwTwips SwFlowFrm::CalcUpperSpace( const SwBorderAttrs *pAttrs, // values of found previous frame and use these values. SwTwips nPrevLowerSpace = 0; SwTwips nPrevLineSpacing = 0; - GetSpacingValuesOfFrm( (*pPrevFrm), nPrevLowerSpace, nPrevLineSpacing ); + // --> OD 2009-08-28 #i102458# + bool bPrevLineSpacingPorportional = false; + GetSpacingValuesOfFrm( (*pPrevFrm), + nPrevLowerSpace, nPrevLineSpacing, + bPrevLineSpacingPorportional ); + // <-- if( pIDSA->get(IDocumentSettingAccess::PARA_SPACE_MAX) ) { nUpper = nPrevLowerSpace + pAttrs->GetULSpace().GetUpper(); @@ -1539,7 +1544,22 @@ SwTwips SwFlowFrm::CalcUpperSpace( const SwBorderAttrs *pAttrs, // building its maximum. if ( pOwn->IsTxtFrm() ) { - nAdd += static_cast<SwTxtFrm&>(rThis).GetLineSpace( true ); + // --> OD 2009-08-28 #i102458# + // Correction: + // A proportional line spacing of the previous text frame + // is added up to a own leading line spacing. + // Otherwise, the maximum of the leading line spacing + // of the previous text frame and the own leading line + // spacing is built. + if ( bPrevLineSpacingPorportional ) + { + nAdd += static_cast<SwTxtFrm&>(rThis).GetLineSpace( true ); + } + else + { + nAdd = Max( nAdd, static_cast<SwTxtFrm&>(rThis).GetLineSpace( true ) ); + } + // <-- } nUpper += nAdd; } @@ -1571,7 +1591,22 @@ SwTwips SwFlowFrm::CalcUpperSpace( const SwBorderAttrs *pAttrs, SwTwips nAdd = nPrevLineSpacing; if ( pOwn->IsTxtFrm() ) { - nAdd += static_cast<SwTxtFrm&>(rThis).GetLineSpace( true ); + // --> OD 2009-08-28 #i102458# + // Correction: + // A proportional line spacing of the previous text frame + // is added up to a own leading line spacing. + // Otherwise, the maximum of the leading line spacing + // of the previous text frame and the own leading line + // spacing is built. + if ( bPrevLineSpacingPorportional ) + { + nAdd += static_cast<SwTxtFrm&>(rThis).GetLineSpace( true ); + } + else + { + nAdd = Max( nAdd, static_cast<SwTxtFrm&>(rThis).GetLineSpace( true ) ); + } + // <-- } nUpper += nAdd; } @@ -1675,7 +1710,10 @@ SwTwips SwFlowFrm::_GetUpperSpaceAmountConsideredForPrevFrm() const { SwTwips nPrevLowerSpace = 0; SwTwips nPrevLineSpacing = 0; - GetSpacingValuesOfFrm( (*pPrevFrm), nPrevLowerSpace, nPrevLineSpacing ); + // --> OD 2009-08-28 #i102458# + bool bDummy = false; + GetSpacingValuesOfFrm( (*pPrevFrm), nPrevLowerSpace, nPrevLineSpacing, bDummy ); + // <-- if ( nPrevLowerSpace > 0 || nPrevLineSpacing > 0 ) { const IDocumentSettingAccess* pIDSA = rThis.GetUpper()->GetFmt()->getIDocumentSettingAccess(); @@ -2697,8 +2735,3 @@ const SwFlowFrm *SwFlowFrm::CastFlowFrm( const SwFrm *pFrm ) return (SwSectionFrm*)pFrm; return 0; } - - - - - diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 1d1238bb15..82c921750a 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -3655,30 +3655,37 @@ const SwRect SwPageFrm::PrtWithoutHeaderAndFooter() const /** method to determine the spacing values of a frame OD 2004-03-10 #i28701# + OD 2009-08-28 #i102458# + Add output parameter <obIsLineSpacingProportional> @author OD */ -void GetSpacingValuesOfFrm( const SwFrm& _rFrm, - SwTwips& _roLowerSpacing, - SwTwips& _roLineSpacing ) +void GetSpacingValuesOfFrm( const SwFrm& rFrm, + SwTwips& onLowerSpacing, + SwTwips& onLineSpacing, + bool& obIsLineSpacingProportional ) { - if ( !_rFrm.IsFlowFrm() ) + if ( !rFrm.IsFlowFrm() ) { - _roLowerSpacing = 0L; - _roLineSpacing = 0L; + onLowerSpacing = 0; + onLineSpacing = 0; } else { - const SvxULSpaceItem& rULSpace = _rFrm.GetAttrSet()->GetULSpace(); - _roLowerSpacing = rULSpace.GetLower(); + const SvxULSpaceItem& rULSpace = rFrm.GetAttrSet()->GetULSpace(); + onLowerSpacing = rULSpace.GetLower(); - _roLineSpacing = 0; - if ( _rFrm.IsTxtFrm() ) + onLineSpacing = 0; + obIsLineSpacingProportional = false; + if ( rFrm.IsTxtFrm() ) { - _roLineSpacing = static_cast<const SwTxtFrm&>(_rFrm).GetLineSpace(); + onLineSpacing = static_cast<const SwTxtFrm&>(rFrm).GetLineSpace(); + obIsLineSpacingProportional = + onLineSpacing != 0 && + static_cast<const SwTxtFrm&>(rFrm).GetLineSpace( true ) == 0; } - ASSERT( _roLowerSpacing >= 0 && _roLineSpacing >= 0, + ASSERT( onLowerSpacing >= 0 && onLineSpacing >= 0, "<GetSpacingValuesOfFrm(..)> - spacing values aren't positive!" ); } } diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index 37bba1d4b0..d8658a5ed8 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -3031,7 +3031,8 @@ SwLayIdle::SwLayIdle( SwRootFrm *pRt, SwViewImp *pI ) : if ( !bInValid ) { pRoot->ResetIdleFormat(); - pImp->GetShell()->GetDoc()->GetDocShell()->Broadcast( SfxEventHint( SW_EVENT_LAYOUT_FINISHED ) ); + SfxObjectShell* pDocShell = pImp->GetShell()->GetDoc()->GetDocShell(); + pDocShell->Broadcast( SfxEventHint( SW_EVENT_LAYOUT_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_LAYOUT_FINISHED), pDocShell ) ); } } diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx index 9a762d3fc4..977f458863 100644 --- a/sw/source/core/layout/laycache.cxx +++ b/sw/source/core/layout/laycache.cxx @@ -727,7 +727,8 @@ void lcl_ApplyWorkaroundForB6375613( SwFrm* p_pFirstFrmOnNewPage ) SwDoc* pDoc( pFirstTextFrmOnNewPage->GetTxtNode()->GetDoc() ); IDocumentContentOperations* pIDCO = pFirstTextFrmOnNewPage->GetTxtNode()->getIDocumentContentOperations(); const SwPaM aTmpPaM( *(pFirstTextFrmOnNewPage->GetTxtNode()) ); - pIDCO->Insert( aTmpPaM, SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0 ); + pIDCO->InsertPoolItem( aTmpPaM, + SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0 ); pFirstTextFrmOnNewPage->GetTxtNode()->UnlockModify(); uno::Reference< document::XDocumentInfoSupplier > xDoc( diff --git a/sw/source/core/swg/SwXMLTextBlocks.cxx b/sw/source/core/swg/SwXMLTextBlocks.cxx index 15e91e7050..8eba626632 100644 --- a/sw/source/core/swg/SwXMLTextBlocks.cxx +++ b/sw/source/core/swg/SwXMLTextBlocks.cxx @@ -641,6 +641,6 @@ void SwXMLTextBlocks::MakeBlockText( const String& rText ) } SwIndex aIdx( pTxtNode ); String sTemp(rText.GetToken( 0, '\015', nPos ) ); - pTxtNode->Insert( sTemp, aIdx ); + pTxtNode->InsertText( sTemp, aIdx ); } while ( STRING_NOTFOUND != nPos ); } diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx index 50c007cae2..cf1d6a8ed2 100644 --- a/sw/source/core/table/swnewtable.cxx +++ b/sw/source/core/table/swnewtable.cxx @@ -909,7 +909,10 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, if( pUndo ) pUndo->MoveBoxCntnt( pDoc, aRg, rInsPosNd ); else - pDoc->Move( aRg, rInsPosNd, IDocumentContentOperations::DOC_NO_DELFRMS ); + { + pDoc->MoveNodeRange( aRg, rInsPosNd, + IDocumentContentOperations::DOC_NO_DELFRMS ); + } } } // Only the cell of the first selected column will stay alive diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 07a1669bfa..df3fdf29f9 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2177,8 +2177,10 @@ void ChgTextToNum( SwTableBox& rBox, const String& rTxt, const Color* pCol, pDoc->DeleteRedline(aTemp, true, USHRT_MAX); } - pTNd->Erase( aIdx, n, INS_EMPTYEXPAND ); - pTNd->Insert( rTxt, aIdx, INS_EMPTYEXPAND ); + pTNd->EraseText( aIdx, n, + IDocumentContentOperations::INS_EMPTYEXPAND ); + pTNd->InsertText( rTxt, aIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); if( pDoc->IsRedlineOn() ) { @@ -2222,8 +2224,10 @@ void ChgNumToText( SwTableBox& rBox, ULONG nFmt ) // zuruecksetzen, damit sie wieder aufgespannt werden pTNd->DontExpandFmt( aIdx, FALSE, FALSE ); aIdx = 0; - pTNd->Erase( aIdx, STRING_LEN, INS_EMPTYEXPAND ); - pTNd->Insert( sTmp, aIdx, INS_EMPTYEXPAND ); + pTNd->EraseText( aIdx, STRING_LEN, + IDocumentContentOperations::INS_EMPTYEXPAND ); + pTNd->InsertText( sTmp, aIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); } } diff --git a/sw/source/core/text/atrhndl.hxx b/sw/source/core/text/atrhndl.hxx index 35fb80bde2..4d9a2909d2 100644 --- a/sw/source/core/text/atrhndl.hxx +++ b/sw/source/core/text/atrhndl.hxx @@ -32,7 +32,7 @@ #define _ATRHNDL_HXX #define INITIAL_NUM_ATTR 3 -#define NUM_ATTRIBUTE_STACKS 39 +#define NUM_ATTRIBUTE_STACKS 40 #include <txatbase.hxx> #include <swfntcch.hxx> diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx index b63cd8776d..641bd51ee3 100644 --- a/sw/source/core/text/atrstck.cxx +++ b/sw/source/core/text/atrstck.cxx @@ -136,8 +136,8 @@ const BYTE StackPos[ static_cast<USHORT>(RES_TXTATR_WITHEND_END) - 0, // RES_TXTATR_DUMMY5 // 46 38, // RES_TXTATR_CJK_RUBY, // 47 0, // RES_TXTATR_UNKNOWN_CONTAINER, // 48 - 0, // RES_TXTATR_DUMMY6, // 49 - 0 // RES_TXTATR_DUMMY7, // 50 + 39, // RES_TXTATR_META, // 49 + 39 // RES_TXTATR_METAFIELD, // 50 }; /************************************************************************* @@ -650,6 +650,10 @@ void SwAttrHandler::ActivateTop( SwFont& rFnt, const USHORT nAttr ) rFnt.GetRef()--; else if ( RES_TXTATR_TOXMARK == nAttr ) rFnt.GetTox()--; + else if ( (RES_TXTATR_META == nAttr) || (RES_TXTATR_METAFIELD == nAttr) ) + { + rFnt.GetMeta()--; + } else if ( RES_TXTATR_CJK_RUBY == nAttr ) { // ruby stack has no more attributes @@ -928,6 +932,13 @@ void SwAttrHandler::FontChg(const SfxPoolItem& rItem, SwFont& rFnt, sal_Bool bPu else rFnt.GetTox()--; break; + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + if ( bPush ) + rFnt.GetMeta()++; + else + rFnt.GetMeta()--; + break; } } diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx index 461ee77b44..b1c2eaefb5 100644 --- a/sw/source/core/text/guess.cxx +++ b/sw/source/core/text/guess.cxx @@ -243,7 +243,7 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf, nBreakStart = nCutPos; } - else if( pBreakIt->xBreak.is() ) + else if( pBreakIt->GetBreakIter().is() ) { // New: We should have a look into the last portion, if it was a // field portion. For this, we expand the text of the field portion @@ -366,7 +366,7 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf, // determines first possible line break from nRightPos to // start index of current line - LineBreakResults aResult = pBreakIt->xBreak->getLineBreak( + LineBreakResults aResult = pBreakIt->GetBreakIter()->getLineBreak( rInf.GetTxt(), nCutPos, aLocale, rInf.GetLineStart(), aHyphOpt, aUserOpt ); @@ -534,7 +534,7 @@ sal_Bool SwTxtGuess::AlternativeSpelling( const SwTxtFormatInfo &rInf, xub_StrLen nWordLen; Boundary aBound = - pBreakIt->xBreak->getWordBoundary( rInf.GetTxt(), nPos, + pBreakIt->GetBreakIter()->getWordBoundary( rInf.GetTxt(), nPos, pBreakIt->GetLocale( rInf.GetFont()->GetLanguage() ), WordType::DICTIONARY_WORD, sal_True ); nBreakStart = (xub_StrLen)aBound.startPos; diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 3521003c32..3f390528e3 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -1277,7 +1277,8 @@ void SwTxtPaintInfo::DrawViewOpt( const SwLinePortion &rPor, case POR_URL: case POR_HIDDEN: case POR_TOX: - case POR_REF : + case POR_REF: + case POR_META: case POR_CONTROLCHAR: if ( !GetOpt().IsPagePreview() && !GetOpt().IsReadonly() && diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index 44ab83e9cd..09be2bd798 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -45,7 +45,6 @@ #include <fmtflcnt.hxx> #include <fmtcntnt.hxx> #include <fmtftn.hxx> -#include <fmthbsh.hxx> #include <frmatr.hxx> #include <frmfmt.hxx> #include <fmtfld.hxx> @@ -126,19 +125,7 @@ SwAttrIter::~SwAttrIter() SwTxtAttr *SwAttrIter::GetAttr( const xub_StrLen nPosition ) const { - if ( pHints ) - { - for ( USHORT i = 0; i < pHints->Count(); ++i ) - { - SwTxtAttr *pPos = pHints->GetTextHint(i); - xub_StrLen nStart = *pPos->GetStart(); - if( nPosition < nStart ) - return 0; - if( nPosition == nStart && !pPos->GetEnd() ) - return pPos; - } - } - return 0; + return (m_pTxtNode) ? m_pTxtNode->GetTxtAttrForCharAt(nPosition) : 0; } /************************************************************************* @@ -400,10 +387,10 @@ sal_Bool lcl_MinMaxString( SwMinMaxArgs& rArg, SwFont* pFnt, const XubString &rT xub_StrLen nStop = nIdx; sal_Bool bClear; LanguageType eLang = pFnt->GetLanguage(); - if( pBreakIt->xBreak.is() ) + if( pBreakIt->GetBreakIter().is() ) { bClear = CH_BLANK == rTxt.GetChar( nStop ); - Boundary aBndry( pBreakIt->xBreak->getWordBoundary( rTxt, nIdx, + Boundary aBndry( pBreakIt->GetBreakIter()->getWordBoundary( rTxt, nIdx, pBreakIt->GetLocale( eLang ), WordType::DICTIONARY_WORD, TRUE ) ); nStop = (xub_StrLen)aBndry.endPos; @@ -870,7 +857,7 @@ USHORT SwTxtNode::GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd ) if ( nStt == nEnd ) { - if ( !pBreakIt->xBreak.is() ) + if ( !pBreakIt->GetBreakIter().is() ) return 100; SwScriptInfo aScriptInfo; @@ -878,7 +865,7 @@ USHORT SwTxtNode::GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd ) aIter.SeekAndChgAttrIter( nStt, pOut ); Boundary aBound = - pBreakIt->xBreak->getWordBoundary( GetTxt(), nStt, + pBreakIt->GetBreakIter()->getWordBoundary( GetTxt(), nStt, pBreakIt->GetLocale( aIter.GetFnt()->GetLanguage() ), WordType::DICTIONARY_WORD, sal_True ); diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 25ad1a25ca..7fbb6bae55 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -157,8 +157,10 @@ void SwTxtMargin::CtorInitTxtMargin( SwTxtFrm *pNewFrm, SwTxtSizeInfo *pNewInf ) GetInfo().SetFont( GetFnt() ); const SwTxtNode *pNode = pFrm->GetTxtNode(); - const SvxLRSpaceItem &rSpace = - pFrm->GetTxtNode()->GetSwAttrSet().GetLRSpace(); + const SvxLRSpaceItem &rSpace = pFrm->GetTxtNode()->GetSwAttrSet().GetLRSpace(); + // --> OD 2009-09-02 #i95907# + const bool bListLevelIndentsApplicable = pFrm->GetTxtNode()->AreListLevelIndentsApplicable(); + // <-- // // Carefully adjust the text formatting ranges. @@ -181,8 +183,13 @@ void SwTxtMargin::CtorInitTxtMargin( SwTxtFrm *pNewFrm, SwTxtSizeInfo *pNewInf ) pFrm->Prt().Left() + nLMWithNum - pNode->GetLeftMarginWithNum( sal_False ) - - rSpace.GetLeft() + - rSpace.GetTxtLeft(); + // --> OD 2009-09-02 #i95907# +// rSpace.GetLeft() + +// rSpace.GetTxtLeft(); + ( bListLevelIndentsApplicable + ? 0 + : ( rSpace.GetLeft() - rSpace.GetTxtLeft() ) ); + // <-- } else { @@ -193,8 +200,13 @@ void SwTxtMargin::CtorInitTxtMargin( SwTxtFrm *pNewFrm, SwTxtSizeInfo *pNewInf ) pFrm->Prt().Left() + nLMWithNum - pNode->GetLeftMarginWithNum( sal_False ) - - rSpace.GetLeft() + - rSpace.GetTxtLeft(); + // --> OD 2009-09-02 #i95907# +// rSpace.GetLeft() + +// rSpace.GetTxtLeft(); + ( bListLevelIndentsApplicable + ? 0 + : ( rSpace.GetLeft() - rSpace.GetTxtLeft() ) ); + // <-- } else { diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 2aa65f2671..57dacd703a 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -107,6 +107,7 @@ void SwTxtFormatter::CtorInitTxtFormatter( SwTxtFrm *pNewFrm, SwTxtFormatInfo *p nCntMidHyph = 0; nLeftScanIdx = STRING_LEN; nRightScanIdx = 0; + m_nHintEndIndex = 0; if( nStart > GetInfo().GetTxt().Len() ) { @@ -313,7 +314,14 @@ SwLinePortion *SwTxtFormatter::UnderFlow( SwTxtFormatInfo &rInf ) } } pPor->Truncate(); - delete rInf.GetRest(); + SwLinePortion *const pRest( rInf.GetRest() ); + if (pRest && pRest->InFldGrp() && + static_cast<SwFldPortion*>(pRest)->IsNoLength()) + { + // HACK: decrement again, so we pick up the suffix in next line! + --m_nHintEndIndex; + } + delete pRest; rInf.SetRest(0); return pPor; } @@ -820,6 +828,34 @@ void SwTxtFormatter::CalcAscent( SwTxtFormatInfo &rInf, SwLinePortion *pPor ) } /************************************************************************* + * class SwMetaPortion + *************************************************************************/ + +class SwMetaPortion : public SwTxtPortion +{ +public: + inline SwMetaPortion() { SetWhichPor( POR_META ); } + virtual void Paint( const SwTxtPaintInfo &rInf ) const; +// OUTPUT_OPERATOR +}; + +//CLASSIO( SwMetaPortion ) + +/************************************************************************* + * virtual SwMetaPortion::Paint() + *************************************************************************/ + +void SwMetaPortion::Paint( const SwTxtPaintInfo &rInf ) const +{ + if ( Width() ) + { + rInf.DrawViewOpt( *this, POR_META ); + SwTxtPortion::Paint( rInf ); + } +} + + +/************************************************************************* * SwTxtFormatter::WhichTxtPor() *************************************************************************/ @@ -832,6 +868,10 @@ SwTxtPortion *SwTxtFormatter::WhichTxtPor( SwTxtFormatInfo &rInf ) const { if( GetFnt()->IsRef() ) pPor = new SwRefPortion; + else if (GetFnt()->IsMeta()) + { + pPor = new SwMetaPortion; + } else { // Erst zum Schluss ! @@ -1068,6 +1108,12 @@ SwLinePortion *SwTxtFormatter::WhichFirstPortion(SwTxtFormatInfo &rInf) pPor = NewTabPortion( rInf, true ); } + // 11) suffix of meta-field + if (!pPor) + { + pPor = TryNewNoLengthPortion(rInf); + } + return pPor; } diff --git a/sw/source/core/text/itrform2.hxx b/sw/source/core/text/itrform2.hxx index f5732ced0b..ec6fce1958 100644 --- a/sw/source/core/text/itrform2.hxx +++ b/sw/source/core/text/itrform2.hxx @@ -60,6 +60,7 @@ class SwTxtFormatter : public SwTxtPainter sal_Bool bChanges : 1; // Flag, fuer die Berechnung des Repaint-Rechtecks sal_Bool bTruncLines : 1; // Flag, Repaint-Rechtecks ggf. erweitern sal_Bool bUnclipped : 1; // Flag, ob Repaint groesser als feste Zeilenhoehe + USHORT m_nHintEndIndex; // HACK for TryNewNoLengthPortion SwLinePortion *NewPortion( SwTxtFormatInfo &rInf ); SwTxtPortion *NewTxtPortion( SwTxtFormatInfo &rInf ); SwLinePortion *NewExtraPortion( SwTxtFormatInfo &rInf ); @@ -75,6 +76,7 @@ class SwTxtFormatter : public SwTxtPainter SwTxtAttr *pHt ) const; SwLinePortion *WhichFirstPortion( SwTxtFormatInfo &rInf ); SwTxtPortion *WhichTxtPor( SwTxtFormatInfo &rInf ) const; + SwExpandPortion * TryNewNoLengthPortion( SwTxtFormatInfo & rInfo ); // Das Herzstueck der Formatierung void BuildPortions( SwTxtFormatInfo &rInf ); diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx index cd2c0618e0..3bed270774 100644 --- a/sw/source/core/text/itrpaint.cxx +++ b/sw/source/core/text/itrpaint.cxx @@ -48,7 +48,6 @@ #include <fmtftn.hxx> #include <fmtfld.hxx> #include <fldbas.hxx> // SwField -#include <fmthbsh.hxx> #include <rootfrm.hxx> #include <pagefrm.hxx> #include <pagedesc.hxx> // SwPageDesc diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index 096d863194..8fcdbca8e7 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -85,6 +85,7 @@ SwFldPortion *SwFldPortion::Clone( const XubString &rExpand ) const pNewFnt = new SwFont( *pFnt ); SwFldPortion* pClone = new SwFldPortion( rExpand, pNewFnt ); pClone->SetNextOffset( nNextOffset ); + pClone->m_bNoLength = this->m_bNoLength; return pClone; } @@ -99,6 +100,7 @@ void SwFldPortion::TakeNextOffset( const SwFldPortion* pFld ) SwFldPortion::SwFldPortion( const XubString &rExpand, SwFont *pFont, sal_Bool bPlaceHold ) : aExpand(rExpand), pFnt(pFont), nNextOffset(0), nNextScriptChg(STRING_LEN), nViewWidth(0), bFollow( sal_False ), bHasFollow( sal_False ), bPlaceHolder( bPlaceHold ) + , m_bNoLength( sal_False ) { SetWhichPor( POR_FLD ); } @@ -114,6 +116,7 @@ SwFldPortion::SwFldPortion( const SwFldPortion& rFld ) bCenter( rFld.IsCenter() ), bHasFollow( rFld.HasFollow() ), bPlaceHolder( rFld.bPlaceHolder ) + , m_bNoLength( rFld.m_bNoLength ) { if ( rFld.HasFont() ) pFnt = new SwFont( *rFld.GetFont() ); @@ -215,25 +218,25 @@ SwFldSlot::~SwFldSlot() void SwFldPortion::CheckScript( const SwTxtSizeInfo &rInf ) { String aTxt; - if( GetExpTxt( rInf, aTxt ) && aTxt.Len() && pBreakIt->xBreak.is() ) + if( GetExpTxt( rInf, aTxt ) && aTxt.Len() && pBreakIt->GetBreakIter().is() ) { BYTE nActual = pFnt ? pFnt->GetActual() : rInf.GetFont()->GetActual(); USHORT nScript; { - nScript = pBreakIt->xBreak->getScriptType( aTxt, 0 ); + nScript = pBreakIt->GetBreakIter()->getScriptType( aTxt, 0 ); xub_StrLen nChg = 0; if( i18n::ScriptType::WEAK == nScript ) { - nChg =(xub_StrLen)pBreakIt->xBreak->endOfScript(aTxt,0,nScript); + nChg =(xub_StrLen)pBreakIt->GetBreakIter()->endOfScript(aTxt,0,nScript); if( nChg < aTxt.Len() ) - nScript = pBreakIt->xBreak->getScriptType( aTxt, nChg ); + nScript = pBreakIt->GetBreakIter()->getScriptType( aTxt, nChg ); } // // nNextScriptChg will be evaluated during SwFldPortion::Format() // if ( nChg < aTxt.Len() ) - nNextScriptChg = (xub_StrLen)pBreakIt->xBreak->endOfScript( aTxt, nChg, nScript ); + nNextScriptChg = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( aTxt, nChg, nScript ); else nNextScriptChg = aTxt.Len(); @@ -378,7 +381,7 @@ sal_Bool SwFldPortion::Format( SwTxtFormatInfo &rInf ) // Das Zeichen wird in der ersten Portion gehalten. // Unbedingt nach Format! - SetLen( nFollow ); + SetLen( (m_bNoLength) ? 0 : nFollow ); if( nRest ) { @@ -1127,12 +1130,12 @@ SwCombinedPortion::SwCombinedPortion( const XubString &rTxt ) aExpand.Erase( 6 ); // Initialization of the scripttype array, // the arrays of width and position are filled by the format function - if( pBreakIt->xBreak.is() ) + if( pBreakIt->GetBreakIter().is() ) { BYTE nScr = SW_SCRIPTS; for( USHORT i = 0; i < rTxt.Len(); ++i ) { - USHORT nScript = pBreakIt->xBreak->getScriptType( rTxt, i ); + USHORT nScript = pBreakIt->GetBreakIter()->getScriptType( rTxt, i ); switch ( nScript ) { case i18n::ScriptType::LATIN : nScr = SW_LATIN; break; case i18n::ScriptType::ASIAN : nScr = SW_CJK; break; diff --git a/sw/source/core/text/porfld.hxx b/sw/source/core/text/porfld.hxx index 084b020672..2292a27b78 100644 --- a/sw/source/core/text/porfld.hxx +++ b/sw/source/core/text/porfld.hxx @@ -61,8 +61,12 @@ protected: sal_Bool bNoPaint : 1; // wird von SwGrfNumPortion benutzt sal_Bool bReplace : 1; // wird von SwGrfNumPortion benutzt sal_Bool bPlaceHolder : 1; + sal_Bool m_bNoLength : 1; // HACK for meta suffix (no CH_TXTATR) inline void SetFont( SwFont *pNew ) { pFnt = pNew; } + inline bool IsNoLength() const { return m_bNoLength; } + inline void SetNoLength() { m_bNoLength = sal_True; } + public: SwFldPortion( const SwFldPortion& rFld ); SwFldPortion( const XubString &rExpand, SwFont *pFnt = 0, sal_Bool bPlaceHolder = sal_False ); diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index a5a628608c..73ad538c74 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -798,7 +798,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode ) void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) { - if( !pBreakIt->xBreak.is() ) + if( !pBreakIt->GetBreakIter().is() ) return; const String& rTxt = rNode.GetTxt(); @@ -907,13 +907,13 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) // we go back in our group until we reach the first character of // type nScript while ( nChg > nGrpStart && - nScript != pBreakIt->xBreak->getScriptType( rTxt, nChg ) ) + nScript != pBreakIt->GetBreakIter()->getScriptType( rTxt, nChg ) ) --nChg; // If we are at the start of a group, we do not trust nScript, // we better get nScript from the breakiterator: if ( nChg == nGrpStart ) - nScript = (BYTE)pBreakIt->xBreak->getScriptType( rTxt, nChg ); + nScript = (BYTE)pBreakIt->GetBreakIter()->getScriptType( rTxt, nChg ); // // INVALID DATA FROM THE SCRIPT INFO ARRAYS HAS TO BE DELETED: @@ -959,14 +959,14 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) // SCRIPT FOR WEAK CHARACTERS AT THE BEGINNING OF A PARAGRAPH // - if( WEAK == pBreakIt->xBreak->getScriptType( rTxt, nChg ) ) + if( WEAK == pBreakIt->GetBreakIter()->getScriptType( rTxt, nChg ) ) { // If the beginning of the current group is weak, this means that // all of the characters in this grounp are weak. We have to assign // the scripts to these characters depending on the fonts which are // set for these characters to display them. xub_StrLen nEnd = - (xub_StrLen)pBreakIt->xBreak->endOfScript( rTxt, nChg, WEAK ); + (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( rTxt, nChg, WEAK ); if( nEnd > rTxt.Len() ) nEnd = rTxt.Len(); @@ -981,7 +981,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) // Get next script type or set to weak in order to exit BYTE nNextScript = ( nEnd < rTxt.Len() ) ? - (BYTE)pBreakIt->xBreak->getScriptType( rTxt, nEnd ) : + (BYTE)pBreakIt->GetBreakIter()->getScriptType( rTxt, nEnd ) : (BYTE)WEAK; if ( nScript != nNextScript ) @@ -1003,7 +1003,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) ASSERT( STRING_LEN != nChg, "65K? Strange length of script section" ); xub_StrLen nSearchStt = nChg; - nChg = (xub_StrLen)pBreakIt->xBreak->endOfScript( rTxt, nSearchStt, nScript ); + nChg = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( rTxt, nSearchStt, nScript ); if ( nChg > rTxt.Len() ) nChg = rTxt.Len(); @@ -1011,16 +1011,16 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) // --> FME 2008-09-17 #i28203# // for 'complex' portions, we make sure that a portion does not contain more // than one script: - if( pBreakIt->xCTLDetect.is() && i18n::ScriptType::COMPLEX == nScript ) + if( i18n::ScriptType::COMPLEX == nScript && pBreakIt->GetScriptTypeDetector().is() ) { - const short nScriptType = pBreakIt->xCTLDetect->getCTLScriptType( rTxt, nSearchStt ); + const short nScriptType = pBreakIt->GetScriptTypeDetector()->getCTLScriptType( rTxt, nSearchStt ); xub_StrLen nNextCTLScriptStart = nSearchStt; short nCurrentScriptType = nScriptType; while( com::sun::star::i18n::CTLScriptType::CTL_UNKNOWN == nCurrentScriptType || nScriptType == nCurrentScriptType ) { - nNextCTLScriptStart = (xub_StrLen)pBreakIt->xCTLDetect->endOfCTLScriptType( rTxt, nNextCTLScriptStart ); + nNextCTLScriptStart = (xub_StrLen)pBreakIt->GetScriptTypeDetector()->endOfCTLScriptType( rTxt, nNextCTLScriptStart ); if( nNextCTLScriptStart < rTxt.Len() && nNextCTLScriptStart < nChg ) - nCurrentScriptType = pBreakIt->xCTLDetect->getCTLScriptType( rTxt, nNextCTLScriptStart ); + nCurrentScriptType = pBreakIt->GetScriptTypeDetector()->getCTLScriptType( rTxt, nNextCTLScriptStart ); else break; } @@ -1031,7 +1031,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) // special case for dotted circle since it can be used with complex // before a mark, so we want it associated with the mark's script if (nChg < rTxt.Len() && nChg > 0 && (i18n::ScriptType::WEAK == - pBreakIt->xBreak->getScriptType(rTxt,nChg - 1))) + pBreakIt->GetBreakIter()->getScriptType(rTxt,nChg - 1))) { int8_t nType = u_charType(rTxt.GetChar(nChg) ); if (nType == U_NON_SPACING_MARK || nType == U_ENCLOSING_MARK || @@ -1287,7 +1287,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) } if ( nChg < rTxt.Len() ) - nScript = (BYTE)pBreakIt->xBreak->getScriptType( rTxt, nChg ); + nScript = (BYTE)pBreakIt->GetBreakIter()->getScriptType( rTxt, nChg ); nLastCompression = nChg; nLastKashida = nChg; @@ -1566,7 +1566,7 @@ void SwScriptInfo::DeleteHiddenRanges( SwTxtNode& rNode ) nHiddenStart = *(rFirst++); SwPaM aPam( rNode, nHiddenStart, rNode, nHiddenEnd ); - rNode.getIDocumentContentOperations()->Delete( aPam ); + rNode.getIDocumentContentOperations()->DeleteRange( aPam ); } } diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index 6ff2c0ff7a..ea8b756212 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -34,9 +34,7 @@ #include <hintids.hxx> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif #include <svx/twolinesitem.hxx> #include <svx/charrotateitem.hxx> #include <vcl/outdev.hxx> @@ -194,13 +192,11 @@ SwRotatedPortion::SwRotatedPortion( const SwMultiCreator& rCreate, if( !pRot ) { const SwTxtAttr& rAttr = *rCreate.pAttr; - if( RES_CHRATR_ROTATE == rAttr.Which() ) - pRot = &rAttr.GetCharRotate(); - else + const SfxPoolItem *const pItem = + CharFmt::GetItem(rAttr, RES_CHRATR_ROTATE); + if ( pItem ) { - const SfxPoolItem* pItem = CharFmt::GetItem( rAttr, RES_CHRATR_ROTATE ); - if ( pItem ) - pRot = (SvxCharRotateItem*)pItem; + pRot = static_cast<const SvxCharRotateItem*>(pItem); } } if( pRot ) @@ -319,13 +315,11 @@ SwDoubleLinePortion::SwDoubleLinePortion( const SwMultiCreator& rCreate, const SwTxtAttr& rAttr = *rCreate.pAttr; pBracket->nStart = *rAttr.GetStart(); - if( RES_CHRATR_TWO_LINES == rAttr.Which() ) - pTwo = &rAttr.Get2Lines(); - else + const SfxPoolItem * const pItem = + CharFmt::GetItem( rAttr, RES_CHRATR_TWO_LINES ); + if ( pItem ) { - const SfxPoolItem* pItem = CharFmt::GetItem( rAttr, RES_CHRATR_TWO_LINES ); - if ( pItem ) - pTwo = (SvxTwoLinesItem*)pItem; + pTwo = static_cast<const SvxTwoLinesItem*>(pItem); } } if( pTwo ) @@ -916,7 +910,7 @@ SwMultiCreator* SwTxtSizeInfo::GetMultiCreator( xub_StrLen &rPos, // for 99% of all cases XubString aTxt = GetTxtFrm()->GetTxtNode()->GetExpandTxt( rPos, 1 ); - if ( pBreakIt->xBreak.is() && aTxt.Len() ) + if ( pBreakIt->GetBreakIter().is() && aTxt.Len() ) { sal_Bool bFldDir = ( i18n::ScriptType::COMPLEX == pBreakIt->GetRealScriptOfText( aTxt, 0 ) ); diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index 1c482fc30e..6eeb5492e2 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -97,8 +97,8 @@ USHORT lcl_AddSpace( const SwTxtSizeInfo &rInf, const XubString* pStr, // first we get the script type if ( pSI ) nScript = pSI->ScriptType( nPos ); - else if ( pBreakIt->xBreak.is() ) - nScript = (BYTE)pBreakIt->xBreak->getScriptType( *pStr, nPos ); + else if ( pBreakIt->GetBreakIter().is() ) + nScript = (BYTE)pBreakIt->GetBreakIter()->getScriptType( *pStr, nPos ); // Note: rInf.GetIdx() can differ from nPos, // e.g., when rPor is a field portion. nPos referes to the string passed @@ -198,7 +198,7 @@ USHORT lcl_AddSpace( const SwTxtSizeInfo &rInf, const XubString* pStr, if ( pPor && pPor->IsKernPortion() ) pPor = pPor->GetPortion(); - if ( ! pBreakIt->xBreak.is() || ! pPor || pPor->InFixMargGrp() ) + if ( ! pBreakIt->GetBreakIter().is() || ! pPor || pPor->InFixMargGrp() ) return nCnt; // next character is inside a field? @@ -211,10 +211,10 @@ USHORT lcl_AddSpace( const SwTxtSizeInfo &rInf, const XubString* pStr, pPor->GetExpTxt( rInf, aStr ); ((SwTxtSizeInfo &)rInf).SetOnWin( bOldOnWin ); - nNextScript = (BYTE)pBreakIt->xBreak->getScriptType( aStr, 0 ); + nNextScript = (BYTE)pBreakIt->GetBreakIter()->getScriptType( aStr, 0 ); } else - nNextScript = (BYTE)pBreakIt->xBreak->getScriptType( rInf.GetTxt(), nPos ); + nNextScript = (BYTE)pBreakIt->GetBreakIter()->getScriptType( rInf.GetTxt(), nPos ); if( ASIAN == nNextScript ) { diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx index 9ae6b7a74a..3a9a7a1072 100644 --- a/sw/source/core/text/redlnitr.cxx +++ b/sw/source/core/text/redlnitr.cxx @@ -110,7 +110,7 @@ void SwAttrIter::CtorInitAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf, S if ( pScriptInfo->GetInvalidity() != STRING_LEN ) pScriptInfo->InitScriptInfo( rTxtNode, bRTL ); - if ( pBreakIt->xBreak.is() ) + if ( pBreakIt->GetBreakIter().is() ) { pFnt->SetActual( SwScriptInfo::WhichFont( 0, 0, pScriptInfo ) ); @@ -263,7 +263,8 @@ short SwRedlineItr::_Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld ) pSet->ClearItem(); else { - SwAttrPool& rPool = (SwAttrPool& )rDoc.GetAttrPool(); + SwAttrPool& rPool = + const_cast<SwDoc&>(rDoc).GetAttrPool(); pSet = new SfxItemSet(rPool, RES_CHRATR_BEGIN, RES_CHRATR_END-1); } @@ -279,7 +280,9 @@ short SwRedlineItr::_Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld ) if( ( nWhich < RES_CHRATR_END ) && ( SFX_ITEM_SET == pSet->GetItemState( nWhich, sal_True, &pItem ) ) ) { - SwTxtAttr* pAttr = ((SwTxtNode&)rNd).MakeRedlineTxtAttr( *pItem ); + SwTxtAttr* pAttr = MakeRedlineTxtAttr( + const_cast<SwDoc&>(rDoc), + *const_cast<SfxPoolItem*>(pItem) ); pAttr->SetPriorityAttr( sal_True ); aHints.C40_INSERT( SwTxtAttr, pAttr, aHints.Count()); rAttrHandler.PushAndChg( *pAttr, rFnt ); @@ -352,7 +355,7 @@ void SwRedlineItr::_Clear( SwFont* pFnt ) rAttrHandler.PopAndChg( *pPos, *pFnt ); else rAttrHandler.Pop( *pPos ); - delete pPos; + SwTxtAttr::Destroy(pPos, const_cast<SwDoc&>(rDoc).GetAttrPool() ); } if( pFnt ) pFnt->SetNoCol( sal_False ); diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx index 89e519bcd2..475beaecb3 100644 --- a/sw/source/core/text/txtdrop.cxx +++ b/sw/source/core/text/txtdrop.cxx @@ -152,19 +152,7 @@ SwDropPortion::~SwDropPortion() sal_Bool SwTxtSizeInfo::_HasHint( const SwTxtNode* pTxtNode, xub_StrLen nPos ) { - const SwpHints *pHints = pTxtNode->GetpSwpHints(); - if( !pHints ) - return sal_False; - for ( USHORT i = 0; i < pHints->Count(); ++i ) - { - const SwTxtAttr *pPos = (*pHints)[i]; - xub_StrLen nStart = *pPos->GetStart(); - if( nPos < nStart ) - return sal_False; - if( nPos == nStart && !pPos->GetEnd() ) - return sal_True; - } - return sal_False; + return 0 != pTxtNode->GetTxtAttrForCharAt(nPos); } /************************************************************************* @@ -179,7 +167,7 @@ MSHORT SwTxtNode::GetDropLen( MSHORT nWishLen ) const if( nWishLen && nWishLen < nEnd ) nEnd = nWishLen; - if ( ! nWishLen && pBreakIt->xBreak.is() ) + if ( ! nWishLen && pBreakIt->GetBreakIter().is() ) { // find first word const SwAttrSet& rAttrSet = GetSwAttrSet(); @@ -201,7 +189,7 @@ MSHORT SwTxtNode::GetDropLen( MSHORT nWishLen ) const } Boundary aBound = - pBreakIt->xBreak->getWordBoundary( GetTxt(), 0, + pBreakIt->GetBreakIter()->getWordBoundary( GetTxt(), 0, pBreakIt->GetLocale( eLanguage ), WordType::DICTIONARY_WORD, sal_True ); nEnd = (xub_StrLen)aBound.endPos; diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index 202cbb886a..4eae178d3e 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -63,6 +63,7 @@ #include "docufld.hxx" #include "pagedesc.hxx" // NewFldPortion, GetNum() #include <pormulti.hxx> // SwMultiPortion +#include "fmtmeta.hxx" // lcl_NewMetaPortion /************************************************************************* @@ -257,12 +258,65 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf, return pRet; } +/************************************************************************* + * SwTxtFormatter::TryNewNoLengthPortion() + *************************************************************************/ + +SwFldPortion * lcl_NewMetaPortion(SwTxtAttr & rHint, const bool bPrefix) +{ + ::sw::Meta *const pMeta( + static_cast<SwFmtMeta &>(rHint.GetAttr()).GetMeta() ); + ::rtl::OUString fix; + ::sw::MetaField *const pField( dynamic_cast< ::sw::MetaField * >(pMeta) ); + OSL_ENSURE(pField, "lcl_NewMetaPortion: no meta field?"); + if (pField) + { + pField->GetPrefixAndSuffix((bPrefix) ? &fix : 0, (bPrefix) ? 0 : &fix); + } + return new SwFldPortion( fix ); +} + +/** Try to create a new portion with zero length, for an end of a hint + (where there is no CH_TXTATR). Because there may be multiple hint ends at a + given index, m_nHintEndIndex is used to keep track of the already created + portions. But the portions created here may actually be deleted again, + due to UnderFlow. In that case, m_nHintEndIndex must be decremented, + so the portion will be created again on the next line. + */ +SwExpandPortion * +SwTxtFormatter::TryNewNoLengthPortion(SwTxtFormatInfo & rInfo) +{ + if (pHints) + { + const xub_StrLen nIdx(rInfo.GetIdx()); + while (m_nHintEndIndex < pHints->GetEndCount()) + { + SwTxtAttr & rHint( *pHints->GetEnd(m_nHintEndIndex) ); + xub_StrLen const nEnd( *rHint.GetAnyEnd() ); + if (nEnd > nIdx) + { + break; + } + ++m_nHintEndIndex; + if (nEnd == nIdx) + { + if (RES_TXTATR_METAFIELD == rHint.Which()) + { + SwFldPortion *const pPortion( + lcl_NewMetaPortion(rHint, false)); + pPortion->SetNoLength(); // no CH_TXTATR at hint end! + return pPortion; + } + } + } + } + return 0; +} /************************************************************************* * SwTxtFormatter::NewExtraPortion() *************************************************************************/ - SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf ) { SwTxtAttr *pHint = GetAttr( rInf.GetIdx() ); @@ -290,16 +344,6 @@ SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf ) pRet = NewFtnPortion( rInf, pHint ); break; } - case RES_TXTATR_SOFTHYPH : - { - pRet = new SwSoftHyphPortion; - break; - } - case RES_TXTATR_HARDBLANK : - { - pRet = new SwBlankPortion( ((SwTxtHardBlank*)pHint)->GetChar() ); - break; - } case RES_TXTATR_FIELD : { pRet = NewFldPortion( rInf, pHint ); @@ -315,6 +359,11 @@ SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf ) pRet = new SwIsoToxPortion; break; } + case RES_TXTATR_METAFIELD: + { + pRet = lcl_NewMetaPortion( *pHint, true ); + break; + } default: ; } if( !pRet ) diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 5bceef690f..8da2cbf4fb 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -500,26 +500,10 @@ bool lcl_HideObj( const SwTxtFrm& _rFrm, _rFrm.GetTxtNode()->GetTxt().GetChar( _nObjAnchorPos ); if ( cAnchorChar == CH_TXTATR_BREAKWORD ) { - SwpHints* pHints = - const_cast<SwTxtFrm&>(_rFrm).GetTxtNode()->GetpSwpHints(); - const SwTxtAttr* pHint( 0 ); - if( pHints ) - { - for ( USHORT i = 0; i < pHints->Count(); ++i ) - { - SwTxtAttr* pPos = pHints->GetTextHint(i); - xub_StrLen nStart = *pPos->GetStart(); - if ( _nObjAnchorPos < nStart ) - break; - if ( _nObjAnchorPos == nStart && !pPos->GetEnd() ) - { - pHint = pPos; - break; - } - } - } - if ( pHint && - pHint->Which() == RES_TXTATR_FLYCNT ) + const SwTxtAttr* const pHint( + _rFrm.GetTxtNode()->GetTxtAttrForCharAt(_nObjAnchorPos, + RES_TXTATR_FLYCNT) ); + if ( pHint ) { const SwFrmFmt* pFrmFmt = static_cast<const SwTxtFlyCnt*>(pHint)->GetFlyCnt().GetFrmFmt(); diff --git a/sw/source/core/text/txthyph.cxx b/sw/source/core/text/txthyph.cxx index f83c68c4c1..722cae6b04 100644 --- a/sw/source/core/text/txthyph.cxx +++ b/sw/source/core/text/txthyph.cxx @@ -89,7 +89,7 @@ sal_Bool SwTxtFrm::Hyphenate( SwInterHyphInfo &rHyphInf ) { ASSERT( ! IsVertical() || ! IsSwapped(),"swapped frame at SwTxtFrm::Hyphenate" ); - if( !pBreakIt->xBreak.is() ) + if( !pBreakIt->GetBreakIter().is() ) return sal_False;; // Wir machen den Laden erstmal dicht: ASSERT( !IsLocked(), "SwTxtFrm::Hyphenate: this is locked" ); @@ -254,7 +254,7 @@ sal_Bool SwTxtFormatter::Hyphenate( SwInterHyphInfo &rHyphInf ) Reference< XHyphenatedWord > xHyphWord; Boundary aBound = - pBreakIt->xBreak->getWordBoundary( rInf.GetTxt(), nWrdStart, + pBreakIt->GetBreakIter()->getWordBoundary( rInf.GetTxt(), nWrdStart, pBreakIt->GetLocale( rInf.GetFont()->GetLanguage() ), WordType::DICTIONARY_WORD, sal_True ); nWrdStart = static_cast<xub_StrLen>(aBound.startPos); nLen = static_cast<xub_StrLen>(aBound.endPos - nWrdStart); diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx index c438cf3fe3..63e551e8c8 100644 --- a/sw/source/core/tox/txmsrt.cxx +++ b/sw/source/core/tox/txmsrt.cxx @@ -223,7 +223,7 @@ void SwTOXSortTabBase::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, GetTxt( sMyTxt, sMyTxtReading ); - rNd.Insert( sMyTxt, rInsPos ); + rNd.InsertText( sMyTxt, rInsPos ); } BOOL SwTOXSortTabBase::operator==( const SwTOXSortTabBase& rCmp ) @@ -459,7 +459,7 @@ void SwTOXIndex::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, USHORT ) cons else GetTxt( sTmp, sTmpReading ); - rNd.Insert( sTmp, rInsPos ); + rNd.InsertText( sTmp, rInsPos ); } @@ -582,7 +582,7 @@ void SwTOXContent::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, USHORT ) co { String sTmp, sTmpReading; GetTxt( sTmp, sTmpReading ); - rNd.Insert( sTmp, rInsPos ); + rNd.InsertText( sTmp, rInsPos ); } } @@ -684,7 +684,7 @@ void SwTOXPara::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, USHORT ) const String sTmp, sTmpReading; GetTxt( sTmp, sTmpReading ); sTmp.SearchAndReplaceAll('\t', ' '); - rNd.Insert( sTmp, rInsPos ); + rNd.InsertText( sTmp, rInsPos ); } } @@ -904,7 +904,7 @@ void SwTOXAuthority::FillText( SwTxtNode& rNd, } else sText = (pField->GetFieldText((ToxAuthorityField) nAuthField)); - rNd.Insert( sText, rInsPos ); + rNd.InsertText( sText, rInsPos ); } /* -----------------14.10.99 09:35------------------- diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 7aded130ed..5248100afd 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -166,6 +166,8 @@ void SwFmtFld::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) { switch( pNew->Which() ) { + case RES_OBJECTDYING: + return; // don't do anything, especially not expand! case RES_TXTATR_FLDCHG: // "Farbe hat sich geaendert !" // this, this fuer "nur Painten" @@ -261,6 +263,7 @@ SwTxtFld::SwTxtFld( SwFmtFld& rAttr, xub_StrLen nStartPos ) , m_pTxtNode( 0 ) { rAttr.pTxtAttr = this; + SetHasDummyChar(true); } SwTxtFld::~SwTxtFld( ) diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx index e9f1debf16..92cbc614d6 100644 --- a/sw/source/core/txtnode/atrflyin.cxx +++ b/sw/source/core/txtnode/atrflyin.cxx @@ -74,6 +74,7 @@ SwTxtFlyCnt::SwTxtFlyCnt( SwFmtFlyCnt& rAttr, xub_StrLen nStartPos ) : SwTxtAttr( rAttr, nStartPos ) { rAttr.pTxtAttr = this; + SetHasDummyChar(true); } diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx index 3edd5758cb..73640e2ba6 100644 --- a/sw/source/core/txtnode/atrftn.cxx +++ b/sw/source/core/txtnode/atrftn.cxx @@ -182,6 +182,7 @@ SwTxtFtn::SwTxtFtn( SwFmtFtn& rAttr, xub_StrLen nStartPos ) , m_nSeqNo( USHRT_MAX ) { rAttr.pTxtAttr = this; + SetHasDummyChar(true); } @@ -291,7 +292,7 @@ void SwTxtFtn::SetNumber( const USHORT nNewNum, const XubString* pStr ) } // Die Fussnoten duplizieren -void SwTxtFtn::CopyFtn( SwTxtFtn *pDest ) +void SwTxtFtn::CopyFtn( SwTxtFtn *pDest ) const { if ( m_pStartNode && pDest->GetStartNode() ) { diff --git a/sw/source/core/txtnode/atrref.cxx b/sw/source/core/txtnode/atrref.cxx index 054f5c950a..831d604fb3 100644 --- a/sw/source/core/txtnode/atrref.cxx +++ b/sw/source/core/txtnode/atrref.cxx @@ -91,7 +91,10 @@ SwTxtRefMark::SwTxtRefMark( SwFmtRefMark& rAttr, m_nEnd = *pEnd; m_pEnd = & m_nEnd; } - SetDontMergeAttr( true ); + else + { + SetHasDummyChar(true); + } SetDontMoveAttr( true ); SetOverlapAllowedAttr( true ); } diff --git a/sw/source/core/txtnode/atrtox.cxx b/sw/source/core/txtnode/atrtox.cxx index a7e86ac4b8..4cee6eef1b 100644 --- a/sw/source/core/txtnode/atrtox.cxx +++ b/sw/source/core/txtnode/atrtox.cxx @@ -50,7 +50,10 @@ SwTxtTOXMark::SwTxtTOXMark( SwTOXMark& rAttr, m_nEnd = *pEnd; m_pEnd = & m_nEnd; } - SetDontMergeAttr( true ); + else + { + SetHasDummyChar(true); + } SetDontMoveAttr( true ); SetOverlapAllowedAttr( true ); } diff --git a/sw/source/core/txtnode/fmtatr1.cxx b/sw/source/core/txtnode/fmtatr1.cxx deleted file mode 100644 index f9073335c0..0000000000 --- a/sw/source/core/txtnode/fmtatr1.cxx +++ /dev/null @@ -1,97 +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: fmtatr1.cxx,v $ - * $Revision: 1.6 $ - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sw.hxx" - - - -#include <hintids.hxx> -#include <errhdl.hxx> -#include <fmthbsh.hxx> - - -/************************************************************************* -|* -|* class SwFmtHardBlank -|* -|* Beschreibung Dokument 1.20 -|* Ersterstellung JP 23.11.90 -|* Letzte Aenderung JP 20.02.91 -|* -*************************************************************************/ - -SwFmtHardBlank::SwFmtHardBlank( sal_Unicode cCh, BOOL ) - : SfxPoolItem( RES_TXTATR_HARDBLANK ), - cChar( cCh ) -{ -// ASSERT( !bCheck || (' ' != cCh && '-' != cCh), -// "Invalid character for the HardBlank attribute - " -// "must be a normal unicode character" ); -} - -int SwFmtHardBlank::operator==( const SfxPoolItem& rAttr ) const -{ - ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" ); - return cChar == ((SwFmtHardBlank&)rAttr).GetChar(); -} - -SfxPoolItem* SwFmtHardBlank::Clone( SfxItemPool* ) const -{ - return new SwFmtHardBlank( *this ); -} - -/************************************************************************* -|* -|* class SwFmtSoftHyph -|* -|* Beschreibung Dokument 1.20 -|* Ersterstellung JP 23.11.90 -|* Letzte Aenderung JP 20.02.91 -|* -*************************************************************************/ - -SwFmtSoftHyph::SwFmtSoftHyph() - : SfxPoolItem( RES_TXTATR_SOFTHYPH ) -{ -} - -int SwFmtSoftHyph::operator==( const SfxPoolItem& ) const -{ -// ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" ); - return TRUE; -} - -SfxPoolItem* SwFmtSoftHyph::Clone( SfxItemPool* ) const -{ - return new SwFmtSoftHyph( *this ); -} - - diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 9e61c7ca70..ce346a8edc 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -31,14 +31,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - - #include "hintids.hxx" #include "unomid.h" -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include <basic/sbxvar.hxx> -#endif #include <svtools/macitem.hxx> #include <svtools/stritem.hxx> #include <svtools/stylepool.hxx> @@ -51,16 +47,24 @@ #include <hints.hxx> // SwUpdateAttr #include <unostyle.hxx> #include <unoevent.hxx> // SwHyperlinkEventDescriptor -#ifndef _COM_SUN_STAR_TEXT_RUBYADJUST_HDL_ #include <com/sun/star/text/RubyAdjust.hdl> -#endif -#ifndef _CMDID_H #include <cmdid.h> -#endif #include <com/sun/star/uno/Any.h> #include <SwStyleNameMapper.hxx> +#include <fmtmeta.hxx> +#include <ndtxt.hxx> // for meta +#include <doc.hxx> // for meta +#include <unometa.hxx> +#include <unoobj.hxx> // SwXTextRange +#include <docsh.hxx> +#include <svtools/zforlist.hxx> // GetNumberFormat + +#include <boost/bind.hpp> +#include <algorithm> + + using namespace ::com::sun::star; using ::rtl::OUString; @@ -578,3 +582,327 @@ BOOL SwFmtRuby::PutValue( const uno::Any& rVal, return bRet; } + +/************************************************************************* + class SwFmtMeta + ************************************************************************/ + +SwFmtMeta * SwFmtMeta::CreatePoolDefault(const USHORT i_nWhich) +{ + return new SwFmtMeta(i_nWhich); +} + +SwFmtMeta::SwFmtMeta(const USHORT i_nWhich) + : SfxPoolItem( i_nWhich ) + , m_pMeta() + , m_pTxtAttr( 0 ) +{ + ASSERT((RES_TXTATR_META == i_nWhich) || (RES_TXTATR_METAFIELD == i_nWhich), + "ERROR: SwFmtMeta: invalid which id!"); +} + +SwFmtMeta::SwFmtMeta( ::boost::shared_ptr< ::sw::Meta > const & i_pMeta, + const USHORT i_nWhich ) + : SfxPoolItem( i_nWhich ) + , m_pMeta( i_pMeta ) + , m_pTxtAttr( 0 ) +{ + ASSERT((RES_TXTATR_META == i_nWhich) || (RES_TXTATR_METAFIELD == i_nWhich), + "ERROR: SwFmtMeta: invalid which id!"); + ASSERT(m_pMeta, "SwFmtMeta: no Meta ?"); + // DO NOT call m_pMeta->SetFmtMeta(this) here; only from SetTxtAttr! +} + +SwFmtMeta::~SwFmtMeta() +{ + if (m_pMeta->GetFmtMeta() == this) + { + m_pMeta->SetFmtMeta(0); + } +} + +int SwFmtMeta::operator==( const SfxPoolItem & i_rOther ) const +{ + ASSERT( SfxPoolItem::operator==( i_rOther ), "i just copied this assert" ); + return SfxPoolItem::operator==( i_rOther ) + && (m_pMeta == static_cast<SwFmtMeta const &>( i_rOther ).m_pMeta); +} + +SfxPoolItem * SwFmtMeta::Clone( SfxItemPool * /*pPool*/ ) const +{ + // if this is indeed a copy, then DoCopy must be called later! + return new SwFmtMeta( m_pMeta, Which() ); +} + +void SwFmtMeta::SetTxtAttr(SwTxtMeta * const i_pTxtAttr) +{ + ASSERT(!(m_pTxtAttr && i_pTxtAttr), + "SwFmtMeta::SetTxtAttr: already has text attribute?"); + ASSERT( m_pTxtAttr || i_pTxtAttr , + "SwFmtMeta::SetTxtAttr: no attribute to remove?"); + m_pTxtAttr = i_pTxtAttr; + ASSERT(m_pMeta, "inserted SwFmtMeta has no sw::Meta?"); + // the sw::Meta must be able to find the current text attribute! + if (i_pTxtAttr && m_pMeta) + { + m_pMeta->SetFmtMeta(this); + } +} + +void SwFmtMeta::NotifyRemoval() +{ + // N.B.: do not reset m_pTxtAttr here: see call in nodes.cxx, + // where the hint is not deleted! + ASSERT(m_pMeta, "NotifyRemoval: no meta ?"); + if (m_pMeta) + { + SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, + &static_cast<SwModify&>(*m_pMeta) ); // cast to proper base class! + m_pMeta->Modify(&aMsgHint, &aMsgHint); + } +} + +void SwFmtMeta::DoCopy(SwFmtMeta & rOriginalMeta) +{ + ASSERT(m_pMeta, "DoCopy called for SwFmtMeta with no sw::Meta?"); + if (m_pMeta) + { + const ::boost::shared_ptr< ::sw::Meta> pOriginal( m_pMeta ); + // UGLY: original sw::Meta now points at _this_ due to being already + // inserted via MakeTxtAttr! so fix it up to point at the original item + // (maybe would be better to tell MakeTxtAttr that it creates a copy?) + pOriginal->SetFmtMeta(&rOriginalMeta); + if (RES_TXTATR_META == Which()) + { + m_pMeta.reset( new ::sw::Meta(this) ); + } + else + { + ::sw::MetaField *const pMetaField( + static_cast< ::sw::MetaField* >(pOriginal.get())); + SwDoc * const pTargetDoc( GetTxtAttr()->GetTxtNode()->GetDoc() ); + m_pMeta = pTargetDoc->GetMetaFieldManager().makeMetaField( this, + pMetaField->m_nNumberFormat, pMetaField->IsFixedLanguage() ); + } + m_pMeta->RegisterAsCopyOf(*pOriginal); + } +} + + +namespace sw { + +/************************************************************************* + class sw::Meta + ************************************************************************/ + +Meta::Meta(SwFmtMeta * const i_pFmt) + : ::sfx2::Metadatable() + , SwModify() + , m_pFmt( i_pFmt ) +{ +} + +Meta::~Meta() +{ +} + +SwTxtMeta * Meta::GetTxtAttr() const +{ + return (m_pFmt) ? m_pFmt->GetTxtAttr() : 0; +} + +SwTxtNode * Meta::GetTxtNode() const +{ + SwTxtMeta * const pTxtAttr( GetTxtAttr() ); + return (pTxtAttr) ? pTxtAttr->GetTxtNode() : 0; +} + +// SwClient +void Meta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) +{ + SwTxtNode * const pTxtNode( GetTxtNode() ); + if (pTxtNode && (GetRegisteredIn() != pTxtNode)) + { + pTxtNode->Add(this); + } + SwModify::Modify(pOld, pNew); +} + +// sw::Metadatable +::sfx2::IXmlIdRegistry& Meta::GetRegistry() +{ + SwTxtNode * const pTxtNode( GetTxtNode() ); + // GetRegistry may only be called on a meta that is actually in the + // document, which means it has a pointer to its text node + OSL_ENSURE(pTxtNode, "ERROR: GetRegistry: no text node?"); + if (!pTxtNode) + throw uno::RuntimeException(); + return pTxtNode->GetRegistry(); +} + +bool Meta::IsInClipboard() const +{ + const SwTxtNode * const pTxtNode( GetTxtNode() ); +// no text node: in UNDO OSL_ENSURE(pTxtNode, "IsInClipboard: no text node?"); + return (pTxtNode) ? pTxtNode->IsInClipboard() : false; +} + +bool Meta::IsInUndo() const +{ + const SwTxtNode * const pTxtNode( GetTxtNode() ); +// no text node: in UNDO OSL_ENSURE(pTxtNode, "IsInUndo: no text node?"); + return (pTxtNode) ? pTxtNode->IsInUndo() : true; +} + +bool Meta::IsInContent() const +{ + const SwTxtNode * const pTxtNode( GetTxtNode() ); + OSL_ENSURE(pTxtNode, "IsInContent: no text node?"); + return (pTxtNode) ? pTxtNode->IsInContent() : true; +} + +::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > +Meta::MakeUnoObject() +{ + // re-use existing SwXMeta + SwClientIter iter( *this ); + SwClient * pClient( iter.First( TYPE( SwXMeta ) ) ); + while (pClient) { + SwXMeta *const pMeta( dynamic_cast<SwXMeta*>(pClient) ); + if (pMeta && pMeta->GetCoreObject() == this) { + return pMeta; + } + pClient = iter.Next(); + } + + // create new SwXMeta + SwTxtMeta * const pTxtAttr( GetTxtAttr() ); + OSL_ENSURE(pTxtAttr, "MakeUnoObject: no text attr?"); + if (!pTxtAttr) return 0; + SwTxtNode * const pTxtNode( pTxtAttr->GetTxtNode() ); + OSL_ENSURE(pTxtNode, "MakeUnoObject: no text node?"); + if (!pTxtNode) return 0; + const SwPosition aPos(*pTxtNode, *pTxtAttr->GetStart()); + const uno::Reference<text::XText> xParentText( + SwXTextRange::CreateParentXText(pTxtNode->GetDoc(), aPos) ); + if (!xParentText.is()) return 0; + return (RES_TXTATR_META == m_pFmt->Which()) + ? new SwXMeta (pTxtNode->GetDoc(), xParentText, 0, pTxtAttr) + : new SwXMetaField(pTxtNode->GetDoc(), xParentText, 0, pTxtAttr); +} + +/************************************************************************* + class sw::MetaField + ************************************************************************/ + +MetaField::MetaField(SwFmtMeta * const i_pFmt, + const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage) + : Meta(i_pFmt) + , m_nNumberFormat( nNumberFormat ) + , m_bIsFixedLanguage( bIsFixedLanguage ) +{ +} + +void MetaField::GetPrefixAndSuffix( + ::rtl::OUString *const o_pPrefix, ::rtl::OUString *const o_pSuffix) +{ + try + { + const uno::Reference<rdf::XMetadatable> xMetaField( MakeUnoObject() ); + OSL_ENSURE(dynamic_cast<SwXMetaField*>(xMetaField.get()), + "GetPrefixAndSuffix: no SwXMetaField?"); + if (xMetaField.is()) + { + SwTxtNode * const pTxtNode( GetTxtNode() ); + SwDocShell const * const pShell(pTxtNode->GetDoc()->GetDocShell()); + const uno::Reference<frame::XModel> xModel( + (pShell) ? pShell->GetModel() : 0, uno::UNO_SET_THROW); + getPrefixAndSuffix(xModel, xMetaField, o_pPrefix, o_pSuffix); + } + } catch (uno::Exception) { + OSL_ENSURE(false, "exception?"); + } +} + +sal_uInt32 MetaField::GetNumberFormat(::rtl::OUString const & rContent) const +{ + //TODO: this probably lacks treatment for some special cases + sal_uInt32 nNumberFormat( m_nNumberFormat ); + SwTxtNode * const pTxtNode( GetTxtNode() ); + if (pTxtNode) + { + SvNumberFormatter *const pNumberFormatter( + pTxtNode->GetDoc()->GetNumberFormatter() ); + double number; + (void) pNumberFormatter->IsNumberFormat( + rContent, nNumberFormat, number ); + } + return nNumberFormat; +} + +void MetaField::SetNumberFormat(sal_uInt32 nNumberFormat) +{ + // effectively, the member is only a default: + // GetNumberFormat checks if the text actually conforms + m_nNumberFormat = nNumberFormat; +} + + +/************************************************************************* + class sw::MetaFieldManager + ************************************************************************/ + + +MetaFieldManager::MetaFieldManager() +{ +} + +::boost::shared_ptr<MetaField> +MetaFieldManager::makeMetaField(SwFmtMeta * const i_pFmt, + const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage) +{ + const ::boost::shared_ptr<MetaField> pMetaField( + new MetaField(i_pFmt, nNumberFormat, bIsFixedLanguage) ); + m_MetaFields.push_back(pMetaField); + return pMetaField; +} + +struct IsInUndo +{ + bool operator()(::boost::weak_ptr<MetaField> const & pMetaField) { + return pMetaField.lock()->IsInUndo(); + } +}; + +struct MakeUnoObject +{ + uno::Reference<text::XTextField> + operator()(::boost::weak_ptr<MetaField> const & pMetaField) { + return uno::Reference<text::XTextField>( + pMetaField.lock()->MakeUnoObject(), uno::UNO_QUERY); + } +}; + +::std::vector< uno::Reference<text::XTextField> > +MetaFieldManager::getMetaFields() +{ + // erase deleted fields + const MetaFieldList_t::iterator iter( + ::std::remove_if(m_MetaFields.begin(), m_MetaFields.end(), + ::boost::bind(&::boost::weak_ptr<MetaField>::expired, _1))); + m_MetaFields.erase(iter, m_MetaFields.end()); + // filter out fields in UNDO + MetaFieldList_t filtered(m_MetaFields.size()); + const MetaFieldList_t::iterator iter2( + ::std::remove_copy_if(m_MetaFields.begin(), m_MetaFields.end(), + filtered.begin(), IsInUndo())); + filtered.erase(iter2, filtered.end()); + // create uno objects + ::std::vector< uno::Reference<text::XTextField> > ret(filtered.size()); + ::std::transform(filtered.begin(), filtered.end(), ret.begin(), + MakeUnoObject()); + return ret; +} + +} // namespace sw + diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 30a414ac39..b01c132c61 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -2425,7 +2425,7 @@ xub_StrLen SwFntObj::GetCrsrOfst( SwDrawTextInfo &rInf ) // skip character cells for complex scripts if ( rInf.GetFont() && SW_CTL == rInf.GetFont()->GetActual() && - pBreakIt->xBreak.is() ) + pBreakIt->GetBreakIter().is() ) { aLang = rInf.GetFont()->GetLanguage(); bSkipCell = sal_True; @@ -2441,7 +2441,7 @@ xub_StrLen SwFntObj::GetCrsrOfst( SwDrawTextInfo &rInf ) if ( bSkipCell ) { - nIdx = (xub_StrLen)pBreakIt->xBreak->nextCharacters( rInf.GetText(), + nIdx = (xub_StrLen)pBreakIt->GetBreakIter()->nextCharacters( rInf.GetText(), nIdx, pBreakIt->GetLocale( aLang ), nItrMode, 1, nDone ); if ( nIdx <= nLastIdx ) break; @@ -2704,13 +2704,13 @@ xub_StrLen SwFont::GetTxtBreak( SwDrawTextInfo& rInf, long nTextWidth ) const XubString aSnippet( rInf.GetText(), rInf.GetIdx(), nLn ); aTmpText = aSub[nActual].CalcCaseMap( aSnippet ); const bool bTitle = SVX_CASEMAP_TITEL == aSub[nActual].GetCaseMap() && - pBreakIt->xBreak.is(); + pBreakIt->GetBreakIter().is(); // Uaaaaahhhh!!! In title case mode, we would get wrong results if ( bTitle && nLn ) { // check if rInf.GetIdx() is begin of word - if ( !pBreakIt->xBreak->isBeginWord( + if ( !pBreakIt->GetBreakIter()->isBeginWord( rInf.GetText(), rInf.GetIdx(), pBreakIt->GetLocale( aSub[nActual].GetLanguage() ), i18n::WordType::ANYWORD_IGNOREWHITESPACES ) ) diff --git a/sw/source/core/txtnode/fntcap.cxx b/sw/source/core/txtnode/fntcap.cxx index 726531e3f0..0ad7ca6278 100644 --- a/sw/source/core/txtnode/fntcap.cxx +++ b/sw/source/core/txtnode/fntcap.cxx @@ -102,13 +102,13 @@ xub_StrLen lcl_CalcCaseMap( const SwFont& rFnt, // special case for title case: const bool bTitle = SVX_CASEMAP_TITEL == rFnt.GetCaseMap() && - pBreakIt->xBreak.is(); + pBreakIt->GetBreakIter().is(); for ( xub_StrLen i = nOfst; i < nEnd; ++i ) { XubString aTmp( rOrigString, i, 1 ); if ( !bTitle || - pBreakIt->xBreak->isBeginWord( + pBreakIt->GetBreakIter()->isBeginWord( rOrigString, i, pBreakIt->GetLocale( rFnt.GetLanguage() ), WordType::ANYWORD_IGNOREWHITESPACES ) ) @@ -654,7 +654,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo ) if( nPos < nMaxPos ) { - nPos = (xub_StrLen)pBreakIt->xBreak->endOfCharBlock( rOldText, nPos, + nPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfCharBlock( rOldText, nPos, pBreakIt->GetLocale( eLng ), CharType::LOWERCASE_LETTER); if( nPos == STRING_LEN ) nPos = nOldPos; @@ -702,7 +702,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo ) rDo.Do(); nOldPos = nPos; } - nPos = (xub_StrLen)pBreakIt->xBreak->nextCharBlock( rOldText, nPos, + nPos = (xub_StrLen)pBreakIt->GetBreakIter()->nextCharBlock( rOldText, nPos, pBreakIt->GetLocale( eLng ), CharType::LOWERCASE_LETTER); if( nPos == STRING_LEN || nPos > nMaxPos ) nPos = nMaxPos; @@ -816,7 +816,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo ) } } while( nOldPos != nPos ); } - nPos = (xub_StrLen)pBreakIt->xBreak->endOfCharBlock( rOldText, nPos, + nPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfCharBlock( rOldText, nPos, pBreakIt->GetLocale( eLng ), CharType::LOWERCASE_LETTER); if( nPos == STRING_LEN || nPos > nMaxPos ) nPos = nMaxPos; diff --git a/sw/source/core/txtnode/makefile.mk b/sw/source/core/txtnode/makefile.mk index f4fbf70014..36c6e09d6b 100644 --- a/sw/source/core/txtnode/makefile.mk +++ b/sw/source/core/txtnode/makefile.mk @@ -53,7 +53,6 @@ SLOFILES = \ $(SLO)$/atrref.obj \ $(SLO)$/atrtox.obj \ $(SLO)$/chrfmt.obj \ - $(SLO)$/fmtatr1.obj \ $(SLO)$/fmtatr2.obj \ $(SLO)$/fntcap.obj \ $(SLO)$/fntcache.obj \ @@ -71,6 +70,7 @@ SLOFILES = \ EXCEPTIONSFILES = \ + $(SLO)$/fmtatr2.obj \ $(SLO)$/atrtox.obj \ $(SLO)$/atrflyin.obj \ $(SLO)$/docnew.obj \ @@ -78,7 +78,7 @@ EXCEPTIONSFILES = \ $(SLO)$/ndtxt.obj \ $(SLO)$/thints.obj \ $(SLO)$/txtedt.obj - + .IF "$(dbutil)" != "" OFILES+=$(SLO)$/dbchratr.$(QBJX) diff --git a/sw/source/core/txtnode/ndhints.cxx b/sw/source/core/txtnode/ndhints.cxx index ef4d01417d..707d62cd14 100644 --- a/sw/source/core/txtnode/ndhints.cxx +++ b/sw/source/core/txtnode/ndhints.cxx @@ -39,6 +39,11 @@ #include "ndhints.hxx" #include <txtatr.hxx> +#ifndef PRODUCT +#include <pam.hxx> +#endif + + _SV_IMPL_SORTAR_ALG( SwpHtStart, SwTxtAttr* ) _SV_IMPL_SORTAR_ALG( SwpHtEnd, SwTxtAttr* ) @@ -101,15 +106,15 @@ static BOOL lcl_IsLessStart( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) { if ( *rHt1.GetStart() == *rHt2.GetStart() ) { - xub_StrLen nHt1 = *rHt1.GetAnyEnd(); - xub_StrLen nHt2 = *rHt2.GetAnyEnd(); + const xub_StrLen nHt1 = *rHt1.GetAnyEnd(); + const xub_StrLen nHt2 = *rHt2.GetAnyEnd(); if ( nHt1 == nHt2 ) { - nHt1 = rHt1.Which(); - nHt2 = rHt2.Which(); - if ( nHt1 == nHt2 ) + const USHORT nWhich1 = rHt1.Which(); + const USHORT nWhich2 = rHt2.Which(); + if ( nWhich1 == nWhich2 ) { - if ( RES_TXTATR_CHARFMT == nHt1 ) + if ( RES_TXTATR_CHARFMT == nWhich1 ) { const USHORT nS1 = static_cast<const SwTxtCharFmt&>(rHt1).GetSortNumber(); const USHORT nS2 = static_cast<const SwTxtCharFmt&>(rHt2).GetSortNumber(); @@ -120,6 +125,8 @@ static BOOL lcl_IsLessStart( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) return (long)&rHt1 < (long)&rHt2; } + // the order must ensure that META is inside RUBY! + return ( nWhich1 < nWhich2 ); } return ( nHt1 > nHt2 ); } @@ -133,18 +140,17 @@ static BOOL lcl_IsLessStart( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) // Zuerst nach Ende danach nach Ptr static BOOL lcl_IsLessEnd( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) { - xub_StrLen nHt1 = *rHt1.GetAnyEnd(); - xub_StrLen nHt2 = *rHt2.GetAnyEnd(); + const xub_StrLen nHt1 = *rHt1.GetAnyEnd(); + const xub_StrLen nHt2 = *rHt2.GetAnyEnd(); if ( nHt1 == nHt2 ) { if ( *rHt1.GetStart() == *rHt2.GetStart() ) { - nHt1 = rHt1.Which(); - nHt2 = rHt2.Which(); - - if ( nHt1 == nHt2 ) + const USHORT nWhich1 = rHt1.Which(); + const USHORT nWhich2 = rHt2.Which(); + if ( nWhich1 == nWhich2 ) { - if ( RES_TXTATR_CHARFMT == nHt1 ) + if ( RES_TXTATR_CHARFMT == nWhich1 ) { const USHORT nS1 = static_cast<const SwTxtCharFmt&>(rHt1).GetSortNumber(); const USHORT nS2 = static_cast<const SwTxtCharFmt&>(rHt2).GetSortNumber(); @@ -155,7 +161,8 @@ static BOOL lcl_IsLessEnd( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) return (long)&rHt1 > (long)&rHt2; } - // else return nHt1 < nHt2, see below + // the order must ensure that META is inside RUBY! + return ( nWhich1 > nWhich2 ); } else return ( *rHt1.GetStart() > *rHt2.GetStart() ); @@ -377,6 +384,37 @@ bool SwpHintsArray::Check() const ( *pHtThis->GetStart() == *pHtThis->GetEnd() ), "HintsCheck: Portion inconsistency. " "This can be temporarily ok during undo operations" ); + + if (pHtThis->IsNesting()) + { + for ( USHORT j = 0; j < Count(); ++j ) + { + SwTxtAttr const * const pOther( m_HintStarts[j] ); + if ( pOther->IsNesting() && (i != j) ) + { + SwComparePosition cmp = ComparePosition( + *pHtThis->GetStart(), *pHtThis->GetEnd(), + *pOther->GetStart(), *pOther->GetEnd()); + CHECK_ERR( (POS_OVERLAP_BEFORE != cmp) && + (POS_OVERLAP_BEHIND != cmp), + "HintsCheck: overlapping nesting hints!!!" ); + } + } + } + + // 9) dummy char check (unfortunately cannot check SwTxtNode::m_Text) + if (pHtThis->HasDummyChar()) + { + for ( USHORT j = 0; j < i; ++j ) + { + SwTxtAttr const * const pOther( m_HintStarts[j] ); + if (pOther->HasDummyChar()) + { + CHECK_ERR( (*pOther->GetStart() != *pHtThis->GetStart()), + "HintsCheck: multiple hints claim same CH_TXTATR!"); + } + } + } #endif } return true; diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 4c9b7910a8..8d0c0637c1 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -52,7 +52,6 @@ #include <fmtinfmt.hxx> #include <fmtpdsc.hxx> #include <txtatr.hxx> -#include <fmthbsh.hxx> #include <fmtrfmrk.hxx> #include <txttxmrk.hxx> #include <fchrfmt.hxx> @@ -64,6 +63,7 @@ #include <ftnidx.hxx> #include <ftninfo.hxx> #include <fmtftn.hxx> +#include <fmtmeta.hxx> #include <charfmt.hxx> #include <ndtxt.hxx> #include <doc.hxx> @@ -234,7 +234,6 @@ SwTxtNode::SwTxtNode( const SwNodeIndex &rWhere, mpNodeNum( 0 ), m_bLastOutlineState( false ), m_bNotifiable( false ), - //nOutlineLevel( pTxtColl->GetOutlineLevel() )//#outline level, removed by zhaojianwei. // --> OD 2008-11-19 #i70748# mbEmptyListStyleSetDueToSetOutlineLevelAttr( false ), // <-- @@ -253,6 +252,15 @@ SwTxtNode::SwTxtNode( const SwNodeIndex &rWhere, // SyncNumberAndNumRule(); if ( !IsInList() && GetNumRule() && GetListId().Len() > 0 ) { + // --> OD 2009-08-27 #i101516# + // apply paragraph style's assigned outline style list level as + // list level of the paragraph, if it has none set already. + if ( !HasAttrListLevel() && + pTxtColl && pTxtColl->IsAssignedToListLevelOfOutlineStyle() ) + { + SetAttrListLevel( pTxtColl->GetAssignedOutlineStyleLevel() ); + } + // <-- AddToList(); } // <-- @@ -390,9 +398,10 @@ void lcl_ChangeFtnRef( SwTxtNode &rNode ) SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) { // lege den Node "vor" mir an - xub_StrLen nSplitPos = rPos.nContent.GetIndex(); - xub_StrLen nTxtLen = m_Text.Len(); - SwTxtNode* pNode = _MakeNewTxtNode( rPos.nNode, FALSE, nSplitPos==nTxtLen ); + const xub_StrLen nSplitPos = rPos.nContent.GetIndex(); + const xub_StrLen nTxtLen = m_Text.Len(); + SwTxtNode* const pNode = + _MakeNewTxtNode( rPos.nNode, FALSE, nSplitPos==nTxtLen ); // the first paragraph gets the XmlId, // _except_ if it is empty and the second is not empty @@ -444,21 +453,27 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) //Ersten Teil des Inhalts in den neuen Node uebertragen und //im alten Node loeschen. SwIndex aIdx( this ); - Cut( pNode, aIdx, nSplitPos ); + CutText( pNode, aIdx, nSplitPos ); if( GetWrong() ) + { pNode->SetWrong( GetWrong()->SplitList( nSplitPos ) ); + } SetWrongDirty( true ); if( GetGrammarCheck() ) + { pNode->SetGrammarCheck( GetGrammarCheck()->SplitGrammarList( nSplitPos ) ); + } SetGrammarCheckDirty( true ); SetWordCountDirty( true ); // SMARTTAGS if( GetSmartTags() ) + { pNode->SetSmartTags( GetSmartTags()->SplitList( nSplitPos ) ); + } SetSmartTagDirty( true ); if ( pNode->HasHints() ) @@ -479,21 +494,22 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) // Attribute loeschen if ( HasHints() ) { - SwTxtAttr* pHt; - xub_StrLen* pEnd; for ( USHORT j = m_pSwpHints->Count(); j; ) { - pHt = m_pSwpHints->GetTextHint( --j ); + SwTxtAttr* const pHt = m_pSwpHints->GetTextHint( --j ); if ( RES_TXTATR_FLYCNT == pHt ->Which() ) { pHt->GetFlyCnt().GetFrmFmt()->DelFrms(); } - else if( pHt->DontExpand() && 0 != ( pEnd = pHt->GetEnd() ) - && *pHt->GetStart() == *pEnd ) + else if ( pHt->DontExpand() ) { - // delete it! - m_pSwpHints->DeleteAtPos( j ); - DestroyAttr( pHt ); + const xub_StrLen* const pEnd = pHt->GetEnd(); + if (pEnd && *pHt->GetStart() == *pEnd ) + { + // delete it! + m_pSwpHints->DeleteAtPos( j ); + DestroyAttr( pHt ); + } } } } @@ -503,6 +519,7 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) SwClientIter aIter( *this ); SwClient* pLastFrm = aIter.GoStart(); if( pLastFrm ) + { do { SwCntntFrm *pFrm = PTR_CAST( SwCntntFrm, pLastFrm ); if ( pFrm ) @@ -512,7 +529,9 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) ((SwTxtFrm*)pFrm)->GetOfst() ) ((SwTxtFrm*)pFrm)->SetOfst( 0 ); } - } while( 0 != ( pLastFrm = aIter++ )); + pLastFrm = aIter++; + } while ( pLastFrm ); + } if ( IsInCache() ) { @@ -522,13 +541,12 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) UnlockModify(); // Benachrichtigungen wieder freischalten - const SwRootFrm *pRootFrm; + const SwRootFrm * const pRootFrm = pNode->GetDoc()->GetRootFrm(); // If there is an accessible layout we must call modify even // with length zero, because we have to notify about the changed // text node. - if( nTxtLen != nSplitPos || - ( (pRootFrm = pNode->GetDoc()->GetRootFrm()) != 0 && - pRootFrm->IsAnyShellAccessible() ) ) + if ( (nTxtLen != nSplitPos) || + ( pRootFrm && pRootFrm->IsAnyShellAccessible() ) ) { // dann sage den Frames noch, das am Ende etwas "geloescht" wurde @@ -568,18 +586,16 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) SetSmartTagDirty( true ); SwIndex aIdx( this ); - Cut( pNode, aIdx, rPos.nContent.GetIndex() ); + CutText( pNode, aIdx, nSplitPos ); // JP 01.10.96: alle leeren und nicht zu expandierenden // Attribute loeschen if ( HasHints() ) { - SwTxtAttr* pHt; - xub_StrLen* pEnd; for ( USHORT j = m_pSwpHints->Count(); j; ) { - pHt = m_pSwpHints->GetTextHint( --j ); - pEnd = pHt->GetEnd(); + SwTxtAttr* const pHt = m_pSwpHints->GetTextHint( --j ); + const xub_StrLen* const pEnd = pHt->GetEnd(); if ( pHt->DontExpand() && pEnd && (*pHt->GetStart() == *pEnd) ) { // delete it! @@ -610,7 +626,9 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) } if ( GetDepends() ) + { MakeFrms( *pNode ); // neue Frames anlegen. + } lcl_ChangeFtnRef( *pNode ); } @@ -622,7 +640,9 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) const SfxPoolItem *pItem; if( GetDepends() && SFX_ITEM_SET == pNode->GetSwAttrSet(). GetItemState( RES_PAGEDESC, TRUE, &pItem ) ) + { pNode->Modify( (SfxPoolItem*)pItem, (SfxPoolItem*)pItem ); + } } return pNode; } @@ -727,7 +747,7 @@ SwCntntNode *SwTxtNode::JoinNext() } { // wg. SwIndex - pTxtNode->Cut( this, SwIndex(pTxtNode), pTxtNode->Len() ); + pTxtNode->CutText( this, SwIndex(pTxtNode), pTxtNode->Len() ); } // verschiebe noch alle Bookmarks/TOXMarks if( aBkmkArr.Count() ) @@ -822,7 +842,7 @@ SwCntntNode *SwTxtNode::JoinPrev() } { // wg. SwIndex - pTxtNode->Cut( this, SwIndex( this ), SwIndex(pTxtNode), nLen ); + pTxtNode->CutText( this, SwIndex(this), SwIndex(pTxtNode), nLen ); } // verschiebe noch alle Bookmarks/TOXMarks if( aBkmkArr.Count() ) @@ -869,51 +889,49 @@ void SwTxtNode::NewAttrSet( SwAttrPool& rPool ) } -// Ueberladen der virtuellen Update-Methode von SwIndexReg. Dadurch -// benoetigen die Text-Attribute nur xub_StrLen statt SwIndizies! -void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, - BOOL bNegativ, BOOL bDelete ) +// override SwIndexReg::Update => text hints do not need SwIndex for start/end! +void SwTxtNode::Update( SwIndex const & rPos, const xub_StrLen nChangeLen, + const bool bNegative, const bool bDelete ) { SetAutoCompleteWordDirty( TRUE ); - TmpHints* pCollector = NULL; + ::std::auto_ptr<TmpHints> pCollector; + const xub_StrLen nChangePos = rPos.GetIndex(); + if ( HasHints() ) { - xub_StrLen nPos = aPos.GetIndex(); - xub_StrLen* pIdx; - SwTxtAttr* pHt; - if( bNegativ ) + if ( bNegative ) { - xub_StrLen nMax = nPos + nLen; + const xub_StrLen nChangeEnd = nChangePos + nChangeLen; for ( USHORT n = 0; n < m_pSwpHints->Count(); ++n ) { - BOOL bSttBefore = FALSE; - pHt = m_pSwpHints->GetTextHint(n); - pIdx = pHt->GetStart(); - if( *pIdx >= nPos ) + SwTxtAttr * const pHint = m_pSwpHints->GetTextHint(n); + xub_StrLen * const pStart = pHint->GetStart(); + if ( *pStart > nChangePos ) { - if( *pIdx > nMax ) - *pIdx = *pIdx - nLen; + if ( *pStart > nChangeEnd ) + { + *pStart = *pStart - nChangeLen; + } else { - *pIdx = nPos; + *pStart = nChangePos; } } - else - bSttBefore = TRUE; - - if( 0 == (pIdx = pHt->GetEnd()) ) - continue; - if( *pIdx >= nPos ) + xub_StrLen * const pEnd = pHint->GetEnd(); + if (pEnd) { - if( *pIdx > nMax ) + if ( *pEnd > nChangePos ) { - *pIdx = *pIdx - nLen; - } - else if( *pIdx != nPos ) - { - *pIdx = nPos; + if( *pEnd > nChangeEnd ) + { + *pEnd = *pEnd - nChangeLen; + } + else + { + *pEnd = nChangePos; + } } } } @@ -922,9 +940,8 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, } else { - xub_StrLen* pEnd; - BOOL bNoExp = FALSE; - BOOL bResort = FALSE; + bool bNoExp = false; + bool bResort = false; const USHORT coArrSz = static_cast<USHORT>(RES_TXTATR_WITHEND_END) - static_cast<USHORT>(RES_CHRATR_BEGIN) + static_cast<USHORT>(RES_UNKNOWNATR_END) - @@ -935,27 +952,29 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, for ( USHORT n = 0; n < m_pSwpHints->Count(); ++n ) { - pHt = m_pSwpHints->GetTextHint(n); - pIdx = pHt->GetStart(); - pEnd = pHt->GetEnd(); - if ( *pIdx >= nPos ) + SwTxtAttr * const pHint = m_pSwpHints->GetTextHint(n); + xub_StrLen * const pStart = pHint->GetStart(); + xub_StrLen * const pEnd = pHint->GetEnd(); + if ( *pStart >= nChangePos ) { - *pIdx = *pIdx + nLen; + *pStart = *pStart + nChangeLen; if ( pEnd ) { - *pEnd = *pEnd + nLen; + *pEnd = *pEnd + nChangeLen; } } - else if ( pEnd && *pEnd >= nPos ) + else if ( pEnd && (*pEnd >= nChangePos) ) { - if( *pEnd > nPos || IsIgnoreDontExpand() ) + if ( (*pEnd > nChangePos) || IsIgnoreDontExpand() ) { - *pEnd = *pEnd + nLen; + *pEnd = *pEnd + nChangeLen; } - else + else // *pEnd == nChangePos { - USHORT nWhPos, nWhich = pHt->Which(); + USHORT nWhPos; + const USHORT nWhich = pHint->Which(); + ASSERT(!isCHRATR(nWhich), "Update: char attr hint?"); if (isCHRATR(nWhich) || isTXTATR_WITHEND(nWhich)) { nWhPos = static_cast<USHORT>(nWhich - @@ -975,13 +994,13 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, if( aDontExp[ nWhPos ] ) continue; - if( pHt->DontExpand() ) + if ( pHint->DontExpand() ) { - pHt->SetDontExpand( FALSE ); - bResort = TRUE; - if( pHt->IsCharFmtAttr() ) + pHint->SetDontExpand( false ); + bResort = true; + if ( pHint->IsCharFmtAttr() ) { - bNoExp = TRUE; + bNoExp = true; aDontExp[ static_cast<USHORT>(RES_TXTATR_CHARFMT) - static_cast<USHORT>(RES_CHRATR_BEGIN) ] = TRUE; aDontExp[ static_cast<USHORT>(RES_TXTATR_INETFMT) - static_cast<USHORT>(RES_CHRATR_BEGIN) ] @@ -992,8 +1011,10 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, } else if( bNoExp ) { - if( !pCollector ) - pCollector = new TmpHints; + if ( !pCollector.get() ) + { + pCollector.reset( new TmpHints ); + } USHORT nCollCnt = pCollector->Count(); for( USHORT i = 0; i < nCollCnt; ++i ) { @@ -1001,22 +1022,24 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, if( nWhich == pTmp->Which() ) { pCollector->Remove( i ); - delete pTmp; + SwTxtAttr::Destroy( pTmp, + GetDoc()->GetAttrPool() ); break; } } - SwTxtAttr *pTmp = MakeTxtAttr( pHt->GetAttr(), - nPos, nPos + nLen ); + SwTxtAttr * const pTmp = MakeTxtAttr( *GetDoc(), + pHint->GetAttr(), + nChangePos, nChangePos + nChangeLen); pCollector->C40_INSERT( SwTxtAttr, pTmp, pCollector->Count() ); } else { - *pEnd = *pEnd + nLen; + *pEnd = *pEnd + nChangeLen; } } } } - if( bResort ) + if ( bResort ) { m_pSwpHints->Resort(); } @@ -1024,45 +1047,51 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, } SwIndexReg aTmpIdxReg; - if( !bNegativ && !bDelete ) + if ( !bNegative && !bDelete ) { - SwIndex* pIdx; const SwRedlineTbl& rTbl = GetDoc()->GetRedlineTbl(); - if( rTbl.Count() ) - for( USHORT i = 0; i < rTbl.Count(); ++i ) + for ( USHORT i = 0; i < rTbl.Count(); ++i ) + { + SwRedline *const pRedl = rTbl[ i ]; + if ( pRedl->HasMark() ) { - SwRedline* pRedl = rTbl[ i ]; - if( pRedl->HasMark() ) + SwPosition* const pEnd = pRedl->End(); + if ( this == &pEnd->nNode.GetNode() && + *pRedl->GetPoint() != *pRedl->GetMark() ) { - SwPosition* pEnd = pRedl->End(); - - if( this == &pEnd->nNode.GetNode() && - *pRedl->GetPoint() != *pRedl->GetMark() && - aPos.GetIndex() == - (pIdx = &pEnd->nContent)->GetIndex() ) - pIdx->Assign( &aTmpIdxReg, pIdx->GetIndex() ); + SwIndex & rIdx = pEnd->nContent; + if (nChangePos == rIdx.GetIndex()) + { + rIdx.Assign( &aTmpIdxReg, rIdx.GetIndex() ); + } } - else if( this == &pRedl->GetPoint()->nNode.GetNode() && - aPos.GetIndex() == (pIdx = &pRedl->GetPoint()-> - nContent)->GetIndex() ) + } + else if ( this == &pRedl->GetPoint()->nNode.GetNode() ) + { + SwIndex & rIdx = pRedl->GetPoint()->nContent; + if (nChangePos == rIdx.GetIndex()) { - pIdx->Assign( &aTmpIdxReg, pIdx->GetIndex() ); - if( &pRedl->GetBound( TRUE ) == pRedl->GetPoint() ) + rIdx.Assign( &aTmpIdxReg, rIdx.GetIndex() ); + // mst: FIXME: why does this adjust the unused position??? + SwIndex * pIdx; + if ( &pRedl->GetBound( true ) == pRedl->GetPoint() ) { - pRedl->GetBound( FALSE ) = pRedl->GetBound( TRUE ); - pIdx = &pRedl->GetBound( FALSE ).nContent; + pRedl->GetBound( false ) = pRedl->GetBound( true ); + pIdx = &pRedl->GetBound( false ).nContent; } else { - pRedl->GetBound( TRUE ) = pRedl->GetBound( FALSE ); - pIdx = &pRedl->GetBound( TRUE ).nContent; + pRedl->GetBound( true ) = pRedl->GetBound( false ); + pIdx = &pRedl->GetBound( true ).nContent; } pIdx->Assign( &aTmpIdxReg, pIdx->GetIndex() ); } } + } const IDocumentMarkAccess* const pMarkAccess = getIDocumentMarkAccess(); - for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin(); + for(IDocumentMarkAccess::const_iterator_t ppMark = + pMarkAccess->getMarksBegin(); ppMark != pMarkAccess->getMarksEnd(); ppMark++) { @@ -1072,21 +1101,25 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, // to the left of the inserted text (used in XML import). const ::sw::mark::IMark* const pMark = ppMark->get(); const SwPosition* pEnd = &pMark->GetMarkEnd(); - pIdx = (SwIndex*)&pEnd->nContent; + SwIndex & rIdx = const_cast<SwIndex&>(pEnd->nContent); if( this == &pEnd->nNode.GetNode() && - aPos.GetIndex() == pIdx->GetIndex() ) - pIdx->Assign( &aTmpIdxReg, pIdx->GetIndex() ); + rPos.GetIndex() == rIdx.GetIndex() ) + { + rIdx.Assign( &aTmpIdxReg, rIdx.GetIndex() ); + } } } - SwIndexReg::Update( aPos, nLen, bNegativ ); - if( pCollector ) + + // base class + SwIndexReg::Update( rPos, nChangeLen, bNegative, bDelete ); + + if ( pCollector.get() ) { - USHORT nCount = pCollector->Count(); - for( USHORT i = 0; i < nCount; ++i ) + const USHORT nCount = pCollector->Count(); + for ( USHORT i = 0; i < nCount; ++i ) { - m_pSwpHints->Insert( (*pCollector)[ i ], *this, FALSE ); + m_pSwpHints->TryInsertHint( (*pCollector)[ i ], *this ); } - delete pCollector; } aTmpIdxReg.MoveTo( *this ); @@ -1252,8 +1285,8 @@ SwCharFmt* lcl_FindCharFmt( const SwCharFmts* pCharFmts, const XubString& rName return NULL; } -void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, - SwTxtAttr *pNewHt, SwDoc* pOtherDoc, SwTxtNode *pDest ) +void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr * const pHt, + SwTxtAttr *const pNewHt, SwDoc *const pOtherDoc, SwTxtNode *const pDest ) { ASSERT( nWhich == pHt->Which(), "Falsche Hint-Id" ); switch( nWhich ) @@ -1261,7 +1294,8 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, // Wenn wir es mit einem Fussnoten-Attribut zu tun haben, // muessen wir natuerlich auch den Fussnotenbereich kopieren. case RES_TXTATR_FTN : - ((SwTxtFtn*)pHt)->CopyFtn( (SwTxtFtn*)pNewHt ); + static_cast<const SwTxtFtn*>(pHt)->CopyFtn( + static_cast<SwTxtFtn*>(pNewHt)); break; // Beim Kopieren von Feldern in andere Dokumente @@ -1272,19 +1306,24 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, { const SwFmtFld& rFld = pHt->GetFld(); if( pOtherDoc ) - ((SwTxtFld*)pHt)->CopyFld( (SwTxtFld*)pNewHt ); + { + static_cast<const SwTxtFld*>(pHt)->CopyFld( + static_cast<SwTxtFld*>(pNewHt) ); + } // Tabellenformel ?? if( RES_TABLEFLD == rFld.GetFld()->GetTyp()->Which() - && ((SwTblField*)rFld.GetFld())->IsIntrnlName() ) + && static_cast<const SwTblField*>(rFld.GetFld())->IsIntrnlName()) { // wandel die interne in eine externe Formel um - const SwTableNode* pDstTblNd = ((SwTxtFld*)pHt)-> + const SwTableNode* const pDstTblNd = + static_cast<const SwTxtFld*>(pHt)-> GetTxtNode().FindTableNode(); if( pDstTblNd ) { - SwTblField* pTblFld = (SwTblField*) - pNewHt->GetFld().GetFld(); + SwTblField* const pTblFld = const_cast<SwTblField*>( + static_cast<const SwTblField*>( + pNewHt->GetFld().GetFld())); pTblFld->PtrToBoxNm( &pDstTblNd->GetTable() ); } } @@ -1294,9 +1333,11 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, case RES_TXTATR_TOXMARK : if( pOtherDoc && pDest && pDest->GetpSwpHints() && USHRT_MAX != pDest->GetpSwpHints()->GetPos( pNewHt ) ) + { // Beim Kopieren von TOXMarks(Client) in andere Dokumente // muss der Verzeichnis (Modify) ausgetauscht werden - ((SwTxtTOXMark*)pNewHt)->CopyTOXMark( pOtherDoc ); + static_cast<SwTxtTOXMark*>(pNewHt)->CopyTOXMark( pOtherDoc ); + } break; case RES_TXTATR_CHARFMT : @@ -1305,21 +1346,27 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, if( pDest && pDest->GetpSwpHints() && USHRT_MAX != pDest->GetpSwpHints()->GetPos( pNewHt ) ) { - SwCharFmt* pFmt = (SwCharFmt*)pHt->GetCharFmt().GetCharFmt(); + SwCharFmt* pFmt = + static_cast<SwCharFmt*>(pHt->GetCharFmt().GetCharFmt()); if( pFmt && pOtherDoc ) + { pFmt = pOtherDoc->CopyCharFmt( *pFmt ); - ((SwFmtCharFmt&)pNewHt->GetCharFmt()).SetCharFmt( pFmt ); + } + const_cast<SwFmtCharFmt&>( static_cast<const SwFmtCharFmt&>( + pNewHt->GetCharFmt() ) ).SetCharFmt( pFmt ); } break; case RES_TXTATR_INETFMT : + { // Wenn wir es mit benutzerdefinierten INet-Zeichenvorlagen // zu tun haben, muessen wir natuerlich auch die Formate kopieren. if( pOtherDoc && pDest && pDest->GetpSwpHints() && USHRT_MAX != pDest->GetpSwpHints()->GetPos( pNewHt ) ) { - const SwDoc* pDoc; - if( 0!=( pDoc = ((SwTxtINetFmt*)pHt)->GetTxtNode().GetDoc() ) ) + const SwDoc* const pDoc = static_cast<const SwTxtINetFmt*>(pHt) + ->GetTxtNode().GetDoc(); + if ( pDoc ) { const SwCharFmts* pCharFmts = pDoc->GetCharFmts(); const SwFmtINetFmt& rFmt = pHt->GetINetFmt(); @@ -1335,11 +1382,27 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, //JP 24.04.98: Bug 49753 - ein TextNode muss am Attribut // gesetzt sein, damit die Vorlagen erzeugt // werden koenne - if( !((SwTxtINetFmt*)pNewHt)->GetpTxtNode() ) - ((SwTxtINetFmt*)pNewHt)->ChgTxtNode( pDest ); + SwTxtINetFmt* const pINetHt = static_cast<SwTxtINetFmt*>(pNewHt); + if ( !pINetHt->GetpTxtNode() ) + { + pINetHt->ChgTxtNode( pDest ); + } //JP 22.10.97: Bug 44875 - Verbindung zum Format herstellen - ((SwTxtINetFmt*)pNewHt)->GetCharFmt(); + pINetHt->GetCharFmt(); + break; + } + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + ASSERT(pNewHt, "copying META should not fail! cannot call DoCopy"); + ASSERT(pDest && (CH_TXTATR_INWORD == + pDest->GetTxt().GetChar(*pNewHt->GetStart())), + "missing CH_TXTATR?"); + if (pNewHt) + { + SwFmtMeta & rMeta(static_cast<SwFmtMeta&>(pNewHt->GetAttr())); + rMeta.DoCopy( const_cast<SwFmtMeta&>(pHt->GetMeta()) ); + } break; } } @@ -1358,40 +1421,41 @@ void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, { if ( HasHints() ) // keine Attribute, keine Kekse { - const xub_StrLen *pEndIdx = 0; - const SwTxtAttr *pHt = 0; - SwTxtAttr *pNewHt = 0; - xub_StrLen nAttrStartIdx = 0; - USHORT nWhich; - - SwDoc* pOtherDoc = pDest->GetDoc(); - if( pOtherDoc == GetDoc() ) - pOtherDoc = 0; + SwDoc* const pOtherDoc = (pDest->GetDoc() != GetDoc()) ? + pDest->GetDoc() : 0; for ( USHORT i = 0; i < m_pSwpHints->Count(); i++ ) { - pHt = (*m_pSwpHints)[i]; - if( nTxtStartIdx < ( nAttrStartIdx = *pHt->GetStart() ) ) + SwTxtAttr *const pHt = m_pSwpHints->GetTextHint(i); + xub_StrLen const nAttrStartIdx = *pHt->GetStart(); + if ( nTxtStartIdx < nAttrStartIdx ) break; // ueber das Textende, da nLen == 0 - pEndIdx = pHt->GetEnd(); - if( pEndIdx ) + const xub_StrLen *const pEndIdx = pHt->GetEnd(); + if ( pEndIdx && !pHt->HasDummyChar() ) { if( ( *pEndIdx > nTxtStartIdx || ( *pEndIdx == nTxtStartIdx && nAttrStartIdx == nTxtStartIdx ) ) ) { - if( RES_TXTATR_REFMARK != ( nWhich = pHt->Which()) ) + USHORT const nWhich = pHt->Which(); + if ( RES_TXTATR_REFMARK != nWhich ) { - // Attribut liegt im Bereich, also kopieren - if( 0 != ( pNewHt = pDest->InsertItem( pHt->GetAttr(), - nOldPos, nOldPos ) ) ) - lcl_CopyHint( nWhich, pHt, pNewHt, pOtherDoc, pDest ); + // attribute in the area => copy + SwTxtAttr *const pNewHt = pDest->InsertItem( + pHt->GetAttr(), nOldPos, nOldPos ); + if ( pNewHt ) + { + lcl_CopyHint( nWhich, pHt, pNewHt, + pOtherDoc, pDest ); + } } else if( !pOtherDoc ? GetDoc()->IsCopyIsMove() : 0 == pOtherDoc->GetRefMark( pHt->GetRefMark().GetRefName() ) ) + { pDest->InsertItem( pHt->GetAttr(), nOldPos, nOldPos ); + } } } } @@ -1413,19 +1477,19 @@ void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, // --> OD 2008-11-18 #i96213# // introduction of new optional parameter to control, if all attributes have to be copied. -void SwTxtNode::Copy( SwTxtNode *pDest, +void SwTxtNode::CopyText( SwTxtNode *const pDest, const SwIndex &rStart, - xub_StrLen nLen, + const xub_StrLen nLen, const bool bForceCopyOfAllAttrs ) { SwIndex aIdx( pDest, pDest->m_Text.Len() ); - Copy( pDest, aIdx, rStart, nLen, bForceCopyOfAllAttrs ); + CopyText( pDest, aIdx, rStart, nLen, bForceCopyOfAllAttrs ); } // <-- // --> OD 2008-11-18 #i96213# // introduction of new optional parameter to control, if all attributes have to be copied. -void SwTxtNode::Copy( SwTxtNode *pDest, +void SwTxtNode::CopyText( SwTxtNode *const pDest, const SwIndex &rDestStart, const SwIndex &rStart, xub_StrLen nLen, @@ -1460,36 +1524,33 @@ void SwTxtNode::Copy( SwTxtNode *pDest, 0 ); aCharSet.Put( *GetpSwAttrSet() ); if( aCharSet.Count() ) + { pDest->SetAttr( aCharSet, nDestStart, nDestStart ); + } } else + { GetpSwAttrSet()->CopyToModify( *pDest ); + } } return; } // 1. Text kopieren - xub_StrLen i = pDest->m_Text.Len() - nDestStart; + const xub_StrLen oldLen = pDest->m_Text.Len(); //JP 15.02.96: Bug 25537 - Attributbehandlung am Ende fehlt! Darum // ueber die InsertMethode den Text einfuegen und nicht // selbst direkt - pDest->Insert( m_Text.Copy( nTxtStartIdx, nLen ), rDestStart, - INS_EMPTYEXPAND ); + pDest->InsertText( m_Text.Copy( nTxtStartIdx, nLen ), rDestStart, + IDocumentContentOperations::INS_EMPTYEXPAND ); // um reale Groesse Updaten ! - nLen = pDest->m_Text.Len() - nDestStart - i; + nLen = pDest->m_Text.Len() - oldLen; if ( !nLen ) // string not longer? return; - i = 0; - const xub_StrLen *pEndIdx = 0; - xub_StrLen nAttrStartIdx = 0; - const SwTxtAttr *pHt = 0; - SwTxtAttr *pNewHt = 0; - - SwDoc* pOtherDoc = pDest->GetDoc(); - if( pOtherDoc == GetDoc() ) - pOtherDoc = 0; + SwDoc* const pOtherDoc = (pDest->GetDoc() != GetDoc()) ? + pDest->GetDoc() : 0; // harte Absatz umspannende Attribute kopieren if( HasSwAttrSet() ) @@ -1510,26 +1571,27 @@ void SwTxtNode::Copy( SwTxtNode *pDest, 0 ); aCharSet.Put( *GetpSwAttrSet() ); if( aCharSet.Count() ) + { pDest->SetAttr( aCharSet, nDestStart, nDestStart + nLen ); + } } else + { GetpSwAttrSet()->CopyToModify( *pDest ); + } } - - const BOOL bUndoNodes = !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); + const bool bUndoNodes = !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); // Ende erst jetzt holen, weil beim Kopieren in sich selbst der // Start-Index und alle Attribute vorher aktualisiert werden. nTxtStartIdx = rStart.GetIndex(); - xub_StrLen nEnd = nTxtStartIdx + nLen; + const xub_StrLen nEnd = nTxtStartIdx + nLen; // 2. Attribute kopieren // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu kopierenden Bereich liegt - USHORT nWhich; - USHORT nSize = m_pSwpHints ? m_pSwpHints->Count() : 0; - xub_StrLen nAttrStt, nAttrEnd; + const USHORT nSize = m_pSwpHints ? m_pSwpHints->Count() : 0; // wird in sich selbst kopiert, dann kann beim Einfuegen ein // Attribut geloescht werden. Darum erst ins Tmp-Array kopieren und @@ -1540,13 +1602,15 @@ void SwTxtNode::Copy( SwTxtNode *pDest, SwpHts aRefMrkArr; //Achtung: kann ungueltig sein!! - while ( ( i < nSize ) && - ((nAttrStartIdx = *(*m_pSwpHints)[i]->GetStart()) < nEnd) ) + for (USHORT n = 0; ( n < nSize ); ++n) { - pHt = (*m_pSwpHints)[i]; - pNewHt = 0; - pEndIdx = pHt->GetEnd(); - nWhich = pHt->Which(); + const xub_StrLen nAttrStartIdx = *(*m_pSwpHints)[n]->GetStart(); + if (!( nAttrStartIdx < nEnd)) + break; + + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(n); + const xub_StrLen * const pEndIdx = pHt->GetEnd(); + const USHORT nWhich = pHt->Which(); // JP 26.04.94: REFMARK's werden nie kopiert. Hat das Refmark aber // keinen Bereich umspannt, so steht im Text ein 255 @@ -1561,44 +1625,52 @@ void SwTxtNode::Copy( SwTxtNode *pDest, if( pEndIdx && RES_TXTATR_REFMARK == nWhich && !bCopyRefMark ) { - ++i; continue; } + xub_StrLen nAttrStt; + xub_StrLen nAttrEnd; + if( nAttrStartIdx < nTxtStartIdx ) { - // Anfang liegt vor dem Bereich - if( pEndIdx && ( nAttrEnd = *pEndIdx ) > nTxtStartIdx ) + // start is before selection + // copy hints with end and CH_TXTATR only if dummy char is copied + if ( pEndIdx && (*pEndIdx > nTxtStartIdx) && !pHt->HasDummyChar() ) { - // Attribut mit einem Bereich - // und das Ende des Attribut liegt im Bereich + // attribute with extent and the end is in the selection nAttrStt = nDestStart; - nAttrEnd = nAttrEnd > nEnd + nAttrEnd = (*pEndIdx > nEnd) ? rDestStart.GetIndex() - : nDestStart + nAttrEnd - nTxtStartIdx; + : nDestStart + (*pEndIdx) - nTxtStartIdx; } else { - ++i; continue; } } else { - // der Anfang liegt innerhalb des Bereiches + // start is in the selection nAttrStt = nDestStart + ( nAttrStartIdx - nTxtStartIdx ); if( pEndIdx ) + { nAttrEnd = *pEndIdx > nEnd ? rDestStart.GetIndex() : nDestStart + ( *pEndIdx - nTxtStartIdx ); + } else + { nAttrEnd = nAttrStt; + } } + SwTxtAttr * pNewHt = 0; + if( pDest == this ) { // die Daten kopieren - pNewHt = MakeTxtAttr( pHt->GetAttr(), nAttrStt, nAttrEnd ); + pNewHt = MakeTxtAttr( *GetDoc(), pHt->GetAttr(), + nAttrStt, nAttrEnd ); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //JP 23.04.95: erstmal so gesondert hier behandeln. Am Besten ist es @@ -1623,38 +1695,28 @@ void SwTxtNode::Copy( SwTxtNode *pDest, else { pNewHt = pDest->InsertItem( pHt->GetAttr(), nAttrStt, - nAttrEnd, nsSetAttrMode::SETATTR_NOTXTATRCHR ); - if( pNewHt ) - lcl_CopyHint( nWhich, pHt, pNewHt, pOtherDoc, pDest ); - else if( !pEndIdx ) - { - // Attribut wurde nicht kopiert, hat seinen Inhalt mitgenommen! - // Damit der rest aber korrekt kopiert werden kann, muss das - // Zeichen wieder an der Position stehen. Darum hier ein - // "Dummy-TextAttribut" einfuegen, wird am Ende wieder entfernt! - pNewHt = pDest->InsertItem( SwFmtHardBlank( 0xB7 ), nAttrStt, 0 - /*???, INS_NOHINTEXPAND*/ ); - aRefMrkArr.C40_INSERT( SwTxtAttr, pNewHt, aRefMrkArr.Count() ); - } + nAttrEnd, nsSetAttrMode::SETATTR_NOTXTATRCHR ); + lcl_CopyHint( nWhich, pHt, pNewHt, pOtherDoc, pDest ); } if( RES_TXTATR_REFMARK == nWhich && !pEndIdx && !bCopyRefMark ) { aRefMrkArr.C40_INSERT( SwTxtAttr, pNewHt, aRefMrkArr.Count() ); } - - ++i; } // nur falls im Array Attribute stehen (kann nur beim Kopieren // sich selbst passieren!!) - for( i = 0; i < aArr.Count(); ++i ) - Insert( aArr[ i ], nsSetAttrMode::SETATTR_NOTXTATRCHR ); + for ( USHORT i = 0; i < aArr.Count(); ++i ) + { + InsertHint( aArr[ i ], nsSetAttrMode::SETATTR_NOTXTATRCHR ); + } if( pDest->GetpSwpHints() ) - for( i = 0; i < aRefMrkArr.Count(); ++i ) + { + for ( USHORT i = 0; i < aRefMrkArr.Count(); ++i ) { - pNewHt = aRefMrkArr[i]; + SwTxtAttr * const pNewHt = aRefMrkArr[i]; if( pNewHt->GetEnd() ) { pDest->GetpSwpHints()->Delete( pNewHt ); @@ -1663,69 +1725,77 @@ void SwTxtNode::Copy( SwTxtNode *pDest, else { const SwIndex aIdx( pDest, *pNewHt->GetStart() ); - pDest->Erase( aIdx, 1 ); + pDest->EraseText( aIdx, 1 ); } } + } CHECK_SWPHINTS(this); } -/* - * Rudimentaeres Editieren, damit die SwDoc-Insert-Methoden - * funktionieren. - */ - -SwTxtNode& SwTxtNode::Insert( const XubString &rStr, - const SwIndex &rIdx, const USHORT nMode ) +void SwTxtNode::InsertText( const XubString & rStr, const SwIndex & rIdx, + const IDocumentContentOperations::InsertFlags nMode ) { - ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::Insert: invalid index." ); + ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::InsertText: invalid index." ); ASSERT( (ULONG)m_Text.Len() + (ULONG)rStr.Len() <= STRING_LEN, - "SwTxtNode::Insert: node text with insertion > STRING_LEN." ); + "SwTxtNode::InsertText: node text with insertion > STRING_LEN." ); xub_StrLen aPos = rIdx.GetIndex(); xub_StrLen nLen = m_Text.Len() - aPos; m_Text.Insert( rStr, aPos ); nLen = m_Text.Len() - aPos - nLen; - if( !nLen ) - return *this; - Update( rIdx, nLen ); // um reale Groesse Updaten ! + + if ( !nLen ) return; + + BOOL bOldExpFlg = IsIgnoreDontExpand(); + if (nMode & IDocumentContentOperations::INS_FORCEHINTEXPAND) + { + SetIgnoreDontExpand( TRUE ); + } + + Update( rIdx, nLen ); // text content changed! + + if (nMode & IDocumentContentOperations::INS_FORCEHINTEXPAND) + { + SetIgnoreDontExpand( bOldExpFlg ); + } // analog zu Insert(char) in txtedt.cxx: // 1) bei bHintExp leere Hints an rIdx.GetIndex suchen und aufspannen // 2) bei bHintExp == FALSE mitgezogene Feldattribute zuruecksetzen - USHORT i; - if ( HasHints() ) { - for ( i = 0; i < m_pSwpHints->Count() && + for ( USHORT i = 0; i < m_pSwpHints->Count() && rIdx >= *(*m_pSwpHints)[i]->GetStart(); ++i ) { - SwTxtAttr *pHt = m_pSwpHints->GetTextHint( i ); - xub_StrLen* pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint( i ); + xub_StrLen * const pEndIdx = pHt->GetEnd(); if( !pEndIdx ) continue; if( rIdx == *pEndIdx ) { - if( nMode & INS_NOHINTEXPAND || pHt->DontExpand() ) + if ( (nMode & IDocumentContentOperations::INS_NOHINTEXPAND) || + (!(nMode & IDocumentContentOperations::INS_FORCEHINTEXPAND) + && pHt->DontExpand()) ) { // bei leeren Attributen auch Start veraendern if( rIdx == *pHt->GetStart() ) *pHt->GetStart() = *pHt->GetStart() - nLen; *pEndIdx = *pEndIdx - nLen; m_pSwpHints->DeleteAtPos(i); - Insert( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); + InsertHint( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); } - // leere Hints an rIdx.GetIndex ? - else if( nMode & INS_EMPTYEXPAND && - *pEndIdx == *pHt->GetStart() ) + // empty hints at insert position? + else if ( (nMode & IDocumentContentOperations::INS_EMPTYEXPAND) + && (*pEndIdx == *pHt->GetStart()) ) { *pHt->GetStart() = *pHt->GetStart() - nLen; const USHORT nAktLen = m_pSwpHints->Count(); m_pSwpHints->DeleteAtPos(i); - Insert( pHt/* AUTOSTYLES:, nsSetAttrMode::SETATTR_NOHINTADJUST*/ ); + InsertHint( pHt/* AUTOSTYLES:, nsSetAttrMode::SETATTR_NOHINTADJUST*/ ); if ( nAktLen > m_pSwpHints->Count() && i ) { --i; @@ -1737,14 +1807,14 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, continue; } } - if ( !(nMode & INS_NOHINTEXPAND) && + if ( !(nMode & IDocumentContentOperations::INS_NOHINTEXPAND) && rIdx == nLen && *pHt->GetStart() == rIdx.GetIndex() && !pHt->IsDontExpandStartAttr() ) { // Kein Feld, am Absatzanfang, HintExpand m_pSwpHints->DeleteAtPos(i); *pHt->GetStart() = *pHt->GetStart() - nLen; - Insert( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); + InsertHint( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); } } TryDeleteSwpHints(); @@ -1761,7 +1831,6 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, SetCalcHiddenCharFlags(); CHECK_SWPHINTS(this); - return *this; } /************************************************************************* @@ -1774,32 +1843,41 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, |* *************************************************************************/ -void SwTxtNode::Cut( SwTxtNode *pDest, const SwIndex &rStart, xub_StrLen nLen ) +void SwTxtNode::CutText( SwTxtNode * const pDest, + const SwIndex & rStart, const xub_StrLen nLen ) { if(pDest) { SwIndex aDestStt( pDest, pDest->GetTxt().Len() ); - _Cut( pDest, aDestStt, rStart, nLen, FALSE ); + CutImpl( pDest, aDestStt, rStart, nLen, false ); } else - Erase( rStart, nLen ); + { + ASSERT(false, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); + EraseText( rStart, nLen ); + } } -void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, - const SwIndex &rStart, xub_StrLen nLen, BOOL bUpdate ) +void SwTxtNode::CutImpl( SwTxtNode * const pDest, const SwIndex & rDestStart, + const SwIndex & rStart, /*const*/ xub_StrLen nLen, const bool bUpdate ) { if(!pDest) { - Erase( rStart, nLen ); + ASSERT(false, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); + EraseText( rStart, nLen ); return; } // nicht im Dokument verschieben ? if( GetDoc() != pDest->GetDoc() ) { - Copy( pDest, rDestStart, rStart, nLen); - Erase(rStart,nLen); + ASSERT(false, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); + CopyText( pDest, rDestStart, rStart, nLen); + EraseText(rStart, nLen); return; } @@ -1813,48 +1891,46 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, xub_StrLen nTxtStartIdx = rStart.GetIndex(); xub_StrLen nDestStart = rDestStart.GetIndex(); // alte Pos merken - xub_StrLen nInitSize = pDest->m_Text.Len(); - - xub_StrLen *pEndIdx = 0; - xub_StrLen nAttrStartIdx = 0; - SwTxtAttr *pHt = 0; - SwTxtAttr *pNewHt = 0; + const xub_StrLen nInitSize = pDest->m_Text.Len(); // wird in sich selbst verschoben, muss es gesondert behandelt werden !! if( pDest == this ) { + ASSERT(false, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); m_Text.Insert( m_Text, nTxtStartIdx, nLen, nDestStart ); m_Text.Erase( nTxtStartIdx + (nDestStart<nTxtStartIdx ? nLen : 0), nLen ); - xub_StrLen nEnd = rStart.GetIndex() + nLen; - USHORT n; + const xub_StrLen nEnd = rStart.GetIndex() + nLen; // dann suche mal alle Attribute zusammen, die im verschobenen // Bereich liegen. Diese werden in das extra Array verschoben, // damit sich die Indizies beim Updaten nicht veraendern !!! - SwIndexReg aTmpRegArr; SwpHts aArr( 5 ); // 2. Attribute verschieben // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu verschiebenden Bereich liegt - USHORT nAttrCnt = 0, nWhich; - while ( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() && - (nAttrStartIdx = *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))-> - GetStart()) < nEnd ) + USHORT nAttrCnt = 0; + while ( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() ) { - pNewHt = 0; - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(nAttrCnt); + const xub_StrLen nAttrStartIdx = *pHt->GetStart(); + if (!( nAttrStartIdx < nEnd )) + break; + const xub_StrLen * const pEndIdx = pHt->GetEnd(); + const USHORT nWhich = pHt->Which(); + SwTxtAttr *pNewHt = 0; if(nAttrStartIdx < nTxtStartIdx) { // Anfang liegt vor dem Bereich - if( RES_TXTATR_REFMARK != ( nWhich = pHt->Which() ) && + if ( RES_TXTATR_REFMARK != nWhich && !pHt->HasDummyChar() && pEndIdx && *pEndIdx > nTxtStartIdx ) { // Attribut mit einem Bereich // und das Ende des Attribut liegt im Bereich - pNewHt = MakeTxtAttr( pHt->GetAttr(), 0, + pNewHt = MakeTxtAttr( *GetDoc(), pHt->GetAttr(), 0, *pEndIdx > nEnd ? nLen : *pEndIdx - nTxtStartIdx ); @@ -1875,9 +1951,9 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, continue; // while-Schleife weiter, ohne ++ ! } // das Ende liegt dahinter - else if( RES_TXTATR_REFMARK != ( nWhich = pHt->Which() )) + else if (RES_TXTATR_REFMARK != nWhich && !pHt->HasDummyChar()) { - pNewHt = MakeTxtAttr( pHt->GetAttr(), + pNewHt = MakeTxtAttr( *GetDoc(), pHt->GetAttr(), nAttrStartIdx - nTxtStartIdx, !pEndIdx ? 0 : ( *pEndIdx > nEnd @@ -1895,8 +1971,10 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, } if( bUpdate ) + { // Update aller Indizies Update( rDestStart, nLen, FALSE, TRUE ); + } #ifdef CUTNOEXPAND else // wird am Ende eingefuegt, nur die Attribut-Indizies verschieben @@ -1904,10 +1982,10 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, { // check if there was the end of an attribute at the insertion // position: if it is not a field, it must be expanded - for ( n = 0; n < m_pSwpHints->Count(); n++ ) + for ( USHORT n = 0; n < m_pSwpHints->Count(); n++ ) { - pHt = m_pSwpHints->GetTextHint(n); - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(n); + const xub_StrLen * const pEndIdx = pHt->GetEnd(); if ( pEndIdx && (*pEndIdx == nInitSize) ) { *pEndIdx = *pEndIdx + nLen; @@ -1923,33 +2001,39 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, // dann setze die kopierten/geloeschten Attribute in den Node if( nDestStart <= nTxtStartIdx ) + { nTxtStartIdx = nTxtStartIdx + nLen; + } else + { nDestStart = nDestStart - nLen; + } - for( n = 0; n < aArr.Count(); ++n ) + for ( USHORT n = 0; n < aArr.Count(); ++n ) { - pNewHt = aArr[n]; + SwTxtAttr *const pNewHt = aArr[n]; *pNewHt->GetStart() = nDestStart + *pNewHt->GetStart(); - if( 0 != ( pEndIdx = pNewHt->GetEnd() )) + xub_StrLen * const pEndIdx = pNewHt->GetEnd(); + if ( pEndIdx ) + { *pEndIdx = nDestStart + *pEndIdx; - Insert( pNewHt, nsSetAttrMode::SETATTR_NOTXTATRCHR ); + } + InsertHint( pNewHt, nsSetAttrMode::SETATTR_NOTXTATRCHR ); } } else { - xub_StrLen i = nInitSize - nDestStart; pDest->m_Text.Insert( m_Text, nTxtStartIdx, nLen, nDestStart ); m_Text.Erase( nTxtStartIdx, nLen ); - nLen = pDest->m_Text.Len() - nDestStart - i; // update w/ current size! + nLen = pDest->m_Text.Len() - nInitSize; // update w/ current size! if( !nLen ) // String nicht gewachsen ?? return; - i = 0; - if( bUpdate ) + { // Update aller Indizies pDest->Update( rDestStart, nLen, FALSE, TRUE); + } #ifdef CUTNOEXPAND else // wird am Ende eingefuegt, nur die Attribut-Indizies verschieben @@ -1959,8 +2043,8 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, // position: if it is not a field, it must be expanded for ( USHORT n = 0; n < pDest->m_pSwpHints->Count(); n++ ) { - pHt = pDest->m_pSwpHints->GetTextHint(n); - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = pDest->m_pSwpHints->GetTextHint(n); + const xub_StrLen * const pEndIdx = pHt->GetEnd(); if ( pEndIdx && (*pEndIdx == nInitSize) ) { *pEndIdx = *pEndIdx + nLen; @@ -1970,11 +2054,14 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, #endif CHECK_SWPHINTS(pDest); - USHORT nEnd = rStart.GetIndex() + nLen; - SwDoc* pOtherDoc = pDest->GetDoc(); - if( pOtherDoc == GetDoc() ) - pOtherDoc = 0; - const BOOL bUndoNodes = !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); + const xub_StrLen nEnd = rStart.GetIndex() + nLen; + SwDoc* const pOtherDoc = (pDest->GetDoc() != GetDoc()) + ? pDest->GetDoc() : 0; + const bool bUndoNodes = + !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); + + ASSERT(!pOtherDoc, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); // harte Absatz umspannende Attribute kopieren if( HasSwAttrSet() ) @@ -1994,30 +2081,37 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, pDest->SetAttr( aCharSet, nDestStart, nDestStart + nLen ); } else + { GetpSwAttrSet()->CopyToModify( *pDest ); + } } // 2. Attribute verschieben // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu verschiebenden Bereich liegt - USHORT nAttrCnt = 0, nWhich; - while ( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() && - ( (nAttrStartIdx = *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))-> - GetStart()) < nEnd ) ) + USHORT nAttrCnt = 0; + while ( m_pSwpHints && (nAttrCnt < m_pSwpHints->Count()) ) { - pNewHt = 0; - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(nAttrCnt); + const xub_StrLen nAttrStartIdx = *pHt->GetStart(); + if (!( nAttrStartIdx < nEnd )) + break; + const xub_StrLen * const pEndIdx = pHt->GetEnd(); + const USHORT nWhich = pHt->Which(); + SwTxtAttr *pNewHt = 0; + // if the hint has a dummy character, then it must not be split! if(nAttrStartIdx < nTxtStartIdx) { // Anfang liegt vor dem Bereich - if( ( RES_TXTATR_REFMARK != ( nWhich = pHt->Which() ) + if( !pHt->HasDummyChar() && ( RES_TXTATR_REFMARK != nWhich || bUndoNodes ) && pEndIdx && *pEndIdx > nTxtStartIdx ) { // Attribut mit einem Bereich // und das Ende des Attribut liegt im Bereich - pNewHt = pDest->MakeTxtAttr( pHt->GetAttr(), nDestStart, - nDestStart + ( + pNewHt = MakeTxtAttr( *pDest->GetDoc(), pHt->GetAttr(), + nDestStart, + nDestStart + ( *pEndIdx > nEnd ? nLen : *pEndIdx - nTxtStartIdx ) ); @@ -2026,33 +2120,40 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, else { // der Anfang liegt vollstaendig im Bereich - nWhich = pHt->Which(); if( !pEndIdx || *pEndIdx < nEnd || - ( !pOtherDoc && !bUndoNodes && RES_TXTATR_REFMARK - == nWhich ) ) + (!pOtherDoc && !bUndoNodes && RES_TXTATR_REFMARK == nWhich) + || pHt->HasDummyChar() ) { // do not delete note and later add it -> sidebar flickering if ( GetDoc()->GetDocShell() ) + { GetDoc()->GetDocShell()->Broadcast( SfxSimpleHint(SFX_HINT_USER04)); + } // Attribut verschieben m_pSwpHints->Delete( pHt ); // die Start/End Indicies neu setzen *pHt->GetStart() = nDestStart + (nAttrStartIdx - nTxtStartIdx); if( pEndIdx ) + { *pHt->GetEnd() = nDestStart + ( *pEndIdx > nEnd ? nLen : *pEndIdx - nTxtStartIdx ); - pDest->Insert( pHt, nsSetAttrMode::SETATTR_NOTXTATRCHR | nsSetAttrMode::SETATTR_DONTREPLACE ); + } + pDest->InsertHint( pHt, + nsSetAttrMode::SETATTR_NOTXTATRCHR + | nsSetAttrMode::SETATTR_DONTREPLACE ); if ( GetDoc()->GetDocShell() ) + { GetDoc()->GetDocShell()->Broadcast( SfxSimpleHint(SFX_HINT_USER04)); + } continue; // while-Schleife weiter, ohne ++ ! } // das Ende liegt dahinter else if( RES_TXTATR_REFMARK != nWhich || bUndoNodes ) { - pNewHt = MakeTxtAttr( pHt->GetAttr(), + pNewHt = MakeTxtAttr( *GetDoc(), pHt->GetAttr(), nDestStart + (nAttrStartIdx - nTxtStartIdx), !pEndIdx ? 0 : nDestStart + ( *pEndIdx > nEnd @@ -2062,8 +2163,13 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, } if ( pNewHt ) { - if( pDest->Insert( pNewHt, nsSetAttrMode::SETATTR_NOTXTATRCHR | nsSetAttrMode::SETATTR_DONTREPLACE )) + const bool bSuccess( pDest->InsertHint( pNewHt, + nsSetAttrMode::SETATTR_NOTXTATRCHR + | nsSetAttrMode::SETATTR_DONTREPLACE ) ); + if (bSuccess) + { lcl_CopyHint( nWhich, pHt, pNewHt, pOtherDoc, pDest ); + } } ++nAttrCnt; } @@ -2074,29 +2180,35 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, if( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() ) { SwpHts aArr( 5 ); - for ( ; nAttrCnt < m_pSwpHints->Count() && - nEnd == *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))->GetStart(); - ++nAttrCnt ) + while ( nAttrCnt < m_pSwpHints->Count() ) { - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(nAttrCnt); + if ( nEnd != *pHt->GetStart() ) + break; + const xub_StrLen * const pEndIdx = pHt->GetEnd(); if ( pEndIdx && *pEndIdx == nEnd ) { aArr.C40_INSERT( SwTxtAttr, pHt, aArr.Count() ); m_pSwpHints->Delete( pHt ); - --nAttrCnt; + } + else + { + ++nAttrCnt; } } Update( rStart, nLen, TRUE, TRUE ); - for( nAttrCnt = 0; nAttrCnt < aArr.Count(); ++nAttrCnt ) + for ( USHORT n = 0; n < aArr.Count(); ++n ) { - pHt = aArr[ nAttrCnt ]; + SwTxtAttr * const pHt = aArr[ n ]; *pHt->GetStart() = *pHt->GetEnd() = rStart.GetIndex(); - Insert( pHt ); + InsertHint( pHt ); } } else + { Update( rStart, nLen, TRUE, TRUE ); + } CHECK_SWPHINTS(this); } @@ -2111,98 +2223,112 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, } -SwTxtNode& SwTxtNode::Erase(const SwIndex &rIdx, xub_StrLen nCount, - const USHORT nMode ) +void SwTxtNode::EraseText(const SwIndex &rIdx, const xub_StrLen nCount, + const IDocumentContentOperations::InsertFlags nMode ) { - ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::Erase: invalid index." ); + ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::EraseText: invalid index." ); - const xub_StrLen nCnt = STRING_LEN == nCount - ? m_Text.Len() - rIdx.GetIndex() : nCount; - m_Text.Erase( rIdx.GetIndex(), nCnt ); + const xub_StrLen nStartIdx = rIdx.GetIndex(); + const xub_StrLen nCnt = (STRING_LEN == nCount) + ? m_Text.Len() - nStartIdx : nCount; + const xub_StrLen nEndIdx = nStartIdx + nCnt; + m_Text.Erase( nStartIdx, nCnt ); /* GCAttr(); alle leeren weggwerfen ist zu brutal. * Es duerfen nur die wegggeworfen werden, * die im Bereich liegen und nicht am Ende des Bereiches liegen */ - // check m_pSwpHints because fields and FlyFrames delete text (recursion!) for ( USHORT i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { SwTxtAttr *pHt = m_pSwpHints->GetTextHint(i); - const xub_StrLen nHtStt = *pHt->GetStart(); + const xub_StrLen nHintStart = *pHt->GetStart(); - if( nHtStt < rIdx.GetIndex() ) + if ( nHintStart < nStartIdx ) continue; - // TextFelder und FlyFrames loeschen Text (Rekursion)!! - const xub_StrLen nEndIdx = rIdx.GetIndex() + nCnt; - if( nHtStt > nEndIdx ) - // die Hints sind nach Ende sortiert, also ist Start - // vom Hint groesser als EndIdx dann Abbrechen - break; + if ( nHintStart > nEndIdx ) + break; // hints are sorted by end, so break here const xub_StrLen* pHtEndIdx = pHt->GetEnd(); const USHORT nWhich = pHt->Which(); if( !pHtEndIdx ) { + ASSERT(pHt->HasDummyChar(), + "attribute with neither end nor CH_TXTATR?"); if (isTXTATR(nWhich) && - (nHtStt >= rIdx.GetIndex()) && (nHtStt < nEndIdx)) + (nHintStart >= nStartIdx) && (nHintStart < nEndIdx)) { m_pSwpHints->DeleteAtPos(i); - // Damit im Dtor der TxtAttr ohne End die CH_TXTATR nicht - // geloescht werden... - *(pHt->GetStart()) = USHRT_MAX; DestroyAttr( pHt ); --i; } continue; } + ASSERT (!( (nHintStart < nEndIdx) && (*pHtEndIdx > nEndIdx) + && pHt->HasDummyChar() ) + // next line: deleting exactly dummy char: DeleteAttributes + || ((nHintStart == nStartIdx) && (nHintStart + 1 == nEndIdx)), + "ERROR: deleting left-overlapped attribute with CH_TXTATR"); + // Delete the hint if: // 1. The hint ends before the deletion end position or // 2. The hint ends at the deletion end position and // we are not in empty expand mode and // the hint is a [toxmark|refmark|ruby] text attribute - if( *pHtEndIdx >= nEndIdx && - !( - *pHtEndIdx == nEndIdx && - !(INS_EMPTYEXPAND & nMode) && - (nWhich == RES_TXTATR_TOXMARK || nWhich == RES_TXTATR_REFMARK || - // --> FME 2006-03-03 #i62668# Ruby text attribute has to be treated - // just like toxmark and refmarks - nWhich == RES_TXTATR_CJK_RUBY) ) + // 3. deleting exactly the dummy char of an hint with end and dummy + // char deletes the hint + if ( (*pHtEndIdx < nEndIdx) + || ( (*pHtEndIdx == nEndIdx) && + !(IDocumentContentOperations::INS_EMPTYEXPAND & nMode) && + ( (RES_TXTATR_TOXMARK == nWhich) || + (RES_TXTATR_REFMARK == nWhich) || + // --> FME 2006-03-03 #i62668# Ruby text attribute must be + // treated just like toxmark and refmarks + (RES_TXTATR_CJK_RUBY == nWhich) ) ) // <-- - ) - continue; - - m_pSwpHints->DeleteAtPos(i); - DestroyAttr( pHt ); - --i; +#if 0 + || ( (nHintStart == nStartIdx) && + (nHintStart + 1 == nEndIdx)&& +#else // generalize this to left-overlapped dummy char hints (see ASSERT) + || ( (nHintStart < nEndIdx) && +#endif + pHt->HasDummyChar() ) + ) + { + m_pSwpHints->DeleteAtPos(i); + DestroyAttr( pHt ); + --i; + } } + ASSERT(rIdx.GetIndex() == nStartIdx, "huh? start index has changed?"); + TryDeleteSwpHints(); Update( rIdx, nCnt, TRUE ); if( 1 == nCnt ) { - SwDelChr aHint( rIdx.GetIndex() ); + SwDelChr aHint( nStartIdx ); SwModify::Modify( 0, &aHint ); } else { - SwDelTxt aHint( rIdx.GetIndex(), nCnt ); + SwDelTxt aHint( nStartIdx, nCnt ); SwModify::Modify( 0, &aHint ); } + ASSERT(rIdx.GetIndex() == nStartIdx, "huh? start index has changed?"); + // By deleting a character, the hidden flags // at the TxtNode can become invalid: SetCalcHiddenCharFlags(); CHECK_SWPHINTS(this); - return *this; } /*********************************************************************** @@ -2221,9 +2347,7 @@ void SwTxtNode::GCAttr() if ( !HasHints() ) return; - const SwTxtAttr *pHt = 0; - const xub_StrLen *pEndIdx = 0; - BOOL bChanged = FALSE; + bool bChanged = false; USHORT nMin = m_Text.Len(), nMax = 0; BOOL bAll = nMin != 0; // Bei leeren Absaetzen werden nur die @@ -2231,21 +2355,23 @@ void SwTxtNode::GCAttr() for ( USHORT i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { - pHt = (*m_pSwpHints)[i]; + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(i); // wenn Ende und Start gleich sind --> loeschen - pEndIdx = pHt->GetEnd(); - if( pEndIdx && (*pEndIdx == *pHt->GetStart()) + const xub_StrLen * const pEndIdx = pHt->GetEnd(); + if (pEndIdx && !pHt->HasDummyChar() && (*pEndIdx == *pHt->GetStart()) && ( bAll || pHt->Which() == RES_TXTATR_INETFMT ) ) { - bChanged = TRUE; + bChanged = true; nMin = Min( nMin, *pHt->GetStart() ); nMax = Max( nMax, *pHt->GetEnd() ); DestroyAttr( m_pSwpHints->Cut(i) ); --i; } else - ((SwTxtAttr*)pHt)->SetDontExpand( FALSE ); + { + pHt->SetDontExpand( false ); + } } TryDeleteSwpHints(); @@ -2258,6 +2384,7 @@ void SwTxtNode::GCAttr() SwModify::Modify( 0, &aNew ); } } + // #i23726# SwNumRule* SwTxtNode::_GetNumRule(BOOL bInParent) const { @@ -2600,30 +2727,25 @@ SwCntntNode* SwTxtNode::AppendNode( const SwPosition & rPos ) /************************************************************************* * SwTxtNode::GetTxtAttr - * - * Diese Methode liefert nur Textattribute auf der Position nIdx - * zurueck, die kein EndIdx besitzen und denselben Which besitzen. - * Ueblicherweise steht an dieser Position ein CH_TXTATR. - * Bei RES_TXTATR_END entfaellt die Pruefung auf den Which-Wert. *************************************************************************/ -SwTxtAttr *SwTxtNode::GetTxtAttr( const xub_StrLen nIdx, - const USHORT nWhichHt ) const +SwTxtAttr * SwTxtNode::GetTxtAttrForCharAt( const xub_StrLen nIndex, + const RES_TXTATR nWhich ) const { if ( HasHints() ) { for ( USHORT i = 0; i < m_pSwpHints->Count(); ++i ) { - SwTxtAttr *pPos = m_pSwpHints->GetTextHint(i); - const xub_StrLen nStartPos = *pPos->GetStart(); - if( nIdx < nStartPos ) + SwTxtAttr * const pHint = m_pSwpHints->GetTextHint(i); + const xub_StrLen nStartPos = *pHint->GetStart(); + if ( nIndex < nStartPos ) + { return 0; - if( nIdx == nStartPos && !pPos->GetEnd() ) + } + if ( (nIndex == nStartPos) && pHint->HasDummyChar() ) { - if( RES_TXTATR_END == nWhichHt || nWhichHt == pPos->Which() ) - return pPos; - else - return 0; + return ( RES_TXTATR_END == nWhich || nWhich == pHint->Which() ) + ? pHint : 0; } } } @@ -2835,7 +2957,8 @@ void SwTxtNode::Replace0xFF( XubString& rTxt, xub_StrLen& rTxtStt, xub_StrLen nPos = rTxt.Search( cSrchChr ); while( STRING_NOTFOUND != nPos && nPos < nEndPos ) { - const SwTxtAttr* pAttr = GetTxtAttr( rTxtStt + nPos ); + const SwTxtAttr* const pAttr = + GetTxtAttrForCharAt( rTxtStt + nPos ); if( pAttr ) { switch( pAttr->Which() ) @@ -2853,11 +2976,6 @@ void SwTxtNode::Replace0xFF( XubString& rTxt, xub_StrLen& rTxtStt, } ++rTxtStt; break; - case RES_TXTATR_HARDBLANK: - rTxt.SetChar( nPos, ((SwTxtHardBlank*)pAttr)->GetChar() ); - ++nPos; - ++nEndPos; - break; case RES_TXTATR_FTN: rTxt.Erase( nPos, 1 ); if( bExpandFlds ) @@ -2959,7 +3077,7 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, SwScriptInfo::MaskHiddenRanges( *this, sTmpText, 0, sTmpText.Len(), cChar ); sTmpText = sTmpText.Copy( nIdx, nLen ); - rDestNd.Insert( sTmpText, aDestIdx ); + rDestNd.InsertText( sTmpText, aDestIdx ); nLen = aDestIdx.GetIndex() - nDestStt; // alle FontAttribute mit CHARSET Symbol in dem Bereich setzen @@ -2969,25 +3087,28 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, for ( USHORT i = 0; i < m_pSwpHints->Count(); i++ ) { const SwTxtAttr* pHt = (*m_pSwpHints)[i]; - xub_StrLen nAttrStartIdx; - USHORT nWhich = pHt->Which(); - if( nIdx + nLen <= ( nAttrStartIdx = *pHt->GetStart() ) ) + const xub_StrLen nAttrStartIdx = *pHt->GetStart(); + const USHORT nWhich = pHt->Which(); + if (nIdx + nLen <= nAttrStartIdx) break; // ueber das Textende - const SvxFontItem* pFont; const xub_StrLen *pEndIdx = pHt->GetEnd(); if( pEndIdx && *pEndIdx > nIdx && ( RES_CHRATR_FONT == nWhich || RES_TXTATR_CHARFMT == nWhich || - RES_TXTATR_AUTOFMT == nWhich ) && - 0 != ( pFont = static_cast<const SvxFontItem*>(CharFmt::GetItem( *pHt, RES_CHRATR_FONT )) ) && - RTL_TEXTENCODING_SYMBOL == pFont->GetCharSet() ) + RES_TXTATR_AUTOFMT == nWhich )) { - // Attribut liegt im Bereich, also kopieren - rDestNd.InsertItem( *pFont, nInsPos + nAttrStartIdx, - nInsPos + *pEndIdx ); + const SvxFontItem* const pFont = + static_cast<const SvxFontItem*>( + CharFmt::GetItem( *pHt, RES_CHRATR_FONT )); + if ( pFont && RTL_TEXTENCODING_SYMBOL == pFont->GetCharSet() ) + { + // attribute in area => copy + rDestNd.InsertItem( *const_cast<SvxFontItem*>(pFont), + nInsPos + nAttrStartIdx, nInsPos + *pEndIdx ); + } } - else if( !pEndIdx && nAttrStartIdx >= nIdx ) + else if ( pHt->HasDummyChar() && (nAttrStartIdx >= nIdx) ) { aDestIdx = nInsPos + nAttrStartIdx; switch( nWhich ) @@ -2998,20 +3119,15 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, if( aExpand.Len() ) { aDestIdx++; // dahinter einfuegen; - rDestNd.Insert( aExpand, aDestIdx ); + rDestNd.InsertText( aExpand, aDestIdx ); aDestIdx = nInsPos + nAttrStartIdx; nInsPos = nInsPos + aExpand.Len(); } - rDestNd.Erase( aDestIdx, 1 ); + rDestNd.EraseText( aDestIdx, 1 ); --nInsPos; } break; - case RES_TXTATR_HARDBLANK: - rDestNd.m_Text.SetChar( nInsPos + nAttrStartIdx, - ((SwTxtHardBlank*)pHt)->GetChar() ); - break; - case RES_TXTATR_FTN: { if ( bWithFtn ) @@ -3028,23 +3144,25 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, GetNumStr( rFtn.GetNumber() ); if( sExpand.Len() ) { - aDestIdx++; // dahinter einfuegen; - rDestNd.InsertItem( SvxEscapementItem( - SVX_ESCAPEMENT_SUPERSCRIPT ), + aDestIdx++; // insert behind + SvxEscapementItem aItem( + SVX_ESCAPEMENT_SUPERSCRIPT ); + rDestNd.InsertItem(aItem, aDestIdx.GetIndex(), aDestIdx.GetIndex() ); - rDestNd.Insert( sExpand, aDestIdx, INS_EMPTYEXPAND ); + rDestNd.InsertText( sExpand, aDestIdx, + IDocumentContentOperations::INS_EMPTYEXPAND); aDestIdx = nInsPos + nAttrStartIdx; nInsPos = nInsPos + sExpand.Len(); } } - rDestNd.Erase( aDestIdx, 1 ); + rDestNd.EraseText( aDestIdx, 1 ); --nInsPos; } break; default: - rDestNd.Erase( aDestIdx, 1 ); + rDestNd.EraseText( aDestIdx, 1 ); --nInsPos; } } @@ -3054,7 +3172,7 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, if( bWithNum ) { aDestIdx = nDestStt; - rDestNd.Insert( GetNumString(), aDestIdx ); + rDestNd.InsertText( GetNumString(), aDestIdx ); } if ( nHiddenChrs > 0 ) @@ -3068,7 +3186,7 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, while ( nIndex < rDestNd.GetTxt().Len() && cChar == rDestNd.GetTxt().GetChar( ++nIndex ) ) ; - rDestNd.Erase( aDestIdx, nIndex - aDestIdx.GetIndex() ); + rDestNd.EraseText( aDestIdx, nIndex - aDestIdx.GetIndex() ); } else ++aDestIdx; @@ -3188,55 +3306,35 @@ XubString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen, } /************************************************************************* - * SwTxtNode::GetExpandTxt + * SwTxtNode::ReplaceText *************************************************************************/ -// Felder werden expandiert: -void SwTxtNode::Replace( const SwIndex& rStart, xub_Unicode cCh ) -{ - ASSERT( rStart.GetIndex() < m_Text.Len(), - "SwTxtNode::Replace: invalid index." ); - - SwTxtAttr* pHt; - if ( ( CH_TXTATR_BREAKWORD == m_Text.GetChar( rStart.GetIndex() ) || - CH_TXTATR_INWORD == m_Text.GetChar( rStart.GetIndex() )) && - 0 != ( pHt = GetTxtAttr( rStart.GetIndex() ) )) - { - Delete( pHt ); - m_Text.Insert( cCh, rStart.GetIndex() ); - } - else - { - m_Text.SetChar( rStart.GetIndex(), cCh ); - } - - SwDelTxt aDelHint( rStart.GetIndex(), 1 ); - SwModify::Modify( 0, &aDelHint ); - - SwInsTxt aHint( rStart.GetIndex(), 1 ); - SwModify::Modify( 0, &aHint ); -} - - -void SwTxtNode::Replace( const SwIndex& rStart, xub_StrLen nLen, - const XubString& rText ) +void SwTxtNode::ReplaceText( const SwIndex& rStart, const xub_StrLen nDelLen, + const XubString& rText ) { ASSERT( rStart.GetIndex() < m_Text.Len() && - rStart.GetIndex() + nLen <= m_Text.Len(), - "ausserhalb des Strings" ); - SwTxtAttr* pHt; + rStart.GetIndex() + nDelLen <= m_Text.Len(), + "SwTxtNode::ReplaceText: index out of bounds" ); const xub_StrLen nStartPos = rStart.GetIndex(); - xub_StrLen nEnde = nStartPos + nLen; - xub_StrLen nDelLen = nLen; - for( xub_StrLen nPos = nStartPos; nPos < nEnde; ++nPos ) + xub_StrLen nEndPos = nStartPos + nDelLen; + xub_StrLen nLen = nDelLen; + for ( xub_StrLen nPos = nStartPos; nPos < nEndPos; ++nPos ) { - if ( ( CH_TXTATR_BREAKWORD == m_Text.GetChar( nPos ) || - CH_TXTATR_INWORD == m_Text.GetChar( nPos )) && - 0 != ( pHt = GetTxtAttr( nPos ) )) + if ( ( CH_TXTATR_BREAKWORD == m_Text.GetChar( nPos ) ) || + ( CH_TXTATR_INWORD == m_Text.GetChar( nPos ) ) ) { - Delete( pHt ); - --nEnde; - --nLen; + SwTxtAttr *const pHint = GetTxtAttrForCharAt( nPos ); + if (pHint) + { + ASSERT (!( pHint->GetEnd() && pHint->HasDummyChar() + && (*pHint->GetStart() < nEndPos) + && (*pHint->GetEnd() > nEndPos) ), + "ReplaceText: ERROR: " + "deleting left-overlapped attribute with CH_TXTATR"); + DeleteAttribute( pHint ); + --nEndPos; + --nLen; + } } } @@ -3251,20 +3349,21 @@ void SwTxtNode::Replace( const SwIndex& rStart, xub_StrLen nLen, ((SwIndex&)rStart)++; m_Text.Erase( rStart.GetIndex(), nLen - 1 ); - Update( rStart, nLen - 1, TRUE ); + Update( rStart, nLen - 1, true ); XubString aTmpTxt( rText ); aTmpTxt.Erase( 0, 1 ); m_Text.Insert( aTmpTxt, rStart.GetIndex() ); - Update( rStart, aTmpTxt.Len(), FALSE ); + Update( rStart, aTmpTxt.Len(), false ); } else { m_Text.Erase( nStartPos, nLen ); - Update( rStart, nLen, TRUE ); + Update( rStart, nLen, true ); m_Text.Insert( rText, nStartPos ); - Update( rStart, rText.Len(), FALSE ); + Update( rStart, rText.Len(), false ); } + SetIgnoreDontExpand( bOldExpFlg ); SwDelTxt aDelHint( nStartPos, nDelLen ); SwModify::Modify( 0, &aDelHint ); diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx index 72bcdfc5fc..15a973b122 100644 --- a/sw/source/core/txtnode/swfont.cxx +++ b/sw/source/core/txtnode/swfont.cxx @@ -445,7 +445,9 @@ SwFont::SwFont( const SwFont &rFont ) pBackColor = rFont.pBackColor ? new Color( *rFont.pBackColor ) : NULL; aUnderColor = rFont.GetUnderColor(); aOverColor = rFont.GetOverColor(); - nToxCnt = nRefCnt = 0; + nToxCnt = 0; + nRefCnt = 0; + m_nMetaCount = 0; bFntChg = rFont.bFntChg; bOrgChg = rFont.bOrgChg; bPaintBlank = rFont.bPaintBlank; @@ -461,7 +463,9 @@ SwFont::SwFont( const SwAttrSet* pAttrSet, const IDocumentSettingAccess* pIDocumentSettingAccess ) { nActual = SW_LATIN; - nToxCnt = nRefCnt = 0; + nToxCnt = 0; + nRefCnt = 0; + m_nMetaCount = 0; bPaintBlank = FALSE; bPaintWrong = FALSE; bURL = FALSE; @@ -590,7 +594,9 @@ SwFont& SwFont::operator=( const SwFont &rFont ) pBackColor = rFont.pBackColor ? new Color( *rFont.pBackColor ) : NULL; aUnderColor = rFont.GetUnderColor(); aOverColor = rFont.GetOverColor(); - nToxCnt = nRefCnt = 0; + nToxCnt = 0; + nRefCnt = 0; + m_nMetaCount = 0; bFntChg = rFont.bFntChg; bOrgChg = rFont.bOrgChg; bPaintBlank = rFont.bPaintBlank; diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 018f59ab29..179e228c27 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -65,6 +65,7 @@ #include <frmfmt.hxx> #include <ftnidx.hxx> #include <fmtruby.hxx> +#include <fmtmeta.hxx> #include <breakit.hxx> #include <doc.hxx> #include <errhdl.hxx> @@ -107,142 +108,497 @@ SwpHints::SwpHints() { } +struct TxtAttrDeleter +{ + SwAttrPool & m_rPool; + TxtAttrDeleter( SwDoc & rDoc ) : m_rPool( rDoc.GetAttrPool() ) { } + void operator() (SwTxtAttr * const pAttr) + { + SwTxtAttr::Destroy( pAttr, m_rPool ); + } +}; -// This function takes care for the following text attribute: -// RES_TXTATR_CHARFMT, RES_TXTATR_INETFMT, RES_TXTATR_AUTOFMT, and -// RES_TXTATR_CJK_RUBY. These attributes have to be handled in a -// special way (Portion building). -// 1. New attribute is RES_TXTATR_AUTOFMT or RES_TXTATR_CHARFMT: -// The new attribute will be split by any existing RES_TXTATR_AUTOFMT, -// RES_TXTATR_CHARFMT or RES_TXTATR_INETFMT. The new attribute itself will -// split any existing RES_TXTATR_AUTOFMT or RES_TXTATR_CHARFMT. -// 2. New attribute is RES_TXTATR_INETFMT: -// The new attribute will split any existing RES_TXTATR_AUTOFMT or RES_TXTATR_CHARFMT. -// The new attribute will suppress any existing RES_TXTATR_INETFMT. -// 3. New attribute is RES_TXTATR_CJK_RUBY: -// The new attribute will suppress any existing RES_TXTATR_CJK_RUBY. +struct TxtAttrContains +{ + xub_StrLen m_nPos; + TxtAttrContains( const xub_StrLen nPos ) : m_nPos( nPos ) { } + bool operator() (SwTxtAttrEnd * const pAttr) + { + return (*pAttr->GetStart() < m_nPos) && (m_nPos < *pAttr->GetEnd()); + } +}; -void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMode ) +// a: |-----| +// b: +// |---| => valid: b before a +// |-----| => valid: start == end; b before a +// |---------| => invalid: overlap (1) +// |-----------| => valid: same end; b around a +// |-----------------| => valid: b around a +// |---| => valid; same start; b within a +// |-----| => valid; same start and end; b around or within a? +// |-----------| => valid: same start: b around a +// |-| => valid: b within a +// |---| => valid: same end; b within a +// |---------| => invalid: overlap (2) +// |-----| => valid: end == start; b after a +// |---| => valid: b after a +// ===> 2 invalid overlap cases +static +bool isOverlap(const xub_StrLen nStart1, const xub_StrLen nEnd1, + const xub_StrLen nStart2, const xub_StrLen nEnd2) { - ASSERT( RES_TXTATR_CHARFMT == rNewHint.Which() || - RES_TXTATR_INETFMT == rNewHint.Which() || - RES_TXTATR_AUTOFMT == rNewHint.Which() || - RES_TXTATR_CJK_RUBY == rNewHint.Which(), - "Expecting CHARFMT or AUTOFMT or INETFMT or RUBY" ) + return + ((nStart1 > nStart2) && (nStart1 < nEnd2) && (nEnd1 > nEnd2)) // (1) + || ((nStart1 < nStart2) && (nStart2 < nEnd1) && (nEnd1 < nEnd2)); // (2) +} - const USHORT nWhich = rNewHint.Which(); +static +bool isNestedAny(const xub_StrLen nStart1, const xub_StrLen nEnd1, + const xub_StrLen nStart2, const xub_StrLen nEnd2) +{ + return (nStart1 == nStart2) // in this case ends do not matter + || ((nStart1 < nStart2) ? (nEnd1 >= nEnd2) : (nEnd1 <= nEnd2)); +} - const xub_StrLen nThisStart = *rNewHint.GetStart(); - const xub_StrLen nThisEnd = *rNewHint.GetEnd(); - const bool bNoLengthAttribute = nThisStart == nThisEnd; +static +bool isSelfNestable(const USHORT nWhich) +{ + if ((RES_TXTATR_INETFMT == nWhich) || + (RES_TXTATR_CJK_RUBY == nWhich)) + return false; + ASSERT((RES_TXTATR_META == nWhich) || + (RES_TXTATR_METAFIELD == nWhich), "???"); + return true; +} - std::vector<SwTxtAttr*> aInsDelHints; - std::vector<SwTxtAttr*>::iterator aIter; +static +bool isSplittable(const USHORT nWhich) +{ + if ((RES_TXTATR_INETFMT == nWhich) || + (RES_TXTATR_CJK_RUBY == nWhich)) + return true; + ASSERT((RES_TXTATR_META == nWhich) || + (RES_TXTATR_METAFIELD == nWhich), "???"); + return false; +} - // - // 1. Some attributes are not allowed to overlap. - // They should displace attributes of the same kind. - // This is a special case for RES_TXTATR_INETFMT and - // RES_TXTATR_CJK_RUBY. - // - if ( RES_TXTATR_INETFMT == nWhich || RES_TXTATR_CJK_RUBY == nWhich ) +enum Split_t { FAIL, SPLIT_NEW, SPLIT_OTHER }; +/** + Calculate splitting policy for overlapping hints, based on what kind of + hint is inserted, and what kind of existing hint overlaps. + */ +static Split_t +splitPolicy(const USHORT nWhichNew, const USHORT nWhichOther) +{ + if (!isSplittable(nWhichOther)) { - for ( USHORT i = 0; i < Count(); ++i ) + if (!isSplittable(nWhichNew)) + return FAIL; + else + return SPLIT_NEW; + } + else + { + if ((RES_TXTATR_INETFMT == nWhichNew) && + (RES_TXTATR_CJK_RUBY == nWhichOther)) + return SPLIT_NEW; + else + return SPLIT_OTHER; + } +} + +static void +lcl_InitINetFmt(SwTxtNode & rNode, SwTxtINetFmt * pNew) +{ + pNew->ChgTxtNode(&rNode); + SwCharFmt * const pFmt( + rNode.GetDoc()->GetCharFmtFromPool(RES_POOLCHR_INET_NORMAL) ); + pFmt->Add( pNew ); +} + +static void +lcl_InitRuby(SwTxtNode & rNode, SwTxtRuby * pNew) +{ + pNew->ChgTxtNode(&rNode); + SwCharFmt * const pFmt( + rNode.GetDoc()->GetCharFmtFromPool(RES_POOLCHR_RUBYTEXT) ); + pFmt->Add( pNew ); +} + +/** + Create a new nesting text hint. + */ +static SwTxtAttrNesting * +MakeTxtAttrNesting(SwTxtNode & rNode, SwTxtAttrNesting & rNesting, + const xub_StrLen nStart, const xub_StrLen nEnd) +{ + SwTxtAttr * const pNew( MakeTxtAttr( + *rNode.GetDoc(), rNesting.GetAttr(), nStart, nEnd ) ); + switch (pNew->Which()) + { + case RES_TXTATR_INETFMT: { - SwTxtAttr* pOther = GetTextHint(i); + lcl_InitINetFmt(rNode, static_cast<SwTxtINetFmt*>(pNew)); + break; + } + case RES_TXTATR_CJK_RUBY: + { + lcl_InitRuby(rNode, static_cast<SwTxtRuby*>(pNew)); + break; + } + default: + ASSERT(false, "MakeTxtAttrNesting: what the hell is that?"); + break; + } + return static_cast<SwTxtAttrNesting*>(pNew); +} - if ( nWhich == pOther->Which() ) - { - xub_StrLen nOtherStart = *pOther->GetStart(); - const xub_StrLen nOtherEnd = *pOther->GetEnd(); +typedef ::std::vector<SwTxtAttrNesting *> NestList_t; - // Check if start of new attribute overlaps with pOther. - // Split pOther if necessary: - if ( nOtherStart < nThisStart && nThisStart < nOtherEnd ) - { - SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), nOtherStart, nThisStart ); - aInsDelHints.push_back( pNewAttr ); +static void +lcl_DoSplitNew(NestList_t & rSplits, SwTxtNode & rNode, + const xub_StrLen nNewStart, + const xub_StrLen nOtherStart, const xub_StrLen nOtherEnd, bool bOtherDummy) +{ + const bool bSplitAtStart(nNewStart < nOtherStart); + const xub_StrLen nSplitPos( (bSplitAtStart) ? nOtherStart : nOtherEnd ); + // first find the portion that is split (not necessarily the last one!) + NestList_t::iterator const iter( + ::std::find_if( rSplits.begin(), rSplits.end(), + TxtAttrContains(nSplitPos) ) ); + if (iter != rSplits.end()) // already split here? + { + const xub_StrLen nStartPos( // skip other's dummy character! + (bSplitAtStart && bOtherDummy) ? nSplitPos + 1 : nSplitPos ); + SwTxtAttrNesting * const pNew( MakeTxtAttrNesting( + rNode, **iter, nStartPos, *(*iter)->GetEnd() ) ); + *(*iter)->GetEnd() = nSplitPos; + rSplits.insert(iter + 1, pNew); + } +} - NoteInHistory( pOther ); - *pOther->GetStart() = nThisStart; - NoteInHistory( pOther, true ); - nOtherStart = nThisStart; - } +/** + Insert nesting hint into the hints array. Also calls NoteInHistory. + @param rNewHint the hint to be inserted (must not overlap existing!) + */ +void SwpHints::InsertNesting(SwTxtAttrNesting & rNewHint) +{ + SwpHintsArray::Insert(& rNewHint); + NoteInHistory( & rNewHint, true ); +} - // Check if end of new attribute overlaps with pOther: - // Split pOther if necessary: - if ( nOtherStart < nThisEnd && nThisEnd < nOtherEnd ) - { - SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), - nOtherStart, nThisEnd ); - aInsDelHints.push_back( pNewAttr ); +/** + +The following hints correspond to well-formed XML elements in ODF: +RES_TXTATR_INETFMT, RES_TXTATR_CJK_RUBY, RES_TXTATR_META, RES_TXTATR_METAFIELD + +The writer core must ensure that these do not overlap; if they did, +the document would not be storable as ODF. + +Also, a Hyperlink must not be nested within another Hyperlink, +and a Ruby must not be nested within another Ruby. + +The ODF export in xmloff will only put a hyperlink into a ruby, never a ruby +into a hyperlink. + +Unfortunately the UNO API for Hyperlink and Ruby consists of the properties +Hyperlink* and Ruby* of the css.text.CharacterProperties service. In other +words, they are treated as formatting attributes, not as content entites. +Furthermore, for API users it is not possible to easily test whether a certain +range would be overlapping with other nested attributes, and most importantly, +<em>which ones</em>, so we can hardly refuse to insert these in cases of +overlap. + +It is possible to split Hyperlink and Ruby into multiple portions, such that +the result is properly nested. + +meta and meta-field must not be split, because they have xml:id. + +These constraints result in the following design: + +RES_TXTATR_INETFMT: + always succeeds + inserts n attributes split at RES_TXTATR_CJK_RUBY, RES_TXTATR_META, + RES_TXTATR_METAFIELD + may replace existing RES_TXTATR_INETFMT at overlap +RES_TXTATR_CJK_RUBY: + always succeeds + inserts n attributes split at RES_TXTATR_META, RES_TXTATR_METAFIELD + may replace existing RES_TXTATR_CJK_RUBY at overlap + may split existing overlapping RES_TXTATR_INETFMT +RES_TXTATR_META: + may fail if overlapping existing RES_TXTATR_META/RES_TXTATR_METAFIELD + may split existing overlapping RES_TXTATR_INETFMT or RES_TXTATR_CJK_RUBY + inserts 1 attribute +RES_TXTATR_METAFIELD: + may fail if overlapping existing RES_TXTATR_META/RES_TXTATR_METAFIELD + may split existing overlapping RES_TXTATR_INETFMT or RES_TXTATR_CJK_RUBY + inserts 1 attribute + +The nesting is expressed by the position of the hints. +RES_TXTATR_META and RES_TXTATR_METAFIELD have a CH_TXTATR, and there can +only be one such hint starting and ending at a given position. +Only RES_TXTATR_INETFMT and RES_TXTATR_CJK_RUBY lack a CH_TXTATR. +The interpretation given is that RES_TXTATR_CJK_RUBY is always around +a RES_TXTATR_INETFMT at the same start and end position (which corresponds +with the UNO API). +Both of these are always around a nesting hint with CH_TXTATR at the same +start and end position (if they should be inside, then the start should be +after the CH_TXTATR). +It would probably be a bad idea to add another nesting hint without +CH_TXTATR; on the other hand, it would be difficult adding a CH_TXTATR to +RES_TXTATR_INETFMT and RES_TXTATR_CJK_RUBY, due to the overwriting and +splitting of exising hints that is necessary for backward compatibility. + + @param rNode the text node + @param rHint the hint to be inserted + @returns true iff hint was successfully inserted +*/ +bool +SwpHints::TryInsertNesting( SwTxtNode & rNode, SwTxtAttrNesting & rNewHint ) +{ +// INVARIANT: the nestable hints in the array are properly nested + const USHORT nNewWhich( rNewHint.Which() ); + const xub_StrLen nNewStart( *rNewHint.GetStart() ); + const xub_StrLen nNewEnd ( *rNewHint.GetEnd() ); +//??? const bool bNoLengthAttribute( nNewStart == nNewEnd ); + const bool bNewSelfNestable( isSelfNestable(nNewWhich) ); + + ASSERT( (RES_TXTATR_INETFMT == nNewWhich) || + (RES_TXTATR_CJK_RUBY == nNewWhich) || + (RES_TXTATR_META == nNewWhich) || + (RES_TXTATR_METAFIELD == nNewWhich), + "TryInsertNesting: Expecting INETFMT or RUBY or META or METAFIELD" ); + + NestList_t OverlappingExisting; // existing hints to be split + NestList_t OverwrittenExisting; // existing hints to be replaced + NestList_t SplitNew; // new hints to be inserted + + SplitNew.push_back(& rNewHint); + + // pass 1: split the inserted hint into fragments if necessary + for ( USHORT i = 0; i < GetEndCount(); ++i ) + { + SwTxtAttr * const pOther = GetEnd(i); - NoteInHistory( pOther ); - *pOther->GetStart() = nThisEnd; - NoteInHistory( pOther, true ); + if (pOther->IsNesting()) + { + const USHORT nOtherWhich( pOther->Which() ); + const xub_StrLen nOtherStart( *(pOther)->GetStart() ); + const xub_StrLen nOtherEnd ( *(pOther)->GetEnd() ); + if (isOverlap(nNewStart, nNewEnd, nOtherStart, nOtherEnd )) + { + switch (splitPolicy(nNewWhich, nOtherWhich)) + { + case FAIL: + OSL_TRACE("cannot insert hint: overlap detected"); + ::std::for_each(SplitNew.begin(), SplitNew.end(), + TxtAttrDeleter(*rNode.GetDoc())); + return false; + case SPLIT_NEW: + lcl_DoSplitNew(SplitNew, rNode, nNewStart, + nOtherStart, nOtherEnd, pOther->HasDummyChar()); + break; + case SPLIT_OTHER: + OverlappingExisting.push_back( + static_cast<SwTxtAttrNesting*>(pOther)); + break; + default: + ASSERT(false, "bad code monkey"); + break; + } + } + else if (isNestedAny(nNewStart, nNewEnd, nOtherStart, nOtherEnd)) + { + if (!bNewSelfNestable && (nNewWhich == nOtherWhich)) + { + // ruby and hyperlink: if there is nesting, _overwrite_ + OverwrittenExisting.push_back( + static_cast<SwTxtAttrNesting*>(pOther)); + } + else if ((nNewStart == nOtherStart) && pOther->HasDummyChar()) + { + if (rNewHint.HasDummyChar()) + { + ASSERT(false, + "ERROR: inserting duplicate CH_TXTATR hint"); + return false; + } else if (nNewEnd < nOtherEnd) { + // other has dummy char, new is inside other, but + // new contains the other's dummy char? + // should be corrected because it may lead to problems + // in SwXMeta::createEnumeration + // SplitNew is sorted, so this is the first split + xub_StrLen *const pStart(SplitNew.front()->GetStart()); + ASSERT(*pStart == nNewStart, "how did that happen?"); + *pStart = nNewStart + 1; + } } } } + } - // Insert the newly created attributes: - const sal_uInt16 nCharFmtID = static_cast<sal_uInt16>( RES_TXTATR_INETFMT == nWhich ? - RES_POOLCHR_INET_NORMAL : - RES_POOLCHR_RUBYTEXT ); - SwCharFmt* pFmt = rNode.GetDoc()->GetCharFmtFromPool( nCharFmtID ); + ASSERT (isSplittable(nNewWhich) || SplitNew.size() == 1, + "splitting the unsplittable ???"); + + // pass 2: split existing hints that overlap/nest with new hint + // do not iterate over hints array, but over remembered set of overlapping + // hints, to keep things simple w.r.t. insertion/removal + // N.B: if there is a hint that splits the inserted hint, then + // that hint would also have already split any hint in OverlappingExisting + // so any hint in OverlappingExisting can be split at most by one hint + // in SplitNew, or even not at all (this is not true for existing hints + // that go _around_ new hint, which is the raison d'^etre for pass 4) + for (NestList_t::iterator itOther = OverlappingExisting.begin(); + itOther != OverlappingExisting.end(); ++itOther) + { + const xub_StrLen nOtherStart( *(*itOther)->GetStart() ); + const xub_StrLen nOtherEnd ( *(*itOther)->GetEnd() ); - for ( aIter = aInsDelHints.begin(); aIter != aInsDelHints.end(); ++aIter ) + for (NestList_t::iterator itNew = SplitNew.begin(); + itNew != SplitNew.end(); ++itNew) { - if ( RES_TXTATR_INETFMT == nWhich ) + const xub_StrLen nSplitNewStart( *(*itNew)->GetStart() ); + const xub_StrLen nSplitNewEnd ( *(*itNew)->GetEnd() ); + // 4 cases: within, around, overlap l, overlap r, (OTHER: no action) + const bool bRemoveOverlap( + !bNewSelfNestable && (nNewWhich == (*itOther)->Which()) ); + + switch (ComparePosition(nSplitNewStart, nSplitNewEnd, + nOtherStart, nOtherEnd)) { - SwTxtINetFmt* pInetAttr = static_cast<SwTxtINetFmt*>(*aIter); - pInetAttr->ChgTxtNode( &rNode ); - pFmt->Add( pInetAttr ); - + case POS_INSIDE: + { + ASSERT(!bRemoveOverlap, + "this one should be in OverwrittenExisting?"); + } + break; + case POS_OUTSIDE: + case POS_EQUAL: + { + ASSERT(false, "existing hint inside new hint: why?"); + } + break; + case POS_OVERLAP_BEFORE: + { + Delete( *itOther ); // this also does NoteInHistory! + *(*itOther)->GetStart() = nSplitNewEnd; + InsertNesting( **itOther ); + if (!bRemoveOverlap) + { + if ( USHRT_MAX == Count() ) + { + ASSERT(false, "hints array full :-("); + return false; + } + SwTxtAttrNesting * const pOtherLeft( + MakeTxtAttrNesting( rNode, **itOther, + nOtherStart, nSplitNewEnd ) ); + InsertNesting( *pOtherLeft ); + } + } + break; + case POS_OVERLAP_BEHIND: + { + Delete( *itOther ); // this also does NoteInHistory! + *(*itOther)->GetEnd() = nSplitNewStart; + InsertNesting( **itOther ); + if (!bRemoveOverlap) + { + if ( USHRT_MAX == Count() ) + { + ASSERT(false, "hints array full :-("); + return false; + } + SwTxtAttrNesting * const pOtherRight( + MakeTxtAttrNesting( rNode, **itOther, + nSplitNewStart, nOtherEnd ) ); + InsertNesting( *pOtherRight ); + } + } + break; + default: + break; // overlap resolved by splitting new: nothing to do } + } + } - else - { - SwTxtRuby* pRubyAttr = static_cast<SwTxtRuby*>(*aIter); - pRubyAttr->ChgTxtNode( &rNode ); - pFmt->Add( pRubyAttr ); - - } + if ( USHRT_MAX - SplitNew.size() <= Count() ) + { + ASSERT(false, "hints array full :-("); + return false; + } - SwpHintsArray::Insert( *aIter ); - NoteInHistory( *aIter, true ); - } + // pass 3: insert new hints + for (NestList_t::iterator iter = SplitNew.begin(); + iter != SplitNew.end(); ++iter) + { + InsertNesting(**iter); + } - aInsDelHints.clear(); + // pass 4: handle overwritten hints + // RES_TXTATR_INETFMT and RES_TXTATR_CJK_RUBY should displace attributes + // of the same kind. + for (NestList_t::iterator itOther = OverwrittenExisting.begin(); + itOther != OverwrittenExisting.end(); ++itOther) + { + const xub_StrLen nOtherStart( *(*itOther)->GetStart() ); + const xub_StrLen nOtherEnd ( *(*itOther)->GetEnd() ); - // Now delete all attributes of the same type as the new one - // which are fully covered by the new attribute: - for ( USHORT i = 0; i < Count(); ++i ) + // overwritten portion is given by start/end of inserted hint + if ((nNewStart <= nOtherStart) && (nOtherEnd <= nNewEnd)) { - SwTxtAttr* pOther = GetTextHint(i); - if ( nWhich == pOther->Which() ) - { - const xub_StrLen nOtherStart = *pOther->GetStart(); - const xub_StrLen nOtherEnd = *pOther->GetEnd(); - - if ( nOtherStart >= nThisStart && nOtherEnd <= nThisEnd ) - aInsDelHints.push_back( pOther ); - } + Delete(*itOther); + rNode.DestroyAttr( *itOther ); } - for ( aIter = aInsDelHints.begin(); aIter != aInsDelHints.end(); ++aIter ) + else { - Delete( *aIter ); - rNode.DestroyAttr( *aIter ); + ASSERT((nOtherStart < nNewStart) && (nNewEnd < nOtherEnd), "huh?"); + // scenario: there is a RUBY, and contained within that a META; + // now a RUBY is inserted within the META => the exising RUBY is split: + // here it is not possible to simply insert the left/right fragment + // of the existing RUBY because they <em>overlap</em> with the META! + Delete( *itOther ); // this also does NoteInHistory! + *(*itOther)->GetEnd() = nNewStart; + bool bSuccess( TryInsertNesting(rNode, **itOther) ); + ASSERT(bSuccess, "recursive call 1 failed?"); + SwTxtAttrNesting * const pOtherRight( + MakeTxtAttrNesting( + rNode, **itOther, nNewEnd, nOtherEnd ) ); + bSuccess = TryInsertNesting(rNode, *pOtherRight); + ASSERT(bSuccess, "recursive call 2 failed?"); } - SwpHintsArray::Insert( &rNewHint ); - NoteInHistory( &rNewHint, true ); - - return; } + return true; +} + + +// This function takes care for the following text attribute: +// RES_TXTATR_CHARFMT, RES_TXTATR_AUTOFMT +// These attributes have to be handled in a special way (Portion building). +// +// The new attribute will be split by any existing RES_TXTATR_AUTOFMT or +// RES_TXTATR_CHARFMT. The new attribute itself will +// split any existing RES_TXTATR_AUTOFMT or RES_TXTATR_CHARFMT. + +void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, + const SetAttrMode nMode ) +{ + const USHORT nWhich = rNewHint.Which(); + + const xub_StrLen nThisStart = *rNewHint.GetStart(); + const xub_StrLen nThisEnd = *rNewHint.GetEnd(); + const bool bNoLengthAttribute = nThisStart == nThisEnd; + + std::vector<SwTxtAttr*> aInsDelHints; + std::vector<SwTxtAttr*>::iterator aIter; + ASSERT( RES_TXTATR_CHARFMT == rNewHint.Which() || RES_TXTATR_AUTOFMT == rNewHint.Which(), - "Expecting CHARFMT or AUTOFMT" ) + "Expecting CHARFMT or AUTOFMT" ); // // 2. Find the hints which cover the start and end position @@ -265,7 +621,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Split pOther if necessary: if ( nOtherStart < nThisStart && nThisStart < nOtherEnd ) { - SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), nOtherStart, nThisStart ); + SwTxtAttr* pNewAttr = MakeTxtAttr( *rNode.GetDoc(), + pOther->GetAttr(), nOtherStart, nThisStart ); if ( RES_TXTATR_CHARFMT == pOther->Which() ) static_cast<SwTxtCharFmt*>(pNewAttr)->SetSortNumber( static_cast<SwTxtCharFmt*>(pOther)->GetSortNumber() ); aInsDelHints.push_back( pNewAttr ); @@ -281,7 +638,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Split pOther if necessary: if ( nOtherStart < nThisEnd && nThisEnd < nOtherEnd ) { - SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), nOtherStart, nThisEnd ); + SwTxtAttr* pNewAttr = MakeTxtAttr( *rNode.GetDoc(), + pOther->GetAttr(), nOtherStart, nThisEnd ); if ( RES_TXTATR_CHARFMT == pOther->Which() ) static_cast<SwTxtCharFmt*>(pNewAttr)->SetSortNumber( static_cast<SwTxtCharFmt*>(pOther)->GetSortNumber() ); aInsDelHints.push_back( pNewAttr ); @@ -433,8 +791,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Create new AutoStyle if ( aNewSet.Count() ) { - pNewAttr = rNode.MakeTxtAttr( aNewSet, - nPorStart, nPorEnd ); + pNewAttr = MakeTxtAttr( *rNode.GetDoc(), + aNewSet, nPorStart, nPorEnd ); SwpHintsArray::Insert( pNewAttr ); NoteInHistory( pNewAttr, true ); } @@ -453,7 +811,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod } else { - pNewAttr = rNode.MakeTxtAttr( rNewHint.GetAttr(), nPorStart, nPorEnd ); + pNewAttr = MakeTxtAttr( *rNode.GetDoc(), rNewHint.GetAttr(), + nPorStart, nPorEnd ); static_cast<SwTxtCharFmt*>(pNewAttr)->SetSortNumber( nCharStyleCount ); } } @@ -510,7 +869,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Create new AutoStyle if ( aNewSet.Count() ) - pNewAttr = rNode.MakeTxtAttr( aNewSet, nPorStart, nPorEnd ); + pNewAttr = MakeTxtAttr( *rNode.GetDoc(), aNewSet, + nPorStart, nPorEnd ); } else { @@ -568,7 +928,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod } else if ( pNewStyle.get() ) { - pNewAttr = rNode.MakeTxtAttr( *pNewStyle, nPorStart, nPorEnd ); + pNewAttr = MakeTxtAttr( *rNode.GetDoc(), *pNewStyle, + nPorStart, nPorEnd ); } } } @@ -597,35 +958,66 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod * SwTxtNode::MakeTxtAttr() *************************************************************************/ -// create new text attribute -SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnd, bool bRedlineAttr ) +SwTxtAttr* MakeRedlineTxtAttr( SwDoc & rDoc, SfxPoolItem & rAttr ) { - SwDoc* pDoc = GetDoc(); + // this is intended _only_ for special-purpose redline attributes! + switch (rAttr.Which()) + { + case RES_CHRATR_COLOR: + case RES_CHRATR_WEIGHT: + case RES_CHRATR_CJK_WEIGHT: + case RES_CHRATR_CTL_WEIGHT: + case RES_CHRATR_POSTURE: + case RES_CHRATR_CJK_POSTURE: + case RES_CHRATR_CTL_POSTURE: + case RES_CHRATR_UNDERLINE: + case RES_CHRATR_CROSSEDOUT: + case RES_CHRATR_CASEMAP: + case RES_CHRATR_BACKGROUND: + break; + default: + ASSERT(false, "unsupported redline attribute"); + break; + } + + // Put new attribute into pool + // FIXME: this const_cast is evil! + SfxPoolItem& rNew = + const_cast<SfxPoolItem&>( rDoc.GetAttrPool().Put( rAttr ) ); + return new SwTxtAttrEnd( rNew, 0, 0 ); +} - if ( !bRedlineAttr && isCHRATR(rAttr.Which()) ) +// create new text attribute +SwTxtAttr* MakeTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr, + xub_StrLen nStt, xub_StrLen nEnd ) +{ + if ( isCHRATR(rAttr.Which()) ) { - // Somebody wants to build a SwTxtAttr for a character attribute (and - // this attribute is not meant for redlining). Sorry, this is not allowed - // any longer. You'll get a brand new autostyle attribute: - SfxItemSet aItemSet( pDoc->GetAttrPool(), RES_CHRATR_BEGIN, RES_CHRATR_END ); + // Somebody wants to build a SwTxtAttr for a character attribute. + // Sorry, this is not allowed any longer. + // You'll get a brand new autostyle attribute: + SfxItemSet aItemSet( rDoc.GetAttrPool(), + RES_CHRATR_BEGIN, RES_CHRATR_END ); aItemSet.Put( rAttr ); - return MakeTxtAttr( aItemSet, nStt, nEnd ); + return MakeTxtAttr( rDoc, aItemSet, nStt, nEnd ); } else if ( RES_TXTATR_AUTOFMT == rAttr.Which() && - static_cast<const SwFmtAutoFmt&>(rAttr).GetStyleHandle()->GetPool() != &pDoc->GetAttrPool() ) + static_cast<const SwFmtAutoFmt&>(rAttr).GetStyleHandle()-> + GetPool() != &rDoc.GetAttrPool() ) { - // If the attribut is an autostyle which referes to a pool that is different from - // pDoc's pool, we have to correct this: + // If the attribute is an auto-style which refers to a pool that is + // different from rDoc's pool, we have to correct this: const StylePool::SfxItemSet_Pointer_t pAutoStyle = static_cast<const SwFmtAutoFmt&>(rAttr).GetStyleHandle(); - const SfxItemSet* pNewSet = pAutoStyle->SfxItemSet::Clone( TRUE, &pDoc->GetAttrPool() ); - SwTxtAttr* pNew = MakeTxtAttr( *pNewSet, nStt, nEnd ); - delete pNewSet; + ::std::auto_ptr<const SfxItemSet> pNewSet( + pAutoStyle->SfxItemSet::Clone( TRUE, &rDoc.GetAttrPool() )); + SwTxtAttr* pNew = MakeTxtAttr( rDoc, *pNewSet, nStt, nEnd ); return pNew; } - // Put new attribute into pool unless we are asked to build a redline attribute - const SfxPoolItem& rNew = !bRedlineAttr ? GetDoc()->GetAttrPool().Put( rAttr ) : rAttr; + // Put new attribute into pool + // FIXME: this const_cast is evil! + SfxPoolItem& rNew = + const_cast<SfxPoolItem&>( rDoc.GetAttrPool().Put( rAttr ) ); SwTxtAttr* pNew = 0; switch( rNew.Which() ) @@ -634,7 +1026,9 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, { SwFmtCharFmt &rFmtCharFmt = (SwFmtCharFmt&) rNew; if( !rFmtCharFmt.GetCharFmt() ) - rFmtCharFmt.SetCharFmt( GetDoc()->GetDfltCharFmt() ); + { + rFmtCharFmt.SetCharFmt( rDoc.GetDfltCharFmt() ); + } pNew = new SwTxtCharFmt( rFmtCharFmt, nStt, nEnd ); } @@ -650,9 +1044,11 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, // erst hier wird das Frame-Format kopiert (mit Inhalt) !! pNew = new SwTxtFlyCnt( (SwFmtFlyCnt&)rNew, nStt ); // Kopie von einem Text-Attribut - if( ((SwFmtFlyCnt&)rAttr).GetTxtFlyCnt() ) - // dann muss das Format Kopiert werden - ((SwTxtFlyCnt*)pNew)->CopyFlyFmt( GetDoc() ); + if ( static_cast<const SwFmtFlyCnt &>(rAttr).GetTxtFlyCnt() ) + { + // then the format must be copied + static_cast<SwTxtFlyCnt *>(pNew)->CopyFlyFmt( &rDoc ); + } } break; case RES_TXTATR_FTN: @@ -661,12 +1057,6 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, if( ((SwFmtFtn&)rAttr).GetTxtFtn() ) ((SwTxtFtn*)pNew)->SetSeqNo( ((SwFmtFtn&)rAttr).GetTxtFtn()->GetSeqRefNo() ); break; - case RES_TXTATR_HARDBLANK: - pNew = new SwTxtHardBlank( (SwFmtHardBlank&)rNew, nStt ); - break; - case RES_CHRATR_TWO_LINES: - pNew = new SwTxt2Lines( (SvxTwoLinesItem&)rNew, nStt, nEnd ); - break; case RES_TXTATR_REFMARK: pNew = nStt == nEnd ? new SwTxtRefMark( (SwFmtRefMark&)rNew, nStt ) @@ -683,7 +1073,12 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, case RES_TXTATR_CJK_RUBY: pNew = new SwTxtRuby( (SwFmtRuby&)rNew, nStt, nEnd ); break; + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + pNew = new SwTxtMeta( static_cast<SwFmtMeta&>(rNew), nStt, nEnd ); + break; default: + ASSERT(RES_TXTATR_AUTOFMT == rNew.Which(), "unknown attribute"); pNew = new SwTxtAttrEnd( rNew, nStt, nEnd ); break; } @@ -691,13 +1086,14 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, return pNew; } -SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd ) +SwTxtAttr* MakeTxtAttr( SwDoc & rDoc, const SfxItemSet& rSet, + xub_StrLen nStt, xub_StrLen nEnd ) { - IStyleAccess& rStyleAccess = getIDocumentStyleAccess(); + IStyleAccess& rStyleAccess = rDoc.GetIStyleAccess(); const StylePool::SfxItemSet_Pointer_t pAutoStyle = rStyleAccess.getAutomaticStyle( rSet, IStyleAccess::AUTO_STYLE_CHAR ); SwFmtAutoFmt aNewAutoFmt; aNewAutoFmt.SetStyleHandle( pAutoStyle ); - SwTxtAttr* pNew = MakeTxtAttr( aNewAutoFmt, nStt, nEnd ); + SwTxtAttr* pNew = MakeTxtAttr( rDoc, aNewAutoFmt, nStt, nEnd ); return pNew; } @@ -781,6 +1177,14 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) case RES_TXTATR_REFMARK: nDelMsg = RES_REFMARK_DELETED; break; + + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + static_cast<SwFmtMeta&>(pAttr->GetAttr()).NotifyRemoval(); + break; + + default: + break; } if( nDelMsg && !pDoc->IsInDtor() && GetNodes().IsDocNodes() ) @@ -789,8 +1193,7 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) pDoc->GetUnoCallBack()->Modify( &aMsgHint, &aMsgHint ); } - pAttr->RemoveFromPool( pDoc->GetAttrPool() ); - delete pAttr; + SwTxtAttr::Destroy( pAttr, pDoc->GetAttrPool() ); } } @@ -798,30 +1201,52 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) * SwTxtNode::Insert() *************************************************************************/ -// lege ein neues TextAttribut an und fuege es ins SwpHints-Array ein -SwTxtAttr* SwTxtNode::InsertItem( const SfxPoolItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnd, USHORT nMode ) +SwTxtAttr* +SwTxtNode::InsertItem( SfxPoolItem& rAttr, + const xub_StrLen nStart, const xub_StrLen nEnd, const SetAttrMode nMode ) { // character attributes will be inserted as automatic styles: ASSERT( !isCHRATR(rAttr.Which()), "AUTOSTYLES - " "SwTxtNode::InsertItem should not be called with character attributes"); - SwTxtAttr* pNew = MakeTxtAttr( rAttr, nStt, nEnd ); + SwTxtAttr* const pNew = MakeTxtAttr( *GetDoc(), rAttr, nStart, nEnd ); if ( pNew ) - Insert( pNew, nMode ); + { + const bool bSuccess( InsertHint( pNew, nMode ) ); + // N.B.: also check that the hint is actually in the hints array, + // because hints of certain types may be merged after succesful + // insertion, and thus destroyed! + if (!bSuccess || ( USHRT_MAX == m_pSwpHints->GetPos( pNew ) )) + { + return 0; + } + } return pNew; } -// uebernehme den Pointer auf das Text-Attribut -BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) +// take ownership of pAttr; if insertion fails, delete pAttr +bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) { BOOL bHiddenPara = FALSE; - ASSERT( pAttr && *pAttr->GetStart() <= Len(), "StartIdx hinter Len!" ); - - if( !pAttr->GetEnd() ) + ASSERT( pAttr && *pAttr->GetStart() <= Len(), "StartIdx out of bounds!" ); + ASSERT( !pAttr->GetEnd() || (*pAttr->GetEnd() <= Len()), + "EndIdx out of bounds!" ); + + // translate from SetAttrMode to InsertMode (for hints with CH_TXTATR) + const enum IDocumentContentOperations::InsertFlags nInsertFlags = + (nMode & nsSetAttrMode::SETATTR_FORCEHINTEXPAND) + ? static_cast<IDocumentContentOperations::InsertFlags>( + IDocumentContentOperations::INS_FORCEHINTEXPAND | + IDocumentContentOperations::INS_EMPTYEXPAND) + : IDocumentContentOperations::INS_EMPTYEXPAND; + + // need this after TryInsertHint, when pAttr may be deleted + const xub_StrLen nStart( *pAttr->GetStart() ); + const bool bDummyChar( pAttr->HasDummyChar() ); + if (bDummyChar) { USHORT nInsMode = nMode; switch( pAttr->Which() ) @@ -843,7 +1268,8 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) (const SfxPoolItem**)&pAnchor ); SwIndex aIdx( this, *pAttr->GetStart() ); - Insert( GetCharOfTxtAttr(*pAttr), aIdx ); + const sal_Unicode c = GetCharOfTxtAttr(*pAttr); + InsertText( c, aIdx, nInsertFlags ); nInsMode |= nsSetAttrMode::SETATTR_NOTXTATRCHR; if( pAnchor && FLY_IN_CNTNT == pAnchor->GetAnchorId() && @@ -892,7 +1318,7 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) pDoc->DoUndo( FALSE ); DestroyAttr( pAttr ); pDoc->DoUndo( bUndo ); - return FALSE; + return false; } } break; @@ -926,7 +1352,7 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) Update( aTmpIdx, 1, TRUE ); } DestroyAttr( pAttr ); - return FALSE; + return false; } // wird eine neue Fussnote eingefuegt ?? @@ -957,7 +1383,8 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) // entstehen koennen und das Attribut im _SortArr_ am // Dokument nicht eingetrage wird. SwIndex aNdIdx( this, *pAttr->GetStart() ); - Insert( GetCharOfTxtAttr(*pAttr), aNdIdx ); + const sal_Unicode c = GetCharOfTxtAttr(*pAttr); + InsertText( c, aNdIdx, nInsertFlags ); nInsMode |= nsSetAttrMode::SETATTR_NOTXTATRCHR; } @@ -1020,92 +1447,105 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) if( !(nsSetAttrMode::SETATTR_NOTXTATRCHR & nInsMode) ) { SwIndex aIdx( this, *pAttr->GetStart() ); - Insert( GetCharOfTxtAttr(*pAttr), aIdx ); + InsertText( GetCharOfTxtAttr(*pAttr), aIdx, nInsertFlags ); + + // adjust end of hint to account for inserted CH_TXTATR + xub_StrLen * const pEnd(pAttr->GetEnd()); + if (pEnd) + { + *pEnd = *pEnd + 1; + } } } - else { - ASSERT( *pAttr->GetEnd() <= Len(), "EndIdx hinter Len!" ); - } GetOrCreateSwpHints(); // 4263: AttrInsert durch TextInsert => kein Adjust - m_pSwpHints->Insert( pAttr, *this, nMode ); + const bool bRet = m_pSwpHints->TryInsertHint( pAttr, *this, nMode ); - // 47375: In pSwpHints->Insert wird u.a. Merge gerufen und das Hints-Array - // von ueberfluessigen Hints befreit, dies kann u.U. sogar der frisch - // eingefuegte Hint pAttr sein, der dann zerstoert wird!! - if ( USHRT_MAX == m_pSwpHints->GetPos( pAttr ) ) + if (!bRet && bDummyChar) { - return FALSE; + // undo insertion of dummy character + // N.B. cannot insert the dummy character after inserting the hint, + // because if the hint has no extent it will be moved in InsertText, + // resulting in infinite recursion + if ( !(nsSetAttrMode::SETATTR_NOTXTATRCHR & nMode) ) + { + ASSERT( ( CH_TXTATR_BREAKWORD == m_Text.GetChar(nStart) || + CH_TXTATR_INWORD == m_Text.GetChar(nStart) ), + "where is my attribute character?" ); + SwIndex aIdx( this, nStart ); + EraseText( aIdx, 1 ); + } } - if( bHiddenPara ) + if ( bHiddenPara ) + { SetCalcHiddenParaField(); + } - return TRUE; + return bRet; } /************************************************************************* - * SwTxtNode::Delete() + * SwTxtNode::DeleteAttribute() *************************************************************************/ -void SwTxtNode::Delete( SwTxtAttr *pAttr, BOOL bThisOnly ) +void SwTxtNode::DeleteAttribute( SwTxtAttr * const pAttr ) { if ( !HasHints() ) + { + ASSERT(false, "DeleteAttribute called, but text node without hints?"); return; + } - if( bThisOnly ) + if ( pAttr->HasDummyChar() ) { - xub_StrLen* pEndIdx = pAttr->GetEnd(); - if( !pEndIdx ) - { - // hat es kein Ende kann es nur das sein, was hier steht! - // Unbedingt Copy-konstruieren! - const SwIndex aIdx( this, *pAttr->GetStart() ); - Erase( aIdx, 1 ); - } - else - { - // den MsgHint jetzt fuettern, weil gleich sind - // Start und End weg. - SwUpdateAttr aHint( *pAttr->GetStart(), *pEndIdx, pAttr->Which() ); - m_pSwpHints->Delete( pAttr ); - pAttr->RemoveFromPool( GetDoc()->GetAttrPool() ); - delete pAttr; - SwModify::Modify( 0, &aHint ); // die Frames benachrichtigen - - TryDeleteSwpHints(); - } - - return; + // Unbedingt Copy-konstruieren! + const SwIndex aIdx( this, *pAttr->GetStart() ); + // erase the CH_TXTATR, which will also delete pAttr + EraseText( aIdx, 1 ); + } + else + { + // create MsgHint before start/end become invalid + SwUpdateAttr aHint( + *pAttr->GetStart(), *pAttr->GetEnd(), pAttr->Which() ); + m_pSwpHints->Delete( pAttr ); + SwTxtAttr::Destroy( pAttr, GetDoc()->GetAttrPool() ); + SwModify::Modify( 0, &aHint ); // notify Frames + + TryDeleteSwpHints(); } - Delete( pAttr->Which(), *pAttr->GetStart(), *pAttr->GetAnyEnd() ); } /************************************************************************* - * SwTxtNode::Delete() + * SwTxtNode::DeleteAttributes() *************************************************************************/ -void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) +//FIXME: this does NOT respect SORT NUMBER (for CHARFMT)! +void SwTxtNode::DeleteAttributes( const USHORT nWhich, + const xub_StrLen nStart, const xub_StrLen nEnd ) { if ( !HasHints() ) return; - const xub_StrLen *pEndIdx; - const xub_StrLen *pSttIdx; - SwTxtAttr* pTxtHt; - for ( USHORT nPos = 0; m_pSwpHints && nPos < m_pSwpHints->Count(); nPos++ ) { - pTxtHt = m_pSwpHints->GetTextHint( nPos ); - const USHORT nWhich = pTxtHt->Which(); - if( nWhich == nTxtWhich && - *( pSttIdx = pTxtHt->GetStart()) == nStt ) + SwTxtAttr * const pTxtHt = m_pSwpHints->GetTextHint( nPos ); + const xub_StrLen nHintStart = *(pTxtHt->GetStart()); + if (nStart < nHintStart) + { + break; // sorted by start + } + else if ( (nStart == nHintStart) && (nWhich == pTxtHt->Which()) ) { if ( nWhich == RES_CHRATR_HIDDEN ) + { + ASSERT(false, "hey, that's a CHRATR! how did that get in?"); SetCalcHiddenCharFlags(); + } else if ( nWhich == RES_TXTATR_CHARFMT ) { // Check if character format contains hidden attribute: @@ -1124,16 +1564,14 @@ void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) } // <-- - pEndIdx = pTxtHt->GetEnd(); + xub_StrLen const * const pEndIdx = pTxtHt->GetEnd(); - // Text-Attribute sind voellig dynamisch, so dass diese nur - // mit ihrer Start-Position verglichen werden. - if( !pEndIdx ) + if ( pTxtHt->HasDummyChar() ) { // Unbedingt Copy-konstruieren! - const SwIndex aIdx( this, *pSttIdx ); - Erase( aIdx, 1 ); - break; + const SwIndex aIdx( this, nStart ); + // erase the CH_TXTATR, which will also delete pTxtHt + EraseText( aIdx, 1 ); } else if( *pEndIdx == nEnd ) { @@ -1141,12 +1579,10 @@ void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) // Start und End weg. // Das CalcVisibleFlag bei HiddenParaFields entfaellt, // da dies das Feld im Dtor selbst erledigt. - SwUpdateAttr aHint( *pSttIdx, *pEndIdx, nTxtWhich ); + SwUpdateAttr aHint( nStart, *pEndIdx, nWhich ); m_pSwpHints->DeleteAtPos( nPos ); // gefunden, loeschen, - pTxtHt->RemoveFromPool( GetDoc()->GetAttrPool() ); - delete pTxtHt; + SwTxtAttr::Destroy( pTxtHt, GetDoc()->GetAttrPool() ); SwModify::Modify( 0, &aHint ); // die Frames benachrichtigen - break; } } } @@ -1165,7 +1601,7 @@ void SwTxtNode::DelSoftHyph( const xub_StrLen nStt, const xub_StrLen nEnd ) nFndPos < nEndPos ) { const SwIndex aIdx( this, nFndPos ); - Erase( aIdx, 1 ); + EraseText( aIdx, 1 ); --nEndPos; } } @@ -1173,7 +1609,7 @@ void SwTxtNode::DelSoftHyph( const xub_StrLen nStt, const xub_StrLen nEnd ) // setze diese Attribute am TextNode. Wird der gesamte Bereich umspannt, // dann setze sie nur im AutoAttrSet (SwCntntNode:: SetAttr) BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, - xub_StrLen nEnd, USHORT nMode ) + xub_StrLen nEnd, const SetAttrMode nMode ) { if( !rSet.Count() ) return FALSE; @@ -1262,7 +1698,8 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, } else { - pNew = MakeTxtAttr( *pItem, nStt, nEnd ); + pNew = MakeTxtAttr( *GetDoc(), + const_cast<SfxPoolItem&>(*pItem), nStt, nEnd ); if ( pNew ) { if ( nEnd != nStt && !pNew->GetEnd() ) @@ -1271,7 +1708,7 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, "Attribut without end, but area marked"); DestroyAttr( pNew ); // do not insert } - else if ( Insert( pNew, nMode ) ) + else if ( InsertHint( pNew, nMode ) ) { ++nCount; } @@ -1287,9 +1724,11 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, if ( aCharSet.Count() ) { - SwTxtAttr* pTmpNew = MakeTxtAttr( aCharSet, nStt, nEnd ); - if ( Insert( pTmpNew, nMode ) ) + SwTxtAttr* pTmpNew = MakeTxtAttr( *GetDoc(), aCharSet, nStt, nEnd ); + if ( InsertHint( pTmpNew, nMode ) ) + { ++nCount; + } } TryDeleteSwpHints(); @@ -1669,7 +2108,9 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) if (lcl_IsNewAttrInSet( *m_pSwpHints, *pItem, GetTxt().Len() )) { m_pSwpHints->SwpHintsArray::Insert( - MakeTxtAttr( *pItem, 0, GetTxt().Len() ) ); + MakeTxtAttr( *GetDoc(), + const_cast<SfxPoolItem&>(*pItem), + 0, GetTxt().Len() ) ); aClearWhichIds.push_back( pItem->Which() ); } @@ -1701,8 +2142,9 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) &pNdItem ) || *pItem != *pNdItem ) && lcl_IsNewAttrInSet( *m_pSwpHints, *pItem, GetTxt().Len() ) ) { - m_pSwpHints->SwpHintsArray::Insert( - MakeTxtAttr( *pItem, 0, GetTxt().Len() ) ); + m_pSwpHints->SwpHintsArray::Insert( MakeTxtAttr( *GetDoc(), + const_cast<SfxPoolItem&>(*pItem), + 0, GetTxt().Len() ) ); aClearWhichIds.push_back( pItem->Which() ); } aNdSet.ClearItem( pItem->Which() ); @@ -1726,7 +2168,9 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) pNd->GetTxt().Len() ) ) { pNd->m_pSwpHints->SwpHintsArray::Insert( - pNd->MakeTxtAttr( *pItem, 0, pNd->GetTxt().Len() ) ); + MakeTxtAttr( *pNd->GetDoc(), + const_cast<SfxPoolItem&>(*pItem), + 0, pNd->GetTxt().Len() ) ); } aClearWhichIds.push_back( pItem->Which() ); @@ -1979,18 +2423,20 @@ void lcl_CheckSortNumber( const SwpHints& rHints, SwTxtCharFmt& rNewCharFmt ) *************************************************************************/ /* - * Insert: Der neue Hint wird immer eingefuegt. Wenn dabei ein - * ueberlappender oder gleicher Hintbereich mit gleichem Attribut - * und Wert gefunden, wird der neue Hint entsprechend veraendert - * und der alte herausgenommen (und zerstoert: - * SwpHints::Destroy()). + * Try to insert the new hint. + * Depending on the type of the hint, this either always succeeds, or may fail. + * Depending on the type of the hint, other hints may be deleted or + * overwritten. + * The return value indicates successful insertion. */ - -void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) +bool SwpHints::TryInsertHint( SwTxtAttr* const pHint, SwTxtNode &rNode, + const SetAttrMode nMode ) { - // Irgendwann ist immer Schluss - if( USHRT_MAX == Count() ) - return; + if ( USHRT_MAX == Count() ) // we're sorry, this flight is overbooked... + { + ASSERT(false, "hints array full :-("); + return false; + } // Felder bilden eine Ausnahme: // 1) Sie koennen nie ueberlappen @@ -2025,11 +2471,7 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) } // <-- case RES_TXTATR_INETFMT: - { - ((SwTxtINetFmt*)pHint)->ChgTxtNode( &rNode ); - SwCharFmt* pFmt = rNode.GetDoc()->GetCharFmtFromPool( RES_POOLCHR_INET_NORMAL ); - pFmt->Add( (SwTxtINetFmt*)pHint ); - } + lcl_InitINetFmt(rNode, static_cast<SwTxtINetFmt*>(pHint)); break; case RES_TXTATR_FIELD: { @@ -2163,12 +2605,12 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) break; case RES_TXTATR_CJK_RUBY: - { - ((SwTxtRuby*)pHint)->ChgTxtNode( &rNode ); - SwCharFmt* pFmt = rNode.GetDoc()->GetCharFmtFromPool( - RES_POOLCHR_RUBYTEXT ); - pFmt->Add( (SwTxtRuby*)pHint ); - } + lcl_InitRuby(rNode, static_cast<SwTxtRuby*>(pHint)); + break; + + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + static_cast<SwTxtMeta *>(pHint)->ChgTxtNode( &rNode ); break; case RES_CHRATR_HIDDEN: @@ -2198,7 +2640,7 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) SwUpdateAttr aHint( nHtStart, nHtStart, nWhich ); rNode.Modify( 0, &aHint ); } - return; + return true; } // ---------------------------------------------------------------- @@ -2219,18 +2661,24 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) const xub_StrLen nHintEnd = *pHtEnd; const bool bNoHintAdjustMode = (nsSetAttrMode::SETATTR_NOHINTADJUST & nMode); + // handle nesting attributes: inserting may fail due to overlap! + if (pHint->IsNesting()) + { + const bool bRet( + TryInsertNesting(rNode, *static_cast<SwTxtAttrNesting*>(pHint))); + if (!bRet) return false; + } // Currently REFMARK and TOXMARK have OverlapAllowed set to true. // These attributes may be inserted directly. // Also attributes without length may be inserted directly. // SETATTR_NOHINTADJUST is set e.g., during undo. // Portion building in not necessary during XML import. + else if ( !bNoHintAdjustMode && !pHint->IsOverlapAllowedAttr() && !rNode.GetDoc()->IsInXMLImport() && ( RES_TXTATR_AUTOFMT == nWhich || - RES_TXTATR_INETFMT == nWhich || - RES_TXTATR_CHARFMT == nWhich || - RES_TXTATR_CJK_RUBY == nWhich ) ) + RES_TXTATR_CHARFMT == nWhich ) ) { ASSERT( nWhich != RES_TXTATR_AUTOFMT || static_cast<const SwFmtAutoFmt&>(pHint->GetAttr()).GetStyleHandle()->GetPool() == @@ -2252,10 +2700,10 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) // multiple times // FME 2007-11-08 #i82989# in NOHINTADJUST mode, we want to insert // character attributes directly - if ( ( RES_TXTATR_CHARFMT == nWhich && !bNoHintAdjustMode ) || - RES_TXTATR_CJK_RUBY == nWhich || - RES_TXTATR_INETFMT == nWhich ) + if ( ( RES_TXTATR_CHARFMT == nWhich && !bNoHintAdjustMode ) ) + { BuildPortions( rNode, *pHint, nMode ); + } else { // --> FME 2007-11-08 #i82989# Check sort numbers in NoHintAdjustMode @@ -2280,7 +2728,7 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) CHECK; #endif - return; + return true; } /************************************************************************* @@ -2348,7 +2796,6 @@ void SwTxtNode::ClearSwpHintsArr( bool bDelFields ) break; case RES_TXTATR_FIELD: - case RES_TXTATR_HARDBLANK: if( bDelFields ) bDel = true; break; @@ -2435,20 +2882,22 @@ sal_Unicode GetCharOfTxtAttr( const SwTxtAttr& rAttr ) sal_Unicode cRet = CH_TXTATR_BREAKWORD; switch ( rAttr.Which() ) { - case RES_TXTATR_REFMARK: - case RES_TXTATR_TOXMARK: - -// case RES_TXTATR_FIELD: ?????? -// case RES_TXTATR_FLYCNT, // 29 + case RES_TXTATR_FTN: + case RES_TXTATR_REFMARK: + case RES_TXTATR_TOXMARK: + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + cRet = CH_TXTATR_INWORD; + break; - case RES_TXTATR_FTN: - cRet = CH_TXTATR_INWORD; - break; + case RES_TXTATR_FIELD: + case RES_TXTATR_FLYCNT: + cRet = CH_TXTATR_BREAKWORD; + break; - // depends on the character ?? -// case RES_TXTATR_HARDBLANK: -// cRet = CH_TXTATR_INWORD; -// break; + default: + ASSERT(false, "GetCharOfTxtAttr: unknown attr"); + break; } return cRet; } diff --git a/sw/source/core/txtnode/txatbase.cxx b/sw/source/core/txtnode/txatbase.cxx index 5b5f81a065..61b425ccce 100644 --- a/sw/source/core/txtnode/txatbase.cxx +++ b/sw/source/core/txtnode/txatbase.cxx @@ -37,17 +37,18 @@ #include <fmtfld.hxx> #include <docufld.hxx> -SwTxtAttr::SwTxtAttr( const SfxPoolItem& rAttr, xub_StrLen nStart ) +SwTxtAttr::SwTxtAttr( SfxPoolItem& rAttr, xub_StrLen nStart ) : m_pAttr( &rAttr ) , m_nStart( nStart ) , m_bDontExpand( false ) , m_bLockExpandFlag( false ) - , m_bDontMergeAttr( false ) , m_bDontMoveAttr( false ) , m_bCharFmtAttr( false ) , m_bOverlapAllowedAttr( false ) , m_bPriorityAttr( false ) , m_bDontExpandStart( false ) + , m_bNesting( false ) + , m_bHasDummyChar( false ) { } @@ -60,11 +61,12 @@ xub_StrLen* SwTxtAttr::GetEnd() return 0; } -// RemoveFromPool must be called before destructor! -void SwTxtAttr::RemoveFromPool( SfxItemPool& rPool ) +void SwTxtAttr::Destroy( SwTxtAttr * pToDestroy, SfxItemPool& rPool ) { - rPool.Remove( GetAttr() ); - m_pAttr = 0; + if (!pToDestroy) return; + SfxPoolItem * const pAttr = pToDestroy->m_pAttr; + delete pToDestroy; + rPool.Remove( *pAttr ); } int SwTxtAttr::operator==( const SwTxtAttr& rAttr ) const @@ -72,7 +74,7 @@ int SwTxtAttr::operator==( const SwTxtAttr& rAttr ) const return GetAttr() == rAttr.GetAttr(); } -SwTxtAttrEnd::SwTxtAttrEnd( const SfxPoolItem& rAttr, +SwTxtAttrEnd::SwTxtAttrEnd( SfxPoolItem& rAttr, xub_StrLen nStart, xub_StrLen nEnd ) : SwTxtAttr( rAttr, nStart ), m_nEnd( nEnd ) { diff --git a/sw/source/core/txtnode/txatritr.cxx b/sw/source/core/txtnode/txatritr.cxx index f6afc22c84..cb3c9e4666 100644 --- a/sw/source/core/txtnode/txatritr.cxx +++ b/sw/source/core/txtnode/txatritr.cxx @@ -55,50 +55,50 @@ SwScriptIterator::SwScriptIterator( const String& rStr, xub_StrLen nStt, sal_Boo nCurScript( ScriptType::WEAK ), bForward( bFrwrd ) { - if( pBreakIt->xBreak.is() ) + if( pBreakIt->GetBreakIter().is() ) { if ( ! bFrwrd && nStt ) --nStt; xub_StrLen nPos = nStt; - nCurScript = pBreakIt->xBreak->getScriptType( rText, nPos ); + nCurScript = pBreakIt->GetBreakIter()->getScriptType( rText, nPos ); if( ScriptType::WEAK == nCurScript ) { if( nPos ) { - nPos = (xub_StrLen)pBreakIt->xBreak->beginOfScript( + nPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfScript( rText, nPos, nCurScript ); if( nPos && nPos < rText.Len() ) { nStt = --nPos; - nCurScript = pBreakIt->xBreak->getScriptType( rText,nPos); + nCurScript = pBreakIt->GetBreakIter()->getScriptType( rText,nPos); } } } nChgPos = bForward ? - (xub_StrLen)pBreakIt->xBreak->endOfScript( rText, nStt, nCurScript ) : - (xub_StrLen)pBreakIt->xBreak->beginOfScript( rText, nStt, nCurScript ); + (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( rText, nStt, nCurScript ) : + (xub_StrLen)pBreakIt->GetBreakIter()->beginOfScript( rText, nStt, nCurScript ); } } sal_Bool SwScriptIterator::Next() { sal_Bool bRet = sal_False; - if( pBreakIt->xBreak.is() ) + if( pBreakIt->GetBreakIter().is() ) { if ( bForward && nChgPos < rText.Len() ) { - nCurScript = pBreakIt->xBreak->getScriptType( rText, nChgPos ); - nChgPos = (xub_StrLen)pBreakIt->xBreak->endOfScript( + nCurScript = pBreakIt->GetBreakIter()->getScriptType( rText, nChgPos ); + nChgPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( rText, nChgPos, nCurScript ); bRet = sal_True; } else if ( ! bForward && nChgPos ) { --nChgPos; - nCurScript = pBreakIt->xBreak->getScriptType( rText, nChgPos ); - nChgPos = (xub_StrLen)pBreakIt->xBreak->beginOfScript( + nCurScript = pBreakIt->GetBreakIter()->getScriptType( rText, nChgPos ); + nChgPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfScript( rText, nChgPos, nCurScript ); bRet = sal_True; } diff --git a/sw/source/core/txtnode/txtatr2.cxx b/sw/source/core/txtnode/txtatr2.cxx index 160d39b620..339cd6e972 100644 --- a/sw/source/core/txtnode/txtatr2.cxx +++ b/sw/source/core/txtnode/txtatr2.cxx @@ -46,24 +46,19 @@ #include <poolfmt.hxx> // RES_POOLCHR_INET_... #include <doc.hxx> // SwDoc #include <fmtruby.hxx> -#include <fmthbsh.hxx> +#include <fmtmeta.hxx> + TYPEINIT1(SwTxtINetFmt,SwClient); TYPEINIT1(SwTxtRuby,SwClient); -/************************************************************************* - * class SwTxtHardBlank - *************************************************************************/ - -SwTxtHardBlank::SwTxtHardBlank( const SwFmtHardBlank& rAttr, xub_StrLen nStt ) - : SwTxtAttr( rAttr, nStt ) - , m_Char( rAttr.GetChar() ) -{ - ASSERT( ' ' != m_Char && '-' != m_Char, - "Invalid character for the HardBlank attribute - " - "must be a normal unicode character" ); -} +// ATT_XMLCONTAINERITEM ****************************** +SwTxtXMLAttrContainer::SwTxtXMLAttrContainer( + SvXMLAttrContainerItem& rAttr, + xub_StrLen nStt, xub_StrLen nEnde ) + : SwTxtAttrEnd( rAttr, nStt, nEnde ) +{} /************************************************************************* * class SwTxtCharFmt @@ -110,20 +105,42 @@ BOOL SwTxtCharFmt::GetInfo( SfxPoolItem& rInfo ) const return FALSE; } + +/************************************************************************* + * class SwTxtAttrNesting + *************************************************************************/ + +SwTxtAttrNesting::SwTxtAttrNesting( SfxPoolItem & i_rAttr, + const xub_StrLen i_nStart, const xub_StrLen i_nEnd ) + : SwTxtAttrEnd( i_rAttr, i_nStart, i_nEnd ) +{ + SetDontExpand( true ); // never expand this attribute + // lock the expand flag: simple guarantee that nesting will not be + // invalidated by expand operations + SetLockExpandFlag( true ); + SetDontExpandStartAttr( true ); + SetNesting( true ); +} + +SwTxtAttrNesting::~SwTxtAttrNesting() +{ +} + + /************************************************************************* * class SwTxtINetFmt *************************************************************************/ SwTxtINetFmt::SwTxtINetFmt( SwFmtINetFmt& rAttr, - xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ) + xub_StrLen nStart, xub_StrLen nEnd ) + : SwTxtAttrNesting( rAttr, nStart, nEnd ) , SwClient( 0 ) , m_pTxtNode( 0 ) , m_bVisited( false ) , m_bVisitedValid( false ) { rAttr.pTxtAttr = this; - SetCharFmtAttr( TRUE ); + SetCharFmtAttr( true ); } SwTxtINetFmt::~SwTxtINetFmt( ) @@ -212,30 +229,17 @@ BOOL SwTxtINetFmt::IsProtect( ) const return m_pTxtNode && m_pTxtNode->IsProtect(); } -// ATT_XNLCONTAINERITEM ****************************** - -SwTxtXMLAttrContainer::SwTxtXMLAttrContainer( - const SvXMLAttrContainerItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ) -{} - - /************************************************************************* * class SwTxtRuby *************************************************************************/ SwTxtRuby::SwTxtRuby( SwFmtRuby& rAttr, xub_StrLen nStart, xub_StrLen nEnd ) - : SwTxtAttrEnd( rAttr, nStart, nEnd ) + : SwTxtAttrNesting( rAttr, nStart, nEnd ) , SwClient( 0 ) , m_pTxtNode( 0 ) { rAttr.pTxtAttr = this; - SetDontExpand( true ); // never expand this attribute - SetLockExpandFlag( true ); - SetDontMergeAttr( true ); - SetDontExpandStartAttr( true ); } SwTxtRuby::~SwTxtRuby() @@ -310,11 +314,26 @@ SwCharFmt* SwTxtRuby::GetCharFmt() return pRet; } -// ****************************** -SwTxt2Lines::SwTxt2Lines( const SvxTwoLinesItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ) +/************************************************************************* + * class SwTxtMeta + *************************************************************************/ + +SwTxtMeta::SwTxtMeta( SwFmtMeta & i_rAttr, + const xub_StrLen i_nStart, const xub_StrLen i_nEnd ) + : SwTxtAttrNesting( i_rAttr, i_nStart, i_nEnd ) + , m_pTxtNode( 0 ) { + i_rAttr.SetTxtAttr( this ); + SetHasDummyChar(true); +} + +SwTxtMeta::~SwTxtMeta() +{ + SwFmtMeta & rFmtMeta( static_cast<SwFmtMeta &>(GetAttr()) ); + if (rFmtMeta.GetTxtAttr() == this) + { + rFmtMeta.SetTxtAttr(0); + } } diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 95fcac2e60..db2743218f 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -368,56 +368,6 @@ static bool lcl_HaveCommonAttributes( IStyleAccess& rStyleAccess, return bRet; } -/* - * Ein Zeichen wurde eingefuegt. - */ - -SwTxtNode& SwTxtNode::Insert( xub_Unicode c, const SwIndex &rIdx ) -{ - xub_StrLen nOrigLen = m_Text.Len(); - - ASSERT( rIdx <= nOrigLen, "SwTxtNode::Insert: invalid index." ); - ASSERT( nOrigLen < STRING_LEN, - "SwTxtNode::Insert: node text with insertion > STRING_LEN." ); - - if ( nOrigLen == m_Text.Insert( c, rIdx.GetIndex() ).Len() ) - return *this; - - Update(rIdx,1); - - // leere Hints und Feldattribute an rIdx.GetIndex suchen - if ( HasHints() ) - { - USHORT* pEndIdx; - for ( USHORT i=0; i < m_pSwpHints->Count() && - rIdx >= *(*m_pSwpHints)[i]->GetStart(); ++i) - { - SwTxtAttr *pHt = m_pSwpHints->GetTextHint(i); - pEndIdx = pHt->GetEnd(); - if ( pEndIdx ) - { - // leere Hints an rIdx.GetIndex ? - BOOL bEmpty = *pEndIdx == *pHt->GetStart() - && rIdx == *pHt->GetStart(); - - if( bEmpty ) - { - m_pSwpHints->DeleteAtPos(i); - if( bEmpty ) - *pHt->GetStart() -= 1; - else - *pEndIdx -= 1; - Insert(pHt); - } - } - } - TryDeleteSwpHints(); - } - // den Frames Bescheid sagen - SwInsChr aHint( rIdx.GetIndex()-1 ); - SwModify::Modify( 0, &aHint ); - return *this; -} inline BOOL InRange(xub_StrLen nIdx, xub_StrLen nStart, xub_StrLen nEnd) { return ((nIdx >=nStart) && (nIdx <= nEnd)); @@ -454,7 +404,6 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, USHORT i = 0; xub_StrLen nStt = rIdx.GetIndex(); xub_StrLen nEnd = nStt + nLen; - xub_StrLen *pAttrEnd; xub_StrLen nAttrStart; SwTxtAttr *pHt; @@ -479,8 +428,8 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, pHt = m_pSwpHints->GetTextHint(i); // attributes without end stay in! - pAttrEnd = pHt->GetEnd(); - if ( !pAttrEnd ) + xub_StrLen * const pAttrEnd = pHt->GetEnd(); + if ( !pAttrEnd /*|| pHt->HasDummyChar()*/ ) // see bInclRefToxMark { i++; continue; @@ -514,8 +463,12 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, else if ( !bInclRefToxMark ) { // 3. case: Reset all attributes except from ref/toxmarks: - bSkipAttr = RES_TXTATR_REFMARK == pHt->Which() || - RES_TXTATR_TOXMARK == pHt->Which(); + // skip hints with CH_TXTATR here + // (deleting those is ONLY allowed for UNDO!) + bSkipAttr = RES_TXTATR_REFMARK == pHt->Which() + || RES_TXTATR_TOXMARK == pHt->Which() + || RES_TXTATR_META == pHt->Which() + || RES_TXTATR_METAFIELD == pHt->Which(); } if ( bSkipAttr ) @@ -547,8 +500,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, if ( pStyleHandle.get() ) { - SwTxtAttr* pNew = MakeTxtAttr( *pStyleHandle, nAttrStart, nAttrEnd ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + *pStyleHandle, nAttrStart, nAttrEnd ); + InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); } // if the last attribute is a Field, the HintsArray is @@ -574,8 +528,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, if ( pStyleHandle.get() && nAttrStart < nEnd ) { - SwTxtAttr* pNew = MakeTxtAttr( *pStyleHandle, nAttrStart, nEnd ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + *pStyleHandle, nAttrStart, nEnd ); + InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); } bChanged = TRUE; @@ -601,8 +556,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, if ( pStyleHandle.get() ) { - SwTxtAttr* pNew = MakeTxtAttr( *pStyleHandle, nStt, nAttrEnd ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + *pStyleHandle, nStt, nAttrEnd ); + InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); } } else if( nLen ) // Fall: 4 @@ -620,20 +576,23 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, if ( pStyleHandle.get() && nStt < nEnd ) { - SwTxtAttr* pNew = MakeTxtAttr( *pStyleHandle, nStt, nEnd ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + *pStyleHandle, nStt, nEnd ); + InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); } if( nEnd < nTmpEnd ) { - SwTxtAttr* pNew = MakeTxtAttr( pHt->GetAttr(), nEnd, nTmpEnd ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + pHt->GetAttr(), nEnd, nTmpEnd ); if ( pNew ) { SwTxtCharFmt* pCharFmt = dynamic_cast<SwTxtCharFmt*>(pHt); if ( pCharFmt ) static_cast<SwTxtCharFmt*>(pNew)->SetSortNumber( pCharFmt->GetSortNumber() ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + InsertHint( pNew, + nsSetAttrMode::SETATTR_NOHINTADJUST ); } @@ -682,7 +641,7 @@ XubString SwTxtNode::GetCurWord( xub_StrLen nPos ) const return m_Text; Boundary aBndry; - const uno::Reference< XBreakIterator > &rxBreak = pBreakIt->xBreak; + const uno::Reference< XBreakIterator > &rxBreak = pBreakIt->GetBreakIter(); if (rxBreak.is()) { sal_Int16 nWordType = WordType::DICTIONARY_WORD; @@ -750,7 +709,7 @@ BOOL SwScanner::NextWord() { if ( !pLanguage ) { - const USHORT nNextScriptType = pBreakIt->xBreak->getScriptType( rText, nBegin ); + const USHORT nNextScriptType = pBreakIt->GetBreakIter()->getScriptType( rText, nBegin ); ModelToViewHelper::ModelPosition aModelBeginPos = ModelToViewHelper::ConvertToModelPosition( pConversionMap, nBegin ); const xub_StrLen nBeginModelPos = (xub_StrLen)aModelBeginPos.mnPos; aCurrLang = rNode.GetLang( nBeginModelPos, 1, nNextScriptType ); @@ -772,7 +731,7 @@ BOOL SwScanner::NextWord() return FALSE; // get the word boundaries - aBound = pBreakIt->xBreak->getWordBoundary( rText, nBegin, + aBound = pBreakIt->GetBreakIter()->getWordBoundary( rText, nBegin, pBreakIt->GetLocale( aCurrLang ), nWordType, sal_True ); //no word boundaries could be found @@ -795,11 +754,11 @@ BOOL SwScanner::NextWord() // restrict boundaries to script boundaries and nEndPos const USHORT nCurrScript = - pBreakIt->xBreak->getScriptType( rText, nBegin ); + pBreakIt->GetBreakIter()->getScriptType( rText, nBegin ); XubString aTmpWord = rText.Copy( nBegin, static_cast<xub_StrLen>(aBound.endPos - nBegin) ); const sal_Int32 nScriptEnd = nBegin + - pBreakIt->xBreak->endOfScript( aTmpWord, 0, nCurrScript ); + pBreakIt->GetBreakIter()->endOfScript( aTmpWord, 0, nCurrScript ); const sal_Int32 nEnd = Min( aBound.endPos, nScriptEnd ); // restrict word start to last script change position @@ -810,7 +769,7 @@ BOOL SwScanner::NextWord() aTmpWord = rText.Copy( static_cast<xub_StrLen>(aBound.startPos), static_cast<xub_StrLen>(nBegin - aBound.startPos + 1) ); nScriptBegin = aBound.startPos + - pBreakIt->xBreak->beginOfScript( aTmpWord, nBegin - aBound.startPos, + pBreakIt->GetBreakIter()->beginOfScript( aTmpWord, nBegin - aBound.startPos, nCurrScript ); } @@ -820,11 +779,11 @@ BOOL SwScanner::NextWord() else { const USHORT nCurrScript = - pBreakIt->xBreak->getScriptType( rText, aBound.startPos ); + pBreakIt->GetBreakIter()->getScriptType( rText, aBound.startPos ); XubString aTmpWord = rText.Copy( static_cast<xub_StrLen>(aBound.startPos), static_cast<xub_StrLen>(aBound.endPos - aBound.startPos) ); const sal_Int32 nScriptEnd = aBound.startPos + - pBreakIt->xBreak->endOfScript( aTmpWord, 0, nCurrScript ); + pBreakIt->GetBreakIter()->endOfScript( aTmpWord, 0, nCurrScript ); const sal_Int32 nEnd = Min( aBound.endPos, nScriptEnd ); nBegin = (xub_StrLen)aBound.startPos; nLen = (xub_StrLen)(nEnd - nBegin); @@ -1003,7 +962,7 @@ void SwTxtNode::SetLanguageAndFont( const SwPaM &rPaM, aSet.Put( aFontItem ); } - GetDoc()->Insert( rPaM, aSet, 0 ); + GetDoc()->InsertItemSet( rPaM, aSet, 0 ); // SetAttr( aSet ); <- Does not set language attribute of empty paragraphs correctly, // <- because since there is no selection the flag to garbage // <- collect all attributes is set, and therefore attributes spanned @@ -1196,7 +1155,7 @@ SwRect SwTxtFrm::_AutoSpell( const SwCntntNode* pActNode, const SwViewOption& rV LanguageType eActLang = pNode->GetLang( nBegin ); Boundary aBound = - pBreakIt->xBreak->getWordBoundary( pNode->GetTxt(), nBegin, + pBreakIt->GetBreakIter()->getWordBoundary( pNode->GetTxt(), nBegin, pBreakIt->GetLocale( eActLang ), WordType::DICTIONARY_WORD, TRUE ); nBegin = xub_StrLen(aBound.startPos); @@ -1352,8 +1311,8 @@ SwRect SwTxtFrm::SmartTagScan( SwCntntNode* /*pActNode*/, xub_StrLen /*nActPos*/ { const LanguageType aCurrLang = pNode->GetLang( nBegin ); const com::sun::star::lang::Locale aCurrLocale = pBreakIt->GetLocale( aCurrLang ); - nBegin = static_cast< xub_StrLen >(pBreakIt->xBreak->beginOfSentence( rText, nBegin, aCurrLocale )); - nEnd = static_cast< xub_StrLen >(Min( rText.getLength(), pBreakIt->xBreak->endOfSentence( rText, nEnd, aCurrLocale ) )); + nBegin = static_cast< xub_StrLen >(pBreakIt->GetBreakIter()->beginOfSentence( rText, nBegin, aCurrLocale )); + nEnd = static_cast< xub_StrLen >(Min( rText.getLength(), pBreakIt->GetBreakIter()->endOfSentence( rText, nEnd, aCurrLocale ) )); } } } @@ -1753,7 +1712,7 @@ void SwTxtNode::CountWords( SwDocStat& rStat, const bool bCount = aExpandText.getLength() > 0; // count words in 'regular' text: - if( bCount && pBreakIt->xBreak.is() ) + if( bCount && pBreakIt->GetBreakIter().is() ) { const String aScannerText( aExpandText ); SwScanner aScanner( *this, aScannerText, 0, pConversionMap, diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 1957c9cea3..44ac5f49c4 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -352,7 +352,7 @@ void SwHistorySetRefMark::SetInDoc( SwDoc* pDoc, bool ) // if a reference mark without an end already exists here: must not insert! if ( m_nStart != m_nEnd || - !pTxtNd->GetTxtAttr( m_nStart, RES_TXTATR_REFMARK ) ) + !pTxtNd->GetTxtAttrForCharAt( m_nStart, RES_TXTATR_REFMARK ) ) { pTxtNd->InsertItem( aRefMark, m_nStart, m_nEnd, nsSetAttrMode::SETATTR_NOTXTATRCHR ); @@ -433,7 +433,7 @@ void SwHistoryResetTxt::SetInDoc( SwDoc* pDoc, bool ) ASSERT( pTxtNd, "SwHistoryResetTxt: no TextNode" ); if ( pTxtNd ) { - pTxtNd->Delete( m_nAttr, m_nStart, m_nEnd ); + pTxtNd->DeleteAttributes( m_nAttr, m_nStart, m_nEnd ); } } @@ -514,12 +514,13 @@ void SwHistorySetFootnote::SetInDoc( SwDoc* pDoc, bool ) m_pUndo->GetHistory()->Rollback( pDoc ); } - pTxtNd->Insert( pTxtFtn ); + pTxtNd->InsertHint( pTxtFtn ); } else { - SwTxtFtn *pFtn = const_cast<SwTxtFtn*>( - static_cast<const SwTxtFtn*>(pTxtNd->GetTxtAttr( m_nStart ))); + SwTxtFtn * const pFtn = + const_cast<SwTxtFtn*>( static_cast<const SwTxtFtn*>( + pTxtNd->GetTxtAttrForCharAt( m_nStart ))); SwFmtFtn &rFtn = const_cast<SwFmtFtn&>(pFtn->GetFtn()); rFtn.SetNumStr( m_FootnoteNumber ); if ( rFtn.IsEndNote() != m_bEndNote ) @@ -615,6 +616,14 @@ SwHistoryBookmark::SwHistoryBookmark( { m_aKeycode = pBookmark->GetKeyCode(); m_aShortName = pBookmark->GetShortName(); + + ::sfx2::Metadatable * const pMetadatable( + const_cast< ::sfx2::Metadatable * >( // CreateUndo should be const? + dynamic_cast< ::sfx2::Metadatable const* >(pBookmark))); + if (pMetadatable) + { + m_pMetadataUndo = pMetadatable->CreateUndo(); + } } } @@ -681,6 +690,16 @@ void SwHistoryBookmark::SetInDoc( SwDoc* pDoc, bool ) { pBookmark->SetKeyCode(m_aKeycode); pBookmark->SetShortName(m_aShortName); + if (m_pMetadataUndo) + { + ::sfx2::Metadatable * const pMeta( + dynamic_cast< ::sfx2::Metadatable* >(pBookmark)); + OSL_ENSURE(pMeta, "metadata undo, but not metadatable?"); + if (pMeta) + { + pMeta->RestoreMetadata(m_pMetadataUndo); + } + } } } pDoc->DoUndo(bDoesUndo); @@ -819,6 +838,25 @@ SwHistoryResetAttrSet::SwHistoryResetAttrSet( const SfxItemSet& rSet, while( TRUE ) { const USHORT nWhich = aIter.GetCurItem()->Which(); + +#ifndef PRODUCT + switch (nWhich) + { + case RES_TXTATR_REFMARK: + case RES_TXTATR_TOXMARK: + if (m_nStart != m_nEnd) break; // else: fall through! + case RES_TXTATR_FIELD: + case RES_TXTATR_FLYCNT: + case RES_TXTATR_FTN: + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + ASSERT(rSet.Count() == 1, + "text attribute with CH_TXTATR, but not the only one:" + "\nnot such a good idea"); + break; + } +#endif + // Character attribute cannot be inserted into the hints array // anymore. Therefore we have to treat them as one RES_TXTATR_AUTOFMT: if (isCHRATR(nWhich)) @@ -868,7 +906,7 @@ void SwHistoryResetAttrSet::SetInDoc( SwDoc* pDoc, bool ) for ( USHORT n = m_Array.Count(); n; --n, ++pArr ) { static_cast<SwTxtNode*>(pCntntNd)-> - Delete( *pArr, m_nStart, m_nEnd ); + DeleteAttributes( *pArr, m_nStart, m_nEnd ); } } } @@ -1292,7 +1330,6 @@ void SwHistory::CopyAttr( SwpHints* pHts, ULONG nNodeIdx, switch( pHt->Which() ) { case RES_TXTATR_FIELD: - case RES_TXTATR_HARDBLANK: // keine Felder, .. kopieren ?? if( !bFields ) bNextAttr = TRUE; @@ -1397,40 +1434,45 @@ void SwRegHistory::AddHint( SwTxtAttr* pHt, const bool bNew ) } -SwRegHistory::SwRegHistory( SwTxtNode* pTxtNode, const SfxItemSet& rSet, - xub_StrLen nStart, xub_StrLen nEnd, USHORT nFlags, - SwHistory* pHst ) - : SwClient( pTxtNode ) - , m_pHistory( pHst ) - , m_nNodeIndex( pTxtNode->GetIndex() ) +bool SwRegHistory::InsertItems( const SfxItemSet& rSet, + xub_StrLen const nStart, xub_StrLen const nEnd, SetAttrMode const nFlags ) { if( !rSet.Count() ) - return; + return false; - BOOL bInsert; + SwTxtNode * const pTxtNode = + dynamic_cast<SwTxtNode *>(const_cast<SwModify *>(GetRegisteredIn())); - if( pTxtNode->GetpSwpHints() && pHst ) + ASSERT(pTxtNode, "SwRegHistory not registered at text node?"); + if (!pTxtNode) + return false; + + if ( pTxtNode->GetpSwpHints() && m_pHistory ) { pTxtNode->GetpSwpHints()->Register( this ); - bInsert = pTxtNode->SetAttr( rSet, nStart, nEnd, nFlags ); + } + + const bool bInserted = pTxtNode->SetAttr( rSet, nStart, nEnd, nFlags ); + // Achtung: Durch das Einfuegen eines Attributs kann das Array // geloescht werden!!! Wenn das einzufuegende zunaechst ein vorhandenes // loescht, selbst aber nicht eingefuegt werden braucht, weil die // Absatzattribute identisch sind( -> bForgetAttr in SwpHints::Insert ) - if ( pTxtNode->GetpSwpHints() ) - pTxtNode->GetpSwpHints()->DeRegister(); + if ( pTxtNode->GetpSwpHints() && m_pHistory ) + { + pTxtNode->GetpSwpHints()->DeRegister(); } - else - bInsert = pTxtNode->SetAttr( rSet, nStart, nEnd, nFlags ); - if( pHst && bInsert ) + if ( m_pHistory && bInserted ) { SwHistoryHint* pNewHstr = new SwHistoryResetAttrSet( rSet, pTxtNode->GetIndex(), nStart, nEnd ); // der NodeIndex kann verschoben sein !! - pHst->m_SwpHstry.Insert( pNewHstr, pHst->Count() ); + m_pHistory->m_SwpHstry.Insert( pNewHstr, m_pHistory->Count() ); } + + return bInserted; } void SwRegHistory::RegisterInModify( SwModify* pRegIn, const SwNode& rNd ) diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index 4be7c56371..512c7c1afe 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -560,18 +560,17 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) SwTxtNode *pTxtNode = (SwTxtNode*)&pPos->nNode.GetNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); -#ifdef DBG_UTIL + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( nIdx, RES_TXTATR_FLYCNT ); ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFrmFmt, "Wrong TxtFlyCnt-Hint." ); -#endif const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); //Die Verbindung ist geloest, jetzt muss noch das Attribut vernichtet //werden. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx ); } { @@ -618,8 +617,9 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) { const SwPosition* pPos = aNewAnchor.GetCntntAnchor(); SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); - ASSERT( pTxtNd, "Kein Textnode an dieser Position" ); - pTxtNd->InsertItem( SwFmtFlyCnt( pFrmFmt ), pPos->nContent.GetIndex(), 0 ); + ASSERT( pTxtNd, "no Text Node at position." ); + SwFmtFlyCnt aFmt( pFrmFmt ); + pTxtNd->InsertItem( aFmt, pPos->nContent.GetIndex(), 0 ); } @@ -767,7 +767,9 @@ void SwUndoResetAttr::Redo( SwUndoIter& rUndoIter ) } // gefunden, also loeschen if( nCnt-- ) - rDoc.Delete( aArr[ nCnt ] ); + { + rDoc.DeleteTOXMark( aArr[ nCnt ] ); + } } } break; @@ -815,7 +817,7 @@ void SwUndoResetAttr::SetAttrs( const SvUShortsSort& rArr ) SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxPoolItem& rAttr, - USHORT nFlags ) + const SetAttrMode nFlags ) : SwUndo( UNDO_INSATTR ), SwUndRng( rRange ) , m_AttrSet( rRange.GetDoc()->GetAttrPool(), rAttr.Which(), rAttr.Which() ) , m_pHistory( new SwHistory ) @@ -828,7 +830,7 @@ SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxPoolItem& rAttr, } SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxItemSet& rSet, - USHORT nFlags ) + const SetAttrMode nFlags ) : SwUndo( UNDO_INSATTR ), SwUndRng( rRange ) , m_AttrSet( rSet ) , m_pHistory( new SwHistory ) @@ -899,7 +901,7 @@ void SwUndoAttr::Undo( SwUndoIter& rUndoIter ) const bool bToLast = (1 == m_AttrSet.Count()) && (RES_TXTATR_FIELD <= *m_AttrSet.GetRanges()) - && (*m_AttrSet.GetRanges() <= RES_TXTATR_HARDBLANK); + && (*m_AttrSet.GetRanges() <= RES_TXTATR_FTN); // restore old values m_pHistory->TmpRollback( pDoc, 0, !bToLast ); @@ -948,15 +950,15 @@ void SwUndoAttr::Repeat( SwUndoIter& rUndoIter ) // RefMarks are not repeat capable if ( SFX_ITEM_SET != m_AttrSet.GetItemState( RES_TXTATR_REFMARK, FALSE ) ) { - rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, - m_AttrSet, m_nInsertFlags ); + rUndoIter.GetDoc().InsertItemSet( *rUndoIter.pAktPam, + m_AttrSet, m_nInsertFlags ); } else if ( 1 < m_AttrSet.Count() ) { SfxItemSet aTmpSet( m_AttrSet ); aTmpSet.ClearItem( RES_TXTATR_REFMARK ); - rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, - aTmpSet, m_nInsertFlags ); + rUndoIter.GetDoc().InsertItemSet( *rUndoIter.pAktPam, + aTmpSet, m_nInsertFlags ); } rUndoIter.pLastUndoObj = this; } @@ -974,7 +976,7 @@ void SwUndoAttr::Redo( SwUndoIter& rUndoIter ) RedlineMode_t eOld = rDoc.GetRedlineMode(); rDoc.SetRedlineMode_intern(static_cast<RedlineMode_t>( eOld & ~nsRedlineMode_t::REDLINE_IGNORE)); - rDoc.Insert( rPam, m_AttrSet, m_nInsertFlags ); + rDoc.InsertItemSet( rPam, m_AttrSet, m_nInsertFlags ); if ( ULONG_MAX != m_nNodeIndex ) { @@ -995,7 +997,7 @@ void SwUndoAttr::Redo( SwUndoIter& rUndoIter ) } else { - rDoc.Insert( rPam, m_AttrSet, m_nInsertFlags ); + rDoc.InsertItemSet( rPam, m_AttrSet, m_nInsertFlags ); } rUndoIter.pLastUndoObj = 0; diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 458266bde6..1ebc3a084f 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -386,7 +386,7 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, // loesche jetzt noch den Text (alle Attribut-Aenderungen kommen in // die Undo-History pSttStr = (String*)new String( pSttTxtNd->GetTxt().Copy( nSttCntnt, nLen )); - pSttTxtNd->Erase( pStt->nContent, nLen ); + pSttTxtNd->EraseText( pStt->nContent, nLen ); if( pSttTxtNd->GetpSwpHints() ) pSttTxtNd->GetpSwpHints()->DeRegister(); @@ -422,7 +422,7 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, // die Undo-History pEndStr = (String*)new String( pEndTxtNd->GetTxt().Copy( 0, pEnd->nContent.GetIndex() )); - pEndTxtNd->Erase( aEndIdx, pEnd->nContent.GetIndex() ); + pEndTxtNd->EraseText( aEndIdx, pEnd->nContent.GetIndex() ); if( pEndTxtNd->GetpSwpHints() ) pEndTxtNd->GetpSwpHints()->DeRegister(); @@ -511,7 +511,7 @@ BOOL SwUndoDelete::CanGrouping( SwDoc* pDoc, const SwPaM& rDelPam ) nUChrPos++; } pSttStr->Insert( cDelChar, nUChrPos ); - pDelTxtNd->Erase( pStt->nContent, 1 ); + pDelTxtNd->EraseText( pStt->nContent, 1 ); bGroup = TRUE; return TRUE; @@ -711,7 +711,8 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) } if( pTxtNd ) { - pTxtNd->Insert( *pEndStr, aPos.nContent, INS_NOHINTEXPAND ); + pTxtNd->InsertText( *pEndStr, aPos.nContent, + IDocumentContentOperations::INS_NOHINTEXPAND ); // METADATA: restore pTxtNd->RestoreMetadata(m_pMetadataUndoEnd); } @@ -804,7 +805,8 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) // SectionNode-Modus und von oben nach unten selektiert: // -> im StartNode steht noch der Rest vom Join => loeschen aPos.nContent.Assign( pTxtNd, nSttCntnt ); - pTxtNd->Insert( *pSttStr, aPos.nContent, INS_NOHINTEXPAND ); + pTxtNd->InsertText( *pSttStr, aPos.nContent, + IDocumentContentOperations::INS_NOHINTEXPAND ); // METADATA: restore pTxtNd->RestoreMetadata(m_pMetadataUndoStart); } diff --git a/sw/source/core/undo/undo.src b/sw/source/core/undo/undo.src index 6437d9f603..2cf91da28b 100644 --- a/sw/source/core/undo/undo.src +++ b/sw/source/core/undo/undo.src @@ -54,7 +54,7 @@ String STR_SPLITNODE_UNDO }; String STR_MOVE_UNDO { - Text [ en-US ] = "Move: $1" ; + Text [ en-US ] = "Move" ; }; String STR_INSATTR_UNDO { @@ -612,7 +612,7 @@ String STR_CHART }; String STR_NOTE { - Text [ en-US ] = "note"; + Text [ en-US ] = "comment"; }; String STR_REFERENCE { diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index af12b42b5a..026e4112e8 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -330,7 +330,7 @@ void SwUndoSaveCntnt::MoveToUndoNds( SwPaM& rPaM, SwNodeIndex* pNodeIdx, } else { - rDoc.GetNodes().Move( rPaM, aPos, rNds, FALSE ); + rDoc.GetNodes().MoveRange( rPaM, aPos, rNds ); SwTxtNode* pTxtNd = aPos.nNode.GetNode().GetTxtNode(); if( pTxtNd ) // fuege einen Trenner fuer die Attribute ein ! @@ -350,7 +350,10 @@ void SwUndoSaveCntnt::MoveToUndoNds( SwPaM& rPaM, SwNodeIndex* pNodeIdx, ++aPos.nContent; } else - pTxtNd->Insert( ' ', aPos.nContent, INS_NOHINTEXPAND); + { + pTxtNd->InsertText( sal_Unicode(' '), aPos.nContent, + IDocumentContentOperations::INS_NOHINTEXPAND ); + } } } if( pEndNdIdx ) @@ -404,7 +407,7 @@ void SwUndoSaveCntnt::MoveFromUndoNds( SwDoc& rDoc, ULONG nNodeIdx, if( pTxtNd->GetTxt().Len() ) { GoInCntnt( aPaM, fnMoveBackward ); - pTxtNd->Erase( aPaM.GetPoint()->nContent, 1 ); + pTxtNd->EraseText( aPaM.GetPoint()->nContent, 1 ); } aPaM.SetMark(); @@ -413,7 +416,7 @@ void SwUndoSaveCntnt::MoveFromUndoNds( SwDoc& rDoc, ULONG nNodeIdx, _SaveRedlEndPosForRestore aRedlRest( rInsPos.nNode, rInsPos.nContent.GetIndex() ); - rNds.Move( aPaM, rInsPos, rDoc.GetNodes() ); + rNds.MoveRange( aPaM, rInsPos, rDoc.GetNodes() ); // noch den letzen Node loeschen. if( !aPaM.GetPoint()->nContent.GetIndex() || @@ -537,11 +540,12 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, SwTxtNode* pTxtNd = (SwTxtNode*)pFtnNd; if( !pHistory ) pHistory = new SwHistory; - SwTxtAttr* pFtnHnt = pTxtNd->GetTxtAttr( nFtnSttIdx ); + SwTxtAttr* const pFtnHnt = + pTxtNd->GetTxtAttrForCharAt( nFtnSttIdx ); ASSERT( pFtnHnt, "kein FtnAttribut" ); SwIndex aIdx( pTxtNd, nFtnSttIdx ); pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), false ); - pTxtNd->Erase( aIdx, 1 ); + pTxtNd->EraseText( aIdx, 1 ); } while( nPos-- && ( pFtnNd = &( pSrch = rFtnArr[ nPos ] )-> @@ -560,11 +564,12 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, SwTxtNode* pTxtNd = (SwTxtNode*)pFtnNd; if( !pHistory ) pHistory = new SwHistory; - SwTxtAttr* pFtnHnt = pTxtNd->GetTxtAttr( nFtnSttIdx ); + SwTxtAttr* const pFtnHnt = + pTxtNd->GetTxtAttrForCharAt( nFtnSttIdx ); ASSERT( pFtnHnt, "kein FtnAttribut" ); SwIndex aIdx( pTxtNd, nFtnSttIdx ); pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), false ); - pTxtNd->Erase( aIdx, 1 ); + pTxtNd->EraseText( aIdx, 1 ); } } } @@ -598,7 +603,8 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, if( !pHistory ) pHistory = new SwHistory; SwTxtNode* pTxtNd = pDoc->GetNodes()[ pAPos->nNode]->GetTxtNode(); - SwTxtAttr* pFlyHnt = pTxtNd->GetTxtAttr( pAPos->nContent.GetIndex()); + SwTxtAttr* const pFlyHnt = pTxtNd->GetTxtAttrForCharAt( + pAPos->nContent.GetIndex()); ASSERT( pFlyHnt, "kein FlyAttribut" ); pHistory->Add( pFlyHnt, 0, false ); // n wieder zurueck, damit nicht ein Format uebesprungen wird ! diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index a6a2d899cd..f0b302c12b 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -123,9 +123,9 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) { // es muss mindestens das Attribut im TextNode stehen SwCntntNode* pCNd = aAnchor.GetCntntAnchor()->nNode.GetNode().GetCntntNode(); - ASSERT( pCNd->IsTxtNode(), "Kein Textnode an dieser Position" ); - ((SwTxtNode*)pCNd)->InsertItem( SwFmtFlyCnt( - (SwFlyFrmFmt*)pFrmFmt ), nCntPos, nCntPos ); + ASSERT( pCNd->IsTxtNode(), "no Text Node at position." ); + SwFmtFlyCnt aFmt( pFrmFmt ); + static_cast<SwTxtNode*>(pCNd)->InsertItem( aFmt, nCntPos, nCntPos ); } pFrmFmt->MakeFrms(); @@ -199,14 +199,15 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc ) nCntPos = pPos->nContent.GetIndex(); SwTxtNode *pTxtNd = pDoc->GetNodes()[ pPos->nNode ]->GetTxtNode(); ASSERT( pTxtNd, "Kein Textnode gefunden" ); - SwTxtFlyCnt* pAttr = (SwTxtFlyCnt*)pTxtNd->GetTxtAttr( nCntPos ); + SwTxtFlyCnt* const pAttr = static_cast<SwTxtFlyCnt*>( + pTxtNd->GetTxtAttrForCharAt( nCntPos, RES_TXTATR_FLYCNT ) ); // Attribut steht noch im TextNode, loeschen if( pAttr && pAttr->GetFlyCnt().GetFrmFmt() == pFrmFmt ) { // Pointer auf 0, nicht loeschen ((SwFmtFlyCnt&)pAttr->GetFlyCnt()).SetFlyFmt(); SwIndex aIdx( pPos->nContent ); - pTxtNd->Erase( aIdx, 1 ); + pTxtNd->EraseText( aIdx, 1 ); } } else if( FLY_AUTO_CNTNT == nRndId ) @@ -558,18 +559,17 @@ void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter ) SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); -#ifdef DBG_UTIL + SwTxtAttr * pHnt = pTxtNode->GetTxtAttrForCharAt( + nIdx, RES_TXTATR_FLYCNT ); ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFrmFmt, "Wrong TxtFlyCnt-Hint." ); -#endif - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); // Die Verbindung ist geloest, jetzt muss noch das Attribut // vernichtet werden. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx ); } // Anker umsetzen @@ -580,8 +580,9 @@ void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter ) if( FLY_IN_CNTNT == aNewAnchor.GetAnchorId() ) { SwPosition* pPos = (SwPosition*)aNewAnchor.GetCntntAnchor(); - pPos->nNode.GetNode().GetTxtNode()->InsertItem( - SwFmtFlyCnt( (SwFlyFrmFmt*)pFrmFmt ), nOldCntnt, 0 ); + SwFmtFlyCnt aFmt( pFrmFmt ); + pPos->nNode.GetNode().GetTxtNode()->InsertItem( aFmt, + nOldCntnt, 0 ); } pFrmFmt->MakeFrms(); diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index e8a2259438..2b89cb1e7c 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -157,14 +157,15 @@ void lcl_SaveAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) // TextAttribut zerstoeren SwTxtNode *pTxtNd = pFmt->GetDoc()->GetNodes()[ rNodePos ]->GetTxtNode(); ASSERT( pTxtNd, "Kein Textnode gefunden" ); - SwTxtFlyCnt* pAttr = (SwTxtFlyCnt*)pTxtNd->GetTxtAttr( nCntntPos ); + SwTxtFlyCnt* pAttr = static_cast<SwTxtFlyCnt*>( + pTxtNd->GetTxtAttrForCharAt( nCntntPos, RES_TXTATR_FLYCNT )); // Attribut steht noch im TextNode, loeschen if( pAttr && pAttr->GetFlyCnt().GetFrmFmt() == pFmt ) { // Pointer auf 0, nicht loeschen ((SwFmtFlyCnt&)pAttr->GetFlyCnt()).SetFlyFmt(); SwIndex aIdx( pTxtNd, nCntntPos ); - pTxtNd->Erase( aIdx, 1 ); + pTxtNd->EraseText( aIdx, 1 ); } } else if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) @@ -198,9 +199,9 @@ void lcl_RestoreAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) { SwTxtNode *pTxtNd = aIdx.GetNode().GetTxtNode(); - ASSERT( pTxtNd, "Kein Textnode gefunden" ); - pTxtNd->InsertItem( SwFmtFlyCnt( (SwFrmFmt*)pFmt ), - nCntntPos, nCntntPos ); + ASSERT( pTxtNd, "no Text Node" ); + SwFmtFlyCnt aFmt( pFmt ); + pTxtNd->InsertItem( aFmt, nCntntPos, nCntntPos ); } } } diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index 9362785ce3..36fc9bde50 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -142,10 +142,13 @@ void SwUndoInsert::Init(const SwNodeIndex & rNd) // #111827# SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd, xub_StrLen nCnt, - xub_StrLen nL, BOOL bWDelim ) + xub_StrLen nL, + const IDocumentContentOperations::InsertFlags nInsertFlags, + BOOL bWDelim ) : SwUndo(UNDO_TYPING), pPos( 0 ), pTxt( 0 ), pRedlData( 0 ), nNode( rNd.GetIndex() ), nCntnt(nCnt), nLen(nL), bIsWordDelim( bWDelim ), bIsAppend( FALSE ) + , m_nInsertFlags(nInsertFlags) { Init(rNd); } @@ -155,6 +158,7 @@ SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd ) : SwUndo(UNDO_SPLITNODE), pPos( 0 ), pTxt( 0 ), pRedlData( 0 ), nNode( rNd.GetIndex() ), nCntnt(0), nLen(1), bIsWordDelim( FALSE ), bIsAppend( TRUE ) + , m_nInsertFlags(IDocumentContentOperations::INS_EMPTYEXPAND) { Init(rNd); } @@ -247,7 +251,7 @@ SwUndoInsert::~SwUndoInsert() { SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNd, "kein TextNode, aus dem geloescht werden soll" ); - pTxtNd->Erase( pPos->nContent ); + pTxtNd->EraseText( pPos->nContent ); pPos->nNode++; } pPos->nContent.Assign( 0, 0 ); @@ -295,15 +299,15 @@ void SwUndoInsert::Undo( SwUndoIter& rUndoIter ) aPaM.SetMark(); - if( pCNd->IsTxtNode() ) // Text !! + SwTxtNode * const pTxtNode( pCNd->GetTxtNode() ); + if ( pTxtNode ) { aPaM.GetPoint()->nContent -= nLen; if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() )) pTmpDoc->DeleteRedline( aPaM, true, USHRT_MAX ); RemoveIdxFromRange( aPaM, FALSE ); - pTxt = new String( ((SwTxtNode*)pCNd)->GetTxt().Copy( - nCntnt-nLen, nLen ) ); - ((SwTxtNode*)pCNd)->Erase( aPaM.GetPoint()->nContent, nLen ); + pTxt = new String( pTxtNode->GetTxt().Copy(nCntnt-nLen, nLen) ); + pTxtNode->EraseText( aPaM.GetPoint()->nContent, nLen ); } else // ansonsten Grafik/OLE/Text/... { @@ -379,9 +383,10 @@ void SwUndoInsert::Redo( SwUndoIter& rUndoIter ) if( pTxt ) { - ASSERT( pCNd->IsTxtNode(), "wo ist mein Textnode ??" ); - ((SwTxtNode*)pCNd)->Insert( *pTxt, pPam->GetMark()->nContent, - INS_EMPTYEXPAND ); + SwTxtNode *const pTxtNode = pCNd->GetTxtNode(); + ASSERT( pTxtNode, "where is my textnode ?" ); + pTxtNode->InsertText( *pTxt, pPam->GetMark()->nContent, + m_nInsertFlags ); DELETEZ( pTxt ); } else @@ -445,7 +450,8 @@ void SwUndoInsert::Repeat( SwUndoIter& rUndoIter ) String aTxt( ((SwTxtNode*)pCNd)->GetTxt() ); BOOL bGroupUndo = rDoc.DoesGroupUndo(); rDoc.DoGroupUndo( FALSE ); - rDoc.Insert( *rUndoIter.pAktPam, aTxt.Copy( nCntnt - nLen, nLen ), true); + rDoc.InsertString( *rUndoIter.pAktPam, + aTxt.Copy( nCntnt - nLen, nLen ) ); rDoc.DoGroupUndo( bGroupUndo ); } break; @@ -712,7 +718,7 @@ void _UnReplaceData::Undo( SwUndoIter& rIter ) SwIndex aIdx( pNd, m_nSttCnt ); if( m_nSttNd == m_nEndNd ) { - pNd->Erase( aIdx, m_sIns.Len() ); + pNd->EraseText( aIdx, m_sIns.Len() ); } else { @@ -741,7 +747,9 @@ void _UnReplaceData::Undo( SwUndoIter& rIter ) } if( m_sOld.Len() ) - pNd->Insert( m_sOld, aIdx ); + { + pNd->InsertText( m_sOld, aIdx ); + } if( pHistory ) { @@ -813,7 +821,7 @@ void _UnReplaceData::Redo( SwUndoIter& rIter ) delete pHistory, pHistory = 0; } - rDoc.Replace( rPam, m_sIns, m_bRegExp ); + rDoc.ReplaceRange( rPam, m_sIns, m_bRegExp ); rPam.DeleteMark(); rDoc.DoUndo( bUndo ); } diff --git a/sw/source/core/undo/unmove.cxx b/sw/source/core/undo/unmove.cxx index 0482e59233..a7491da0c8 100644 --- a/sw/source/core/undo/unmove.cxx +++ b/sw/source/core/undo/unmove.cxx @@ -207,7 +207,9 @@ void SwUndoMove::Undo( SwUndoIter& rUndoIter ) SwNodeRange aRg( aIdx, aIdx ); aRg.aEnd = nDestEndNode; aIdx = nInsPosNode; - if( !pDoc->Move( aRg, aIdx, IDocumentContentOperations::DOC_MOVEDEFAULT ) ) + bool bSuccess = pDoc->MoveNodeRange( aRg, aIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT ); + if (!bSuccess) break; } else @@ -231,7 +233,10 @@ void SwUndoMove::Undo( SwUndoIter& rUndoIter ) ((SwTxtNode*)pCNd)->ClearSwpHintsArr( false ); // an der InsertPos erstmal alle Attribute entfernen, - if( !pDoc->Move( aPam, aPos, ( bMoveRedlines ? IDocumentContentOperations::DOC_MOVEREDLINES : IDocumentContentOperations::DOC_MOVEDEFAULT ) ) ) + const bool bSuccess = pDoc->MoveRange( aPam, aPos, (bMoveRedlines) + ? IDocumentContentOperations::DOC_MOVEREDLINES + : IDocumentContentOperations::DOC_MOVEDEFAULT ); + if (!bSuccess) break; aPam.Exchange(); @@ -294,7 +299,9 @@ void SwUndoMove::Redo( SwUndoIter& rUndoIter ) { // nur ein Move mit SwRange SwNodeRange aRg( rNds, nSttNode, rNds, nEndNode ); - rDoc.Move( aRg, aIdx, ( bMoveRedlines ? IDocumentContentOperations::DOC_MOVEREDLINES : IDocumentContentOperations::DOC_MOVEDEFAULT ) ); + rDoc.MoveNodeRange( aRg, aIdx, (bMoveRedlines) + ? IDocumentContentOperations::DOC_MOVEREDLINES + : IDocumentContentOperations::DOC_MOVEDEFAULT ); } else { @@ -310,7 +317,8 @@ void SwUndoMove::Redo( SwUndoIter& rUndoIter ) BOOL bJoinTxt = aIdx.GetNode().IsTxtNode(); aIdx--; - rDoc.Move( aPam, aMvPos, IDocumentContentOperations::DOC_MOVEDEFAULT ); + rDoc.MoveRange( aPam, aMvPos, + IDocumentContentOperations::DOC_MOVEDEFAULT ); if( nSttNode != nEndNode && bJoinTxt ) { diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx index d445612539..d91db0515e 100644 --- a/sw/source/core/undo/unovwr.cxx +++ b/sw/source/core/undo/unovwr.cxx @@ -105,13 +105,14 @@ SwUndoOverwrite::SwUndoOverwrite( SwDoc* pDoc, SwPosition& rPos, BOOL bOldExpFlg = pTxtNd->IsIgnoreDontExpand(); pTxtNd->SetIgnoreDontExpand( TRUE ); - pTxtNd->Insert( cIns, rPos.nContent ); + pTxtNd->InsertText( cIns, rPos.nContent, + IDocumentContentOperations::INS_EMPTYEXPAND ); aInsStr.Insert( cIns ); if( !bInsChar ) { const SwIndex aTmpIndex( rPos.nContent, -2 ); - pTxtNd->Erase( aTmpIndex, 1 ); + pTxtNd->EraseText( aTmpIndex, 1 ); } pTxtNd->SetIgnoreDontExpand( bOldExpFlg ); @@ -143,7 +144,7 @@ BOOL SwUndoOverwrite::CanGrouping( SwDoc* pDoc, SwPosition& rPos, CharClass& rCC = GetAppCharClass(); // befrage das einzufuegende Charakter - if( ( CH_TXTATR_BREAKWORD == cIns && CH_TXTATR_INWORD == cIns ) || + if (( CH_TXTATR_BREAKWORD == cIns || CH_TXTATR_INWORD == cIns ) || rCC.isLetterNumeric( String( cIns ), 0 ) != rCC.isLetterNumeric( aInsStr, aInsStr.Len()-1 ) ) return FALSE; @@ -183,13 +184,14 @@ BOOL SwUndoOverwrite::CanGrouping( SwDoc* pDoc, SwPosition& rPos, BOOL bOldExpFlg = pDelTxtNd->IsIgnoreDontExpand(); pDelTxtNd->SetIgnoreDontExpand( TRUE ); - pDelTxtNd->Insert( cIns, rPos.nContent ); + pDelTxtNd->InsertText( cIns, rPos.nContent, + IDocumentContentOperations::INS_EMPTYEXPAND ); aInsStr.Insert( cIns ); if( !bInsChar ) { const SwIndex aTmpIndex( rPos.nContent, -2 ); - pDelTxtNd->Erase( aTmpIndex, 1 ); + pDelTxtNd->EraseText( aTmpIndex, 1 ); } pDelTxtNd->SetIgnoreDontExpand( bOldExpFlg ); @@ -225,7 +227,7 @@ void SwUndoOverwrite::Undo( SwUndoIter& rUndoIter ) if( aInsStr.Len() > aDelStr.Len() ) { rIdx += aDelStr.Len(); - pTxtNd->Erase( rIdx, aInsStr.Len() - aDelStr.Len() ); + pTxtNd->EraseText( rIdx, aInsStr.Len() - aDelStr.Len() ); rIdx = nSttCntnt; } @@ -242,9 +244,9 @@ void SwUndoOverwrite::Undo( SwUndoIter& rUndoIter ) { // einzeln, damit die Attribute stehen bleiben !!! *pTmpStr = aDelStr.GetChar( n ); - pTxtNd->Insert( aTmpStr, rIdx /*???, SETATTR_NOTXTATRCHR*/ ); + pTxtNd->InsertText( aTmpStr, rIdx /*???, SETATTR_NOTXTATRCHR*/ ); rIdx -= 2; - pTxtNd->Erase( rIdx, 1 ); + pTxtNd->EraseText( rIdx, 1 ); rIdx += 2; } pTxtNd->SetIgnoreDontExpand( bOldExpFlg ); @@ -312,11 +314,12 @@ void SwUndoOverwrite::Redo( SwUndoIter& rUndoIter ) for( xub_StrLen n = 0; n < aInsStr.Len(); n++ ) { // einzeln, damit die Attribute stehen bleiben !!! - pTxtNd->Insert( aInsStr.GetChar( n ), rIdx ); + pTxtNd->InsertText( aInsStr.GetChar( n ), rIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); if( n < aDelStr.Len() ) { rIdx -= 2; - pTxtNd->Erase( rIdx, 1 ); + pTxtNd->EraseText( rIdx, 1 ); rIdx += n+1 < aDelStr.Len() ? 2 : 1; } } diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx index b43ec4eeb2..76f8efa306 100644 --- a/sw/source/core/undo/unsect.cxx +++ b/sw/source/core/undo/unsect.cxx @@ -192,7 +192,9 @@ void SwUndoInsSection::Redo( SwUndoIter& rUndoIter ) rBase, pAttr, TRUE ); } else - rDoc.Insert( *rUndoIter.pAktPam, *pSection, pAttr, TRUE ); + { + rDoc.InsertSwSection( *rUndoIter.pAktPam, *pSection, pAttr, true ); + } if( pHistory ) pHistory->SetTmpEnd( pHistory->Count() ); @@ -236,7 +238,10 @@ void SwUndoInsSection::Repeat( SwUndoIter& rUndoIter ) rBase, pAttr, TRUE ); } else - rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, *pSection, pAttr ); + { + rUndoIter.GetDoc().InsertSwSection( *rUndoIter.pAktPam, + *pSection, pAttr ); + } } @@ -255,7 +260,7 @@ void SwUndoInsSection::Join( SwDoc& rDoc, ULONG nNode ) if( pHistory ) { SwIndex aCntIdx( pTxtNd, 0 ); - pTxtNd->RstAttr( aCntIdx, pTxtNd->GetTxt().Len() ); + pTxtNd->RstAttr( aCntIdx, pTxtNd->Len(), 0, 0, true ); } } diff --git a/sw/source/core/undo/unsort.cxx b/sw/source/core/undo/unsort.cxx index a368362173..e5f4a1c25c 100644 --- a/sw/source/core/undo/unsort.cxx +++ b/sw/source/core/undo/unsort.cxx @@ -166,7 +166,8 @@ void SwUndoSort::Undo( SwUndoIter& rIter) { SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i ); SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 ); - rDoc.Move(aRg, aIdx, IDocumentContentOperations::DOC_MOVEDEFAULT); + rDoc.MoveNodeRange(aRg, aIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT); } // Indixes loeschen aIdxList.DeleteAndDestroy(0, aIdxList.Count()); @@ -238,7 +239,8 @@ void SwUndoSort::Redo( SwUndoIter& rIter) { SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i); SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 ); - rDoc.Move(aRg, aIdx, IDocumentContentOperations::DOC_MOVEDEFAULT); + rDoc.MoveNodeRange(aRg, aIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT); } // Indixes loeschen aIdxList.DeleteAndDestroy(0, aIdxList.Count()); diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 3669d2adbf..2782a408ac 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -590,7 +590,7 @@ SwTableNode* SwNodes::UndoTableToText( ULONG nSttNd, ULONG nEndNd, ASSERT( pTxtNd, "Wo ist der TextNode geblieben?" ); SwIndex aCntPos( pTxtNd, pSave->m_nCntnt - 1 ); - pTxtNd->Erase( aCntPos, 1 ); + pTxtNd->EraseText( aCntPos, 1 ); SwCntntNode* pNewNd = pTxtNd->SplitCntntNode( SwPosition( aSttIdx, aCntPos )); if( aBkmkArr.Count() ) @@ -2120,7 +2120,7 @@ CHECKTABLE(pTblNd->GetTable()) pTxtNd->RstAttr( aTmpIdx, pTxtNd->GetTxt().Len() - nDelPos + 1 ); // das Trennzeichen loeschen - pTxtNd->Erase( aTmpIdx, 1 ); + pTxtNd->EraseText( aTmpIdx, 1 ); } // delete pUndo; DUMPDOC( &rDoc, String( "d:\\tmp\\tab_") + String( aNewSttNds.Count() - i ) + @@ -2197,7 +2197,7 @@ void SwUndoTblMerge::MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& r SwUndoMove* pUndo = new SwUndoMove( pDoc, rRg, rPos ); sal_Bool bDoesUndo = pDoc->DoesUndo(); pDoc->DoUndo( sal_False ); - pDoc->Move( rRg, rPos, pSaveTbl->IsNewModel() ? + pDoc->MoveNodeRange( rRg, rPos, (pSaveTbl->IsNewModel()) ? IDocumentContentOperations::DOC_NO_DELFRMS : IDocumentContentOperations::DOC_MOVEDEFAULT ); if( bDoesUndo ) @@ -2348,8 +2348,9 @@ void SwUndoTblNumFmt::Undo( SwUndoIter& rIter ) SwIndex aIdx( pTxtNd, 0 ); if( aStr.Len() ) { - pTxtNd->Erase( aIdx ); - pTxtNd->Insert( aStr, aIdx, INS_NOHINTEXPAND ); + pTxtNd->EraseText( aIdx ); + pTxtNd->InsertText( aStr, aIdx, + IDocumentContentOperations::INS_NOHINTEXPAND ); } } diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index 05f7afb921..e6aad03906 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -158,7 +158,9 @@ SwUndoInserts::~SwUndoInserts() SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNd, "kein TextNode, aus dem geloescht werden soll" ); if( pTxtNd ) // Robust - pTxtNd->Erase( pPos->nContent ); + { + pTxtNd->EraseText( pPos->nContent ); + } pPos->nNode++; } pPos->nContent.Assign( 0, 0 ); @@ -247,7 +249,6 @@ void SwUndoInserts::Undo( SwUndoIter& rUndoIter ) } else { - pDoc->RstTxtAttrs( *pPam, TRUE ); if( bJoinNext && pTxtNode->CanJoinNext()) { { @@ -256,6 +257,9 @@ void SwUndoInserts::Undo( SwUndoIter& rUndoIter ) } pTxtNode->JoinNext(); } + // reset all text attributes in the paragraph! + pTxtNode->RstAttr( SwIndex(pTxtNode, 0), pTxtNode->Len(), + 0, 0, true ); // setze alle Attribute im Node zurueck pTxtNode->ResetAllAttr(); @@ -288,7 +292,6 @@ void SwUndoInserts::Redo( SwUndoIter& rUndoIter ) pSavTxtFmtColl = ((SwTxtNode*)pCNd)->GetTxtColl(); pHistory->SetTmpEnd( nSetPos ); - pHistory->TmpRollback( pDoc, 0, false ); // alte Anfangs-Position fuers Rollback zurueckholen if( ( nSttNode != nEndNode || nSttCntnt != nEndCntnt ) && pPos ) @@ -346,7 +349,7 @@ void SwUndoInserts::Repeat( SwUndoIter& rUndoIter ) SwPaM aPam( *rUndoIter.pAktPam->GetPoint() ); SetPaM( aPam ); - aPam.GetDoc()->Copy( aPam, *rUndoIter.pAktPam->GetPoint(), false ); + aPam.GetDoc()->CopyRange( aPam, *rUndoIter.pAktPam->GetPoint(), false ); rUndoIter.pLastUndoObj = this; } diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index ca27062014..11ea44de5f 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -46,6 +46,8 @@ #include <comcore.hrc> #endif #include <undobj.hxx> +#include <docsh.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::lang; @@ -280,6 +282,23 @@ void SwXBookmark::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) } } +// MetadatableMixin +::sfx2::Metadatable* SwXBookmark::GetCoreObject() +{ + return dynamic_cast< ::sfx2::Metadatable* >( GetBookmark() ); +} + +uno::Reference<frame::XModel> SwXBookmark::GetModel() +{ + if (GetDoc()) + { + SwDocShell const * const pShell( GetDoc()->GetDocShell() ); + return (pShell) ? pShell->GetModel() : 0; + } + return 0; +} + + uno::Reference< beans::XPropertySetInfo > SwXBookmark::getPropertySetInfo(void) throw( uno::RuntimeException ) { diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 3c9ec39343..e4f7138e06 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -76,8 +76,10 @@ #include <slist> #include <iterator> +#include "unometa.hxx" #include "docsh.hxx" + using ::rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::document; @@ -174,11 +176,11 @@ const ProvNamesId_Type __FAR_DATA aProvNamesId[] = { "com.sun.star.text.TextField.Bibliography", SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY }, { "com.sun.star.text.TextField.CombinedCharacters", SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS }, { "com.sun.star.text.TextField.DropDown", SW_SERVICE_FIELDTYPE_DROPDOWN }, + { "com.sun.star.text.textfield.MetadataField", SW_SERVICE_FIELDTYPE_METAFIELD }, { "", SW_SERVICE_FIELDTYPE_DUMMY_4 }, { "", SW_SERVICE_FIELDTYPE_DUMMY_5 }, { "", SW_SERVICE_FIELDTYPE_DUMMY_6 }, { "", SW_SERVICE_FIELDTYPE_DUMMY_7 }, - { "", SW_SERVICE_FIELDTYPE_DUMMY_8 }, { "com.sun.star.text.FieldMaster.User", SW_SERVICE_FIELDMASTER_USER }, { "com.sun.star.text.FieldMaster.DDE", SW_SERVICE_FIELDMASTER_DDE }, { "com.sun.star.text.FieldMaster.SetExpression", SW_SERVICE_FIELDMASTER_SET_EXP }, @@ -207,6 +209,7 @@ const ProvNamesId_Type __FAR_DATA aProvNamesId[] = { "com.sun.star.chart2.data.DataProvider", SW_SERVICE_CHART2_DATA_PROVIDER }, { "com.sun.star.text.Fieldmark", SW_SERVICE_TYPE_FIELDMARK }, { "com.sun.star.text.FormFieldmark", SW_SERVICE_TYPE_FORMFIELDMARK }, + { "com.sun.star.text.InContentMetadata", SW_SERVICE_TYPE_META }, // case-correct versions of the service names (see #i67811) { CSS_TEXT_TEXTFIELD_DATE_TIME, SW_SERVICE_FIELDTYPE_DATETIME }, @@ -604,6 +607,12 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 if( pDoc->GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) xRet = (cppu::OWeakObject*) pDoc->GetChartDataProvider( true /* create - if not yet available */ ); break; + case SW_SERVICE_TYPE_META: + xRet = static_cast< ::cppu::OWeakObject* >( new SwXMeta(pDoc) ); + break; + case SW_SERVICE_FIELDTYPE_METAFIELD: + xRet = static_cast< ::cppu::OWeakObject* >(new SwXMetaField(pDoc)); + break; default: throw uno::RuntimeException(); } @@ -889,10 +898,20 @@ SwXFrameEnumeration<T>::SwXFrameEnumeration(const SwDoc* const pDoc) const SwSpzFrmFmts* const pFmts = pDoc->GetSpzFrmFmts(); if(!pFmts->Count()) return; - const SwFrmFmt* const pFmtsEnd = (*pFmts)[pFmts->Count()]; + // --> OD 2009-09-10 #i104937# +// const SwFrmFmt* const pFmtsEnd = (*pFmts)[pFmts->Count()]; + const USHORT nSize = pFmts->Count(); + // <-- ::std::insert_iterator<frmcontainer_t> pInserter = ::std::insert_iterator<frmcontainer_t>(m_aFrames, m_aFrames.begin()); - for(SwFrmFmt* pFmt = (*pFmts)[0]; pFmt < pFmtsEnd; ++pFmt) + // --> OD 2009-09-10 #i104937# + SwFrmFmt* pFmt( 0 ); + for( USHORT i = 0; i < nSize; ++i ) +// for(SwFrmFmt* pFmt = (*pFmts)[0]; pFmt < pFmtsEnd; ++pFmt) + // <-- { + // --> OD 2009-09-10 #i104937# + pFmt = (*pFmts)[i]; + // <-- if(pFmt->Which() != RES_FLYFRMFMT) continue; const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index a6ef83aea1..b3d17e83a4 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -343,20 +343,9 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry { if( pAny ) { - const SwFmtFld& rFld = pTxtAttr->GetFld(); - SwClientIter aIter(*rFld.GetFld()->GetTyp()); - SwXTextField* pFld = 0; - SwXTextField* pTemp = (SwXTextField*)aIter.First(TYPE(SwXTextField)); - while(pTemp && !pFld) - { - if(pTemp->GetFldFmt() == &rFld) - pFld = pTemp; - pTemp = (SwXTextField*)aIter.Next(); - } - if(!pFld) - pFld = new SwXTextField( rFld, rPam.GetDoc()); - uno::Reference< XTextField > xRet = pFld; - pAny->setValue(&xRet, ::getCppuType((uno::Reference<XTextField>*)0)); + SwXTextField* pField = CreateSwXTextField(*rPam.GetDoc(), + pTxtAttr->GetFld()); + *pAny <<= uno::Reference< XTextField >( pField ); } } else @@ -943,25 +932,37 @@ void InsertFile(SwUnoCrsr* pUnoCrsr, // paragraph breaks at those positions by calling SplitNode sal_Bool DocInsertStringSplitCR( SwDoc &rDoc, - const SwPaM &rNewCursor, const String &rText ) + const SwPaM &rNewCursor, const String &rText, + const bool bForceExpandHints ) { sal_Bool bOK = sal_True; + const enum IDocumentContentOperations::InsertFlags nInsertFlags = + (bForceExpandHints) + ? static_cast<IDocumentContentOperations::InsertFlags>( + IDocumentContentOperations::INS_FORCEHINTEXPAND | + IDocumentContentOperations::INS_EMPTYEXPAND) + : IDocumentContentOperations::INS_EMPTYEXPAND; + OUString aTxt; xub_StrLen nStartIdx = 0; - xub_StrLen nMaxLength = STRING_LEN; - SwTxtNode* pTxtNd = rNewCursor.GetPoint()->nNode.GetNode().GetTxtNode(); - if( pTxtNd ) - nMaxLength = STRING_LEN - pTxtNd->GetTxt().Len(); + SwTxtNode* const pTxtNd = + rNewCursor.GetPoint()->nNode.GetNode().GetTxtNode(); + const xub_StrLen nMaxLength = ( pTxtNd ) + ? STRING_LEN - pTxtNd->GetTxt().Len() + : STRING_LEN; xub_StrLen nIdx = rText.Search( '\r', nStartIdx ); if( ( nIdx == STRING_NOTFOUND && nMaxLength < rText.Len() ) || ( nIdx != STRING_NOTFOUND && nMaxLength < nIdx ) ) + { nIdx = nMaxLength; + } while (nIdx != STRING_NOTFOUND ) { DBG_ASSERT( nIdx - nStartIdx >= 0, "index negative!" ); aTxt = rText.Copy( nStartIdx, nIdx - nStartIdx ); - if (aTxt.getLength() && !rDoc.Insert( rNewCursor, aTxt, true )) + if (aTxt.getLength() && + !rDoc.InsertString( rNewCursor, aTxt, nInsertFlags )) { DBG_ERROR( "Doc->Insert(Str) failed." ); bOK = sal_False; @@ -975,7 +976,8 @@ sal_Bool DocInsertStringSplitCR( nIdx = rText.Search( '\r', nStartIdx ); } aTxt = rText.Copy( nStartIdx ); - if (aTxt.getLength() && !rDoc.Insert( rNewCursor, aTxt, true )) + if (aTxt.getLength() && + !rDoc.InsertString( rNewCursor, aTxt, nInsertFlags )) { DBG_ERROR( "Doc->Insert(Str) failed." ); bOK = sal_False; diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 7269af7d71..0abfc6844e 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -1297,20 +1297,25 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( + nIdx, RES_TXTATR_FLYCNT ); DBG_ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); DBG_ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFmt, "Wrong TxtFlyCnt-Hint." ); - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()) + .SetFlyFmt(); //The connection is removed now the attribute can be deleted. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( + RES_TXTATR_FLYCNT, nIdx ); //create a new one SwTxtNode *pNd = pInternalPam->GetNode()->GetTxtNode(); - DBG_ASSERT( pNd, "Crsr steht nicht auf TxtNode." ); - pNd->InsertItem( SwFmtFlyCnt( pFmt ), - pInternalPam->GetPoint()->nContent.GetIndex(), 0 ); + DBG_ASSERT( pNd, "Cursor not at TxtNode." ); + SwFmtFlyCnt aFmt( pFmt ); + pNd->InsertItem(aFmt, pInternalPam->GetPoint() + ->nContent.GetIndex(), 0 ); } else { @@ -1379,15 +1384,18 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( + nIdx, RES_TXTATR_FLYCNT ); DBG_ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); DBG_ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFlyFmt, "Wrong TxtFlyCnt-Hint." ); - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()) + .SetFlyFmt(); //The connection is removed now the attribute can be deleted. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes(RES_TXTATR_FLYCNT, nIdx); } else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor && FLY_PAGE == eOldAnchorId ) @@ -1418,8 +1426,9 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A //the RES_TXTATR_FLYCNT needs to be added now SwTxtNode *pNd = aPam.GetNode()->GetTxtNode(); DBG_ASSERT( pNd, "Crsr is not in a TxtNode." ); - pNd->InsertItem( SwFmtFlyCnt( pFlyFmt ), - aPam.GetPoint()->nContent.GetIndex(), 0 ); + SwFmtFlyCnt aFmt( pFlyFmt ); + pNd->InsertItem(aFmt, + aPam.GetPoint()->nContent.GetIndex(), 0 ); //aPam.GetPoint()->nContent--; } @@ -2124,8 +2133,10 @@ void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange) pDoc = pText->GetDoc(); else if (!pDoc && pCursor) pDoc = pCursor->GetDoc(); - else if ( !pDoc && pPortion && pPortion->GetCrsr() ) - pDoc = pPortion->GetCrsr()->GetDoc(); + else if ( !pDoc && pPortion && pPortion->GetCursor() ) + { + pDoc = pPortion->GetCursor()->GetDoc(); + } } @@ -2213,7 +2224,7 @@ void SwXShape::dispose(void) throw( uno::RuntimeException ) const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode(); const xub_StrLen nIdx = rPos.nContent.GetIndex(); - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx ); } else pFmt->GetDoc()->DelLayoutFmt( pFmt ); diff --git a/sw/source/core/unocore/unoevent.cxx b/sw/source/core/unocore/unoevent.cxx index 2351540b6e..cfec12bfb7 100644 --- a/sw/source/core/unocore/unoevent.cxx +++ b/sw/source/core/unocore/unoevent.cxx @@ -73,93 +73,6 @@ const sal_Char sAPI_SwHyperlinkEventDescriptor[] = const sal_Char sAPI_SwAutoTextEventDescriptor[] = "SwAutoTextEventDescriptor"; - -// // -// // tables of all known events handled by this class -// // - -// // careful: keep aKnownEventIDs and aKnownEventNames in sync! - -// const USHORT aKnownEventIDs[] = -// { -// SW_EVENT_OBJECT_SELECT, -// SW_EVENT_START_INS_GLOSSARY, -// SW_EVENT_END_INS_GLOSSARY, -// SW_EVENT_MAIL_MERGE, -// SW_EVENT_FRM_KEYINPUT_ALPHA, -// SW_EVENT_FRM_KEYINPUT_NOALPHA, -// SW_EVENT_FRM_RESIZE, -// SW_EVENT_FRM_MOVE, -// SW_EVENT_PAGE_COUNT, -// SFX_EVENT_MOUSEOVER_OBJECT, -// SFX_EVENT_MOUSECLICK_OBJECT, -// SFX_EVENT_MOUSEOUT_OBJECT, -// SFX_EVENT_OPENDOC, -// SFX_EVENT_CLOSEDOC, -// SFX_EVENT_STARTAPP, -// SFX_EVENT_CLOSEAPP, -// SFX_EVENT_CREATEDOC, -// SFX_EVENT_SAVEDOC, -// SFX_EVENT_SAVEASDOC, -// SFX_EVENT_ACTIVATEDOC, -// SFX_EVENT_DEACTIVATEDOC, -// SFX_EVENT_PRINTDOC, -// SFX_EVENT_ONERROR, -// SFX_EVENT_LOADFINISHED, -// SFX_EVENT_SAVEFINISHED, -// SFX_EVENT_MODIFYCHANGED, -// SFX_EVENT_PREPARECLOSEDOC, -// SFX_EVENT_NEWMESSAGE, -// SFX_EVENT_TOGGLEFULLSCREENMODE, -// SFX_EVENT_SAVEDOCDONE, -// SFX_EVENT_SAVEASDOCDONE, -// SVX_EVENT_IMAGE_LOAD, -// SVX_EVENT_IMAGE_ABORT, -// SVX_EVENT_IMAGE_ERROR, -// 0 -// }; - -// const sal_Char* aKnownEventNames[] = -// { -// "OnSelect", // SW_EVENT_OBJECT_SELECT -// "OnInsertStart", // SW_EVENT_START_INS_GLOSSARY -// "OnInsertDone", // SW_EVENT_END_INS_GLOSSARY -// "OnMailMerge", // SW_EVENT_MAIL_MERGE -// "OnAlphaCharInput", // SW_EVENT_FRM_KEYINPUT_ALPHA -// "OnNonAlphaCharInput", // SW_EVENT_FRM_KEYINPUT_NOALPHA -// "OnResize", // SW_EVENT_FRM_RESIZE -// "OnMove", // SW_EVENT_FRM_MOVE -// "PageCountChange", // SW_EVENT_PAGE_COUNT -// "OnMouseOver", // SFX_EVENT_MOUSEOVER_OBJECT -// "OnClick", // SFX_EVENT_MOUSECLICK_OBJECT -// "OnMouseOut", // SFX_EVENT_MOUSEOUT_OBJECT -// "OnLoad", // SFX_EVENT_OPENDOC, -// "OnUnload", // SFX_EVENT_CLOSEDOC, -// "OnStartApp", // SFX_EVENT_STARTAPP, -// "OnCloseApp", // SFX_EVENT_CLOSEAPP, -// "OnNew", // SFX_EVENT_CREATEDOC, -// "OnSave", // SFX_EVENT_SAVEDOC, -// "OnSaveAs", // SFX_EVENT_SAVEASDOC, -// "OnFocus", // SFX_EVENT_ACTIVATEDOC, -// "OnUnfocus", // SFX_EVENT_DEACTIVATEDOC, -// "OnPrint", // SFX_EVENT_PRINTDOC, -// "OnError", // SFX_EVENT_ONERROR, -// "OnLoadFinished", // SFX_EVENT_LOADFINISHED, -// "OnSaveFinished", // SFX_EVENT_SAVEFINISHED, -// "OnModifyChanged", // SFX_EVENT_MODIFYCHANGED, -// "OnPrepareUnload", // SFX_EVENT_PREPARECLOSEDOC, -// "OnNewMail", // SFX_EVENT_NEWMESSAGE, -// "OnToggleFullscreen", // SFX_EVENT_TOGGLEFULLSCREENMODE, -// "OnSaveDone", // SFX_EVENT_SAVEDOCDONE, -// "OnSaveAsDone", // SFX_EVENT_SAVEASDOCDONE, -// "OnLoadError", // SVX_EVENT_IMAGE_LOAD, -// "OnLoadCancel", // SVX_EVENT_IMAGE_ABORT, -// "OnLoadDone", // SVX_EVENT_IMAGE_ERROR, - -// NULL -// }; - - // // tables of allowed events for specific objects // @@ -229,40 +142,6 @@ const struct SvEventDescription aFrameStyleEvents[] = { 0, NULL } }; -const struct SvEventDescription aDocumentEvents[] = -{ - { SFX_EVENT_STARTAPP, "OnStartApp" }, - { SFX_EVENT_CLOSEAPP, "OnCloseApp" }, - { SFX_EVENT_CREATEDOC, "OnNew" }, - { SFX_EVENT_OPENDOC, "OnLoad" }, - { SFX_EVENT_SAVEDOC, "OnSave" }, - { SFX_EVENT_SAVEASDOC, "OnSaveAs" }, -// ??? cf. SAVEDOCDONE, SAVEASDOCDONE - { SFX_EVENT_SAVEFINISHED, "OnSaveFinished" }, - { SFX_EVENT_CLOSEDOC, "OnUnload" }, - { SFX_EVENT_ACTIVATEDOC, "OnFocus" }, - { SFX_EVENT_DEACTIVATEDOC, "OnUnfocus" }, - { SFX_EVENT_ONERROR, "OnError" }, - { SFX_EVENT_NEWMESSAGE, "OnNewMail" }, - { SFX_EVENT_PRINTDOC, "OnPrint" }, - { SW_EVENT_MAIL_MERGE, "OnMailMerge" }, - { SW_EVENT_PAGE_COUNT, "PageCountChange" }, - { SW_EVENT_FIELD_MERGE, "OnFieldMerge" }, - { SW_EVENT_FIELD_MERGE_FINISHED, "OnFieldMergeFinished" }, -// SFX_EVENT_LOADFINISHED, -// SFX_EVENT_MODIFYCHANGED, -// SFX_EVENT_PREPARECLOSEDOC, -// SFX_EVENT_TOGGLEFULLSCREENMODE, -// SFX_EVENT_SAVEDOCDONE, -// SFX_EVENT_SAVEASDOCDONE, - - { 0, NULL } -}; - - - - - // // SwHyperlinkEventDescriptor // diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 778b48294c..f8dc8e5cce 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -94,6 +94,7 @@ #include <textapi.hxx> #include <svx/outliner.hxx> #include <docsh.hxx> +#include <fmtmeta.hxx> // MetaFieldManager using ::rtl::OUString; using namespace ::com::sun::star; @@ -371,7 +372,7 @@ USHORT lcl_GetPropertyMapOfService( USHORT nServiceId ) case SW_SERVICE_FIELDTYPE_DUMMY_5: case SW_SERVICE_FIELDTYPE_DUMMY_6: case SW_SERVICE_FIELDTYPE_DUMMY_7: - case SW_SERVICE_FIELDTYPE_DUMMY_8: nRet = PROPERTY_MAP_FLDTYP_DUMMY_0; break; + nRet = PROPERTY_MAP_FLDTYP_DUMMY_0; break; case SW_SERVICE_FIELDMASTER_USER: nRet = PROPERTY_MAP_FLDMSTR_USER; break; case SW_SERVICE_FIELDMASTER_DDE: nRet = PROPERTY_MAP_FLDMSTR_DDE; break; case SW_SERVICE_FIELDMASTER_SET_EXP: nRet = PROPERTY_MAP_FLDMSTR_SET_EXP; break; @@ -784,24 +785,12 @@ uno::Any SwXFieldMaster::getPropertyValue(const OUString& rPropertyName) } uno::Sequence<uno::Reference <text::XDependentTextField> > aRetSeq(aFldArr.Count()); uno::Reference<text::XDependentTextField>* pRetSeq = aRetSeq.getArray(); - SwXTextField* pInsert = 0; for(USHORT i = 0; i < aFldArr.Count(); i++) { pFld = aFldArr.GetObject(i); - SwXTextField* pTemp = (SwXTextField*)aIter.First(TYPE(SwXTextField)); - while(pTemp) - { - if(pTemp->GetFldFmt() == pFld) - { - pInsert = pTemp; - break; - } - pTemp = (SwXTextField*)aIter.Next(); - } - if(!pInsert) - pInsert = new SwXTextField( *pFld, GetDoc()); + SwXTextField * pInsert = CreateSwXTextField(*GetDoc(), *pFld); + pRetSeq[i] = uno::Reference<text::XDependentTextField>(pInsert); - pInsert = 0; } aRet <<= aRetSeq; } @@ -1079,6 +1068,26 @@ OUString SwXFieldMaster::LocalizeFormula( } return rFormula; } + + +SwXTextField * CreateSwXTextField(SwDoc & rDoc, SwFmtFld const& rFmt) +{ + SwClientIter aIter(*rFmt.GetFld()->GetTyp()); + SwXTextField * pField = 0; + SwXTextField * pTemp = + static_cast<SwXTextField*>(aIter.First( TYPE(SwXTextField) )); + while (pTemp) + { + if (pTemp->GetFldFmt() == &rFmt) + { + pField = pTemp; + break; + } + pTemp = static_cast<SwXTextField*>(aIter.Next()); + } + return pField ? pField : new SwXTextField( rFmt, &rDoc ); +} + /****************************************************************** * ******************************************************************/ @@ -1809,8 +1818,18 @@ void SwXTextField::attachToRange( SwTxtAttr* pTxtAttr = 0; if(aPam.HasMark()) pDoc->DeleteAndJoin(aPam); - pDoc->Insert(aPam, aFmt, 10000); - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( + + SwXTextCursor const*const pTextCursor( + dynamic_cast<SwXTextCursor*>(pCursor)); + const bool bForceExpandHints( (pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND + : nsSetAttrMode::SETATTR_DEFAULT; + + pDoc->InsertPoolItem(aPam, aFmt, nInsertFlags); + + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FIELD); // was passiert mit dem Update der Felder ? (siehe fldmgr.cxx) @@ -2915,6 +2934,22 @@ SwXFieldEnumeration::SwXFieldEnumeration(SwDoc* pDc) : } } } + // now handle meta-fields, which are not SwFields + const ::std::vector< uno::Reference<text::XTextField> > MetaFields( + pDc->GetMetaFieldManager().getMetaFields() ); + for (size_t i = 0; i < MetaFields.size(); ++i) + { + pItems[ nFillPos ] = MetaFields[i]; + nFillPos++; + + //FIXME UGLY + // enlarge sequence if necessary + if (aItems.getLength() == nFillPos) + { + aItems.realloc( 2 * aItems.getLength() ); + pItems = aItems.getArray(); + } + } // resize sequence to actual used size aItems.realloc( nFillPos ); } diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index bce475610d..68015384da 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -228,7 +228,7 @@ void SAL_CALL SwXFlatParagraph::changeText(::sal_Int32 nPos, ::sal_Int32 nLen, c mpTxtNode = pOldTxtNode; // setPropertyValue() modifies this. We restore the old state. IDocumentContentOperations* pIDCO = mpTxtNode->getIDocumentContentOperations(); - pIDCO->Replace( aPaM, aNewText, false ); + pIDCO->ReplaceRange( aPaM, aNewText, false ); mpTxtNode = 0; } diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index a519b9503e..37f53ade45 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2028,7 +2028,7 @@ void SwXFrame::dispose(void) throw( uno::RuntimeException ) const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode(); const xub_StrLen nIdx = rPos.nContent.GetIndex(); - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx ); } else pFmt->GetDoc()->DelLayoutFmt(pFmt); diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 11b004dd36..d7a974bfb1 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -254,11 +254,18 @@ void SwXFootnote::attachToRange(const uno::Reference< text::XTextRange > & xText SwFmtFtn aFootNote(m_bIsEndnote); if(m_sLabel.Len()) aFootNote.SetNumStr(m_sLabel); - SfxItemSet aSet(pNewDoc->GetAttrPool(), RES_TXTATR_FTN, RES_TXTATR_FTN, 0L); - aSet.Put(aFootNote); - SwXTextCursor::SetCrsrAttr(aPam, aSet, 0); - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( + SwXTextCursor const*const pTextCursor( + dynamic_cast<SwXTextCursor*>(pCursor)); + const bool bForceExpandHints( (pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND + : nsSetAttrMode::SETATTR_DEFAULT; + + pNewDoc->InsertPoolItem(aPam, aFootNote, nInsertFlags); + + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FTN ); if(pTxtAttr) diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index e2d0612eaa..41643101c1 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -1369,7 +1369,7 @@ void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno: aPam.GetPoint()->nContent++; //die alte Marke loeschen - m_pDoc->Delete(m_pTOXMark); + m_pDoc->DeleteTOXMark(m_pTOXMark); m_pTOXMark = 0; SwTxtAttr* pTxtAttr = 0; @@ -1379,13 +1379,14 @@ void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno: if( bInsAtPos ) { SwPaM aTmp( *pStt ); - m_pDoc->Insert( aTmp, aMark, 0 ); - pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( + m_pDoc->InsertPoolItem( aTmp, aMark, 0 ); + pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttrForCharAt( pStt->nContent.GetIndex()-1, RES_TXTATR_TOXMARK); } else if( *pEnd != *pStt ) { - m_pDoc->Insert( aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND ); + m_pDoc->InsertPoolItem( aPam, aMark, + nsSetAttrMode::SETATTR_DONTEXPAND ); pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( pStt->nContent, RES_TXTATR_TOXMARK); } @@ -1501,7 +1502,17 @@ void SwXDocumentIndexMark::attachToRange(const uno::Reference< text::XTextRange // deshalb hier ein Leerzeichen - ob das die ideale Loesung ist? if(!bMark && !aMark.GetAlternativeText().Len()) aMark.SetAlternativeText( String(' ') ); - pDoc->Insert(aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND); + + SwXTextCursor const*const pTextCursor( + dynamic_cast<SwXTextCursor*>(pCursor)); + const bool bForceExpandHints( (!bMark && pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND + | nsSetAttrMode::SETATTR_DONTEXPAND) + : nsSetAttrMode::SETATTR_DONTEXPAND; + + pDoc->InsertPoolItem(aPam, aMark, nInsertFlags); if( bMark && *aPam.GetPoint() > *aPam.GetMark()) aPam.Exchange(); @@ -1510,8 +1521,10 @@ void SwXDocumentIndexMark::attachToRange(const uno::Reference< text::XTextRange pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( aPam.GetPoint()->nContent, RES_TXTATR_TOXMARK ); else - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( + { + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_TOXMARK ); + } if(pTxtAttr) { @@ -1571,7 +1584,7 @@ void SwXDocumentIndexMark::dispose(void) throw( uno::RuntimeException ) SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); if(pType && m_pTOXMark) { - m_pDoc->Delete(m_pTOXMark); + m_pDoc->DeleteTOXMark(m_pTOXMark); } else throw uno::RuntimeException(); @@ -1681,7 +1694,7 @@ void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, aPam.GetPoint()->nContent++; //delete the old mark - pLocalDoc->Delete(m_pTOXMark); + pLocalDoc->DeleteTOXMark(m_pTOXMark); m_pTOXMark = 0; sal_Bool bInsAtPos = aMark.IsAlternativeText(); @@ -1692,13 +1705,14 @@ void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, if( bInsAtPos ) { SwPaM aTmp( *pStt ); - pLocalDoc->Insert( aTmp, aMark, 0 ); - pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( + pLocalDoc->InsertPoolItem( aTmp, aMark, 0 ); + pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttrForCharAt( pStt->nContent.GetIndex()-1, RES_TXTATR_TOXMARK ); } else if( *pEnd != *pStt ) { - pLocalDoc->Insert( aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND ); + pLocalDoc->InsertPoolItem( aPam, aMark, + nsSetAttrMode::SETATTR_DONTEXPAND ); pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( pStt->nContent, RES_TXTATR_TOXMARK ); } diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index a707da9679..4d535f1262 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -1649,6 +1649,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s {SW_PROP_NMID(UNO_NAME_IS_START), FN_UNO_IS_START, CPPU_E2T(CPPUTYPE_BOOLEAN), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0 }, //_REDLINE_PROPERTIES {SW_PROP_NMID(UNO_NAME_TEXT_PORTION_TYPE), FN_UNO_TEXT_PORTION_TYPE, CPPU_E2T(CPPUTYPE_OUSTRING), PropertyAttribute::READONLY, 0}, + {SW_PROP_NMID(UNO_NAME_META), FN_UNO_META, CPPU_E2T(CPPUTYPE_REFTEXTCNTNT), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0 }, {0,0,0,0,0,0} }; aMapEntriesArr[nPropertyId] = aTextPortionExtensionMap_Impl; @@ -2484,6 +2485,19 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s aMapEntriesArr[nPropertyId] = aChart2DataSequenceMap; } break; + case PROPERTY_MAP_METAFIELD: + { + static SfxItemPropertyMapEntry aMetaFieldMap[] = + { + { SW_PROP_NMID(UNO_NAME_NUMBER_FORMAT), 0, + CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE, 0 }, + { SW_PROP_NMID(UNO_NAME_IS_FIXED_LANGUAGE), 0, + CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, 0 }, + {0,0,0,0,0,0} + }; + aMapEntriesArr[nPropertyId] = aMetaFieldMap; + } + break; default: DBG_ERROR( "unexpected property map ID" ); @@ -3091,6 +3105,12 @@ const SfxItemPropertySet* SwUnoPropertyMapProvider::GetPropertySet( sal_uInt16 aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM; } break; + case PROPERTY_MAP_METAFIELD: + { + static SfxItemPropertySet aPROPERTY_MAP_METAFIELD(pEntries); + aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_METAFIELD; + } + break; } } return aPropertySetArr[nPropertyId]; diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index d03c6b67c8..cb327b1962 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -59,7 +59,6 @@ #include <swerror.h> #include <swtblfmt.hxx> #include <fmtruby.hxx> -#include <fmthbsh.hxx> #include <docsh.hxx> #include <docstyle.hxx> #include <charfmt.hxx> @@ -92,6 +91,7 @@ #include <unocoll.hxx> #include <unostyle.hxx> #include <unofield.hxx> +#include <unometa.hxx> #include <fmtanchr.hxx> #include <svx/flstitem.hxx> #include <svtools/ctrltool.hxx> @@ -118,11 +118,10 @@ #include <dcontact.hxx> #include <SwStyleNameMapper.hxx> #include <crsskip.hxx> -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif #include <memory> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -378,9 +377,11 @@ void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) SwTxtFmtColl *pLocal = pStyle->GetCollection(); UnoActionContext aAction(pDoc); pDoc->StartUndo( UNDO_START, NULL ); - FOREACHUNOPAM_START(&rPaM) - pDoc->SetTxtFmtColl(*PUNOPAM, pLocal); - FOREACHUNOPAM_END() + SwPaM *pTmpCrsr = &rPaM; + do { + pDoc->SetTxtFmtColl(*pTmpCrsr, pLocal); + pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != &rPaM ); pDoc->EndUndo( UNDO_END, NULL ); } else @@ -653,7 +654,7 @@ return bRet; /* -----------------30.06.98 08:39------------------- * * --------------------------------------------------*/ -SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional) +SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) { static const sal_uInt16 nMaxLookup = 1000; SwFmtColl *pFmt = 0; @@ -661,12 +662,13 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional) // if ( GetCrsrCnt() > nMaxLookup ) // return 0; sal_Bool bError = sal_False; - FOREACHUNOPAM_START(&rPam) + SwPaM *pTmpCrsr = &rPaM; + do { - ULONG nSttNd = PUNOPAM->GetMark()->nNode.GetIndex(), - nEndNd = PUNOPAM->GetPoint()->nNode.GetIndex(); - xub_StrLen nSttCnt = PUNOPAM->GetMark()->nContent.GetIndex(), - nEndCnt = PUNOPAM->GetPoint()->nContent.GetIndex(); + ULONG nSttNd = pTmpCrsr->GetMark()->nNode.GetIndex(); + ULONG nEndNd = pTmpCrsr->GetPoint()->nNode.GetIndex(); + xub_StrLen nSttCnt = pTmpCrsr->GetMark()->nContent.GetIndex(); + xub_StrLen nEndCnt = pTmpCrsr->GetPoint()->nContent.GetIndex(); if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt )) { @@ -680,7 +682,7 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional) break; } - const SwNodes& rNds = rPam.GetDoc()->GetNodes(); + const SwNodes& rNds = rPaM.GetDoc()->GetNodes(); for( ULONG n = nSttNd; n <= nEndNd; ++n ) { const SwTxtNode* pNd = rNds[ n ]->GetTxtNode(); @@ -699,7 +701,9 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional) } if(bError) break; - FOREACHUNOPAM_END() + + pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != &rPaM ); return bError ? 0 : pFmt; } @@ -851,7 +855,8 @@ SwXTextCursor::~SwXTextCursor() /*-- 09.12.98 14:19:18--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::DeleteAndInsert(const String& rText) +void SwXTextCursor::DeleteAndInsert(const String& rText, + const bool bForceExpandHints) { SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) @@ -870,10 +875,12 @@ void SwXTextCursor::DeleteAndInsert(const String& rText) } if(nTxtLen) { - if( !SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *_pStartCrsr, rText ) ) - { - DBG_ASSERT( sal_False, "Doc->Insert(Str) failed." ); - } + const bool bSuccess( + SwUnoCursorHelper::DocInsertStringSplitCR( + *pDoc, *_pStartCrsr, rText, bForceExpandHints ) ); + DBG_ASSERT( bSuccess, "Doc->Insert(Str) failed." ); + (void) bSuccess; + SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); _pStartCrsr->Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); } @@ -881,6 +888,82 @@ void SwXTextCursor::DeleteAndInsert(const String& rText) pDoc->EndUndo(UNDO_INSERT, NULL); } } + + +enum ForceIntoMetaMode { META_CHECK_BOTH, META_INIT_START, META_INIT_END }; + +sal_Bool lcl_ForceIntoMeta(SwPaM & rCursor, + uno::Reference<text::XText> const & xParentText, + const enum ForceIntoMetaMode eMode) +{ + sal_Bool bRet( sal_True ); // means not forced in META_CHECK_BOTH + SwXMeta const * const pXMeta( dynamic_cast<SwXMeta*>(xParentText.get()) ); + ASSERT(pXMeta, "no parent?"); + if (!pXMeta) + throw uno::RuntimeException(); + SwTxtNode * pTxtNode; + xub_StrLen nStart; + xub_StrLen nEnd; + const bool bSuccess( pXMeta->SetContentRange(pTxtNode, nStart, nEnd) ); + ASSERT(bSuccess, "no pam?"); + if (!bSuccess) + throw uno::RuntimeException(); + // force the cursor back into the meta if it has moved outside + SwPosition start(*pTxtNode, nStart); + SwPosition end(*pTxtNode, nEnd); + switch (eMode) + { + case META_INIT_START: + *rCursor.GetPoint() = start; + break; + case META_INIT_END: + *rCursor.GetPoint() = end; + break; + case META_CHECK_BOTH: + if (*rCursor.Start() < start) + { + *rCursor.Start() = start; + bRet = sal_False; + } + if (*rCursor.End() > end) + { + *rCursor.End() = end; + bRet = sal_False; + } + break; + } + return bRet; +} + +bool SwXTextCursor::IsAtEndOfMeta() const +{ + if (CURSOR_META == eType) + { + SwUnoCrsr const * const pCursor( GetCrsr() ); + SwXMeta const*const pXMeta( dynamic_cast<SwXMeta*>(xParentText.get()) ); + ASSERT(pXMeta, "no meta?"); + if (pCursor && pXMeta) + { + SwTxtNode * pTxtNode; + xub_StrLen nStart; + xub_StrLen nEnd; + const bool bSuccess( + pXMeta->SetContentRange(pTxtNode, nStart, nEnd) ); + ASSERT(bSuccess, "no pam?"); + if (bSuccess) + { + const SwPosition end(*pTxtNode, nEnd); + if ( (*pCursor->GetPoint() == end) + || (*pCursor->GetMark() == end)) + { + return true; + } + } + } + } + return false; +} + /* -----------------------------10.03.00 18:02-------------------------------- ---------------------------------------------------------------------------*/ @@ -972,6 +1055,11 @@ sal_Bool SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand) throw( uno::Ru { SwXTextCursor::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->Left( nCount, CRSR_SKIP_CHARS, FALSE, FALSE); + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else { @@ -991,6 +1079,11 @@ sal_Bool SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand) throw( uno::R { SwXTextCursor::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->Right(nCount, CRSR_SKIP_CHARS, FALSE, FALSE); + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else { @@ -1044,6 +1137,10 @@ void SwXTextCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException ) { pUnoCrsr->MoveSection( fnSectionCurr, fnSectionStart); } + else if (CURSOR_META == eType) + { + lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_INIT_START); + } } else { @@ -1061,7 +1158,9 @@ void SwXTextCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException ) { SwXTextCursor::SelectPam(*pUnoCrsr, Expand); if(eType == CURSOR_BODY) + { pUnoCrsr->Move( fnMoveForward, fnGoDoc ); + } else if(eType == CURSOR_FRAME || eType == CURSOR_TBLTEXT || eType == CURSOR_HEADER || @@ -1071,6 +1170,10 @@ void SwXTextCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException ) { pUnoCrsr->MoveSection( fnSectionCurr, fnSectionEnd); } + else if (CURSOR_META == eType) + { + lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_INIT_END); + } } else { @@ -1099,6 +1202,11 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); } + if (!pRange && !pCursor) + { + throw uno::RuntimeException(); + } + SwStartNodeType eSearchNodeType = SwNormalStartNode; switch(eType) { @@ -1141,6 +1249,27 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B throw uno::RuntimeException(); } + if (CURSOR_META == eType) + { + const SwPosition & rPoint( (pRange) + ? pRange->GetBookmark()->GetMarkPos() + : *pCursor->GetPaM()->GetPoint() ); + const SwPosition & rMark ( (pRange) + ? ((pRange->GetBookmark()->IsExpanded()) + ? pRange->GetBookmark()->GetOtherMarkPos() : rPoint) + : *pCursor->GetPaM()->GetMark() ); + SwPaM aPam(rPoint, rMark); + const bool bNotForced( + lcl_ForceIntoMeta(aPam, xParentText, META_CHECK_BOTH) ); + if (!bNotForced) + { + throw uno::RuntimeException( + C2U("gotoRange: parameter range not contained in nesting" + " text content for which this cursor was created"), + static_cast<text::XWordCursor*>(this)); + } + } + //jetzt muss die Selektion erweitert werden if(bExpand) { @@ -1277,7 +1406,9 @@ sal_Bool SwXTextCursor::gotoNextWord(sal_Bool Expand) throw( uno::RuntimeExcepti //Absatzende? if(pUnoCrsr->GetCntntNode() && pPoint->nContent == pUnoCrsr->GetCntntNode()->Len()) + { pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); + } else { sal_Bool bTmp = pUnoCrsr->GoNextWordWT( i18n::WordType::DICTIONARY_WORD ); @@ -1289,6 +1420,10 @@ sal_Bool SwXTextCursor::gotoNextWord(sal_Bool Expand) throw( uno::RuntimeExcepti // return true if cursor has moved bRet = &pPoint->nNode.GetNode() != pOldNode || pPoint->nContent.GetIndex() != nOldIndex; + if (bRet && (CURSOR_META == eType)) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + } } else { @@ -1316,7 +1451,9 @@ sal_Bool SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw( uno::RuntimeExc SwXTextCursor::SelectPam(*pUnoCrsr, Expand); //Absatzanfang ? if(pPoint->nContent == 0) + { pUnoCrsr->Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); + } else { pUnoCrsr->GoPrevWordWT( i18n::WordType::DICTIONARY_WORD ); @@ -1327,6 +1464,10 @@ sal_Bool SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw( uno::RuntimeExc // return true if cursor has moved bRet = &pPoint->nNode.GetNode() != pOldNode || pPoint->nContent.GetIndex() != nOldIndex; + if (bRet && (CURSOR_META == eType)) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + } } else { @@ -1363,6 +1504,10 @@ sal_Bool SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw( uno::RuntimeExcept pPoint->nNode = rOldNode; pPoint->nContent = nOldIndex; } + else if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + } } else { @@ -1399,6 +1544,10 @@ sal_Bool SwXTextCursor::gotoStartOfWord(sal_Bool Expand) throw( uno::RuntimeExce pPoint->nNode = rOldNode; pPoint->nContent = nOldIndex; } + else if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + } } else { @@ -1489,6 +1638,11 @@ sal_Bool SwXTextCursor::gotoNextSentence(sal_Bool Expand) throw( uno::RuntimeExc if (bWasEOS && !bNextWord) bRet = sal_False; } + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else throw uno::RuntimeException(); @@ -1516,6 +1670,11 @@ sal_Bool SwXTextCursor::gotoPreviousSentence(sal_Bool Expand) throw( uno::Runtim pUnoCrsr->GoSentence(SwCursor::PREV_SENT); } } + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else throw uno::RuntimeException(); @@ -1538,6 +1697,11 @@ sal_Bool SwXTextCursor::gotoStartOfSentence(sal_Bool Expand) throw( uno::Runtime bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr) || pUnoCrsr->GoSentence(SwCursor::START_SENT) || SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr); + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else throw uno::RuntimeException(); @@ -1561,7 +1725,11 @@ sal_Bool SwXTextCursor::gotoEndOfSentence(sal_Bool Expand) throw( uno::RuntimeEx bRet = !bAlreadyParaEnd && (pUnoCrsr->GoSentence(SwCursor::END_SENT) || pUnoCrsr->MovePara(fnParaCurr, fnParaEnd)); - + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else throw uno::RuntimeException(); @@ -1603,6 +1771,8 @@ sal_Bool SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) throw( uno::Runtim { vos::OGuard aGuard(Application::GetSolarMutex()); sal_Bool bRet = sal_False; + if (CURSOR_META == eType) + return bRet; SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr ) { @@ -1627,6 +1797,8 @@ sal_Bool SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw( uno::RuntimeE { vos::OGuard aGuard(Application::GetSolarMutex()); sal_Bool bRet = sal_False; + if (CURSOR_META == eType) + return bRet; SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { @@ -1651,6 +1823,8 @@ sal_Bool SwXTextCursor::gotoNextParagraph(sal_Bool Expand) throw( uno::RuntimeEx { vos::OGuard aGuard(Application::GetSolarMutex()); sal_Bool bRet = sal_False; + if (CURSOR_META == eType) + return bRet; SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { @@ -1668,6 +1842,8 @@ sal_Bool SwXTextCursor::gotoPreviousParagraph(sal_Bool Expand) throw( uno::Runti { vos::OGuard aGuard(Application::GetSolarMutex()); sal_Bool bRet = sal_False; + if (CURSOR_META == eType) + return bRet; SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { @@ -1697,7 +1873,19 @@ uno::Reference< XTextRange > SwXTextCursor::getStart(void) throw( uno::RuntimeE { SwPaM aPam(*pUnoCrsr->Start()); uno::Reference< XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); + if (CURSOR_META == eType) + { + // return cursor to prevent modifying SwXTextRange for META + SwXTextCursor * const pCursor( + new SwXTextCursor(xParent, *pUnoCrsr->GetPoint(), + CURSOR_META, pUnoCrsr->GetDoc()) ); + pCursor->gotoStart(sal_False); + xRet = static_cast<text::XWordCursor*>(pCursor); + } + else + { + xRet = new SwXTextRange(aPam, xParent); + } } else throw uno::RuntimeException(); @@ -1715,7 +1903,19 @@ uno::Reference< XTextRange > SwXTextCursor::getEnd(void) throw( uno::RuntimeExc { SwPaM aPam(*pUnoCrsr->End()); uno::Reference< XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); + if (CURSOR_META == eType) + { + // return cursor to prevent modifying SwXTextRange for META + SwXTextCursor * const pCursor( + new SwXTextCursor(xParent, *pUnoCrsr->GetPoint(), + CURSOR_META, pUnoCrsr->GetDoc()) ); + pCursor->gotoEnd(sal_False); + xRet = static_cast<text::XWordCursor*>(pCursor); + } + else + { + xRet = new SwXTextRange(aPam, xParent); + } } else throw uno::RuntimeException(); @@ -1762,7 +1962,11 @@ void SwXTextCursor::setString(const OUString& aString) throw( uno::RuntimeExcept if(!pUnoCrsr) throw uno::RuntimeException(); - DeleteAndInsert(aString); + const bool bForceExpandHints( (CURSOR_META != eType) + ? false + : dynamic_cast<SwXMeta*>(xParentText.get())->CheckForOwnMemberMeta( + 0, GetPaM(), true) ); + DeleteAndInsert(aString, bForceExpandHints); } /* -----------------------------03.05.00 12:56-------------------------------- diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index e894d08e6b..36dd9cc160 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -57,7 +57,6 @@ #include <shellio.hxx> #include <swerror.h> #include <swtblfmt.hxx> -#include <fmthbsh.hxx> #include <docsh.hxx> #include <docstyle.hxx> #include <charfmt.hxx> @@ -124,6 +123,11 @@ // OD 2004-05-24 #i28701# #include <sortedobjs.hxx> +#include <algorithm> +#include <iterator> +#include <boost/bind.hpp> + + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -135,9 +139,20 @@ using namespace ::com::sun::star::drawing; using ::rtl::OUString; + +struct FrameDependSortListLess +{ + bool operator() (FrameDependSortListEntry const& r1, + FrameDependSortListEntry const& r2) + { + return (r1.nIndex < r2.nIndex) + || ((r1.nIndex == r2.nIndex) && (r1.nOrder < r2.nOrder)); + } +}; + // OD 2004-05-07 #i28701# - adjust 4th parameter void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, - SwDependArr& rFrameArr, + FrameDependSortList_t & rFrames, const bool _bAtCharAnchoredObjs ) { // _bAtCharAnchoredObjs: @@ -163,21 +178,21 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt(); if ( rFmt.GetAnchor().GetAnchorId() == nChkType ) { - //jetzt einen SwDepend anlegen und in das Array einfuegen + // create SwDepend and insert into array SwDepend* pNewDepend = new SwDepend( &rClnt, &rFmt ); + xub_StrLen idx = + rFmt.GetAnchor().GetCntntAnchor()->nContent.GetIndex(); + sal_uInt32 nOrder = rFmt.GetAnchor().GetOrder(); // OD 2004-05-07 #i28701# - sorting no longer needed, // because list <SwSortedObjs> is already sorted. - rFrameArr.C40_INSERT( SwDepend, pNewDepend, rFrameArr.Count() ); + FrameDependSortListEntry entry(idx, nOrder, pNewDepend); + rFrames.push_back(entry); } } } else { - // OD 2004-05-07 #i28701# - helper list to get <rFrameArr> sorted - std::vector< std::pair< xub_StrLen, sal_uInt32 > > aSortLst; - typedef std::vector< std::pair< xub_StrLen, sal_uInt32 > >::iterator tSortLstIter; - const SwSpzFrmFmts& rFmts = *pDoc->GetSpzFrmFmts(); USHORT nSize = rFmts.Count(); for ( USHORT i = 0; i < nSize; i++) @@ -194,32 +209,14 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, // OD 2004-05-07 #i28701# - determine insert position for // sorted <rFrameArr> - USHORT nInsPos = rFrameArr.Count(); - { - xub_StrLen nCntIndex = pAnchorPos->nContent.GetIndex(); - sal_uInt32 nAnchorOrder = rAnchor.GetOrder(); + xub_StrLen nIndex = pAnchorPos->nContent.GetIndex(); + sal_uInt32 nOrder = rAnchor.GetOrder(); - tSortLstIter aInsIter = aSortLst.end(); - for ( tSortLstIter aIter = aSortLst.begin(); - aIter != aSortLst.end(); - ++aIter ) - { - if ( (*aIter).first > nCntIndex || - ( (*aIter).first == nCntIndex && - (*aIter).second > nAnchorOrder ) ) - { - nInsPos = sal::static_int_cast< USHORT >(aIter - aSortLst.begin()); - aInsIter = aIter; - break; - } - } - std::pair< xub_StrLen, sal_uInt32 > aEntry( nCntIndex, - nAnchorOrder ); - aSortLst.insert( aInsIter, aEntry ); - } - rFrameArr.C40_INSERT( SwDepend, pNewDepend, nInsPos ); + FrameDependSortListEntry entry(nIndex, nOrder, pNewDepend); + rFrames.push_back(entry); } } + ::std::sort(rFrames.begin(), rFrames.end(), FrameDependSortListLess()); } } @@ -769,7 +766,9 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt { if( _pStartCrsr->HasMark() && ( (CRSR_ATTR_MODE_TABLE & nAttrMode) || *_pStartCrsr->GetPoint() != *_pStartCrsr->GetMark() )) - pDoc->Insert(*_pStartCrsr, rSet, nFlags ); + { + pDoc->InsertItemSet(*_pStartCrsr, rSet, nFlags); + } } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != &rPam ); pDoc->EndUndo(UNDO_INSATTR, NULL); @@ -778,7 +777,7 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt { // if( !HasSelection() ) // UpdateAttr(); - pDoc->Insert( *pCrsr, rSet, nFlags ); + pDoc->InsertItemSet( *pCrsr, rSet, nFlags ); } //#outline level,add by zhaojianwei if( rSet.GetItemState( RES_PARATR_OUTLINELEVEL, false ) >= SFX_ITEM_AVAILABLE ) @@ -1214,9 +1213,16 @@ void SwXTextRange::_CreateNewBookmark(SwPaM& rPam) pMark->Add(this); } -void SwXTextRange::DeleteAndInsert(const String& rText) +void SwXTextRange::DeleteAndInsert( + const String& rText, const bool bForceExpandHints) throw(uno::RuntimeException) { + if (RANGE_IS_TABLE == eRangePosition) + { + // setString on table not allowed + throw uno::RuntimeException(); + } + ::sw::mark::IMark const * const pBkmk = GetBookmark(); if(pBkmk) { @@ -1231,11 +1237,14 @@ void SwXTextRange::DeleteAndInsert(const String& rText) UnoActionContext aAction(pDoc); pDoc->StartUndo(UNDO_INSERT, NULL); if(aNewCrsr.HasMark()) + { pDoc->DeleteAndJoin(aNewCrsr); + } if(rText.Len()) { - SwUnoCursorHelper::DocInsertStringSplitCR(*pDoc, aNewCrsr, rText); + SwUnoCursorHelper::DocInsertStringSplitCR( + *pDoc, aNewCrsr, rText, bForceExpandHints); SwXTextCursor::SelectPam(aNewCrsr, sal_True); aNewCrsr.Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); @@ -1335,13 +1344,7 @@ void SwXTextRange::setString(const OUString& aString) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(RANGE_IS_TABLE == eRangePosition) - { - //setString in Tabellen kann nicht erlaubt werden - throw uno::RuntimeException(); - } - else - DeleteAndInsert(aString); + DeleteAndInsert(aString, false); } void SwXTextRange::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) @@ -1438,12 +1441,10 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, } else { - const SwPaM* pUnoCrsr = 0; - SwDoc* pDoc = pCursor ? pCursor->GetDoc() : NULL; - - if ( !pDoc ) - pDoc = pPortion ? pPortion->GetCrsr()->GetDoc() : NULL; - pUnoCrsr = pCursor ? pCursor->GetPaM() : pPortion ? pPortion->GetCrsr() : 0; + SwDoc* const pDoc = (pCursor) ? pCursor->GetDoc() + : ((pPortion) ? pPortion->GetCursor()->GetDoc() : 0); + const SwPaM* const pUnoCrsr = (pCursor) ? pCursor->GetPaM() + : ((pPortion) ? pPortion->GetCursor() : 0); if (pUnoCrsr && pDoc == rToFill.GetDoc()) { DBG_ASSERT((SwPaM*)pUnoCrsr->GetNext() == pUnoCrsr, "was machen wir mit Ringen?" ); @@ -1907,9 +1908,11 @@ sal_Int32 SwXTextRanges::getCount(void) throw( uno::RuntimeException ) SwUnoCrsr* pCrsr = GetCrsr(); if(pCrsr) { - FOREACHUNOPAM_START(pCrsr) + SwPaM *pTmpCrsr = pCrsr; + do { nRet++; - FOREACHUNOPAM_END() + pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != pCrsr ); } else if(pRangeArr) nRet = pRangeArr->Count(); @@ -1958,15 +1961,20 @@ XTextRangeArr* SwXTextRanges::GetRangesArray() if(!pRangeArr && pCrsr) { pRangeArr = new XTextRangeArr(); - FOREACHUNOPAM_START(pCrsr) + SwPaM *pTmpCrsr = pCrsr; + do { uno::Reference< XTextRange >* pPtr = - new uno::Reference<XTextRange>( SwXTextRange::CreateTextRangeFromPosition(PUNOPAM->GetDoc(), - *PUNOPAM->GetPoint(), PUNOPAM->GetMark())); -// new uno::Reference<XTextRange>( SwXTextRange::createTextRangeFromPaM(*PUNOPAM, xParentText)); + new uno::Reference<XTextRange>( + SwXTextRange::CreateTextRangeFromPosition( + pTmpCrsr->GetDoc(), + *pTmpCrsr->GetPoint(), pTmpCrsr->GetMark())); +// new uno::Reference<XTextRange>( SwXTextRange::createTextRangeFromPaM(*pTmpCrsr, xParentText)); if(pPtr->is()) pRangeArr->Insert(pPtr, pRangeArr->Count()); - FOREACHUNOPAM_END() + + pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != pCrsr ); pCrsr->Remove( this ); } return pRangeArr; @@ -1994,37 +2002,107 @@ void SwXTextCursor::SetString(SwCursor& rCrsr, const OUString& rString) pDoc->DeleteAndJoin(rCrsr); if(nTxtLen) { - if( !SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, rCrsr, aText ) ) - { - DBG_ASSERT( sal_False, "DocInsertStringSplitCR" ); - } + const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR( + *pDoc, rCrsr, aText, false ) ); + DBG_ASSERT( bSuccess, "DocInsertStringSplitCR" ); + (void) bSuccess; SwXTextCursor::SelectPam(rCrsr, sal_True); rCrsr.Left(nTxtLen, CRSR_SKIP_CHARS, FALSE, FALSE); } pDoc->EndUndo(UNDO_INSERT, NULL); } + /****************************************************************** * SwXParaFrameEnumeration ******************************************************************/ -SV_IMPL_PTRARR(SwDependArr, SwDepend*); + +/* -----------------23.03.99 13:38------------------- + * + * --------------------------------------------------*/ +static sal_Bool +lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr, + uno::Reference<text::XTextContent> & o_rNextObject, + FrameDependList_t & i_rFrames) +{ + if (!i_rFrames.size()) + return sal_False; + + SwFrmFmt* pFormat = static_cast<SwFrmFmt*>(const_cast<SwModify*>( + i_rFrames.front()->GetRegisteredIn())); + i_rFrames.pop_front(); + // the format should be valid here, otherwise the client + // would have been removed in ::Modify + // check for a shape first + SwClientIter aIter(*pFormat); + SwDrawContact * const pContact = + static_cast<SwDrawContact*>( aIter.First(TYPE(SwDrawContact)) ); + if (pContact) + { + SdrObject * const pSdr = pContact->GetMaster(); + if (pSdr) + { + o_rNextObject.set(pSdr->getUnoShape(), uno::UNO_QUERY); + } + } + else + { + const SwNodeIndex* pIdx = pFormat->GetCntnt().GetCntntIdx(); + DBG_ASSERT(pIdx, "where is the index?"); + const SwNode* pNd = + i_rUnoCrsr.GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ]; + + const FlyCntType eType = (!pNd->IsNoTxtNode()) ? FLYCNTTYPE_FRM + : ( (pNd->IsGrfNode()) ? FLYCNTTYPE_GRF : FLYCNTTYPE_OLE ); + + const uno::Reference< container::XNamed > xFrame = + SwXFrames::GetObject(*pFormat, eType); + o_rNextObject.set(xFrame, uno::UNO_QUERY); + } + + return o_rNextObject.is(); +} + +/* -----------------------------03.04.00 10:15-------------------------------- + Description: Search for a FLYCNT text attribute at the cursor point + and fill the frame into the array + ---------------------------------------------------------------------------*/ +static void +lcl_FillFrame(SwXParaFrameEnumeration & rEnum, SwUnoCrsr& rUnoCrsr, + FrameDependList_t & rFrames) +{ + // search for objects at the cursor - anchored at/as char + const SwTxtAttr * pTxtAttr = rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttr( + rUnoCrsr.GetPoint()->nContent, RES_TXTATR_FLYCNT); + if (pTxtAttr) + { + const SwFmtFlyCnt& rFlyCnt = pTxtAttr->GetFlyCnt(); + SwFrmFmt * const pFrmFmt = rFlyCnt.GetFrmFmt(); + SwDepend * const pNewDepend = new SwDepend(&rEnum, pFrmFmt); + rFrames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) ); + } +} + /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXParaFrameEnumeration::getImplementationName(void) throw( RuntimeException ) +OUString SwXParaFrameEnumeration::getImplementationName() +throw( RuntimeException ) { return C2U("SwXParaFrameEnumeration"); } /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXParaFrameEnumeration::supportsService(const OUString& rServiceName) throw( RuntimeException ) +sal_Bool SwXParaFrameEnumeration::supportsService(const OUString& rServiceName) +throw( RuntimeException ) { return C2U("com.sun.star.util.ContentEnumeration") == rServiceName; } /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -Sequence< OUString > SwXParaFrameEnumeration::getSupportedServiceNames(void) throw( RuntimeException ) +Sequence< OUString > SwXParaFrameEnumeration::getSupportedServiceNames() +throw( RuntimeException ) { Sequence< OUString > aRet(1); OUString* pArray = aRet.getArray(); @@ -2049,14 +2127,17 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, if (PARAFRAME_PORTION_PARAGRAPH == nParaFrameMode) { - ::CollectFrameAtNode( *this, rPaM.GetPoint()->nNode, - aFrameArr, FALSE ); + FrameDependSortList_t frames; + ::CollectFrameAtNode( *this, rPaM.GetPoint()->nNode, frames, false ); + ::std::transform(frames.begin(), frames.end(), + ::std::back_inserter(m_Frames), + ::boost::bind(&FrameDependSortListEntry::pFrameDepend, _1)); } else if (pFmt) { //jetzt einen SwDepend anlegen und in das Array einfuegen SwDepend* pNewDepend = new SwDepend(this, pFmt); - aFrameArr.C40_INSERT(SwDepend, pNewDepend, aFrameArr.Count()); + m_Frames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) ); } else if((PARAFRAME_PORTION_CHAR == nParaFrameMode) || (PARAFRAME_PORTION_TEXTRANGE == nParaFrameMode)) @@ -2072,7 +2153,7 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, SwFrmFmt* pFrmFmt = (SwFrmFmt*)&pPosFly->GetFmt(); //jetzt einen SwDepend anlegen und in das Array einfuegen SwDepend* pNewDepend = new SwDepend(this, pFrmFmt); - aFrameArr.C40_INSERT(SwDepend, pNewDepend, aFrameArr.Count()); + m_Frames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) ); } //created from any text range if(pUnoCrsr->HasMark()) @@ -2081,13 +2162,13 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, pUnoCrsr->Exchange(); do { - FillFrame(*pUnoCrsr); + lcl_FillFrame(*this, *pUnoCrsr, m_Frames); pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); } while(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()); } } - FillFrame(*pUnoCrsr); + lcl_FillFrame(*this, *pUnoCrsr, m_Frames); } } /*-- 23.03.99 13:22:30--------------------------------------------------- @@ -2096,102 +2177,53 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, SwXParaFrameEnumeration::~SwXParaFrameEnumeration() { vos::OGuard aGuard(Application::GetSolarMutex()); - aFrameArr.DeleteAndDestroy(0, aFrameArr.Count()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + + SwUnoCrsr* pUnoCrsr = GetCursor(); delete pUnoCrsr; } -/* -----------------------------03.04.00 10:15-------------------------------- - Description: Search for a FLYCNT text attribute at the cursor point - and fill the frame into the array - ---------------------------------------------------------------------------*/ -void SwXParaFrameEnumeration::FillFrame(SwUnoCrsr& rUnoCrsr) -{ - // search for objects at the cursor - anchored at/as char - SwTxtAttr* pTxtAttr = rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttr( - rUnoCrsr.GetPoint()->nContent, RES_TXTATR_FLYCNT); - if(pTxtAttr) - { - const SwFmtFlyCnt& rFlyCnt = pTxtAttr->GetFlyCnt(); - SwFrmFmt* pFrmFmt = rFlyCnt.GetFrmFmt(); - //jetzt einen SwDepend anlegen und in das Array einfuegen - SwDepend* pNewDepend = new SwDepend(this, pFrmFmt); - aFrameArr.C40_INSERT(SwDepend, pNewDepend, aFrameArr.Count()); - } -} + /*-- 23.03.99 13:22:32--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXParaFrameEnumeration::hasMoreElements(void) throw( uno::RuntimeException ) +sal_Bool SwXParaFrameEnumeration::hasMoreElements() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetCrsr()) + + if (!GetCursor()) throw uno::RuntimeException(); - return xNextObject.is() ? sal_True : CreateNextObject(); + + return m_xNextObject.is() ? sal_True : + lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames); } /*-- 23.03.99 13:22:33--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParaFrameEnumeration::nextElement(void) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SwXParaFrameEnumeration::nextElement() + throw( container::NoSuchElementException, + lang::WrappedTargetException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetCrsr()) + + if (!GetCursor()) throw uno::RuntimeException(); - if(!xNextObject.is() && aFrameArr.Count()) + + if (!m_xNextObject.is() && m_Frames.size()) { - CreateNextObject(); + lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames); } - if(!xNextObject.is()) + if(!m_xNextObject.is()) throw container::NoSuchElementException(); - uno::Any aRet(&xNextObject, ::getCppuType((uno::Reference<XTextContent>*)0)); - xNextObject = 0; + uno::Any aRet(&m_xNextObject, + ::getCppuType((uno::Reference<XTextContent>*)0)); + m_xNextObject = 0; return aRet; } -/* -----------------23.03.99 13:38------------------- - * - * --------------------------------------------------*/ -sal_Bool SwXParaFrameEnumeration::CreateNextObject() -{ - if(!aFrameArr.Count()) - return sal_False; - SwDepend* pDepend = aFrameArr.GetObject(0); - aFrameArr.Remove(0); - SwFrmFmt* pFormat = (SwFrmFmt*)pDepend->GetRegisteredIn(); - delete pDepend; - // the format should be valid her otherwise the client - // would have been removed in ::Modify - // check for a shape first - SwClientIter aIter(*pFormat); - SwDrawContact* pContact = (SwDrawContact*) - aIter.First(TYPE(SwDrawContact)); - if(pContact) - { - SdrObject* pSdr = pContact->GetMaster(); - if(pSdr) - { - xNextObject = uno::Reference< XTextContent >(pSdr->getUnoShape(), uno::UNO_QUERY); - } - } - else - { - const SwNodeIndex* pIdx = pFormat->GetCntnt().GetCntntIdx(); - DBG_ASSERT(pIdx, "where is the index?"); - const SwNode* pNd = GetCrsr()->GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ]; - FlyCntType eType; - if(!pNd->IsNoTxtNode()) - eType = FLYCNTTYPE_FRM; - else if(pNd->IsGrfNode()) - eType = FLYCNTTYPE_GRF; - else - eType = FLYCNTTYPE_OLE; - - uno::Reference< container::XNamed > xFrame = SwXFrames::GetObject(*pFormat, eType); - xNextObject = uno::Reference< XTextContent >(xFrame, uno::UNO_QUERY); - } - - return xNextObject.is(); -} +struct InvalidFrameDepend { + bool operator() (::boost::shared_ptr<SwDepend> const & rEntry) + { return !rEntry->GetRegisteredIn(); } +}; /*-- 23.03.99 13:22:37--------------------------------------------------- @@ -2215,21 +2247,16 @@ void SwXParaFrameEnumeration::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) } if(!GetRegisteredIn()) { - aFrameArr.DeleteAndDestroy(0, aFrameArr.Count()); - xNextObject = 0; + m_Frames.clear(); + m_xNextObject = 0; } else { - //dann war es vielleicht ein Frame am Absatz? - for(sal_uInt16 i = aFrameArr.Count(); i; i--) - { - SwDepend* pDepend = aFrameArr.GetObject(i-1); - if(!pDepend->GetRegisteredIn()) - { - delete pDepend; - aFrameArr.Remove(i-1); - } - } + // check if any frame went away... + FrameDependList_t::iterator iter = + ::std::remove_if(m_Frames.begin(), m_Frames.end(), + InvalidFrameDepend()); + m_Frames.erase(iter, m_Frames.end()); } } // ----------------------------------------------------------------------------- diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 9408fda5cc..89032a3b20 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -35,6 +35,7 @@ #include <cmdid.h> #include <unomid.h> #include <unoobj.hxx> +#include <unoport.hxx> #include <unomap.hxx> #include <unocrsr.hxx> #include <unoprnms.hxx> diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index 0c8cbca39b..8671230214 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -41,20 +41,20 @@ #include <unoobj.hxx> #include <unomap.hxx> #include <unoprnms.hxx> -#ifndef _UNOMID_H #include <unomid.h> -#endif #include <txtatr.hxx> #include <txtfld.hxx> #include <ndtxt.hxx> #include <doc.hxx> #include <fmtflcnt.hxx> #include <fmtfld.hxx> + #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp> #include <com/sun/star/beans/GetPropertyTolerantResult.hpp> #include <com/sun/star/beans/TolerantPropertySetResultType.hpp> + using namespace ::com::sun::star; using ::rtl::OUString; @@ -63,88 +63,95 @@ using ::rtl::OUString; * SwXTextPortion ******************************************************************/ -/*-- 11.12.98 09:56:52--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwFmtFld* SwXTextPortion::GetFldFmt(sal_Bool bInit) +static void init(SwXTextPortion & rPortion, const SwUnoCrsr* pPortionCursor) { - SwFmtFld* pRet = 0; - // initial wird es immer gesucht, danach nur noch, wenn es bereits existierte - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr && (bInit || pFmtFld)) + SwUnoCrsr* pUnoCursor = + pPortionCursor->GetDoc()->CreateUnoCrsr(*pPortionCursor->GetPoint()); + if (pPortionCursor->HasMark()) { - SwTxtNode *pNode = pUnoCrsr->GetPoint()->nNode.GetNode().GetTxtNode(); - SwTxtFld *pTxtFld = 0; - if( pNode ) - pTxtFld = pNode->GetTxtFld( pUnoCrsr->Start()->nContent ); - if(pTxtFld) - pFmtFld = pRet = (SwFmtFld*)&pTxtFld->GetFld(); + pUnoCursor->SetMark(); + *pUnoCursor->GetMark() = *pPortionCursor->GetMark(); } - return pRet; + pUnoCursor->Add(& rPortion); } + /*-- 11.12.98 09:56:55--------------------------------------------------- -----------------------------------------------------------------------*/ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, uno::Reference< text::XText > const& rParent, - SwTextPortionType eType) : - aLstnrCntnr( (text::XTextRange*)this), - m_pPropSet(aSwMapProvider.GetPropertySet( - (PORTION_REDLINE_START == eType || - PORTION_REDLINE_END == eType) ? - PROPERTY_MAP_REDLINE_PORTION : PROPERTY_MAP_TEXTPORTION_EXTENSIONS)), - xParentText(rParent), - pRubyText(0), - pRubyStyle(0), - pRubyAdjust(0), - pRubyIsAbove(0), - pFmtFld(0), - aFrameDepend(this, 0), - pFrameFmt(0), - ePortionType(eType), - nControlChar(0), - bIsCollapsed(FALSE) + SwTextPortionType eType) + : m_ListenerContainer( static_cast<text::XTextRange*>(this) ) + , m_pPropSet(aSwMapProvider.GetPropertySet( + (PORTION_REDLINE_START == eType || + PORTION_REDLINE_END == eType) + ? PROPERTY_MAP_REDLINE_PORTION + : PROPERTY_MAP_TEXTPORTION_EXTENSIONS)) + , m_xParentText(rParent) + , m_pRubyText(0) + , m_pRubyStyle(0) + , m_pRubyAdjust(0) + , m_pRubyIsAbove(0) + , m_FrameDepend(this, 0) + , m_pFrameFmt(0) + , m_ePortionType(eType) + , m_bIsCollapsed(false) { - SwUnoCrsr* pUnoCrsr = pPortionCrsr->GetDoc()->CreateUnoCrsr(*pPortionCrsr->GetPoint()); - if(pPortionCrsr->HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pPortionCrsr->GetMark(); - } - pUnoCrsr->Add(this); - // erst nach ->Add() - if(ePortionType == PORTION_FIELD) - GetFldFmt(sal_True); -// else if(ePortionType == PORTION_FRAME) -// ...; + init(*this, pPortionCrsr); } + /* -----------------24.03.99 16:30------------------- * * --------------------------------------------------*/ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, uno::Reference< text::XText > const& rParent, - SwFrmFmt& rFmt ) : - aLstnrCntnr( (text::XTextRange*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXTPORTION_EXTENSIONS)), - xParentText(rParent), - pRubyText(0), - pRubyStyle(0), - pRubyAdjust(0), - pRubyIsAbove(0), - pFmtFld(0), - aFrameDepend(this, &rFmt), - pFrameFmt(&rFmt), - ePortionType(PORTION_FRAME), - nControlChar(0), - bIsCollapsed(FALSE) + SwFrmFmt& rFmt ) + : m_ListenerContainer( static_cast<text::XTextRange*>(this) ) + , m_pPropSet(aSwMapProvider.GetPropertySet( + PROPERTY_MAP_TEXTPORTION_EXTENSIONS)) + , m_xParentText(rParent) + , m_pRubyText(0) + , m_pRubyStyle(0) + , m_pRubyAdjust(0) + , m_pRubyIsAbove(0) + , m_FrameDepend(this, &rFmt) + , m_pFrameFmt(&rFmt) + , m_ePortionType(PORTION_FRAME) + , m_bIsCollapsed(false) { - SwUnoCrsr* pUnoCrsr = pPortionCrsr->GetDoc()->CreateUnoCrsr(*pPortionCrsr->GetPoint()); - if(pPortionCrsr->HasMark()) + init(*this, pPortionCrsr); +} + +/* -----------------------------19.02.01 10:52-------------------------------- + + ---------------------------------------------------------------------------*/ +SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, + SwTxtRuby const& rAttr, + uno::Reference< text::XText > const& xParent, + sal_Bool bIsEnd ) + : m_ListenerContainer( static_cast<text::XTextRange*>(this) ) + , m_pPropSet(aSwMapProvider.GetPropertySet( + PROPERTY_MAP_TEXTPORTION_EXTENSIONS)) + , m_xParentText(xParent) + , m_pRubyText ( bIsEnd ? 0 : new uno::Any ) + , m_pRubyStyle ( bIsEnd ? 0 : new uno::Any ) + , m_pRubyAdjust ( bIsEnd ? 0 : new uno::Any ) + , m_pRubyIsAbove( bIsEnd ? 0 : new uno::Any ) + , m_FrameDepend(this, 0) + , m_pFrameFmt(0) + , m_ePortionType( bIsEnd ? PORTION_RUBY_END : PORTION_RUBY_START ) + , m_bIsCollapsed(false) +{ + init(*this, pPortionCrsr); + + if (!bIsEnd) { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pPortionCrsr->GetMark(); + const SfxPoolItem& rItem = rAttr.GetAttr(); + rItem.QueryValue(*m_pRubyText, MID_RUBY_TEXT); + rItem.QueryValue(*m_pRubyStyle, MID_RUBY_CHARSTYLE); + rItem.QueryValue(*m_pRubyAdjust, MID_RUBY_ADJUST); + rItem.QueryValue(*m_pRubyIsAbove, MID_RUBY_ABOVE); } - pUnoCrsr->Add(this); } /*-- 11.12.98 09:56:55--------------------------------------------------- @@ -153,77 +160,71 @@ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, SwXTextPortion::~SwXTextPortion() { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); delete pUnoCrsr; - delete pRubyText; - delete pRubyStyle; - delete pRubyAdjust; - delete pRubyIsAbove; } /*-- 11.12.98 09:56:56--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XText > SwXTextPortion::getText(void) throw( uno::RuntimeException ) +uno::Reference< text::XText > SwXTextPortion::getText() +throw( uno::RuntimeException ) { - return xParentText; + return m_xParentText; } /*-- 11.12.98 09:56:56--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXTextPortion::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SwXTextPortion::getStart() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - SwPaM aPam(*pUnoCrsr->Start()); - uno::Reference< text::XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwPaM aPam(*pUnoCrsr->Start()); + uno::Reference< text::XText > xParent = getText(); + xRet = new SwXTextRange(aPam, xParent); return xRet; } /*-- 11.12.98 09:56:57--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXTextPortion::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SwXTextPortion::getEnd() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - SwPaM aPam(*pUnoCrsr->End()); - uno::Reference< text::XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwPaM aPam(*pUnoCrsr->End()); + uno::Reference< text::XText > xParent = getText(); + xRet = new SwXTextRange(aPam, xParent); return xRet; } /*-- 11.12.98 09:56:57--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXTextPortion::getString(void) throw( uno::RuntimeException ) +OUString SwXTextPortion::getString() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - String aTxt; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) + OUString aTxt; + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) + throw uno::RuntimeException(); + + // TextPortions are always within a paragraph + SwTxtNode* pTxtNd = pUnoCrsr->GetNode()->GetTxtNode(); + if ( pTxtNd ) { - //TextPortions liegen immer innerhalb eines Absatzes - SwTxtNode* pTxtNd = pUnoCrsr->GetNode()->GetTxtNode(); - if( pTxtNd ) - { - xub_StrLen nStt = pUnoCrsr->Start()->nContent.GetIndex(); - aTxt = pTxtNd->GetExpandTxt( nStt, - pUnoCrsr->End()->nContent.GetIndex() - nStt ); - } + xub_StrLen nStt = pUnoCrsr->Start()->nContent.GetIndex(); + aTxt = pTxtNd->GetExpandTxt( nStt, + pUnoCrsr->End()->nContent.GetIndex() - nStt ); } - else - throw uno::RuntimeException(); return aTxt; } /*-- 11.12.98 09:56:57--------------------------------------------------- @@ -232,17 +233,19 @@ OUString SwXTextPortion::getString(void) throw( uno::RuntimeException ) void SwXTextPortion::setString(const OUString& aString) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - SwXTextCursor::SetString(*pUnoCrsr, aString); - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwXTextCursor::SetString(*pUnoCrsr, aString); } /*-- 11.12.98 09:56:57--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXTextPortion::getPropertySetInfo(void) throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SwXTextPortion::getPropertySetInfo() +throw( uno::RuntimeException ) { + vos::OGuard aGuard(Application::GetSolarMutex()); //! PropertySetInfo for text portion extensions static uno::Reference< beans::XPropertySetInfo > xTxtPorExtRef = aSwMapProvider.GetPropertySet( @@ -252,8 +255,8 @@ uno::Reference< beans::XPropertySetInfo > SwXTextPortion::getPropertySetInfo(vo xRedlPorRef = aSwMapProvider.GetPropertySet( PROPERTY_MAP_REDLINE_PORTION)->getPropertySetInfo(); - return (PORTION_REDLINE_START == ePortionType || - PORTION_REDLINE_END == ePortionType) ? xRedlPorRef : xTxtPorExtRef; + return (PORTION_REDLINE_START == m_ePortionType || + PORTION_REDLINE_END == m_ePortionType) ? xRedlPorRef : xTxtPorExtRef; } /*-- 11.12.98 09:56:57--------------------------------------------------- @@ -264,13 +267,12 @@ void SwXTextPortion::setPropertyValue(const OUString& rPropertyName, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - SwXTextCursor::SetPropertyValue(*pUnoCrsr, *m_pPropSet, rPropertyName, aValue); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwXTextCursor::SetPropertyValue(*pUnoCrsr, *m_pPropSet, + rPropertyName, aValue); } /*-- 04.11.03 09:56:58--------------------------------------------------- @@ -291,13 +293,12 @@ void SwXTextPortion::GetPropertyValue( case FN_UNO_TEXT_PORTION_TYPE: { const char* pRet; - switch (ePortionType) + switch (m_ePortionType) { case PORTION_TEXT: pRet = "Text";break; case PORTION_FIELD: pRet = "TextField";break; case PORTION_FRAME: pRet = "Frame";break; case PORTION_FOOTNOTE: pRet = "Footnote";break; - case PORTION_CONTROL_CHAR: pRet = "ControlCharacter";break; case PORTION_REFMARK_START: case PORTION_REFMARK_END: pRet = SW_PROP_NAME_STR(UNO_NAME_REFERENCE_MARK);break; case PORTION_TOXMARK_START: @@ -309,6 +310,7 @@ void SwXTextPortion::GetPropertyValue( case PORTION_RUBY_START: case PORTION_RUBY_END: pRet = "Ruby";break; case PORTION_SOFT_PAGEBREAK:pRet = "SoftPageBreak";break; + case PORTION_META: pRet = SW_PROP_NAME_STR(UNO_NAME_META); break; case PORTION_FIELD_START:pRet = "TextFieldStart";break; case PORTION_FIELD_END:pRet = "TextFieldEnd";break; case PORTION_FIELD_START_END:pRet = "TextFieldStartEnd";break; @@ -322,28 +324,29 @@ void SwXTextPortion::GetPropertyValue( rVal <<= sRet; } break; - case FN_UNO_CONTROL_CHARACTER: - { - if(PORTION_CONTROL_CHAR == ePortionType) - rVal <<= (sal_Int16) nControlChar; - } + case FN_UNO_CONTROL_CHARACTER: // obsolete! break; case FN_UNO_DOCUMENT_INDEX_MARK: - rVal <<= xTOXMark; + rVal <<= m_xTOXMark; break; case FN_UNO_REFERENCE_MARK: - rVal <<= xRefMark; + rVal <<= m_xRefMark; break; case FN_UNO_BOOKMARK: - rVal <<= xBookmark; + rVal <<= m_xBookmark; break; case FN_UNO_FOOTNOTE: - rVal <<= xFootnote; + rVal <<= m_xFootnote; + break; + case FN_UNO_TEXT_FIELD: + rVal <<= m_xTextField; + break; + case FN_UNO_META: + rVal <<= m_xMeta; break; case FN_UNO_IS_COLLAPSED: { - BOOL bPut = TRUE; - switch (ePortionType) + switch (m_ePortionType) { case PORTION_REFMARK_START: case PORTION_BOOKMARK_START : @@ -357,17 +360,17 @@ void SwXTextPortion::GetPropertyValue( case PORTION_RUBY_END: case PORTION_FIELD_START: case PORTION_FIELD_END: - rVal.setValue(&bIsCollapsed, ::getBooleanCppuType()); + rVal.setValue(&m_bIsCollapsed, ::getBooleanCppuType()); break; default: - bPut = FALSE; + break; } } break; case FN_UNO_IS_START: { BOOL bStart = TRUE, bPut = TRUE; - switch (ePortionType) + switch (m_ePortionType) { case PORTION_REFMARK_START: case PORTION_BOOKMARK_START: @@ -394,13 +397,13 @@ void SwXTextPortion::GetPropertyValue( break; case RES_TXTATR_CJK_RUBY: { - uno::Any* pToSet = 0; + const uno::Any* pToSet = 0; switch(rEntry.nMemberId) { - case MID_RUBY_TEXT : pToSet = pRubyText; break; - case MID_RUBY_ADJUST : pToSet = pRubyAdjust; break; - case MID_RUBY_CHARSTYLE:pToSet = pRubyStyle; break; - case MID_RUBY_ABOVE : pToSet = pRubyIsAbove; break; + case MID_RUBY_TEXT : pToSet = m_pRubyText.get(); break; + case MID_RUBY_ADJUST : pToSet = m_pRubyAdjust.get(); break; + case MID_RUBY_CHARSTYLE:pToSet = m_pRubyStyle.get(); break; + case MID_RUBY_ABOVE : pToSet = m_pRubyIsAbove.get();break; } if(pToSet) rVal = *pToSet; @@ -436,8 +439,10 @@ uno::Sequence< uno::Any > SAL_CALL SwXTextPortion::GetPropertyValues_Impl( const OUString *pPropertyNames = rPropertyNames.getConstArray(); uno::Sequence< uno::Any > aValues(rPropertyNames.getLength()); uno::Any *pValues = aValues.getArray(); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) + throw uno::RuntimeException(); + { SfxItemSet *pSet = 0; // get startting pount fo the look-up, either the provided one or else @@ -455,8 +460,6 @@ uno::Sequence< uno::Any > SAL_CALL SwXTextPortion::GetPropertyValues_Impl( } delete pSet; } - else - throw uno::RuntimeException(); return aValues; } /*-- 11.12.98 09:56:58--------------------------------------------------- @@ -480,8 +483,10 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl( throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) + throw uno::RuntimeException(); + { const OUString* pPropertyNames = rPropertyNames.getConstArray(); const uno::Any* pValues = rValues.getConstArray(); @@ -494,11 +499,10 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl( if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - SwXTextCursor::SetPropertyValue( *pUnoCrsr, *m_pPropSet, pPropertyNames[nProp], pValues[nProp]); + SwXTextCursor::SetPropertyValue( *pUnoCrsr, *m_pPropSet, + pPropertyNames[nProp], pValues[nProp]); } } - else - throw uno::RuntimeException(); } void SwXTextPortion::setPropertyValues( @@ -564,7 +568,7 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXTextPortion::setPr if (rPropertyNames.getLength() != rValues.getLength()) throw lang::IllegalArgumentException(); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); + SwUnoCrsr* pUnoCrsr = this->GetCursor(); if (!pUnoCrsr) throw uno::RuntimeException(); @@ -664,7 +668,7 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion: { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); + SwUnoCrsr* pUnoCrsr = this->GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); @@ -701,6 +705,12 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion: aResult.State = pPropertyStates[i]; aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE; + //#i104499# ruby portion attributes need special handling: + if( pEntry->nWID == RES_TXTATR_CJK_RUBY && + m_ePortionType == PORTION_RUBY_START ) + { + aResult.State = beans::PropertyState_DIRECT_VALUE; + } if (!bDirectValuesOnly || beans::PropertyState_DIRECT_VALUE == aResult.State) { // get property value @@ -811,17 +821,20 @@ beans::PropertyState SwXTextPortion::getPropertyState(const OUString& rPropertyN { vos::OGuard aGuard(Application::GetSolarMutex()); beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) + throw uno::RuntimeException(); + + if (GetTextPortionType() == PORTION_RUBY_START && + !rPropertyName.compareToAscii( RTL_CONSTASCII_STRINGPARAM("Ruby") )) { - if(GetTextPortionType() == PORTION_RUBY_START && - !rPropertyName.compareToAscii( RTL_CONSTASCII_STRINGPARAM("Ruby") )) - eRet = beans::PropertyState_DIRECT_VALUE; - else - eRet = SwXTextCursor::GetPropertyState(*pUnoCrsr, *m_pPropSet, rPropertyName); + eRet = beans::PropertyState_DIRECT_VALUE; } else - throw uno::RuntimeException(); + { + eRet = SwXTextCursor::GetPropertyState(*pUnoCrsr, *m_pPropSet, + rPropertyName); + } return eRet; } /*-- 08.03.99 09:41:47--------------------------------------------------- @@ -832,10 +845,13 @@ uno::Sequence< beans::PropertyState > SwXTextPortion::getPropertyStates( throw( beans::UnknownPropertyException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); - uno::Sequence< beans::PropertyState > aRet = SwXTextCursor::GetPropertyStates(*pUnoCrsr, *m_pPropSet, rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION); + + uno::Sequence< beans::PropertyState > aRet = + SwXTextCursor::GetPropertyStates(*pUnoCrsr, *m_pPropSet, + rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION); if(GetTextPortionType() == PORTION_RUBY_START) { @@ -856,13 +872,11 @@ void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName) throw( beans::UnknownPropertyException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwXTextCursor::SetPropertyToDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwXTextCursor::SetPropertyToDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); } /*-- 08.03.99 09:41:48--------------------------------------------------- @@ -870,33 +884,17 @@ void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName) uno::Any SwXTextPortion::getPropertyDefault(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) { + vos::OGuard aGuard(Application::GetSolarMutex()); uno::Any aRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - aRet = SwXTextCursor::GetPropertyDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + aRet = SwXTextCursor::GetPropertyDefault(*pUnoCrsr, *m_pPropSet, + rPropertyName); return aRet; } -/*-- 11.12.98 09:56:59--------------------------------------------------- - -----------------------------------------------------------------------*/ -OUString SwXTextPortion::getPresentation(sal_Bool /*bShowCommand*/) throw( uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - String sRet; - SwFmtFld* pFmt = 0; - if(pUnoCrsr && 0 != (pFmt = GetFldFmt())) - { - const SwField* pField = pFmt->GetFld(); - DBG_ERROR("bShowCommand auswerten!"); - sRet = pField->Expand(); - } - return sRet; -} /*-- 11.12.98 09:56:59--------------------------------------------------- -----------------------------------------------------------------------*/ @@ -911,31 +909,31 @@ void SwXTextPortion::attach(const uno::Reference< text::XTextRange > & /*xTextRa /*-- 11.12.98 09:57:00--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXTextPortion::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SwXTextPortion::getAnchor() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > aRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - aRet = new SwXTextRange(*pUnoCrsr, xParentText); - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + aRet = new SwXTextRange(*pUnoCrsr, m_xParentText); return aRet; } /*-- 11.12.98 09:57:00--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextPortion::dispose(void) throw( uno::RuntimeException ) +void SwXTextPortion::dispose() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - setString(aEmptyStr); - pUnoCrsr->Remove(this); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + setString(aEmptyStr); + pUnoCrsr->Remove(this); } /*-- 11.12.98 09:57:00--------------------------------------------------- @@ -945,7 +943,8 @@ void SwXTextPortion::addEventListener(const uno::Reference< lang::XEventListener vos::OGuard aGuard(Application::GetSolarMutex()); if(!GetRegisteredIn()) throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + + m_ListenerContainer.AddListener(aListener); } /*-- 11.12.98 09:57:01--------------------------------------------------- @@ -953,7 +952,7 @@ void SwXTextPortion::addEventListener(const uno::Reference< lang::XEventListener void SwXTextPortion::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + if (!GetRegisteredIn() || !m_ListenerContainer.RemoveListener(aListener)) throw uno::RuntimeException(); } /* -----------------24.03.99 13:30------------------- @@ -963,10 +962,13 @@ uno::Reference< container::XEnumeration > SwXTextPortion::createContentEnumerat throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); - uno::Reference< container::XEnumeration > xRet = new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_CHAR, pFrameFmt); + + uno::Reference< container::XEnumeration > xRet = + new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_CHAR, + m_pFrameFmt); return xRet; } @@ -995,7 +997,8 @@ sal_Int64 SwXTextPortion::getSomething( const uno::Sequence< sal_Int8 >& rId ) /* -----------------24.03.99 13:30------------------- * * --------------------------------------------------*/ -uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames(void) throw( uno::RuntimeException ) +uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Sequence< OUString > aRet(1); @@ -1006,7 +1009,8 @@ uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames(void) throw( /* -----------------25.03.99 10:30------------------- * * --------------------------------------------------*/ -OUString SwXTextPortion::getImplementationName(void) throw( uno::RuntimeException ) +OUString SwXTextPortion::getImplementationName() +throw( uno::RuntimeException ) { return C2U("SwXTextPortion"); } @@ -1016,7 +1020,7 @@ OUString SwXTextPortion::getImplementationName(void) throw( uno::RuntimeExceptio sal_Bool SwXTextPortion::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); @@ -1028,25 +1032,24 @@ sal_Bool SwXTextPortion::supportsService(const OUString& rServiceName) throw( un !rServiceName.compareToAscii("com.sun.star.style.ParagraphProperties") || !rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesAsian") || !rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesComplex")) + { bRet = sal_True; - else if(COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextField")) - bRet = 0 != GetFldFmt(); + } return bRet; } /* --------------------------------------------------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames(void) - throw( uno::RuntimeException ) +uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(!pUnoCrsr) + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); - sal_Bool bField = 0 != GetFldFmt(); - sal_uInt16 nCount = bField ? 8 : 7; - uno::Sequence< OUString > aRet(nCount); + + uno::Sequence< OUString > aRet(7); OUString* pArray = aRet.getArray(); pArray[0] = C2U("com.sun.star.text.TextPortion"); pArray[1] = C2U("com.sun.star.style.CharacterProperties"); @@ -1055,8 +1058,6 @@ uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames(void) pArray[4] = C2U("com.sun.star.style.ParagraphProperties"); pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian"); pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex"); - if(bField) - pArray[7] = C2U("com.sun.star.text.TextField"); return aRet; } /*-- 11.12.98 09:57:01--------------------------------------------------- @@ -1065,35 +1066,9 @@ uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames(void) void SwXTextPortion::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) { ClientModify(this, pOld, pNew); - if(!aFrameDepend.GetRegisteredIn()) - pFrameFmt = 0; -} -/* -----------------------------19.02.01 10:52-------------------------------- - - ---------------------------------------------------------------------------*/ -SwXRubyPortion::SwXRubyPortion(const SwUnoCrsr* pPortionCrsr, - SwTxtRuby& rAttr, - uno::Reference< text::XText > const& rParent, - sal_Bool bEnd ) : - SwXTextPortion(pPortionCrsr, rParent, bEnd ? PORTION_RUBY_END : PORTION_RUBY_START ) -{ - if(!bEnd) + if (!m_FrameDepend.GetRegisteredIn()) { - const SfxPoolItem& rItem = rAttr.GetAttr(); - pRubyText = new uno::Any; - pRubyStyle = new uno::Any; - pRubyAdjust = new uno::Any; - pRubyIsAbove = new uno::Any; - rItem.QueryValue(*pRubyText, MID_RUBY_TEXT); - rItem.QueryValue(*pRubyStyle, MID_RUBY_CHARSTYLE); - rItem.QueryValue(*pRubyAdjust, MID_RUBY_ADJUST); - rItem.QueryValue(*pRubyIsAbove, MID_RUBY_ABOVE); + m_pFrameFmt = 0; } } -/* -----------------------------19.02.01 10:52-------------------------------- - - ---------------------------------------------------------------------------*/ -SwXRubyPortion::~SwXRubyPortion() -{ -} diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 5aa9d224c4..327bfd7c68 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -32,30 +32,37 @@ #include "precompiled_sw.hxx" +#include <unoport.hxx> #include <IMark.hxx> // --> OD 2007-10-23 #i81002# #include <crossrefbookmark.hxx> // <-- #include <doc.hxx> #include <txatbase.hxx> +#include <txtatr.hxx> #include <ndhints.hxx> #include <ndtxt.hxx> #include <unocrsr.hxx> #include <docary.hxx> -#include <fmthbsh.hxx> #include <tox.hxx> #include <unoclbck.hxx> #include <unoobj.hxx> #include <unoredline.hxx> +#include <unofield.hxx> +#include <unometa.hxx> #include <fmtanchr.hxx> +#include <fmtrfmrk.hxx> #include <unoidx.hxx> #include <redline.hxx> #include <crsskip.hxx> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> #include <set> + #include <boost/shared_ptr.hpp> #include <boost/bind.hpp> +#include <algorithm> +#include <stack> using namespace ::com::sun::star; @@ -64,6 +71,16 @@ using namespace ::com::sun::star::text; using ::rtl::OUString; using namespace ::std; +typedef ::std::pair< TextRangeList_t * const, SwTxtAttr const * const > PortionList_t; +typedef ::std::stack< PortionList_t > PortionStack_t; + +static void lcl_CreatePortions( + TextRangeList_t & i_rPortions, + uno::Reference< text::XText > const& i_xParentText, + SwUnoCrsr* pUnoCrsr, + FrameDependSortList_t & i_rFrames, + const sal_Int32 i_nStartPos, const sal_Int32 i_nEndPos ); + namespace { @@ -182,8 +199,9 @@ const uno::Sequence< sal_Int8 > & SwXTextPortionEnumeration::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXTextPortionEnumeration::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL SwXTextPortionEnumeration::getSomething( + const uno::Sequence< sal_Int8 >& rId ) +throw(uno::RuntimeException) { if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), @@ -196,167 +214,286 @@ sal_Int64 SAL_CALL SwXTextPortionEnumeration::getSomething( const uno::Sequence< /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXTextPortionEnumeration::getImplementationName(void) throw( RuntimeException ) +OUString SwXTextPortionEnumeration::getImplementationName() +throw( RuntimeException ) { return C2U("SwXTextPortionEnumeration"); } /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXTextPortionEnumeration::supportsService(const OUString& rServiceName) throw( RuntimeException ) +sal_Bool +SwXTextPortionEnumeration::supportsService(const OUString& rServiceName) +throw( RuntimeException ) { return C2U("com.sun.star.text.TextPortionEnumeration") == rServiceName; } /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -Sequence< OUString > SwXTextPortionEnumeration::getSupportedServiceNames(void) throw( RuntimeException ) +Sequence< OUString > SwXTextPortionEnumeration::getSupportedServiceNames() +throw( RuntimeException ) { Sequence< OUString > aRet(1); OUString* pArray = aRet.getArray(); pArray[0] = C2U("com.sun.star.text.TextPortionEnumeration"); return aRet; } + /*-- 27.01.99 10:44:43--------------------------------------------------- -----------------------------------------------------------------------*/ SwXTextPortionEnumeration::SwXTextPortionEnumeration( - SwPaM& rParaCrsr, - uno::Reference< XText > xParentText, - sal_Int32 nStart, - sal_Int32 nEnd - ) : - xParent(xParentText), - bAtEnd(sal_False), - bFirstPortion(sal_True), - nStartPos(nStart), - nEndPos(nEnd) + SwPaM& rParaCrsr, + uno::Reference< XText > const & xParentText, + const sal_Int32 nStart, + const sal_Int32 nEnd ) + : m_Portions() { - SwUnoCrsr* pUnoCrsr = rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), sal_False); + SwUnoCrsr* pUnoCrsr = + rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), sal_False); pUnoCrsr->Add(this); DBG_ASSERT(nEnd == -1 || (nStart <= nEnd && nEnd <= pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()->GetTxt().Len()), "start or end value invalid!"); - //alle Rahmen, Grafiken und OLEs suchen, die an diesem Absatz - // AM ZEICHEN gebunden sind - ::CollectFrameAtNode( *this, pUnoCrsr->GetPoint()->nNode, - aFrameArr, TRUE ); - CreatePortions(); + + // find all frames, graphics and OLEs that are bound AT character in para + FrameDependSortList_t frames; + ::CollectFrameAtNode(*this, pUnoCrsr->GetPoint()->nNode, frames, true); + lcl_CreatePortions(m_Portions, xParentText, pUnoCrsr, frames, nStart, nEnd); +} + +SwXTextPortionEnumeration::SwXTextPortionEnumeration( + SwPaM& rParaCrsr, + TextRangeList_t const & rPortions ) + : m_Portions( rPortions ) +{ + SwUnoCrsr* const pUnoCrsr = + rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), sal_False); + pUnoCrsr->Add(this); } + /*-- 27.01.99 10:44:44--------------------------------------------------- -----------------------------------------------------------------------*/ SwXTextPortionEnumeration::~SwXTextPortionEnumeration() { vos::OGuard aGuard(Application::GetSolarMutex()); - for(sal_uInt16 nFrame = aFrameArr.Count(); nFrame; ) - delete aFrameArr.GetObject( --nFrame ); - aFrameArr.Remove(0, aFrameArr.Count()); - - if( aPortionArr.Count() ) - aPortionArr.DeleteAndDestroy(0, aPortionArr.Count() ); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); delete pUnoCrsr; } /*-- 27.01.99 10:44:44--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextPortionEnumeration::hasMoreElements(void) throw( uno::RuntimeException ) +sal_Bool SwXTextPortionEnumeration::hasMoreElements() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - return aPortionArr.Count() > 0; + + return (m_Portions.size() > 0) ? sal_True : sal_False; } /*-- 27.01.99 10:44:45--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXTextPortionEnumeration::nextElement(void) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SwXTextPortionEnumeration::nextElement() +throw( container::NoSuchElementException, lang::WrappedTargetException, + uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!aPortionArr.Count()) + + if (!m_Portions.size()) throw container::NoSuchElementException(); - XTextRangeRefPtr pPortion = aPortionArr.GetObject(0); - Any aRet(pPortion, ::getCppuType((uno::Reference<XTextRange>*)0)); - aPortionArr.Remove(0); - delete pPortion; - return aRet; + + Any any; + any <<= m_Portions.front(); + m_Portions.pop_front(); + return any; +} + +//====================================================================== + +typedef ::std::deque< xub_StrLen > FieldMarks_t; + +static void +lcl_FillFieldMarkArray(FieldMarks_t & rFieldMarks, SwUnoCrsr const & rUnoCrsr, + const sal_Int32 i_nStartPos) +{ + const SwTxtNode * const pTxtNode = + rUnoCrsr.GetPoint()->nNode.GetNode().GetTxtNode(); + if (!pTxtNode) return; + + const sal_Unicode fld[] = { + CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDEND, CH_TXT_ATR_FORMELEMENT, 0 }; + xub_StrLen pos = ::std::max(static_cast<const sal_Int32>(0), i_nStartPos); + while ((pos = pTxtNode->GetTxt().SearchChar(fld, pos)) != STRING_NOTFOUND) + { + rFieldMarks.push_back(pos); + ++pos; + } } + +static uno::Reference<text::XTextRange> +lcl_ExportFieldMark( + uno::Reference< text::XText > const & i_xParentText, + SwUnoCrsr * const pUnoCrsr, + const SwTxtNode * const pTxtNode ) +{ + uno::Reference<text::XTextRange> xRef; + SwDoc* pDoc = pUnoCrsr->GetDoc(); + //flr: maybe its a good idea to add a special hint to the hints array and rely on the hint segmentation.... + const xub_StrLen start = pUnoCrsr->Start()->nContent.GetIndex(); + ASSERT(pUnoCrsr->End()->nContent.GetIndex() == start, + "hmm --- why is this different"); + + pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); + if ( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) + { + ASSERT(false, "cannot move cursor?"); + return 0; + } + + const sal_Unicode Char = pTxtNode->GetTxt().GetChar(start); + if (CH_TXT_ATR_FIELDSTART == Char) + { + ::sw::mark::IFieldmark* pFieldmark = NULL; + if (pDoc) + { + pFieldmark = pDoc->getIDocumentMarkAccess()-> + getFieldmarkFor(*pUnoCrsr->GetMark()); + } + SwXTextPortion* pPortion = new SwXTextPortion( + pUnoCrsr, i_xParentText, PORTION_FIELD_START); + xRef = pPortion; + if (pPortion && pFieldmark && pDoc) + pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc)); + } + else if (CH_TXT_ATR_FIELDEND == Char) + { + ::sw::mark::IFieldmark* pFieldmark = NULL; + if (pDoc) + { + pFieldmark = pDoc->getIDocumentMarkAccess()-> + getFieldmarkFor(*pUnoCrsr->GetMark()); + } + SwXTextPortion* pPortion = new SwXTextPortion( + pUnoCrsr, i_xParentText, PORTION_FIELD_END); + xRef = pPortion; + if (pPortion && pFieldmark && pDoc) + pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc)); + } + else if (CH_TXT_ATR_FORMELEMENT == Char) + { + ::sw::mark::IFieldmark* pFieldmark = NULL; + if (pDoc) + { + pFieldmark = pDoc->getIDocumentMarkAccess()-> + getFieldmarkFor(*pUnoCrsr->GetMark()); + } + SwXTextPortion* pPortion = new SwXTextPortion( + pUnoCrsr, i_xParentText, PORTION_FIELD_START_END); + xRef = pPortion; + if (pPortion && pFieldmark && pDoc) + pPortion->SetBookmark(new SwXFieldmark(true, pFieldmark, pDoc)); + } + else + { + ASSERT(false, "no fieldmark found?"); + } + return xRef; +} + /* -----------------------------31.08.00 14:28-------------------------------- ---------------------------------------------------------------------------*/ -void lcl_InsertRefMarkPortion( - XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, - Reference<XText> const& rParent, SwTxtAttr* pAttr, BOOL bEnd) +static Reference<XTextRange> +lcl_CreateRefMarkPortion( + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + const SwTxtAttr & rAttr, const bool bEnd) { SwDoc* pDoc = pUnoCrsr->GetDoc(); - SwFmtRefMark& rRefMark = ((SwFmtRefMark&)pAttr->GetAttr()); - Reference<XTextContent> xContent = ((SwUnoCallBack*)pDoc->GetUnoCallBack())->GetRefMark(rRefMark); - if(!xContent.is()) + const SwFmtRefMark& rRefMark = + static_cast<const SwFmtRefMark&>(rAttr.GetAttr()); + Reference<XTextContent> xContent = + static_cast<SwUnoCallBack*>(pDoc->GetUnoCallBack()) + ->GetRefMark(rRefMark); + if (!xContent.is()) + { xContent = new SwXReferenceMark(pDoc, &rRefMark); + } SwXTextPortion* pPortion = 0; - if(!bEnd) + if (!bEnd) { - rArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_REFMARK_START)), - rArr.Count()); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_REFMARK_START); pPortion->SetRefMark(xContent); - pPortion->SetCollapsed(pAttr->GetEnd() ? FALSE : TRUE); + pPortion->SetCollapsed(rAttr.GetEnd() ? false : true); } else { - rArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_REFMARK_END)), - rArr.Count()); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_REFMARK_END); pPortion->SetRefMark(xContent); } + return pPortion; } + //----------------------------------------------------------------------------- -void lcl_InsertRubyPortion( XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, - Reference<XText> const& rParent, SwTxtAttr* pAttr, BOOL bEnd) +static void +lcl_InsertRubyPortion( + TextRangeList_t & rPortions, + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + const SwTxtAttr & rAttr, const sal_Bool bEnd) { - SwXRubyPortion* pPortion = - new SwXRubyPortion(pUnoCrsr, *(SwTxtRuby*)pAttr, rParent, bEnd); - rArr.Insert( new Reference< XTextRange >(pPortion), rArr.Count() ); - pPortion->SetCollapsed(pAttr->GetEnd() ? FALSE : TRUE); + SwXTextPortion* pPortion = new SwXTextPortion(pUnoCrsr, + static_cast<const SwTxtRuby&>(rAttr), xParent, bEnd); + rPortions.push_back(pPortion); + pPortion->SetCollapsed(rAttr.GetEnd() ? false : true); } + //----------------------------------------------------------------------------- -void lcl_InsertTOXMarkPortion( - XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, Reference<XText> const& rParent, - SwTxtAttr* pAttr, BOOL bEnd) +static Reference<XTextRange> +lcl_CreateTOXMarkPortion( + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + const SwTxtAttr & rAttr, const bool bEnd) { SwDoc* pDoc = pUnoCrsr->GetDoc(); - SwTOXMark& rTOXMark = ((SwTOXMark&)pAttr->GetAttr()); + const SwTOXMark& rTOXMark = static_cast<const SwTOXMark&>(rAttr.GetAttr()); Reference<XTextContent> xContent = - ((SwUnoCallBack*)pDoc->GetUnoCallBack())->GetTOXMark(rTOXMark); - if(!xContent.is()) - xContent = new SwXDocumentIndexMark(rTOXMark.GetTOXType(), &rTOXMark, pDoc); + static_cast<SwUnoCallBack*>(pDoc->GetUnoCallBack()) + ->GetTOXMark(rTOXMark); + if (!xContent.is()) + { + xContent = new SwXDocumentIndexMark(rTOXMark.GetTOXType(), + &rTOXMark, pDoc); + } SwXTextPortion* pPortion = 0; - if(!bEnd) + if (!bEnd) { - rArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_TOXMARK_START)), - rArr.Count()); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_TOXMARK_START); pPortion->SetTOXMark(xContent); - pPortion->SetCollapsed(pAttr->GetEnd() ? FALSE : TRUE); + pPortion->SetCollapsed(rAttr.GetEnd() ? false : true); } - if(bEnd) + else { - rArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_TOXMARK_END)), - rArr.Count()); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_TOXMARK_END); pPortion->SetTOXMark(xContent); } + return pPortion; } //----------------------------------------------------------------------------- -void lcl_ExportBookmark( - SwXBookmarkPortion_ImplList& rBkmArr, ULONG nIndex, - SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr) +static void +lcl_ExportBookmark( + TextRangeList_t & rPortions, + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + SwXBookmarkPortion_ImplList& rBkmArr, const ULONG nIndex) { for ( SwXBookmarkPortion_ImplList::iterator aIter = rBkmArr.begin(), aEnd = rBkmArr.end(); aIter != aEnd; ) @@ -371,31 +508,37 @@ void lcl_ExportBookmark( break; SwXTextPortion* pPortion = 0; - if(BKM_TYPE_START == pPtr->nBkmType || BKM_TYPE_START_END == pPtr->nBkmType) + if ((BKM_TYPE_START == pPtr->nBkmType) || + (BKM_TYPE_START_END == pPtr->nBkmType)) { - rPortionArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_BOOKMARK_START)), - rPortionArr.Count()); + pPortion = + new SwXTextPortion(pUnoCrsr, xParent, PORTION_BOOKMARK_START); + rPortions.push_back(pPortion); pPortion->SetBookmark(pPtr->xBookmark); - pPortion->SetCollapsed(BKM_TYPE_START_END == pPtr->nBkmType ? TRUE : FALSE); + pPortion->SetCollapsed( (BKM_TYPE_START_END == pPtr->nBkmType) + ? true : false); } - if(BKM_TYPE_END == pPtr->nBkmType) + if (BKM_TYPE_END == pPtr->nBkmType) { - rPortionArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_BOOKMARK_END)), - rPortionArr.Count()); + pPortion = + new SwXTextPortion(pUnoCrsr, xParent, PORTION_BOOKMARK_END); + rPortions.push_back(pPortion); pPortion->SetBookmark(pPtr->xBookmark); } rBkmArr.erase( aIter++ ); } } -void lcl_ExportSoftPageBreak( - SwSoftPageBreakList& rBreakArr, ULONG nIndex, - SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr) +static void +lcl_ExportSoftPageBreak( + TextRangeList_t & rPortions, + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + SwSoftPageBreakList& rBreakArr, const ULONG nIndex) { - for ( SwSoftPageBreakList::iterator aIter = rBreakArr.begin(), aEnd = rBreakArr.end(); + for ( SwSoftPageBreakList::iterator aIter = rBreakArr.begin(), + aEnd = rBreakArr.end(); aIter != aEnd; ) { if ( nIndex > *aIter ) @@ -406,9 +549,8 @@ void lcl_ExportSoftPageBreak( if ( nIndex < *aIter ) break; - rPortionArr.Insert( - new Reference< XTextRange >(new SwXTextPortion(pUnoCrsr, rParent, PORTION_SOFT_PAGEBREAK)), - rPortionArr.Count()); + rPortions.push_back( + new SwXTextPortion(pUnoCrsr, xParent, PORTION_SOFT_PAGEBREAK) ); rBreakArr.erase( aIter++ ); } } @@ -426,49 +568,60 @@ void lcl_ExportSoftPageBreak( struct SwXRedlinePortion_Impl { - const SwRedline* pRedline; - sal_Bool bStart; + const SwRedline* m_pRedline; + const bool m_bStart; - SwXRedlinePortion_Impl ( const SwRedline* pRed, sal_Bool bIsStart ) - : pRedline(pRed) - , bStart(bIsStart) + SwXRedlinePortion_Impl ( const SwRedline* pRed, const bool bIsStart ) + : m_pRedline(pRed) + , m_bStart(bIsStart) { } + ULONG getRealIndex () { - return bStart ? pRedline->Start()->nContent.GetIndex() : - pRedline->End() ->nContent.GetIndex(); + return m_bStart ? m_pRedline->Start()->nContent.GetIndex() + : m_pRedline->End() ->nContent.GetIndex(); } }; -typedef boost::shared_ptr < SwXRedlinePortion_Impl > SwXRedlinePortion_ImplSharedPtr; +typedef boost::shared_ptr < SwXRedlinePortion_Impl > + SwXRedlinePortion_ImplSharedPtr; + struct RedlineCompareStruct { const SwPosition& getPosition ( const SwXRedlinePortion_ImplSharedPtr &r ) { - return *(r->bStart ? r->pRedline->Start() : r->pRedline->End()); + return *(r->m_bStart ? r->m_pRedline->Start() : r->m_pRedline->End()); } + bool operator () ( const SwXRedlinePortion_ImplSharedPtr &r1, const SwXRedlinePortion_ImplSharedPtr &r2 ) { return getPosition ( r1 ) < getPosition ( r2 ); } }; -typedef std::multiset < SwXRedlinePortion_ImplSharedPtr, RedlineCompareStruct > SwXRedlinePortion_ImplList; + +typedef std::multiset < SwXRedlinePortion_ImplSharedPtr, RedlineCompareStruct > +SwXRedlinePortion_ImplList; //----------------------------------------------------------------------------- -Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, - XTextRangeArr& rPortionArr, - SwUnoCrsr* pUnoCrsr, - const Reference<XText> & rParent, +static Reference<XTextRange> +lcl_ExportHints( + PortionStack_t & rPortionStack, + const Reference<XText> & xParent, + SwUnoCrsr * const pUnoCrsr, + SwpHints * const pHints, + const sal_Int32 i_nStartPos, + const sal_Int32 i_nEndPos, const xub_StrLen nCurrentIndex, - SwTextPortionType & rePortionType, - bool & io_rbRightMoveForbidden, + const bool bRightMoveForbidden, + bool & o_rbCursorMoved, sal_Int32 & o_rNextAttrPosition ) { + // if the attribute has a dummy character, then xRef is set (except META) + // otherwise, the portion for the attribute is inserted into rPortions! Reference<XTextRange> xRef; SwDoc* pDoc = pUnoCrsr->GetDoc(); - bool bAlreadyMoved = false; //search for special text attributes - first some ends sal_uInt16 nEndIndex = 0; sal_uInt16 nNextEnd = 0; @@ -478,35 +631,88 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, { if(pHints->GetEnd(nEndIndex)->GetEnd()) { - SwTxtAttr* pAttr = pHints->GetEnd(nEndIndex); - USHORT nAttrWhich = pAttr->Which(); - if(nNextEnd == nCurrentIndex && - ( RES_TXTATR_TOXMARK == nAttrWhich || - RES_TXTATR_REFMARK == nAttrWhich || - RES_TXTATR_CJK_RUBY == nAttrWhich)) + SwTxtAttr * const pAttr = pHints->GetEnd(nEndIndex); + if (nNextEnd == nCurrentIndex) { - switch( nAttrWhich ) + const USHORT nWhich( pAttr->Which() ); + switch (nWhich) { case RES_TXTATR_TOXMARK: - lcl_InsertTOXMarkPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - rePortionType = PORTION_TEXT; + { + Reference<XTextRange> xTmp = lcl_CreateTOXMarkPortion( + xParent, pUnoCrsr, *pAttr, true); + rPortionStack.top().first->push_back(xTmp); + } break; case RES_TXTATR_REFMARK: - lcl_InsertRefMarkPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - rePortionType = PORTION_TEXT; + { + Reference<XTextRange> xTmp = lcl_CreateRefMarkPortion( + xParent, pUnoCrsr, *pAttr, true); + rPortionStack.top().first->push_back(xTmp); + } break; case RES_TXTATR_CJK_RUBY: //#i91534# GetEnd() == 0 mixes the order of ruby start/end if( *pAttr->GetEnd() == *pAttr->GetStart()) { - lcl_InsertRubyPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, sal_False); + lcl_InsertRubyPortion( *rPortionStack.top().first, + xParent, pUnoCrsr, *pAttr, sal_False); } - lcl_InsertRubyPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - rePortionType = PORTION_TEXT; + lcl_InsertRubyPortion( *rPortionStack.top().first, + xParent, pUnoCrsr, *pAttr, sal_True); + break; + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + { + ASSERT(*pAttr->GetStart() != *pAttr->GetEnd(), + "empty meta?"); + if ((i_nStartPos > 0) && + (*pAttr->GetStart() < i_nStartPos)) + { + // force skip pAttr and rest of attribute ends + // at nCurrentIndex + // because they are not contained in the meta pAttr + // and the meta pAttr itself is outside selection! + // (necessary for SwXMeta::createEnumeration) + if (*pAttr->GetStart() + 1 == i_nStartPos) + { + nEndIndex = pHints->GetEndCount() - 1; + } + break; + } + PortionList_t Top = rPortionStack.top(); + if (Top.second != pAttr) + { + ASSERT(false, "ExportHints: stack error" ); + } + else + { + TextRangeList_t *const pCurrentPortions(Top.first); + rPortionStack.pop(); + SwXTextPortion * pPortion; + if (RES_TXTATR_META == nWhich) + { + SwXMeta * const pMeta = + new SwXMeta(pDoc, xParent, + pCurrentPortions, + static_cast<SwTxtMeta * const>(pAttr)); + pPortion = new SwXTextPortion( + pUnoCrsr, xParent, PORTION_META); + pPortion->SetMeta(pMeta); + } + else + { + SwXMetaField * const pMeta = + new SwXMetaField(pDoc, xParent, + pCurrentPortions, + static_cast<SwTxtMeta * const>(pAttr)); + pPortion = new SwXTextPortion( + pUnoCrsr, xParent, PORTION_FIELD); + pPortion->SetTextField(pMeta); + } + rPortionStack.top().first->push_back(pPortion); + } + } break; } } @@ -520,128 +726,126 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, while(nStartIndex < pHints->GetStartCount() && nCurrentIndex >= (nNextStart = (*pHints->GetStart(nStartIndex)->GetStart()))) { - SwTxtAttr* pAttr = pHints->GetStart(nStartIndex); + const SwTxtAttr * const pAttr = pHints->GetStart(nStartIndex); USHORT nAttrWhich = pAttr->Which(); - if(nNextStart == nCurrentIndex && - (!pAttr->GetEnd() || - RES_TXTATR_TOXMARK == nAttrWhich || - RES_TXTATR_REFMARK == nAttrWhich|| - RES_TXTATR_CJK_RUBY == nAttrWhich)) + if (nNextStart == nCurrentIndex) { switch( nAttrWhich ) { case RES_TXTATR_FIELD: - if(!io_rbRightMoveForbidden) + if(!bRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) break; - bAlreadyMoved = true; - rePortionType = PORTION_FIELD; + SwXTextPortion* pPortion; + xRef = pPortion = new SwXTextPortion( + pUnoCrsr, xParent, PORTION_FIELD); + Reference<XTextField> xField = + CreateSwXTextField(*pDoc, pAttr->GetFld()); + pPortion->SetTextField(xField); } break; case RES_TXTATR_FLYCNT : - if(!io_rbRightMoveForbidden) + if(!bRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) break; // Robust #i81708 content in covered cells pUnoCrsr->Exchange(); - bAlreadyMoved = true; - rePortionType = PORTION_FRAME; + xRef = new SwXTextPortion( + pUnoCrsr, xParent, PORTION_FRAME); } break; case RES_TXTATR_FTN : { - if(!io_rbRightMoveForbidden) + if(!bRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) break; SwXTextPortion* pPortion; - xRef = pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_FOOTNOTE); - Reference<XTextContent> xContent = - Reference<XTextContent>( - SwXFootnotes::GetObject(*pDoc, pAttr->SwTxtAttr::GetFtn()), - UNO_QUERY); + xRef = pPortion = new SwXTextPortion( + pUnoCrsr, xParent, PORTION_FOOTNOTE); + Reference<XFootnote> xContent = + SwXFootnotes::GetObject(*pDoc, pAttr->GetFtn()); pPortion->SetFootnote(xContent); - bAlreadyMoved = true; - rePortionType = PORTION_TEXT; } } break; - case RES_TXTATR_SOFTHYPH : - { - SwXTextPortion* pPortion = 0; - rPortionArr.Insert( - new Reference< XTextRange >( - pPortion = new SwXTextPortion( - pUnoCrsr, rParent, PORTION_CONTROL_CHAR)), - rPortionArr.Count()); - pPortion->SetControlChar(3); - rePortionType = PORTION_TEXT; - } - break; - case RES_TXTATR_HARDBLANK: - { - rePortionType = PORTION_CONTROL_CHAR; - SwXTextPortion* pPortion = 0; - rPortionArr.Insert( - new Reference< XTextRange >( - pPortion = new SwXTextPortion( - pUnoCrsr, rParent, PORTION_CONTROL_CHAR)), - rPortionArr.Count()); - const SwFmtHardBlank& rFmt = pAttr->GetHardBlank(); - if(rFmt.GetChar() == '-') - pPortion->SetControlChar(2);//HARD_HYPHEN - else - pPortion->SetControlChar(4);//HARD_SPACE - rePortionType = PORTION_TEXT; - } - break; case RES_TXTATR_TOXMARK: - lcl_InsertTOXMarkPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - rePortionType = PORTION_TEXT; - break; case RES_TXTATR_REFMARK: - - if(!io_rbRightMoveForbidden || pAttr->GetEnd()) + { + bool bIsPoint = !(pAttr->GetEnd()); + if (!bRightMoveForbidden || !bIsPoint) { - if(!pAttr->GetEnd()) + if (bIsPoint) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); - bAlreadyMoved = true; } - lcl_InsertRefMarkPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - rePortionType = PORTION_TEXT; - if(!pAttr->GetEnd()) + Reference<XTextRange> xTmp = + (RES_TXTATR_REFMARK == nAttrWhich) + ? lcl_CreateRefMarkPortion( + xParent, pUnoCrsr, *pAttr, false) + : lcl_CreateTOXMarkPortion( + xParent, pUnoCrsr, *pAttr, false); + if (bIsPoint) // consume CH_TXTATR! { - if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); + pUnoCrsr->Normalize(FALSE); pUnoCrsr->DeleteMark(); + xRef = xTmp; + } + else // just insert it + { + rPortionStack.top().first->push_back(xTmp); } } + } break; case RES_TXTATR_CJK_RUBY: //#i91534# GetEnd() == 0 mixes the order of ruby start/end if(pAttr->GetEnd() && (*pAttr->GetEnd() != *pAttr->GetStart())) { - lcl_InsertRubyPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - rePortionType = PORTION_TEXT; + lcl_InsertRubyPortion( *rPortionStack.top().first, + xParent, pUnoCrsr, *pAttr, sal_False); } break; + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + if (*pAttr->GetStart() != *pAttr->GetEnd()) + { + if (!bRightMoveForbidden) + { + pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); + o_rbCursorMoved = true; + // only if the end is included in selection! + if ((i_nEndPos < 0) || + (*pAttr->GetEnd() <= i_nEndPos)) + { + rPortionStack.push( ::std::make_pair( + new TextRangeList_t, pAttr )); + } + } + } + break; + case RES_TXTATR_AUTOFMT: + case RES_TXTATR_INETFMT: + case RES_TXTATR_CHARFMT: + case RES_TXTATR_UNKNOWN_CONTAINER: + break; // these are handled as properties of a "Text" portion default: - DBG_ERROR("was fuer ein Attribut?"); + DBG_ERROR("unknown attribute"); + break; } - } nStartIndex++; } - if (!bAlreadyMoved) + if (xRef.is()) // implies that we have moved the cursor + { + o_rbCursorMoved = true; + } + if (!o_rbCursorMoved) { // search for attribute changes behind the current cursor position // break up at frames, bookmarks, redlines @@ -666,17 +870,15 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, o_rNextAttrPosition = nNextPos; } } - else - { - io_rbRightMoveForbidden = true; - } return xRef; } -void lcl_MoveCursor( SwUnoCrsr* pUnoCrsr, +//----------------------------------------------------------------------------- +void lcl_MoveCursor( SwUnoCrsr * const pUnoCrsr, const xub_StrLen nCurrentIndex, const sal_Int32 nNextFrameIndex, const sal_Int32 nNextPortionIndex, - const sal_Int32 nNextAttrIndex, const sal_Int32 nEndPos ) + const sal_Int32 nNextAttrIndex, const sal_Int32 nNextFieldMarkIndex, + const sal_Int32 nEndPos ) { sal_Int32 nMovePos = pUnoCrsr->GetCntntNode()->Len(); @@ -700,26 +902,22 @@ void lcl_MoveCursor( SwUnoCrsr* pUnoCrsr, nMovePos = nNextAttrIndex; } + if ((nNextFieldMarkIndex >= 0) && (nNextFieldMarkIndex < nMovePos)) + { + nMovePos = nNextFieldMarkIndex; + } + if (nMovePos > nCurrentIndex) { // pUnoCrsr->Right(nMovePos - nCurrentIndex); pUnoCrsr->GetPoint()->nContent = static_cast<USHORT>(nMovePos); } - else if(nEndPos < 0 || nCurrentIndex < nEndPos) - { - // ensure proper exit: move to paragraph end - // (this should not be necessary any more; we assert it only - // happens when the above would move to the end of the - // paragraph anyway) - DBG_ASSERT(nMovePos == pUnoCrsr->GetCntntNode()->Len()|| - (nEndPos > 0 && nMovePos == nEndPos), - "may only happen at paragraph end"); - pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); - } } //----------------------------------------------------------------------------- -void lcl_FillRedlineArray(SwDoc& rDoc,SwUnoCrsr& rUnoCrsr, SwXRedlinePortion_ImplList& rRedArr ) +static void +lcl_FillRedlineArray(SwDoc const & rDoc, SwUnoCrsr const & rUnoCrsr, + SwXRedlinePortion_ImplList& rRedArr ) { const SwRedlineTbl& rRedTbl = rDoc.GetRedlineTbl(); USHORT nRedTblCount = rRedTbl.Count(); @@ -736,18 +934,21 @@ void lcl_FillRedlineArray(SwDoc& rDoc,SwUnoCrsr& rUnoCrsr, SwXRedlinePortion_Imp const SwNodeIndex nRedNode = pRedStart->nNode; if ( nOwnNode == nRedNode ) rRedArr.insert( SwXRedlinePortion_ImplSharedPtr ( - new SwXRedlinePortion_Impl ( pRedline, TRUE) ) ); + new SwXRedlinePortion_Impl ( pRedline, true ) ) ); if( pRedline->HasMark() && pRedline->End()->nNode == nOwnNode ) rRedArr.insert( SwXRedlinePortion_ImplSharedPtr ( - new SwXRedlinePortion_Impl ( pRedline, FALSE) ) ); + new SwXRedlinePortion_Impl ( pRedline, false) ) ); } } } //----------------------------------------------------------------------------- -void lcl_FillSoftPageBreakArray( SwUnoCrsr& rUnoCrsr, SwSoftPageBreakList& rBreakArr ) +static void +lcl_FillSoftPageBreakArray( + SwUnoCrsr const & rUnoCrsr, SwSoftPageBreakList& rBreakArr ) { - const SwTxtNode *pTxtNode = rUnoCrsr.GetPoint()->nNode.GetNode().GetTxtNode(); + const SwTxtNode *pTxtNode = + rUnoCrsr.GetPoint()->nNode.GetNode().GetTxtNode(); if( pTxtNode ) pTxtNode->fillSoftPageBreakList( rBreakArr ); } @@ -755,9 +956,12 @@ void lcl_FillSoftPageBreakArray( SwUnoCrsr& rUnoCrsr, SwSoftPageBreakList& rBrea /* -----------------------------19.12.00 12:25-------------------------------- ---------------------------------------------------------------------------*/ -void lcl_ExportRedline( - SwXRedlinePortion_ImplList& rRedlineArr, ULONG nIndex, - SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr) +static void +lcl_ExportRedline( + TextRangeList_t & rPortions, + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + SwXRedlinePortion_ImplList& rRedlineArr, const ULONG nIndex) { // MTG: 23/11/05: We want this loop to iterate over all red lines in this @@ -773,10 +977,8 @@ void lcl_ExportRedline( // MTG: 23/11/05: If the elements match, and them to the list else if ( nIndex == nRealIndex ) { - rPortionArr.Insert( - new Reference< XTextRange >( new SwXRedlinePortion( - pPtr->pRedline, pUnoCrsr, rParent, pPtr->bStart)), - rPortionArr.Count()); + rPortions.push_back( new SwXRedlinePortion( + pPtr->m_pRedline, pUnoCrsr, xParent, pPtr->m_bStart) ); rRedlineArr.erase ( aIter++ ); } // MTG: 23/11/05: If we've iterated past nIndex, exit the loop @@ -784,29 +986,63 @@ void lcl_ExportRedline( break; } } + /* -----------------------------19.12.00 13:09-------------------------------- ---------------------------------------------------------------------------*/ -void lcl_ExportBkmAndRedline( +static void +lcl_ExportBkmAndRedline( + TextRangeList_t & rPortions, + Reference<XText> const & xParent, + const SwUnoCrsr * const pUnoCrsr, SwXBookmarkPortion_ImplList& rBkmArr, SwXRedlinePortion_ImplList& rRedlineArr, SwSoftPageBreakList& rBreakArr, - ULONG nIndex, - SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr) + const ULONG nIndex) { if (rBkmArr.size()) - lcl_ExportBookmark(rBkmArr, nIndex, pUnoCrsr, rParent, rPortionArr); + lcl_ExportBookmark(rPortions, xParent, pUnoCrsr, rBkmArr, nIndex); if (rRedlineArr.size()) - lcl_ExportRedline(rRedlineArr, nIndex, pUnoCrsr, rParent, rPortionArr); + lcl_ExportRedline(rPortions, xParent, pUnoCrsr, rRedlineArr, nIndex); if (rBreakArr.size()) - lcl_ExportSoftPageBreak(rBreakArr, nIndex, pUnoCrsr, rParent, rPortionArr); + lcl_ExportSoftPageBreak(rPortions, xParent, pUnoCrsr, rBreakArr, nIndex); } + //----------------------------------------------------------------------------- -sal_Int32 lcl_GetNextIndex(SwXBookmarkPortion_ImplList& rBkmArr, - SwXRedlinePortion_ImplList& rRedlineArr, - SwSoftPageBreakList& rBreakArr ) +static sal_Int32 +lcl_ExportFrames( + TextRangeList_t & rPortions, + Reference<XText> const & i_xParent, + SwUnoCrsr * const i_pUnoCrsr, + FrameDependSortList_t & i_rFrames, + xub_StrLen const i_nCurrentIndex) +{ + // find first Frame in (sorted) i_rFrames at current position + while (i_rFrames.size() && (i_rFrames.front().nIndex == i_nCurrentIndex)) + // do not check for i_nEnd here; this is done implicity by lcl_MoveCursor + { + const SwModify * const pFrame = + i_rFrames.front().pFrameDepend->GetRegisteredIn(); + if (pFrame) // Frame could be disposed + { + SwXTextPortion* pPortion = new SwXTextPortion(i_pUnoCrsr, i_xParent, + *static_cast<SwFrmFmt*>( const_cast<SwModify*>( pFrame ) ) ); + rPortions.push_back(pPortion); + } + i_rFrames.pop_front(); + } + + return i_rFrames.size() ? i_rFrames.front().nIndex : -1; +} + +//----------------------------------------------------------------------------- +static sal_Int32 +lcl_GetNextIndex( + SwXBookmarkPortion_ImplList const & rBkmArr, + SwXRedlinePortion_ImplList const & rRedlineArr, + SwSoftPageBreakList const & rBreakArr ) { sal_Int32 nRet = -1; if(rBkmArr.size()) @@ -828,284 +1064,146 @@ sal_Int32 lcl_GetNextIndex(SwXBookmarkPortion_ImplList& rBkmArr, } return nRet; }; + //----------------------------------------------------------------------------- -void SwXTextPortionEnumeration::CreatePortions() +static void +lcl_CreatePortions( + TextRangeList_t & i_rPortions, + uno::Reference< text::XText > const & i_xParentText, + SwUnoCrsr * const pUnoCrsr, + FrameDependSortList_t & i_rFrames, + const sal_Int32 i_nStartPos, + const sal_Int32 i_nEndPos ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); + if (!pUnoCrsr) + return; + // set the start if a selection should be exported - if(nStartPos > 0 && pUnoCrsr->Start()->nContent.GetIndex() != nStartPos) + if ((i_nStartPos > 0) && + (pUnoCrsr->Start()->nContent.GetIndex() != i_nStartPos)) { - if(pUnoCrsr->HasMark()) - pUnoCrsr->DeleteMark(); + pUnoCrsr->DeleteMark(); DBG_ASSERT(pUnoCrsr->Start()->nNode.GetNode().GetTxtNode() && - nStartPos <= pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()->GetTxt().Len(), - "Incorrect start position" ); - // ??? should this be nStartPos - current position ? - pUnoCrsr->Right((xub_StrLen)nStartPos,CRSR_SKIP_CHARS,FALSE,FALSE); + (i_nStartPos <= pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()-> + GetTxt().Len()), "Incorrect start position" ); + // ??? should this be i_nStartPos - current position ? + pUnoCrsr->Right(static_cast<xub_StrLen>(i_nStartPos), + CRSR_SKIP_CHARS, FALSE, FALSE); } - if(pUnoCrsr /*&& !bAtEnd*/) + + FieldMarks_t FieldMarks; + SwXBookmarkPortion_ImplList Bookmarks; + SwXRedlinePortion_ImplList Redlines; + SwSoftPageBreakList SoftPageBreaks; + + SwDoc * const pDoc = pUnoCrsr->GetDoc(); + lcl_FillFieldMarkArray(FieldMarks, *pUnoCrsr, i_nStartPos); + lcl_FillBookmarkArray(*pDoc, *pUnoCrsr, Bookmarks); + lcl_FillRedlineArray(*pDoc, *pUnoCrsr, Redlines); + lcl_FillSoftPageBreakArray(*pUnoCrsr, SoftPageBreaks); + + PortionStack_t PortionStack; + PortionStack.push( PortionList_t(&i_rPortions, 0) ); + + bool bAtEnd( false ); + while (!bAtEnd) // every iteration consumes at least current character! { - SwXBookmarkPortion_ImplList aBkmArr; - SwXRedlinePortion_ImplList aRedArr; - SwSoftPageBreakList aBreakArr; - - SwDoc* pDoc = pUnoCrsr->GetDoc(); - lcl_FillRedlineArray(*pDoc, *pUnoCrsr, aRedArr); - lcl_FillBookmarkArray(*pDoc, *pUnoCrsr, aBkmArr ); - lcl_FillSoftPageBreakArray( *pUnoCrsr, aBreakArr ); -#if OSL_DEBUG_LEVEL > 1 - for (SwXBookmarkPortion_ImplList::const_iterator aIter = aBkmArr.begin(), aEnd = aBkmArr.end(); - aIter != aEnd; - ++aIter ) + if (pUnoCrsr->HasMark()) { - SwXBookmarkPortion_ImplSharedPtr pPtr = (*aIter); + pUnoCrsr->Normalize(FALSE); + pUnoCrsr->DeleteMark(); } -#endif - while(!bAtEnd) + SwTxtNode * const pTxtNode = pUnoCrsr->GetNode()->GetTxtNode(); + if (!pTxtNode) { - if(pUnoCrsr->HasMark()) + DBG_ERROR("lcl_CreatePortions: no TextNode - what now ?"); + return; + } + + SwpHints * const pHints = pTxtNode->GetpSwpHints(); + const xub_StrLen nCurrentIndex = + pUnoCrsr->GetPoint()->nContent.GetIndex(); + // this contains the portion which consumes the character in the + // text at nCurrentIndex; i.e. it must be set _once_ per iteration + uno::Reference< XTextRange > xRef; + + SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); // set mark + + const sal_Int32 nFirstFrameIndex = + lcl_ExportFrames( *PortionStack.top().first, + i_xParentText, pUnoCrsr, i_rFrames, nCurrentIndex); + + lcl_ExportBkmAndRedline( *PortionStack.top().first, i_xParentText, + pUnoCrsr, Bookmarks, Redlines, SoftPageBreaks, nCurrentIndex ); + + bool bCursorMoved( false ); + sal_Int32 nNextAttrIndex = -1; + // #111716# the cursor must not move right at the + // end position of a selection! + bAtEnd = ((i_nEndPos >= 0) && (nCurrentIndex >= i_nEndPos)) + || (nCurrentIndex >= pTxtNode->Len()); + if (pHints) + { + // N.B.: side-effects nNextAttrIndex, bCursorMoved; may move cursor + xRef = lcl_ExportHints(PortionStack, i_xParentText, pUnoCrsr, + pHints, i_nStartPos, i_nEndPos, nCurrentIndex, bAtEnd, + bCursorMoved, nNextAttrIndex); + if (PortionStack.empty()) { - if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); - pUnoCrsr->DeleteMark(); + ASSERT(false, "CreatePortions: stack underflow"); + return; } - SwNode* pNode = pUnoCrsr->GetNode(); - SwCntntNode *pCNd = pNode->GetCntntNode(); - if(!bFirstPortion && pCNd && - pUnoCrsr->GetPoint()->nContent == pCNd->Len()) + } + + if (!xRef.is() && !bCursorMoved) + { + if (!bAtEnd && + FieldMarks.size() && (FieldMarks.front() == nCurrentIndex)) { - //hier sollte man nie ankommen! - bAtEnd = sal_True; + // moves cursor + xRef = lcl_ExportFieldMark(i_xParentText, pUnoCrsr, pTxtNode); + FieldMarks.pop_front(); } - else - { - if(ND_TEXTNODE == pNode->GetNodeType()) - { - SwTxtNode* pTxtNode = (SwTxtNode*)pNode; - SwpHints* pHints = pTxtNode->GetpSwpHints(); - SwTextPortionType ePortionType = PORTION_TEXT; - xub_StrLen nCurrentIndex = pUnoCrsr->GetPoint()->nContent.GetIndex(); - xub_StrLen nFirstFrameIndex = STRING_MAXLEN; - uno::Reference< XTextRange > xRef; - if(!pCNd->Len()) - { - lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr, 0, pUnoCrsr, xParent, aPortionArr); - // the paragraph is empty - xRef = new SwXTextPortion(pUnoCrsr, xParent, ePortionType); - // are there any frames? - while(aFrameArr.Count()) - { - SwDepend* pCurDepend = aFrameArr.GetObject(0); - if(pCurDepend->GetRegisteredIn()) - { - //the previously created portion has to be inserted here - aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count()); - xRef = new SwXTextPortion(pUnoCrsr, xParent, - *(SwFrmFmt*)pCurDepend->GetRegisteredIn()); - } - delete pCurDepend; - aFrameArr.Remove(0); - } - } - else - { - //falls schon Rahmen entsorgt wurden, dann raus hier - for(sal_uInt16 nFrame = aFrameArr.Count(); nFrame; nFrame--) - { - SwDepend* pCurDepend = aFrameArr.GetObject(nFrame - 1); - if(!pCurDepend->GetRegisteredIn()) - { - delete pCurDepend; - aFrameArr.Remove(nFrame - 1); - } - } + } + else + { + ASSERT(!FieldMarks.size() || + (FieldMarks.front() != nCurrentIndex), + "fieldmark and hint with CH_TXTATR at same pos?"); + } - //zunaechst den ersten Frame im aFrameArr finden (bezogen auf die Position im Absatz) - SwDepend* pFirstFrameDepend = 0; - //Eintraege im aFrameArr sind sortiert! - if(aFrameArr.Count()) - { - SwDepend* pCurDepend = aFrameArr.GetObject(0); - SwFrmFmt* pFormat = (SwFrmFmt*)pCurDepend->GetRegisteredIn(); - const SwFmtAnchor& rAnchor = pFormat->GetAnchor(); - const SwPosition* pAnchorPos = rAnchor.GetCntntAnchor(); - pFirstFrameDepend = pCurDepend; - nFirstFrameIndex = pAnchorPos->nContent.GetIndex(); - if(nEndPos >= 0 && nFirstFrameIndex >= nEndPos) - nFirstFrameIndex = USHRT_MAX; - } + if (!bAtEnd && !xRef.is() && !bCursorMoved) + { + const sal_Int32 nNextPortionIndex = + lcl_GetNextIndex(Bookmarks, Redlines, SoftPageBreaks); + const sal_Int32 nNextFieldMarkIndex( + FieldMarks.size() ? FieldMarks.front() : -1); - SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); + lcl_MoveCursor(pUnoCrsr, nCurrentIndex, + nFirstFrameIndex, nNextPortionIndex, nNextAttrIndex, + nNextFieldMarkIndex, + i_nEndPos); - //ist hier schon ein Rahmen faellig? - if(nCurrentIndex == nFirstFrameIndex) - { - xRef = new SwXTextPortion(pUnoCrsr, xParent, - *(SwFrmFmt*)pFirstFrameDepend->GetRegisteredIn()); - SwDepend* pCurDepend = aFrameArr.GetObject(0); - delete pCurDepend; - aFrameArr.Remove(0); - } - } - if(!xRef.is()) - { - lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr, - nCurrentIndex, pUnoCrsr, xParent, aPortionArr); - sal_Int32 nNextAttrIndex = -1; - sal_Int32 nNextPortionIndex = - lcl_GetNextIndex(aBkmArr, aRedArr, aBreakArr); - // #111716# the cursor must not move right at the - // end position of a selection! - bool bRightMoveForbidden = - ((nEndPos > 0) && (nCurrentIndex >= nEndPos)); - if (pHints) - { - // N.B.: side-effects bRightMoveForbidden - // and nNextAttrIndex - xRef = lcl_ExportHints(pHints, aPortionArr, - pUnoCrsr, xParent, nCurrentIndex, ePortionType, - bRightMoveForbidden, nNextAttrIndex); - } - if (!bRightMoveForbidden) - { - lcl_MoveCursor(pUnoCrsr, nCurrentIndex, - nFirstFrameIndex, nNextPortionIndex, - nNextAttrIndex, nEndPos); - } - } - if(!xRef.is() && pUnoCrsr->HasMark() ) { - //flr: maybe its a good idea to add a special hint to the hints array and rely on the hint segmentation.... - xub_StrLen start=pUnoCrsr->Start()->nContent.GetIndex(); - xub_StrLen end=pUnoCrsr->End()->nContent.GetIndex(); - ASSERT(start<=end, "hmm --- why is this different"); - xub_StrLen startMarkerPos=pTxtNode->GetTxt().Search(CH_TXT_ATR_FIELDSTART, start); - xub_StrLen endMarkerPos=pTxtNode->GetTxt().Search(CH_TXT_ATR_FIELDEND, start); - xub_StrLen formMarkerPos=pTxtNode->GetTxt().Search(CH_TXT_ATR_FORMELEMENT, start); - xub_StrLen markerPos=STRING_LEN; - if (startMarkerPos>=start && startMarkerPos<end) - { - markerPos=startMarkerPos; - } - if (endMarkerPos>=start && endMarkerPos<end) - { - if (endMarkerPos<markerPos) - markerPos=endMarkerPos; - } - if (formMarkerPos>=start && formMarkerPos<end) - { - if (formMarkerPos<markerPos) - markerPos=formMarkerPos; - } - if (markerPos<end) - { - if (start==markerPos) - end = markerPos+1; - else - end = markerPos; - bAtEnd = sal_False; - pUnoCrsr->GetPoint()->nContent = end; - } - if (start+1==end && pTxtNode->GetTxt().GetChar(start)==CH_TXT_ATR_FIELDSTART) - { - ::sw::mark::IFieldmark* pFieldmark = NULL; - if (pDoc && pUnoCrsr->GetPoint()) - pFieldmark = pDoc->getIDocumentMarkAccess()->getFieldmarkFor(*pUnoCrsr->GetPoint()); - SwXTextPortion* pPortion = NULL; - xRef = (pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD_START)); - if (pPortion && pFieldmark && pDoc) - pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc)); - } - else if (start+1==end && pTxtNode->GetTxt().GetChar(start)==CH_TXT_ATR_FIELDEND) - { - ::sw::mark::IFieldmark* pFieldmark = NULL; - if (pDoc && pUnoCrsr->GetPoint()) - { - SwPosition aPos(*pUnoCrsr->GetPoint()); - aPos.nContent = markerPos; - pFieldmark = pDoc->getIDocumentMarkAccess()->getFieldmarkFor(aPos); - } - SwXTextPortion* pPortion = NULL; - xRef = (pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD_END)); - if (pPortion && pFieldmark && pDoc) - pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc)); - } - else if (start+1==end && pTxtNode->GetTxt().GetChar(start)==CH_TXT_ATR_FORMELEMENT) - { - ::sw::mark::IFieldmark* pFieldmark = NULL; - if (pDoc && pUnoCrsr->GetPoint()) - { - SwPosition aPos(*pUnoCrsr->GetPoint()); - aPos.nContent=markerPos; - pFieldmark = pDoc->getIDocumentMarkAccess()->getFieldmarkFor(aPos); - } - SwXTextPortion* pPortion=NULL; - xRef = (pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD_START_END)); - if(pPortion && pFieldmark && pDoc) - pPortion->SetBookmark(new SwXFieldmark(true, pFieldmark, pDoc)); - } - else - { - xRef = new SwXTextPortion(pUnoCrsr, xParent, ePortionType); - } - } - if(xRef.is()) - aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count()); - } - else - { - DBG_ERROR("kein TextNode - was nun?"); - } - } - if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); - - // Absatzende ? - pNode = pUnoCrsr->GetNode(); - pCNd = pNode->GetCntntNode(); - sal_Int32 nLocalEnd = nEndPos >= 0 ? nEndPos : pCNd->Len(); - if( pCNd && pUnoCrsr->GetPoint()->nContent >= (xub_StrLen)nLocalEnd) - { - bAtEnd = sal_True; - lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr, nLocalEnd, - pUnoCrsr, xParent, aPortionArr); - if(ND_TEXTNODE == pNode->GetNodeType()) - { - SwTxtNode* pTxtNode = (SwTxtNode*)pNode; - SwpHints* pHints = pTxtNode->GetpSwpHints(); - if(pHints) - { - SwTextPortionType ePortionType = PORTION_TEXT; - bool bDummy = false; - sal_Int32 nDummy = -1; - Reference<XTextRange> xRef = lcl_ExportHints(pHints, - aPortionArr, - pUnoCrsr, - xParent, - static_cast< xub_StrLen >(nLocalEnd), - ePortionType, - bDummy, nDummy); - if(xRef.is()) - aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count()); - } - } - while(aFrameArr.Count()) - { - SwDepend* pCurDepend = aFrameArr.GetObject(0); - if(pCurDepend->GetRegisteredIn()) - { - Reference<XTextRange> xRef = new SwXTextPortion(pUnoCrsr, xParent, - *(SwFrmFmt*)pCurDepend->GetRegisteredIn()); - aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count()); - } - delete pCurDepend; - aFrameArr.Remove(0); - } + xRef = new SwXTextPortion(pUnoCrsr, i_xParentText, PORTION_TEXT); + } + else if (bAtEnd && !xRef.is() && !pTxtNode->Len()) + { + // special case: for an empty paragraph, we better put out a + // text portion because there may be a hyperlink attribute + xRef = new SwXTextPortion(pUnoCrsr, i_xParentText, PORTION_TEXT); + } - } + if (xRef.is()) + { + PortionStack.top().first->push_back(xRef); } } + + ASSERT((PortionStack.size() == 1) && !PortionStack.top().second, + "CreatePortions: stack error" ); } + /*-- 27.01.99 10:44:45--------------------------------------------------- -----------------------------------------------------------------------*/ diff --git a/sw/source/core/unocore/unoprnms.cxx b/sw/source/core/unocore/unoprnms.cxx index d8ff216755..fc0cddd250 100644 --- a/sw/source/core/unocore/unoprnms.cxx +++ b/sw/source/core/unocore/unoprnms.cxx @@ -779,7 +779,8 @@ const SwPropNameTab aPropNameTab = { /* 0734 CHAR_OVERLINE_COLOR */ {MAP_CHAR_LEN("CharOverlineColor")}, /* 0735 CHAR_OVERLINE_HAS_COLOR */ {MAP_CHAR_LEN("CharOverlineHasColor")}, /* 0736 UNO_NAME_OUTLINE_LEVEL */ {MAP_CHAR_LEN("OutlineLevel")},//#outline level,add<-zhaojianwei Outlinelevel -/* 0737 UNO_NAME_DESCRIPTION */ {MAP_CHAR_LEN("Description")} +/* 0737 UNO_NAME_DESCRIPTION */ {MAP_CHAR_LEN("Description")}, +/* 0738 UNO_NAME_META */ {MAP_CHAR_LEN("InContentMetadata")}, }; const SwPropNameLen& SwGetPropName( USHORT nId ) diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index 22a12bb157..d3b85ff340 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -295,7 +295,7 @@ uno::Any SwXRedlinePortion::getPropertyValue( const OUString& rPropertyName ) { if ( 1 < ( pNodeIdx->GetNode().EndOfSectionIndex() - pNodeIdx->GetNode().GetIndex() ) ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); uno::Reference<text::XText> xRet = new SwXRedlineText(pUnoCrsr->GetDoc(), *pNodeIdx); aRet <<= xRet; } @@ -318,7 +318,7 @@ uno::Any SwXRedlinePortion::getPropertyValue( const OUString& rPropertyName ) ---------------------------------------------------------------------------*/ void SwXRedlinePortion::Validate() throw( uno::RuntimeException ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); //search for the redline diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 336ba97e68..752022c763 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -124,7 +124,7 @@ SwXReferenceMark::~SwXReferenceMark() /* -----------------03.11.99 14:14------------------- --------------------------------------------------*/ -void SwXReferenceMark::InsertRefMark( SwPaM& rPam ) +void SwXReferenceMark::InsertRefMark(SwPaM& rPam, SwXTextCursor * pCursor) { //! in some cases when this function is called the pDoc pointer member may have become //! invalid/deleted thus we obtain the document pointer from rPaM where it should always @@ -134,10 +134,19 @@ void SwXReferenceMark::InsertRefMark( SwPaM& rPam ) UnoActionContext aCont(pDoc2); SwTxtAttr* pTxtAttr = 0; SwFmtRefMark aRefMark(sMarkName); - SfxItemSet aSet(pDoc2->GetAttrPool(), RES_TXTATR_REFMARK, RES_TXTATR_REFMARK, 0L); - aSet.Put(aRefMark); +// SfxItemSet aSet(pDoc2->GetAttrPool(), RES_TXTATR_REFMARK, RES_TXTATR_REFMARK, 0L); +// aSet.Put(aRefMark); sal_Bool bMark = *rPam.GetPoint() != *rPam.GetMark(); - SwXTextCursor::SetCrsrAttr(rPam, aSet, 0); +// SwXTextCursor::SetCrsrAttr(rPam, aSet, 0); + + const bool bForceExpandHints( (!bMark && pCursor) + ? pCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND + | nsSetAttrMode::SETATTR_DONTEXPAND) + : nsSetAttrMode::SETATTR_DONTEXPAND; + + pDoc2->InsertPoolItem( rPam, aRefMark, nInsertFlags ); if( bMark && *rPam.GetPoint() > *rPam.GetMark()) rPam.Exchange(); @@ -146,8 +155,10 @@ void SwXReferenceMark::InsertRefMark( SwPaM& rPam ) pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttr( rPam.GetPoint()->nContent, RES_TXTATR_REFMARK ); else - pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttr( + { + pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( rPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_REFMARK ); + } if(pTxtAttr) pMark = &pTxtAttr->GetRefMark(); @@ -179,7 +190,7 @@ void SwXReferenceMark::attachToRange(const uno::Reference< text::XTextRange > & SwUnoInternalPaM aPam(*pDocument); //das muss jetzt sal_True liefern SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); - InsertRefMark(aPam); + InsertRefMark(aPam, dynamic_cast<SwXTextCursor*>(pCursor)); m_bIsDescriptor = sal_False; pDoc = pDocument; pDoc->GetUnoCallBack()->Add(this); @@ -318,7 +329,7 @@ void SwXReferenceMark::setName(const OUString& Name_) throw( uno::RuntimeExcepti sMarkName = sNewName; //create a new one - InsertRefMark( aPam ); + InsertRefMark( aPam, 0 ); pDoc = aPam.GetDoc(); } } @@ -424,3 +435,1056 @@ void SwXReferenceMark::removeVetoableChangeListener( { } +#include <com/sun/star/lang/DisposedException.hpp> +#include <unometa.hxx> +#include <unoport.hxx> +#include <txtatr.hxx> +#include <fmtmeta.hxx> +#include <docsh.hxx> + +//============================================================================= + +/****************************************************************** + * SwXMetaText + ******************************************************************/ + +class SwXMetaText + : public SwXText +{ +private: + SwXMeta & m_rMeta; + + virtual void PrepareForAttach(uno::Reference< text::XTextRange > & xRange, + const SwXTextRange* const pRange, const SwPaM * const pPam); + + virtual bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, + const SwPaM* const pPam, bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + +protected: + virtual const SwStartNode *GetStartNode() const; + virtual uno::Reference< text::XTextCursor > + createCursor() throw (uno::RuntimeException); + +public: + SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta); + + // XInterface + virtual void SAL_CALL acquire() throw() + { OSL_ENSURE(false, "ERROR: SwXMetaText::acquire"); } + virtual void SAL_CALL release() throw() + { OSL_ENSURE(false, "ERROR: SwXMetaText::release"); } + + // XTypeProvider + virtual uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() throw (uno::RuntimeException); + + // XText + virtual uno::Reference< text::XTextCursor > SAL_CALL + createTextCursor() throw (uno::RuntimeException); + virtual uno::Reference< text::XTextCursor > SAL_CALL + createTextCursorByRange( + const uno::Reference< text::XTextRange > & xTextPosition) + throw (uno::RuntimeException); + +}; + +SwXMetaText::SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta) + : SwXText(&rDoc, CURSOR_META) + , m_rMeta(rMeta) +{ +} + +const SwStartNode *SwXMetaText::GetStartNode() const +{ + SwXText const * const pParent( + dynamic_cast<SwXText*>(m_rMeta.GetParentText().get())); + return (pParent) ? pParent->GetStartNode() : 0; +} + +void SwXMetaText::PrepareForAttach( uno::Reference<text::XTextRange> & xRange, + const SwXTextRange* const pRange, const SwPaM * const pPam) +{ + SwPosition const* pPoint(0); + SwPosition const* pMark (0); + if (pRange) + { + ::sw::mark::IMark const& rIMark(*pRange->GetBookmark()); + pMark = &rIMark.GetMarkPos(); + if (rIMark.IsExpanded()) + { + pMark = &rIMark.GetOtherMarkPos(); + } + } + else if (pPam) + { + pPoint = pPam->GetPoint(); + if (pPam->HasMark()) + { + pMark = pPam->GetMark(); + } + } + // create a new cursor to prevent modifying SwXTextRange + if (pPoint) + { + xRange = static_cast<text::XWordCursor*>( + new SwXTextCursor(&m_rMeta, *pPoint, CURSOR_META, GetDoc(), pMark)); + } +} + +bool SwXMetaText::CheckForOwnMemberMeta(const SwXTextRange* const pRange, + const SwPaM* const pPam, bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) +{ + return m_rMeta.CheckForOwnMemberMeta(pRange, pPam, bAbsorb); +} + +uno::Reference< text::XTextCursor > SwXMetaText::createCursor() +throw (uno::RuntimeException) +{ + uno::Reference< text::XTextCursor > xRet; + if (IsValid()) + { + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess( + m_rMeta.SetContentRange(pTxtNode, nMetaStart, nMetaEnd) ); + if (bSuccess) + { + SwPosition aPos(*pTxtNode, nMetaStart); + xRet = static_cast<text::XWordCursor*>( + new SwXTextCursor(&m_rMeta, aPos, CURSOR_META, GetDoc())); + } + } + return xRet; +} + +uno::Sequence<sal_Int8> SAL_CALL +SwXMetaText::getImplementationId() throw (uno::RuntimeException) +{ + return m_rMeta.getImplementationId(); +} + +// XText +uno::Reference< text::XTextCursor > SAL_CALL +SwXMetaText::createTextCursor() throw (uno::RuntimeException) +{ + return createCursor(); +} + +uno::Reference< text::XTextCursor > SAL_CALL +SwXMetaText::createTextCursorByRange( + const uno::Reference<text::XTextRange> & xTextPosition) + throw (uno::RuntimeException) +{ + const uno::Reference<text::XTextCursor> xCursor( createCursor() ); + xCursor->gotoRange(xTextPosition, sal_False); + return xCursor; +} + +/****************************************************************** + * SwXMeta + ******************************************************************/ + +// the Meta has a cached list of text portions for its contents +// this list is created by SwXTextPortionEnumeration +// the Meta listens at the SwTxtNode and throws away the cache when it changes + +struct SwXMeta::Impl +{ + SwEventListenerContainer m_ListenerContainer; + ::std::auto_ptr<const TextRangeList_t> m_pTextPortions; + // 3 possible states: not attached, attached, disposed + bool m_bIsDisposed; + bool m_bIsDescriptor; + uno::Reference<text::XText> m_xParentText; + SwXMetaText m_Text; + + Impl(SwXMeta & rThis, SwDoc & rDoc, + uno::Reference<text::XText> const& xParentText, + TextRangeList_t const * const pPortions, + SwTxtMeta const * const pHint) + : m_ListenerContainer( + static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_pTextPortions( pPortions ) + , m_bIsDisposed( false ) + , m_bIsDescriptor( 0 == pHint ) + , m_xParentText(xParentText) + , m_Text(rDoc, rThis) + { + } +}; + +TYPEINIT1(SwXMeta, SwClient); + +inline const ::sw::Meta * SwXMeta::GetMeta() const +{ + return static_cast< const ::sw::Meta * >(GetRegisteredIn()); +} + +uno::Reference<text::XText> SwXMeta::GetParentText() const +{ + return m_pImpl->m_xParentText; +} + +bool SwXMeta::SetContentRange( + SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd ) const +{ + ::sw::Meta const * const pMeta( GetMeta() ); + if (pMeta) + { + SwTxtMeta const * const pTxtAttr( pMeta->GetTxtAttr() ); + if (pTxtAttr) + { + rpNode = pTxtAttr->GetTxtNode(); + if (rpNode) + { + // rStart points at the first position _within_ the meta! + rStart = *pTxtAttr->GetStart() + 1; + rEnd = *pTxtAttr->GetEnd(); + return true; + } + } + } + return false; +} + +SwXMeta::SwXMeta(SwDoc *const pDoc, + uno::Reference<text::XText> const& xParentText, + TextRangeList_t * const pPortions, SwTxtMeta * const pHint) + : m_pImpl( new SwXMeta::Impl(*this, *pDoc, xParentText, pPortions, pHint) ) +{ + if (pHint) + { + ::sw::Meta * const pMeta( + static_cast<SwFmtMeta&>(pHint->GetAttr()).GetMeta() ); + ASSERT(pMeta, "SwXMeta: no meta?") + if (pMeta) + { + pMeta->Add(this); + } + } +} + +bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, + const SwPaM* const pPam, bool bAbsorb) + throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + ASSERT((pPam && !pRange) || (!pPam && pRange), "ERROR: pam xor range"); + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess( SetContentRange(pTxtNode, nMetaStart, nMetaEnd) ); + ASSERT(bSuccess, "no pam?"); + if (!bSuccess) + throw lang::DisposedException(); + SwPosition const * const pStartPos( (pPam) + ? pPam->Start() + : &pRange->GetBookmark()->GetMarkStart() ); + if (&pStartPos->nNode.GetNode() != pTxtNode) + { + throw lang::IllegalArgumentException( + C2U("trying to insert into a nesting text content, but start " + "of text range not in same paragraph as text content"), + 0, 0); + } + bool bForceExpandHints(false); + const xub_StrLen nStartPos(pStartPos->nContent.GetIndex()); + // not <= but < because nMetaStart is behind dummy char! + // not >= but > because == means insert at end! + if ((nStartPos < nMetaStart) || (nStartPos > nMetaEnd)) + { + throw lang::IllegalArgumentException( + C2U("trying to insert into a nesting text content, but start " + "of text range not inside text content"), + 0, 0); + } + else if (nStartPos == nMetaEnd) + { + bForceExpandHints = true; + } + const bool bHasEnd( (pPam) + ? pPam->HasMark() + : pRange->GetBookmark()->IsExpanded()); + if (bHasEnd && bAbsorb) + { + SwPosition const * const pEndPos( (pPam) + ? pPam->End() + : &pRange->GetBookmark()->GetMarkEnd() ); + if (&pEndPos->nNode.GetNode() != pTxtNode) + { + throw lang::IllegalArgumentException( + C2U("trying to insert into a nesting text content, but end " + "of text range not in same paragraph as text content"), + 0, 0); + } + const xub_StrLen nEndPos(pEndPos->nContent.GetIndex()); + // not <= but < because nMetaStart is behind dummy char! + // not >= but > because == means insert at end! + if ((nEndPos < nMetaStart) || (nEndPos > nMetaEnd)) + { + throw lang::IllegalArgumentException( + C2U("trying to insert into a nesting text content, but end " + "of text range not inside text content"), + 0, 0); + } + else if (nEndPos == nMetaEnd) + { + bForceExpandHints = true; + } + } + return bForceExpandHints; +} + + +SwXMeta::SwXMeta(SwDoc *const pDoc) + : m_pImpl( new SwXMeta::Impl(*this, *pDoc, 0, 0, 0) ) +{ +} + +SwXMeta::~SwXMeta() +{ +} + +const uno::Sequence< sal_Int8 > & SwXMeta::getUnoTunnelId() +{ + static uno::Sequence< sal_Int8 > aSeq( ::CreateUnoTunnelId() ); + return aSeq; +} + +// XUnoTunnel +sal_Int64 SAL_CALL +SwXMeta::getSomething( const uno::Sequence< sal_Int8 > & i_rId ) +throw (uno::RuntimeException) +{ + if ( i_rId.getLength() == 16 && + 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), + i_rId.getConstArray(), 16 ) ) + { + return sal::static_int_cast< sal_Int64 >( + reinterpret_cast< sal_IntPtr >(this) ); + } + return 0; +} + +// XServiceInfo +::rtl::OUString SAL_CALL +SwXMeta::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXMeta"); +} + +sal_Bool SAL_CALL +SwXMeta::supportsService(const ::rtl::OUString& rServiceName) +throw (uno::RuntimeException) +{ + return rServiceName.equalsAscii("com.sun.star.text.TextContent") + || rServiceName.equalsAscii("com.sun.star.text.InContentMetadata"); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL +SwXMeta::getSupportedServiceNames() throw (uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aRet(2); + aRet[0] = C2U("com.sun.star.text.TextContent"); + aRet[1] = C2U("com.sun.star.text.InContentMetadata"); + return aRet; +} + + +// XComponent +void SAL_CALL +SwXMeta::addEventListener( + uno::Reference< lang::XEventListener> const & xListener ) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + m_pImpl->m_ListenerContainer.AddListener(xListener); + if (m_pImpl->m_bIsDisposed) + { + m_pImpl->m_ListenerContainer.Disposing(); + } +} + +void SAL_CALL +SwXMeta::removeEventListener( + uno::Reference< lang::XEventListener> const & xListener ) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->m_bIsDisposed) + { + m_pImpl->m_ListenerContainer.RemoveListener(xListener); + } +} + +void SAL_CALL +SwXMeta::dispose() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_pTextPortions.reset(); + m_pImpl->m_ListenerContainer.Disposing(); + m_pImpl->m_bIsDisposed = true; + m_pImpl->m_Text.Invalidate(); + } + else if (!m_pImpl->m_bIsDisposed) + { + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess(SetContentRange(pTxtNode, nMetaStart, nMetaEnd)); + ASSERT(bSuccess, "no pam?"); + if (bSuccess) + { + // -1 because of CH_TXTATR + SwPaM aPam( *pTxtNode, nMetaStart - 1, *pTxtNode, nMetaEnd ); + SwDoc * const pDoc( pTxtNode->GetDoc() ); + pDoc->DeleteAndJoin( aPam ); + + // removal should call Modify and do the dispose + OSL_ENSURE(m_pImpl->m_bIsDisposed, "zombie meta"); + } + } +} + + +void SAL_CALL +SwXMeta::AttachImpl(const uno::Reference< text::XTextRange > & i_xTextRange, + const USHORT i_nWhich) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (m_pImpl->m_bIsDisposed) + { + throw lang::DisposedException(); + } + if (!m_pImpl->m_bIsDescriptor) + { + throw uno::RuntimeException( + C2S("SwXMeta::attach(): already attached"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + uno::Reference<lang::XUnoTunnel> xRangeTunnel(i_xTextRange, uno::UNO_QUERY); + if (!xRangeTunnel.is()) + { + throw lang::IllegalArgumentException( + C2S("SwXMeta::attach(): argument is no XUnoTunnel"), + static_cast< ::cppu::OWeakObject* >(this), 0); + } + SwXTextRange * const pRange( + reinterpret_cast< SwXTextRange * >( + sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( + SwXTextRange::getUnoTunnelId() ))) ); + OTextCursorHelper * const pCursor( pRange ? 0 : + reinterpret_cast< OTextCursorHelper * >( + sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ))) ); + if (!pRange && !pCursor) + { + throw lang::IllegalArgumentException( + C2S("SwXMeta::attach(): argument not supported type"), + static_cast< ::cppu::OWeakObject* >(this), 0); + } + + SwDoc * const pDoc( + pRange ? pRange->GetDoc() : pCursor ? pCursor->GetDoc() : 0 ); + if (!pDoc) + { + throw lang::IllegalArgumentException( + C2S("SwXMeta::attach(): argument has no SwDoc"), + static_cast< ::cppu::OWeakObject* >(this), 0); + } + + SwUnoInternalPaM aPam(*pDoc); + SwXTextRange::XTextRangeToSwPaM(aPam, i_xTextRange); + + UnoActionContext aContext(pDoc); + + SwXTextCursor const*const pTextCursor( + dynamic_cast<SwXTextCursor*>(pCursor)); + const bool bForceExpandHints((pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false); + const SetAttrMode nInsertFlags( (bForceExpandHints) + ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND + | nsSetAttrMode::SETATTR_DONTEXPAND) + : nsSetAttrMode::SETATTR_DONTEXPAND ); + + const ::boost::shared_ptr< ::sw::Meta> pMeta( (RES_TXTATR_META == i_nWhich) + ? ::boost::shared_ptr< ::sw::Meta>( new ::sw::Meta() ) + : ::boost::shared_ptr< ::sw::Meta>( + pDoc->GetMetaFieldManager().makeMetaField()) ); + SwFmtMeta meta(pMeta, i_nWhich); // this is cloned by Insert! + const bool bSuccess( pDoc->InsertPoolItem( aPam, meta, nInsertFlags ) ); + SwTxtAttr * const pTxtAttr( pMeta->GetTxtAttr() ); + if (!bSuccess) + { + throw lang::IllegalArgumentException( + C2S("SwXMeta::attach(): cannot create meta: range invalid?"), + static_cast< ::cppu::OWeakObject* >(this), 1); + } + if (!pTxtAttr) + { + ASSERT(false, "meta inserted, but has no text attribute?"); + throw uno::RuntimeException( + C2S("SwXMeta::attach(): cannot create meta"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + pMeta->Add(this); + + m_pImpl->m_xParentText = + SwXTextRange::CreateParentXText(pDoc, *aPam.GetPoint()); + + m_pImpl->m_bIsDescriptor = false; +} + +// XTextContent +void SAL_CALL +SwXMeta::attach(const uno::Reference< text::XTextRange > & i_xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + return SwXMeta::AttachImpl(i_xTextRange, RES_TXTATR_META); +} + +uno::Reference< text::XTextRange > SAL_CALL +SwXMeta::getAnchor() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (m_pImpl->m_bIsDisposed) + { + throw lang::DisposedException(); + } + if (m_pImpl->m_bIsDescriptor) + { + throw uno::RuntimeException( + C2S("SwXMeta::getAnchor(): not inserted"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess(SetContentRange(pTxtNode, nMetaStart, nMetaEnd)); + ASSERT(bSuccess, "no pam?"); + if (!bSuccess) + { + throw lang::DisposedException( + C2S("SwXMeta::getAnchor(): not attached"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + const SwPosition start(*pTxtNode, nMetaStart - 1); // -1 due to CH_TXTATR + const SwPosition end(*pTxtNode, nMetaEnd); + return SwXTextRange::CreateTextRangeFromPosition( + pTxtNode->GetDoc(), start, &end); +} + +// XTextRange +uno::Reference< text::XText > SAL_CALL +SwXMeta::getText() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + //TODO probably this should return outer meta in case there is nesting, + // but currently that is not done; would need to change at least + // SwXTextPortionEnumeration and SwXMeta::attach and other places where + // SwXMeta is constructed + return GetParentText(); +} + +uno::Reference< text::XTextRange > SAL_CALL +SwXMeta::getStart() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.getStart(); +} + +uno::Reference< text::XTextRange > SAL_CALL +SwXMeta::getEnd() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.getEnd(); +} + +rtl::OUString SAL_CALL +SwXMeta::getString() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.getString(); +} + +void SAL_CALL +SwXMeta::setString(const rtl::OUString& rString) throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.setString(rString); +} + +// XSimpleText +uno::Reference< text::XTextCursor > SAL_CALL +SwXMeta::createTextCursor() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.createTextCursor(); +} + +uno::Reference< text::XTextCursor > SAL_CALL +SwXMeta::createTextCursorByRange( + const uno::Reference<text::XTextRange> & xTextPosition) + throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.createTextCursorByRange(xTextPosition); +} + +void SAL_CALL +SwXMeta::insertString(const uno::Reference<text::XTextRange> & xRange, + const rtl::OUString& rString, sal_Bool bAbsorb) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.insertString(xRange, rString, bAbsorb); +} + +void SAL_CALL +SwXMeta::insertControlCharacter(const uno::Reference<text::XTextRange> & xRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.insertControlCharacter(xRange, nControlCharacter, + bAbsorb); +} + +// XText +void SAL_CALL +SwXMeta::insertTextContent( const uno::Reference<text::XTextRange> & xRange, + const uno::Reference<text::XTextContent> & xContent, sal_Bool bAbsorb) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.insertTextContent(xRange, xContent, bAbsorb); +} + +void SAL_CALL +SwXMeta::removeTextContent( + const uno::Reference< text::XTextContent > & xContent) + throw (container::NoSuchElementException, uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.removeTextContent(xContent); +} + +// XElementAccess +uno::Type SAL_CALL +SwXMeta::getElementType() throw (uno::RuntimeException) +{ + return text::XTextRange::static_type(); +} + +sal_Bool SAL_CALL +SwXMeta::hasElements() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + return GetRegisteredIn() ? sal_True : sal_False; +} + +// XEnumerationAccess +uno::Reference< container::XEnumeration > SAL_CALL +SwXMeta::createEnumeration() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (m_pImpl->m_bIsDisposed) + { + throw lang::DisposedException(); + } + if (m_pImpl->m_bIsDescriptor) + { + throw uno::RuntimeException( + C2S("getAnchor(): not inserted"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess(SetContentRange(pTxtNode, nMetaStart, nMetaEnd)); + ASSERT(bSuccess, "no pam?"); + if (!bSuccess) + throw lang::DisposedException(); + + SwPaM aPam(*pTxtNode, nMetaStart); + + if (!m_pImpl->m_pTextPortions.get()) + { + return new SwXTextPortionEnumeration( + aPam, GetParentText(), nMetaStart, nMetaEnd); + } + else // cached! + { + return new SwXTextPortionEnumeration(aPam, *m_pImpl->m_pTextPortions); + } +} + + +// MetadatableMixin +::sfx2::Metadatable* SwXMeta::GetCoreObject() +{ + return const_cast< ::sw::Meta * >(GetMeta()); +} + +uno::Reference<frame::XModel> SwXMeta::GetModel() +{ + ::sw::Meta const * const pMeta( GetMeta() ); + if (pMeta) + { + SwTxtNode const * const pTxtNode( pMeta->GetTxtNode() ); + if (pTxtNode) + { + SwDocShell const * const pShell(pTxtNode->GetDoc()->GetDocShell()); + return (pShell) ? pShell->GetModel() : 0; + } + } + return 0; +} + +// SwModify +void SwXMeta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) +{ + m_pImpl->m_pTextPortions.reset(); // throw away cache (SwTxtNode changed) + + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn()) // removed => dispose + { + m_pImpl->m_ListenerContainer.Disposing(); + m_pImpl->m_bIsDisposed = true; + m_pImpl->m_Text.Invalidate(); + } +} + + +/****************************************************************** + * SwXMetaField + ******************************************************************/ + +inline const ::sw::MetaField * SwXMetaField::GetMetaField() const +{ + return static_cast< const ::sw::MetaField * >(GetRegisteredIn()); +} + +SwXMetaField::SwXMetaField(SwDoc *const pDoc, + uno::Reference<text::XText> const& xParentText, + TextRangeList_t * const pPortions, SwTxtMeta * const pHint) + : SwXMetaFieldBaseClass(pDoc, xParentText, pPortions, pHint) +{ + ASSERT(!pHint || RES_TXTATR_METAFIELD == pHint->Which(), + "SwXMetaField created for wrong hint!"); +} + +SwXMetaField::SwXMetaField(SwDoc *const pDoc) + : SwXMetaFieldBaseClass(pDoc) +{ +} + +SwXMetaField::~SwXMetaField() +{ +} + +// XServiceInfo +::rtl::OUString SAL_CALL +SwXMetaField::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXMetaField"); +} + +sal_Bool SAL_CALL +SwXMetaField::supportsService(const ::rtl::OUString& rServiceName) +throw (uno::RuntimeException) +{ + return rServiceName.equalsAscii("com.sun.star.text.TextContent") + || rServiceName.equalsAscii("com.sun.star.text.TextField") + || rServiceName.equalsAscii("com.sun.star.text.textfield.MetadataField"); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL +SwXMetaField::getSupportedServiceNames() throw (uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aRet(3); + aRet[0] = C2U("com.sun.star.text.TextContent"); + aRet[1] = C2U("com.sun.star.text.TextField"); + aRet[2] = C2U("com.sun.star.text.textfield.MetadataField"); + return aRet; +} + +// XComponent +void SAL_CALL +SwXMetaField::addEventListener( + uno::Reference< lang::XEventListener> const & xListener ) +throw (uno::RuntimeException) +{ + return SwXMeta::addEventListener(xListener); +} + +void SAL_CALL +SwXMetaField::removeEventListener( + uno::Reference< lang::XEventListener> const & xListener ) +throw (uno::RuntimeException) +{ + return SwXMeta::removeEventListener(xListener); +} + +void SAL_CALL +SwXMetaField::dispose() throw (uno::RuntimeException) +{ + return SwXMeta::dispose(); +} + +// XTextContent +void SAL_CALL +SwXMetaField::attach(const uno::Reference< text::XTextRange > & i_xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + return SwXMeta::AttachImpl(i_xTextRange, RES_TXTATR_METAFIELD); +} + +uno::Reference< text::XTextRange > SAL_CALL +SwXMetaField::getAnchor() throw (uno::RuntimeException) +{ + return SwXMeta::getAnchor(); +} + +// XPropertySet +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXMetaField::getPropertySetInfo() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + static uno::Reference< beans::XPropertySetInfo > xRef( + aSwMapProvider.GetPropertySet(PROPERTY_MAP_METAFIELD) + ->getPropertySetInfo() ); + return xRef; +} + +void SAL_CALL +SwXMetaField::setPropertyValue( + const ::rtl::OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + ::sw::MetaField * const pMeta( + const_cast< ::sw::MetaField * >(GetMetaField()) ); + if (!pMeta) + throw lang::DisposedException(); + + if (rPropertyName.equalsAscii("NumberFormat")) + { + sal_Int32 nNumberFormat(0); + if (rValue >>= nNumberFormat) + { + pMeta->SetNumberFormat(static_cast<sal_uInt32>(nNumberFormat)); + } + } + else if (rPropertyName.equalsAscii("IsFixedLanguage")) + { + bool b(false); + if (rValue >>= b) + { + pMeta->SetIsFixedLanguage(b); + } + } + else + { + throw beans::UnknownPropertyException(); + } +} + +uno::Any SAL_CALL +SwXMetaField::getPropertyValue(const ::rtl::OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + ::sw::MetaField const * const pMeta( GetMetaField() ); + if (!pMeta) + throw lang::DisposedException(); + + uno::Any any; + + if (rPropertyName.equalsAscii("NumberFormat")) + { + const ::rtl::OUString text( getPresentation(sal_False) ); + any <<= static_cast<sal_Int32>(pMeta->GetNumberFormat(text)); + } + else if (rPropertyName.equalsAscii("IsFixedLanguage")) + { + any <<= pMeta->IsFixedLanguage(); + } + else + { + throw beans::UnknownPropertyException(); + } + + return any; +} + +void SAL_CALL +SwXMetaField::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXMetaField::addPropertyChangeListener(): not implemented"); +} + +void SAL_CALL +SwXMetaField::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXMetaField::removePropertyChangeListener(): not implemented"); +} + +void SAL_CALL +SwXMetaField::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXMetaField::addVetoableChangeListener(): not implemented"); +} + +void SAL_CALL +SwXMetaField::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXMetaField::removeVetoableChangeListener(): not implemented"); +} + +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> +#include <com/sun/star/rdf/Statement.hpp> +#include <com/sun/star/rdf/URI.hpp> +#include <com/sun/star/rdf/URIs.hpp> +#include <com/sun/star/rdf/XLiteral.hpp> +#include <com/sun/star/rdf/XRepositorySupplier.hpp> +#include <comphelper/processfactory.hxx> + +static uno::Reference<rdf::XURI> const& +lcl_getURI(const bool bPrefix) +{ + static uno::Reference< uno::XComponentContext > xContext( + ::comphelper::getProcessComponentContext()); + static uno::Reference< rdf::XURI > xOdfPrefix( + rdf::URI::createKnown(xContext, rdf::URIs::ODF_PREFIX), + uno::UNO_SET_THROW); + static uno::Reference< rdf::XURI > xOdfSuffix( + rdf::URI::createKnown(xContext, rdf::URIs::ODF_SUFFIX), + uno::UNO_SET_THROW); + return (bPrefix) ? xOdfPrefix : xOdfSuffix; +} + +static ::rtl::OUString +lcl_getPrefixOrSuffix( + uno::Reference<rdf::XRepository> const & xRepository, + uno::Reference<rdf::XResource> const & xMetaField, + uno::Reference<rdf::XURI> const & xPredicate) +{ + const uno::Reference<container::XEnumeration> xEnum( + xRepository->getStatements(xMetaField, xPredicate, 0), + uno::UNO_SET_THROW); + while (xEnum->hasMoreElements()) { + rdf::Statement stmt; + if (!(xEnum->nextElement() >>= stmt)) { + throw uno::RuntimeException(); + } + const uno::Reference<rdf::XLiteral> xObject(stmt.Object, + uno::UNO_QUERY); + if (!xObject.is()) continue; + if (xEnum->hasMoreElements()) { + OSL_TRACE("ignoring other odf:Prefix/odf:Suffix statements"); + } + return xObject->getValue(); + } + return ::rtl::OUString(); +} + +void +getPrefixAndSuffix( + const uno::Reference<frame::XModel>& xModel, + const uno::Reference<rdf::XMetadatable>& xMetaField, + ::rtl::OUString *const o_pPrefix, ::rtl::OUString *const o_pSuffix) +{ + try { + const uno::Reference<rdf::XRepositorySupplier> xRS( + xModel, uno::UNO_QUERY_THROW); + const uno::Reference<rdf::XRepository> xRepo( + xRS->getRDFRepository(), uno::UNO_SET_THROW); + const uno::Reference<rdf::XResource> xMeta( + xMetaField, uno::UNO_QUERY_THROW); + if (o_pPrefix) + { + *o_pPrefix = lcl_getPrefixOrSuffix(xRepo, xMeta, lcl_getURI(true)); + } + if (o_pSuffix) + { + *o_pSuffix = lcl_getPrefixOrSuffix(xRepo, xMeta, lcl_getURI(false)); + } + } catch (uno::RuntimeException &) { + throw; + } catch (uno::Exception & e) { + throw lang::WrappedTargetRuntimeException( + ::rtl::OUString::createFromAscii("getPrefixAndSuffix: exception"), + 0, uno::makeAny(e)); + } +} + +// XTextField +::rtl::OUString SAL_CALL +SwXMetaField::getPresentation(sal_Bool bShowCommand) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (bShowCommand) + { +//FIXME ? + return ::rtl::OUString(); + } + else + { + // getString should check if this is invalid + const ::rtl::OUString content( this->getString() ); + ::rtl::OUString prefix; + ::rtl::OUString suffix; + getPrefixAndSuffix(GetModel(), this, &prefix, &suffix); + return prefix + content + suffix; + } +} + diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index fc5c8984c3..55b6fc7d0f 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -461,7 +461,7 @@ void SwXTextSection::attachToRange(const uno::Reference< text::XTextRange > & xT if (pProps->aPassword.getLength() > 0) aSect.SetPasswd(pProps->aPassword); - pRet = pDoc->Insert( aPam, aSect, aSet.Count() ? &aSet : 0 ); + pRet = pDoc->InsertSwSection( aPam, aSect, aSet.Count() ? &aSet : 0 ); // now create the client m_refCount++; // keep block to remove Reference before the refcount is decremented diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index ad6154f533..73d08d7cf5 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -45,6 +45,7 @@ #include <unoidx.hxx> #include <unoframe.hxx> #include <unofield.hxx> +#include <unometa.hxx> #include <unodraw.hxx> #include <unoredline.hxx> #include <unomap.hxx> @@ -58,7 +59,6 @@ #include <swundo.hxx> #include <section.hxx> #include <IMark.hxx> -#include <fmthbsh.hxx> #include <fmtanchr.hxx> #include <crsskip.hxx> #include <ndtxt.hxx> @@ -77,6 +77,21 @@ const sal_Char cInvalidObject[] = "this object is invalid"; -----------------------------------------------------------------------*/ +void SwXText::PrepareForAttach( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > &, + const SwXTextRange* const, const SwPaM * const) +{ +} + +bool SwXText::CheckForOwnMemberMeta(const SwXTextRange* const, + const SwPaM* const, bool) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) +{ + ASSERT(CURSOR_META != eCrsrType, "should not be called!"); + return false; +} + const SwStartNode *SwXText::GetStartNode() const { return GetDoc()->GetNodes().GetEndOfContent().StartOfSectionNode(); @@ -85,12 +100,12 @@ const SwStartNode *SwXText::GetStartNode() const uno::Reference< text::XTextCursor > SwXText::createCursor() throw (uno::RuntimeException) { uno::Reference< text::XTextCursor > xRet; - OUString sRet; if(IsValid()) { SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); SwPosition aPos(rNode); - xRet = (text::XWordCursor*)new SwXTextCursor(this, aPos, GetTextType(), GetDoc()); + xRet = static_cast<text::XWordCursor*>( + new SwXTextCursor(this, aPos, GetTextType(), GetDoc())); xRet->gotoStart(sal_False); } return xRet; @@ -278,12 +293,41 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, if(!pOwnStartNode || pOwnStartNode != pTmp) throw uno::RuntimeException(); } + bool bForceExpandHints( false ); + if (CURSOR_META == eCrsrType) + { + try + { + bForceExpandHints = CheckForOwnMemberMeta( + pRange, (pCursor) ? pCursor->GetPaM() : 0, bAbsorb); + } + catch (lang::IllegalArgumentException & iae) + { + // stupid method not allowed to throw iae + throw uno::RuntimeException(iae.Message, 0); + } + } if(bAbsorb) { //!! scan for CR characters and inserting the paragraph breaks //!! has to be done in the called function. //!! Implemented in SwXTextRange::DeleteAndInsert - xTextRange->setString(aString); + if (pCursor) + { + SwXTextCursor * const pTextCursor( dynamic_cast<SwXTextCursor*>(pCursor) ); + if (pTextCursor) + { + pTextCursor->DeleteAndInsert(aString, bForceExpandHints); + } + else + { + xTextRange->setString(aString); + } + } + else + { + pRange->DeleteAndInsert(aString, bForceExpandHints); + } } else { @@ -294,10 +338,11 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, ? pCursor->GetPaM()->Start() : &pRange->GetBookmark()->GetMarkStart(); SwPaM aInsertPam(*pPos); - sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); + const sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); GetDoc()->DoGroupUndo(sal_False); - SwUnoCursorHelper::DocInsertStringSplitCR(*GetDoc(), aInsertPam, aString); + SwUnoCursorHelper::DocInsertStringSplitCR( + *GetDoc(), aInsertPam, aString, bForceExpandHints ); GetDoc()->DoGroupUndo(bGroupUndo); } } @@ -316,15 +361,29 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & throw( lang::IllegalArgumentException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(GetDoc() && xTextRange.is()) + if (!xTextRange.is()) + throw lang::IllegalArgumentException(); + if (GetDoc()) { SwUnoInternalPaM aPam(*GetDoc()); if(SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange)) { + const bool bForceExpandHints( + CheckForOwnMemberMeta( 0, &aPam, bAbsorb) ); + + const enum IDocumentContentOperations::InsertFlags nInsertFlags = + (bForceExpandHints) + ? static_cast<IDocumentContentOperations::InsertFlags>( + IDocumentContentOperations::INS_FORCEHINTEXPAND | + IDocumentContentOperations::INS_EMPTYEXPAND) + : IDocumentContentOperations::INS_EMPTYEXPAND; + //Steuerzeichen einfuegen SwPaM aTmp(*aPam.Start()); if(bAbsorb && aPam.HasMark()) + { pDoc->DeleteAndJoin(aPam); + } sal_Unicode cIns = 0; switch( nControlCharacter ) @@ -367,7 +426,9 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & case text::ControlCharacter::HARD_SPACE: cIns = CHAR_HARDBLANK; break; } if( cIns ) - pDoc->Insert( aTmp, cIns ); + { + pDoc->InsertString( aTmp, cIns, nInsertFlags ); + } if(bAbsorb) { @@ -476,9 +537,9 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); pSrcNode = &pBkmk->GetMarkPos().nNode.GetNode(); } - else if (pPortion && pPortion->GetCrsr()) + else if (pPortion && pPortion->GetCursor()) { - pSrcNode = pPortion->GetCrsr()->GetNode(); + pSrcNode = pPortion->GetCursor()->GetNode(); } else if (pText) { @@ -511,9 +572,12 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang aRunException.Message = C2U("text interface and cursor not related"); throw aRunException; } + + const bool bForceExpandHints( CheckForOwnMemberMeta( + pRange, (pCursor) ? pCursor->GetPaM() : 0, bAbsorb) ); + // Sonderbehandlung fuer Contents, die den Range nicht ersetzen, sonder darueber gelegt werden // Bookmarks, IndexEntry - sal_Bool bAttribute = sal_False; uno::Reference<lang::XUnoTunnel> xContentTunnel( xContent, uno::UNO_QUERY); if(!xContentTunnel.is()) { @@ -529,8 +593,12 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXBookmark::getUnoTunnelId()) )); SwXReferenceMark* pReferenceMark = reinterpret_cast< SwXReferenceMark * >( sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXReferenceMark::getUnoTunnelId()) )); + SwXMeta *const pMeta = reinterpret_cast< SwXMeta* >( + sal::static_int_cast< sal_IntPtr >( + xContentTunnel->getSomething( SwXMeta::getUnoTunnelId()))); - bAttribute = pBookmark || pDocumentIndexMark || pSection || pReferenceMark; + const bool bAttribute = pBookmark || pDocumentIndexMark + || pSection || pReferenceMark || pMeta; if(bAbsorb && !bAttribute) { @@ -542,6 +610,12 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang xTempRange = xRange; else xTempRange = xRange->getStart(); + if (bForceExpandHints) + { + // if necessary, replace xTempRange with a new SwXTextCursor + PrepareForAttach(xTempRange, pRange, + (pCursor) ? pCursor->GetPaM() : 0); + } xContent->attach(xTempRange); } else @@ -582,7 +656,7 @@ void SwXText::insertTextContentBefore( if(!pPara || !pPara->IsDescriptor() || !xSuccessor.is()) throw lang::IllegalArgumentException(); - sal_Bool bRet = FALSE; + sal_Bool bRet = sal_False; SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xSuccessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; @@ -636,7 +710,7 @@ void SwXText::insertTextContentAfter( SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; - sal_Bool bRet = FALSE; + sal_Bool bRet = sal_False; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { SwTable* pTable = SwTable::FindTable( pTableFmt ); @@ -680,7 +754,7 @@ void SwXText::removeTextContentBefore( throw aRuntime; } - sal_Bool bRet = FALSE; + sal_Bool bRet = sal_False; SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation( xSuccessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; @@ -727,7 +801,7 @@ void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>& throw aRuntime; } - sal_Bool bRet = FALSE; + sal_Bool bRet = sal_False; SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; @@ -818,10 +892,8 @@ uno::Reference< text::XTextRange > SwXText::getEnd(void) throw( uno::RuntimeExc aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - else - xRef->gotoEnd(sal_False); - uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY);; - + xRef->gotoEnd(sal_False); + uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); return xRet; } /*-- 09.12.98 12:43:29--------------------------------------------------- @@ -856,6 +928,7 @@ void SwXText::setString(const OUString& aString) throw( uno::RuntimeException ) GetDoc()->StartUndo(UNDO_START, NULL); //insert an empty paragraph at the start and at the end to ensure that //all tables and sections can be removed by the selecting text::XTextCursor + if (CURSOR_META != eCrsrType) { SwPosition aStartPos(*pStartNode); const SwEndNode* pEnd = pStartNode->EndOfSectionNode(); @@ -903,6 +976,7 @@ void SwXText::setString(const OUString& aString) throw( uno::RuntimeException ) GetDoc()->EndUndo(UNDO_END, NULL); } +//FIXME why is CheckForOwnMember duplicated in some insert methods? // Description: Checks if pRange/pCursor are member of the same text interface. // Only one of the pointers has to be set! sal_Bool SwXText::CheckForOwnMember( @@ -1361,7 +1435,8 @@ uno::Reference< text::XTextRange > SwXText::appendTextPortion( if(rText.getLength()) { xub_StrLen nContentPos = pCursor->GetPoint()->nContent.GetIndex(); - SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *pCursor, rText ); + SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *pCursor, rText, + false ); SwXTextCursor::SelectPam(*pCursor, sal_True); pCursor->GetPoint()->nContent = nContentPos; } diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 9d1632c653..dd53eea0e4 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -2230,12 +2230,12 @@ void ViewShell::ApplyViewOptions( const SwViewOption &rOpt ) { SwViewOption aOpt( *pSh->GetViewOptions() ); aOpt.SetFldName( rOpt.IsFldName() ); - aOpt.SetShowHiddenField( rOpt.IsShowHiddenField() ); + aOpt.SetShowHiddenField( rOpt.IsShowHiddenField() ); aOpt.SetShowHiddenPara( rOpt.IsShowHiddenPara() ); - aOpt.SetShowHiddenChar( rOpt.IsShowHiddenChar() ); - aOpt.SetViewLayoutBookMode( rOpt.IsViewLayoutBookMode() ); - aOpt.SetViewLayoutColumns( rOpt.GetViewLayoutColumns() ); - + aOpt.SetShowHiddenChar( rOpt.IsShowHiddenChar() ); + aOpt.SetViewLayoutBookMode( rOpt.IsViewLayoutBookMode() ); + aOpt.SetViewLayoutColumns( rOpt.GetViewLayoutColumns() ); + aOpt.SetPostIts(rOpt.IsPostIts()); if ( !(aOpt == *pSh->GetViewOptions()) ) pSh->ImplApplyViewOptions( aOpt ); pSh = (ViewShell*)pSh->GetNext(); diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 08957c1094..3ae5a3b5ba 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -1,4 +1,5 @@ -/************************************************************************* +/************************************************************************** + * * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -44,6 +45,7 @@ #include <svx/pbinitem.hxx> #include <svx/svdview.hxx> #include <unotools/localedatawrapper.hxx> +#include <svtools/syslocale.hxx> #include <txtfld.hxx> #include <fmtfld.hxx> #include <fmtfsize.hxx> @@ -353,8 +355,8 @@ void lcl_FormatPostIt( IDocumentContentOperations* pIDCO, SwPaM& aPam, SwPostItF aStr.AppendAscii(sTmp); aStr += pField->GetPar1(); aStr += ' '; - aStr += GetAppLocaleData().getDate( pField->GetDate() ); - pIDCO->Insert( aPam, aStr, true ); + aStr += SvtSysLocale().GetLocaleData().getDate( pField->GetDate() ); + pIDCO->InsertString( aPam, aStr ); pIDCO->SplitNode( *aPam.GetPoint(), false ); aStr = pField->GetPar2(); @@ -362,7 +364,7 @@ void lcl_FormatPostIt( IDocumentContentOperations* pIDCO, SwPaM& aPam, SwPostItF // Bei Windows und Co alle CR rausschmeissen aStr.EraseAllChars( '\r' ); #endif - pIDCO->Insert( aPam, aStr, true ); + pIDCO->InsertString( aPam, aStr ); pIDCO->SplitNode( *aPam.GetPoint(), false ); pIDCO->SplitNode( *aPam.GetPoint(), false ); } @@ -453,7 +455,7 @@ void lcl_PrintPostItsEndDoc( ViewShell* pPrtShell, aPam.Move( fnMoveBackward, fnGoDoc ); aPam.SetMark(); aPam.Move( fnMoveForward, fnGoDoc ); - pPrtDoc->Delete( aPam ); + pPrtDoc->DeleteRange( aPam ); for( USHORT i = 0, nVirtPg, nLineNo; i < nPostIts; ++i ) { @@ -502,7 +504,7 @@ void lcl_PrintPostItsEndPage( ViewShell* pPrtShell, aPam.Move( fnMoveBackward, fnGoDoc ); aPam.SetMark(); aPam.Move( fnMoveForward, fnGoDoc ); - pPrtDoc->Delete( aPam ); + pPrtDoc->DeleteRange( aPam ); while( i < nPostIts ) { @@ -1516,7 +1518,9 @@ BOOL ViewShell::IsAnyFieldInDoc() const { const SwFmtFld* pFmtFld = (SwFmtFld*)pItem; const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld(); - if( pTxtFld && pTxtFld->GetTxtNode().GetNodes().IsDocNodes() ) + //#i101026# mod: do not include postits in field check + const SwField* pFld = pFmtFld->GetFld(); + if( pTxtFld && pTxtFld->GetTxtNode().GetNodes().IsDocNodes() && (pFld->Which() != RES_POSTITFLD)) return TRUE; } return FALSE; diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx index 5d313e5905..10e85b5c08 100644 --- a/sw/source/filter/ascii/ascatr.cxx +++ b/sw/source/filter/ascii/ascatr.cxx @@ -88,20 +88,16 @@ xub_StrLen SwASC_AttrIter::SearchNext( xub_StrLen nStartPos ) const SwpHints* pTxtAttrs = rNd.GetpSwpHints(); if( pTxtAttrs ) { - USHORT i; - xub_StrLen nPos; - const xub_StrLen * pPos; - // kann noch optimiert werden, wenn ausgenutzt wird, dass die TxtAttrs // nach der Anfangsposition geordnet sind. Dann muessten // allerdings noch 2 Indices gemerkt werden - for( i = 0; i < pTxtAttrs->Count(); i++ ) + for ( USHORT i = 0; i < pTxtAttrs->Count(); i++ ) { const SwTxtAttr* pHt = (*pTxtAttrs)[i]; - nPos = *pHt->GetStart(); // gibt erstes Attr-Zeichen - pPos = pHt->GetEnd(); - if( !pPos ) + if (pHt->HasDummyChar()) { + xub_StrLen nPos = *pHt->GetStart(); + if( nPos >= nStartPos && nPos <= nMinPos ) nMinPos = nPos; @@ -124,8 +120,7 @@ BOOL SwASC_AttrIter::OutAttr( xub_StrLen nSwPos ) for( i = 0; i < pTxtAttrs->Count(); i++ ) { const SwTxtAttr* pHt = (*pTxtAttrs)[i]; - const xub_StrLen * pEnd = pHt->GetEnd(); - if( !pEnd && nSwPos == *pHt->GetStart() ) + if ( pHt->HasDummyChar() && nSwPos == *pHt->GetStart() ) { bRet = TRUE; String sOut; @@ -135,10 +130,6 @@ BOOL SwASC_AttrIter::OutAttr( xub_StrLen nSwPos ) sOut = ((SwTxtFld*)pHt)->GetFld().GetFld()->Expand(); break; - case RES_TXTATR_HARDBLANK: - sOut = ((SwTxtHardBlank*)pHt)->GetChar(); - break; - case RES_TXTATR_FTN: { const SwFmtFtn& rFtn = pHt->GetFtn(); diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx index 96d23eabee..b713190564 100644 --- a/sw/source/filter/ascii/parasc.cxx +++ b/sw/source/filter/ascii/parasc.cxx @@ -261,7 +261,7 @@ ULONG SwASCIIParser::CallParser() // !!!!! ASSERT( !this, "Have to change - hard attr. to para. style" ); - pDoc->Insert( *pInsPam, *pItemSet, 0 ); + pDoc->InsertItemSet( *pInsPam, *pItemSet, 0 ); } } delete pItemSet, pItemSet = 0; @@ -467,7 +467,7 @@ ULONG SwASCIIParser::ReadChars() InsertText( String( pLastStt )); } pDoc->SplitNode( *pPam->GetPoint(), false ); - pDoc->Insert( *pPam, SvxFmtBreakItem( + pDoc->InsertPoolItem( *pPam, SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0); pLastStt = pStt; nLineLen = 0; @@ -528,7 +528,7 @@ ULONG SwASCIIParser::ReadChars() void SwASCIIParser::InsertText( const String& rStr ) { - pDoc->Insert( *pPam, rStr, true ); + pDoc->InsertString( *pPam, rStr ); if( pItemSet && pBreakIt && nScript != ( SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX ) ) diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx index 25f50924a6..4e55ee6ce6 100644 --- a/sw/source/filter/basflt/fltini.cxx +++ b/sw/source/filter/basflt/fltini.cxx @@ -670,13 +670,13 @@ void CalculateFlySize(SfxItemSet& rFlySet, const SwNodeIndex& rAnchor, // if the first node dont contained any content, then // insert one char in it calc again and delete once again SwIndex aNdIdx( pFirstTxtNd ); - pFirstTxtNd->Insert( String::CreateFromAscii( + pFirstTxtNd->InsertText( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "MM" )), aNdIdx ); ULONG nAbsMinCnts; pFirstTxtNd->GetMinMaxSize( pFirstTxtNd->GetIndex(), nMinFrm, nMaxFrm, nAbsMinCnts ); aNdIdx -= 2; - pFirstTxtNd->Erase( aNdIdx, 2 ); + pFirstTxtNd->EraseText( aNdIdx, 2 ); } // Umrandung und Abstand zum Inhalt beachten diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index 819fba7325..ab62e9d2ee 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -81,7 +81,6 @@ #include <txatbase.hxx> #include <frmatr.hxx> #include <charfmt.hxx> -#include <fmthbsh.hxx> #include <fmtfld.hxx> #include <doc.hxx> #include <pam.hxx> @@ -1801,8 +1800,8 @@ HTMLEndPosLst::HTMLEndPosLst( SwDoc *pD, SwDoc* pTempl, xub_StrLen nPos = 0; while( nPos < nEndPos ) { - sal_uInt16 nScript = pBreakIt->xBreak->getScriptType( rText, nPos ); - nPos = (xub_StrLen)pBreakIt->xBreak->endOfScript( rText, nPos, nScript ); + sal_uInt16 nScript = pBreakIt->GetBreakIter()->getScriptType( rText, nPos ); + nPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( rText, nPos, nScript ); aScriptChgLst.Insert( nPos, aScriptChgLst.Count() ); aScriptLst.Insert( nScript, aScriptLst.Count() ); } @@ -2495,7 +2494,7 @@ Writer& OutHTML_SwTxtNode( Writer& rWrt, const SwCntntNode& rNode ) if( RES_TXTATR_FIELD == pHt->Which() ) // Felder nicht continue; // ausgeben - if( pHt->GetEnd() ) + if ( pHt->GetEnd() && !pHt->HasDummyChar() ) { xub_StrLen nHtEnd = *pHt->GetEnd(), nHtStt = *pHt->GetStart(); @@ -2555,7 +2554,7 @@ Writer& OutHTML_SwTxtNode( Writer& rWrt, const SwCntntNode& rNode ) && nStrPos != nEnde ) { do { - if( pHt->GetEnd() ) + if ( pHt->GetEnd() && !pHt->HasDummyChar() ) { if( RES_CHRATR_KERNING == pHt->Which() && rHTMLWrt.IsHTMLMode(HTMLMODE_FIRSTLINE) && @@ -3041,15 +3040,6 @@ static Writer& OutHTML_SwFlyCnt( Writer& rWrt, const SfxPoolItem& rHt ) return rWrt; } -static Writer& OutHTML_SwHardBlank( Writer& rWrt, const SfxPoolItem& rHt ) -{ - HTMLOutContext aContext ( ((SwHTMLWriter&)rWrt).eDestEnc ); - HTMLOutFuncs::Out_Char( rWrt.Strm(), ((SwFmtHardBlank&)rHt).GetChar(), - aContext, - &((SwHTMLWriter&)rWrt).aNonConvertableCharacters); - HTMLOutFuncs::FlushToAscii( rWrt.Strm(), aContext ); - return rWrt; -} // Das ist jetzt unser Blink-Item. Blinkend wird eingeschaltet, indem man // das Item auf TRUE setzt! @@ -3416,7 +3406,7 @@ SwAttrFnTab aHTMLAttrFnTab = { /* RES_TXTATR_FLYCNT */ OutHTML_SwFlyCnt, /* RES_TXTATR_FTN */ OutHTML_SwFmtFtn, /* RES_TXTATR_SOFTHYPH */ 0, -/* RES_TXTATR_HARDBLANK*/ OutHTML_SwHardBlank, +/* RES_TXTATR_HARDBLANK*/ 0, /* RES_TXTATR_DUMMY1 */ 0, // Dummy: /* RES_TXTATR_DUMMY2 */ 0, // Dummy: diff --git a/sw/source/filter/html/htmlbas.cxx b/sw/source/filter/html/htmlbas.cxx index 3f3a5aa74a..1eab2c7fbc 100644 --- a/sw/source/filter/html/htmlbas.cxx +++ b/sw/source/filter/html/htmlbas.cxx @@ -47,6 +47,8 @@ #include <svtools/htmltokn.h> #include <svtools/htmlkywd.hxx> +#include <com/sun/star/document/XEventsSupplier.hpp> +#include <com/sun/star/uno/Reference.hxx> #include <fmtornt.hxx> #include <fmtfld.hxx> @@ -251,7 +253,7 @@ void SwHTMLParser::AddScriptSource() } } -void SwHTMLParser::InsertBasicDocEvent( USHORT nEvent, const String& rName, +void SwHTMLParser::InsertBasicDocEvent( rtl::OUString aEvent, const String& rName, ScriptType eScrType, const String& rScrType ) { @@ -270,8 +272,10 @@ void SwHTMLParser::InsertBasicDocEvent( USHORT nEvent, const String& rName, if( EXTENDED_STYPE == eScrType ) sScriptType = rScrType; + rtl::OUString aEventName; + SfxEventConfiguration* pECfg = SFX_APP()->GetEventConfig(); - pECfg->ConfigureEvent( nEvent, SvxMacro( sEvent, sScriptType, eScrType ), + pECfg->ConfigureEvent( aEvent, SvxMacro( sEvent, sScriptType, eScrType ), pDocSh ); } @@ -338,6 +342,10 @@ void SwHTMLWriter::OutBasic() SFX_APP()->LeaveBasicCall(); } +static const char* aEventNames[] = +{ + "OnLoad", "OnPrepareUnload", "OnFocus", "OnUnfocus" +}; void SwHTMLWriter::OutBasicBodyEvents() { @@ -345,14 +353,19 @@ void SwHTMLWriter::OutBasicBodyEvents() if( !pDocSh ) return; - SfxEventConfiguration* pECfg = SFX_APP()->GetEventConfig(); - ASSERT( pECfg, "Wo ist die Event-Konfiguration?" ); - if( !pECfg ) - return; + SvxMacroTableDtor *pDocTable = new SvxMacroTableDtor; + + uno::Reference< document::XEventsSupplier > xSup( pDocSh->GetModel(), uno::UNO_QUERY ); + uno::Reference < container::XNameReplace > xEvents = xSup->getEvents(); + for ( sal_Int32 i=0; i<4; i++ ) + { + SvxMacro* pMacro = SfxEventConfiguration::ConvertToMacro( xEvents->getByName( ::rtl::OUString::createFromAscii(aEventNames[i]) ), pDocSh, TRUE ); + if ( pMacro ) + pDocTable->Insert( aBodyEventTable[i].nEvent, pMacro ); + } - SvxMacroTableDtor *pMacTable = pECfg->GetDocEventTable( pDocSh ); - if( pMacTable && pMacTable->Count() ) - HTMLOutFuncs::Out_Events( Strm(), *pMacTable, aBodyEventTable, + if( pDocTable && pDocTable->Count() ) + HTMLOutFuncs::Out_Events( Strm(), *pDocTable, aBodyEventTable, bCfgStarBasic, eDestEnc, &aNonConvertableCharacters ); } diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx index 2a28f63b67..0017b15db7 100644 --- a/sw/source/filter/html/htmlfld.cxx +++ b/sw/source/filter/html/htmlfld.cxx @@ -547,7 +547,7 @@ void SwHTMLParser::NewField() } else { - pDoc->Insert( *pPam, SwFmtFld(*pFld), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld(*pFld), 0 ); delete pFld; } bInField = TRUE; @@ -585,7 +585,7 @@ void SwHTMLParser::EndField() break; } - pDoc->Insert( *pPam, SwFmtFld(*pField), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld(*pField), 0 ); delete pField; pField = 0; } diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx index 0d961cf5e3..4027ddc7be 100644 --- a/sw/source/filter/html/htmlfldw.cxx +++ b/sw/source/filter/html/htmlfldw.cxx @@ -312,8 +312,8 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pFld, sal_Bool bNeedsCJKProcessing = sal_False; if( sExpand.Len() ) { - sal_uInt16 nScriptType = pBreakIt->xBreak->getScriptType( sExpand, 0 ); - xub_StrLen nPos = (xub_StrLen)pBreakIt->xBreak->endOfScript( sExpand, 0, + sal_uInt16 nScriptType = pBreakIt->GetBreakIter()->getScriptType( sExpand, 0 ); + xub_StrLen nPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( sExpand, 0, nScriptType ); sal_uInt16 nScript = @@ -361,10 +361,10 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pFld, xub_StrLen nPos = 0; do { - sal_uInt16 nScriptType = pBreakIt->xBreak->getScriptType( sExpand, nPos ); + sal_uInt16 nScriptType = pBreakIt->GetBreakIter()->getScriptType( sExpand, nPos ); sal_uInt16 nScript = SwHTMLWriter::GetCSS1ScriptForScriptType( nScriptType ); - xub_StrLen nEndPos = (xub_StrLen)pBreakIt->xBreak->endOfScript( + xub_StrLen nEndPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( sExpand, nPos, nScriptType ); if( nScript != CSS1_OUTMODE_ANY_SCRIPT && /* #108791# */ nScript != rHTMLWrt.nCSS1Script ) diff --git a/sw/source/filter/html/htmlftn.cxx b/sw/source/filter/html/htmlftn.cxx index 9f385105fe..e0051c67f3 100644 --- a/sw/source/filter/html/htmlftn.cxx +++ b/sw/source/filter/html/htmlftn.cxx @@ -228,11 +228,10 @@ void SwHTMLParser::FinishFootEndNote() if( pFootEndNoteImpl->bFixed ) aFtn.SetNumStr( pFootEndNoteImpl->sContent ); - pDoc->Insert( *pPam, aFtn, 0 ); - SwTxtFtn *pTxtFtn = - (SwTxtFtn *)pPam->GetNode()->GetTxtNode()->GetTxtAttr( - pPam->GetPoint()->nContent.GetIndex() - 1, - RES_TXTATR_FTN ); + pDoc->InsertPoolItem( *pPam, aFtn, 0 ); + SwTxtFtn * const pTxtFtn = static_cast<SwTxtFtn *>( + pPam->GetNode()->GetTxtNode()->GetTxtAttrForCharAt( + pPam->GetPoint()->nContent.GetIndex() - 1, RES_TXTATR_FTN ) ); // In Kopf- und Fusszeilen duerfen keine Fussnoten eingefuegt werden. if( pTxtFtn ) { diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index ae6500e7d6..688ed149a5 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -53,7 +53,7 @@ #include <svtools/imap.hxx> #include <svtools/htmltokn.h> #include <svtools/htmlkywd.hxx> - +#include <svtools/eventcfg.hxx> #include <fmtornt.hxx> #include <fmturl.hxx> @@ -841,7 +841,7 @@ void SwHTMLParser::InsertBodyOptions() { const HTMLOption *pOption = (*pHTMLOptions)[--i]; ScriptType eScriptType2 = eDfltScriptType; - USHORT nEvent = 0; + rtl::OUString aEvent; BOOL bSetEvent = FALSE; switch( pOption->GetToken() ) @@ -872,28 +872,28 @@ void SwHTMLParser::InsertBodyOptions() case HTML_O_SDONLOAD: eScriptType2 = STARBASIC; case HTML_O_ONLOAD: - nEvent = SFX_EVENT_OPENDOC; + aEvent = GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC ); bSetEvent = TRUE; break; case HTML_O_SDONUNLOAD: eScriptType2 = STARBASIC; case HTML_O_ONUNLOAD: - nEvent = SFX_EVENT_PREPARECLOSEDOC; + aEvent = GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEDOC ); bSetEvent = TRUE; break; case HTML_O_SDONFOCUS: eScriptType2 = STARBASIC; case HTML_O_ONFOCUS: - nEvent = SFX_EVENT_ACTIVATEDOC; + aEvent = GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ); bSetEvent = TRUE; break; case HTML_O_SDONBLUR: eScriptType2 = STARBASIC; case HTML_O_ONBLUR: - nEvent = SFX_EVENT_DEACTIVATEDOC; + aEvent = GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC ); bSetEvent = TRUE; break; @@ -919,7 +919,7 @@ void SwHTMLParser::InsertBodyOptions() { const String& rEvent = pOption->GetString(); if( rEvent.Len() ) - InsertBasicDocEvent( nEvent, rEvent, eScriptType2, + InsertBasicDocEvent( aEvent, rEvent, eScriptType2, sDfltScriptType ); } } @@ -1374,7 +1374,7 @@ void SwHTMLParser::StripTrailingPara() if( pPrvNd ) { SwIndex aSrc( pCNd, 0 ); - pCNd->GetTxtNode()->Cut( pPrvNd, aSrc, pCNd->Len() ); + pCNd->GetTxtNode()->CutText( pPrvNd, aSrc, pCNd->Len() ); } } @@ -1436,9 +1436,10 @@ void SwHTMLParser::StripTrailingPara() xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex(); while( bSetSmallFont && nPos>0 ) { - bSetSmallFont = CH_TXTATR_BREAKWORD == - pTxtNd->GetTxt().GetChar( --nPos ) && - 0 != pTxtNd->GetTxtAttr( nPos, RES_TXTATR_FLYCNT ); + --nPos; + bSetSmallFont = + (CH_TXTATR_BREAKWORD == pTxtNd->GetTxt().GetChar( nPos )) && + (0 != pTxtNd->GetTxtAttrForCharAt( nPos, RES_TXTATR_FLYCNT )); } } diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx index 0ab0427017..293a7f8a64 100644 --- a/sw/source/filter/html/htmlsect.cxx +++ b/sw/source/filter/html/htmlsect.cxx @@ -351,7 +351,7 @@ void SwHTMLParser::NewDivision( int nToken ) aItemSet.ClearItem( RES_FRAMEDIR ); } - pDoc->Insert( *pPam, aSection, &aFrmItemSet, sal_False ); + pDoc->InsertSwSection( *pPam, aSection, &aFrmItemSet, false ); // ggfs. einen Bereich anspringen if( JUMPTO_REGION == eJumpTo && aName == sJmpMark ) @@ -746,7 +746,7 @@ void SwHTMLParser::NewMultiCol() aFrmItemSet.Put( *pItem ); aItemSet.ClearItem( RES_FRAMEDIR ); } - pDoc->Insert( *pPam, aSection, &aFrmItemSet, sal_False ); + pDoc->InsertSwSection( *pPam, aSection, &aFrmItemSet, false ); // Jump to section, if this is requested. if( JUMPTO_REGION == eJumpTo && aName == sJmpMark ) diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index 67d7535215..11526ebfb2 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -3030,7 +3030,7 @@ xub_StrLen SwHTMLParser::StripTrailingLF() nPos = nLen - nLFCount; SwIndex nIdx( pTxtNd, nPos ); - pTxtNd->Erase( nIdx, nLFCount ); + pTxtNd->EraseText( nIdx, nLFCount ); nStripped = nLFCount; } } @@ -5495,7 +5495,8 @@ HTMLTable *SwHTMLParser::BuildTable( SvxAdjust eParentAdjust, pNd = pTblStNd->EndOfSectionNode(); SwNodeIndex aDstIdx( *pNd, bTop ? 0 : 1 ); - pDoc->Move( aSrcRg, aDstIdx, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveNodeRange( aSrcRg, aDstIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT ); // Wenn die Caption vor der Tabelle eingefuegt wurde muss // eine an der Tabelle gestzte Seitenvorlage noch in den diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 0c22e03aee..08d12b419b 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -79,7 +79,6 @@ #include <charatr.hxx> #include <fmtfld.hxx> #include <fmtpdsc.hxx> -#include <fmthbsh.hxx> #include <txtfld.hxx> #include <fmtanchr.hxx> #include <fmtsrnd.hxx> @@ -235,7 +234,7 @@ ULONG HTMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPam, const // sonst ist sie schon gesetzt. if( !rDoc.get(IDocumentSettingAccess::HTML_MODE) ) { - rDoc.Insert( rPam, SwFmtPageDesc( + rDoc.InsertPoolItem( rPam, SwFmtPageDesc( rDoc.GetPageDescFromPool( RES_POOLPAGE_HTML, false )), 0 ); } } @@ -1282,7 +1281,9 @@ void __EXPORT SwHTMLParser::NextToken( int nToken ) pPageDesc = pCSS1Parser->GetRightPageDesc(); if( pPageDesc ) - pDoc->Insert( *pPam, SwFmtPageDesc( pPageDesc ), 0 ); + { + pDoc->InsertPoolItem( *pPam, SwFmtPageDesc( pPageDesc ), 0 ); + } } break; @@ -1436,11 +1437,11 @@ void __EXPORT SwHTMLParser::NextToken( int nToken ) break; case HTML_NONBREAKSPACE: - pDoc->Insert( *pPam, CHAR_HARDBLANK ); + pDoc->InsertString( *pPam, CHAR_HARDBLANK ); break; case HTML_SOFTHYPH: - pDoc->Insert( *pPam, CHAR_SOFTHYPHEN ); + pDoc->InsertString( *pPam, CHAR_SOFTHYPHEN ); break; case HTML_LINEFEEDCHAR: @@ -1482,7 +1483,7 @@ void __EXPORT SwHTMLParser::NextToken( int nToken ) { if( !bDocInitalized ) DocumentDetected(); - pDoc->Insert( *pPam, aToken, true ); + pDoc->InsertString( *pPam, aToken ); // wenn es noch vorlaefige Absatz-Attribute gibt, der Absatz aber // nicht leer ist, dann sind die Absatz-Attribute entgueltig. @@ -2190,9 +2191,9 @@ BOOL SwHTMLParser::AppendTxtNode( SwHTMLAppendMode eMode, BOOL bUpdateNum ) { const String& rText = pTxtNd->GetTxt(); sal_uInt16 nScriptTxt = - pBreakIt->xBreak->getScriptType( + pBreakIt->GetBreakIter()->getScriptType( rText, pAttr->GetSttCnt() ); - xub_StrLen nScriptEnd = (xub_StrLen)pBreakIt->xBreak + xub_StrLen nScriptEnd = (xub_StrLen)pBreakIt->GetBreakIter() ->endOfScript( rText, nStt, nScriptTxt ); while( nScriptEnd < nEndCnt ) { @@ -2212,9 +2213,9 @@ BOOL SwHTMLParser::AppendTxtNode( SwHTMLAppendMode eMode, BOOL bUpdateNum ) pNext->InsertPrev( pSetAttr ); } nStt = nScriptEnd; - nScriptTxt = pBreakIt->xBreak->getScriptType( + nScriptTxt = pBreakIt->GetBreakIter()->getScriptType( rText, nStt ); - nScriptEnd = (xub_StrLen)pBreakIt->xBreak + nScriptEnd = (xub_StrLen)pBreakIt->GetBreakIter() ->endOfScript( rText, nStt, nScriptTxt ); } bInsert = nScriptItem == nScriptTxt; @@ -2336,7 +2337,7 @@ BOOL SwHTMLParser::AppendTxtNode( SwHTMLAppendMode eMode, BOOL bUpdateNum ) // also delete the SwpHints!!! To avoid any trouble // we leave the loop immediately if this is the last // hint. - pTxtNd->Delete( pHt, sal_True ); + pTxtNd->DeleteAttribute( pHt ); if( 1 == nCntAttr ) break; i--; @@ -2821,7 +2822,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, eJumpTo = JUMPTO_NONE; } - pDoc->Insert( *pAttrPam, *pAttr->pItem, nsSetAttrMode::SETATTR_DONTREPLACE ); + pDoc->InsertPoolItem( *pAttrPam, *pAttr->pItem, nsSetAttrMode::SETATTR_DONTREPLACE ); } pAttrPam->DeleteMark(); @@ -2903,7 +2904,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, pAttrPam->Move( fnMoveBackward ); } - pDoc->Insert( *pAttrPam, *pAttr->pItem, 0 ); + pDoc->InsertPoolItem( *pAttrPam, *pAttr->pItem, 0 ); aFields.Remove( 0, 1 ); delete pAttr; @@ -3007,9 +3008,9 @@ void SwHTMLParser::EndAttr( _HTMLAttr* pAttr, _HTMLAttr **ppDepAttr, .GetTxtNode(); ASSERT( pTxtNd, "No text node" ); const String& rText = pTxtNd->GetTxt(); - sal_uInt16 nScriptTxt = pBreakIt->xBreak->getScriptType( + sal_uInt16 nScriptTxt = pBreakIt->GetBreakIter()->getScriptType( rText, pAttr->GetSttCnt() ); - xub_StrLen nScriptEnd = (xub_StrLen)pBreakIt->xBreak + xub_StrLen nScriptEnd = (xub_StrLen)pBreakIt->GetBreakIter() ->endOfScript( rText, pAttr->GetSttCnt(), nScriptTxt ); while( nScriptEnd < nEndCnt ) { @@ -3027,9 +3028,9 @@ void SwHTMLParser::EndAttr( _HTMLAttr* pAttr, _HTMLAttr **ppDepAttr, } } pAttr->nSttCntnt = nScriptEnd; - nScriptTxt = pBreakIt->xBreak->getScriptType( + nScriptTxt = pBreakIt->GetBreakIter()->getScriptType( rText, nScriptEnd ); - nScriptEnd = (xub_StrLen)pBreakIt->xBreak + nScriptEnd = (xub_StrLen)pBreakIt->GetBreakIter() ->endOfScript( rText, nScriptEnd, nScriptTxt ); } bInsert = nScriptItem == nScriptTxt; @@ -4941,7 +4942,7 @@ void SwHTMLParser::InsertSpacer() { NewAttr( &aAttrTab.pKerning, SvxKerningItem( (short)nSize, RES_CHRATR_KERNING ) ); String aTmp( ' ' ); - pDoc->Insert( *pPam, aTmp /*, CHARSET_ANSI*/, true ); + pDoc->InsertString( *pPam, aTmp ); EndAttr( aAttrTab.pKerning ); } } @@ -5149,7 +5150,7 @@ void SwHTMLParser::InsertLineBreak() // wenn kein CLEAR ausgefuehrt werden sollte oder konnte, wird // ein Zeilenumbruch eingef?gt String sTmp( (sal_Unicode)0x0a ); // make the Mac happy :-) - pDoc->Insert( *pPam, sTmp, true ); + pDoc->InsertString( *pPam, sTmp ); } else if( pPam->GetPoint()->nContent.GetIndex() ) { diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx index bf7b7f80bd..f302a3301f 100644 --- a/sw/source/filter/html/swhtml.hxx +++ b/sw/source/filter/html/swhtml.hxx @@ -782,7 +782,7 @@ private: void AddScriptSource(); // ein Event in die SFX-Konfiguation eintragen (htmlbas.cxx) - void InsertBasicDocEvent( sal_uInt16 nEvent, const String& rName, + void InsertBasicDocEvent( rtl::OUString aEventName, const String& rName, ScriptType eScrType, const String& rScrType ); // ein Event an ein VC-Control anhaengen (htmlform.cxx) diff --git a/sw/source/filter/rtf/rtfatr.cxx b/sw/source/filter/rtf/rtfatr.cxx index 494b0eba17..ba95d018ac 100644 --- a/sw/source/filter/rtf/rtfatr.cxx +++ b/sw/source/filter/rtf/rtfatr.cxx @@ -102,7 +102,6 @@ #include <fmtfld.hxx> #include <fmtflcnt.hxx> #include <fmtftn.hxx> -#include <fmthbsh.hxx> #include <fchrfmt.hxx> #include <fmtautofmt.hxx> #include <fmtcntnt.hxx> @@ -2790,8 +2789,8 @@ static Writer& OutRTF_SwField( Writer& rWrt, const SfxPoolItem& rHt ) */ const String& rFldPar1 = pFld->GetPar1(); USHORT nScript; - if( pBreakIt->xBreak.is() ) - nScript = pBreakIt->xBreak->getScriptType( rFldPar1, 0); + if( pBreakIt->GetBreakIter().is() ) + nScript = pBreakIt->GetBreakIter()->getScriptType( rFldPar1, 0); else nScript = i18n::ScriptType::ASIAN; @@ -3048,14 +3047,6 @@ static Writer& OutRTF_SwFtn( Writer& rWrt, const SfxPoolItem& rHt ) return rWrt; } -static Writer& OutRTF_SwHardBlank( Writer& rWrt, const SfxPoolItem& rHt) -{ - RTFOutFuncs::Out_String(rWrt.Strm(), - String(((SwFmtHardBlank&)rHt).GetChar()), ((SwRTFWriter&)rWrt).eDefaultEncoding, - ((SwRTFWriter&)rWrt).bWriteHelpFmt); - return rWrt; -} - static Writer& OutRTF_SwTxtCharFmt( Writer& rWrt, const SfxPoolItem& rHt ) { const SwFmtCharFmt& rChrFmt = (const SwFmtCharFmt&)rHt; @@ -3110,8 +3101,8 @@ static Writer& OutRTF_SwTxtRuby( Writer& rWrt, const SfxPoolItem& rHt ) defaulting to asian. */ USHORT nScript; - if( pBreakIt->xBreak.is() ) - nScript = pBreakIt->xBreak->getScriptType( rRuby.GetText(), 0); + if( pBreakIt->GetBreakIter().is() ) + nScript = pBreakIt->GetBreakIter()->getScriptType( rRuby.GetText(), 0); else nScript = i18n::ScriptType::ASIAN; @@ -3153,8 +3144,8 @@ static Writer& OutRTF_SwTxtRuby( Writer& rWrt, const SfxPoolItem& rHt ) rWrt.Strm() << "\\\\a" << cDirective; rWrt.Strm() << "(\\\\s\\\\up "; - if( pBreakIt->xBreak.is() ) - nScript = pBreakIt->xBreak->getScriptType( pNd->GetTxt(), + if( pBreakIt->GetBreakIter().is() ) + nScript = pBreakIt->GetBreakIter()->getScriptType( pNd->GetTxt(), *pRubyTxt->GetStart() ); else nScript = i18n::ScriptType::ASIAN; @@ -4275,7 +4266,7 @@ SwAttrFnTab aRTFAttrFnTab = { /* RES_TXTATR_FLYCNT */ OutRTF_SwFlyCntnt, /* RES_TXTATR_FTN */ OutRTF_SwFtn, /* RES_TXTATR_SOFTHYPH */ 0, // old attr. - coded now by character -/* RES_TXTATR_HARDBLANK*/ OutRTF_SwHardBlank, +/* RES_TXTATR_HARDBLANK*/ 0, /* RES_TXTATR_DUMMY1 */ 0, // Dummy: /* RES_TXTATR_DUMMY2 */ 0, // Dummy: diff --git a/sw/source/filter/rtf/rtffld.cxx b/sw/source/filter/rtf/rtffld.cxx index c41818de81..d891d53fd2 100644 --- a/sw/source/filter/rtf/rtffld.cxx +++ b/sw/source/filter/rtf/rtffld.cxx @@ -450,7 +450,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) // steht jetzt geanu auf dem Format-Namen aFld.ChangeFormat( CheckNumberFmtStr( aSaveStr )); } - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 ); SkipGroup(); } break; @@ -469,7 +469,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) // steht jetzt geanu auf dem Format-Namen aPF.ChangeFormat( CheckNumberFmtStr( aSaveStr )); } - pDoc->Insert( *pPam, SwFmtFld( aPF ), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aPF ), 0 ); SkipGroup(); // ueberlese den Rest } break; @@ -480,8 +480,8 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) { // es fehlt die Format - Angabe: defaulten auf Datum pFldType = pDoc->GetSysFldType( RES_DATETIMEFLD ); - pDoc->Insert( *pPam, SwFmtFld( SwDateTimeField( - (SwDateTimeFieldType*)pFldType, DATEFLD )), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( SwDateTimeField( + static_cast<SwDateTimeFieldType*>(pFldType), DATEFLD)), 0); } else { @@ -524,7 +524,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) if( pFld ) { - pDoc->Insert( *pPam, SwFmtFld( *pFld ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( *pFld ), 0); delete pFld; } } @@ -553,8 +553,8 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) if( bField ) { pFldType = pDoc->GetSysFldType( RES_DBNAMEFLD ); - pDoc->Insert( *pPam, SwFmtFld( SwDBNameField( - (SwDBNameFieldType*)pFldType, SwDBData() ) ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( SwDBNameField( + static_cast<SwDBNameFieldType*>(pFldType), SwDBData())), 0); } else pDoc->ChgDBData( aData ); // MS: Keine DBInfo verwenden @@ -569,7 +569,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) SwDBField aDBFld( (SwDBFieldType*)pDoc->InsertFldType( aTmp )); aDBFld.ChangeFormat( UF_STRING ); - pDoc->Insert( *pPam, SwFmtFld( aDBFld ), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld( aDBFld ), 0); SkipGroup(); // ueberlese den Rest } break; @@ -598,7 +598,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) sal_Unicode nChar = (sal_Unicode)sParam.ToInt32(); if( nChar ) { - pDoc->Insert( *pPam, nChar ); + pDoc->InsertString( *pPam, nChar ); bCharIns = TRUE; } } @@ -708,8 +708,8 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) { //Make a guess at which of asian of western we should be setting USHORT nScript; - if (pBreakIt->xBreak.is()) - nScript = pBreakIt->xBreak->getScriptType( aData.sUp, 0); + if (pBreakIt->GetBreakIter().is()) + nScript = pBreakIt->GetBreakIter()->getScriptType( aData.sUp, 0); else nScript = i18n::ScriptType::ASIAN; @@ -763,10 +763,11 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) aRuby.SetAdjustment( (USHORT)aData.nJustificationCode ); // im FieldStr steht der anzuzeigenden Text, im - pDoc->Insert( *pPam, aData.sText, true ); + pDoc->InsertString( *pPam, aData.sText ); pPam->SetMark(); pPam->GetMark()->nContent -= aData.sText.Len(); - pDoc->Insert( *pPam, aRuby, nsSetAttrMode::SETATTR_DONTEXPAND ); + pDoc->InsertPoolItem( *pPam, aRuby, + nsSetAttrMode::SETATTR_DONTEXPAND ); pPam->DeleteMark(); } // or a combined character field? @@ -778,7 +779,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) sFld += aData.sDown; SwCombinedCharField aFld((SwCombinedCharFieldType*)pDoc-> GetSysFldType( RES_COMBINED_CHARS ), sFld ); - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0); } SkipGroup(); // ueberlese den Rest @@ -808,7 +809,9 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) sOrigBkmName,REF_BOOKMARK,0,REF_PAGE); if(!bNestedField) - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0 ); + { + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 ); + } else bNestedField = false; } @@ -850,14 +853,14 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) SwGetRefField aFld( (SwGetRefFieldType*)pDoc->GetSysFldType( RES_GETREFFLD ), sOrigBkmName,REF_BOOKMARK,0,REF_CHAPTER); - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 ); } else { SwGetRefField aFld( (SwGetRefFieldType*)pDoc->GetSysFldType( RES_GETREFFLD ), sOrigBkmName,REF_BOOKMARK,0,REF_CONTENT); - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 ); } } @@ -866,7 +869,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) SwGetRefField aFld( (SwGetRefFieldType*) pDoc->GetSysFldType( RES_GETREFFLD ), sOrigBkmName, REF_BOOKMARK, 0, REF_UPDOWN ); - pDoc->Insert(*pPam, SwFmtFld(aFld), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld(aFld), 0); } } break; @@ -882,7 +885,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) SwUserFieldType aTmp( pDoc, aSaveStr ); SwUserField aUFld( (SwUserFieldType*)pDoc->InsertFldType( aTmp )); aUFld.ChangeFormat( UF_STRING ); - pDoc->Insert( *pPam, SwFmtFld( aUFld ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aUFld ), 0); nRet = RTFFLD_UNKNOWN; } break; @@ -1045,7 +1048,8 @@ void SwRTFParser::ReadField() // FieldResult wurde eingelesen if (SwTxtNode* pTxtNd = pPam->GetPoint()->nNode.GetNode().GetTxtNode()) { - SwTxtAttr* pFldAttr = pTxtNd->GetTxtAttr( + SwTxtAttr* const pFldAttr = + pTxtNd->GetTxtAttrForCharAt( pPam->GetPoint()->nContent.GetIndex()-1 ); if (pFldAttr) @@ -1078,7 +1082,7 @@ void SwRTFParser::ReadField() sNestedFieldStr.Erase(); // im FieldStr steht der anzuzeigenden Text, im - pDoc->Insert( *pPam, sFieldStr, true ); + pDoc->InsertString( *pPam, sFieldStr ); String sTarget( sFieldNm.GetToken( 1, '\1' )); if( sTarget.Len() ) @@ -1087,7 +1091,7 @@ void SwRTFParser::ReadField() // oder ueber den Stack setzen?? pPam->SetMark(); pPam->GetMark()->nContent -= sFieldStr.Len(); - pDoc->Insert( *pPam, + pDoc->InsertPoolItem( *pPam, SwFmtINetFmt( sFieldNm, sTarget ), nsSetAttrMode::SETATTR_DONTEXPAND ); pPam->DeleteMark(); diff --git a/sw/source/filter/rtf/rtffly.cxx b/sw/source/filter/rtf/rtffly.cxx index de1df2ee7f..706dc39b81 100644 --- a/sw/source/filter/rtf/rtffly.cxx +++ b/sw/source/filter/rtf/rtffly.cxx @@ -396,7 +396,8 @@ void SwRTFParser::SetFlysInDoc() } } aTmpIdx = *pSttNd->EndOfSectionNode(); - pDoc->Move( aRg, aTmpIdx, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveNodeRange( aRg, aTmpIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT ); } // patch from cmc for #i52542# @@ -1174,7 +1175,7 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) { SwTxtNode* pTxtNd = pFlySave->nSttNd.GetNode().GetTxtNode(); - SwTxtFlyCnt* pFlyCnt; + SwTxtFlyCnt* pFlyCnt = 0; if( 1 == pTxtNd->GetTxt().Len() && 0 != ( pFlyCnt = (SwTxtFlyCnt*)pTxtNd->GetTxtAttr( 0, RES_TXTATR_FLYCNT )) && @@ -1232,7 +1233,8 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() ); SwNodeIndex aTmp( pFlySave->nSttNd, +1 ); - pDoc->Move( aRg, aTmp, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveNodeRange( aRg, aTmp, + IDocumentContentOperations::DOC_MOVEDEFAULT ); // now delete the redundant txtnode pDoc->GetNodes().Delete( pFlySave->nSttNd, 1 ); diff --git a/sw/source/filter/rtf/rtftbl.cxx b/sw/source/filter/rtf/rtftbl.cxx index 0931f6e5c0..c3a56f64e3 100644 --- a/sw/source/filter/rtf/rtftbl.cxx +++ b/sw/source/filter/rtf/rtftbl.cxx @@ -851,7 +851,8 @@ void SwRTFParser::ReadTable( int nToken ) //table aRg.SetMark(); aRg.GetMark()->nContent.Assign(aRg.GetCntntNode(), 0); - pDoc->Move(aRg, *pPam->GetPoint(), IDocumentContentOperations::DOC_MOVEDEFAULT); + pDoc->MoveRange(aRg, *pPam->GetPoint(), + IDocumentContentOperations::DOC_MOVEDEFAULT); } //Update the attribute stack entries to reflect that the properties diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 091b8d2b76..d4e8d48453 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -55,7 +55,6 @@ #include <svx/hyznitem.hxx> #include <fmtpdsc.hxx> #include <fmtfld.hxx> -#include <fmthbsh.hxx> #include <fmthdft.hxx> #include <fmtcntnt.hxx> #include <txtftn.hxx> @@ -449,7 +448,6 @@ if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( FALSE ).nNode.GetIndex() ) for (rtfSections::myrDummyIter aI = maSegments.maDummyPageNos.rbegin(); aI != aDEnd; ++aI) pDoc->DelPageDesc(*aI); - if( aFlyArr.Count() ) SetFlysInDoc(); @@ -852,7 +850,8 @@ SwSectionFmt *rtfSections::InsertSection(SwPaM& rMyPaM, rtfSection &rSection) aSet.Put(SvxFrameDirectionItem( nRTLPgn ? FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR)); - rSection.mpSection = mrReader.pDoc->Insert( rMyPaM, aSection, &aSet ); + rSection.mpSection = + mrReader.pDoc->InsertSwSection( rMyPaM, aSection, &aSet ); ASSERT(rSection.mpSection, "section not inserted!"); if (!rSection.mpSection) return 0; @@ -1003,7 +1002,7 @@ void rtfSections::InsertSegments(bool bNewDoc) aIter->maStart.GetNode().GetCntntNode(), 0); SwPaM aPage(aPamStart); - mrReader.pDoc->Insert(aPage, aPgDesc, 0); + mrReader.pDoc->InsertPoolItem(aPage, aPgDesc, 0); } ++nDesc; } @@ -1824,7 +1823,8 @@ void SwRTFParser::NextToken( int nToken ) if (lcl_UsedPara(*pPam)) InsertPara(); CheckInsNewTblLine(); - pDoc->Insert(*pPam, SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); + pDoc->InsertPoolItem(*pPam, + SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); } break; @@ -1976,12 +1976,13 @@ void SwRTFParser::NextToken( int nToken ) &const_cast<const SwDoc *>(pDoc) ->GetPageDesc( USHORT(nTokenValue) ); CheckInsNewTblLine(); - pDoc->Insert( *pPam, SwFmtPageDesc( pPgDsc ), 0); + pDoc->InsertPoolItem(*pPam, SwFmtPageDesc( pPgDsc ), 0); } break; case RTF_COLUM: - pDoc->Insert( *pPam, SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE, RES_BREAK ), 0); + pDoc->InsertPoolItem(*pPam, + SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE, RES_BREAK ), 0); break; case RTF_DXFRTEXT: // werden nur im Zusammenhang mit Flys ausgewertet @@ -2001,7 +2002,7 @@ SETCHDATEFIELD: SwDateTimeField aDateFld( (SwDateTimeFieldType*) pDoc->GetSysFldType( RES_DATETIMEFLD ), DATEFLD, nFormat); CheckInsNewTblLine(); - pDoc->Insert( *pPam, SwFmtFld( aDateFld ), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld( aDateFld ), 0); } break; @@ -2013,7 +2014,7 @@ SETCHDATEFIELD: SwDateTimeField aTimeFld( (SwDateTimeFieldType*) pDoc->GetSysFldType( RES_DATETIMEFLD ), TIMEFLD, nFormat); CheckInsNewTblLine(); - pDoc->Insert( *pPam, SwFmtFld( aTimeFld ), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld( aTimeFld ), 0); } break; @@ -2023,7 +2024,7 @@ SETCHDATEFIELD: pDoc->GetSysFldType( RES_PAGENUMBERFLD ), PG_RANDOM, SVX_NUM_ARABIC ); CheckInsNewTblLine(); - pDoc->Insert( *pPam, SwFmtFld( aPageFld), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld(aPageFld), 0); } break; @@ -2053,7 +2054,7 @@ SETCHDATEFIELD: CheckInsNewTblLine(); if( nTokenValue ) aToken = (sal_Unicode )nTokenValue; - pDoc->Insert( *pPam, aToken, true ); + pDoc->InsertString( *pPam, aToken ); } break; @@ -2119,7 +2120,7 @@ void SwRTFParser::InsertText() if(pRedlineDelete) mpRedlineStack->open(*pPam->GetPoint(), *pRedlineDelete); - pDoc->Insert( *pPam, aToken, true ); + pDoc->InsertString( *pPam, aToken ); if(pRedlineDelete) { @@ -2283,14 +2284,15 @@ void SwRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) } } while( 0 != (pStyle = GetStyleTbl().Next()) ); - pDoc->Insert(aPam, *pCharFmt, 0); + pDoc->InsertPoolItem(aPam, *pCharFmt, 0); rSet.GetAttrSet().ClearItem(RES_TXTATR_CHARFMT); //test hack } if (rSet.GetAttrSet().Count()) { // dann setze ueber diesen Bereich die Attrbiute SetSwgValues(rSet.GetAttrSet()); - pDoc->Insert(aPam, rSet.GetAttrSet(), nsSetAttrMode::SETATTR_DONTCHGNUMRULE); + pDoc->InsertItemSet(aPam, rSet.GetAttrSet(), + nsSetAttrMode::SETATTR_DONTCHGNUMRULE); } } @@ -2452,7 +2454,7 @@ void SwRTFParser::SetPageInformationAsDefault(const DocPageInformation &rInfo) { SwFmtPageDesc aPgDsc( &rPg ); aPgDsc.SetNumOffset( nPgStart ); - pDoc->Insert( *pPam, aPgDsc, 0 ); + pDoc->InsertPoolItem( *pPam, aPgDsc, 0 ); } } } @@ -3711,7 +3713,7 @@ void SwRTFParser::ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc ) aSet.Put( SwFmtAnchor( FLY_IN_CNTNT )); pHdFtFmt = pDoc->MakeFlySection( FLY_IN_CNTNT, pPam->GetPoint(), &aSet ); - pTxtAttr = pPam->GetNode()->GetTxtNode()->GetTxtAttr( + pTxtAttr = pPam->GetNode()->GetTxtNode()->GetTxtAttrForCharAt( nPos, RES_TXTATR_FLYCNT ); ASSERT( pTxtAttr, "konnte den Fly nicht einfuegen/finden" ); @@ -4297,7 +4299,7 @@ void SwRTFParser::UnknownAttrToken( int nToken, SfxItemSet* pSet ) { const SwPageDesc* pPgDsc = &const_cast<const SwDoc *>(pDoc) ->GetPageDesc( (USHORT)nTokenValue ); - pDoc->Insert( *pPam, SwFmtPageDesc( pPgDsc ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtPageDesc( pPgDsc ), 0); } break; case RTF_CS: diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index 4ff75f1ce1..55d3a4f759 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -340,10 +340,6 @@ ULONG Writer::Write( SwPaM& rPam, SfxMedium& rMed, const String* pFileName ) // This method must be overloaded in SwXMLWriter a storage from medium will be used there. // The microsoft format can write to storage but the storage will be based on the stream. return Write( rPam, *rMed.GetOutStream(), pFileName ); - - // return IsStgWriter() - // ? Write( rPam, rMed.GetStorage(), pFileName ) - // : Write( rPam, *rMed.GetOutStream(), pFileName ); } ULONG Writer::Write( SwPaM& /*rPam*/, SvStorage&, const String* ) diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx index 82c2b5cdc5..880255cabe 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/ww1/fltshell.cxx @@ -492,7 +492,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* { // XRefs und Bookmarks sind bereits geUpcased MakeBookRegionOrPoint(pEntry, pDoc, aRegion, TRUE); - pDoc->Insert(aRegion, SwFmtRefMark(rName), 0); + pDoc->InsertPoolItem(aRegion, SwFmtRefMark(rName), 0); } else if( !pB->IsOnlyRef() ) { @@ -506,7 +506,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* pB->GetValSys()); aFld.SetSubType( nsSwExtendedSubType::SUB_INVISIBLE ); MakePoint(pEntry, pDoc, aRegion); - pDoc->Insert(aRegion, SwFmtFld(aFld), 0); + pDoc->InsertPoolItem(aRegion, SwFmtFld(aFld), 0); MoveAttrs( *(aRegion.GetPoint()) ); } } @@ -564,8 +564,9 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* break; case RES_FLTR_SECTION: MakePoint(pEntry, pDoc, aRegion); // bislang immer Point==Mark - pDoc->Insert(aRegion, *((SwFltSection*)pEntry->pAttr)->GetSection(), - 0, FALSE); + pDoc->InsertSwSection(aRegion, + *(static_cast<SwFltSection*>(pEntry->pAttr))->GetSection(), + 0, false); delete(((SwFltSection*)pEntry->pAttr)->GetSection()); break; case RES_FLTR_REDLINE: @@ -602,7 +603,9 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* break; default: if (pEntry->MakeRegion(pDoc, aRegion, FALSE)) - pDoc->Insert(aRegion, *pEntry->pAttr, 0); + { + pDoc->InsertPoolItem(aRegion, *pEntry->pAttr, 0); + } break; } } @@ -1006,7 +1009,7 @@ SwFltShell::~SwFltShell() SwFltShell& SwFltShell::operator << ( const String& rStr ) { ASSERT(eSubMode != Style, "char insert while in style-mode"); - GetDoc().Insert( *pPaM, rStr, true ); + GetDoc().InsertString( *pPaM, rStr ); return *this; } @@ -1043,7 +1046,7 @@ String SwFltShell::QuoteStr( const String& rIn ) SwFltShell& SwFltShell::operator << ( const sal_Unicode c ) { ASSERT( eSubMode != Style, "char insert while in style-mode"); - GetDoc().Insert( *pPaM, c ); + GetDoc().InsertString( *pPaM, c ); return *this; } @@ -1060,7 +1063,7 @@ SwFltShell& SwFltShell::AddError( const sal_Char* pErr ) SwSetExpField aFld( (SwSetExpFieldType*)pFT, String::CreateFromAscii( pErr )); //, VVF_INVISIBLE - GetDoc().Insert(*pPaM, SwFmtFld(aFld), 0); + GetDoc().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return *this; } @@ -1079,7 +1082,8 @@ void SwFltShell::NextParagraph() void SwFltShell::NextPage() { NextParagraph(); - GetDoc().Insert(*pPaM, SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); + GetDoc().InsertPoolItem(*pPaM, + SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); } SwFltShell& SwFltShell::AddGraphic( const String& rPicName ) @@ -1170,7 +1174,7 @@ SwFltShell& SwFltShell::EndItem( USHORT nAttrId ) SwFltShell& SwFltShell::operator << (const SwField& rField) { - GetDoc().Insert(*pPaM, SwFmtFld(rField), 0); + GetDoc().InsertPoolItem(*pPaM, SwFmtFld(rField), 0); return *this; } @@ -1931,7 +1935,7 @@ void SwFltShell::BeginFootnote() // Fussnoten im PMW uebernommen werden SwFmtFtn aFtn; - GetDoc().Insert(*pPaM, aFtn, 0); + GetDoc().InsertPoolItem(*pPaM, aFtn, 0); ASSERT(pSavedPos == NULL, "SwFltShell"); pSavedPos = new SwPosition(*pPaM->GetPoint()); pPaM->Move(fnMoveBackward, fnGoCntnt); @@ -2031,7 +2035,9 @@ SwPageDesc* SwFltShell::MakePageDesc(SwPageDesc* pFirstPageDesc) pNewPD->SetFollow(pNewPD); } else - GetDoc().Insert( *pPaM, SwFmtPageDesc( pNewPD ), 0 ); + { + GetDoc().InsertPoolItem( *pPaM, SwFmtPageDesc( pNewPD ), 0 ); + } pNewPD->WriteUseOn( // alle Seiten (UseOnPage)(nsUseOnPage::PD_ALL | nsUseOnPage::PD_HEADERSHARE | nsUseOnPage::PD_FOOTERSHARE)); return pNewPD; diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx index 7abc23eef3..cf6c68cafb 100644 --- a/sw/source/filter/ww8/attributeoutputbase.hxx +++ b/sw/source/filter/ww8/attributeoutputbase.hxx @@ -449,9 +449,6 @@ protected: /// Sfx item RES_TXTATR_FTN virtual void TextFootnote_Impl( const SwFmtFtn& ) = 0; - /// Sfx item RES_TXTATR_HARDBLANK - virtual void TextHardBlank( const SwFmtHardBlank& ) = 0; - /// Sfx item RES_PARATR_LINESPACING void ParaLineSpacing( const SvxLineSpacingItem& ); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 9c11efbfea..44a5c329a5 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2776,13 +2776,6 @@ void DocxAttributeOutput::FootnotesEndnotes( bool bFootnotes ) } -void DocxAttributeOutput::TextHardBlank( const SwFmtHardBlank& ) -{ -#if OSL_DEBUG_LEVEL > 0 - fprintf( stderr, "TODO DocxAttributeOutput::TextHardBlank()\n" ); -#endif -} - void DocxAttributeOutput::ParaLineSpacing_Impl( short nSpace, short /*nMulti*/ ) { if ( !m_pSpacingAttrList ) diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index cbe5345e40..d751e6cf7a 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -434,9 +434,6 @@ protected: /// Output the footnote/endnote reference (if there's one to output). void FootnoteEndnoteReference(); - /// Sfx item RES_TXTATR_HARDBLANK - virtual void TextHardBlank( const SwFmtHardBlank& ); - /// Sfx item RES_PARATR_LINESPACING virtual void ParaLineSpacing_Impl( short nSpace, short nMulti ); diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx index e91e2aeb18..8c77c6a3c7 100644 --- a/sw/source/filter/ww8/writerwordglue.cxx +++ b/sw/source/filter/ww8/writerwordglue.cxx @@ -548,8 +548,8 @@ namespace sw using namespace ::com::sun::star::i18n; sal_uInt16 nScript = i18n::ScriptType::LATIN; - if (rTxt.Len() && pBreakIt && pBreakIt->xBreak.is()) - nScript = pBreakIt->xBreak->getScriptType(rTxt, 0); + if (rTxt.Len() && pBreakIt && pBreakIt->GetBreakIter().is()) + nScript = pBreakIt->GetBreakIter()->getScriptType(rTxt, 0); rtl_TextEncoding eChrSet = ItemGet<SvxFontItem>(rTxtNd, GetWhichOfScript(RES_CHRATR_FONT, nScript)).GetCharSet(); @@ -635,20 +635,20 @@ namespace sw using sw::types::writer_cast; - if (pBreakIt && pBreakIt->xBreak.is()) + if (pBreakIt && pBreakIt->GetBreakIter().is()) { xub_StrLen nLen = rTxt.Len(); xub_StrLen nPos = 0; while (nPos < nLen) { - sal_Int32 nEnd2 = pBreakIt->xBreak->endOfScript(rTxt, nPos, + sal_Int32 nEnd2 = pBreakIt->GetBreakIter()->endOfScript(rTxt, nPos, nScript); if (nEnd2 < 0) break; // nPos = writer_cast<xub_StrLen>(nEnd2); nPos = static_cast< xub_StrLen >(nEnd2); aScripts.push_back(ScriptEntry(nPos, nScript)); - nScript = pBreakIt->xBreak->getScriptType(rTxt, nPos); + nScript = pBreakIt->GetBreakIter()->getScriptType(rTxt, nPos); } } diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 4de54fac8f..213ea13ed8 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -885,8 +885,8 @@ void WW8_SdrAttrIter::NextPara( USHORT nPar ) pEditPool = aSet.GetPool(); eNdChrSet = ItemGet<SvxFontItem>(aSet,EE_CHAR_FONTINFO).GetCharSet(); - if( pBreakIt->xBreak.is() ) - nScript = pBreakIt->xBreak->getScriptType( pEditObj->GetText(nPara), 0); + if( pBreakIt->GetBreakIter().is() ) + nScript = pBreakIt->GetBreakIter()->getScriptType( pEditObj->GetText(nPara), 0); else nScript = i18n::ScriptType::LATIN; diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 9ac2e499b2..7ef0640ed1 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -344,9 +344,9 @@ xub_StrLen SwAttrIter::SearchNext( xub_StrLen nStartPos ) if( nPos >= nStartPos && nPos <= nMinPos ) nMinPos = nPos; } - else + if (pHt->HasDummyChar()) { - // Attr ohne Ende Laenge 1 wegen CH_TXTATR im Text + // pos + 1 because of CH_TXTATR in Text nPos = *pHt->GetStart() + 1; if( nPos >= nStartPos && nPos <= nMinPos ) nMinPos = nPos; @@ -545,13 +545,13 @@ void SwAttrIter::OutFlys(xub_StrLen nSwPos) bool SwAttrIter::IsTxtAttr( xub_StrLen nSwPos ) { - // search for attrs without end position + // search for attrs with CH_TXTATR if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints()) { for (USHORT i = 0; i < pTxtAttrs->Count(); ++i) { const SwTxtAttr* pHt = (*pTxtAttrs)[i]; - if( !pHt->GetEnd() && *pHt->GetStart() == nSwPos ) + if ( pHt->HasDummyChar() && (*pHt->GetStart() == nSwPos) ) return true; } } @@ -670,15 +670,15 @@ void WW8AttributeOutput::StartRuby( const SwTxtNode& rNode, const SwFmtRuby& rRu aStr += String::CreateFromInt32( nJC ); /* - MS needs to know the name and size of the font used in the ruby item, - but we coud have written it in a mixture of asian and western - scripts, and each of these can be a different font and size than the - other, so we make a guess based upon the first character of the text, - defaulting to asian. - */ + MS needs to know the name and size of the font used in the ruby item, + but we coud have written it in a mixture of asian and western + scripts, and each of these can be a different font and size than the + other, so we make a guess based upon the first character of the text, + defaulting to asian. + */ USHORT nRubyScript; - if ( pBreakIt->xBreak.is() ) - nRubyScript = pBreakIt->xBreak->getScriptType( rRuby.GetText(), 0); + if( pBreakIt->GetBreakIter().is() ) + nRubyScript = pBreakIt->GetBreakIter()->getScriptType( rRuby.GetText(), 0); else nRubyScript = i18n::ScriptType::ASIAN; @@ -726,8 +726,8 @@ void WW8AttributeOutput::StartRuby( const SwTxtNode& rNode, const SwFmtRuby& rRu aStr.APPEND_CONST_ASC( "(\\s\\up " ); - if ( pBreakIt->xBreak.is() ) - nRubyScript = pBreakIt->xBreak->getScriptType( rNode.GetTxt(), + if ( pBreakIt->GetBreakIter().is() ) + nRubyScript = pBreakIt->GetBreakIter()->getScriptType( rNode.GetTxt(), *( pRubyTxt->GetStart() ) ); else nRubyScript = i18n::ScriptType::ASIAN; @@ -1409,8 +1409,8 @@ String SwAttrIter::GetSnippet(const String &rStr, xub_StrLen nAktPos, if (SVX_CASEMAP_TITEL == ((const SvxCaseMapItem&)rItem).GetValue()) { sal_uInt16 nScriptType = i18n::ScriptType::LATIN; - if (pBreakIt->xBreak.is()) - nScriptType = pBreakIt->xBreak->getScriptType(aSnippet, 0); + if (pBreakIt->GetBreakIter().is()) + nScriptType = pBreakIt->GetBreakIter()->getScriptType(aSnippet, 0); LanguageType nLanguage; switch (nScriptType) @@ -1435,7 +1435,7 @@ String SwAttrIter::GetSnippet(const String &rStr, xub_StrLen nAktPos, //If we weren't at the begin of a word undo the case change. //not done before doing the casemap because the sequence might start //with whitespace - if (pBreakIt->xBreak.is() && !pBreakIt->xBreak->isBeginWord( + if (pBreakIt->GetBreakIter().is() && !pBreakIt->GetBreakIter()->isBeginWord( rStr, nAktPos, pBreakIt->GetLocale(nLanguage), i18n::WordType::ANYWORD_IGNOREWHITESPACES ) ) { diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index f26c40877b..f2601348e8 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2416,9 +2416,7 @@ void WW8Export::SectionBreaksAndFrames( const SwTxtNode& rNode ) void MSWordExportBase::WriteText() { #ifdef DEBUG -//!! does not compile with debug=t -> unresolved external (dbg_out), -//!! sommeone who knows what he wants to get should fix this -// ::std::clog << "<WriteText>" << ::std::endl; + ::std::clog << "<WriteText>" << ::std::endl; // ::std::clog << dbg_out(pCurPam->GetDoc()->GetNodes()) << ::std::endl; #endif diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index a1a5441acd..a374682e33 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -109,7 +109,6 @@ #include <pagedesc.hxx> // for SwPageDesc #include <flddat.hxx> // for Date fields #include <ndtxt.hxx> // for Numrules -#include <fmthbsh.hxx> #include <swrect.hxx> #include <reffld.hxx> #include <ftninfo.hxx> @@ -2383,9 +2382,9 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect ) GetExport( ).OutputField( 0, eCode, sStr, WRITEFIELD_START | WRITEFIELD_CMD_START | WRITEFIELD_CMD_END ); } - - GetExport( ).bStartTOX = false; } + + GetExport( ).bStartTOX = false; } void AttributeOutputBase::EndTOX( const SwSection& rSect ) @@ -2961,8 +2960,8 @@ void AttributeOutputBase::TextField( const SwFmtFld& rField ) font size of that script as our default. */ USHORT nScript; - if( pBreakIt->xBreak.is() ) - nScript = pBreakIt->xBreak->getScriptType( pFld->GetPar1(), 0); + if( pBreakIt->GetBreakIter().is() ) + nScript = pBreakIt->GetBreakIter()->getScriptType( pFld->GetPar1(), 0); else nScript = i18n::ScriptType::ASIAN; @@ -3140,10 +3139,6 @@ void WW8AttributeOutput::ParaVerticalAlign( const SvxParaVertAlignItem& rAlign ) // NoHyphen: ich habe keine Entsprechung in der SW-UI und WW-UI gefunden -void WW8AttributeOutput::TextHardBlank( const SwFmtHardBlank& rHardBlank ) -{ - m_rWW8Export.WriteChar( rHardBlank.GetChar() ); -} // RefMark, NoLineBreakHere fehlen noch @@ -3757,8 +3752,17 @@ void WW8AttributeOutput::FormatTextGrid( const SwTextGridItem& rGrid ) UINT16 nHeight = rGrid.GetBaseHeight() + rGrid.GetRubyHeight(); m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaLinePitch ); m_rWW8Export.InsUInt16( nHeight ); - sal_uInt32 nPageCharSize = ItemGet<SvxFontHeightItem>(*(m_rWW8Export.pStyles->GetSwFmt()), - RES_CHRATR_CJK_FONTSIZE).GetHeight(); + + MSWordStyles * pStyles = m_rWW8Export.pStyles; + SwFmt * pSwFmt = pStyles->GetSwFmt(); + + sal_uInt32 nPageCharSize = 0; + + if (pSwFmt != NULL) + { + nPageCharSize = ItemGet<SvxFontHeightItem> + (*pSwFmt, RES_CHRATR_CJK_FONTSIZE).GetHeight(); + } INT32 nCharWidth = rGrid.GetBaseWidth() - nPageCharSize; INT32 nFraction = 0; @@ -4543,9 +4547,9 @@ void AttributeOutputBase::ParaLineSpacing( const SvxLineSpacingItem& rSpacing ) { const SwTxtNode* pNd = (const SwTxtNode*)GetExport().pOutFmtNode; pSet = &pNd->GetSwAttrSet(); - if ( pBreakIt->xBreak.is() ) + if ( pBreakIt->GetBreakIter().is() ) { - nScript = pBreakIt->xBreak-> + nScript = pBreakIt->GetBreakIter()-> getScriptType(pNd->GetTxt(), 0); } } @@ -5146,9 +5150,6 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt ) case RES_TXTATR_FTN: TextFootnote( static_cast< const SwFmtFtn& >( rHt ) ); break; - case RES_TXTATR_HARDBLANK: - TextHardBlank( static_cast< const SwFmtHardBlank& >( rHt ) ); - break; case RES_PARATR_LINESPACING: ParaLineSpacing( static_cast< const SvxLineSpacingItem& >( rHt ) ); diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx index 936c090a6e..608dfc17d2 100644 --- a/sw/source/filter/ww8/ww8attributeoutput.hxx +++ b/sw/source/filter/ww8/ww8attributeoutput.hxx @@ -323,9 +323,6 @@ protected: /// Sfx item RES_TXTATR_FTN virtual void TextFootnote_Impl( const SwFmtFtn& ); - /// Sfx item RES_TXTATR_HARDBLANK - virtual void TextHardBlank( const SwFmtHardBlank& ); - /// Sfx item RES_PARATR_LINESPACING virtual void ParaLineSpacing_Impl( short nSpace, short nMulti ); diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx index 1eb9ae96b6..fe7fb79e01 100644 --- a/sw/source/filter/ww8/ww8glsy.cxx +++ b/sw/source/filter/ww8/ww8glsy.cxx @@ -187,7 +187,7 @@ bool WW8Glossary::MakeEntries(SwDoc *pD, SwTextBlocks &rBlocks, -1 ); pCNd = aIdx.GetNode().GetCntntNode(); SwPosition aPos( aIdx, SwIndex( pCNd, pCNd->Len() )); - pD->Copy( aPam, aPos, false ); + pD->CopyRange( aPam, aPos, false ); rBlocks.PutDoc(); } } diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 9d6f6fd34f..070de35a6d 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -46,7 +46,7 @@ #include <unotools/tempfile.hxx> #include <svtools/sfxecode.hxx> -#include <svtools/docpasswdrequest.hxx> +#include <comphelper/docpasswordrequest.hxx> #include <hintids.hxx> #include <svx/tstpitem.hxx> @@ -81,7 +81,6 @@ #include <fmtcntnt.hxx> #include <fmtcnct.hxx> #include <fmtpdsc.hxx> -#include <fmthbsh.hxx> #include <ftninfo.hxx> #include <fmtftn.hxx> #include <txtftn.hxx> @@ -579,7 +578,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, pObj->SetMergedItemSet(aSet); pObj->SetModel(pSdrModel); - if (bVerticalText && dynamic_cast< SdrTextObj* >( pObj ) ) + if (bVerticalText && dynamic_cast< SdrTextObj* >( pObj ) ) dynamic_cast< SdrTextObj* >( pObj )->SetVerticalWriting(sal_True); if ( bIsSimpleDrawingTextBox ) @@ -597,7 +596,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, } } - if ( ( mnFix16Angle || nTextRotationAngle ) && dynamic_cast< SdrObjCustomShape* >( pObj ) ) + if ( ( ( rObjData.nSpFlags & SP_FFLIPV ) || mnFix16Angle || nTextRotationAngle ) && dynamic_cast< SdrObjCustomShape* >( pObj ) ) { SdrObjCustomShape* pCustomShape = dynamic_cast< SdrObjCustomShape* >( pObj ); @@ -606,6 +605,10 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, { // text is already rotated, we have to take back the object rotation if DFF_Prop_RotateText is false fExtraTextRotation = -mnFix16Angle; } + if ( rObjData.nSpFlags & SP_FFLIPV ) // sj: in ppt the text is flipped, whereas in word the text + { // remains unchanged, so we have to take back the flipping here + fExtraTextRotation += 18000.0; // because our core will flip text if the shape is flipped. + } fExtraTextRotation += nTextRotationAngle; if ( !::basegfx::fTools::equalZero( fExtraTextRotation ) ) { @@ -950,7 +953,9 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, pFrm->SetFmtAttr(aURL); } else - pDoc->Insert(aRegion, *pEntry->pAttr, 0); + { + pDoc->InsertPoolItem(aRegion, *pEntry->pAttr, 0); + } } } break; @@ -1068,7 +1073,7 @@ void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos, SwTxtNode* pTxt = rBkMrkPos.nNode.GetNode().GetTxtNode(); if( pTxt && rBkMrkPos.nContent.GetIndex() ) { - SwTxtAttr* pFtn = pTxt->GetTxtAttr( + SwTxtAttr* const pFtn = pTxt->GetTxtAttrForCharAt( rBkMrkPos.nContent.GetIndex()-1, RES_TXTATR_FTN ); if( pFtn ) { @@ -1083,7 +1088,7 @@ void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos, } } - pDoc->Insert(aPaM, *pEntry->pAttr, 0); + pDoc->InsertPoolItem(aPaM, *pEntry->pAttr, 0); MoveAttrs(*aPaM.GetPoint()); } break; @@ -1623,7 +1628,7 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes) sTxt, aDate ); aPostIt.SetTextObject(pOutliner); - rDoc.Insert(*pPaM, SwFmtFld(aPostIt), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aPostIt), 0); return 0; } @@ -2177,6 +2182,66 @@ CharSet SwWW8ImplReader::GetCurrentCharSet() switch (pLang->GetLanguage()) { case LANGUAGE_CZECH: + case LANGUAGE_HUNGARIAN: + case LANGUAGE_POLISH: + eSrcCharSet = RTL_TEXTENCODING_MS_1250; + break; + case LANGUAGE_RUSSIAN: + eSrcCharSet = RTL_TEXTENCODING_MS_1251; + break; + case LANGUAGE_GREEK: + eSrcCharSet = RTL_TEXTENCODING_MS_1253; + break; + case LANGUAGE_TURKISH: + eSrcCharSet = RTL_TEXTENCODING_MS_1254; + break; + default: + eSrcCharSet = RTL_TEXTENCODING_MS_1252; + break; + } + } + } + } + return eSrcCharSet; +} + +//Takashi Ono for CJK +CharSet SwWW8ImplReader::GetCurrentCJKCharSet() +{ + /* + #i2015 + If the hard charset is set use it, if not see if there is an open + character run that has set the charset, if not then fallback to the + current underlying paragraph style. + */ + CharSet eSrcCharSet = eHardCharSet; + if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) + { + if (!maFontSrcCJKCharSets.empty()) + eSrcCharSet = maFontSrcCJKCharSets.top(); + if ((eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) && (nCharFmt != -1)) + eSrcCharSet = pCollA[nCharFmt].GetCJKCharSet(); + if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) + eSrcCharSet = pCollA[nAktColl].GetCJKCharSet(); + if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) + { // patch from cmc for #i52786# + /* + #i22206#/#i52786# + The (default) character set used for a run of text is the default + character set for the version of Word that last saved the document. + + This is a bit tentative, more might be required if the concept is correct. + When later version of word write older 6/95 documents the charset is + correctly set in the character runs involved, so its hard to reproduce + documents that require this to be sure of the process involved. + */ + const SvxLanguageItem *pLang = + (const SvxLanguageItem*)GetFmtAttr(RES_CHRATR_LANGUAGE); + if (pLang) + { + switch (pLang->GetLanguage()) + { + case LANGUAGE_CZECH: eSrcCharSet = RTL_TEXTENCODING_MS_1250; break; default: @@ -2221,7 +2286,7 @@ void SwWW8ImplReader::PostProcessAttrs() is only in use for 6/7 and for 8+ if we are in 8bit mode then the encoding is always 1252. - So a encoding converter that on an undefined character attempts to + So a encoding converter that on an undefined character attempts to convert from 1252 on the undefined character */ sal_Size Custom8BitToUnicode(rtl_TextToUnicodeConverter hConverter, @@ -2335,6 +2400,8 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs) const CharSet eSrcCharSet = bVer67 ? GetCurrentCharSet() : RTL_TEXTENCODING_MS_1252; + const CharSet eSrcCJKCharSet = bVer67 ? GetCurrentCJKCharSet() : + RTL_TEXTENCODING_MS_1252; // (re)alloc UniString data String sPlainCharsBuf; @@ -2395,7 +2462,7 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs) sal_Char aTest[2]; aTest[0] = static_cast< sal_Char >((nUCode & 0xFF00) >> 8); aTest[1] = static_cast< sal_Char >(nUCode & 0x00FF); - String aTemp(aTest, 2, eSrcCharSet); + String aTemp(aTest, 2, eSrcCJKCharSet); ASSERT(aTemp.Len() == 1, "so much for that theory"); *pWork = aTemp.GetChar(0); } @@ -2450,7 +2517,7 @@ bool SwWW8ImplReader::AddTextToParagraph(const String& rAddString) */ if ((pNd->GetTxt().Len() + rAddString.Len()) < STRING_MAXLEN -1) { - rDoc.Insert (*pPaM, rAddString, true); + rDoc.InsertString(*pPaM, rAddString); } else { @@ -2459,16 +2526,16 @@ bool SwWW8ImplReader::AddTextToParagraph(const String& rAddString) { String sTempStr (rAddString,0, STRING_MAXLEN - pNd->GetTxt().Len() -1); - rDoc.Insert (*pPaM, sTempStr, true); + rDoc.InsertString(*pPaM, sTempStr); sTempStr = rAddString.Copy(sTempStr.Len(), rAddString.Len() - sTempStr.Len()); AppendTxtNode(*pPaM->GetPoint()); - rDoc.Insert (*pPaM,sTempStr, true ); + rDoc.InsertString(*pPaM, sTempStr); } else { AppendTxtNode(*pPaM->GetPoint()); - rDoc.Insert (*pPaM, rAddString, true); + rDoc.InsertString(*pPaM, rAddString); } } @@ -2489,7 +2556,9 @@ bool SwWW8ImplReader::ReadChars(WW8_CP& rPos, WW8_CP nNextAttr, long nTextEnd, if( bSymbol ) // Spezialzeichen einfuegen { for(USHORT nCh = 0; nCh < nEnd - rPos; ++nCh) - rDoc.Insert( *pPaM, cSymbol ); + { + rDoc.InsertString( *pPaM, cSymbol ); + } pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_FONT ); } pStrm->SeekRel( nEnd- rPos ); @@ -2570,7 +2639,7 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs) SwPageNumberField aFld( (SwPageNumberFieldType*)rDoc.GetSysFldType( RES_PAGENUMBERFLD ), PG_RANDOM, SVX_NUM_ARABIC); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); } break; case 0xe: @@ -2582,7 +2651,8 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs) { // Always insert a txtnode for a column break, e.g. ## AppendTxtNode(*pPaM->GetPoint()); - rDoc.Insert(*pPaM, SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK), 0); + rDoc.InsertPoolItem(*pPaM, + SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK), 0); } break; case 0x7: @@ -2612,7 +2682,7 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs) SwPosition aEndPos = *pPaM->GetPoint(); SwPaM aFldPam(pFieldCtx->GetPtNode(), pFieldCtx->GetPtCntnt(), aEndPos.nNode, aEndPos.nContent.GetIndex()); IDocumentMarkAccess* const pMarkAccess = rDoc.getIDocumentMarkAccess(); - ::sw::mark::IFieldmark* pFieldmark = + ::sw::mark::IFieldmark* pFieldmark = dynamic_cast< ::sw::mark::IFieldmark*>(pMarkAccess->makeMark( aFldPam, pFieldCtx->GetBookmarkName(), @@ -2633,14 +2703,14 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs) case 0xc: bRet = HandlePageBreakChar(); break; - case 0x1e: - rDoc.Insert( *pPaM, CHAR_HARDHYPHEN); // Non-breaking hyphen + case 0x1e: // Non-breaking hyphen + rDoc.InsertString( *pPaM, CHAR_HARDHYPHEN ); break; - case 0x1f: - rDoc.Insert( *pPaM, CHAR_SOFTHYPHEN); // Non-required hyphens + case 0x1f: // Non-required hyphens + rDoc.InsertString( *pPaM, CHAR_SOFTHYPHEN ); break; - case 0xa0: - rDoc.Insert( *pPaM, CHAR_HARDBLANK); // Non-breaking spaces + case 0xa0: // Non-breaking spaces + rDoc.InsertString( *pPaM, CHAR_HARDBLANK ); break; case 0x1: /* @@ -3098,7 +3168,8 @@ bool SwWW8ImplReader::ReadText(long nStartCp, long nTextLen, ManTypes nType) AppendTxtNode(*pPaM->GetPoint()); } // <-- - rDoc.Insert(*pPaM, SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); + rDoc.InsertPoolItem(*pPaM, + SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); bPgSecBreak = false; } } @@ -3332,7 +3403,7 @@ void GiveNodePageDesc(SwNodeIndex &rIdx, const SwFmtPageDesc &rPgDesc, rIdx.GetNode().GetCntntNode(), 0); SwPaM aPage(aPamStart); - rDoc.Insert(aPage, rPgDesc, 0); + rDoc.InsertPoolItem(aPage, rPgDesc, 0); } } @@ -4171,8 +4242,8 @@ namespace uno::Reference< task::XInteractionHandler > xHandler( rMedium.GetInteractionHandler() ); if( xHandler.is() ) { - RequestDocumentPassword* pRequest = new RequestDocumentPassword( - task::PasswordRequestMode_PASSWORD_ENTER, + ::comphelper::DocPasswordRequest* pRequest = new ::comphelper::DocPasswordRequest( + ::comphelper::DocPasswordRequestType_MS, task::PasswordRequestMode_PASSWORD_ENTER, INetURLObject( rMedium.GetOrigURL() ).GetName( INetURLObject::DECODE_WITH_CHARSET ) ); uno::Reference< task::XInteractionRequest > xRequest( pRequest ); @@ -4348,7 +4419,7 @@ ULONG SwWW8ImplReader::LoadThroughDecryption(SwPaM& rPaM ,WW8Glossary *pGloss) if ( pMedium ) { SfxItemSet* pSet = pMedium->GetItemSet(); - if ( pSet ) + if ( pSet ) pSet->Put( SfxStringItem(SID_PASSWORD, sUniPassword) ); } } diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index 02c6e60573..a377602b87 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -933,6 +933,7 @@ private: Stack of textencoding being used as we progress through the document text */ std::stack<rtl_TextEncoding> maFontSrcCharSets; + std::stack<rtl_TextEncoding> maFontSrcCJKCharSets; /* Winword numbering gets imported as SwNumRules, there is a problem that @@ -1173,6 +1174,7 @@ private: rtl_TextEncoding&); bool SetNewFontAttr(USHORT nFCode, bool bSetEnums, USHORT nWhich); void ResetCharSetVars(); + void ResetCJKCharSetVars(); const SfxPoolItem* GetFmtAttr( USHORT nWhich ); bool JoinNode(SwPaM &rPam, bool bStealAttr = false); @@ -1615,6 +1617,7 @@ public: // eigentlich private, geht aber leider nur public // Laden eines kompletten DocFiles ULONG LoadDoc( SwPaM&,WW8Glossary *pGloss=0); CharSet GetCurrentCharSet(); + CharSet GetCurrentCJKCharSet(); void PostProcessAttrs(); }; diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 51d9cf86ee..4fa5075bd7 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -381,7 +381,7 @@ sal_uInt16 SwWW8ImplReader::End_Ftn() sChar.Append(pTxt->GetTxt().GetChar(--nPos)); pPaM->SetMark(); pPaM->GetMark()->nContent--; - rDoc.Delete( *pPaM ); + rDoc.DeleteRange( *pPaM ); pPaM->DeleteMark(); SwFmtFtn aFtn(rDesc.meType == MAN_EDN); pFN = pTxt->InsertItem(aFtn, nPos, nPos); @@ -435,7 +435,7 @@ sal_uInt16 SwWW8ImplReader::End_Ftn() pPaM->GetMark()->nContent++; pPaM->GetMark()->nContent++; pReffingStck->Delete(*pPaM); - rDoc.Delete( *pPaM ); + rDoc.DeleteRange( *pPaM ); pPaM->DeleteMark(); } } @@ -4725,4 +4725,11 @@ CharSet SwWW8StyInf::GetCharSet() const return eLTRFontSrcCharSet; } +CharSet SwWW8StyInf::GetCJKCharSet() const +{ + if ((pFmt) && (pFmt->GetFrmDir().GetValue() == FRMDIR_HORI_RIGHT_TOP)) + return eRTLFontSrcCharSet; + return eCJKFontSrcCharSet; +} + /* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/ww8par2.hxx b/sw/source/filter/ww8/ww8par2.hxx index 8041b68f1e..d8730b0c55 100644 --- a/sw/source/filter/ww8/ww8par2.hxx +++ b/sw/source/filter/ww8/ww8par2.hxx @@ -224,6 +224,7 @@ public: return pOutlineNumrule; } CharSet GetCharSet() const; + CharSet GetCJKCharSet() const; }; class WW8RStyle: public WW8Style diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 3101d1a8ef..4e1ec2fcfd 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -207,7 +207,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormTextBox( WW8FieldDesc* pF, String& rStr ) aFld.SetHelp(aFormula.sHelp); aFld.SetToolTip(aFormula.sToolTip); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } else { WW8PLCFx_Book* pB = pPlcxMan->GetBook(); @@ -321,7 +321,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormListBox( WW8FieldDesc* pF, String& rStr) aFld.SetSelectedItem(aFormula.maListEntries[nIndex]); } - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 54f328ee00..3cded67e9f 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -61,7 +61,6 @@ #include <svx/fhgtitem.hxx> #include <svx/langitem.hxx> #include <fmtfld.hxx> -#include <fmthbsh.hxx> #include <fmtanchr.hxx> #include <pam.hxx> // fuer SwPam #include <doc.hxx> @@ -1062,7 +1061,8 @@ void SwWW8ImplReader::InsertTagField( const USHORT nId, const String& rTagText ) if( SwFltGetFlag(nFieldFlags, SwFltControlStack::TAGS_IN_TEXT)) { aName += rTagText; // als Txt taggen - rDoc.Insert(*pPaM, aName, false); + rDoc.InsertString(*pPaM, aName, + IDocumentContentOperations::INS_NOHINTEXPAND); } else { // normal tagggen @@ -1073,7 +1073,7 @@ void SwWW8ImplReader::InsertTagField( const USHORT nId, const String& rTagText ) USHORT nSubType = ( SwFltGetFlag( nFieldFlags, SwFltControlStack::TAGS_VISIBLE ) ) ? 0 : nsSwExtendedSubType::SUB_INVISIBLE; aFld.SetSubType(nSubType | nsSwGetSetExpType::GSE_STRING); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); } } @@ -1133,7 +1133,7 @@ eF_ResT SwWW8ImplReader::Read_F_Input( WW8FieldDesc* pF, String& rStr ) SwInputField aFld( (SwInputFieldType*)rDoc.GetSysFldType( RES_INPUTFLD ), aDef, aQ, INP_TXT, 0 ); // sichtbar ( geht z.Zt. nicht anders ) - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1335,7 +1335,7 @@ eF_ResT SwWW8ImplReader::Read_F_InputVar( WW8FieldDesc* pF, String& rStr ) aFld.SetInputFlag(true); aFld.SetPromptText( aQ ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); pReffedStck->SetAttr(*pPaM->GetPoint(), RES_FLTR_BOOKMARK, true, nNo); return FLD_OK; @@ -1351,7 +1351,7 @@ eF_ResT SwWW8ImplReader::Read_F_ANumber( WW8FieldDesc*, String& rStr ) SwSetExpField aFld( (SwSetExpFieldType*)pNumFldType, aEmptyStr, GetNumberPara( rStr ) ); aFld.SetValue( ++nFldNum ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1427,7 +1427,7 @@ eF_ResT SwWW8ImplReader::Read_F_Seq( WW8FieldDesc*, String& rStr ) else if (!bCountOn) aFld.SetFormula(aSequenceName); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } @@ -1552,7 +1552,7 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, String& rStr ) */ SwDocInfoField aFld( (SwDocInfoFieldType*) rDoc.GetSysFldType( RES_DOCINFOFLD ), DI_CUSTOM|nReg, aDocProperty, GetFieldResult( pF ) ); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } @@ -1632,7 +1632,7 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, String& rStr ) rDoc.GetSysFldType( RES_DOCINFOFLD ), nSub|nReg, String(), nFormat ); if (bDateTime) ForceFieldLanguage(aFld, nLang); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } @@ -1645,7 +1645,7 @@ eF_ResT SwWW8ImplReader::Read_F_Author( WW8FieldDesc*, String& ) SwDocInfoField aFld( (SwDocInfoFieldType*) rDoc.GetSysFldType( RES_DOCINFOFLD ), DI_CREATE|DI_SUB_AUTHOR, String() ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1653,7 +1653,7 @@ eF_ResT SwWW8ImplReader::Read_F_TemplName( WW8FieldDesc*, String& ) { SwTemplNameField aFld( (SwTemplNameFieldType*) rDoc.GetSysFldType( RES_TEMPLNAMEFLD ), FF_NAME ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1708,14 +1708,14 @@ eF_ResT SwWW8ImplReader::Read_F_DateTime( WW8FieldDesc*pF, String& rStr ) SwDateTimeField aFld((SwDateTimeFieldType*) rDoc.GetSysFldType(RES_DATETIMEFLD ), DATEFLD, nFormat); ForceFieldLanguage(aFld, nLang); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); } else if (nDT == NUMBERFORMAT_TIME) { SwDateTimeField aFld((SwDateTimeFieldType*) rDoc.GetSysFldType(RES_DATETIMEFLD), TIMEFLD, nFormat); ForceFieldLanguage(aFld, nLang); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); } return FLD_OK; @@ -1745,7 +1745,7 @@ eF_ResT SwWW8ImplReader::Read_F_FileName(WW8FieldDesc*, String &rStr) SwFileNameField aFld( (SwFileNameFieldType*)rDoc.GetSysFldType(RES_FILENAMEFLD), eType); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } @@ -1759,7 +1759,7 @@ eF_ResT SwWW8ImplReader::Read_F_Anz( WW8FieldDesc* pF, String& rStr ) SwDocStatField aFld( (SwDocStatFieldType*) rDoc.GetSysFldType( RES_DOCSTATFLD ), nSub, GetNumberPara( rStr ) ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1771,7 +1771,7 @@ eF_ResT SwWW8ImplReader::Read_F_CurPage( WW8FieldDesc*, String& rStr ) SwChapterField aFld( (SwChapterFieldType*) rDoc.GetSysFldType( RES_CHAPTERFLD ), CF_NUMBER ); aFld.SetLevel( nPgChpLevel ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); static const sal_Char aDelim[] = "-.:\x97\x96"; BYTE nDelim = nPgChpDelim; @@ -1781,9 +1781,13 @@ eF_ResT SwWW8ImplReader::Read_F_CurPage( WW8FieldDesc*, String& rStr ) sal_Unicode c = ByteString::ConvertToUnicode( aDelim[ nDelim ], RTL_TEXTENCODING_MS_1252 ); if( '-' == c ) - rDoc.Insert( *pPaM, CHAR_HARDHYPHEN ); + { + rDoc.InsertString( *pPaM, CHAR_HARDHYPHEN ); + } else - rDoc.Insert( *pPaM, SwFmtHardBlank( c ), 0); + { + rDoc.InsertString( *pPaM, c ); // maybe insert ZWNBSP? + } } // Seitennummer @@ -1791,7 +1795,7 @@ eF_ResT SwWW8ImplReader::Read_F_CurPage( WW8FieldDesc*, String& rStr ) rDoc.GetSysFldType( RES_PAGENUMBERFLD ), PG_RANDOM, GetNumberPara(rStr, true)); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1850,7 +1854,7 @@ eF_ResT SwWW8ImplReader::Read_F_Symbol( WW8FieldDesc*, String& rStr ) NewAttr(aSz); } - rDoc.Insert(*pPaM, cChar); + rDoc.InsertString(*pPaM, cChar); if (nSize > 0) pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_CHRATR_FONTSIZE); @@ -1859,7 +1863,7 @@ eF_ResT SwWW8ImplReader::Read_F_Symbol( WW8FieldDesc*, String& rStr ) } else { - rDoc.Insert(*pPaM, CREATE_CONST_ASC("###"), true); + rDoc.InsertString(*pPaM, CREATE_CONST_ASC("###")); } return FLD_OK; @@ -1920,7 +1924,7 @@ eF_ResT SwWW8ImplReader::Read_F_Set( WW8FieldDesc* pF, String& rStr ) SwSetExpField aFld( (SwSetExpFieldType*)pFT, sVal, ULONG_MAX ); aFld.SetSubType(nsSwExtendedSubType::SUB_INVISIBLE | nsSwGetSetExpType::GSE_STRING); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); pReffedStck->SetAttr(*pPaM->GetPoint(), RES_FLTR_BOOKMARK, true, nNo); @@ -1970,7 +1974,7 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr ) SwGetRefField aFld( (SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ), sBkmName,REF_BOOKMARK,0,REF_CHAPTER); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); } else { @@ -1993,7 +1997,7 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr ) SwGetRefField aFld( (SwGetRefFieldType*) rDoc.GetSysFldType( RES_GETREFFLD ), sBkmName, REF_BOOKMARK, 0, REF_UPDOWN ); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); } return FLD_OK; } @@ -2070,7 +2074,7 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, String& rStr ) (SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ), sName, REF_BOOKMARK, 0, REF_PAGE ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -2119,7 +2123,7 @@ eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, String& rStr) SwMacroField aFld( (SwMacroFieldType*) rDoc.GetSysFldType( RES_MACROFLD ), aName, aVText ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); WW8_CP nOldCp = pPlcxMan->Where(); @@ -2280,7 +2284,7 @@ eF_ResT SwWW8ImplReader::Read_F_IncludeText( WW8FieldDesc* /*pF*/, String& rStr aSection.SetLinkFileName( aPara ); aSection.SetProtect(true); - SwSection* pSection = rDoc.Insert(*pPaM, aSection, 0 ,false); + SwSection*const pSection = rDoc.InsertSwSection(*pPaM, aSection, 0, false); ASSERT(pSection, "no section inserted"); if (!pSection) return FLD_TEXT; @@ -2327,7 +2331,7 @@ eF_ResT SwWW8ImplReader::Read_F_DBField( WW8FieldDesc* pF, String& rStr ) aFld.InitContent(aResult); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld( aFld ), 0); return FLD_OK; } @@ -2339,7 +2343,7 @@ eF_ResT SwWW8ImplReader::Read_F_DBNext( WW8FieldDesc*, String& ) SwFieldType* pFT = rDoc.InsertFldType( aN ); SwDBNextSetField aFld( (SwDBNextSetFieldType*)pFT, aEmptyStr, aEmptyStr, SwDBData() ); // Datenbank: Nichts - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -2350,7 +2354,7 @@ eF_ResT SwWW8ImplReader::Read_F_DBNum( WW8FieldDesc*, String& ) SwFieldType* pFT = rDoc.InsertFldType( aN ); SwDBSetNumberField aFld( (SwDBSetNumberFieldType*)pFT, SwDBData() ); // Datenbank: Nichts - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -2415,7 +2419,7 @@ void SwWW8ImplReader::Read_SubF_Combined( _ReadFieldParams& rReadParam) { SwCombinedCharField aFld((SwCombinedCharFieldType*) rDoc.GetSysFldType(RES_COMBINED_CHARS),sCombinedCharacters); - rDoc.Insert(*pPaM,SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); } } @@ -2521,8 +2525,8 @@ void SwWW8ImplReader::Read_SubF_Ruby( _ReadFieldParams& rReadParam) const SwCharFmt *pCharFmt=0; //Make a guess at which of asian of western we should be setting USHORT nScript; - if (pBreakIt->xBreak.is()) - nScript = pBreakIt->xBreak->getScriptType(sRuby, 0); + if (pBreakIt->GetBreakIter().is()) + nScript = pBreakIt->GetBreakIter()->getScriptType(sRuby, 0); else nScript = i18n::ScriptType::ASIAN; @@ -2573,7 +2577,7 @@ void SwWW8ImplReader::Read_SubF_Ruby( _ReadFieldParams& rReadParam) aRuby.SetAdjustment(nJustificationCode); NewAttr(aRuby); - rDoc.Insert( *pPaM, sText, true ); + rDoc.InsertString( *pPaM, sText ); pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_TXTATR_CJK_RUBY ); } } @@ -3423,7 +3427,7 @@ void lcl_ImportTox(SwDoc &rDoc, SwPaM &rPaM, const String &rStr, bool bIdx) if (sFldTxt.Len()) { aM.SetAlternativeText( sFldTxt ); - rDoc.Insert( rPaM, aM, 0 ); + rDoc.InsertPoolItem( rPaM, aM, 0 ); } } diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 118b2f165e..0fa9cc60a8 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -698,7 +698,8 @@ SwSectionFmt *wwSectionManager::InsertSection( aSection.SetProtect(SectionIsProtected(rSection)); - rSection.mpSection = mrReader.rDoc.Insert( rMyPaM, aSection, &aSet ); + rSection.mpSection = + mrReader.rDoc.InsertSwSection( rMyPaM, aSection, &aSet ); ASSERT(rSection.mpSection, "section not inserted!"); if (!rSection.mpSection) return 0; @@ -851,7 +852,7 @@ void wwSectionManager::CreateSep(const long nTxtPos, bool /*bMustHaveBreak*/) aSection.SetProtect(true); // --> CMC, OD 2004-06-18 #i19922# improvement: // return value of method <Insert> not used. - mrReader.rDoc.Insert(*mrReader.pPaM, aSection, 0 ,false); + mrReader.rDoc.InsertSwSection(*mrReader.pPaM, aSection, 0, false); } wwSection aLastSection(*mrReader.pPaM->GetPoint()); @@ -3217,7 +3218,7 @@ SwFrmFmt *SwWW8ImplReader::ContainsSingleInlineGraphic(const SwPaM &rRegion) if ( aBegin == aEnd && nBegin == nEnd - 1 && 0 != (pTNd = aBegin.GetNode().GetTxtNode()) && - 0 != (pTFlyAttr = pTNd->GetTxtAttr(nBegin, RES_TXTATR_FLYCNT)) + 0 != (pTFlyAttr = pTNd->GetTxtAttrForCharAt(nBegin, RES_TXTATR_FLYCNT)) ) { const SwFmtFlyCnt& rFly = pTFlyAttr->GetFlyCnt(); @@ -3557,11 +3558,32 @@ bool SwWW8ImplReader::SetNewFontAttr(USHORT nFCode, bool bSetEnums, //off the stack will keep in sync if (!pAktColl && IsListOrDropcap()) { - if (!maFontSrcCharSets.empty()) - eSrcCharSet = maFontSrcCharSets.top(); + if (nWhich == RES_CHRATR_CJK_FONT) + { + if (!maFontSrcCJKCharSets.empty()) + { + eSrcCharSet = maFontSrcCJKCharSets.top(); + } + else + { + eSrcCharSet = RTL_TEXTENCODING_DONTKNOW; + } + + maFontSrcCJKCharSets.push(eSrcCharSet); + } else - eSrcCharSet = RTL_TEXTENCODING_DONTKNOW; - maFontSrcCharSets.push(eSrcCharSet); + { + if (!maFontSrcCharSets.empty()) + { + eSrcCharSet = maFontSrcCharSets.top(); + } + else + { + eSrcCharSet = RTL_TEXTENCODING_DONTKNOW; + } + + maFontSrcCharSets.push(eSrcCharSet); + } } return false; } @@ -3591,7 +3613,10 @@ bool SwWW8ImplReader::SetNewFontAttr(USHORT nFCode, bool bSetEnums, else if (IsListOrDropcap()) { //Add character text encoding to stack - maFontSrcCharSets.push(eSrcCharSet); + if (nWhich == RES_CHRATR_CJK_FONT) + maFontSrcCJKCharSets.push(eSrcCharSet); + else + maFontSrcCharSets.push(eSrcCharSet); } } @@ -3607,6 +3632,13 @@ void SwWW8ImplReader::ResetCharSetVars() maFontSrcCharSets.pop(); } +void SwWW8ImplReader::ResetCJKCharSetVars() +{ + ASSERT(!maFontSrcCJKCharSets.empty(),"no charset to remove"); + if (!maFontSrcCJKCharSets.empty()) + maFontSrcCJKCharSets.pop(); +} + /* Font ein oder ausschalten: */ @@ -3637,7 +3669,10 @@ void SwWW8ImplReader::Read_FontCode( USHORT nId, const BYTE* pData, short nLen ) if( nLen < 0 ) // Ende des Attributes { pCtrlStck->SetAttr( *pPaM->GetPoint(), nId ); - ResetCharSetVars(); + if (nId == RES_CHRATR_CJK_FONT) + ResetCJKCharSetVars(); + else + ResetCharSetVars(); } else { diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 4ea643ea4e..3f7bf9e056 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -1498,8 +1498,15 @@ WW8_CP WW8ScannerBase::WW8Fc2Cp( WW8_FC nFcPos ) const } INT32 nFcStart = SVBT32ToUInt32( ((WW8_PCD*)pData)->fc ); if( 8 <= pWw8Fib->nVersion ) + { nFcStart = WW8PLCFx_PCD::TransformPieceAddress( nFcStart, bIsUnicode ); + } + else + { + if (pWw8Fib->fExtChar) + bIsUnicode=true; + } INT32 nLen = (nCpEnd - nCpStart) * (bIsUnicode ? 2 : 1); /* @@ -1581,7 +1588,10 @@ WW8_FC WW8ScannerBase::WW8Cp2Fc(WW8_CP nCpPos, bool* pIsUnicode, WW8_FC nRet = SVBT32ToUInt32( ((WW8_PCD*)pData)->fc ); if (8 > pWw8Fib->nVersion) - *pIsUnicode = false; + if (pWw8Fib->fExtChar) + *pIsUnicode=true; + else + *pIsUnicode = false; else nRet = WW8PLCFx_PCD::TransformPieceAddress( nRet, *pIsUnicode ); diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index 2c135dc12d..76029cc249 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -646,7 +646,7 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo) // delete 'deleted' redlines and forget about the whole thing if (nsRedlineType_t::REDLINE_DELETE == pRedlineInfo->eType) { - pDoc->Delete(aPaM); + pDoc->DeleteRange(aPaM); // And what about the "deleted nodes"? // They have to be deleted as well (#i80689)! if( bIgnoreRedlines && pRedlineInfo->pContentIndex != NULL ) @@ -657,7 +657,7 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo) { SwNodeIndex aEnd( *pEnd, 1 ); SwPaM aDel( aIdx, aEnd ); - pDoc->Delete(aDel); + pDoc->DeleteRange(aDel); } } } diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index c215e1e41b..db83d59eaf 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -216,6 +216,24 @@ sal_Int32 ReadThroughComponent( } catch( xml::sax::SAXParseException& r ) { + // sax parser sends wrapped exceptions, + // try to find the original one + xml::sax::SAXException aSaxEx = *(xml::sax::SAXException*)(&r); + sal_Bool bTryChild = sal_True; + + while( bTryChild ) + { + xml::sax::SAXException aTmp; + if ( aSaxEx.WrappedException >>= aTmp ) + aSaxEx = aTmp; + else + bTryChild = sal_False; + } + + packages::zip::ZipIOException aBrokenPackage; + if ( aSaxEx.WrappedException >>= aBrokenPackage ) + return ERRCODE_IO_BROKENPACKAGE; + if( bEncrypted ) return ERRCODE_SFX_WRONGPASSWORD; @@ -246,7 +264,10 @@ sal_Int32 ReadThroughComponent( } catch( xml::sax::SAXException& r) { - (void)r; + packages::zip::ZipIOException aBrokenPackage; + if ( r.WrappedException >>= aBrokenPackage ) + return ERRCODE_IO_BROKENPACKAGE; + if( bEncrypted ) return ERRCODE_SFX_WRONGPASSWORD; @@ -255,6 +276,7 @@ sal_Int32 ReadThroughComponent( aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); DBG_ERROR( aError.GetBuffer() ); #endif + return ERR_SWG_READ_ERROR; } catch( packages::zip::ZipIOException& r) @@ -873,35 +895,39 @@ ULONG XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const S // <-- sal_uInt32 nWarnRDF = 0; - // RDF metadata - must be read before styles/content - // N.B.: embedded documents have their own manifest.rdf! - try - { - const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(xModelComp, - uno::UNO_QUERY_THROW); - const uno::Reference<rdf::XURI> xBaseURI( ::sfx2::createBaseURI( - aContext.getUNOContext(), xStorage, aBaseURL, StreamPath) ); - const uno::Reference<task::XInteractionHandler> xHandler( - pDocSh->GetMedium()->GetInteractionHandler() ); - xDMA->loadMetadataFromStorage(xStorage, xBaseURI, xHandler); - } - catch (lang::WrappedTargetException & e) + if ( !(IsOrganizerMode() || IsBlockMode() || aOpt.IsFmtsOnly() || + bInsertMode) ) { - ucb::InteractiveAugmentedIOException iaioe; - if (e.TargetException >>= iaioe) + // RDF metadata - must be read before styles/content + // N.B.: embedded documents have their own manifest.rdf! + try { - // import error that was not ignored by InteractionHandler! - nWarnRDF = ERR_SWG_READ_ERROR; + const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(xModelComp, + uno::UNO_QUERY_THROW); + const uno::Reference<rdf::XURI> xBaseURI( ::sfx2::createBaseURI( + aContext.getUNOContext(), xStorage, aBaseURL, StreamPath) ); + const uno::Reference<task::XInteractionHandler> xHandler( + pDocSh->GetMedium()->GetInteractionHandler() ); + xDMA->loadMetadataFromStorage(xStorage, xBaseURI, xHandler); } - else + catch (lang::WrappedTargetException & e) + { + ucb::InteractiveAugmentedIOException iaioe; + if (e.TargetException >>= iaioe) + { + // import error that was not ignored by InteractionHandler! + nWarnRDF = ERR_SWG_READ_ERROR; + } + else + { + nWarnRDF = WARN_SWG_FEATURES_LOST; // uhh... something wrong? + } + } + catch (uno::Exception &) { nWarnRDF = WARN_SWG_FEATURES_LOST; // uhh... something went wrong? } } - catch (uno::Exception &) - { - nWarnRDF = WARN_SWG_FEATURES_LOST; // uhh... something went wrong? - } sal_uInt32 nWarn = 0; sal_uInt32 nWarn2 = 0; diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index 5ccaaa948f..2aef86c78d 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -699,7 +699,7 @@ void SwXMLTableCellContext_Impl::EndElement() SwPaM aSrcPaM( *pSrcPaM->GetPoint(), *pSrcPaM->GetMark() ); SwPosition aDstPos( *pDstTxtCrsr->GetPaM()->GetPoint() ); - pDoc->Copy( aSrcPaM, aDstPos, false ); + pDoc->CopyRange( aSrcPaM, aDstPos, false ); nColRepeat--; } diff --git a/sw/source/ui/app/appopt.cxx b/sw/source/ui/app/appopt.cxx index 9e3c539f7d..0e8fe09583 100644 --- a/sw/source/ui/app/appopt.cxx +++ b/sw/source/ui/app/appopt.cxx @@ -35,6 +35,8 @@ #include <cmdid.h> // Funktion-Ids #endif +#include <com/sun/star/i18n/ScriptType.hpp> + #define _SVSTDARR_STRINGSDTOR #include <svtools/svstdarr.hxx> @@ -54,6 +56,7 @@ #include <svx/optgrid.hxx> #include <svx/svxdlg.hxx> #include <svx/dialogs.hrc> +#include <i18npool/mslangid.hxx> #include <fontcfg.hxx> #include <optload.hxx> #include <optcomp.hxx> @@ -191,19 +194,25 @@ SfxItemSet* SwModule::CreateItemSet( USHORT nId ) pRet->Put(SwPtrItem(FN_PARAM_PRINTER, pPrt));*/ SvtLinguConfig aLinguCfg; + Locale aLocale; + LanguageType nLang; + + using namespace ::com::sun::star::i18n::ScriptType; Any aLang = aLinguCfg.GetProperty(C2U("DefaultLocale")); - Locale aLocale; aLang >>= aLocale; - pRet->Put(SvxLanguageItem(SvxLocaleToLanguage( aLocale ), SID_ATTR_LANGUAGE)); + nLang = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aLocale), LATIN); + pRet->Put(SvxLanguageItem(nLang, SID_ATTR_LANGUAGE)); aLang = aLinguCfg.GetProperty(C2U("DefaultLocale_CJK")); aLang >>= aLocale; - pRet->Put(SvxLanguageItem(SvxLocaleToLanguage( aLocale ), SID_ATTR_CHAR_CJK_LANGUAGE)); + nLang = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aLocale), ASIAN); + pRet->Put(SvxLanguageItem(nLang, SID_ATTR_CHAR_CJK_LANGUAGE)); aLang = aLinguCfg.GetProperty(C2U("DefaultLocale_CTL")); aLang >>= aLocale; - pRet->Put(SvxLanguageItem(SvxLocaleToLanguage( aLocale ), SID_ATTR_CHAR_CTL_LANGUAGE)); + nLang = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aLocale), COMPLEX); + pRet->Put(SvxLanguageItem(nLang, SID_ATTR_CHAR_CTL_LANGUAGE)); } if(bTextDialog) pRet->Put(SwPtrItem(FN_PARAM_STDFONTS, GetStdFontConfig())); diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx index 0d71a7f304..ec29858041 100644 --- a/sw/source/ui/app/docsh.cxx +++ b/sw/source/ui/app/docsh.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -435,7 +435,7 @@ sal_Bool SwDocShell::SaveAs( SfxMedium& rMedium ) if(pView) pView->GetEditWin().StopQuickHelp(); - //#i91811# mod if we have an active margin window, write back the text + //#i91811# mod if we have an active margin window, write back the text if (pView && pView->GetPostItMgr() && pView->GetPostItMgr()->GetActivePostIt()) pView->GetPostItMgr()->GetActivePostIt()->UpdateData(); @@ -582,7 +582,7 @@ BOOL SwDocShell::ConvertTo( SfxMedium& rMedium ) if(pView) pView->GetEditWin().StopQuickHelp(); - //#i91811# mod if we have an active margin window, write back the text + //#i91811# mod if we have an active margin window, write back the text if (pView && pView->GetPostItMgr() && pView->GetPostItMgr()->GetActivePostIt()) pView->GetPostItMgr()->GetActivePostIt()->UpdateData(); @@ -1083,15 +1083,10 @@ void SwDocShell::GetState(SfxItemSet& rSet) break; case SID_SOURCEVIEW: { - if(IsLoading()) - rSet.DisableItem(nWhich); - else - { - SfxViewShell* pCurrView = GetView() ? (SfxViewShell*)GetView() - : SfxViewShell::Current(); - BOOL bSourceView = 0 != PTR_CAST(SwSrcView, pCurrView); - rSet.Put(SfxBoolItem(SID_SOURCEVIEW, bSourceView)); - } + SfxViewShell* pCurrView = GetView() ? (SfxViewShell*)GetView() + : SfxViewShell::Current(); + BOOL bSourceView = 0 != PTR_CAST(SwSrcView, pCurrView); + rSet.Put(SfxBoolItem(SID_SOURCEVIEW, bSourceView)); } break; case SID_HTML_MODE: @@ -1116,18 +1111,10 @@ void SwDocShell::GetState(SfxItemSet& rSet) case SID_BROWSER_MODE: case FN_PRINT_LAYOUT: { - SfxViewShell* pViewShell = SfxViewShell::Current(); - BOOL bDisable = 0 != PTR_CAST(SwPagePreView, pViewShell) || - 0 != PTR_CAST(SwSrcView, pViewShell); - if (bDisable) - rSet.DisableItem( nWhich ); - else - { - sal_Bool bState = GetDoc()->get(IDocumentSettingAccess::BROWSE_MODE); - if(FN_PRINT_LAYOUT == nWhich) - bState = !bState; - rSet.Put( SfxBoolItem( nWhich, bState)); - } + sal_Bool bState = GetDoc()->get(IDocumentSettingAccess::BROWSE_MODE); + if(FN_PRINT_LAYOUT == nWhich) + bState = !bState; + rSet.Put( SfxBoolItem( nWhich, bState)); } break; @@ -1337,44 +1324,42 @@ uno::Reference< frame::XController > /* -----------------------------12.02.01 12:08-------------------------------- ---------------------------------------------------------------------------*/ +static const char* pEventNames[] = +{ + "OnPageCountChange", + "OnMailMerge", + "OnMailMergeFinished", + "OnFieldMerge", + "OnFieldMergeFinished", + "OnLayoutFinished" +}; + Sequence< OUString > SwDocShell::GetEventNames() { Sequence< OUString > aRet = SfxObjectShell::GetEventNames(); sal_Int32 nLen = aRet.getLength(); - aRet.realloc(nLen + 2); + aRet.realloc(nLen + 6); OUString* pNames = aRet.getArray(); - pNames[nLen++] = OUString::createFromAscii("OnMailMerge"); - pNames[nLen] = OUString::createFromAscii("OnPageCountChange"); + pNames[nLen++] = GetEventName(0); + pNames[nLen++] = GetEventName(1); + pNames[nLen++] = GetEventName(2); + pNames[nLen++] = GetEventName(3); + pNames[nLen++] = GetEventName(4); + pNames[nLen] = GetEventName(5); + return aRet; } -/* -void SwTmpPersist::FillClass( SvGlobalName * pClassName, - ULONG * pClipFormat, - String * pAppName, - String * pLongUserName, - String * pUserName, - sal_Int32 nFileFormat ) const -{ - pDShell->SwDocShell::FillClass( pClassName, pClipFormat, pAppName, - pLongUserName, pUserName, nFileFormat ); -} -BOOL SwTmpPersist::Save() -{ - if( SaveChilds() ) - return SvPersist::Save(); - return FALSE; -} +static sal_Int32 nEvents=13; -BOOL SwTmpPersist::SaveCompleted( SvStorage * pStor ) +rtl::OUString SwDocShell::GetEventName( sal_Int32 nIndex ) { - if( SaveCompletedChilds( pStor ) ) - return SvPersist::SaveCompleted( pStor ); - return FALSE; -} */ + if ( nIndex<nEvents ) + return ::rtl::OUString::createFromAscii(pEventNames[nIndex]); + return rtl::OUString(); +} const ::sfx2::IXmlIdRegistry* SwDocShell::GetXmlIdRegistry() const { return pDoc ? &pDoc->GetXmlIdRegistry() : 0; } - diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index 8cd955aa19..1b0a0c1c0e 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -943,10 +943,10 @@ void SwDocShell::Execute(SfxRequest& rReq) bDone = TRUE; SfxEventConfiguration* pEvent = SFX_APP()->GetEventConfig(); SvxMacro aMac(aEmptyStr, aEmptyStr, STARBASIC); - pEvent->ConfigureEvent(SFX_EVENT_OPENDOC, aMac, this); - pEvent->ConfigureEvent(SFX_EVENT_CLOSEDOC, aMac, this); - pEvent->ConfigureEvent(SFX_EVENT_ACTIVATEDOC, aMac, this); - pEvent->ConfigureEvent(SFX_EVENT_DEACTIVATEDOC, aMac, this); + pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC ), aMac, this); + pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEDOC ), aMac, this); + pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ), aMac, this); + pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC ), aMac, this); ReloadFromHtml(aTempFile.GetURL(), pSrcView); nSlot = 0; } @@ -983,6 +983,8 @@ void SwDocShell::Execute(SfxRequest& rReq) //pSavePrinter darf nicht wieder geloescht werden } pViewFrm->GetBindings().SetState(SfxBoolItem(SID_SOURCEVIEW, nSlot == SID_VIEWSHELL2)); + pViewFrm->GetBindings().Invalidate( SID_BROWSER_MODE ); + pViewFrm->GetBindings().Invalidate( FN_PRINT_LAYOUT ); } break; case SID_GET_COLORTABLE: @@ -1780,7 +1782,10 @@ void SwDocShell::ToggleBrowserMode(BOOL bSet, SwView* _pView ) SwView* pTempView = _pView ? _pView : (SwView*)GetView(); if( pTempView ) { - pTempView->GetViewFrame()->GetBindings().Invalidate(FN_SHADOWCURSOR); + SfxBindings& rBind = pTempView->GetViewFrame()->GetBindings(); + rBind.Invalidate(FN_SHADOWCURSOR); + rBind.Invalidate(SID_BROWSER_MODE); + rBind.Invalidate(FN_PRINT_LAYOUT); if( !GetDoc()->getPrinter( false ) ) { @@ -1793,8 +1798,8 @@ void SwDocShell::ToggleBrowserMode(BOOL bSet, SwView* _pView ) GetDoc()->CheckDefaultPageFmt(); // <-- - //Wenn wir die BrowseView einschalten, darf es nur diese eine - //Sicht auf das Dokument geben, alle anderen werden geschlossen. + // Currently there can be only one view (layout) if the document is viewed in Web layout + // So if there are more views we are in print layout and for toggling to Web layout all other views must be closed SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(this, 0, FALSE); do { if( pTmpFrm != pTempView->GetViewFrame() ) diff --git a/sw/source/ui/app/docshini.cxx b/sw/source/ui/app/docshini.cxx index d925673268..4ceae52f27 100644 --- a/sw/source/ui/app/docshini.cxx +++ b/sw/source/ui/app/docshini.cxx @@ -37,6 +37,7 @@ #ifndef _SVX_DIALOGS_HRC #include <svx/dialogs.hrc> #endif +#include <i18npool/mslangid.hxx> #include <sot/storinfo.hxx> #include <sot/storage.hxx> #include <svtools/zforlist.hxx> @@ -58,6 +59,7 @@ #endif #include <linguistic/lngprops.hxx> #include <com/sun/star/document/UpdateDocMode.hpp> +#include <com/sun/star/i18n/ScriptType.hpp> #include <rtl/logfile.hxx> #include <sfx2/docfilt.hxx> #include <svx/xtable.hxx> @@ -791,9 +793,9 @@ void SwDocShell::SubInitNew() SvtLinguConfig().GetOptions( aLinguOpt ); - sal_Int16 nVal = aLinguOpt.nDefaultLanguage, - eCJK = aLinguOpt.nDefaultLanguage_CJK, - eCTL = aLinguOpt.nDefaultLanguage_CTL; + sal_Int16 nVal = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), + eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), + eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX); aDfltSet.Put( SvxLanguageItem( nVal, RES_CHRATR_LANGUAGE ) ); aDfltSet.Put( SvxLanguageItem( eCJK, RES_CHRATR_CJK_LANGUAGE ) ); aDfltSet.Put( SvxLanguageItem( eCTL, RES_CHRATR_CTL_LANGUAGE ) ); diff --git a/sw/source/ui/app/docstyle.cxx b/sw/source/ui/app/docstyle.cxx index 1add147bc1..db72c86319 100644 --- a/sw/source/ui/app/docstyle.cxx +++ b/sw/source/ui/app/docstyle.cxx @@ -37,6 +37,7 @@ #include <hintids.hxx> #include <svtools/itemiter.hxx> #include <svtools/eitem.hxx> +#include <svtools/syslocale.hxx> #include <svx/boxitem.hxx> #include <svx/numitem.hxx> // --> OD 2008-02-13 #newlistlevelattrs# @@ -609,7 +610,7 @@ String SwDocStyleSheet::GetDescription(SfxMapUnit eUnit) { IntlWrapper aIntlWrapper( ::comphelper::getProcessServiceFactory(), - GetAppLocaleData().getLocale()); + SvtSysLocale().GetLocaleData().getLocale()); String sPlus(String::CreateFromAscii(" + ")); if ( SFX_STYLE_FAMILY_PAGE == nFamily ) diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src index 33368585df..f1f210f1a4 100644 --- a/sw/source/ui/app/mn.src +++ b/sw/source/ui/app/mn.src @@ -441,26 +441,26 @@ {\ Identifier = FN_DELETE_NOTE ;\ HelpID = FN_DELETE_NOTE ;\ - Text [ en-US ] = "Delete ~Note" ;\ + Text [ en-US ] = "Delete ~Comment" ;\ };\ MenuItem\ {\ Identifier = FN_DELETE_NOTE_AUTHOR ;\ HelpID = FN_DELETE_NOTE_AUTHOR ;\ - Text [ en-US ] = "Delete ~All Notes by $1" ;\ + Text [ en-US ] = "Delete ~All Comments by $1" ;\ };\ MenuItem\ {\ Identifier = FN_DELETE_ALL_NOTES ;\ HelpID = FN_DELETE_ALL_NOTES ;\ - Text [ en-US ] = "~Delete All Notes" ;\ + Text [ en-US ] = "~Delete All Comments" ;\ };\ /* MenuItem\ {\ Identifier = FN_HIDE_NOTE ;\ HelpID = FN_HIDE_NOTE ;\ - Text [ en-US ] = "~Hide note" ;\ + Text [ en-US ] = "~Hide comment" ;\ };\ MenuItem\ {\ @@ -472,7 +472,7 @@ {\ Identifier = FN_HIDE_ALL_NOTES ;\ HelpID = FN_HIDE_ALL_NOTES ;\ - Text [ en-US ] = "Hide all ~notes" ;\ + Text [ en-US ] = "Hide all ~comments" ;\ }; */ diff --git a/sw/source/ui/app/swmodule.cxx b/sw/source/ui/app/swmodule.cxx index ccc5a9fd7f..779add8526 100644 --- a/sw/source/ui/app/swmodule.cxx +++ b/sw/source/ui/app/swmodule.cxx @@ -221,11 +221,6 @@ SwModule::SwModule( SfxObjectFactory* pWebFact, ERRCODE_AREA_SW_END, pSwResMgr ); - SfxEventConfiguration::RegisterEvent(SW_EVENT_MAIL_MERGE, SW_RES(STR_PRINT_MERGE_MACRO), String::CreateFromAscii("OnMailMerge")); - SfxEventConfiguration::RegisterEvent(SW_EVENT_MAIL_MERGE_END, SW_RES(STR_PRINT_MERGE_MACRO), String::CreateFromAscii("OnMailMergeFinished")); - SfxEventConfiguration::RegisterEvent(SW_EVENT_FIELD_MERGE, String(), String::CreateFromAscii("OnFieldMerge")); - SfxEventConfiguration::RegisterEvent(SW_EVENT_FIELD_MERGE_FINISHED, String(), String::CreateFromAscii("OnFieldMergeFinished")); - SfxEventConfiguration::RegisterEvent(SW_EVENT_PAGE_COUNT, SW_RES(STR_PAGE_COUNT_MACRO), String::CreateFromAscii("OnPageCountChange")); pModuleConfig = new SwModuleOptions; //Die brauchen wie sowieso diff --git a/sw/source/ui/cctrl/actctrl.cxx b/sw/source/ui/cctrl/actctrl.cxx index 94e9b0ff0e..2122bc9b46 100644 --- a/sw/source/ui/cctrl/actctrl.cxx +++ b/sw/source/ui/cctrl/actctrl.cxx @@ -71,6 +71,15 @@ long NumEditAction::Notify( NotifyEvent& rNEvt ) Beschreibung: KeyInput fuer ShortName - Edits ohne Spaces ------------------------------------------------------------------------*/ +NoSpaceEdit::NoSpaceEdit( Window* pParent, const ResId& rResId) + : Edit(pParent, rResId), + sForbiddenChars(String::CreateFromAscii(" ")) +{ +} + +NoSpaceEdit::~NoSpaceEdit() +{ +} void NoSpaceEdit::KeyInput(const KeyEvent& rEvt) { diff --git a/sw/source/ui/config/fontcfg.cxx b/sw/source/ui/config/fontcfg.cxx index 8b2a6de735..533a3869e8 100644 --- a/sw/source/ui/config/fontcfg.cxx +++ b/sw/source/ui/config/fontcfg.cxx @@ -33,10 +33,12 @@ #include <fontcfg.hxx> +#include <i18npool/mslangid.hxx> #include <vcl/outdev.hxx> #include <svtools/lingucfg.hxx> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/i18n/ScriptType.hpp> #include <swtypes.hxx> #include <unomid.h> @@ -116,9 +118,10 @@ SwStdFontConfig::SwStdFontConfig() : SvtLinguConfig().GetOptions( aLinguOpt ); - sal_Int16 eWestern = aLinguOpt.nDefaultLanguage, - eCJK = aLinguOpt.nDefaultLanguage_CJK, - eCTL = aLinguOpt.nDefaultLanguage_CTL; + sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), + eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), + eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX); + for(sal_Int16 i = 0; i < DEF_FONT_COUNT; i++) { sDefaultFonts[i] = GetDefaultFor(i, @@ -163,9 +166,10 @@ void SwStdFontConfig::Commit() SvtLinguConfig().GetOptions( aLinguOpt ); - sal_Int16 eWestern = aLinguOpt.nDefaultLanguage, - eCJK = aLinguOpt.nDefaultLanguage_CJK, - eCTL = aLinguOpt.nDefaultLanguage_CTL; + sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), + eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), + eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX); + for(sal_uInt16 nProp = 0; nProp < sal::static_int_cast< sal_uInt16, sal_Int32 >( aNames.getLength() ); nProp++) @@ -198,9 +202,10 @@ BOOL SwStdFontConfig::IsFontDefault(USHORT nFontType) const SvtLinguConfig().GetOptions( aLinguOpt ); - sal_Int16 eWestern = aLinguOpt.nDefaultLanguage, - eCJK = aLinguOpt.nDefaultLanguage_CJK, - eCTL = aLinguOpt.nDefaultLanguage_CTL; + sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), + eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), + eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX); + String sDefFont(GetDefaultFor(FONT_STANDARD, eWestern)); String sDefFontCJK(GetDefaultFor(FONT_STANDARD_CJK, eCJK)); String sDefFontCTL(GetDefaultFor(FONT_STANDARD_CTL, eCTL)); @@ -320,9 +325,11 @@ void SwStdFontConfig::ChangeInt( USHORT nFontType, sal_Int32 nHeight ) { SvtLinguOptions aLinguOpt; SvtLinguConfig().GetOptions( aLinguOpt ); - sal_Int16 eWestern = aLinguOpt.nDefaultLanguage, - eCJK = aLinguOpt.nDefaultLanguage_CJK, - eCTL = aLinguOpt.nDefaultLanguage_CTL; + + sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), + eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), + eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX); + // #i92090# default height value sets back to -1 const sal_Int32 nDefaultHeight = GetDefaultHeightFor(nFontType, lcl_LanguageOfType(nFontType, eWestern, eCJK, eCTL)); const bool bIsDefaultHeight = nHeight == nDefaultHeight; diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 6fd2204237..1a4c97061c 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -173,7 +173,7 @@ TabPage TP_CONTENT_OPT { Pos = MAP_APPFONT ( 12 , 119 ) ; Size = MAP_APPFONT ( 108 , 10 ) ; - Text [ en-US ] = "~Notes" ; + Text [ en-US ] = "~Comments" ; }; FixedLine FL_SETTINGS { @@ -323,7 +323,7 @@ TabPage TP_OPTPRINT_PAGE { Pos = MAP_APPFONT ( 180 , 27 ) ; Size = MAP_APPFONT ( 74 , 10 ) ; - Text [ en-US ] = "Notes ~only" ; + Text [ en-US ] = "Comments ~only" ; }; RadioButton RB_END { @@ -347,7 +347,7 @@ TabPage TP_OPTPRINT_PAGE { Pos = MAP_APPFONT ( 174 , 3 ) ; Size = MAP_APPFONT ( 80 , 8 ) ; - Text [ en-US ] = "Notes" ; + Text [ en-US ] = "Comments" ; Group = TRUE ; }; FixedLine FL_4 diff --git a/sw/source/ui/config/usrpref.cxx b/sw/source/ui/config/usrpref.cxx index da2bbfd992..ad1285e3d0 100644 --- a/sw/source/ui/config/usrpref.cxx +++ b/sw/source/ui/config/usrpref.cxx @@ -33,7 +33,7 @@ #include <tools/stream.hxx> - +#include <svtools/syslocale.hxx> #include "swtypes.hxx" #include "hintids.hxx" @@ -72,7 +72,7 @@ SwMasterUsrPref::SwMasterUsrPref(BOOL bWeb) : aCursorConfig(*this), pWebColorConfig(bWeb ? new SwWebColorConfig(*this) : 0) { - MeasurementSystem eSystem = GetAppLocaleData().getMeasurementSystemEnum(); + MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum(); eUserMetric = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH; eHScrollMetric = eUserMetric; eVScrollMetric = eUserMetric; diff --git a/sw/source/ui/config/viewopt.cxx b/sw/source/ui/config/viewopt.cxx index ac437154e3..a24fa2fdb1 100644 --- a/sw/source/ui/config/viewopt.cxx +++ b/sw/source/ui/config/viewopt.cxx @@ -58,6 +58,7 @@ #include <crstate.hxx> #include <svtools/colorcfg.hxx> #include <svtools/accessibilityoptions.hxx> +#include <svtools/syslocale.hxx> #include <svx/acorrcfg.hxx> @@ -237,7 +238,7 @@ SwViewOption::SwViewOption() : nCore2Options = VIEWOPT_CORE2_BLACKFONT | VIEWOPT_CORE2_HIDDENPARA; nUIOptions = VIEWOPT_2_MODIFIED | VIEWOPT_2_GRFKEEPZOOM |VIEWOPT_2_ANY_RULER; - if(MEASURE_METRIC != GetAppLocaleData().getMeasurementSystemEnum()) + if(MEASURE_METRIC != SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()) aSnapSize.Width() = aSnapSize.Height() = 720; // 1/2" else aSnapSize.Width() = aSnapSize.Height() = 567; // 1 cm diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index efd27f3365..ff140629c2 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -1131,7 +1131,9 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, for( n = 0; n < nCols; ++n ) { if( aRbHeadlColnms.IsChecked() ) - rSh.SwEditShell::Insert( aColFlds[ n ]->sColumn ); + { + rSh.SwEditShell::Insert2( aColFlds[ n ]->sColumn ); + } rSh.GoNextCell(); } } @@ -1227,7 +1229,9 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, { rtl::OUString sVal = xColumn->getString(); if(!xColumn->wasNull()) - rSh.SwEditShell::Insert( sVal ); + { + rSh.SwEditShell::Insert2( sVal ); + } } } catch(Exception& diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 144ab217f6..ef1bc3375c 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -701,7 +701,7 @@ void SwNewDBMgr::ImportDBEntry(SwWrtShell* pSh) if (i < nLength - 1) sStr += '\t'; } - pSh->SwEditShell::Insert(sStr); + pSh->SwEditShell::Insert2(sStr); pSh->SwFEShell::SplitNode(); // Zeilenvorschub } } @@ -932,9 +932,9 @@ BOOL SwNewDBMgr::MergePrint( SwView& rView, do { nStartRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0; { - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, pSh->GetView().GetViewFrame()->GetObjectShell())); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), pSh->GetView().GetViewFrame()->GetObjectShell())); pSh->ViewShell::UpdateFlds(); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, pSh->GetView().GetViewFrame()->GetObjectShell())); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), pSh->GetView().GetViewFrame()->GetObjectShell())); ++rOpt.nMergeAct; // launch MailMergeEvent if required @@ -1080,7 +1080,7 @@ BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, USHORT nDocEnd = pConfigItem->GetPrintRangeEnd(); DBG_ASSERT(nDocStart < nDocEnd && nDocEnd <= pConfigItem->GetMergedDocumentCount(), "merge print settings are not correct"); - + for( sal_uInt32 nPrintDocument = nDocStart; nPrintDocument < nDocEnd; ++nPrintDocument) { SwDocMergeInfo& rDocInfo = pConfigItem->GetDocumentMergeInfo(nPrintDocument); @@ -1455,9 +1455,9 @@ BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell, SwDoc* pWorkDoc = ((SwDocShell*)(&xWorkDocSh))->GetDoc(); SwNewDBMgr* pOldDBMgr = pWorkDoc->GetNewDBMgr(); pWorkDoc->SetNewDBMgr( this ); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, xWorkDocSh)); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), xWorkDocSh)); pWorkDoc->UpdateFlds(NULL, false); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, xWorkDocSh)); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), xWorkDocSh)); // alle versteckten Felder/Bereiche entfernen pWorkDoc->RemoveInvisibleContent(); @@ -2764,19 +2764,19 @@ String SwNewDBMgr::LoadAndRegisterDataSource() if( bTextConnection ) { - uno::Reference < ui::dialogs::XExecutableDialog > xSettingsDlg( + uno::Reference < ui::dialogs::XExecutableDialog > xSettingsDlg( xMgr->createInstance( C2U( "com.sun.star.sdb.TextConnectionSettings" ) ), uno::UNO_QUERY); if( xSettingsDlg->execute() ) { uno::Any aSettings = xDataProperties->getPropertyValue( C2U( "Settings" ) ); uno::Reference < beans::XPropertySet > xDSSettings; aSettings >>= xDSSettings; - ::comphelper::copyProperties( - uno::Reference < beans::XPropertySet >( xSettingsDlg, uno::UNO_QUERY ), + ::comphelper::copyProperties( + uno::Reference < beans::XPropertySet >( xSettingsDlg, uno::UNO_QUERY ), xDSSettings ); xDSSettings->setPropertyValue( C2U("Extension"), uno::makeAny( ::rtl::OUString( sExt ))); } - } + } Reference<XDocumentDataSource> xDS(xNewInstance, UNO_QUERY_THROW); Reference<XStorable> xStore(xDS->getDatabaseDocument(), UNO_QUERY_THROW); @@ -2858,7 +2858,7 @@ void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh, aDescriptor[daCursor] <<= xResSet; SfxObjectShellRef xDocShell = rSh.GetView().GetViewFrame()->GetObjectShell(); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, xDocShell)); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), xDocShell)); { //copy rSh to aTempFile ::rtl::OUString sTempURL; @@ -2899,11 +2899,11 @@ void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh, SwDoc* pWorkDoc = pView->GetWrtShell().GetDoc(); SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr(); pWorkDoc->SetNewDBMgr( this ); - + SwMergeDescriptor aMergeDesc( pImpl->pMergeDialog->GetMergeType(), pView->GetWrtShell(), aDescriptor ); - aMergeDesc.sSaveToFilter = pImpl->pMergeDialog->GetSaveFilter(); + aMergeDesc.sSaveToFilter = pImpl->pMergeDialog->GetSaveFilter(); MergeNew(aMergeDesc); - + pWorkDoc->SetNewDBMgr( pWorkDBMgr ); //close the temporary file uno::Reference< util::XCloseable > xClose( xWorkDocSh->GetModel(), uno::UNO_QUERY ); @@ -2921,10 +2921,10 @@ void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh, } } } - //remove the temporary file + //remove the temporary file SWUnoHelper::UCB_DeleteFile( sTempURL ); } - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, rSh.GetView().GetViewFrame()->GetObjectShell())); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), rSh.GetView().GetViewFrame()->GetObjectShell())); // reset the cursor inside xResSet = NULL; @@ -3260,9 +3260,9 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig, // create a layout rWorkShell.CalcLayout(); rWorkShell.UnlockExpFlds(); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, rWorkShell.GetView().GetViewFrame()->GetObjectShell())); - rWorkShell.ViewShell::UpdateFlds(); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, rWorkShell.GetView().GetViewFrame()->GetObjectShell())); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), rWorkShell.GetView().GetViewFrame()->GetObjectShell())); + rWorkShell.ViewShell::UpdateFlds(); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), rWorkShell.GetView().GetViewFrame()->GetObjectShell())); // strip invisible content and convert fields to text rWorkShell.RemoveInvisibleContent(); diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx index dd9f07e279..eb1f75d579 100644 --- a/sw/source/ui/dbui/mmoutputpage.cxx +++ b/sw/source/ui/dbui/mmoutputpage.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -833,11 +833,11 @@ IMPL_LINK(SwMailMergeOutputPage, SaveOutputHdl_Impl, PushButton*, pButton) aSaveMonitor.aCancel.SetClickHdl(LINK(this, SwMailMergeOutputPage, SaveCancelHdl_Impl)); aSaveMonitor.aPrinter.SetText( INetURLObject( sPath ).getFSysPath( INetURLObject::FSYS_DETECT ) ); aSaveMonitor.ResizeControls(); - + m_bCancelSaving = false; aSaveMonitor.Show(); m_pWizard->enableButtons(WZB_CANCEL, sal_False); - + for(sal_uInt32 nDoc = nBegin; nDoc < nEnd && !m_bCancelSaving; ++nDoc) { SwDocMergeInfo& rInfo = rConfigItem.GetDocumentMergeInfo(nDoc); @@ -1000,14 +1000,14 @@ IMPL_LINK(SwMailMergeOutputPage, PrintHdl_Impl, PushButton*, EMPTYARG) } SfxObjectShell* pObjSh = pTargetView->GetViewFrame()->GetObjectShell(); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, pObjSh)); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), pObjSh)); rSh.GetNewDBMgr()->SetMergeType( DBMGR_MERGE_DOCUMENTS ); SfxDispatcher *pDis = pTargetView->GetViewFrame()->GetDispatcher(); SfxBoolItem aMergeSilent(SID_SILENT, sal_False); m_pWizard->enableButtons(WZB_CANCEL, sal_False); pDis->Execute(SID_PRINTDOCDIRECT, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aMergeSilent, 0L); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, pObjSh)); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), pObjSh)); pTargetView->SetMailMergeConfigItem(0, 0, sal_False); m_pWizard->enableButtons(WZB_CANCEL, sal_True); diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx index 66629b5030..34b04822c0 100644 --- a/sw/source/ui/dialog/ascfldlg.cxx +++ b/sw/source/ui/dialog/ascfldlg.cxx @@ -35,6 +35,8 @@ #endif #include <hintids.hxx> #include <rtl/textenc.h> +#include <i18npool/mslangid.hxx> +#include <com/sun/star/i18n/ScriptType.hpp> #include <svtools/lingucfg.hxx> #include <fontcfg.hxx> #include <swmodule.hxx> @@ -234,14 +236,14 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh, switch(nAppScriptType) { case SCRIPTTYPE_ASIAN: - aOpt.SetLanguage(aLinguOpt.nDefaultLanguage_CJK); + aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, SCRIPTTYPE_ASIAN)); break; case SCRIPTTYPE_COMPLEX: - aOpt.SetLanguage(aLinguOpt.nDefaultLanguage_CTL); + aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, SCRIPTTYPE_COMPLEX)); break; //SCRIPTTYPE_LATIN: default: - aOpt.SetLanguage(aLinguOpt.nDefaultLanguage); + aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, SCRIPTTYPE_LATIN)); } } } diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx index a446c5e08e..88e3df03a2 100644 --- a/sw/source/ui/dialog/uiregionsw.cxx +++ b/sw/source/ui/dialog/uiregionsw.cxx @@ -34,29 +34,22 @@ #undef SW_DLLIMPLEMENTATION #endif -#include "hintids.hxx" -#include "regionsw.hxx" +#include <hintids.hxx> +#include <regionsw.hxx> #include <svtools/urihelper.hxx> #include <svtools/PasswordHelper.hxx> #include <vcl/svapp.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svtools/stritem.hxx> #include <svtools/eitem.hxx> -#ifndef _PASSWD_HXX //autogen #include <sfx2/passwd.hxx> -#endif #include <sfx2/docfilt.hxx> #include <sfx2/request.hxx> #include <sfx2/docfile.hxx> #include <sfx2/linkmgr.hxx> #include <sfx2/docinsert.hxx> #include <sfx2/filedlghelper.hxx> -#ifndef _SVX_SIZEITEM_HXX //autogen - #include <svx/sizeitem.hxx> -#endif #include <svx/htmlcfg.hxx> #include <comphelper/storagehelper.hxx> @@ -65,15 +58,9 @@ #include <section.hxx> #include <docary.hxx> #include <doc.hxx> // fuers SwSectionFmt-Array -#ifndef _BASESH_HXX #include <basesh.hxx> -#endif -#ifndef _WDOCSH_HXX #include <wdocsh.hxx> -#endif -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <swmodule.hxx> #include <wrtsh.hxx> #include <swundo.hxx> // fuer Undo-Ids @@ -82,27 +69,15 @@ #include <swunodef.hxx> #include <shellio.hxx> -#ifndef _HELPID_H #include <helpid.h> -#endif -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _REGIONSW_HRC #include <regionsw.hrc> -#endif -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif #include <sfx2/bindings.hxx> #include <svx/htmlmode.hxx> #include <svx/dlgutil.hxx> -#ifndef _SVX_DIALOGS_HRC #include <svx/dialogs.hrc> -#endif #include <svx/svxdlg.hxx> #include <svx/flagsdef.hxx> @@ -115,7 +90,65 @@ SV_IMPL_PTRARR( SwSectionFmts, SwSectionFmtPtr ) SV_IMPL_OP_PTRARR_SORT( SectReprArr, SectReprPtr ) -static void lcl_ReadSections( SwWrtShell& rSh, SfxMedium& rMedium, ComboBox& rBox ); +static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox ); + +void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames, const SwSectionFmt* pNewFmt ) +{ + const SwSectionFmt* pFmt; + if( !pNewFmt ) + { + USHORT nCount = rSh.GetSectionFmtCount(); + for(USHORT i=0;i<nCount;i++) + { + SectionType eTmpType; + if( !(pFmt = &rSh.GetSectionFmt(i))->GetParent() && + pFmt->IsInNodesArr() && + (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION + && TOX_HEADER_SECTION != eTmpType ) + { + String* pString = new String(pFmt->GetSection()->GetName()); + if(pAvailNames) + pAvailNames->InsertEntry(*pString); + rSubRegions.InsertEntry(*pString); + lcl_FillList( rSh, rSubRegions, pAvailNames, pFmt ); + } + } + } + else + { + SwSections aTmpArr; + USHORT nCnt = pNewFmt->GetChildSections(aTmpArr,SORTSECT_POS); + if( nCnt ) + { + SectionType eTmpType; + for( USHORT n = 0; n < nCnt; ++n ) + if( (pFmt = aTmpArr[n]->GetFmt())->IsInNodesArr()&& + (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION + && TOX_HEADER_SECTION != eTmpType ) + { + String* pString = new String(pFmt->GetSection()->GetName()); + if(pAvailNames) + pAvailNames->InsertEntry(*pString); + rSubRegions.InsertEntry(*pString); + lcl_FillList( rSh, rSubRegions, pAvailNames, pFmt ); + } + } + } +} + +void lcl_FillSubRegionList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames ) +{ + lcl_FillList( rSh, rSubRegions, pAvailNames, 0 ); + IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess(); + for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin(); + ppMark != pMarkAccess->getMarksEnd(); + ppMark++) + { + const ::sw::mark::IMark* pBkmk = ppMark->get(); + if( pBkmk->IsExpanded() ) + rSubRegions.InsertEntry( pBkmk->GetName() ); + } +} /* -----------------25.06.99 15:38------------------- @@ -275,6 +308,7 @@ SwEditRegionDlg::SwEditRegionDlg( Window* pParent, SwWrtShell& rWrtSh ) aFilePB ( this, SW_RES( PB_FILE ) ), aSubRegionFT ( this, SW_RES( FT_SUBREG ) ) , aSubRegionED ( this, SW_RES( LB_SUBREG ) ) , + bSubRegionsFilled( false ), aProtectFL ( this, SW_RES( FL_PROTECT ) ), aProtectCB ( this, SW_RES( CB_PROTECT ) ), @@ -330,6 +364,8 @@ SwEditRegionDlg::SwEditRegionDlg( Window* pParent, SwWrtShell& rWrtSh ) aFilePB.SetClickHdl ( LINK( this, SwEditRegionDlg, FileSearchHdl )); aFileNameED.SetModifyHdl( LINK( this, SwEditRegionDlg, FileNameHdl )); aSubRegionED.SetModifyHdl( LINK( this, SwEditRegionDlg, FileNameHdl )); + aSubRegionED.AddEventListener( LINK( this, SwEditRegionDlg, SubRegionEventHdl )); + aSubRegionED.EnableAutocomplete( sal_True, sal_True ); aTree.SetHelpId(HID_REGION_TREE); aTree.SetSelectionMode( MULTIPLE_SELECTION ); @@ -667,6 +703,8 @@ IMPL_LINK( SwEditRegionDlg, GetFirstEntryHdl, SvTreeListBox *, pBox ) aDismiss.Enable(); String aFile = pRepr->GetFile(); String sSub = pRepr->GetSubRegion(); + bSubRegionsFilled = false; + aSubRegionED.Clear(); if(aFile.Len()||sSub.Len()) { aFileCB.Check(TRUE); @@ -1174,6 +1212,8 @@ IMPL_LINK( SwEditRegionDlg, FileNameHdl, Edit *, pEdit ) SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData(); if(pEdit == &aFileNameED) { + bSubRegionsFilled = false; + aSubRegionED.Clear(); if( aDDECB.IsChecked() ) { String sLink( pEdit->GetText() ); @@ -1371,7 +1411,7 @@ IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg ) const SfxPoolItem* pItem; if ( SFX_ITEM_SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, FALSE, &pItem ) ) sPassword = ( (SfxStringItem*)pItem )->GetValue(); - ::lcl_ReadSections( rSh, *pMedium, aSubRegionED ); + ::lcl_ReadSections( *pMedium, aSubRegionED ); delete pMedium; } } @@ -1390,6 +1430,36 @@ IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg ) Application::SetDefDialogParent( m_pOldDefDlgParent ); return 0; } +/*-- 03.09.2009 16:24:18--------------------------------------------------- + + -----------------------------------------------------------------------*/ +IMPL_LINK( SwEditRegionDlg, SubRegionEventHdl, VclWindowEvent *, pEvent ) +{ + if( !bSubRegionsFilled && pEvent && pEvent->GetId() == VCLEVENT_DROPDOWN_PRE_OPEN ) + { + //if necessary fill the names bookmarks/sections/tables now + + rtl::OUString sFileName = aFileNameED.GetText(); + if(sFileName.getLength()) + { + SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium(); + INetURLObject aAbs; + if( pMedium ) + aAbs = pMedium->GetURLObject(); + sFileName = URIHelper::SmartRel2Abs( + aAbs, sFileName, URIHelper::GetMaybeFileHdl() ); + + //load file and set the shell + SfxMedium aMedium( sFileName, STREAM_STD_READ ); + sFileName = aMedium.GetURLObject().GetMainURL( INetURLObject::NO_DECODE ); + ::lcl_ReadSections( aMedium, aSubRegionED ); + } + else + lcl_FillSubRegionList( rSh, aSubRegionED, 0 ); + bSubRegionsFilled = true; + } + return 0; +} /* -----------------------------08.05.2002 15:00------------------------------ @@ -1404,7 +1474,7 @@ Image SwEditRegionDlg::BuildBitmap(BOOL bProtect,BOOL bHidden, BOOL bHighContras Beschreibung: Hilfsfunktion - Bereichsnamen aus dem Medium lesen --------------------------------------------------------------------*/ -static void lcl_ReadSections( SwWrtShell& /*rSh*/, SfxMedium& rMedium, ComboBox& rBox ) +static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox ) { rBox.Clear(); uno::Reference < embed::XStorage > xStg; @@ -1580,6 +1650,7 @@ SwInsertSectionTabPage::SwInsertSectionTabPage( aCurName.SetModifyHdl ( LINK( this, SwInsertSectionTabPage, NameEditHdl)); aDDECB.SetClickHdl ( LINK( this, SwInsertSectionTabPage, DDEHdl )); ChangeProtectHdl(&aProtectCB); + aSubRegionED.EnableAutocomplete( sal_True, sal_True ); } /* -----------------21.05.99 10:31------------------- * @@ -1603,16 +1674,7 @@ void SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh) aDDECommandFT .Hide(); } - FillList(); - IDocumentMarkAccess* const pMarkAccess = m_pWrtSh->getIDocumentMarkAccess(); - for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin(); - ppMark != pMarkAccess->getMarksEnd(); - ppMark++) - { - const ::sw::mark::IMark* pBkmk = ppMark->get(); - if( pBkmk->IsExpanded() ) - aSubRegionED.InsertEntry( pBkmk->GetName() ); - } + lcl_FillSubRegionList( *m_pWrtSh, aSubRegionED, &aCurName ); SwSection* pSect = ((SwInsertSectionTabDialog*)GetTabDialog())->GetSection(); if( pSect ) // etwas vorgegeben ? @@ -1875,7 +1937,7 @@ IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFil m_sFilePasswd = ( (SfxStringItem*)pItem )->GetValue(); aFileNameED.SetText( INetURLObject::decode( m_sFileName, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS, RTL_TEXTENCODING_UTF8 ) ); - ::lcl_ReadSections( *m_pWrtSh, *pMedium, aSubRegionED ); + ::lcl_ReadSections( *pMedium, aSubRegionED ); delete pMedium; } } @@ -1886,52 +1948,6 @@ IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFil return 0; } -/*-------------------------------------------------------------------- - Beschreibung: Liste der verwendeten Namen fuellen - --------------------------------------------------------------------*/ - -void SwInsertSectionTabPage::FillList( const SwSectionFmt* pNewFmt ) -{ - const SwSectionFmt* pFmt; - if( !pNewFmt ) - { - USHORT nCount = m_pWrtSh->GetSectionFmtCount(); - for(USHORT i=0;i<nCount;i++) - { - SectionType eTmpType; - if( !(pFmt = &m_pWrtSh->GetSectionFmt(i))->GetParent() && - pFmt->IsInNodesArr() && - (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION - && TOX_HEADER_SECTION != eTmpType ) - { - String* pString = new String(pFmt->GetSection()->GetName()); - aCurName.InsertEntry(*pString); - aSubRegionED.InsertEntry(*pString); - FillList( pFmt ); - } - } - } - else - { - SwSections aTmpArr; - USHORT nCnt = pNewFmt->GetChildSections(aTmpArr,SORTSECT_POS); - if( nCnt ) - { - SectionType eTmpType; - for( USHORT n = 0; n < nCnt; ++n ) - if( (pFmt = aTmpArr[n]->GetFmt())->IsInNodesArr()&& - (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION - && TOX_HEADER_SECTION != eTmpType ) - { - String* pString = new String(pFmt->GetSection()->GetName()); - aCurName.InsertEntry(*pString); - aSubRegionED.InsertEntry(*pString); - FillList( pFmt ); - } - } - } -} - // -------------------------------------------------------------- // Numerierungsformat Umsetzung: diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx index 2ff17d0a04..e991938aad 100644 --- a/sw/source/ui/dochdl/swdtflvr.cxx +++ b/sw/source/ui/dochdl/swdtflvr.cxx @@ -3778,6 +3778,7 @@ BOOL SwTrnsfrDdeLink::WriteData( SvStream& rStrm ) // remove mark pServerObject->SetNoServer(); // this removes the connection between SwServerObject and mark + // N.B. ppMark was not loaded from file and cannot have xml:id pMarkAccess->deleteMark(ppMark); // recreate as Bookmark diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx index 1e5eb8788b..6aa8f80c4d 100644 --- a/sw/source/ui/docvw/PostItMgr.cxx +++ b/sw/source/ui/docvw/PostItMgr.cxx @@ -74,6 +74,7 @@ #include <svtools/langtab.hxx> #include <svtools/smplhint.hxx> +#include <svx/svdview.hxx> #include <svx/eeitem.hxx> #include <svx/langitem.hxx> #include <svx/outliner.hxx> @@ -153,6 +154,14 @@ SwPostItMgr::SwPostItMgr(SwView* pView) mbWaitingForCalcRects = true; mnEventId = Application::PostUserEvent( LINK( this, SwPostItMgr, CalcHdl), 0 ); } + + //#i# + if (HasNotes() && !mpWrtShell->GetViewOptions()->IsPostIts()) + { + SfxRequest aRequest(mpView->GetViewFrame(),FN_VIEW_NOTES); + mpView->ExecViewOptions(aRequest); + } + } SwPostItMgr::~SwPostItMgr() @@ -307,8 +316,9 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) /* else if ( rHint.IsA(TYPE(SwRedlineHint) ) ) { - SwRedline* pRedline = const_cast<SwRedline*>(((SwRedlineHint&)rHint).GetRedline()); - switch ( ((SwRedlineHint&)rHint).Which() ) + const SwRedlineHint rRedlineHint = static_cast<const SwRedlineHint&>(rHint); + SwRedline* pRedline = const_cast<SwRedline*>(rRedlineHint.GetRedline()); + switch ( rRedlineHint.Which() ) { case SWREDLINE_INSERTED : { @@ -324,8 +334,9 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) break; } case SWREDLINE_FOCUS: - { - Focus(rBC); + { + if (rRedlineHint.GetView()== mpView) + Focus(rBC); break; } } @@ -333,8 +344,9 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) */ else if ( rHint.IsA(TYPE(SwFmtFldHint) ) ) { - SwFmtFld* pFld = const_cast <SwFmtFld*>( ((SwFmtFldHint&)rHint).GetField() ); - switch ( ((SwFmtFldHint&)rHint).Which() ) + const SwFmtFldHint& rFmtHint = static_cast<const SwFmtFldHint&>(rHint); + SwFmtFld* pFld = const_cast <SwFmtFld*>( rFmtHint.GetField() ); + switch ( rFmtHint.Which() ) { case SWFMTFLD_INSERTED : { @@ -351,9 +363,10 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) if (bEmpty && !mvPostItFlds.empty()) PrepareView(true); } - else { + else + { DBG_ERROR( "Inserted field not in document!" ); - } + } break; } case SWFMTFLD_REMOVED: @@ -370,19 +383,23 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) break; } case SWFMTFLD_FOCUS: - { - Focus(rBC); + { + if (rFmtHint.GetView()== mpView) + Focus(rBC); break; } case SWFMTFLD_CHANGED: { - SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC); + SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC); for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( pFmtFld == (*i)->GetBroadCaster() ) + if ( pFmtFld == (*i)->GetBroadCaster() ) { if ((*i)->pPostIt) + { (*i)->pPostIt->SetPostItText(); + mbLayout = true; + } break; } } @@ -390,10 +407,10 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) } case SWFMTFLD_LANGUAGE: { - SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC); + SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC); for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( pFmtFld == (*i)->GetBroadCaster() ) + if ( pFmtFld == (*i)->GetBroadCaster() ) { if ((*i)->pPostIt) { @@ -1914,3 +1931,27 @@ sal_uInt16 SwPostItMgr::SearchReplace(const SwFmtFld &pFld, const ::com::sun::st } return aResult; } + +void SwPostItMgr::AssureStdModeAtShell() +{ + //#i103373# #i103645# + // deselect any drawing or frame and leave editing mode + SdrView* pSdrView = mpWrtShell->GetDrawView(); + if ( pSdrView && pSdrView->IsTextEdit() ) + { + sal_Bool bLockView = mpWrtShell->IsViewLocked(); + mpWrtShell->LockView( sal_True ); + mpWrtShell->EndTextEdit(); + mpWrtShell->LockView( bLockView ); + } + + if( mpWrtShell->IsSelFrmMode() || mpWrtShell->IsObjSelected()) + { + mpWrtShell->UnSelectFrm(); + mpWrtShell->LeaveSelFrmMode(); + mpWrtShell->EnterStdMode(); + + mpWrtShell->DrawSelChanged(); + mpView->StopShellTimer(); + } +} diff --git a/sw/source/ui/docvw/docvw.src b/sw/source/ui/docvw/docvw.src index 602749b602..74da4994c7 100644 --- a/sw/source/ui/docvw/docvw.src +++ b/sw/source/ui/docvw/docvw.src @@ -315,12 +315,12 @@ String STR_POSTIT_YESTERDAY String STR_DELETE_ALL_NOTES { - Text [ en-US ] = "All Notes" ; + Text [ en-US ] = "All Comments" ; }; String STR_DELETE_AUTHOR_NOTES { - Text [ en-US ] = "Notes by " ; + Text [ en-US ] = "Comments by " ; }; String STR_NODATE diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 6ed958a9eb..949093c661 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -5568,11 +5568,12 @@ void QuickHelpData::Stop( SwWrtShell& rSh ) void QuickHelpData::FillStrArr( SwWrtShell& rSh, const String& rWord ) { - pCalendarWrapper->LoadDefaultCalendar( rSh.GetCurLang() ); + salhelper::SingletonRef<SwCalendarWrapper>* pCalendar = s_getCalendarWrapper(); + (*pCalendar)->LoadDefaultCalendar( rSh.GetCurLang() ); { uno::Sequence< i18n::CalendarItem > aNames( - pCalendarWrapper->getMonths() ); + (*pCalendar)->getMonths() ); for( int n = 0; n < 2; ++n ) { for( long nPos = 0, nEnd = aNames.getLength(); nPos < nEnd; ++nPos ) @@ -5592,7 +5593,7 @@ void QuickHelpData::FillStrArr( SwWrtShell& rSh, const String& rWord ) } } if( !n ) // get data for the second loop - aNames = pCalendarWrapper->getDays(); + aNames = (*pCalendar)->getDays(); } } diff --git a/sw/source/ui/docvw/postit.cxx b/sw/source/ui/docvw/postit.cxx index 5bb42c27ab..157a6e1997 100644 --- a/sw/source/ui/docvw/postit.cxx +++ b/sw/source/ui/docvw/postit.cxx @@ -91,6 +91,7 @@ #include <vcl/svapp.hxx> #include <vcl/gradient.hxx> #include <vcl/salbtype.hxx> // FRound +#include <vcl/msgbox.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/tuple/b2dtuple.hxx> @@ -269,6 +270,8 @@ void PostItTxt::KeyInput( const KeyEvent& rKeyEvt ) bool bIsProtected = mpMarginWin->IsProtected(); if (!bIsProtected || (bIsProtected && !mpMarginWin->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt)) ) bDone = mpOutlinerView->PostKeyEvent( rKeyEvt ); + else + InfoBox( this, SW_RES( MSG_READONLY_CONTENT )).Execute(); } if (bDone) mpMarginWin->ResizeIfNeccessary(aOldHeight,mpMarginWin->GetPostItTextHeight()); @@ -436,33 +439,6 @@ void PostItTxt::Command( const CommandEvent& rCEvt ) mpMarginWin->DocView()->HandleWheelCommands(rCEvt); } } - else if (rCEvt.GetCommand() == COMMAND_SELECTIONCHANGE) - { - if ( mpOutlinerView ) - { - const CommandSelectionChangeData *pData = rCEvt.GetSelectionChangeData(); - ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); - aSelection.nStartPos = sal::static_int_cast<sal_uInt16, ULONG>(pData->GetStart()); - aSelection.nEndPos = sal::static_int_cast<sal_uInt16, ULONG>(pData->GetEnd()); - mpOutlinerView->GetEditView().SetSelection(aSelection); - } - } - else if (rCEvt.GetCommand() == COMMAND_PREPARERECONVERSION) - { - if ( mpOutlinerView && mpOutlinerView->HasSelection() ) - { - EditEngine *aEditEngine = mpOutlinerView->GetEditView().GetEditEngine(); - ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); - aSelection.Adjust(); - if( aSelection.nStartPara != aSelection.nEndPara ) - { - xub_StrLen aParaLen = aEditEngine->GetTextLen( aSelection.nStartPara ); - aSelection.nEndPara = aSelection.nStartPara; - aSelection.nEndPos = aParaLen; - mpOutlinerView->GetEditView().SetSelection( aSelection ); - } - } - } else { if ( mpOutlinerView ) @@ -477,40 +453,6 @@ void PostItTxt::DataChanged( const DataChangedEvent& aData) Window::DataChanged( aData ); } -XubString PostItTxt::GetSurroundingText() const -{ - if( mpOutlinerView ) - { - EditEngine *aEditEngine = mpOutlinerView->GetEditView().GetEditEngine(); - if( mpOutlinerView->HasSelection() ) - return mpOutlinerView->GetSelected(); - else - { - ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); - XubString aStr = aEditEngine->GetText(aSelection.nStartPara); - return aStr; - } - } - else - return XubString::EmptyString(); -} - -Selection PostItTxt::GetSurroundingTextSelection() const -{ - if( mpOutlinerView ) - { - if( mpOutlinerView->HasSelection() ) - return Selection( 0, mpOutlinerView->GetSelected().Len() ); - else - { - ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); - return Selection( aSelection.nStartPos, aSelection.nEndPos ); - } - } - else - return Selection( 0, 0 ); -} - IMPL_LINK( PostItTxt, WindowEventListener, VclSimpleEvent*, pWinEvent ) { if ( pWinEvent && pWinEvent->ISA( VclWindowEvent ) ) @@ -549,6 +491,22 @@ IMPL_LINK( PostItTxt, WindowEventListener, VclSimpleEvent*, pWinEvent ) return sal_True; } +XubString PostItTxt::GetSurroundingText() const +{ + if( mpOutlinerView ) + return mpOutlinerView->GetSurroundingText(); + else + return XubString::EmptyString(); +} + +Selection PostItTxt::GetSurroundingTextSelection() const +{ + if( mpOutlinerView ) + return mpOutlinerView->GetSurroundingTextSelection(); + else + return Selection( 0, 0 ); +} + /************** SwMarginWin***********************************++*/ SwMarginWin::SwMarginWin(Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits) : Window(pParent, nBits), @@ -735,6 +693,15 @@ void SwMarginWin::ShowAnkorOnly(const Point &aPoint) mpShadow->setVisible(false); } +SfxItemSet SwMarginWin::DefaultItem() +{ + SfxItemSet aItem( mpView->GetDocShell()->GetPool() ); + aItem.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); + aItem.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), + EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); + return aItem; +} + void SwMarginWin::InitControls() { // actual window which holds the user text @@ -779,11 +746,7 @@ void SwMarginWin::InitControls() mpPostItTxt->SetTextView(mpOutlinerView); mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,1,1) ) ); - SfxItemSet item(aShell->GetPool()); - item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); - item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), - EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); - mpOutlinerView->SetAttribs(item); + mpOutlinerView->SetAttribs(DefaultItem()); // TODO: ?? EEHorizontalTextDirection aDefHoriTextDir = Application::GetSettings().GetLayoutRTL() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R; @@ -965,7 +928,7 @@ void SwMarginWin::SetPosAndSize() { mpAnkor->SetAnkorState(AS_ALL); SwMarginWin* pWin = GetTopReplyNote(); - if (IsFollow() && pWin ) + if (pWin) pWin->Ankor()->SetAnkorState(AS_END); } } @@ -973,9 +936,9 @@ void SwMarginWin::SetPosAndSize() void SwMarginWin::DoResize() { - long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height(); - unsigned long aWidth = GetSizePixel().Width(); - long aHeight = GetSizePixel().Height(); + long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height(); + long aHeight = GetSizePixel().Height(); + unsigned long aWidth = GetSizePixel().Width(); if (mbMeta) { @@ -998,8 +961,7 @@ void SwMarginWin::DoResize() { mpVScrollbar->Hide(); } - - mpPostItTxt->SetPosSizePixel(0, 0, aWidth, aHeight); + mpMeta->SetPosSizePixel(0,aHeight,GetSizePixel().Width()-GetMetaButtonAreaWidth(),GetMetaHeight()); mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ; mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) ); @@ -1007,11 +969,21 @@ void SwMarginWin::DoResize() { // if we do not have a scrollbar anymore, we want to see the complete text mpOutlinerView->SetVisArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) ); } - mpVScrollbar->SetPosSizePixel( aWidth, 0, GetScrollbarWidth(), aHeight ); + + if (!Application::GetSettings().GetLayoutRTL()) + { + mpPostItTxt->SetPosSizePixel(0, 0, aWidth, aHeight); + mpVScrollbar->SetPosSizePixel( aWidth, 0, GetScrollbarWidth(), aHeight); + } + else + { + mpPostItTxt->SetPosSizePixel((aTextHeight > aHeight) && !IsPreview() ? GetScrollbarWidth() : 0 , 0, aWidth, aHeight); + mpVScrollbar->SetPosSizePixel( 0, 0, GetScrollbarWidth(), aHeight); + } + mpVScrollbar->SetVisibleSize( PixelToLogic(Size(0,aHeight)).Height() ); mpVScrollbar->SetPageSize( PixelToLogic(Size(0,aHeight)).Height() * 8 / 10 ); mpVScrollbar->SetLineSize( mpOutliner->GetTextHeight() / 10 ); - //mpVScrollbar->SetThumbPos( mpOutlinerView->GetVisArea().Top()+ mpOutlinerView->GetEditView().GetCursor()->GetOffsetY()); SetScrollbar(); mpVScrollbar->SetRange( Range(0, mpOutliner->GetTextHeight())); @@ -1025,10 +997,6 @@ void SwMarginWin::DoResize() Point aRight = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH-1)*fx.GetNumerator()/fx.GetDenominator(), aBase.Y()+17*fy.GetNumerator()/fy.GetDenominator() ) ); Point aBottom = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH+2)*fx.GetNumerator()/fx.GetDenominator(), aBase.Y()+20*fy.GetNumerator()/fy.GetDenominator() ) ); - //Point aLeft = PixelToLogic(Point(mpMeta->GetPosPixel().X()+mpMeta->GetPosPixel().X()+GetSizePixel().Width()-(GetMetaButtonWidth()+10)+5,mpMeta->GetPosPixel().Y()+17)); - //Point aRight = PixelToLogic(Point(mpMeta->GetPosPixel().X()+mpMeta->GetPosPixel().X()+GetSizePixel().Width()-(GetMetaButtonWidth()+10)+11,mpMeta->GetPosPixel().Y()+17)); - //Point aBottom = PixelToLogic(Point(mpMeta->GetPosPixel().X()+mpMeta->GetPosPixel().X()+GetSizePixel().Width()-(GetMetaButtonWidth()+10)+8,mpMeta->GetPosPixel().Y()+20)); - aPopupTriangle.clear(); aPopupTriangle.append(basegfx::B2DPoint(aLeft.X(),aLeft.Y())); aPopupTriangle.append(basegfx::B2DPoint(aRight.X(),aRight.Y())); @@ -1220,6 +1188,8 @@ void SwMarginWin::HideNote() void SwMarginWin::ActivatePostIt() { + mpMgr->AssureStdModeAtShell(); + mpOutliner->ClearModifyFlag(); mpOutliner->GetUndoManager().Clear(); @@ -1280,11 +1250,13 @@ void SwMarginWin::ToggleInsMode() void SwMarginWin::ExecuteCommand(USHORT nSlot) { + mpMgr->AssureStdModeAtShell(); + switch (nSlot) { case FN_POSTIT: case FN_REPLY: - { + { // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note // will be created SwView* pView = DocView(); @@ -1444,9 +1416,7 @@ void SwMarginWin::ResetAttributes() { mpOutlinerView->RemoveAttribsKeepLanguages(TRUE); mpOutliner->RemoveFields(TRUE); - SfxItemSet aSet( mpView->GetDocShell()->GetPool() ); - aSet.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); - mpOutlinerView->SetAttribs(aSet); + mpOutlinerView->SetAttribs(DefaultItem()); } sal_Int32 SwMarginWin::GetScrollbarWidth() @@ -1504,7 +1474,7 @@ void SwMarginWin::SetViewState(ShadowState bState) { mpAnkor->SetAnkorState(AS_ALL); SwMarginWin* pWin = GetTopReplyNote(); - if (IsFollow() && pWin) + if (pWin) pWin->Ankor()->SetAnkorState(AS_END); mpAnkor->setLineSolid(true); } @@ -1567,7 +1537,7 @@ bool SwMarginWin::IsAnyStackParentVisible() SwMarginWin* SwMarginWin::GetTopReplyNote() { SwMarginWin* pTopNote = 0; - SwMarginWin* pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, this); + SwMarginWin* pMarginWin = IsFollow() ? mpMgr->GetNextPostIt(KEY_PAGEUP, this) : 0; while (pMarginWin) { pTopNote = pMarginWin; @@ -1627,11 +1597,7 @@ void SwPostIt::SetPostItText() else { Engine()->Clear(); - SfxItemSet item( DocView()->GetDocShell()->GetPool() ); - item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); - item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), - EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); - View()->SetAttribs(item); + View()->SetAttribs(DefaultItem()); View()->InsertText(mpFld->GetPar2(),false); } @@ -1654,8 +1620,10 @@ void SwPostIt::UpdateData() mpFld->SetTextObject(Engine()->CreateParaObject()); DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true)); delete pOldField; - // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one) + // so we get a new layout of notes (anchor position is still the same and we would otherwise not get one) Mgr()->SetLayout(); + // #i98686# if we have several views, all notes should update their text + mpFmtFld->Broadcast(SwFmtFldHint( 0, SWFMTFLD_CHANGED)); DocView()->GetDocShell()->SetModified(); } Engine()->ClearModifyFlag(); @@ -1699,7 +1667,8 @@ bool SwPostIt::CalcFollow() SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld(); SwPosition aPosition( pTxtFld->GetTxtNode() ); aPosition.nContent = *pTxtFld->GetStart(); - SwTxtAttr* pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttr( aPosition.nContent.GetIndex()-1,RES_TXTATR_FIELD ); + SwTxtAttr * const pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt( + aPosition.nContent.GetIndex() - 1, RES_TXTATR_FIELD ); const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0; return pFld && (pFld->Which()== RES_POSTITFLD); } @@ -1711,13 +1680,15 @@ sal_uInt32 SwPostIt::CountFollowing() SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld(); SwPosition aPosition( pTxtFld->GetTxtNode() ); aPosition.nContent = *pTxtFld->GetStart(); - - SwTxtAttr* pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttr( aPosition.nContent.GetIndex()+1,RES_TXTATR_FIELD ); + + SwTxtAttr * pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt( + aPosition.nContent.GetIndex() + 1, RES_TXTATR_FIELD ); SwField* pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0; while (pFld && (pFld->Which()== RES_POSTITFLD)) { - aCount++; - pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttr( aPosition.nContent.GetIndex() + aCount,RES_TXTATR_FIELD ); + aCount++; + pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt( + aPosition.nContent.GetIndex() + aCount, RES_TXTATR_FIELD ); pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0; } return aCount - 1; @@ -1818,11 +1789,7 @@ void SwPostIt::InitAnswer(OutlinerParaObject* pText) //remove all attributes and reset our standard ones View()->GetEditView().RemoveAttribsKeepLanguages(true); - SfxItemSet aNormalSet( DocView()->GetDocShell()->GetPool() ); - aNormalSet.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); - aNormalSet.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), - EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); - View()->SetAttribs(aNormalSet); + View()->SetAttribs(DefaultItem()); // lets insert an undo step so the initial text can be easily deleted // but do not use UpdateData() directly, would set modified state again and reentrance into Mgr Engine()->SetModifyHdl( Link() ); @@ -1895,11 +1862,7 @@ void SwRedComment::SetPostItText() Engine()->EnableUndo( FALSE ); Engine()->Clear(); - SfxItemSet item( DocView()->GetDocShell()->GetPool() ); - item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); - item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), - EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); - View()->SetAttribs(item); + View()->SetAttribs(DefaultItem()); View()->InsertText(pRedline->GetComment(),false); Engine()->ClearModifyFlag(); diff --git a/sw/source/ui/docvw/srcedtw.cxx b/sw/source/ui/docvw/srcedtw.cxx index 759fac9391..ac6786427e 100644 --- a/sw/source/ui/docvw/srcedtw.cxx +++ b/sw/source/ui/docvw/srcedtw.cxx @@ -395,8 +395,10 @@ void TextViewOutWin::MouseButtonUp( const MouseEvent &rEvt ) if ( pTextView ) { pTextView->MouseButtonUp( rEvt ); - ((SwSrcEditWindow*)GetParent())->GetSrcView()->GetViewFrame()-> - GetBindings().Invalidate( SID_TABLE_CELL ); + SfxBindings& rBindings = ((SwSrcEditWindow*)GetParent())->GetSrcView()->GetViewFrame()->GetBindings(); + rBindings.Invalidate( SID_TABLE_CELL ); + rBindings.Invalidate( SID_CUT ); + rBindings.Invalidate( SID_COPY ); } } @@ -459,6 +461,7 @@ void TextViewOutWin::KeyInput( const KeyEvent& rKEvt ) if(bChange) bDone = pTextView->KeyInput( rKEvt ); + SfxBindings& rBindings = ((SwSrcEditWindow*)GetParent())->GetSrcView()->GetViewFrame()->GetBindings(); if ( !bDone ) { if ( !SfxViewShell::Current()->KeyInput( rKEvt ) ) @@ -466,7 +469,6 @@ void TextViewOutWin::KeyInput( const KeyEvent& rKEvt ) } else { - SfxBindings& rBindings = ((SwSrcEditWindow*)GetParent())->GetSrcView()->GetViewFrame()->GetBindings(); rBindings.Invalidate( SID_TABLE_CELL ); if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_CURSOR ) rBindings.Update( SID_BASICIDE_STAT_POS ); @@ -478,6 +480,10 @@ void TextViewOutWin::KeyInput( const KeyEvent& rKEvt ) if( rKEvt.GetKeyCode().GetCode() == KEY_INSERT ) rBindings.Invalidate( SID_ATTR_INSERT ); } + + rBindings.Invalidate( SID_CUT ); + rBindings.Invalidate( SID_COPY ); + SwDocShell* pDocShell = pSrcEditWin->GetSrcView()->GetDocShell(); if(pSrcEditWin->GetTextEngine()->IsModified()) { diff --git a/sw/source/ui/fldui/fldmgr.cxx b/sw/source/ui/fldui/fldmgr.cxx index 289b4ab7bb..67c921f011 100644 --- a/sw/source/ui/fldui/fldmgr.cxx +++ b/sw/source/ui/fldui/fldmgr.cxx @@ -1615,7 +1615,7 @@ USHORT SwFldMgr::GetCurrLanguage() const SwWrtShell* pSh = pWrtShell ? pWrtShell : ::lcl_GetShell(); if( pSh ) return pSh->GetCurLang(); - return SvxLocaleToLanguage( GetAppLocaleData().getLocale() ); + return SvxLocaleToLanguage( SvtSysLocale().GetLocaleData().getLocale() ); } void SwFieldType::_GetFldName() diff --git a/sw/source/ui/fldui/fldtdlg.cxx b/sw/source/ui/fldui/fldtdlg.cxx index 63570d7538..3e2d031c0a 100644 --- a/sw/source/ui/fldui/fldtdlg.cxx +++ b/sw/source/ui/fldui/fldtdlg.cxx @@ -136,7 +136,7 @@ SwFldDlg::SwFldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, Window *pParent) ::comphelper::getProcessServiceFactory(), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "/org.openoffice.Office.DataAccess/ApplicationIntegration/InstalledFeatures/Writer" ) ), + "/org.openoffice.Office.DataAccess/Policies/Features/Writer" ) ), -1, utl::OConfigurationTreeRoot::CM_READONLY); diff --git a/sw/source/ui/inc/actctrl.hxx b/sw/source/ui/inc/actctrl.hxx index 296cd947f4..70ddedadcc 100644 --- a/sw/source/ui/inc/actctrl.hxx +++ b/sw/source/ui/inc/actctrl.hxx @@ -66,10 +66,8 @@ protected: virtual void Modify(); public: - NoSpaceEdit( Window* pParent, const ResId& rResId) - : Edit(pParent, rResId), - sForbiddenChars(String::CreateFromAscii(" ")) - {} + NoSpaceEdit( Window* pParent, const ResId& rResId); + virtual ~NoSpaceEdit(); void SetForbiddenChars(const String& rSet){sForbiddenChars = rSet;} const String& GetForbiddenChars(){return sForbiddenChars;} }; diff --git a/sw/source/ui/inc/regionsw.hxx b/sw/source/ui/inc/regionsw.hxx index 0d9e77616b..a7347c0aa7 100644 --- a/sw/source/ui/inc/regionsw.hxx +++ b/sw/source/ui/inc/regionsw.hxx @@ -33,35 +33,23 @@ #include <hintids.hxx> #include <vcl/field.hxx> #include <vcl/lstbox.hxx> -#ifndef _EDIT_HXX //autogen #include <vcl/edit.hxx> -#endif -#ifndef _BUTTON_HXX //autogen #include <vcl/button.hxx> -#endif -#ifndef _FIXED_HXX //autogen #include <vcl/fixed.hxx> -#endif -#ifndef _COMBOBOX_HXX //autogen #include <vcl/combobox.hxx> -#endif -#ifndef _GROUP_HXX //autogen #include <vcl/group.hxx> -#endif #include <svtools/svtreebx.hxx> #include <sfx2/basedlgs.hxx> #include <sfx2/tabdlg.hxx> #include <svx/brshitem.hxx> -#ifndef _CONDEDIT_HXX #include <condedit.hxx> -#endif #include <section.hxx> #include <fmtclds.hxx> #include <fmtftntx.hxx> #include <fmtclbl.hxx> #include <numberingtypelistbox.hxx> -#include "svx/frmdiritem.hxx" +#include <svx/frmdiritem.hxx> #include <vcl/image.hxx> #include <svx/paraprev.hxx> #include <svx/lrspitem.hxx> @@ -179,6 +167,7 @@ class SwEditRegionDlg : public SfxModalDialog PushButton aFilePB; FixedText aSubRegionFT; ComboBox aSubRegionED; + bool bSubRegionsFilled; FixedLine aProtectFL; TriStateBox aProtectCB; @@ -239,6 +228,7 @@ class SwEditRegionDlg : public SfxModalDialog DECL_LINK( FileNameHdl, Edit* ); DECL_LINK( DDEHdl, CheckBox* ); DECL_LINK( DlgClosedHdl, sfx2::FileDialogHelper* ); + DECL_LINK( SubRegionEventHdl, VclWindowEvent * ); BOOL CheckPasswd(CheckBox* pBox = 0); @@ -308,8 +298,6 @@ class SwInsertSectionTabPage : public SfxTabPage DECL_LINK( DDEHdl, CheckBox* ); DECL_LINK( DlgClosedHdl, sfx2::FileDialogHelper* ); - void FillList( const SwSectionFmt* pFmt = 0 ); - public: SwInsertSectionTabPage(Window *pParent, const SfxItemSet &rAttrSet); virtual ~SwInsertSectionTabPage(); diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx index f9d49cd931..b3929abdcc 100644 --- a/sw/source/ui/inc/wrtsh.hxx +++ b/sw/source/ui/inc/wrtsh.hxx @@ -165,6 +165,8 @@ public: // Selektion von Rahmen aufheben void UnSelectFrm(); + void Invalidate(); + // Tabellenzellen selektieren fuer Bearbeiten von Formeln in der Ribbonbar inline void SelTblCells( const Link &rLink, BOOL bMark = TRUE ); inline void EndSelTblCells(); diff --git a/sw/source/ui/lingu/olmenu.cxx b/sw/source/ui/lingu/olmenu.cxx index 8af28e1241..52540f21dd 100644 --- a/sw/source/ui/lingu/olmenu.cxx +++ b/sw/source/ui/lingu/olmenu.cxx @@ -62,6 +62,7 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/frame/XModuleManager.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/i18n/ScriptType.hpp> #include <svx/dlgutil.hxx> #include <svtools/itemset.hxx> #include <svx/langitem.hxx> @@ -168,7 +169,7 @@ LanguageType lcl_CheckLanguage( SvtLinguOptions aLinguOpt; SvtLinguConfig().GetOptions( aLinguOpt ); // The default document language from "Tools/Options - Language Settings - Languages: Western" - aLangList[0] = aLinguOpt.nDefaultLanguage; + aLangList[0] = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN); // The one from "Tools/Options - Language Settings - Languages: User interface" aLangList[1] = rSettings.GetUILanguage(); // The one from "Tools/Options - Language Settings - Languages: Locale setting" diff --git a/sw/source/ui/misc/pgfnote.cxx b/sw/source/ui/misc/pgfnote.cxx index 5135dcaa5f..d684116f4e 100644 --- a/sw/source/ui/misc/pgfnote.cxx +++ b/sw/source/ui/misc/pgfnote.cxx @@ -48,6 +48,7 @@ #include <vcl/field.hxx> #include <vcl/svapp.hxx> #include <unotools/localedatawrapper.hxx> +#include <svtools/syslocale.hxx> #include <svx/sizeitem.hxx> #include <svx/pageitem.hxx> #include <svtools/eitem.hxx> @@ -183,7 +184,7 @@ SwFootNotePage::SwFootNotePage(Window *pParent, const SfxItemSet &rSet) : SetMetric( aMaxHeightEdit, aMetric ); SetMetric( aDistEdit, aMetric ); SetMetric( aLineDistEdit, aMetric ); - MeasurementSystem eSys = GetAppLocaleData().getMeasurementSystemEnum(); + MeasurementSystem eSys = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum(); long nHeightValue = MEASURE_METRIC != eSys ? 1440 : 1134; aMaxHeightEdit.SetValue(aMaxHeightEdit.Normalize(nHeightValue),FUNIT_TWIP);; } diff --git a/sw/source/ui/misc/redlndlg.src b/sw/source/ui/misc/redlndlg.src index 1ca0e0b99e..05066494ca 100644 --- a/sw/source/ui/misc/redlndlg.src +++ b/sw/source/ui/misc/redlndlg.src @@ -64,7 +64,7 @@ ModalDialog DLG_MOD_REDLINE_ACCEPT { HelpID = HID_REDLINE_AUTOFMT_ACCEPT ; REDLNDLG - Text [ en-US ] = "Accept or Reject AutoFormat Changes"; + Text [ en-US ] = "Accept or Reject AutoCorrect Changes"; }; Menu MN_REDLINE_POPUP diff --git a/sw/source/ui/ribbar/inputwin.cxx b/sw/source/ui/ribbar/inputwin.cxx index d4d5d20963..cd98771445 100644 --- a/sw/source/ui/ribbar/inputwin.cxx +++ b/sw/source/ui/ribbar/inputwin.cxx @@ -461,8 +461,8 @@ IMPL_LINK( SwInputWindow, SelTblCellsNotify, SwWrtShell *, pCaller ) aPam.Move( fnMoveForward, fnGoSection ); IDocumentContentOperations* pIDCO = pWrtShell->getIDocumentContentOperations(); - pIDCO->Delete( aPam ); - pIDCO->Insert( aPam, sNew, true ); + pIDCO->DeleteRange( aPam ); + pIDCO->InsertString( aPam, sNew ); pWrtShell->EndAllAction(); sOldFml = sNew; } @@ -499,7 +499,7 @@ IMPL_LINK( SwInputWindow, ModifyHdl, InputEdit*, EMPTYARG ) sNew += CH_LRE; sNew += aEdit.GetText(); sNew += CH_PDF; - pWrtShell->SwEditShell::Insert( sNew ); + pWrtShell->SwEditShell::Insert2( sNew ); pWrtShell->EndAllAction(); sOldFml = sNew; } diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx index adf7f14ddb..68b8e87c3b 100755 --- a/sw/source/ui/shells/annotsh.cxx +++ b/sw/source/ui/shells/annotsh.cxx @@ -347,7 +347,7 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break; case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break; } - pOLV->InsertText( String(cIns), TRUE ); + pOLV->InsertText( String(cIns)); rReq.Done(); break; } @@ -799,16 +799,18 @@ void SwAnnotationShell::ExecClpbrd(SfxRequest &rReq) switch (nSlot) { case SID_CUT: - pOLV->Cut(); + if ( (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED) && pOLV->HasSelection() ) + pOLV->Cut(); break; case SID_COPY: - pOLV->Copy(); + if( pOLV->HasSelection() ) + pOLV->Copy(); break; case SID_PASTE: if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED) pOLV->Paste(); break; - case FN_PASTESPECIAL: + case SID_PASTE_SPECIAL: { if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED) { @@ -886,7 +888,7 @@ void SwAnnotationShell::StateClpbrd(SfxItemSet &rSet) break; } case SID_PASTE: - case FN_PASTESPECIAL: + case SID_PASTE_SPECIAL: { if( !bPastePossible ) rSet.DisableItem( nWhich ); @@ -1380,6 +1382,8 @@ void SwAnnotationShell::ExecUndo(SfxRequest &rReq) } } + rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False); + if (rView.GetPostItMgr()->GetActivePostIt()) rView.GetPostItMgr()->GetActivePostIt()->ResizeIfNeccessary(aOldHeight,rView.GetPostItMgr()->GetActivePostIt()->GetPostItTextHeight()); } @@ -1595,7 +1599,7 @@ void SwAnnotationShell::InsertSymbol(SfxRequest& rReq) aFontSet.Set( aOldSet ); // String einfuegen - pOLV->InsertText( sSym, TRUE ); + pOLV->InsertText( sSym); // attributieren (Font setzen) SfxItemSet aSetFont( *aFontSet.GetPool(), aFontSet.GetRanges() ); diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx index 168441d479..84b6f53a57 100644 --- a/sw/source/ui/shells/basesh.cxx +++ b/sw/source/ui/shells/basesh.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -301,11 +301,9 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq) if ( rSh.HasSelection() ) { SwTransferable* pTransfer = new SwTransferable( rSh ); -/*??*/ uno::Reference< - datatransfer::XTransferable > xRef( - pTransfer ); +/*??*/ uno::Reference< datatransfer::XTransferable > xRef( pTransfer ); - if ( nId == SID_CUT ) + if ( nId == SID_CUT && !rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT) ) pTransfer->Cut(); else { @@ -395,7 +393,7 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq) aReq.Done(); } } - + if (rSh.IsFrmSelected() || rSh.IsObjSelected()) rSh.EnterSelFrmMode(); pView->AttrChangedNotify( &rSh ); @@ -404,8 +402,8 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq) return; } break; - - case FN_PASTESPECIAL: + + case SID_PASTE_SPECIAL: { TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( @@ -481,10 +479,10 @@ void SwBaseShell::StateClpbrd(SfxItemSet &rSet) rSet.DisableItem( SID_PASTE ); break; - case FN_PASTESPECIAL: + case SID_PASTE_SPECIAL: if( !GetView().IsPasteSpecialAllowed() ) { - rSet.DisableItem( FN_PASTESPECIAL ); + rSet.DisableItem( SID_PASTE_SPECIAL ); rSet.DisableItem( SID_PASTE_UNFORMATTED ); } break; @@ -539,6 +537,8 @@ void SwBaseShell::ExecUndo(SfxRequest &rReq) default: DBG_ERROR("falscher Dispatcher"); } + + GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False); } /*-------------------------------------------------------------------- @@ -2547,7 +2547,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) //Hintergrundattribute der Tabelle holen und in den Set packen SvxBrushItem aBrush(RES_BACKGROUND); rSh.GetBoxBackground( aBrush ); - pDlg = pFact->CreateSfxDialog( pMDI, aSet, + pDlg = pFact->CreateSfxDialog( pMDI, aSet, rView.GetViewFrame()->GetFrame()->GetFrameInterface(), RC_SWDLG_BACKGROUND ); DBG_ASSERT(pDlg, "Dialogdiet fail!"); @@ -2566,7 +2566,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) rSh.GetFlyFrmAttr( aSet ); - pDlg = pFact->CreateSfxDialog( pMDI, aSet, + pDlg = pFact->CreateSfxDialog( pMDI, aSet, rView.GetViewFrame()->GetFrame()->GetFrameInterface(), RC_SWDLG_BACKGROUND ); DBG_ASSERT(pDlg, "Dialogdiet fail!"); @@ -2581,7 +2581,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) // Umrandungsattribute ganz normal ueber Shell setzen rSh.GetCurAttr( aSet ); - pDlg = pFact->CreateSfxDialog( pMDI, aSet, + pDlg = pFact->CreateSfxDialog( pMDI, aSet, rView.GetViewFrame()->GetFrame()->GetFrameInterface(), RC_SWDLG_BACKGROUND ); DBG_ASSERT(pDlg, "Dialogdiet fail!"); diff --git a/sw/source/ui/shells/drwtxtex.cxx b/sw/source/ui/shells/drwtxtex.cxx index fc15241d12..60059cdeb1 100644 --- a/sw/source/ui/shells/drwtxtex.cxx +++ b/sw/source/ui/shells/drwtxtex.cxx @@ -736,9 +736,9 @@ ASK_ESCAPE: SvtCTLOptions aCTLOptions; sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled(); GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled ); - if(!bEnabled) - rSet.DisableItem(nWhich); - } + if(!bEnabled) + rSet.DisableItem(nWhich); + } break; default: nSlotId = 0; // don't know this slot @@ -828,15 +828,20 @@ void SwDrawTextShell::ExecClpbrd(SfxRequest &rReq) return; OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + + ESelection aSel(pOLV->GetSelection()); + const sal_Bool bCopy = (aSel.nStartPara != aSel.nEndPara) || (aSel.nStartPos != aSel.nEndPos); sal_uInt16 nId = rReq.GetSlot(); switch( nId ) { case SID_CUT: - pOLV->Cut(); + if (bCopy) + pOLV->Cut(); return; case SID_COPY: - pOLV->Copy(); + if (bCopy) + pOLV->Copy(); return; case SID_PASTE: @@ -888,8 +893,8 @@ void SwDrawTextShell::StateClpbrd(SfxItemSet &rSet) } break; - case FN_PASTESPECIAL: - rSet.DisableItem( FN_PASTESPECIAL ); + case SID_PASTE_SPECIAL: + rSet.DisableItem( SID_PASTE_SPECIAL ); break; // --> OD 2008-06-20 #151110# case SID_CLIPBOARD_FORMAT_ITEMS: diff --git a/sw/source/ui/shells/drwtxtsh.cxx b/sw/source/ui/shells/drwtxtsh.cxx index 9098c55dcf..ad6ab1d2e7 100644 --- a/sw/source/ui/shells/drwtxtsh.cxx +++ b/sw/source/ui/shells/drwtxtsh.cxx @@ -514,7 +514,7 @@ void SwDrawTextShell::ExecDraw(SfxRequest &rReq) case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break; case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break; } - pOLV->InsertText( String(cIns), TRUE ); + pOLV->InsertText( String(cIns)); rReq.Done(); } break; @@ -640,6 +640,7 @@ void SwDrawTextShell::ExecUndo(SfxRequest &rReq) pUndoManager->Redo(0); } bCallBase = FALSE; + GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False); } break; } @@ -856,7 +857,7 @@ void SwDrawTextShell::InsertSymbol(SfxRequest& rReq) aFontSet.Set( aOldSet ); // String einfuegen - pOLV->InsertText( sSym, TRUE ); + pOLV->InsertText( sSym ); // attributieren (Font setzen) SfxItemSet aFontAttribSet( *aFontSet.GetPool(), aFontSet.GetRanges() ); diff --git a/sw/source/ui/shells/shells.src b/sw/source/ui/shells/shells.src index 9140062f21..92434115d7 100644 --- a/sw/source/ui/shells/shells.src +++ b/sw/source/ui/shells/shells.src @@ -98,7 +98,7 @@ String STR_REDLINE_DELETED }; String STR_REDLINE_AUTOFMT { - Text [ en-US ] = "AutoFormat"; + Text [ en-US ] = "AutoCorrect"; Text [ x-comment ] = " "; }; String STR_REDLINE_FORMATED @@ -118,12 +118,12 @@ String STR_REDLINE_FMTCOLLSET }; String STR_REDLINE_TITLE { - Text [ en-US ] = "AutoFormat"; + Text [ en-US ] = "AutoCorrect"; Text [ x-comment ] = " "; }; String STR_REDLINE_MSG { - Text [ en-US ] = "AutoFormat completed.\nYou can accept or reject all changes,\nor accept or reject particular changes."; + Text [ en-US ] = "AutoCorrect completed.\nYou can accept or reject all changes,\nor accept or reject particular changes."; Text [ x-comment ] = " "; }; String STR_REDLINE_ACCEPT_ALL diff --git a/sw/source/ui/shells/textfld.cxx b/sw/source/ui/shells/textfld.cxx index 094ddf318c..529ac59604 100644 --- a/sw/source/ui/shells/textfld.cxx +++ b/sw/source/ui/shells/textfld.cxx @@ -382,7 +382,7 @@ void SwTextShell::ExecField(SfxRequest &rReq) SwFmtFld* pSwFmtFld = static_cast<SwFmtFld*>(pFirst); if ( pSwFmtFld->GetFld() == pPostIt ) { - pSwFmtFld->Broadcast( SwFmtFldHint( 0, SWFMTFLD_FOCUS ) ); + pSwFmtFld->Broadcast( SwFmtFldHint( 0, SWFMTFLD_FOCUS, &GetView() ) ); break; } pFirst = aIter++; @@ -402,7 +402,7 @@ void SwTextShell::ExecField(SfxRequest &rReq) sComment = pRedline->GetComment(); if ( sComment == String(rtl::OUString::createFromAscii("")) ) GetView().GetDocShell()->Broadcast(SwRedlineHint(pRedline,SWREDLINE_INSERTED)); - const_cast<SwRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS)); + const_cast<SwRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS,&GetView())); } */ diff --git a/sw/source/ui/shells/textsh.cxx b/sw/source/ui/shells/textsh.cxx index 4602dd3cdd..965b0f5d32 100644 --- a/sw/source/ui/shells/textsh.cxx +++ b/sw/source/ui/shells/textsh.cxx @@ -819,7 +819,11 @@ void SwTextShell::StateInsert( SfxItemSet &rSet ) rSh.Push(); const BOOL bCrsrInHidden = rSh.SelectHiddenRange(); - rSh.Pop(FALSE); + // --> OD 2009-08-05 #i103839#, #b6855246# + // Do not call method <SwCrsrShell::Pop(..)> with 1st parameter = <FALSE> + // in order to avoid that the view jumps to the visible cursor. + rSh.Pop(); + // <-- while ( nWhich ) { @@ -827,8 +831,11 @@ void SwTextShell::StateInsert( SfxItemSet &rSet ) { case SID_INSERT_SOUND: case SID_INSERT_VIDEO: + /*!SvxPluginFileDlg::IsAvailable( nWhich ) || + + discussed with mba: for performance reasons we skip the IsAvailable call here + */ if ( GetShell().IsSelFrmMode() || - !SvxPluginFileDlg::IsAvailable( nWhich ) || SFX_CREATE_MODE_EMBEDDED == eCreateMode || bCrsrInHidden ) { rSet.DisableItem( nWhich ); diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx index 156fada7ee..a0ccd838ac 100644 --- a/sw/source/ui/shells/textsh1.cxx +++ b/sw/source/ui/shells/textsh1.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -373,7 +373,7 @@ void SwTextShell::Execute(SfxRequest &rReq) if (bForParagraph) SwLangHelper::SelectCurrentPara( rWrtSh ); - + if (!bForSelection) // document language to be changed... { rWrtSh.SelAll(); @@ -789,7 +789,7 @@ void SwTextShell::Execute(SfxRequest &rReq) GetView().GetViewFrame()->ToggleChildWindow(SID_HYPERLINK_DIALOG); break; case FN_REMOVE_HYPERLINK: - { + { BOOL bSel = rWrtSh.HasSelection(); if(!bSel) { @@ -1044,7 +1044,14 @@ void SwTextShell::Execute(SfxRequest &rReq) // --> OD 2008-03-18 #refactorlists# String sContinuedListId; const SwNumRule* pRule = - rWrtSh.SearchNumRule( FALSE, TRUE, FALSE, -1, sContinuedListId ); + rWrtSh.SearchNumRule( false, true, false, -1, sContinuedListId ); + // --> OD 2009-08-26 #i86492# + // Search also for bullet list + if ( !pRule ) + { + pRule = rWrtSh.SearchNumRule( false, false, false, -1, sContinuedListId ); + } + // <-- if ( pRule ) { rWrtSh.SetCurNumRule( *pRule, false, sContinuedListId ); @@ -1623,14 +1630,23 @@ void SwTextShell::GetState( SfxItemSet &rSet ) break; case FN_NUM_CONTINUE: { - if ( rSh.GetCurNumRule() ) - rSet.DisableItem(nWhich); - else + // --> OD 2009-08-26 #i86492# + // Allow continuation of previous list, even if at current cursor + // a list is active. +// if ( rSh.GetCurNumRule() ) +// rSet.DisableItem(nWhich); +// else + // <-- { - // --> OD 2008-03-18 #refactorlists# + // --> OD 2009-08-26 #i86492# + // Search also for bullet list String aDummy; const SwNumRule* pRule = - rSh.SearchNumRule( FALSE, TRUE, FALSE, -1, aDummy ); + rSh.SearchNumRule( false, true, false, -1, aDummy ); + if ( !pRule ) + { + pRule = rSh.SearchNumRule( false, false, false, -1, aDummy ); + } // <-- if ( !pRule ) rSet.DisableItem(nWhich); diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index 3b290d392b..1c2fba0c8a 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -1580,6 +1580,10 @@ void SwPagePreView::GetState( SfxItemSet& rSet ) { switch(nWhich) { + case SID_BROWSER_MODE: + case FN_PRINT_LAYOUT: + rSet.DisableItem(nWhich); + break; case FN_START_OF_DOCUMENT: { if ( pPagePrevwLay->IsPageVisible( 1 ) ) @@ -2491,6 +2495,10 @@ SfxPrinter* SwPagePreView::GetPrinter( BOOL bCreate ) USHORT SwPagePreView::SetPrinter( SfxPrinter *pNew, USHORT nDiffFlags, bool ) { ViewShell &rSh = *GetViewShell(); + SfxPrinter* pOld = rSh.getIDocumentDeviceAccess()->getPrinter( false ); + if ( pOld && pOld->IsPrinting() ) + return SFX_PRINTERROR_BUSY; + SwEditShell &rESh = (SwEditShell&)rSh; //Buh... if( ( SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP ) & nDiffFlags ) { diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx index 24eca08fac..5653071d84 100644 --- a/sw/source/ui/uiview/srcview.cxx +++ b/sw/source/ui/uiview/srcview.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -57,6 +57,7 @@ #include <sfx2/app.hxx> #include <sfx2/objface.hxx> #include <sfx2/viewfrm.hxx> +#include <sfx2/bindings.hxx> #include <sfx2/docfilt.hxx> #include <sfx2/fcontnr.hxx> #include <sfx2/request.hxx> @@ -457,17 +458,21 @@ void SwSrcView::Execute(SfxRequest& rReq) break; case SID_UNDO: pTextView->Undo(); + GetViewFrame()->GetBindings().InvalidateAll(FALSE); break; case SID_REDO: pTextView->Redo(); + GetViewFrame()->GetBindings().InvalidateAll(FALSE); break; case SID_REPEAT: break; case SID_CUT: - pTextView->Cut(); + if(pTextView->HasSelection()) + pTextView->Cut(); break; case SID_COPY: - pTextView->Copy(); + if(pTextView->HasSelection()) + pTextView->Copy(); break; case SID_PASTE: pTextView->Paste(); @@ -588,6 +593,8 @@ void SwSrcView::GetState(SfxItemSet& rSet) case SID_DIRECTEXPORTDOCASPDF: case SID_EXPORTDOC: case SID_REPEAT: + case SID_BROWSER_MODE: + case FN_PRINT_LAYOUT: rSet.DisableItem(nWhich); break; case SID_CUT: @@ -731,6 +738,10 @@ USHORT SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem, USHORT SwSrcView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) { SwDocShell* pDocSh = GetDocShell(); + SfxPrinter* pOld = pDocSh->GetDoc()->getPrinter( false ); + if ( pOld && pOld->IsPrinting() ) + return SFX_PRINTERROR_BUSY; + if ( (SFX_PRINTER_JOBSETUP | SFX_PRINTER_PRINTER) & nDiffFlags ) { pDocSh->GetDoc()->setPrinter( pNew, true, true ); @@ -865,7 +876,7 @@ SfxPrinter* SwSrcView::GetPrinter( BOOL bCreate ) void SwSrcView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { if ( rHint.ISA(SfxSimpleHint) && - ( + ( ((SfxSimpleHint&) rHint).GetId() == SFX_HINT_MODECHANGED || ( ((SfxSimpleHint&) rHint).GetId() == SFX_HINT_TITLECHANGED && diff --git a/sw/source/ui/uiview/uivwimp.cxx b/sw/source/ui/uiview/uivwimp.cxx index f6feb0ec0d..1930856661 100644 --- a/sw/source/ui/uiview/uivwimp.cxx +++ b/sw/source/ui/uiview/uivwimp.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -335,48 +335,14 @@ void SAL_CALL SwClipboardChangeListener::changedContents( const CLIP_NMSPC::Clip SfxBindings& rBind = pView->GetViewFrame()->GetBindings(); rBind.Invalidate( SID_PASTE ); - rBind.Invalidate( FN_PASTESPECIAL ); + rBind.Invalidate( SID_PASTE_SPECIAL ); rBind.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS ); } } void SwClipboardChangeListener::AddRemoveListener( BOOL bAdd ) { - try - { - do { - -#ifdef _DONT_WORD_FOR_WEBTOP_ -JP 4.7.2001: change for WebTop - get Clipboard from the Window. - Reference< XMultiServiceFactory > xFact( - ::comphelper::getProcessServiceFactory() ); - if( !xFact.is() ) - break; - Reference< XClipboard > xClipboard( xFact->createInstance( - ::rtl::OUString::createFromAscii( - "com.sun.star.datatransfer.clipboard.SystemClipboard" )), - UNO_QUERY ); -#else - Reference< XClipboard > xClipboard( - pView->GetEditWin().GetClipboard() ); -#endif - if( !xClipboard.is() ) - break; - - Reference< XClipboardNotifier > xClpbrdNtfr( xClipboard, UNO_QUERY ); - if( xClpbrdNtfr.is() ) - { - Reference< XClipboardListener > xClipEvtLstnr( this ); - if( bAdd ) - xClpbrdNtfr->addClipboardListener( xClipEvtLstnr ); - else - xClpbrdNtfr->removeClipboardListener( xClipEvtLstnr ); - } - } while ( FALSE ); - } - catch( const uno::Exception& ) - { - } + pView->AddRemoveClipboardListener( Reference< XClipboardListener >( this ), bAdd ); } diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx index 1b5b100dd4..191ff8ac0d 100644 --- a/sw/source/ui/uiview/view.cxx +++ b/sw/source/ui/uiview/view.cxx @@ -56,93 +56,46 @@ #include <svx/extrusionbar.hxx> #include <svx/fontworkbar.hxx> #include <unotxvw.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _SWHINTS_HXX #include <swhints.hxx> -#endif #include <swmodule.hxx> #include <inputwin.hxx> #include <chartins.hxx> #include <uivwimp.hxx> #include <uitool.hxx> #include <edtwin.hxx> -#ifndef _TEXTSH_HXX #include <textsh.hxx> -#endif -#ifndef _LISTSH_HXX #include <listsh.hxx> -#endif -#ifndef _TABSH_HXX #include <tabsh.hxx> -#endif -#ifndef _GRFSH_HXX #include <grfsh.hxx> -#endif -#ifndef _MEDIASH_HXX #include <mediash.hxx> -#endif -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <frmsh.hxx> -#ifndef _OLESH_HXX #include <olesh.hxx> -#endif -#ifndef _DRAWSH_HXX #include <drawsh.hxx> -#endif -#ifndef _DRAWBASE_HXX #include <drawbase.hxx> -#endif -#ifndef _DRFORMSH_HXX #include <drformsh.hxx> -#endif -#ifndef _DRWTXTSH_HXX #include <drwtxtsh.hxx> -#endif -#ifndef _BEZIERSH_HXX #include <beziersh.hxx> -#endif -#ifndef _GLOBDOC_HXX #include <globdoc.hxx> -#endif #include <scroll.hxx> -#ifndef _GLOBDOC_HXX #include <globdoc.hxx> -#endif #include <navipi.hxx> #include <gloshdl.hxx> #include <usrpref.hxx> -#ifndef _SRCVIEW_HXX #include <srcview.hxx> -#endif #include <doc.hxx> -#ifndef _WDOCSH_HXX +#include <drawdoc.hxx> #include <wdocsh.hxx> -#endif -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <workctrl.hxx> #include <wrtsh.hxx> -#ifndef _BARCFG_HXX #include <barcfg.hxx> -#endif -#ifndef _PVIEW_HXX #include <pview.hxx> -#endif #include <swdtflvr.hxx> -#ifndef _VIEW_HRC #include <view.hrc> -#endif -#ifndef _GLOBDOC_HRC #include <globdoc.hrc> -#endif -#ifndef _FRMUI_HRC #include <frmui.hrc> -#endif #include <cfgitems.hxx> #include <prtopt.hxx> #include <swprtopt.hxx> @@ -152,9 +105,7 @@ #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/scanner/ScannerContext.hpp> #include <com/sun/star/scanner/XScannerManager.hpp> -#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/unohlp.hxx> -#endif #include <rtl/ustrbuf.hxx> #include <xmloff/xmluconv.hxx> @@ -673,7 +624,7 @@ void SwView::_CheckReadonlyState() SID_UNDO, SID_REDO, SID_REPEAT, SID_PASTE, SID_PASTE_UNFORMATTED, - FN_PASTESPECIAL, SID_SBA_BRW_INSERT, + SID_PASTE_SPECIAL, SID_SBA_BRW_INSERT, SID_BACKGROUND_COLOR, FN_INSERT_BOOKMARK, SID_CHARMAP, FN_INSERT_SOFT_HYPHEN, FN_INSERT_HARDHYPHEN, FN_INSERT_HARD_SPACE, FN_INSERT_BREAK, @@ -1471,7 +1422,7 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue > { pValue->Value >>= bSelectedFrame; bGotIsSelectedFrame = sal_True; - } + } pValue++; } if (bGotVisibleBottom) @@ -1781,7 +1732,18 @@ void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) CreateTab(); else KillTab(); - SfxBoolItem aItem( SID_FM_DESIGN_MODE, !GetDocShell()->IsReadOnly()); + bool bReadonly = GetDocShell()->IsReadOnly(); + //#i76332# if document is to be opened in alive-mode then this has to be regarded while switching from readonly-mode to edit-mode + if( !bReadonly ) + { + SwDrawDocument * pDrawDoc = 0; + if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (GetDocShell()->GetDoc()->GetDrawModel() ) ) ) + { + if( !pDrawDoc->GetOpenInDesignMode() ) + break;// don't touch the design mode + } + } + SfxBoolItem aItem( SID_FM_DESIGN_MODE, !bReadonly); GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_ASYNCHRON, &aItem, 0L ); } diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index 41a9ada943..493daabe92 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -650,7 +650,7 @@ void __EXPORT SwView::Execute(SfxRequest &rReq) break; case FN_REDLINE_ACCEPT_DIRECT: case FN_REDLINE_REJECT_DIRECT: - { + { SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE ); Point aCrsrPos = pWrtShell->GetCrsrDocPos( sal_True ); if( pWrtShell->GetContentAtPos( aCrsrPos, aCntntAtPos ) ) @@ -1067,23 +1067,23 @@ void __EXPORT SwView::Execute(SfxRequest &rReq) } break; case SID_RECHECK_DOCUMENT: - { + { SwDocShell* pDocShell = GetDocShell(); SwDoc* pDoc = pDocShell->GetDoc(); uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( pDoc->GetGCIterator() ); if( xGCIterator.is() ) { xGCIterator->resetIgnoreRules(); - } + } // reset ignore lists pDoc->SpellItAgainSam( sal_True, sal_False, sal_False ); - // clear ignore dictionary + // clear ignore dictionary uno::Reference< linguistic2::XDictionary > xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY ); if( xDictionary.is() ) xDictionary->clear(); // put cursor to the start of the document pWrtShell->SttDoc(); - } + } // no break; - but call spell/grammar dialog case FN_SPELL_GRAMMAR_DIALOG: { @@ -1233,7 +1233,7 @@ void SwView::StateStatusLine(SfxItemSet &rSet) if (nPageCnt != nCnt) // Basic benachrichtigen { nPageCnt = nCnt; - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_PAGE_COUNT, GetViewFrame()->GetObjectShell()), FALSE); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_PAGE_COUNT, SwDocShell::GetEventName(STR_SW_EVENT_PAGE_COUNT), GetViewFrame()->GetObjectShell()), FALSE); } } break; @@ -1404,7 +1404,7 @@ void SwView::StateStatusLine(SfxItemSet &rSet) } } } - + //#outline level, removed by zhaojianwei //const SwNumRule* pNumRule = rShell.GetCurNumRule(); //if (pNumRule) // Cursor in Numerierung @@ -1443,11 +1443,11 @@ void SwView::StateStatusLine(SfxItemSet &rSet) // } //}//<-removed end ,zhaojianwei - //-->#outline level,added by zhaojianwei + //-->#outline level,added by zhaojianwei const SwNumRule* pNumRule = rShell.GetCurNumRule(); const bool bOutlineNum = pNumRule ? pNumRule->IsOutlineRule() : 0; //((SwTxtFmtColl*)rShell.GetCrsr()->GetNode()->GetTxtNode()->GetFmtColl())->IsAssignedToListLevelOfOutlineStyle(); - + if (pNumRule && !bOutlineNum ) // Cursor in Numerierung { BYTE nNumLevel = rShell.GetNumLevel(); @@ -1481,9 +1481,9 @@ void SwView::StateStatusLine(SfxItemSet &rSet) } } } - if( sStr.Len() ) + if( sStr.Len() ) sStr.AppendAscii(sStatusDelim); - sStr += SW_RESSTR(STR_NUM_LEVEL); + sStr += SW_RESSTR(STR_NUM_LEVEL); sStr += String::CreateFromInt32( nNumLevel + 1 ); } @@ -1495,9 +1495,9 @@ void SwView::StateStatusLine(SfxItemSet &rSet) sStr.AppendAscii(sStatusComma); if( bOutlineNum ) { - sStr += SW_RESSTR(STR_OUTLINE_NUMBERING); + sStr += SW_RESSTR(STR_OUTLINE_NUMBERING); sStr.AppendAscii(sStatusDelim); - sStr += SW_RESSTR(STR_NUM_LEVEL); + sStr += SW_RESSTR(STR_NUM_LEVEL); } else sStr += SW_RESSTR(STR_NUM_OUTLINE); @@ -2469,8 +2469,8 @@ IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg ) } void SwView::ExecuteScan( SfxRequest& rReq ) -{ - if (pViewImpl) +{ + if (pViewImpl) pViewImpl->ExecuteScan(rReq) ; } diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index 443eee31c0..4f3870c559 100644 --- a/sw/source/ui/uiview/viewprt.cxx +++ b/sw/source/ui/uiview/viewprt.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -141,6 +141,10 @@ void SetPrinter( IDocumentDeviceAccess* pIDDA, SfxPrinter* pNew, BOOL bWeb ) USHORT __EXPORT SwView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) { SwWrtShell &rSh = GetWrtShell(); + SfxPrinter* pOld = rSh.getIDocumentDeviceAccess()->getPrinter( false ); + if ( pOld && pOld->IsPrinting() ) + return SFX_PRINTERROR_BUSY; + if ( (SFX_PRINTER_JOBSETUP | SFX_PRINTER_PRINTER) & nDiffFlags ) { rSh.getIDocumentDeviceAccess()->setPrinter( pNew, true, true ); @@ -231,12 +235,12 @@ ErrCode SwView::DoPrint( SfxPrinter *pPrinter, PrintDialog *pDlg, BOOL bSilent, SwPrtOptions aOpts( sDocumentTitle ); BOOL bWeb = 0 != PTR_CAST(SwWebView, this); nMergeType = pMgr->GetMergeType(); - + BOOL bPrtPros; BOOL bPrtPros_RTL; SwView::MakeOptions( pDlg, aOpts, &bPrtPros, &bPrtPros_RTL, bWeb, GetPrinter(), pSh->getIDocumentDeviceAccess()->getPrintData() ); - + //set the appropriate view options to print //on silent mode the field commands have to be switched off always //on default print the user is asked what to do @@ -259,7 +263,7 @@ ErrCode SwView::DoPrint( SfxPrinter *pPrinter, PrintDialog *pDlg, BOOL bSilent, //switch off display of hidden characters if on and hidden characters are in use const sal_Bool bOldShowHiddenChar = pCurrentViewOptions->IsShowHiddenChar(); const sal_Bool bOldMetaChars = pCurrentViewOptions->IsViewMetaChars(); - if( bOldShowHiddenChar != aOpts.IsPrintHiddenText() + if( bOldShowHiddenChar != aOpts.IsPrintHiddenText() && pSh->GetDoc()->ContainsHiddenChars()) bApplyViewOptions |= true; //switch off display of hidden paragraphs if on and hidden paragraphs are in use @@ -294,7 +298,7 @@ ErrCode SwView::DoPrint( SfxPrinter *pPrinter, PrintDialog *pDlg, BOOL bSilent, SW_MOD()->ApplyUsrPref(*pOrgViewOption, this, VIEWOPT_DEST_VIEW_ONLY ); } - + if( nMergeType == DBMGR_MERGE_MAILMERGE || DBMGR_MERGE_DOCUMENTS == nMergeType ) { @@ -431,9 +435,19 @@ ErrCode SwView::DoPrint( SfxPrinter *pPrinter, PrintDialog *pDlg, BOOL bSilent, } pProgress->Stop(); - pProgress->DeleteOnEndPrint(); - pPrinter->EndJob(); - return pPrinter->GetError(); + if ( pPrinter->IsJobActive() ) + { + pProgress->DeleteOnEndPrint(); + pPrinter->EndJob(); + return pPrinter->GetError(); + } + else + { + // the next call might destroy pPrinter (in case it is not the usual document printer); so get the error before + ULONG nError = pPrinter->GetError(); + pProgress->DeleteOnEndPrint(); + return nError; + } } diff --git a/sw/source/ui/uno/swdetect.cxx b/sw/source/ui/uno/swdetect.cxx index f20309a4ab..c48834b40d 100644 --- a/sw/source/ui/uno/swdetect.cxx +++ b/sw/source/ui/uno/swdetect.cxx @@ -217,7 +217,7 @@ SwFilterDetect::~SwFilterDetect() BOOL bIsStorage = aMedium.IsStorage(); if ( bIsStorage ) { - uno::Reference< embed::XStorage > xStorage = aMedium.GetStorage(); + uno::Reference< embed::XStorage > xStorage = aMedium.GetStorage( sal_False ); if ( aMedium.GetLastStorageCreationState() != ERRCODE_NONE ) { // error during storage creation means _here_ that the medium diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index a2133bea18..4801259cd7 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -416,7 +416,8 @@ sal_Bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextR if(pxCursor) { SwPaM* pUnoCrsr = pxCursor->GetPaM(); - bRet |= (true == pxCursor->GetDoc()->Copy( *pUnoCrsr, aPos, false )); + bRet = pxCursor->GetDoc()->CopyRange( *pUnoCrsr, aPos, false ) + || bRet; } else { @@ -424,7 +425,8 @@ sal_Bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextR if(pBkmk && pBkmk->IsExpanded()) { SwPaM aTmp(pBkmk->GetOtherMarkPos(), pBkmk->GetMarkPos()); - bRet |= (true == pxRange->GetDoc()->Copy(aTmp, aPos, false)); + bRet = pxRange->GetDoc()->CopyRange(aTmp, aPos, false) + || bRet; } } } diff --git a/sw/source/ui/uno/unomailmerge.cxx b/sw/source/ui/uno/unomailmerge.cxx index 2679791f07..ce1e099e83 100644 --- a/sw/source/ui/uno/unomailmerge.cxx +++ b/sw/source/ui/uno/unomailmerge.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * 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 @@ -830,9 +830,9 @@ uno::Any SAL_CALL SwXMailMerge::execute( DBG_ASSERT( !pOldSrc || pOldSrc == this, "Ooops... different event source already set." ); pMgr->SetMailMergeEvtSrc( this ); // launch events for listeners - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, xCurDocSh)); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), xCurDocSh)); BOOL bSucc = pMgr->MergeNew( aMergeDesc ); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, xCurDocSh)); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), xCurDocSh)); pMgr->SetMailMergeEvtSrc( pOldSrc ); diff --git a/sw/source/ui/uno/unomod.cxx b/sw/source/ui/uno/unomod.cxx index 4818a7973a..2f7716bac1 100644 --- a/sw/source/ui/uno/unomod.cxx +++ b/sw/source/ui/uno/unomod.cxx @@ -125,7 +125,10 @@ enum SwPrintSettingsPropertyHandles HANDLE_PRINTSET_PAPER_FROM_SETUP, HANDLE_PRINTSET_TABLES, HANDLE_PRINTSET_SINGLE_JOBS, - HANDLE_PRINTSET_EMPTY_PAGES + HANDLE_PRINTSET_EMPTY_PAGES, + HANDLE_PRINTSET_PROSPECT_RTL, + HANDLE_PRINTSET_PLACEHOLDER, + HANDLE_PRINTSET_HIDDEN_TEXT }; static ChainablePropertySetInfo * lcl_createViewSettingsInfo() @@ -186,14 +189,17 @@ static ChainablePropertySetInfo * lcl_createPrintSettingsInfo() { RTL_CONSTASCII_STRINGPARAM ( "PrintControls" ), HANDLE_PRINTSET_CONTROLS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintDrawings" ), HANDLE_PRINTSET_DRAWINGS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintGraphics" ), HANDLE_PRINTSET_GRAPHICS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, + { RTL_CONSTASCII_STRINGPARAM ( "PrintHiddenText"), HANDLE_PRINTSET_HIDDEN_TEXT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintLeftPages" ), HANDLE_PRINTSET_LEFT_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintPageBackground" ), HANDLE_PRINTSET_PAGE_BACKGROUND , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintProspect" ), HANDLE_PRINTSET_PROSPECT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, + { RTL_CONSTASCII_STRINGPARAM ( "PrintProspectRTL" ), HANDLE_PRINTSET_PROSPECT_RTL , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintReversed" ), HANDLE_PRINTSET_REVERSED , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintRightPages" ), HANDLE_PRINTSET_RIGHT_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintFaxName" ), HANDLE_PRINTSET_FAX_NAME , CPPUTYPE_OUSTRING, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintPaperFromSetup" ), HANDLE_PRINTSET_PAPER_FROM_SETUP , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintTables" ), HANDLE_PRINTSET_TABLES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, + { RTL_CONSTASCII_STRINGPARAM ( "PrintTextPlaceholder"), HANDLE_PRINTSET_PLACEHOLDER , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintSingleJobs" ), HANDLE_PRINTSET_SINGLE_JOBS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintEmptyPages" ), HANDLE_PRINTSET_EMPTY_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { 0, 0, 0, CPPUTYPE_UNKNOWN, 0, 0 } @@ -456,6 +462,24 @@ void SwXPrintSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, throw lang::IllegalArgumentException(); } break; + case HANDLE_PRINTSET_PROSPECT_RTL: + { + bVal = *(sal_Bool*)rValue.getValue(); + mpPrtOpt->SetPrintProspect_RTL(bVal); + } + break; + case HANDLE_PRINTSET_PLACEHOLDER: + { + bVal = *(sal_Bool*)rValue.getValue(); + mpPrtOpt->SetPrintTextPlaceholder(bVal); + } + break; + case HANDLE_PRINTSET_HIDDEN_TEXT: + { + bVal = *(sal_Bool*)rValue.getValue(); + mpPrtOpt->SetPrintHiddenText(bVal); + } + break; default: throw UnknownPropertyException(); } @@ -550,6 +574,21 @@ void SwXPrintSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, rValue <<= mpPrtOpt->GetFaxName(); } break; + case HANDLE_PRINTSET_PROSPECT_RTL: + { + rValue <<= mpPrtOpt->IsPrintProspect_RTL(); + } + break; + case HANDLE_PRINTSET_PLACEHOLDER: + { + rValue <<= mpPrtOpt->IsPrintTextPlaceholder(); + } + break; + case HANDLE_PRINTSET_HIDDEN_TEXT: + { + rValue <<= mpPrtOpt->IsPrintHiddenText(); + } + break; default: throw UnknownPropertyException(); } @@ -1024,3 +1063,4 @@ Sequence< OUString > SwXViewSettings::getSupportedServiceNames(void) throw( Runt pArray[0] = C2U("com.sun.star.text.ViewSettings"); return aRet; } + diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 6fc167c72f..1ebfda6d1c 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -81,7 +81,13 @@ #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/XFastPropertySet.hpp> #include <com/sun/star/document/RedlineDisplayType.hpp> +#include <com/sun/star/document/XDocumentEventBroadcaster.hpp> +#include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/script/XInvocation.hpp> +#include <com/sun/star/reflection/XIdlClassProvider.hpp> #include <svx/linkmgr.hxx> #include <svx/unofill.hxx> #include <svx/unolingu.hxx> @@ -236,15 +242,23 @@ sal_Int64 SAL_CALL SwXTextDocument::getSomething( const Sequence< sal_Int8 >& rI Any SAL_CALL SwXTextDocument::queryInterface( const uno::Type& rType ) throw(RuntimeException) { Any aRet = SwXTextDocumentBaseClass::queryInterface(rType); - if(aRet.getValueType() == getVoidCppuType()) + if ( !aRet.hasValue() ) aRet = SfxBaseModel::queryInterface(rType); - if(aRet.getValueType() == getVoidCppuType() && + if ( !aRet.hasValue() && rType == ::getCppuType((Reference<lang::XMultiServiceFactory>*)0)) { Reference<lang::XMultiServiceFactory> xTmp = this; aRet <<= xTmp; } - if(aRet.getValueType() == getVoidCppuType()) + + if ( !aRet.hasValue() + && rType != ::getCppuType((Reference< com::sun::star::document::XDocumentEventBroadcaster>*)0) + && rType != ::getCppuType((Reference< com::sun::star::frame::XController>*)0) + && rType != ::getCppuType((Reference< com::sun::star::frame::XFrame>*)0) + && rType != ::getCppuType((Reference< com::sun::star::script::XInvocation>*)0) + && rType != ::getCppuType((Reference< com::sun::star::reflection::XIdlClassProvider>*)0) + && rType != ::getCppuType((Reference< com::sun::star::beans::XFastPropertySet>*)0) + && rType != ::getCppuType((Reference< com::sun::star::awt::XWindow>*)0)) { GetNumberFormatter(); if(xNumFmtAgg.is()) diff --git a/sw/source/ui/utlui/content.cxx b/sw/source/ui/utlui/content.cxx index eaf9bb5c66..10a94901f5 100644 --- a/sw/source/ui/utlui/content.cxx +++ b/sw/source/ui/utlui/content.cxx @@ -906,16 +906,17 @@ SwContentTree::SwContentTree(Window* pParent, const ResId& rResId) : sRename(SW_RES(ST_RENAME)), sReadonlyIdx(SW_RES(ST_READONLY_IDX)), sInvisible(SW_RES(ST_INVISIBLE)), - sPostItShow(SW_RES(ST_POSTIT_SHOW)), - sPostItHide(SW_RES(ST_POSTIT_HIDE)), - sPostItDelete(SW_RES(ST_POSTIT_DELETE)), + + sPostItShow(SW_RES(ST_POSTIT_SHOW)), + sPostItHide(SW_RES(ST_POSTIT_HIDE)), + sPostItDelete(SW_RES(ST_POSTIT_DELETE)), pHiddenShell(0), - pActiveShell(0), - pConfig(SW_MOD()->GetNavigationConfig()), + pActiveShell(0), + pConfig(SW_MOD()->GetNavigationConfig()), nActiveBlock(0), - nHiddenBlock(0), + nHiddenBlock(0), nRootType(USHRT_MAX), nLastSelType(USHRT_MAX), @@ -2929,6 +2930,7 @@ void SwContentTree::EditEntry(SvLBoxEntry* pEntry, sal_uInt8 nMode) break; case CONTENT_TYPE_POSTIT: + pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell(); if(nMode == EDIT_MODE_DELETE) { if (((SwPostItContent*)pCnt)->IsPostIt()) @@ -3097,6 +3099,7 @@ void SwContentTree::GotoContent(SwContent* pCnt) } break; case CONTENT_TYPE_POSTIT: + pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell(); if (((SwPostItContent*)pCnt)->IsPostIt()) pActiveShell->GotoFld(*((SwPostItContent*)pCnt)->GetPostIt()); else diff --git a/sw/source/ui/utlui/initui.cxx b/sw/source/ui/utlui/initui.cxx index aca79b9e1c..9f90efe028 100644 --- a/sw/source/ui/utlui/initui.cxx +++ b/sw/source/ui/utlui/initui.cxx @@ -54,6 +54,7 @@ #ifndef _DBMGR_HXX #include <dbmgr.hxx> #endif +#include <svtools/syslocale.hxx> #include <unomid.h> @@ -261,7 +262,7 @@ ImpAutoFmtNameListLoader::ImpAutoFmtNameListLoader( SvStringsDtor& rLst ) p->SearchAndReplace(C2S("%1"), C2S(",,")); p->SearchAndReplace(C2S("%2"), C2S("''")); #else - LocaleDataWrapper& rLclD = GetAppLocaleData(); + const LocaleDataWrapper& rLclD = SvtSysLocale().GetLocaleData(); //unter richtigen Betriebssystemen funktioniert es auch so p->SearchAndReplace(C2S("%1"), rLclD.getDoubleQuotationMarkStart()); p->SearchAndReplace(C2S("%2"), rLclD.getDoubleQuotationMarkEnd()); diff --git a/sw/source/ui/utlui/numfmtlb.cxx b/sw/source/ui/utlui/numfmtlb.cxx index 18f57d6ec1..d6ea01d58b 100644 --- a/sw/source/ui/utlui/numfmtlb.cxx +++ b/sw/source/ui/utlui/numfmtlb.cxx @@ -120,7 +120,7 @@ void NumFormatListBox::Init(short nFormatType, BOOL bUsrFmts) if (pView) eCurLanguage = pView->GetWrtShell().GetCurLang(); else - eCurLanguage = SvxLocaleToLanguage( GetAppLocaleData().getLocale() ); + eCurLanguage = SvxLocaleToLanguage( SvtSysLocale().GetLocaleData().getLocale() ); if (bUsrFmts == FALSE) { diff --git a/sw/source/ui/utlui/uitool.cxx b/sw/source/ui/utlui/uitool.cxx index ec6d4a7a64..e9dcc6785a 100644 --- a/sw/source/ui/utlui/uitool.cxx +++ b/sw/source/ui/utlui/uitool.cxx @@ -39,6 +39,7 @@ #include <unotools/collatorwrapper.hxx> #include <svtools/urihelper.hxx> #include <svtools/stritem.hxx> +#include <svtools/syslocale.hxx> #include <sfx2/app.hxx> #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> @@ -732,7 +733,7 @@ SwTwips GetTableWidth( SwFrmFmt* pFmt, SwTabCols& rCols, USHORT *pPercent, String GetAppLangDateTimeString( const DateTime& rDT ) { - LocaleDataWrapper& rAppLclData = GetAppLocaleData(); + const LocaleDataWrapper& rAppLclData = SvtSysLocale().GetLocaleData(); String sRet( rAppLclData.getDate( rDT )); ( sRet += ' ' ) += rAppLclData.getTime( rDT, FALSE, FALSE ); return sRet; diff --git a/sw/source/ui/utlui/utlui.src b/sw/source/ui/utlui/utlui.src index 7a45772630..34d9186fa6 100644 --- a/sw/source/ui/utlui/utlui.src +++ b/sw/source/ui/utlui/utlui.src @@ -226,7 +226,7 @@ String STR_CONTENT_TYPE_DRAWOBJECT }; String STR_CONTENT_TYPE_POSTIT { - Text [ en-US ] = "Notes" ; + Text [ en-US ] = "Comments" ; }; String STR_CONTENT_TYPE_SINGLE_OUTLINE { @@ -270,7 +270,7 @@ String STR_CONTENT_TYPE_SINGLE_INDEX }; String STR_CONTENT_TYPE_SINGLE_POSTIT { - Text [ en-US ] = "Note" ; + Text [ en-US ] = "Comment" ; }; String STR_CONTENT_TYPE_SINGLE_DRAWOBJECT { diff --git a/sw/source/ui/wrtsh/select.cxx b/sw/source/ui/wrtsh/select.cxx index ffca2d74eb..21f1882f9e 100644 --- a/sw/source/ui/wrtsh/select.cxx +++ b/sw/source/ui/wrtsh/select.cxx @@ -73,6 +73,13 @@ using namespace ::com::sun::star::util; static long nStartDragX = 0, nStartDragY = 0; static BOOL bStartDrag = FALSE; +void SwWrtShell::Invalidate() +{ + // to avoid making the slot volatile, invalidate it everytime if something could have been changed + // this is still much cheaper than asking for the state every 200 ms (and avoid background processing) + GetView().GetViewFrame()->GetBindings().Invalidate( FN_STAT_SELMODE ); +} + BOOL SwWrtShell::SelNearestWrd() { MV_KONTEXT(this); @@ -336,6 +343,7 @@ void SwWrtShell::UnSelectFrm() // Rahmenselektion aufheben mit garantiert ungueltiger Position Point aPt(LONG_MIN, LONG_MIN); SelectObj(aPt, 0); + GetView().LeaveDrawCreate(); SwTransferable::ClearSelection( *this ); } @@ -374,6 +382,7 @@ long SwWrtShell::ResetSelect(const Point *,BOOL) */ GetChgLnk().Call(this); } + Invalidate(); SwTransferable::ClearSelection( *this ); return 1; } @@ -408,6 +417,7 @@ void SwWrtShell::SttSelect() fnKillSel = &SwWrtShell::Ignore; fnSetCrsr = &SwWrtShell::SetCrsr; bInSelect = TRUE; + Invalidate(); SwTransferable::CreateSelection( *this ); } /* @@ -576,6 +586,7 @@ void SwWrtShell::EnterStdMode() fnKillSel = &SwWrtShell::ResetSelect; } } + Invalidate(); SwTransferable::ClearSelection( *this ); } @@ -654,6 +665,7 @@ void SwWrtShell::EnterAddMode() bExtMode = FALSE; if(SwCrsrShell::HasSelection()) CreateCrsr(); + Invalidate(); } @@ -664,6 +676,7 @@ void SwWrtShell::LeaveAddMode() fnKillSel = &SwWrtShell::ResetSelect; fnSetCrsr = &SwWrtShell::SetCrsrKillSel; bAddMode = FALSE; + Invalidate(); } /* @@ -676,6 +689,7 @@ void SwWrtShell::EnterBlockMode() EnterStdMode(); bBlockMode = TRUE; CrsrToBlockCrsr(); + Invalidate(); } @@ -685,6 +699,7 @@ void SwWrtShell::LeaveBlockMode() bBlockMode = FALSE; BlockCrsrToCrsr(); EndSelect(); + Invalidate(); } // Einfuegemodus @@ -699,6 +714,7 @@ void SwWrtShell::SetInsMode( BOOL bOn ) GetView().GetViewFrame()->GetBindings().SetState( aTmp ); StartAction(); EndAction(); + Invalidate(); } //Overwrite mode is incompatible with red-lining void SwWrtShell::SetRedlineModeAndCheckInsMode( USHORT eMode ) @@ -743,6 +759,7 @@ void SwWrtShell::EnterSelFrmMode(const Point *pPos) fnDrag = &SwWrtShell::BeginFrmDrag; fnEndDrag = &SwWrtShell::UpdateLayoutFrm; SwBaseShell::SetFrmMode( FLY_DRAG_START, this ); + Invalidate(); } @@ -755,6 +772,7 @@ void SwWrtShell::LeaveSelFrmMode() bStartDrag = FALSE; Edit(); SwBaseShell::SetFrmMode( FLY_DRAG_END, this ); + Invalidate(); } /*------------------------------------------------------------------------ Beschreibung: Rahmengebundenes Macro ausfuehren @@ -798,6 +816,7 @@ long SwWrtShell::UpdateLayoutFrm(const Point *pPt, BOOL ) long SwWrtShell::ToggleAddMode() { bAddMode ? LeaveAddMode(): EnterAddMode(); + Invalidate(); return !bAddMode; } @@ -805,6 +824,7 @@ long SwWrtShell::ToggleAddMode() long SwWrtShell::ToggleBlockMode() { bBlockMode ? LeaveBlockMode(): EnterBlockMode(); + Invalidate(); return !bBlockMode; } @@ -812,6 +832,7 @@ long SwWrtShell::ToggleBlockMode() long SwWrtShell::ToggleExtMode() { bExtMode ? LeaveExtMode() : EnterExtMode(); + Invalidate(); return !bExtMode; } /* diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx index 3e8b72843b..6294722f46 100644 --- a/sw/source/ui/wrtsh/wrtsh1.cxx +++ b/sw/source/ui/wrtsh/wrtsh1.cxx @@ -70,7 +70,6 @@ #include <svx/extrusionbar.hxx> #include <svx/fontworkbar.hxx> #include <fmtftn.hxx> -#include <fmthbsh.hxx> #include <fmtpdsc.hxx> #ifndef _WDOCSH_HXX #include <wdocsh.hxx> @@ -245,6 +244,7 @@ void SwWrtShell::Insert( const String &rStr ) BOOL bStarted = FALSE, bHasSel = HasSelection(), bCallIns = bIns /*|| bHasSel*/; + bool bDeleted = false; if( bHasSel || ( !bIns && SelectHiddenRange() ) ) { @@ -268,7 +268,7 @@ void SwWrtShell::Insert( const String &rStr ) StartUndo(UNDO_REPLACE, &aRewriter); bStarted = TRUE; - DelRight(); + bDeleted = DelRight() != 0; } /* @@ -283,7 +283,8 @@ JP 21.01.98: Ueberschreiben ueberschreibt nur die Selektion, nicht das } else */ - bCallIns ? SwEditShell::Insert( rStr ) : SwEditShell::Overwrite( rStr ); + bCallIns ? + SwEditShell::Insert2( rStr, bDeleted ) : SwEditShell::Overwrite( rStr ); if( bStarted ) @@ -669,10 +670,10 @@ void SwWrtShell::MoveObjectIfActive( svt::EmbeddedObjectRef& xObj, const Point& try { sal_Int32 nState = xObj->getCurrentState(); - if ( nState == ::com::sun::star::embed::EmbedStates::INPLACE_ACTIVE + if ( nState == ::com::sun::star::embed::EmbedStates::INPLACE_ACTIVE || nState == ::com::sun::star::embed::EmbedStates::UI_ACTIVE ) { - SfxInPlaceClient* pCli = + SfxInPlaceClient* pCli = GetView().FindIPClient( xObj.GetObject(), &(GetView().GetEditWin()) ); if ( pCli ) { @@ -1103,7 +1104,7 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) pDoc->FindNumRulePtr(pColl->GetNumRule( FALSE ).GetValue()); if ( !pDirectCollRule ) { - pCollRule = 0L; + pCollRule = 0; } } // --> OD 2006-11-20 #i71764# @@ -1141,12 +1142,9 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) { // check, if numbering of the outline level of the pararaph // style is active. If not, activate this outline level. - //nActivateOutlineLvl = pColl->GetOutlineLevel(); //#outline level,zhaojianwei - //ASSERT( /*nActivateOutlineLvl >= 0 &&*/ nActivateOutlineLvl < MAXLEVEL, nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel(); ASSERT( pColl->IsAssignedToListLevelOfOutlineStyle(), //<-end,zhaojianwei "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" ); - //if ( /*nActivateOutlineLvl >= 0 &&*/ nActivateOutlineLvl < MAXLEVEL && //#outline level,zhaojianwei if ( pColl->IsAssignedToListLevelOfOutlineStyle() && //<-end,zhaojianwei pCollRule->Get( static_cast<USHORT>(nActivateOutlineLvl) ).GetNumberingType() == SVX_NUM_NUMBER_NONE ) @@ -1162,31 +1160,40 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) } else { + // --> OD 2009-08-27 #i101234# // activate outline numbering, because from the precondition // it's known, that <SwEdit::HasNumber()> == FALSE bActivateOutlineRule = true; - //nActivateOutlineLvl = pColl->GetOutlineLevel(); //#outline level,zhaojianwei nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei } } else if ( !pNumRule ) { - // activate outline numbering, because from the precondition - // it's known, that <SwEdit::HasNumber()> == FALSE - bActivateOutlineRule = true; - //nActivateOutlineLvl = pColl->GetOutlineLevel(); //#outline level,zhaojianwei + // --> OD 2009-08-27 #i101234# + // Check, if corresponding list level of the outline numbering + // has already a numbering format set. nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei,need further consideration + if ( pCollRule->Get( static_cast<USHORT>(nActivateOutlineLvl) ).GetNumberingType() + == SVX_NUM_NUMBER_NONE ) + { + // activate outline numbering, because from the precondition + // it's known, that <SwEdit::HasNumber()> == FALSE + bActivateOutlineRule = true; + } + else + { + // turning on outline numbering at current cursor position + bContinueFoundNumRule = true; + } + // <-- } else { // check, if numbering of the outline level of the pararaph // style is active. If not, activate this outline level. - //nActivateOutlineLvl = pColl->GetOutlineLevel(); nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//#outline level,zhaojianwei - //ASSERT( /*nActivateOutlineLvl >= 0 &&*/ nActivateOutlineLvl < MAXLEVEL, ASSERT( pColl->IsAssignedToListLevelOfOutlineStyle(),//#outline level,zhaojianwei "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" ); - //if ( /*nActivateOutlineLvl >= 0 &&*/ nActivateOutlineLvl < MAXLEVEL && if ( pColl->IsAssignedToListLevelOfOutlineStyle() &&//#outline level,zhaojianwei pCollRule->Get( static_cast<USHORT>(nActivateOutlineLvl) ).GetNumberingType() == SVX_NUM_NUMBER_NONE ) @@ -1212,12 +1219,12 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) { if ( !pNumRule->IsAutoRule() ) { - pNumRule = 0L; + pNumRule = 0; } else if ( pNumRule == GetDoc()->GetOutlineNumRule() && !bActivateOutlineRule && !bContinueFoundNumRule ) { - pNumRule = 0L; + pNumRule = 0; } } // <-- @@ -1229,7 +1236,7 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) if ( !pNumRule ) { pNumRule = GetDoc()->SearchNumRule( *GetCrsr()->GetPoint(), - FALSE, bNum, FALSE, 0, + false, bNum, false, 0, sContinuedListId ); bContinueFoundNumRule = pNumRule != 0; } @@ -1290,11 +1297,12 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) } else { + // --> OD 2009-08-27 #i95907# + const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode( + numfunc::GetDefaultPositionAndSpaceMode() ); // --> OD 2008-02-11 #newlistlevelattrs# - SwNumRule aNumRule( GetUniqueNumRuleName(), - // --> OD 2008-06-06 #i89178# - numfunc::GetDefaultPositionAndSpaceMode() ); - // <-- + SwNumRule aNumRule( GetUniqueNumRuleName(), ePosAndSpaceMode ); + // <-- // <-- // Zeichenvorlage an die Numerierung haengen SwCharFmt* pChrFmt; @@ -1315,9 +1323,10 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) pChrFmt = GetCharFmtFromPool( RES_POOLCHR_BUL_LEVEL ); } - SwTxtNode * pTxtNode = - GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode(); - USHORT nWidthOfTabs = pTxtNode->GetWidthOfLeadingTabs(); + const SwTxtNode* pTxtNode = GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode(); + const SwTwips nWidthOfTabs = pTxtNode + ? pTxtNode->GetWidthOfLeadingTabs() + : 0; GetDoc()->RemoveLeadingWhiteSpace( *GetCrsr()->GetPoint() ); const bool bHtml = 0 != PTR_CAST(SwWebDocShell, pDocSh); @@ -1339,16 +1348,21 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL); } - if(bHtml && nLvl) - { - // 1/2" fuer HTML - aFmt.SetLSpace(720); - aFmt.SetAbsLSpace(nLvl * 720); - } - else if ( nWidthOfTabs > 0 ) + // --> OD 2009-08-26 #i95907# + if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { - aFmt.SetAbsLSpace(nWidthOfTabs + nLvl * 720); + if(bHtml && nLvl) + { + // 1/2" fuer HTML + aFmt.SetLSpace(720); + aFmt.SetAbsLSpace(nLvl * 720); + } + else if ( nWidthOfTabs > 0 ) + { + aFmt.SetAbsLSpace(nWidthOfTabs + nLvl * 720); + } } + // <-- // --> FME 2005-01-21 #i38904# Default alignment for // numbering/bullet should be rtl in rtl paragraph: @@ -1361,6 +1375,21 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) aNumRule.Set( nLvl, aFmt ); } + // --> OD 2009-08-26 #i95907# + if ( pTxtNode && + ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT ) + { + short nTxtNodeFirstLineOffset( 0 ); + pTxtNode->GetFirstLineOfsWithNum( nTxtNodeFirstLineOffset ); + const SwTwips nTxtNodeIndent = pTxtNode->GetLeftMarginForTabCalculation() + + nTxtNodeFirstLineOffset; + if ( ( nTxtNodeIndent + nWidthOfTabs ) != 0 ) + { + const SwTwips nIndentChange = nTxtNodeIndent + nWidthOfTabs; + aNumRule.ChangeIndent( nIndentChange ); + } + } + // <-- // --> OD 2008-02-08 #newlistlevelattrs# // reset indent attribute on applying list style // --> OD 2008-03-17 #refactorlists# diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx index 28fd1b6934..0927372db9 100644 --- a/sw/source/ui/wrtsh/wrtsh2.cxx +++ b/sw/source/ui/wrtsh/wrtsh2.cxx @@ -93,10 +93,13 @@ void SwWrtShell::Insert(SwField &rFld) StartUndo(UNDO_INSERT, &aRewriter); + bool bDeleted = false; if( HasSelection() ) - DelRight(); + { + bDeleted = DelRight() != 0; + } - SwEditShell::Insert(rFld); + SwEditShell::Insert2(rFld, bDeleted); EndUndo(UNDO_INSERT); EndAllAction(); } |