diff options
Diffstat (limited to 'editeng/source/editeng/impedit4.cxx')
-rw-r--r-- | editeng/source/editeng/impedit4.cxx | 940 |
1 files changed, 510 insertions, 430 deletions
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index e42a36c5e826..121259f7e394 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -18,11 +18,10 @@ */ -#include <vcl/svapp.hxx> - #include <svl/srchitem.hxx> -#include <editeng/lspcitem.hxx> #include <editeng/adjustitem.hxx> +#include <editeng/cmapitem.hxx> +#include <editeng/lspcitem.hxx> #include <editeng/tstpitem.hxx> #include "eertfpar.hxx" @@ -35,6 +34,7 @@ #include <sal/log.hxx> #include <o3tl/safeint.hxx> #include <osl/diagnose.h> +#include <osl/thread.h> #include <editxml.hxx> @@ -73,6 +73,7 @@ #include <svtools/rtfkeywd.hxx> #include <editeng/edtdlg.hxx> +#include <cstddef> #include <memory> #include <unordered_map> #include <vector> @@ -85,8 +86,7 @@ using namespace ::com::sun::star::linguistic2; EditPaM ImpEditEngine::Read(SvStream& rInput, const OUString& rBaseURL, EETextFormat eFormat, const EditSelection& rSel, SvKeyValueIterator* pHTTPHeaderAttrs) { - bool _bUpdate = GetUpdateMode(); - SetUpdateMode( false ); + bool _bUpdate = SetUpdateLayout( false ); EditPaM aPaM; if ( eFormat == EETextFormat::Text ) aPaM = ReadText( rInput, rSel ); @@ -102,7 +102,7 @@ EditPaM ImpEditEngine::Read(SvStream& rInput, const OUString& rBaseURL, EETextFo } FormatFullDoc(); // perhaps a simple format is enough? - SetUpdateMode( _bUpdate ); + SetUpdateLayout( _bUpdate ); return aPaM; } @@ -117,10 +117,6 @@ EditPaM ImpEditEngine::ReadText( SvStream& rInput, EditSelection aSel ) bool bDone = rInput.ReadByteStringLine( aTmpStr, rInput.GetStreamCharSet() ); while ( bDone ) { - if (aTmpStr.getLength() > MAXCHARSINPARA) - { - aTmpStr = aTmpStr.copy(0, MAXCHARSINPARA); - } aPaM = ImpInsertText( EditSelection( aPaM, aPaM ), aTmpStr ); aPaM = ImpInsertParaBreak( aPaM ); bDone = rInput.ReadByteStringLine( aTmpStr, rInput.GetStreamCharSet() ); @@ -145,17 +141,16 @@ EditPaM ImpEditEngine::ReadRTF( SvStream& rInput, EditSelection aSel ) // The SvRTF parser expects the Which-mapping passed on in the pool, not // dependent on a secondary. - SfxItemPool* pPool = &aEditDoc.GetItemPool(); + SfxItemPool* pPool = &maEditDoc.GetItemPool(); while (pPool->GetSecondaryPool() && pPool->GetName() != "EditEngineItemPool") - { + { pPool = pPool->GetSecondaryPool(); - } DBG_ASSERT(pPool && pPool->GetName() == "EditEngineItemPool", "ReadRTF: no EditEnginePool!"); - EditRTFParserRef xPrsr = new EditRTFParser(rInput, aSel, *pPool, pEditEngine); + EditRTFParserRef xPrsr = new EditRTFParser(rInput, aSel, *pPool, mpEditEngine); SvParserState eState = xPrsr->CallParser(); if ( ( eState != SvParserState::Accepted ) && ( !rInput.GetError() ) ) { @@ -171,7 +166,7 @@ EditPaM ImpEditEngine::ReadHTML( SvStream& rInput, const OUString& rBaseURL, Edi aSel = ImpDeleteSelection( aSel ); EditHTMLParserRef xPrsr = new EditHTMLParser( rInput, rBaseURL, pHTTPHeaderAttrs ); - SvParserState eState = xPrsr->CallParser(pEditEngine, aSel.Max()); + SvParserState eState = xPrsr->CallParser(mpEditEngine, aSel.Max()); if ( ( eState != SvParserState::Accepted ) && ( !rInput.GetError() ) ) { rInput.SetError( EE_READWRITE_WRONGFORMAT ); @@ -208,20 +203,20 @@ ErrCode ImpEditEngine::WriteText( SvStream& rOutput, EditSelection aSel ) bool bRange = aSel.HasRange(); if ( bRange ) { - aSel.Adjust( aEditDoc ); - nStartNode = aEditDoc.GetPos( aSel.Min().GetNode() ); - nEndNode = aEditDoc.GetPos( aSel.Max().GetNode() ); + aSel.Adjust( maEditDoc ); + nStartNode = maEditDoc.GetPos( aSel.Min().GetNode() ); + nEndNode = maEditDoc.GetPos( aSel.Max().GetNode() ); } else { nStartNode = 0; - nEndNode = aEditDoc.Count()-1; + nEndNode = maEditDoc.Count()-1; } // iterate over the paragraphs ... for ( sal_Int32 nNode = nStartNode; nNode <= nEndNode; nNode++ ) { - ContentNode* pNode = aEditDoc.GetObject( nNode ); + ContentNode* pNode = maEditDoc.GetObject( nNode ); DBG_ASSERT( pNode, "Node not found: Search&Replace" ); sal_Int32 nStartPos = 0; @@ -254,7 +249,7 @@ bool ImpEditEngine::WriteItemListAsRTF( ItemList& rLst, SvStream& rOutput, sal_I static void lcl_FindValidAttribs( ItemList& rLst, ContentNode* pNode, sal_Int32 nIndex, sal_uInt16 nScriptType ) { - sal_uInt16 nAttr = 0; + std::size_t nAttr = 0; EditCharAttrib* pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); while ( pAttr && ( pAttr->GetStart() <= nIndex ) ) { @@ -278,31 +273,31 @@ void ImpEditEngine::WriteXML(SvStream& rOutput, const EditSelection& rSel) ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) { - DBG_ASSERT( GetUpdateMode(), "WriteRTF for UpdateMode = sal_False!" ); + assert( IsUpdateLayout() && "WriteRTF for UpdateMode = sal_False!" ); CheckIdleFormatter(); if ( !IsFormatted() ) FormatDoc(); sal_Int32 nStartNode, nEndNode; - aSel.Adjust( aEditDoc ); + aSel.Adjust( maEditDoc ); - nStartNode = aEditDoc.GetPos( aSel.Min().GetNode() ); - nEndNode = aEditDoc.GetPos( aSel.Max().GetNode() ); + nStartNode = maEditDoc.GetPos( aSel.Min().GetNode() ); + nEndNode = maEditDoc.GetPos( aSel.Max().GetNode() ); // RTF header ... rOutput.WriteChar( '{' ) ; - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_RTF ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_RTF ); - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_ANSI ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_ANSI ); rtl_TextEncoding eDestEnc = RTL_TEXTENCODING_MS_1252; // Generate and write out Font table ... std::vector<std::unique_ptr<SvxFontItem>> aFontTable; // default font must be up front, so DEF font in RTF - aFontTable.emplace_back( new SvxFontItem( aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO ) ) ); - aFontTable.emplace_back( new SvxFontItem( aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO_CJK ) ) ); - aFontTable.emplace_back( new SvxFontItem( aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO_CTL ) ) ); + aFontTable.emplace_back( new SvxFontItem( maEditDoc.GetItemPool().GetUserOrPoolDefaultItem( EE_CHAR_FONTINFO ) ) ); + aFontTable.emplace_back( new SvxFontItem( maEditDoc.GetItemPool().GetUserOrPoolDefaultItem( EE_CHAR_FONTINFO_CJK ) ) ); + aFontTable.emplace_back( new SvxFontItem( maEditDoc.GetItemPool().GetUserOrPoolDefaultItem( EE_CHAR_FONTINFO_CTL ) ) ); for ( sal_uInt16 nScriptType = 0; nScriptType < 3; nScriptType++ ) { sal_uInt16 nWhich = EE_CHAR_FONTINFO; @@ -311,12 +306,14 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) else if ( nScriptType == 2 ) nWhich = EE_CHAR_FONTINFO_CTL; - for (const SfxPoolItem* pItem : aEditDoc.GetItemPool().GetItemSurrogates(nWhich)) + ItemSurrogates aSurrogates; + maEditDoc.GetItemPool().GetItemSurrogates(aSurrogates, nWhich); + for (const SfxPoolItem* pItem : aSurrogates) { SvxFontItem const*const pFontItem = static_cast<const SvxFontItem*>(pItem); bool bAlreadyExist = false; - sal_uLong nTestMax = nScriptType ? aFontTable.size() : 1; - for ( sal_uLong nTest = 0; !bAlreadyExist && ( nTest < nTestMax ); nTest++ ) + size_t nTestMax = nScriptType ? aFontTable.size() : 1; + for ( size_t nTest = 0; !bAlreadyExist && ( nTest < nTestMax ); nTest++ ) { bAlreadyExist = *aFontTable[ nTest ] == *pFontItem; } @@ -327,31 +324,31 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) } rOutput << endl; - rOutput.WriteChar( '{' ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FONTTBL ); + rOutput.WriteChar( '{' ).WriteOString( OOO_STRING_SVTOOLS_RTF_FONTTBL ); for ( std::vector<SvxFontItem*>::size_type j = 0; j < aFontTable.size(); j++ ) { SvxFontItem* pFontItem = aFontTable[ j ].get(); rOutput.WriteChar( '{' ); - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_F ); - rOutput.WriteUInt32AsString( j ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_F ); + rOutput.WriteNumberAsString( j ); switch ( pFontItem->GetFamily() ) { - case FAMILY_DONTKNOW: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FNIL ); + case FAMILY_DONTKNOW: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_FNIL ); break; - case FAMILY_DECORATIVE: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FDECOR ); + case FAMILY_DECORATIVE: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_FDECOR ); break; - case FAMILY_MODERN: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FMODERN ); + case FAMILY_MODERN: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_FMODERN ); break; - case FAMILY_ROMAN: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FROMAN ); + case FAMILY_ROMAN: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_FROMAN ); break; - case FAMILY_SCRIPT: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FSCRIPT ); + case FAMILY_SCRIPT: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_FSCRIPT ); break; - case FAMILY_SWISS: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FSWISS ); + case FAMILY_SWISS: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_FSWISS ); break; default: break; } - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FPRQ ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_FPRQ ); sal_uInt16 nVal = 0; switch( pFontItem->GetPitch() ) { @@ -360,18 +357,28 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) default: break; } - rOutput.WriteUInt32AsString( nVal ); + rOutput.WriteNumberAsString( nVal ); rtl_TextEncoding eChrSet = pFontItem->GetCharSet(); + // tdf#47679 OpenSymbol is not encoded in Symbol Encoding + // and anyway we always attempt to write as eDestEnc + // of RTL_TEXTENCODING_MS_1252 and pay no attention + // on export what encoding we claim to use for these + // fonts. + if (IsOpenSymbol(pFontItem->GetFamilyName())) + { + SAL_WARN_IF(eChrSet == RTL_TEXTENCODING_SYMBOL, "editeng", "OpenSymbol should not have charset of RTL_TEXTENCODING_SYMBOL in new documents"); + eChrSet = RTL_TEXTENCODING_UTF8; + } DBG_ASSERT( eChrSet != 9, "SystemCharSet?!" ); if( RTL_TEXTENCODING_DONTKNOW == eChrSet ) eChrSet = osl_getThreadTextEncoding(); - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FCHARSET ); - rOutput.WriteUInt32AsString( rtl_getBestWindowsCharsetFromTextEncoding( eChrSet ) ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_FCHARSET ); + rOutput.WriteNumberAsString( rtl_getBestWindowsCharsetFromTextEncoding( eChrSet ) ); rOutput.WriteChar( ' ' ); RTFOutFuncs::Out_String( rOutput, pFontItem->GetFamilyName(), eDestEnc ); - rOutput.WriteCharPtr( ";}" ); + rOutput.WriteOString( ";}" ); } rOutput.WriteChar( '}' ); rOutput << endl; @@ -380,12 +387,14 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) SvxColorList aColorList; // COL_AUTO should be the default color, always put it first aColorList.emplace_back(COL_AUTO); - SvxColorItem const& rDefault(aEditDoc.GetItemPool().GetDefaultItem(EE_CHAR_COLOR)); + SvxColorItem const& rDefault(maEditDoc.GetItemPool().GetUserOrPoolDefaultItem(EE_CHAR_COLOR)); if (rDefault.GetValue() != COL_AUTO) // is the default always AUTO? { aColorList.push_back(rDefault.GetValue()); } - for (const SfxPoolItem* pItem : aEditDoc.GetItemPool().GetItemSurrogates(EE_CHAR_COLOR)) + ItemSurrogates aSurrogates; + maEditDoc.GetItemPool().GetItemSurrogates(aSurrogates, EE_CHAR_COLOR); + for (const SfxPoolItem* pItem : aSurrogates) { auto pColorItem(dynamic_cast<SvxColorItem const*>(pItem)); if (pColorItem && pColorItem->GetValue() != COL_AUTO) // may be null! @@ -394,18 +403,18 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) } } - rOutput.WriteChar( '{' ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_COLORTBL ); + rOutput.WriteChar( '{' ).WriteOString( OOO_STRING_SVTOOLS_RTF_COLORTBL ); for ( SvxColorList::size_type j = 0; j < aColorList.size(); j++ ) { Color const color = aColorList[j]; if (color != COL_AUTO) // auto is represented by "empty" element { - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_RED ); - rOutput.WriteUInt32AsString( color.GetRed() ); - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_GREEN ); - rOutput.WriteUInt32AsString( color.GetGreen() ); - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_BLUE ); - rOutput.WriteUInt32AsString( color.GetBlue() ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_RED ); + rOutput.WriteNumberAsString( color.GetRed() ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_GREEN ); + rOutput.WriteNumberAsString( color.GetGreen() ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_BLUE ); + rOutput.WriteNumberAsString( color.GetBlue() ); } rOutput.WriteChar( ';' ); } @@ -431,16 +440,16 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) { sal_uInt32 nStyle = 0; - rOutput.WriteChar( '{' ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_STYLESHEET ); + rOutput.WriteChar( '{' ).WriteOString( OOO_STRING_SVTOOLS_RTF_STYLESHEET ); for ( SfxStyleSheetBase* pStyle = aSSSIterator->First(); pStyle; pStyle = aSSSIterator->Next() ) { rOutput << endl; - rOutput.WriteChar( '{' ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_S ); + rOutput.WriteChar( '{' ).WriteOString( OOO_STRING_SVTOOLS_RTF_S ); sal_uInt32 nNumber = nStyle + 1; - rOutput.WriteUInt32AsString( nNumber ); + rOutput.WriteNumberAsString( nNumber ); // Attribute, also from Parent! for ( sal_uInt16 nParAttr = EE_PARA_START; nParAttr <= EE_CHAR_END; nParAttr++ ) @@ -457,9 +466,11 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) { SfxStyleSheet* pParent = static_cast<SfxStyleSheet*>(GetStyleSheetPool()->Find( pStyle->GetParent(), pStyle->GetFamily() )); DBG_ASSERT( pParent, "Parent not found!" ); - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_SBASEDON ); - nNumber = aStyleSheetToIdMap.find(pParent)->second; - rOutput.WriteUInt32AsString( nNumber ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_SBASEDON ); + auto iter = aStyleSheetToIdMap.find(pParent); + assert(iter != aStyleSheetToIdMap.end()); + nNumber = iter->second; + rOutput.WriteNumberAsString( nNumber ); } // Next Style... (more) @@ -469,14 +480,16 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) pNext = static_cast<SfxStyleSheet*>(GetStyleSheetPool()->Find( pStyle->GetFollow(), pStyle->GetFamily() )); DBG_ASSERT( pNext, "Next not found!" ); - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_SNEXT ); - nNumber = aStyleSheetToIdMap.find(pNext)->second; - rOutput.WriteUInt32AsString( nNumber ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_SNEXT ); + auto iter = aStyleSheetToIdMap.find(pNext); + assert(iter != aStyleSheetToIdMap.end()); + nNumber = iter->second; + rOutput.WriteNumberAsString( nNumber ); // Name of the template... - rOutput.WriteCharPtr( " " ); + rOutput.WriteOString( " " ); RTFOutFuncs::Out_String( rOutput, pStyle->GetName(), eDestEnc ); - rOutput.WriteCharPtr( ";}" ); + rOutput.WriteOString( ";}" ); nStyle++; } rOutput.WriteChar( '}' ); @@ -485,10 +498,10 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) } // Write the pool defaults in advance ... - rOutput.WriteChar( '{' ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_IGNORE ).WriteCharPtr( "\\EditEnginePoolDefaults" ); + rOutput.WriteChar( '{' ).WriteOString( OOO_STRING_SVTOOLS_RTF_IGNORE ).WriteOString( "\\EditEnginePoolDefaults" ); for ( sal_uInt16 nPoolDefItem = EE_PARA_START; nPoolDefItem <= EE_CHAR_END; nPoolDefItem++) { - const SfxPoolItem& rItem = aEditDoc.GetItemPool().GetDefaultItem( nPoolDefItem ); + const SfxPoolItem& rItem = maEditDoc.GetItemPool().GetUserOrPoolDefaultItem( nPoolDefItem ); WriteItemAsRTF( rItem, rOutput, 0, 0, aFontTable, aColorList ); } rOutput.WriteChar( '}' ) << endl; @@ -496,17 +509,17 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) // DefTab: MapMode aTwpMode( MapUnit::MapTwip ); sal_uInt16 nDefTabTwps = static_cast<sal_uInt16>(GetRefDevice()->LogicToLogic( - Point( aEditDoc.GetDefTab(), 0 ), + Point( maEditDoc.GetDefTab(), 0 ), &GetRefMapMode(), &aTwpMode ).X()); - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_DEFTAB ); - rOutput.WriteUInt32AsString( nDefTabTwps ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_DEFTAB ); + rOutput.WriteNumberAsString( nDefTabTwps ); rOutput << endl; // iterate over the paragraphs ... rOutput.WriteChar( '{' ) << endl; for ( sal_Int32 nNode = nStartNode; nNode <= nEndNode; nNode++ ) { - ContentNode* pNode = aEditDoc.GetObject( nNode ); + ContentNode* pNode = maEditDoc.GetObject( nNode ); DBG_ASSERT( pNode, "Node not found: Search&Replace" ); // The paragraph attributes in advance ... @@ -516,9 +529,11 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) if ( pNode->GetStyleSheet() ) { // Number of template - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_S ); - sal_uInt32 nNumber = aStyleSheetToIdMap.find(pNode->GetStyleSheet())->second; - rOutput.WriteUInt32AsString( nNumber ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_S ); + auto iter = aStyleSheetToIdMap.find(pNode->GetStyleSheet()); + assert(iter != aStyleSheetToIdMap.end()); + sal_uInt32 nNumber = iter->second; + rOutput.WriteNumberAsString( nNumber ); // All Attribute // Attribute, also from Parent! @@ -639,12 +654,11 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) nIndex = nIndex + rTextPortion.GetLen(); } - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_PAR ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_PARD ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_PLAIN ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_PAR ).WriteOString( OOO_STRING_SVTOOLS_RTF_PARD ).WriteOString( OOO_STRING_SVTOOLS_RTF_PLAIN ); rOutput << endl; } // RTF-trailer ... - rOutput.WriteCharPtr( "}}" ); // 1xparentheses paragraphs, 1xparentheses RTF document - rOutput.Flush(); + rOutput.WriteOString( "}}" ); // 1xparentheses paragraphs, 1xparentheses RTF document aFontTable.clear(); @@ -662,9 +676,9 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, { const SvxFrameDirectionItem& rWritingMode = static_cast<const SvxFrameDirectionItem&>(rItem); if ( rWritingMode.GetValue() == SvxFrameDirection::Horizontal_RL_TB ) - rOutput.WriteCharPtr( "\\rtlpar" ); + rOutput.WriteOString( "\\rtlpar" ); else - rOutput.WriteCharPtr( "\\ltrpar" ); + rOutput.WriteOString( "\\ltrpar" ); } break; case EE_PARA_OUTLLEVEL: @@ -672,43 +686,43 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, sal_Int32 nLevel = static_cast<const SfxInt16Item&>(rItem).GetValue(); if( nLevel >= 0 ) { - rOutput.WriteCharPtr( "\\level" ); - rOutput.WriteInt32AsString( nLevel ); + rOutput.WriteOString( "\\level" ); + rOutput.WriteNumberAsString( nLevel ); } } break; case EE_PARA_OUTLLRSPACE: case EE_PARA_LRSPACE: { - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FI ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_FI ); sal_Int32 nTxtFirst = static_cast<const SvxLRSpaceItem&>(rItem).GetTextFirstLineOffset(); nTxtFirst = LogicToTwips( nTxtFirst ); - rOutput.WriteInt32AsString( nTxtFirst ); - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_LI ); + rOutput.WriteNumberAsString( nTxtFirst ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_LI ); sal_uInt32 nTxtLeft = static_cast< sal_uInt32 >(static_cast<const SvxLRSpaceItem&>(rItem).GetTextLeft()); nTxtLeft = static_cast<sal_uInt32>(LogicToTwips( nTxtLeft )); - rOutput.WriteInt32AsString( nTxtLeft ); - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_RI ); + rOutput.WriteNumberAsString( nTxtLeft ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_RI ); sal_uInt32 nTxtRight = static_cast<const SvxLRSpaceItem&>(rItem).GetRight(); nTxtRight = LogicToTwips( nTxtRight); - rOutput.WriteUInt32AsString( nTxtRight ); + rOutput.WriteNumberAsString( nTxtRight ); } break; case EE_PARA_ULSPACE: { - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_SB ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_SB ); sal_uInt32 nUpper = static_cast<const SvxULSpaceItem&>(rItem).GetUpper(); nUpper = static_cast<sal_uInt32>(LogicToTwips( nUpper )); - rOutput.WriteUInt32AsString( nUpper ); - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_SA ); + rOutput.WriteNumberAsString( nUpper ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_SA ); sal_uInt32 nLower = static_cast<const SvxULSpaceItem&>(rItem).GetLower(); nLower = LogicToTwips( nLower ); - rOutput.WriteUInt32AsString( nLower ); + rOutput.WriteNumberAsString( nLower ); } break; case EE_PARA_SBL: { - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_SL ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_SL ); sal_Int32 nVal = static_cast<const SvxLineSpacingItem&>(rItem).GetLineHeight(); char cMult = '0'; if ( static_cast<const SvxLineSpacingItem&>(rItem).GetInterLineSpaceRule() == SvxInterLineSpaceRule::Prop ) @@ -720,8 +734,8 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, nVal /= 100; cMult = '1'; } - rOutput.WriteInt32AsString( nVal ); - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_SLMULT ).WriteChar( cMult ); + rOutput.WriteNumberAsString( nVal ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_SLMULT ).WriteChar( cMult ); } break; case EE_PARA_JUST: @@ -729,11 +743,11 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, SvxAdjust eJustification = static_cast<const SvxAdjustItem&>(rItem).GetAdjust(); switch ( eJustification ) { - case SvxAdjust::Center: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_QC ); + case SvxAdjust::Center: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_QC ); break; - case SvxAdjust::Right: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_QR ); + case SvxAdjust::Right: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_QR ); break; - default: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_QL ); + default: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_QL ); break; } } @@ -744,8 +758,8 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, for ( sal_uInt16 i = 0; i < rTabs.Count(); i++ ) { const SvxTabStop& rTab = rTabs[i]; - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_TX ); - rOutput.WriteInt32AsString( LogicToTwips( rTab.GetTabPos() ) ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_TX ); + rOutput.WriteNumberAsString( LogicToTwips( rTab.GetTabPos() ) ); } } break; @@ -756,8 +770,8 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, static_cast<SvxColorItem const&>(rItem).GetValue()); assert(iter != rColorList.end()); sal_uInt32 const n = iter - rColorList.begin(); - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_CF ); - rOutput.WriteUInt32AsString( n ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_CF ); + rOutput.WriteNumberAsString( n ); } break; case EE_CHAR_FONTINFO: @@ -774,20 +788,20 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, } } - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_F ); - rOutput.WriteUInt32AsString( n ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_F ); + rOutput.WriteNumberAsString( n ); } break; case EE_CHAR_FONTHEIGHT: case EE_CHAR_FONTHEIGHT_CJK: case EE_CHAR_FONTHEIGHT_CTL: { - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FS ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_FS ); sal_Int32 nHeight = static_cast<const SvxFontHeightItem&>(rItem).GetHeight(); nHeight = LogicToTwips( nHeight ); // Twips => HalfPoints nHeight /= 10; - rOutput.WriteInt32AsString( nHeight ); + rOutput.WriteNumberAsString( nHeight ); } break; case EE_CHAR_WEIGHT: @@ -797,8 +811,8 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, FontWeight e = static_cast<const SvxWeightItem&>(rItem).GetWeight(); switch ( e ) { - case WEIGHT_BOLD: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_B ); break; - default: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_B ).WriteChar( '0' ); break; + case WEIGHT_BOLD: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_B ); break; + default: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_B ).WriteChar( '0' ); break; } } break; @@ -809,10 +823,10 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, FontLineStyle e = static_cast<const SvxUnderlineItem&>(rItem).GetLineStyle(); switch ( e ) { - case LINESTYLE_NONE: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_ULNONE ); break; - case LINESTYLE_SINGLE: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_UL ); break; - case LINESTYLE_DOUBLE: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_ULDB ); break; - case LINESTYLE_DOTTED: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_ULD ); break; + case LINESTYLE_NONE: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_ULNONE ); break; + case LINESTYLE_SINGLE: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_UL ); break; + case LINESTYLE_DOUBLE: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_ULDB ); break; + case LINESTYLE_DOTTED: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_ULD ); break; default: break; } @@ -823,10 +837,10 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, FontLineStyle e = static_cast<const SvxOverlineItem&>(rItem).GetLineStyle(); switch ( e ) { - case LINESTYLE_NONE: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_OLNONE ); break; - case LINESTYLE_SINGLE: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_OL ); break; - case LINESTYLE_DOUBLE: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_OLDB ); break; - case LINESTYLE_DOTTED: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_OLD ); break; + case LINESTYLE_NONE: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_OLNONE ); break; + case LINESTYLE_SINGLE: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_OL ); break; + case LINESTYLE_DOUBLE: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_OLDB ); break; + case LINESTYLE_DOTTED: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_OLD ); break; default: break; } @@ -838,8 +852,8 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, switch ( e ) { case STRIKEOUT_SINGLE: - case STRIKEOUT_DOUBLE: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_STRIKE ); break; - case STRIKEOUT_NONE: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_STRIKE ).WriteChar( '0' ); break; + case STRIKEOUT_DOUBLE: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_STRIKE ); break; + case STRIKEOUT_NONE: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_STRIKE ).WriteChar( '0' ); break; default: break; } @@ -853,8 +867,8 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, switch ( e ) { case ITALIC_OBLIQUE: - case ITALIC_NORMAL: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_I ); break; - case ITALIC_NONE: rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_I ).WriteChar( '0' ); break; + case ITALIC_NORMAL: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_I ); break; + case ITALIC_NONE: rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_I ).WriteChar( '0' ); break; default: break; } @@ -862,7 +876,7 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, break; case EE_CHAR_OUTLINE: { - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_OUTL ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_OUTL ); if ( !static_cast<const SvxContourItem&>(rItem).GetValue() ) rOutput.WriteChar( '0' ); } @@ -871,56 +885,56 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, { FontRelief nRelief = static_cast<const SvxCharReliefItem&>(rItem).GetValue(); if ( nRelief == FontRelief::Embossed ) - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_EMBO ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_EMBO ); if ( nRelief == FontRelief::Engraved ) - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_IMPR ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_IMPR ); } break; case EE_CHAR_EMPHASISMARK: { FontEmphasisMark nMark = static_cast<const SvxEmphasisMarkItem&>(rItem).GetEmphasisMark(); if ( nMark == FontEmphasisMark::NONE ) - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_ACCNONE ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_ACCNONE ); else if ( nMark == (FontEmphasisMark::Accent | FontEmphasisMark::PosAbove) ) - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_ACCCOMMA ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_ACCCOMMA ); else - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_ACCDOT ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_ACCDOT ); } break; case EE_CHAR_SHADOW: { - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_SHAD ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_SHAD ); if ( !static_cast<const SvxShadowedItem&>(rItem).GetValue() ) rOutput.WriteChar( '0' ); } break; case EE_FEATURE_TAB: { - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_TAB ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_TAB ); } break; case EE_FEATURE_LINEBR: { - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_SL ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_LINE ); } break; case EE_CHAR_KERNING: { - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_EXPNDTW ); - rOutput.WriteInt32AsString( LogicToTwips( + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_EXPNDTW ); + rOutput.WriteNumberAsString( LogicToTwips( static_cast<const SvxKerningItem&>(rItem).GetValue() ) ); } break; case EE_CHAR_PAIRKERNING: { - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_KERNING ); - rOutput.WriteUInt32AsString( static_cast<const SvxAutoKernItem&>(rItem).GetValue() ? 1 : 0 ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_KERNING ); + rOutput.WriteNumberAsString( static_cast<const SvxAutoKernItem&>(rItem).GetValue() ? 1 : 0 ); } break; case EE_CHAR_ESCAPEMENT: { SvxFont aFont; - ContentNode* pNode = aEditDoc.GetObject( nPara ); + ContentNode* pNode = maEditDoc.GetObject( nPara ); SeekCursor( pNode, nPos, aFont ); MapMode aPntMode( MapUnit::MapPoint ); tools::Long nFontHeight = GetRefDevice()->LogicToLogic( @@ -951,15 +965,35 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, // SWG: if ( nEsc ) { - rOutput.WriteCharPtr( "{\\*\\updnprop" ).WriteCharPtr( OString::number( - nProp100).getStr() ).WriteChar( '}' ); + rOutput.WriteOString( "{\\*\\updnprop" ).WriteNumberAsString( + nProp100 ).WriteChar( '}' ); } tools::Long nUpDown = nFontHeight * std::abs( nEsc ) / 100; if ( nEsc < 0 ) - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_DN ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_DN ); else if ( nEsc > 0 ) - rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_UP ); - rOutput.WriteOString( OString::number(nUpDown) ); + rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_UP ); + rOutput.WriteNumberAsString(nUpDown); + } + break; + case EE_CHAR_CASEMAP: + { + const SvxCaseMapItem& rCaseMap = static_cast<const SvxCaseMapItem&>(rItem); + switch (rCaseMap.GetValue()) + { + case SvxCaseMap::SmallCaps: + rOutput.WriteOString(OOO_STRING_SVTOOLS_RTF_SCAPS); + break; + case SvxCaseMap::Uppercase: + rOutput.WriteOString(OOO_STRING_SVTOOLS_RTF_CAPS); + break; + default: // Something that rtf does not support + rOutput.WriteOString(OOO_STRING_SVTOOLS_RTF_SCAPS); + rOutput.WriteNumberAsString(0); + rOutput.WriteOString(OOO_STRING_SVTOOLS_RTF_CAPS); + rOutput.WriteNumberAsString(0); + break; + } } break; } @@ -968,8 +1002,8 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, std::unique_ptr<EditTextObject> ImpEditEngine::GetEmptyTextObject() { EditSelection aEmptySel; - aEmptySel.Min() = aEditDoc.GetStartPaM(); - aEmptySel.Max() = aEditDoc.GetStartPaM(); + aEmptySel.Min() = maEditDoc.GetStartPaM(); + aEmptySel.Max() = maEditDoc.GetStartPaM(); return CreateTextObject( aEmptySel ); } @@ -977,52 +1011,46 @@ std::unique_ptr<EditTextObject> ImpEditEngine::GetEmptyTextObject() std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject() { EditSelection aCompleteSelection; - aCompleteSelection.Min() = aEditDoc.GetStartPaM(); - aCompleteSelection.Max() = aEditDoc.GetEndPaM(); + aCompleteSelection.Min() = maEditDoc.GetStartPaM(); + aCompleteSelection.Max() = maEditDoc.GetEndPaM(); return CreateTextObject( aCompleteSelection ); } std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject(const EditSelection& rSel) { - return CreateTextObject(rSel, GetEditTextObjectPool(), aStatus.AllowBigObjects(), nBigTextObjectStart); + return CreateTextObject(rSel, GetEditTextObjectPool(), maStatus.AllowBigObjects(), mnBigTextObjectStart); } std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection aSel, SfxItemPool* pPool, bool bAllowBigObjects, sal_Int32 nBigObjectStart ) { - std::unique_ptr<EditTextObject> pTxtObj(new EditTextObject(pPool)); - pTxtObj->SetVertical( GetDirectVertical() ); - pTxtObj->SetRotation( GetRotation() ); - MapUnit eMapUnit = aEditDoc.GetItemPool().GetMetric( DEF_METRIC ); - pTxtObj->mpImpl->SetMetric( static_cast<sal_uInt16>(eMapUnit) ); - if ( pTxtObj->mpImpl->IsOwnerOfPool() ) - pTxtObj->mpImpl->GetPool()->SetDefaultMetric( eMapUnit ); - sal_Int32 nStartNode, nEndNode; sal_Int32 nTextPortions = 0; - aSel.Adjust( aEditDoc ); - nStartNode = aEditDoc.GetPos( aSel.Min().GetNode() ); - nEndNode = aEditDoc.GetPos( aSel.Max().GetNode() ); + aSel.Adjust( maEditDoc ); + nStartNode = maEditDoc.GetPos( aSel.Min().GetNode() ); + nEndNode = maEditDoc.GetPos( aSel.Max().GetNode() ); bool bOnlyFullParagraphs = !( aSel.Min().GetIndex() || ( aSel.Max().GetIndex() < aSel.Max().GetNode()->Len() ) ); // Templates are not saved! // (Only the name and family, template itself must be in App!) - pTxtObj->mpImpl->SetScriptType(GetItemScriptType(aSel)); + + const MapUnit eMapUnit = maEditDoc.GetItemPool().GetMetric(DEF_METRIC); + auto pTxtObj(std::make_unique<EditTextObjectImpl>(pPool, eMapUnit, GetVertical(), GetRotation(), + GetItemScriptType(aSel))); // iterate over the paragraphs ... sal_Int32 nNode; for ( nNode = nStartNode; nNode <= nEndNode; nNode++ ) { - ContentNode* pNode = aEditDoc.GetObject( nNode ); + ContentNode* pNode = maEditDoc.GetObject( nNode ); DBG_ASSERT( pNode, "Node not found: Search&Replace" ); if ( bOnlyFullParagraphs ) { - const ParaPortion* pParaPortion = GetParaPortions()[nNode]; - nTextPortions += pParaPortion->GetTextPortions().Count(); + nTextPortions += GetParaPortions().getRef(nNode).GetTextPortions().Count(); } sal_Int32 nStartPos = 0; @@ -1036,7 +1064,7 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a nEndPos = aSel.Max().GetIndex(); - ContentInfo *pC = pTxtObj->mpImpl->CreateAndInsertContent(); + ContentInfo *pC = pTxtObj->CreateAndInsertContent(); // The paragraph attributes ... pC->GetParaAttribs().Set( pNode->GetContentAttribs().GetItems() ); @@ -1053,32 +1081,31 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a auto& rCAttriblist = pC->GetCharAttribs(); // and the Attribute... - sal_uInt16 nAttr = 0; + std::size_t nAttr = 0; EditCharAttrib* pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); + rCAttriblist.reserve(rCAttriblist.size() + pNode->GetCharAttribs().GetAttribs().size()); while ( pAttr ) { // In a blank paragraph keep the attributes! if ( bEmptyPara || ( ( pAttr->GetEnd() > nStartPos ) && ( pAttr->GetStart() < nEndPos ) ) ) { - std::unique_ptr<XEditAttribute> pX = pTxtObj->mpImpl->CreateAttrib(*pAttr->GetItem(), pAttr->GetStart(), pAttr->GetEnd()); + XEditAttribute aX = pTxtObj->CreateAttrib(*pAttr->GetItem(), pAttr->GetStart(), pAttr->GetEnd()); // Possibly Correct ... if ( ( nNode == nStartNode ) && ( nStartPos != 0 ) ) { - pX->GetStart() = ( pX->GetStart() > nStartPos ) ? pX->GetStart()-nStartPos : 0; - pX->GetEnd() = pX->GetEnd() - nStartPos; + aX.GetStart() = ( aX.GetStart() > nStartPos ) ? aX.GetStart()-nStartPos : 0; + aX.GetEnd() = aX.GetEnd() - nStartPos; } if ( nNode == nEndNode ) { - if ( pX->GetEnd() > (nEndPos-nStartPos) ) - pX->GetEnd() = nEndPos-nStartPos; + if ( aX.GetEnd() > (nEndPos-nStartPos) ) + aX.GetEnd() = nEndPos-nStartPos; } - DBG_ASSERT( pX->GetEnd() <= (nEndPos-nStartPos), "CreateBinTextObject: Attribute too long!" ); - if ( !pX->GetLen() && !bEmptyPara ) - pTxtObj->mpImpl->DestroyAttrib(std::move(pX)); - else - rCAttriblist.push_back(std::move(pX)); + DBG_ASSERT( aX.GetEnd() <= (nEndPos-nStartPos), "CreateTextObject: Attribute too long!" ); + if ( aX.GetLen() || bEmptyPara ) + rCAttriblist.push_back(std::move(aX)); } nAttr++; pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); @@ -1092,45 +1119,46 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a // Remember the portions info in case of large text objects: // sleeper set up when Olli paragraphs not hacked! - if ( bAllowBigObjects && bOnlyFullParagraphs && IsFormatted() && GetUpdateMode() && ( nTextPortions >= nBigObjectStart ) ) + if ( bAllowBigObjects && bOnlyFullParagraphs && IsFormatted() && IsUpdateLayout() && ( nTextPortions >= nBigObjectStart ) ) { - XParaPortionList* pXList = new XParaPortionList( GetRefDevice(), aPaperSize.Width(), nStretchX, nStretchY ); - pTxtObj->mpImpl->SetPortionInfo(std::unique_ptr<XParaPortionList>(pXList)); + XParaPortionList* pXList = new XParaPortionList(GetRefDevice(), GetColumnWidth(maPaperSize), + maScalingParameters.fFontX, maScalingParameters.fFontY, + maScalingParameters.fSpacingX, maScalingParameters.fSpacingY); + pTxtObj->SetPortionInfo(std::unique_ptr<XParaPortionList>(pXList)); for ( nNode = nStartNode; nNode <= nEndNode; nNode++ ) { - const ParaPortion* pParaPortion = GetParaPortions()[nNode]; + ParaPortion const& rParaPortion = GetParaPortions().getRef(nNode); XParaPortion* pX = new XParaPortion; pXList->push_back(pX); - pX->nHeight = pParaPortion->GetHeight(); - pX->nFirstLineOffset = pParaPortion->GetFirstLineOffset(); + pX->nHeight = rParaPortion.GetHeight(); + pX->nFirstLineOffset = rParaPortion.GetFirstLineOffset(); // The TextPortions - sal_uInt16 nCount = pParaPortion->GetTextPortions().Count(); + sal_uInt16 nCount = rParaPortion.GetTextPortions().Count(); sal_uInt16 n; for ( n = 0; n < nCount; n++ ) { - const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[n]; + const TextPortion& rTextPortion = rParaPortion.GetTextPortions()[n]; TextPortion* pNew = new TextPortion( rTextPortion ); pX->aTextPortions.Append(pNew); } // The lines - nCount = pParaPortion->GetLines().Count(); + nCount = rParaPortion.GetLines().Count(); for ( n = 0; n < nCount; n++ ) { - const EditLine& rLine = pParaPortion->GetLines()[n]; - EditLine* pNew = rLine.Clone(); - pX->aLines.Append(pNew); + const EditLine& rLine = rParaPortion.GetLines()[n]; + pX->aLines.Append(std::unique_ptr<EditLine>(rLine.Clone())); } #ifdef DBG_UTIL sal_uInt16 nTest; int nTPLen = 0, nTxtLen = 0; - for ( nTest = pParaPortion->GetTextPortions().Count(); nTest; ) - nTPLen += pParaPortion->GetTextPortions()[--nTest].GetLen(); - for ( nTest = pParaPortion->GetLines().Count(); nTest; ) - nTxtLen += pParaPortion->GetLines()[--nTest].GetLen(); - DBG_ASSERT( ( nTPLen == pParaPortion->GetNode()->Len() ) && ( nTxtLen == pParaPortion->GetNode()->Len() ), "CreateBinTextObject: ParaPortion not completely formatted!" ); + for (nTest = rParaPortion.GetTextPortions().Count(); nTest;) + nTPLen += rParaPortion.GetTextPortions()[--nTest].GetLen(); + for (nTest = rParaPortion.GetLines().Count(); nTest; ) + nTxtLen += rParaPortion.GetLines()[--nTest].GetLen(); + DBG_ASSERT(nTPLen == rParaPortion.GetNode()->Len() && nTxtLen == rParaPortion.GetNode()->Len(), "CreateBinTextObject: ParaPortion not completely formatted!"); #endif } } @@ -1141,27 +1169,27 @@ void ImpEditEngine::SetText( const EditTextObject& rTextObject ) { // Since setting a text object is not undo-able! ResetUndoManager(); - bool _bUpdate = GetUpdateMode(); + bool _bUpdate = IsUpdateLayout(); bool _bUndo = IsUndoEnabled(); SetText( OUString() ); - EditPaM aPaM = aEditDoc.GetStartPaM(); + EditPaM aPaM = maEditDoc.GetStartPaM(); - SetUpdateMode( false ); + SetUpdateLayout( false ); EnableUndo( false ); InsertText( rTextObject, EditSelection( aPaM, aPaM ) ); - SetVertical(rTextObject.GetDirectVertical()); + SetVertical(rTextObject.GetVertical()); SetRotation(rTextObject.GetRotation()); DBG_ASSERT( !HasUndoManager() || !GetUndoManager().GetUndoActionCount(), "From where comes the Undo in SetText ?!" ); - SetUpdateMode( _bUpdate ); + SetUpdateLayout( _bUpdate ); EnableUndo( _bUndo ); } EditSelection ImpEditEngine::InsertText( const EditTextObject& rTextObject, EditSelection aSel ) { - aSel.Adjust( aEditDoc ); + aSel.Adjust( maEditDoc ); if ( aSel.HasRange() ) aSel = ImpDeleteSelection( aSel ); EditSelection aNewSel = InsertTextObject( rTextObject, aSel.Max() ); @@ -1172,15 +1200,18 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject { // Optimize: No getPos undFindParaportion, instead calculate index! EditSelection aSel( aPaM, aPaM ); - DBG_ASSERT( !aSel.DbgIsBuggy( aEditDoc ), "InsertBibTextObject: Selection broken!(1)" ); + DBG_ASSERT( !aSel.DbgIsBuggy( maEditDoc ), "InsertBibTextObject: Selection broken!(1)" ); bool bUsePortionInfo = false; - XParaPortionList* pPortionInfo = rTextObject.mpImpl->GetPortionInfo(); - - if ( pPortionInfo && ( static_cast<tools::Long>(pPortionInfo->GetPaperWidth()) == aPaperSize.Width() ) - && ( pPortionInfo->GetRefMapMode() == GetRefDevice()->GetMapMode() ) - && ( pPortionInfo->GetStretchX() == nStretchX ) - && ( pPortionInfo->GetStretchY() == nStretchY ) ) + const EditTextObjectImpl& rTextObjectImpl = toImpl(rTextObject); + XParaPortionList* pPortionInfo = rTextObjectImpl.GetPortionInfo(); + + if (pPortionInfo && ( static_cast<tools::Long>(pPortionInfo->GetPaperWidth()) == GetColumnWidth(maPaperSize)) + && pPortionInfo->GetRefMapMode() == GetRefDevice()->GetMapMode() + && pPortionInfo->getFontScaleX() == maScalingParameters.fFontX + && pPortionInfo->getFontScaleY() == maScalingParameters.fFontY + && pPortionInfo->getSpacingScaleX() == maScalingParameters.fSpacingX + && pPortionInfo->getSpacingScaleY() == maScalingParameters.fSpacingY) { if ( (pPortionInfo->GetRefDevPtr() == GetRefDevice()) || (pPortionInfo->RefDevIsVirtual() && GetRefDevice()->IsVirtual()) ) @@ -1189,10 +1220,10 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject bool bConvertMetricOfItems = false; MapUnit eSourceUnit = MapUnit(), eDestUnit = MapUnit(); - if (rTextObject.mpImpl->HasMetric()) + if (rTextObjectImpl.HasMetric()) { - eSourceUnit = static_cast<MapUnit>(rTextObject.mpImpl->GetMetric()); - eDestUnit = aEditDoc.GetItemPool().GetMetric( DEF_METRIC ); + eSourceUnit = rTextObjectImpl.GetMetric(); + eDestUnit = maEditDoc.GetItemPool().GetMetric( DEF_METRIC ); if ( eSourceUnit != eDestUnit ) bConvertMetricOfItems = true; } @@ -1200,13 +1231,13 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject // Before, paragraph count was of type sal_uInt16 so if nContents exceeded // 0xFFFF this wouldn't have worked anyway, given that nPara is used to // number paragraphs and is fearlessly incremented. - sal_Int32 nContents = static_cast<sal_Int32>(rTextObject.mpImpl->GetContents().size()); + sal_Int32 nContents = static_cast<sal_Int32>(rTextObjectImpl.GetContents().size()); SAL_WARN_IF( nContents < 0, "editeng", "ImpEditEngine::InsertTextObject - contents overflow " << nContents); - sal_Int32 nPara = aEditDoc.GetPos( aPaM.GetNode() ); + sal_Int32 nPara = maEditDoc.GetPos( aPaM.GetNode() ); for (sal_Int32 n = 0; n < nContents; ++n, ++nPara) { - const ContentInfo* pC = rTextObject.mpImpl->GetContents()[n].get(); + const ContentInfo* pC = rTextObjectImpl.GetContents()[n].get(); bool bNewContent = aPaM.GetNode()->Len() == 0; const sal_Int32 nStartPos = aPaM.GetIndex(); @@ -1224,7 +1255,7 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject bool bUpdateFields = false; for (size_t nAttr = 0; nAttr < nNewAttribs; ++nAttr) { - const XEditAttribute& rX = *pC->GetCharAttribs()[nAttr]; + const XEditAttribute& rX = pC->GetCharAttribs()[nAttr]; // Can happen when paragraphs > 16K, it is simply wrapped. //TODO! Still true, still needed? if ( rX.GetEnd() <= aPaM.GetNode()->Len() ) @@ -1238,12 +1269,12 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject DBG_ASSERT( rX.GetEnd() <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute too large!" ); EditCharAttrib* pAttr; if ( !bConvertMetricOfItems ) - pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *(rX.GetItem()), rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos ); + pAttr = MakeCharAttrib( maEditDoc.GetItemPool(), *(rX.GetItem()), rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos ); else { std::unique_ptr<SfxPoolItem> pNew(rX.GetItem()->Clone()); ConvertItem( pNew, eSourceUnit, eDestUnit ); - pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *pNew, rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos ); + pAttr = MakeCharAttrib( maEditDoc.GetItemPool(), *pNew, rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos ); } DBG_ASSERT( pAttr->GetEnd() <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute does not fit! (1)" ); aPaM.GetNode()->GetCharAttribs().InsertAttrib( pAttr ); @@ -1254,7 +1285,7 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject { DBG_ASSERT( rX.GetEnd()+nStartPos <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute does not fit! (2)" ); // Tabs and other Features can not be inserted through InsertAttrib: - aEditDoc.InsertAttrib( aPaM.GetNode(), rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos, *rX.GetItem() ); + maEditDoc.InsertAttrib( aPaM.GetNode(), rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos, *rX.GetItem() ); } } } @@ -1282,21 +1313,21 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject SetStyleSheet( nPara, pStyle ); } if ( !bConvertMetricOfItems ) - SetParaAttribs( aEditDoc.GetPos( aPaM.GetNode() ), pC->GetParaAttribs() ); + SetParaAttribs( maEditDoc.GetPos( aPaM.GetNode() ), pC->GetParaAttribs() ); else { SfxItemSet aAttribs( GetEmptyItemSet() ); ConvertAndPutItems( aAttribs, pC->GetParaAttribs(), &eSourceUnit, &eDestUnit ); - SetParaAttribs( aEditDoc.GetPos( aPaM.GetNode() ), aAttribs ); + SetParaAttribs( maEditDoc.GetPos( aPaM.GetNode() ), aAttribs ); } if ( bNewContent && bUsePortionInfo ) { const XParaPortion& rXP = (*pPortionInfo)[n]; - ParaPortion* pParaPortion = GetParaPortions()[ nPara ]; + ParaPortion* pParaPortion = GetParaPortions().SafeGetObject(nPara); DBG_ASSERT( pParaPortion, "InsertBinTextObject: ParaPortion?" ); - pParaPortion->nHeight = rXP.nHeight; - pParaPortion->nFirstLineOffset = rXP.nFirstLineOffset; - pParaPortion->bForceRepaint = true; + pParaPortion->mnHeight = rXP.nHeight; + pParaPortion->mnFirstLineOffset = rXP.nFirstLineOffset; + pParaPortion->mbForceRepaint = true; pParaPortion->SetValid(); // Do not format // The Text Portions @@ -1306,7 +1337,7 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject { const TextPortion& rTextPortion = rXP.aTextPortions[_n]; TextPortion* pNew = new TextPortion( rTextPortion ); - pParaPortion->GetTextPortions().Insert(_n, pNew); + pParaPortion->GetTextPortions().Append(pNew); } // The lines @@ -1317,7 +1348,7 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject const EditLine& rLine = rXP.aLines[m]; EditLine* pNew = rLine.Clone(); pNew->SetInvalid(); // Paint again! - pParaPortion->GetLines().Insert(m, pNew); + pParaPortion->GetLines().Append(std::unique_ptr<EditLine>(pNew)); } #ifdef DBG_UTIL sal_uInt16 nTest; @@ -1326,14 +1357,14 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject nTPLen += pParaPortion->GetTextPortions()[--nTest].GetLen(); for ( nTest = pParaPortion->GetLines().Count(); nTest; ) nTxtLen += pParaPortion->GetLines()[--nTest].GetLen(); - DBG_ASSERT( ( nTPLen == pParaPortion->GetNode()->Len() ) && ( nTxtLen == pParaPortion->GetNode()->Len() ), "InsertBinTextObject: ParaPortion not completely formatted!" ); + DBG_ASSERT( ( nTPLen == pParaPortion->GetNode()->Len() ) && ( nTxtLen == pParaPortion->GetNode()->Len() ), "InsertTextObject: ParaPortion not completely formatted!" ); #endif } } if ( !bParaAttribs ) // DefFont is not calculated for FastInsertParagraph { - aPaM.GetNode()->GetCharAttribs().GetDefFont() = aEditDoc.GetDefFont(); - if ( aStatus.UseCharAttribs() ) + aPaM.GetNode()->GetCharAttribs().GetDefFont() = maEditDoc.GetDefFont(); + if (maStatus.UseCharAttribs()) aPaM.GetNode()->CreateDefFont(); } @@ -1353,7 +1384,7 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject } aSel.Max() = aPaM; - DBG_ASSERT( !aSel.DbgIsBuggy( aEditDoc ), "InsertBibTextObject: Selection broken!(1)" ); + DBG_ASSERT( !aSel.DbgIsBuggy( maEditDoc ), "InsertBibTextObject: Selection broken!(1)" ); return aSel; } @@ -1368,7 +1399,7 @@ void ImpEditEngine::GetAllMisspellRanges( std::vector<editeng::MisspellRanges>& if (!pWrongList) continue; - aRanges.emplace_back(i, pWrongList->GetRanges()); + aRanges.emplace_back(i, std::vector(pWrongList->GetRanges())); } aRanges.swap(rRanges); @@ -1385,97 +1416,105 @@ void ImpEditEngine::SetAllMisspellRanges( const std::vector<editeng::MisspellRan pNode->CreateWrongList(); WrongList* pWrongList = pNode->GetWrongList(); - pWrongList->SetRanges(rParaRanges.maRanges); + pWrongList->SetRanges(std::vector(rParaRanges.maRanges)); } } -LanguageType ImpEditEngine::GetLanguage( const EditPaM& rPaM, sal_Int32* pEndPos ) const +editeng::LanguageSpan ImpEditEngine::GetLanguage( const EditPaM& rPaM, sal_Int32* pEndPos ) const { short nScriptTypeI18N = GetI18NScriptType( rPaM, pEndPos ); // pEndPos will be valid now, pointing to ScriptChange or NodeLen SvtScriptType nScriptType = SvtLanguageOptions::FromI18NToSvtScriptType(nScriptTypeI18N); sal_uInt16 nLangId = GetScriptItemId( EE_CHAR_LANGUAGE, nScriptType ); const SvxLanguageItem* pLangItem = &static_cast<const SvxLanguageItem&>(rPaM.GetNode()->GetContentAttribs().GetItem( nLangId )); const EditCharAttrib* pAttr = rPaM.GetNode()->GetCharAttribs().FindAttrib( nLangId, rPaM.GetIndex() ); + + editeng::LanguageSpan aLang; + if ( pAttr ) + { pLangItem = static_cast<const SvxLanguageItem*>(pAttr->GetItem()); + aLang.nStart = pAttr->GetStart(); + aLang.nEnd = pAttr->GetEnd(); + } if ( pEndPos && pAttr && ( pAttr->GetEnd() < *pEndPos ) ) *pEndPos = pAttr->GetEnd(); - return pLangItem->GetLanguage(); + aLang.nLang = pLangItem->GetLanguage(); + + return aLang; } css::lang::Locale ImpEditEngine::GetLocale( const EditPaM& rPaM ) const { - return LanguageTag( GetLanguage( rPaM ) ).getLocale(); + return LanguageTag( GetLanguage( rPaM ).nLang ).getLocale(); } Reference< XSpellChecker1 > const & ImpEditEngine::GetSpeller() { - if ( !xSpeller.is() ) - xSpeller = LinguMgr::GetSpellChecker(); - return xSpeller; + if (!mxSpeller.is()) + mxSpeller = LinguMgr::GetSpellChecker(); + return mxSpeller; } void ImpEditEngine::CreateSpellInfo( bool bMultipleDocs ) { - if (!pSpellInfo) - pSpellInfo.reset( new SpellInfo ); + if (!mpSpellInfo) + mpSpellInfo.reset(new SpellInfo); else - *pSpellInfo = SpellInfo(); // reset to default values + *mpSpellInfo = SpellInfo(); // reset to default values - pSpellInfo->bMultipleDoc = bMultipleDocs; + mpSpellInfo->bMultipleDoc = bMultipleDocs; // always spell draw objects completely, starting at the top. // (spelling in only a selection or not starting with the top requires // further changes elsewhere to work properly) - pSpellInfo->aSpellStart = EPaM(); - pSpellInfo->aSpellTo = EPaM( EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND ); + mpSpellInfo->aSpellStart = EPaM(); + mpSpellInfo->aSpellTo = EPaM( EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND ); } -EESpellState ImpEditEngine::Spell( EditView* pEditView, bool bMultipleDoc ) +EESpellState ImpEditEngine::Spell(EditView* pEditView, weld::Widget* pDialogParent, bool bMultipleDoc) { - SAL_WARN_IF( !xSpeller.is(), "editeng", "No Spell checker set!" ); + SAL_WARN_IF(!mxSpeller.is(), "editeng", "No Spell checker set!"); - if ( !xSpeller.is() ) + if (!mxSpeller.is()) return EESpellState::NoSpeller; - aOnlineSpellTimer.Stop(); + maOnlineSpellTimer.Stop(); // In MultipleDoc always from the front / rear ... if ( bMultipleDoc ) { - pEditView->pImpEditView->SetEditSelection( aEditDoc.GetStartPaM() ); + pEditView->getImpl().SetEditSelection( maEditDoc.GetStartPaM() ); } - EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() ); + EditSelection aCurSel( pEditView->getImpl().GetEditSelection() ); CreateSpellInfo( bMultipleDoc ); bool bIsStart = false; if ( bMultipleDoc ) bIsStart = true; // Accessible from the front or from behind ... - else if ( CreateEPaM( aEditDoc.GetStartPaM() ) == pSpellInfo->aSpellStart ) + else if ( CreateEPaM( maEditDoc.GetStartPaM() ) == mpSpellInfo->aSpellStart ) bIsStart = true; - vcl::Window* pParent = Application::GetDefDialogParent(); - std::unique_ptr<EditSpellWrapper> pWrp(new EditSpellWrapper(pParent ? pParent->GetFrameWeld() : nullptr, - bIsStart, pEditView )); - pWrp->SpellDocument(); - pWrp.reset(); + { + EditSpellWrapper aWrp(pDialogParent, bIsStart, pEditView ); + aWrp.SpellDocument(); + } if ( !bMultipleDoc ) { - pEditView->pImpEditView->DrawSelectionXOR(); + pEditView->getImpl().DrawSelectionXOR(); if ( aCurSel.Max().GetIndex() > aCurSel.Max().GetNode()->Len() ) aCurSel.Max().SetIndex( aCurSel.Max().GetNode()->Len() ); aCurSel.Min() = aCurSel.Max(); - pEditView->pImpEditView->SetEditSelection( aCurSel ); - pEditView->pImpEditView->DrawSelectionXOR(); + pEditView->getImpl().SetEditSelection( aCurSel ); + pEditView->getImpl().DrawSelectionXOR(); pEditView->ShowCursor( true, false ); } - EESpellState eState = pSpellInfo->eState; - pSpellInfo.reset(); + EESpellState eState = mpSpellInfo->eState; + mpSpellInfo.reset(); return eState; } @@ -1484,11 +1523,11 @@ bool ImpEditEngine::HasConvertibleTextPortion( LanguageType nSrcLang ) { bool bHasConvTxt = false; - sal_Int32 nParas = pEditEngine->GetParagraphCount(); + sal_Int32 nParas = mpEditEngine->GetParagraphCount(); for (sal_Int32 k = 0; k < nParas; ++k) { std::vector<sal_Int32> aPortions; - pEditEngine->GetPortions( k, aPortions ); + mpEditEngine->GetPortions( k, aPortions ); for ( size_t nPos = 0; nPos < aPortions.size(); ++nPos ) { sal_Int32 nEnd = aPortions[ nPos ]; @@ -1499,8 +1538,8 @@ bool ImpEditEngine::HasConvertibleTextPortion( LanguageType nSrcLang ) // specified position is evaluated. if (nEnd > nStart) // empty para? ++nStart; - LanguageType nLangFound = pEditEngine->GetLanguage( k, nStart ); -#ifdef DEBUG + LanguageType nLangFound = mpEditEngine->GetLanguage( k, nStart ).nLang; +#if OSL_DEBUG_LEVEL >= 2 lang::Locale aLocale( LanguageTag::convertToLocale( nLangFound ) ); #endif bHasConvTxt = (nSrcLang == nLangFound) || @@ -1508,14 +1547,13 @@ bool ImpEditEngine::HasConvertibleTextPortion( LanguageType nSrcLang ) editeng::HangulHanjaConversion::IsChinese( nSrcLang )); if (bHasConvTxt) return bHasConvTxt; - } + } } return bHasConvTxt; } - -void ImpEditEngine::Convert( EditView* pEditView, +void ImpEditEngine::Convert( EditView* pEditView, weld::Widget* pDialogParent, LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc ) { @@ -1523,15 +1561,15 @@ void ImpEditEngine::Convert( EditView* pEditView, // In MultipleDoc always from the front / rear ... if ( bMultipleDoc ) - pEditView->pImpEditView->SetEditSelection( aEditDoc.GetStartPaM() ); + pEditView->getImpl().SetEditSelection( maEditDoc.GetStartPaM() ); // initialize pConvInfo - EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() ); - aCurSel.Adjust( aEditDoc ); - pConvInfo.reset(new ConvInfo); - pConvInfo->bMultipleDoc = bMultipleDoc; - pConvInfo->aConvStart = CreateEPaM( aCurSel.Min() ); + EditSelection aCurSel( pEditView->getImpl().GetEditSelection() ); + aCurSel.Adjust( maEditDoc ); + mpConvInfo.reset(new ConvInfo); + mpConvInfo->bMultipleDoc = bMultipleDoc; + mpConvInfo->aConvStart = CreateEPaM( aCurSel.Min() ); // if it is not just a selection and we are about to begin // with the current conversion for the very first time @@ -1549,19 +1587,19 @@ void ImpEditEngine::Convert( EditView* pEditView, // not work. Thus since chinese conversion is not interactive we start // at the begin of the paragraph to solve the problem, i.e. have the // TextConversion service get those characters together in the same call. - pConvInfo->aConvStart.nIndex = editeng::HangulHanjaConversion::IsChinese( nSrcLang ) + mpConvInfo->aConvStart.nIndex = editeng::HangulHanjaConversion::IsChinese( nSrcLang ) ? 0 : aWordStartPaM.GetIndex(); } - pConvInfo->aConvContinue = pConvInfo->aConvStart; + mpConvInfo->aConvContinue = mpConvInfo->aConvStart; bool bIsStart = false; if ( bMultipleDoc ) bIsStart = true; // Accessible from the front or from behind ... - else if ( CreateEPaM( aEditDoc.GetStartPaM() ) == pConvInfo->aConvStart ) + else if ( CreateEPaM( maEditDoc.GetStartPaM() ) == mpConvInfo->aConvStart ) bIsStart = true; - TextConvWrapper aWrp( pEditView->GetWindow()->GetFrameWeld(), + TextConvWrapper aWrp( pDialogParent, ::comphelper::getProcessComponentContext(), LanguageTag::convertToLocale( nSrcLang ), LanguageTag::convertToLocale( nDestLang ), @@ -1588,15 +1626,15 @@ void ImpEditEngine::Convert( EditView* pEditView, if ( !bMultipleDoc ) { - pEditView->pImpEditView->DrawSelectionXOR(); + pEditView->getImpl().DrawSelectionXOR(); if ( aCurSel.Max().GetIndex() > aCurSel.Max().GetNode()->Len() ) aCurSel.Max().SetIndex( aCurSel.Max().GetNode()->Len() ); aCurSel.Min() = aCurSel.Max(); - pEditView->pImpEditView->SetEditSelection( aCurSel ); - pEditView->pImpEditView->DrawSelectionXOR(); + pEditView->getImpl().SetEditSelection( aCurSel ); + pEditView->getImpl().DrawSelectionXOR(); pEditView->ShowCursor( true, false ); } - pConvInfo.reset(); + mpConvInfo.reset(); } @@ -1605,11 +1643,11 @@ void ImpEditEngine::SetLanguageAndFont( LanguageType nLang, sal_uInt16 nLangWhichId, const vcl::Font *pFont, sal_uInt16 nFontWhichId ) { - ESelection aOldSel = pActiveView->GetSelection(); - pActiveView->SetSelection( rESel ); + ESelection aOldSel = mpActiveView->GetSelection(); + mpActiveView->SetSelection( rESel ); // set new language attribute - SfxItemSet aNewSet( pActiveView->GetEmptyItemSet() ); + SfxItemSet aNewSet(mpActiveView->GetEmptyItemSet()); aNewSet.Put( SvxLanguageItem( nLang, nLangWhichId ) ); // new font to be set? @@ -1627,9 +1665,8 @@ void ImpEditEngine::SetLanguageAndFont( } // apply new attributes - pActiveView->SetAttribs( aNewSet ); - - pActiveView->SetSelection( aOldSel ); + mpActiveView->SetAttribs(aNewSet); + mpActiveView->SetSelection(aOldSel); } @@ -1645,7 +1682,7 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang, OUString aRes; LanguageType nResLang = LANGUAGE_NONE; - EditPaM aPos( CreateEditPaM( pConvInfo->aConvContinue ) ); + EditPaM aPos(CreateEditPaM(mpConvInfo->aConvContinue)); EditSelection aCurSel( aPos, aPos ); OUString aWord; @@ -1654,9 +1691,9 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang, { // empty paragraph found that needs to have language and font set? if (bAllowImplicitChangesForNotConvertibleText && - pEditEngine->GetText( pConvInfo->aConvContinue.nPara ).isEmpty()) + mpEditEngine->GetText(mpConvInfo->aConvContinue.nPara).isEmpty()) { - sal_Int32 nPara = pConvInfo->aConvContinue.nPara; + sal_Int32 nPara = mpConvInfo->aConvContinue.nPara; ESelection aESel( nPara, 0, nPara, 0 ); // see comment for below same function call SetLanguageAndFont( aESel, @@ -1665,8 +1702,8 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang, } - if (pConvInfo->aConvContinue.nPara == pConvInfo->aConvTo.nPara && - pConvInfo->aConvContinue.nIndex >= pConvInfo->aConvTo.nIndex) + if (mpConvInfo->aConvContinue.nPara == mpConvInfo->aConvTo.nPara && + mpConvInfo->aConvContinue.nIndex >= mpConvInfo->aConvTo.nIndex) break; sal_Int32 nAttribStart = -1; @@ -1674,7 +1711,7 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang, sal_Int32 nCurPos = -1; EPaM aCurStart = CreateEPaM( aCurSel.Min() ); std::vector<sal_Int32> aPortions; - pEditEngine->GetPortions( aCurStart.nPara, aPortions ); + mpEditEngine->GetPortions(aCurStart.nPara, aPortions); for ( size_t nPos = 0; nPos < aPortions.size(); ++nPos ) { const sal_Int32 nEnd = aPortions[ nPos ]; @@ -1685,8 +1722,8 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang, // thus we usually have to add 1 in order to get the language // of the text right to the cursor position const sal_Int32 nLangIdx = nEnd > nStart ? nStart + 1 : nStart; - LanguageType nLangFound = pEditEngine->GetLanguage( aCurStart.nPara, nLangIdx ); -#ifdef DEBUG + LanguageType nLangFound = mpEditEngine->GetLanguage( aCurStart.nPara, nLangIdx ).nLang; +#if OSL_DEBUG_LEVEL >= 2 lang::Locale aLocale( LanguageTag::convertToLocale( nLangFound ) ); #endif bool bLangOk = (nLangFound == nSrcLang) || @@ -1754,26 +1791,26 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang, aCurSel.Max().SetIndex( nCurPos ); } - if ( !pConvInfo->bConvToEnd ) + if ( !mpConvInfo->bConvToEnd ) { EPaM aEPaM( CreateEPaM( aCurSel.Min() ) ); - if ( !( aEPaM < pConvInfo->aConvTo ) ) + if ( !( aEPaM < mpConvInfo->aConvTo ) ) break; } // clip selected word to the converted area // (main use when conversion starts/ends **within** a word) - EditPaM aPaM( CreateEditPaM( pConvInfo->aConvStart ) ); - if (pConvInfo->bConvToEnd && + EditPaM aPaM( CreateEditPaM( mpConvInfo->aConvStart ) ); + if (mpConvInfo->bConvToEnd && aCurSel.Min().GetNode() == aPaM.GetNode() && aCurSel.Min().GetIndex() < aPaM.GetIndex()) aCurSel.Min().SetIndex( aPaM.GetIndex() ); - aPaM = CreateEditPaM( pConvInfo->aConvContinue ); + aPaM = CreateEditPaM( mpConvInfo->aConvContinue ); if (aCurSel.Min().GetNode() == aPaM.GetNode() && aCurSel.Min().GetIndex() < aPaM.GetIndex()) aCurSel.Min().SetIndex( aPaM.GetIndex() ); - aPaM = CreateEditPaM( pConvInfo->aConvTo ); - if ((!pConvInfo->bConvToEnd || rConvRange.HasRange())&& + aPaM = CreateEditPaM( mpConvInfo->aConvTo ); + if ((!mpConvInfo->bConvToEnd || rConvRange.HasRange())&& aCurSel.Max().GetNode() == aPaM.GetNode() && aCurSel.Max().GetIndex() > aPaM.GetIndex()) aCurSel.Max().SetIndex( aPaM.GetIndex() ); @@ -1787,12 +1824,12 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang, if ( aRes.isEmpty() ) aCurSel = WordRight( aCurSel.Min(), css::i18n::WordType::DICTIONARY_WORD ); - pConvInfo->aConvContinue = CreateEPaM( aCurSel.Max() ); + mpConvInfo->aConvContinue = CreateEPaM( aCurSel.Max() ); } - pEditView->pImpEditView->DrawSelectionXOR(); - pEditView->pImpEditView->SetEditSelection( aCurSel ); - pEditView->pImpEditView->DrawSelectionXOR(); + pEditView->getImpl().DrawSelectionXOR(); + pEditView->getImpl().SetEditSelection( aCurSel ); + pEditView->getImpl().DrawSelectionXOR(); pEditView->ShowCursor( true, false ); rConvTxt = aRes; @@ -1803,10 +1840,10 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang, Reference< XSpellAlternatives > ImpEditEngine::ImpSpell( EditView* pEditView ) { - DBG_ASSERT( xSpeller.is(), "No spell checker set!" ); + DBG_ASSERT(mxSpeller.is(), "No spell checker set!"); - ContentNode* pLastNode = aEditDoc.GetObject( aEditDoc.Count()-1 ); - EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() ); + ContentNode* pLastNode = maEditDoc.GetObject( maEditDoc.Count()-1 ); + EditSelection aCurSel( pEditView->getImpl().GetEditSelection() ); aCurSel.Min() = aCurSel.Max(); Reference< XSpellAlternatives > xSpellAlt; @@ -1816,7 +1853,7 @@ Reference< XSpellAlternatives > ImpEditEngine::ImpSpell( EditView* pEditView ) // Known (most likely) bug: If SpellToCurrent, the current has to be // corrected at each replacement, otherwise it may not fit exactly in // the end ... - if ( pSpellInfo->bSpellToEnd || pSpellInfo->bMultipleDoc ) + if (mpSpellInfo->bSpellToEnd || mpSpellInfo->bMultipleDoc) { if ( aCurSel.Max().GetNode() == pLastNode ) { @@ -1824,10 +1861,10 @@ Reference< XSpellAlternatives > ImpEditEngine::ImpSpell( EditView* pEditView ) break; } } - else if ( !pSpellInfo->bSpellToEnd ) + else if (!mpSpellInfo->bSpellToEnd) { EPaM aEPaM( CreateEPaM( aCurSel.Max() ) ); - if ( !( aEPaM < pSpellInfo->aSpellTo ) ) + if (!(aEPaM < mpSpellInfo->aSpellTo)) break; } @@ -1848,20 +1885,20 @@ Reference< XSpellAlternatives > ImpEditEngine::ImpSpell( EditView* pEditView ) if ( !aWord.isEmpty() ) { - LanguageType eLang = GetLanguage( aCurSel.Max() ); - SvxSpellWrapper::CheckSpellLang( xSpeller, eLang ); - xSpellAlt = xSpeller->spell( aWord, static_cast<sal_uInt16>(eLang), aEmptySeq ); + LanguageType eLang = GetLanguage( aCurSel.Max() ).nLang; + SvxSpellWrapper::CheckSpellLang(mxSpeller, eLang); + xSpellAlt = mxSpeller->spell( aWord, static_cast<sal_uInt16>(eLang), aEmptySeq ); } if ( !xSpellAlt.is() ) aCurSel = WordRight( aCurSel.Min(), css::i18n::WordType::DICTIONARY_WORD ); else - pSpellInfo->eState = EESpellState::ErrorFound; + mpSpellInfo->eState = EESpellState::ErrorFound; } - pEditView->pImpEditView->DrawSelectionXOR(); - pEditView->pImpEditView->SetEditSelection( aCurSel ); - pEditView->pImpEditView->DrawSelectionXOR(); + pEditView->getImpl().DrawSelectionXOR(); + pEditView->getImpl().SetEditSelection( aCurSel ); + pEditView->getImpl().DrawSelectionXOR(); pEditView->ShowCursor( true, false ); return xSpellAlt; } @@ -1897,13 +1934,13 @@ Reference< XSpellAlternatives > ImpEditEngine::ImpFindNextError(EditSelection& r } if ( !aWord.isEmpty() ) - xSpellAlt = xSpeller->spell( aWord, static_cast<sal_uInt16>(GetLanguage( aCurSel.Max() )), aEmptySeq ); + xSpellAlt = mxSpeller->spell( aWord, static_cast<sal_uInt16>(GetLanguage( aCurSel.Max() ).nLang), aEmptySeq ); if ( !xSpellAlt.is() ) aCurSel = WordRight( aCurSel.Min(), css::i18n::WordType::DICTIONARY_WORD ); else { - pSpellInfo->eState = EESpellState::ErrorFound; + mpSpellInfo->eState = EESpellState::ErrorFound; rSelection = aCurSel; } } @@ -1914,18 +1951,18 @@ bool ImpEditEngine::SpellSentence(EditView const & rEditView, svx::SpellPortions& rToFill ) { bool bRet = false; - EditSelection aCurSel( rEditView.pImpEditView->GetEditSelection() ); - if(!pSpellInfo) + EditSelection aCurSel( rEditView.getImpl().GetEditSelection() ); + if (!mpSpellInfo) CreateSpellInfo( true ); - pSpellInfo->aCurSentenceStart = aCurSel.Min(); - DBG_ASSERT( xSpeller.is(), "No spell checker set!" ); - pSpellInfo->aLastSpellPortions.clear(); - pSpellInfo->aLastSpellContentSelections.clear(); + mpSpellInfo->aCurSentenceStart = aCurSel.Min(); + DBG_ASSERT(mxSpeller.is(), "No spell checker set!"); + mpSpellInfo->aLastSpellPortions.clear(); + mpSpellInfo->aLastSpellContentSelections.clear(); rToFill.clear(); //if no selection previously exists the range is extended to the end of the object if (!aCurSel.HasRange()) { - ContentNode* pLastNode = aEditDoc.GetObject( aEditDoc.Count()-1); + ContentNode* pLastNode = maEditDoc.GetObject( maEditDoc.Count()-1); aCurSel.Max() = EditPaM(pLastNode, pLastNode->Len()); } // check for next error in aCurSel and set aCurSel to that one if any was found @@ -1964,7 +2001,7 @@ bool ImpEditEngine::SpellSentence(EditView const & rEditView, while( xAlt.is() ); //set the selection to the end of the current sentence - rEditView.pImpEditView->SetEditSelection(aSentencePaM.Max()); + rEditView.getImpl().SetEditSelection(aSentencePaM.Max()); } return bRet; } @@ -1981,14 +2018,14 @@ void ImpEditEngine::AddPortion( svx::SpellPortion aPortion; aPortion.sText = GetSelected( rSel ); - aPortion.eLanguage = GetLanguage( rSel.Min() ); + aPortion.eLanguage = GetLanguage( rSel.Min() ).nLang; aPortion.xAlternatives = xAlt; aPortion.bIsField = bIsField; rToFill.push_back(aPortion); //save the spelled portions for later use - pSpellInfo->aLastSpellPortions.push_back(aPortion); - pSpellInfo->aLastSpellContentSelections.push_back(rSel); + mpSpellInfo->aLastSpellPortions.push_back(aPortion); + mpSpellInfo->aLastSpellContentSelections.push_back(rSel); } // Adds one or more portions of text to the SpellPortions depending on language changes @@ -2015,8 +2052,8 @@ void ImpEditEngine::AddPortionIterated( //iterate over the text to find changes in language //set the mark equal to the point EditPaM aCursor(aStart); - rEditView.pImpEditView->SetEditSelection( aCursor ); - LanguageType eStartLanguage = GetLanguage( aCursor ); + rEditView.getImpl().SetEditSelection( aCursor ); + LanguageType eStartLanguage = GetLanguage( aCursor ).nLang; //search for a field attribute at the beginning - only the end position //of this field is kept to end a portion at that position const EditCharAttrib* pFieldAttr = aCursor.GetNode()->GetCharAttribs(). @@ -2042,7 +2079,7 @@ void ImpEditEngine::AddPortionIterated( if (bIsField) nEndField = _pFieldAttr->GetEnd(); - LanguageType eCurLanguage = GetLanguage( aCursor ); + LanguageType eCurLanguage = GetLanguage( aCursor ).nLang; if(eCurLanguage != eStartLanguage || bIsField || bIsEndField) { eStartLanguage = eCurLanguage; @@ -2067,27 +2104,27 @@ void ImpEditEngine::ApplyChangedSentence(EditView const & rEditView, // Note: rNewPortions.size() == 0 is valid and happens when the whole // sentence got removed in the dialog - DBG_ASSERT(pSpellInfo, "pSpellInfo not initialized"); - if (!pSpellInfo || pSpellInfo->aLastSpellPortions.empty()) // no portions -> no text to be changed + DBG_ASSERT(mpSpellInfo, "mpSpellInfo not initialized"); + if (!mpSpellInfo || mpSpellInfo->aLastSpellPortions.empty()) // no portions -> no text to be changed return; // get current paragraph length to calculate later on how the sentence length changed, // in order to place the cursor at the end of the sentence again - EditSelection aOldSel( rEditView.pImpEditView->GetEditSelection() ); + EditSelection aOldSel( rEditView.getImpl().GetEditSelection() ); sal_Int32 nOldLen = aOldSel.Max().GetNode()->Len(); UndoActionStart( EDITUNDO_INSERT ); - if(pSpellInfo->aLastSpellPortions.size() == rNewPortions.size()) + if (mpSpellInfo->aLastSpellPortions.size() == rNewPortions.size()) { - DBG_ASSERT( !rNewPortions.empty(), "rNewPortions should not be empty here" ); - DBG_ASSERT( pSpellInfo->aLastSpellPortions.size() == pSpellInfo->aLastSpellContentSelections.size(), - "aLastSpellPortions and aLastSpellContentSelections size mismatch" ); + DBG_ASSERT(!rNewPortions.empty(), "rNewPortions should not be empty here"); + DBG_ASSERT(mpSpellInfo->aLastSpellPortions.size() == mpSpellInfo->aLastSpellContentSelections.size(), + "aLastSpellPortions and aLastSpellContentSelections size mismatch"); //the simple case: the same number of elements on both sides //each changed element has to be applied to the corresponding source element svx::SpellPortions::const_iterator aCurrentNewPortion = rNewPortions.end(); - svx::SpellPortions::const_iterator aCurrentOldPortion = pSpellInfo->aLastSpellPortions.end(); - SpellContentSelections::const_iterator aCurrentOldPosition = pSpellInfo->aLastSpellContentSelections.end(); + svx::SpellPortions::const_iterator aCurrentOldPortion = mpSpellInfo->aLastSpellPortions.end(); + SpellContentSelections::const_iterator aCurrentOldPosition = mpSpellInfo->aLastSpellContentSelections.end(); bool bSetToEnd = false; do { @@ -2099,7 +2136,7 @@ void ImpEditEngine::ApplyChangedSentence(EditView const & rEditView, if(!bSetToEnd) { bSetToEnd = true; - rEditView.pImpEditView->SetEditSelection( aCurrentOldPosition->Max() ); + rEditView.getImpl().SetEditSelection( aCurrentOldPosition->Max() ); } SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( aCurrentNewPortion->eLanguage ); @@ -2113,7 +2150,7 @@ void ImpEditEngine::ApplyChangedSentence(EditView const & rEditView, if(aCurrentNewPortion->sText != aCurrentOldPortion->sText) { //change text and apply language - SfxItemSet aSet( aEditDoc.GetItemPool(), {{nLangWhichId, nLangWhichId}}); + SfxItemSet aSet( maEditDoc.GetItemPool(), nLangWhichId, nLangWhichId ); aSet.Put(SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId)); SetAttribs( *aCurrentOldPosition, aSet ); ImpInsertText( *aCurrentOldPosition, aCurrentNewPortion->sText ); @@ -2121,7 +2158,7 @@ void ImpEditEngine::ApplyChangedSentence(EditView const & rEditView, else if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage) { //apply language - SfxItemSet aSet( aEditDoc.GetItemPool(), {{nLangWhichId, nLangWhichId}}); + SfxItemSet aSet( maEditDoc.GetItemPool(), nLangWhichId, nLangWhichId); aSet.Put(SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId)); SetAttribs( *aCurrentOldPosition, aSet ); } @@ -2130,12 +2167,12 @@ void ImpEditEngine::ApplyChangedSentence(EditView const & rEditView, } else { - DBG_ASSERT( !pSpellInfo->aLastSpellContentSelections.empty(), "aLastSpellContentSelections should not be empty here" ); + DBG_ASSERT( !mpSpellInfo->aLastSpellContentSelections.empty(), "aLastSpellContentSelections should not be empty here" ); //select the complete sentence - SpellContentSelections::const_iterator aCurrentEndPosition = pSpellInfo->aLastSpellContentSelections.end(); + SpellContentSelections::const_iterator aCurrentEndPosition = mpSpellInfo->aLastSpellContentSelections.end(); --aCurrentEndPosition; - SpellContentSelections::const_iterator aCurrentStartPosition = pSpellInfo->aLastSpellContentSelections.begin(); + SpellContentSelections::const_iterator aCurrentStartPosition = mpSpellInfo->aLastSpellContentSelections.begin(); EditSelection aAllSentence(aCurrentStartPosition->Min(), aCurrentEndPosition->Max()); //delete the sentence completely @@ -2144,7 +2181,7 @@ void ImpEditEngine::ApplyChangedSentence(EditView const & rEditView, for(const auto& rCurrentNewPortion : rNewPortions) { //set the language attribute - LanguageType eCurLanguage = GetLanguage( aCurrentPaM ); + LanguageType eCurLanguage = GetLanguage( aCurrentPaM ).nLang; if(eCurLanguage != rCurrentNewPortion.eLanguage) { SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( rCurrentNewPortion.eLanguage ); @@ -2155,7 +2192,7 @@ void ImpEditEngine::ApplyChangedSentence(EditView const & rEditView, case SvtScriptType::COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break; default: break; } - SfxItemSet aSet( aEditDoc.GetItemPool(), {{nLangWhichId, nLangWhichId}}); + SfxItemSet aSet( maEditDoc.GetItemPool(), nLangWhichId, nLangWhichId); aSet.Put(SvxLanguageItem(rCurrentNewPortion.eLanguage, nLangWhichId)); SetAttribs( aCurrentPaM, aSet ); } @@ -2167,27 +2204,28 @@ void ImpEditEngine::ApplyChangedSentence(EditView const & rEditView, EditPaM aNext; if (bRecheck) - aNext = pSpellInfo->aCurSentenceStart; + aNext = mpSpellInfo->aCurSentenceStart; else { // restore cursor position to the end of the modified sentence. // (This will define the continuation position for spell/grammar checking) // First: check if the sentence/para length changed - const sal_Int32 nDelta = rEditView.pImpEditView->GetEditSelection().Max().GetNode()->Len() - nOldLen; + const sal_Int32 nDelta = rEditView.getImpl().GetEditSelection().Max().GetNode()->Len() - nOldLen; const sal_Int32 nEndOfSentence = aOldSel.Max().GetIndex() + nDelta; aNext = EditPaM( aOldSel.Max().GetNode(), nEndOfSentence ); } - rEditView.pImpEditView->SetEditSelection( aNext ); + rEditView.getImpl().SetEditSelection( aNext ); - FormatAndUpdate(); - aEditDoc.SetModified(true); + if (IsUpdateLayout()) + FormatAndLayout(); + maEditDoc.SetModified(true); } void ImpEditEngine::PutSpellingToSentenceStart( EditView const & rEditView ) { - if( pSpellInfo && !pSpellInfo->aLastSpellContentSelections.empty() ) + if (mpSpellInfo && !mpSpellInfo->aLastSpellContentSelections.empty()) { - rEditView.pImpEditView->SetEditSelection( pSpellInfo->aLastSpellContentSelections.begin()->Min() ); + rEditView.getImpl().SetEditSelection(mpSpellInfo->aLastSpellContentSelections.begin()->Min()); } } @@ -2205,18 +2243,18 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC even out properly with VDev on transitions from wrong => right) */ - if ( !xSpeller.is() ) + if (!mxSpeller.is()) return; EditPaM aCursorPos; - if( pActiveView && !bSpellAtCursorPos ) + if (mpActiveView && !bSpellAtCursorPos) { - aCursorPos = pActiveView->pImpEditView->GetEditSelection().Max(); + aCursorPos = mpActiveView->getImpl().GetEditSelection().Max(); } bool bRestartTimer = false; - ContentNode* pLastNode = aEditDoc.GetObject( aEditDoc.Count() - 1 ); + ContentNode* pLastNode = maEditDoc.GetObject( maEditDoc.Count() - 1 ); sal_Int32 nNodes = GetEditDoc().Count(); sal_Int32 nInvalids = 0; Sequence< PropertyValue > aEmptySeq; @@ -2267,7 +2305,7 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC { const sal_Int32 nWStart = aSel.Min().GetIndex(); const sal_Int32 nWEnd = aSel.Max().GetIndex(); - if ( !xSpeller->isValid( aWord, static_cast<sal_uInt16>(GetLanguage( EditPaM( aSel.Min().GetNode(), nWStart+1 ) )), aEmptySeq ) ) + if (!mxSpeller->isValid( aWord, static_cast<sal_uInt16>(GetLanguage( EditPaM( aSel.Min().GetNode(), nWStart+1 ) ).nLang), aEmptySeq)) { // Check if already marked correctly... const sal_Int32 nXEnd = bDottAdded ? nWEnd -1 : nWEnd; @@ -2331,10 +2369,10 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC // Invalidate? if ( nPaintFrom>=0 ) { - aStatus.GetStatusWord() |= EditStatusFlags::WRONGWORDCHANGED; + maStatus.GetStatusWord() |= EditStatusFlags::WRONGWORDCHANGED; CallStatusHdl(); - if (!aEditViews.empty()) + if (!maEditViews.empty()) { // For SimpleRepaint one was painted over a range without // reaching VDEV, but then one would have to intersect, c @@ -2343,35 +2381,35 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC EditPaM aEndPaM( pNode, nPaintTo ); tools::Rectangle aStartCursor( PaMtoEditCursor( aStartPaM ) ); tools::Rectangle aEndCursor( PaMtoEditCursor( aEndPaM ) ); - DBG_ASSERT( aInvalidRect.IsEmpty(), "InvalidRect set!" ); - aInvalidRect.SetLeft( 0 ); - aInvalidRect.SetRight( GetPaperSize().Width() ); - aInvalidRect.SetTop( aStartCursor.Top() ); - aInvalidRect.SetBottom( aEndCursor.Bottom() ); - if ( pActiveView && pActiveView->HasSelection() ) + DBG_ASSERT(maInvalidRect.IsEmpty(), "InvalidRect set!"); + maInvalidRect.SetLeft( 0 ); + maInvalidRect.SetRight( GetPaperSize().Width() ); + maInvalidRect.SetTop( aStartCursor.Top() ); + maInvalidRect.SetBottom( aEndCursor.Bottom() ); + if (mpActiveView && mpActiveView->HasSelection()) { // Then no output through VDev. UpdateViews(); } else if ( bSimpleRepaint ) { - for (EditView* pView : aEditViews) + for (EditView* pView : maEditViews) { - tools::Rectangle aClipRect( aInvalidRect ); + tools::Rectangle aClipRect(maInvalidRect); aClipRect.Intersection( pView->GetVisArea() ); if ( !aClipRect.IsEmpty() ) { // convert to window coordinates... - aClipRect.SetPos( pView->pImpEditView->GetWindowPos( aClipRect.TopLeft() ) ); - pView->pImpEditView->InvalidateAtWindow(aClipRect); + aClipRect.SetPos( pView->getImpl().GetWindowPos( aClipRect.TopLeft() ) ); + pView->getImpl().InvalidateAtWindow(aClipRect); } } } else { - UpdateViews( pActiveView ); + UpdateViews(mpActiveView); } - aInvalidRect = tools::Rectangle(); + maInvalidRect = tools::Rectangle(); } } // After two corrected nodes give up the control... @@ -2387,16 +2425,16 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC break; } if ( bRestartTimer ) - aOnlineSpellTimer.Start(); + maOnlineSpellTimer.Start(); } EESpellState ImpEditEngine::HasSpellErrors() { - DBG_ASSERT( xSpeller.is(), "No spell checker set!" ); + DBG_ASSERT(mxSpeller.is(), "No spell checker set!"); - ContentNode* pLastNode = aEditDoc.GetObject( aEditDoc.Count() - 1 ); - EditSelection aCurSel( aEditDoc.GetStartPaM() ); + ContentNode* pLastNode = maEditDoc.GetObject( maEditDoc.Count() - 1 ); + EditSelection aCurSel( maEditDoc.GetStartPaM() ); OUString aWord; Reference< XSpellAlternatives > xSpellAlt; @@ -2413,9 +2451,9 @@ EESpellState ImpEditEngine::HasSpellErrors() aWord = GetSelected( aCurSel ); if ( !aWord.isEmpty() ) { - LanguageType eLang = GetLanguage( aCurSel.Max() ); - SvxSpellWrapper::CheckSpellLang( xSpeller, eLang ); - xSpellAlt = xSpeller->spell( aWord, static_cast<sal_uInt16>(eLang), aEmptySeq ); + LanguageType eLang = GetLanguage( aCurSel.Max() ).nLang; + SvxSpellWrapper::CheckSpellLang(mxSpeller, eLang); + xSpellAlt = mxSpeller->spell( aWord, static_cast<sal_uInt16>(eLang), aEmptySeq ); } aCurSel = WordRight( aCurSel.Max(), css::i18n::WordType::DICTIONARY_WORD ); } @@ -2425,12 +2463,12 @@ EESpellState ImpEditEngine::HasSpellErrors() void ImpEditEngine::ClearSpellErrors() { - aEditDoc.ClearSpellErrors(); + maEditDoc.ClearSpellErrors(); } -EESpellState ImpEditEngine::StartThesaurus( EditView* pEditView ) +EESpellState ImpEditEngine::StartThesaurus(EditView* pEditView, weld::Widget* pDialogParent) { - EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() ); + EditSelection aCurSel( pEditView->getImpl().GetEditSelection() ); if ( !aCurSel.HasRange() ) aCurSel = SelectWord( aCurSel, css::i18n::WordType::DICTIONARY_WORD ); OUString aWord( GetSelected( aCurSel ) ); @@ -2440,14 +2478,14 @@ EESpellState ImpEditEngine::StartThesaurus( EditView* pEditView ) return EESpellState::ErrorFound; EditAbstractDialogFactory* pFact = EditAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractThesaurusDialog> xDlg(pFact->CreateThesaurusDialog(pEditView->GetWindow()->GetFrameWeld(), xThes, - aWord, GetLanguage( aCurSel.Max() ) )); + ScopedVclPtr<AbstractThesaurusDialog> xDlg(pFact->CreateThesaurusDialog(pDialogParent, xThes, + aWord, GetLanguage( aCurSel.Max() ).nLang )); if (xDlg->Execute() == RET_OK) { // Replace Word... - pEditView->pImpEditView->DrawSelectionXOR(); - pEditView->pImpEditView->SetEditSelection( aCurSel ); - pEditView->pImpEditView->DrawSelectionXOR(); + pEditView->getImpl().DrawSelectionXOR(); + pEditView->getImpl().SetEditSelection( aCurSel ); + pEditView->getImpl().DrawSelectionXOR(); pEditView->InsertText(xDlg->GetWord()); pEditView->ShowCursor(true, false); } @@ -2459,7 +2497,7 @@ sal_Int32 ImpEditEngine::StartSearchAndReplace( EditView* pEditView, const SvxSe { sal_Int32 nFound = 0; - EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() ); + EditSelection aCurSel( pEditView->getImpl().GetEditSelection() ); // FIND_ALL is not possible without multiple selection. if ( ( rSearchItem.GetCommand() == SvxSearchCmd::FIND ) || @@ -2487,10 +2525,10 @@ sal_Int32 ImpEditEngine::StartSearchAndReplace( EditView* pEditView, const SvxSe SvxSearchItem aTmpItem( rSearchItem ); aTmpItem.SetBackward( false ); - pEditView->pImpEditView->DrawSelectionXOR(); + pEditView->getImpl().DrawSelectionXOR(); - aCurSel.Adjust( aEditDoc ); - EditPaM aStartPaM = aTmpItem.GetSelection() ? aCurSel.Min() : aEditDoc.GetStartPaM(); + aCurSel.Adjust( maEditDoc ); + EditPaM aStartPaM = aTmpItem.GetSelection() ? aCurSel.Min() : maEditDoc.GetStartPaM(); EditSelection aFoundSel( aCurSel.Max() ); bool bFound = ImpSearch( aTmpItem, aCurSel, aStartPaM, aFoundSel ); if ( bFound ) @@ -2506,13 +2544,13 @@ sal_Int32 ImpEditEngine::StartSearchAndReplace( EditView* pEditView, const SvxSe EditPaM aNewPaM( aFoundSel.Max() ); if ( aNewPaM.GetIndex() > aNewPaM.GetNode()->Len() ) aNewPaM.SetIndex( aNewPaM.GetNode()->Len() ); - pEditView->pImpEditView->SetEditSelection( aNewPaM ); - FormatAndUpdate( pEditView ); + pEditView->getImpl().SetEditSelection( aNewPaM ); + FormatAndLayout( pEditView ); UndoActionEnd(); } else { - pEditView->pImpEditView->DrawSelectionXOR(); + pEditView->getImpl().DrawSelectionXOR(); pEditView->ShowCursor( true, false ); } } @@ -2521,8 +2559,8 @@ sal_Int32 ImpEditEngine::StartSearchAndReplace( EditView* pEditView, const SvxSe bool ImpEditEngine::Search( const SvxSearchItem& rSearchItem, EditView* pEditView ) { - EditSelection aSel( pEditView->pImpEditView->GetEditSelection() ); - aSel.Adjust( aEditDoc ); + EditSelection aSel( pEditView->getImpl().GetEditSelection() ); + aSel.Adjust( maEditDoc ); EditPaM aStartPaM( aSel.Max() ); if ( rSearchItem.GetSelection() && !rSearchItem.GetBackward() ) aStartPaM = aSel.Min(); @@ -2535,18 +2573,18 @@ bool ImpEditEngine::Search( const SvxSearchItem& rSearchItem, EditView* pEditVie bFound = ImpSearch( rSearchItem, aSel, aStartPaM, aFoundSel ); } - pEditView->pImpEditView->DrawSelectionXOR(); + pEditView->getImpl().DrawSelectionXOR(); if ( bFound ) { // First, set the minimum, so the whole word is in the visible range. - pEditView->pImpEditView->SetEditSelection( aFoundSel.Min() ); + pEditView->getImpl().SetEditSelection( aFoundSel.Min() ); pEditView->ShowCursor( true, false ); - pEditView->pImpEditView->SetEditSelection( aFoundSel ); + pEditView->getImpl().SetEditSelection( aFoundSel ); } else - pEditView->pImpEditView->SetEditSelection( aSel.Max() ); + pEditView->getImpl().SetEditSelection( aSel.Max() ); - pEditView->pImpEditView->DrawSelectionXOR(); + pEditView->getImpl().DrawSelectionXOR(); pEditView->ShowCursor( true, false ); return bFound; } @@ -2559,15 +2597,15 @@ bool ImpEditEngine::ImpSearch( const SvxSearchItem& rSearchItem, bool bBack = rSearchItem.GetBackward(); bool bSearchInSelection = rSearchItem.GetSelection(); - sal_Int32 nStartNode = aEditDoc.GetPos( rStartPos.GetNode() ); + sal_Int32 nStartNode = maEditDoc.GetPos( rStartPos.GetNode() ); sal_Int32 nEndNode; if ( bSearchInSelection ) { - nEndNode = aEditDoc.GetPos( bBack ? rSearchSelection.Min().GetNode() : rSearchSelection.Max().GetNode() ); + nEndNode = maEditDoc.GetPos( bBack ? rSearchSelection.Min().GetNode() : rSearchSelection.Max().GetNode() ); } else { - nEndNode = bBack ? 0 : aEditDoc.Count()-1; + nEndNode = bBack ? 0 : maEditDoc.Count()-1; } utl::TextSearch aSearcher( aSearchOptions ); @@ -2581,7 +2619,7 @@ bool ImpEditEngine::ImpSearch( const SvxSearchItem& rSearchItem, if ( nNode < 0 ) return false; - ContentNode* pNode = aEditDoc.GetObject( nNode ); + ContentNode* pNode = maEditDoc.GetObject( nNode ); sal_Int32 nStartPos = 0; sal_Int32 nEndPos = pNode->GetExpandedLen(); @@ -2636,7 +2674,7 @@ bool ImpEditEngine::HasText( const SvxSearchItem& rSearchItem ) aTmpItem.SetBackward( false ); aTmpItem.SetSelection( false ); - EditPaM aStartPaM( aEditDoc.GetStartPaM() ); + EditPaM aStartPaM( maEditDoc.GetStartPaM() ); EditSelection aDummySel( aStartPaM ); EditSelection aFoundSel; return ImpSearch( aTmpItem, aDummySel, aStartPaM, aFoundSel ); @@ -2644,9 +2682,9 @@ bool ImpEditEngine::HasText( const SvxSearchItem& rSearchItem ) void ImpEditEngine::SetAutoCompleteText(const OUString& rStr, bool bClearTipWindow) { - aAutoCompleteText = rStr; - if ( bClearTipWindow && pActiveView ) - Help::ShowQuickHelp( pActiveView->GetWindow(), tools::Rectangle(), OUString() ); + maAutoCompleteText = rStr; + if ( bClearTipWindow && mpActiveView ) + Help::ShowQuickHelp( mpActiveView->GetWindow(), tools::Rectangle(), OUString() ); } namespace @@ -2668,10 +2706,17 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection, return rSelection; EditSelection aSel( rSelection ); - aSel.Adjust( aEditDoc ); + aSel.Adjust( maEditDoc ); if ( !aSel.HasRange() ) - aSel = SelectWord( aSel ); + { + aSel = SelectWord( aSel, css::i18n::WordType::ANYWORD_IGNOREWHITESPACES, true, true ); + if (!aSel.HasRange() && aSel.Min().GetIndex() > 0 && + OUString(".!?").indexOf(aSel.Min().GetNode()->GetChar(aSel.Min().GetIndex() - 1)) > -1 ) + { + aSel = SelectSentence(aSel); + } + } // tdf#107176: if there's still no range, just return aSel if ( !aSel.HasRange() ) @@ -2679,8 +2724,8 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection, EditSelection aNewSel( aSel ); - const sal_Int32 nStartNode = aEditDoc.GetPos( aSel.Min().GetNode() ); - const sal_Int32 nEndNode = aEditDoc.GetPos( aSel.Max().GetNode() ); + const sal_Int32 nStartNode = maEditDoc.GetPos( aSel.Min().GetNode() ); + const sal_Int32 nEndNode = maEditDoc.GetPos( aSel.Max().GetNode() ); bool bChanges = false; bool bLenChanged = false; @@ -2691,7 +2736,7 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection, for ( sal_Int32 nNode = nStartNode; nNode <= nEndNode; nNode++ ) { - ContentNode* pNode = aEditDoc.GetObject( nNode ); + ContentNode* pNode = maEditDoc.GetObject( nNode ); const OUString& aNodeStr = pNode->GetString(); const sal_Int32 nStartPos = nNode==nStartNode ? aSel.Min().GetIndex() : 0; const sal_Int32 nEndPos = nNode==nEndNode ? aSel.Max().GetIndex() : aNodeStr.getLength(); // can also be == nStart! @@ -2748,6 +2793,21 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection, nWordType); } + /* Nothing to do if user selection lies entirely outside of word start and end boundary computed above. + * Skip this node, because otherwise the below logic for constraining to the selection will fail */ + if (aSttBndry.startPos >= aSel.Max().GetIndex() || aEndBndry.endPos <= aSel.Min().GetIndex()) { + continue; + } + + // prevent going outside of the user's selection, which may + // start or end in the middle of a word + if (nNode == nStartNode) { + aSttBndry.startPos = std::max(aSttBndry.startPos, aSel.Min().GetIndex()); + aSttBndry.endPos = std::min(aSttBndry.endPos, aSel.Max().GetIndex()); + aEndBndry.startPos = std::max(aEndBndry.startPos, aSttBndry.startPos); + aEndBndry.endPos = std::min(aEndBndry.endPos, aSel.Max().GetIndex()); + } + i18n::Boundary aCurWordBndry( aSttBndry ); while (aCurWordBndry.endPos && aCurWordBndry.startPos <= aEndBndry.startPos) { @@ -2758,7 +2818,7 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection, Sequence< sal_Int32 > aOffsets; OUString aNewText( aTransliterationWrapper.transliterate(aNodeStr, - GetLanguage( EditPaM( pNode, nCurrentStart + 1 ) ), + GetLanguage( EditPaM( pNode, nCurrentStart + 1 ) ).nLang, nCurrentStart, nLen, &aOffsets )); if (aNodeStr != aNewText) @@ -2836,6 +2896,12 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection, nCurrentEnd = nLastEnd; } + // prevent making any change outside of the user's selection + nCurrentStart = std::max(aSel.Min().GetIndex(), nCurrentStart); + nCurrentEnd = std::min(aSel.Max().GetIndex(), nCurrentEnd); + nLastStart = std::max(aSel.Min().GetIndex(), nLastStart); + nLastEnd = std::min(aSel.Max().GetIndex(), nLastEnd); + while (nCurrentStart < nLastEnd) { const sal_Int32 nLen = nCurrentEnd - nCurrentStart; @@ -2843,7 +2909,7 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection, Sequence< sal_Int32 > aOffsets; OUString aNewText( aTransliterationWrapper.transliterate( aNodeStr, - GetLanguage( EditPaM( pNode, nCurrentStart + 1 ) ), + GetLanguage( EditPaM( pNode, nCurrentStart + 1 ) ).nLang, nCurrentStart, nLen, &aOffsets )); if (aNodeStr != aNewText) @@ -2873,7 +2939,7 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection, { if ( bConsiderLanguage ) { - nLanguage = GetLanguage( EditPaM( pNode, nCurrentStart+1 ), &nCurrentEnd ); + nLanguage = GetLanguage( EditPaM( pNode, nCurrentStart+1 ), &nCurrentEnd ).nLang; if ( nCurrentEnd > nEndPos ) nCurrentEnd = nEndPos; } @@ -2916,7 +2982,7 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection, aNewSel = aSel; ESelection aESel( CreateESel( aSel ) ); - pUndo.reset(new EditUndoTransliteration(pEditEngine, aESel, nTransliterationMode)); + pUndo.reset(new EditUndoTransliteration(mpEditEngine, aESel, nTransliterationMode)); const bool bSingleNode = aSel.Min().GetNode()== aSel.Max().GetNode(); const bool bHasAttribs = aSel.Min().GetNode()->GetCharAttribs().HasAttrib( aSel.Min().GetIndex(), aSel.Max().GetIndex() ); @@ -2945,9 +3011,9 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection, if (aSel.Max().GetNode() == rData.aSelection.Max().GetNode()) aNewSel.Max().SetIndex( aNewSel.Max().GetIndex() + nDiffs ); - sal_Int32 nSelNode = aEditDoc.GetPos( rData.aSelection.Min().GetNode() ); - ParaPortion* pParaPortion = GetParaPortions()[nSelNode]; - pParaPortion->MarkSelectionInvalid( rData.nStart ); + sal_Int32 nSelNode = maEditDoc.GetPos( rData.aSelection.Min().GetNode() ); + ParaPortion& rParaPortion = GetParaPortions().getRef(nSelNode); + rParaPortion.MarkSelectionInvalid(rData.nStart); } } } @@ -2965,7 +3031,8 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection, SetModifyFlag( true ); if ( bLenChanged ) UpdateSelections(); - FormatAndUpdate(); + if (IsUpdateLayout()) + FormatAndLayout(); } return aNewSel; @@ -3004,7 +3071,7 @@ short ImpEditEngine::ReplaceTextOnly( else { DBG_ASSERT( nDiff == 1, "TransliterateText - Diff other than expected! But should work..." ); - GetEditDoc().InsertText( EditPaM( pNode, nCurrentPos ), OUString(rNewText[n]) ); + GetEditDoc().InsertText( EditPaM( pNode, nCurrentPos ), OUStringChar(rNewText[n]) ); } nDiffs = sal::static_int_cast< short >(nDiffs + nDiff); @@ -3016,9 +3083,9 @@ short ImpEditEngine::ReplaceTextOnly( void ImpEditEngine::SetAsianCompressionMode( CharCompressType n ) { - if ( n != nAsianCompressionMode ) + if (n != mnAsianCompressionMode) { - nAsianCompressionMode = n; + mnAsianCompressionMode = n; if ( ImplHasText() ) { FormatFullDoc(); @@ -3029,9 +3096,9 @@ void ImpEditEngine::SetAsianCompressionMode( CharCompressType n ) void ImpEditEngine::SetKernAsianPunctuation( bool b ) { - if ( b != bKernAsianPunctuation ) + if ( b != mbKernAsianPunctuation ) { - bKernAsianPunctuation = b; + mbKernAsianPunctuation = b; if ( ImplHasText() ) { FormatFullDoc(); @@ -3044,7 +3111,7 @@ void ImpEditEngine::SetAddExtLeading( bool bExtLeading ) { if ( IsAddExtLeading() != bExtLeading ) { - bAddExtLeading = bExtLeading; + mbAddExtLeading = bExtLeading; if ( ImplHasText() ) { FormatFullDoc(); @@ -3063,8 +3130,21 @@ sal_Int32 ImpEditEngine::LogicToTwips(sal_Int32 n) { Size aSz(n, 0); MapMode aTwipsMode( MapUnit::MapTwip ); - aSz = pRefDev->LogicToLogic( aSz, nullptr, &aTwipsMode ); + aSz = mpRefDev->LogicToLogic( aSz, nullptr, &aTwipsMode ); return aSz.Width(); } +double ImpEditEngine::roundToNearestPt(double fInput) const +{ + if (mbRoundToNearestPt) + { + double fInputPt = o3tl::convert(fInput, o3tl::Length::mm100, o3tl::Length::pt); + return o3tl::convert(std::round(fInputPt), o3tl::Length::pt, o3tl::Length::mm100); + } + else + { + return fInput; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |