summaryrefslogtreecommitdiff
path: root/editeng/source/editeng/impedit4.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'editeng/source/editeng/impedit4.cxx')
-rw-r--r--editeng/source/editeng/impedit4.cxx853
1 files changed, 468 insertions, 385 deletions
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index dd3f13cf0f47..b761c4914c07 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>
@@ -116,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() );
@@ -144,7 +141,7 @@ 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();
@@ -153,7 +150,7 @@ EditPaM ImpEditEngine::ReadRTF( SvStream& rInput, EditSelection aSel )
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() ) )
{
@@ -169,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 );
@@ -206,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;
@@ -252,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 ) )
{
@@ -282,25 +279,25 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
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;
@@ -309,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;
}
@@ -325,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() )
{
@@ -358,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;
@@ -378,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!
@@ -392,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( ';' );
}
@@ -429,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++ )
@@ -455,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)
@@ -467,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( '}' );
@@ -483,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;
@@ -494,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 ...
@@ -514,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!
@@ -545,20 +562,21 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
rOutput.WriteChar( ' ' ); // Separator
ItemList aAttribItems;
- ParaPortion& rParaPortion = FindParaPortion( pNode );
+ ParaPortion* pParaPortion = FindParaPortion( pNode );
+ DBG_ASSERT( pParaPortion, "Portion not found: WriteRTF" );
sal_Int32 nIndex = 0;
sal_Int32 nStartPos = 0;
sal_Int32 nEndPos = pNode->Len();
sal_Int32 nStartPortion = 0;
- sal_Int32 nEndPortion = rParaPortion.GetTextPortions().Count() - 1;
+ sal_Int32 nEndPortion = pParaPortion->GetTextPortions().Count() - 1;
bool bFinishPortion = false;
sal_Int32 nPortionStart;
if ( nNode == nStartNode )
{
nStartPos = aSel.Min().GetIndex();
- nStartPortion = rParaPortion.GetTextPortions().FindPortion( nStartPos, nPortionStart );
+ nStartPortion = pParaPortion->GetTextPortions().FindPortion( nStartPos, nPortionStart );
if ( nStartPos != 0 )
{
aAttribItems.Clear();
@@ -576,14 +594,14 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
if ( nNode == nEndNode ) // can also be == nStart!
{
nEndPos = aSel.Max().GetIndex();
- nEndPortion = rParaPortion.GetTextPortions().FindPortion( nEndPos, nPortionStart );
+ nEndPortion = pParaPortion->GetTextPortions().FindPortion( nEndPos, nPortionStart );
}
const EditCharAttrib* pNextFeature = pNode->GetCharAttribs().FindFeature(nIndex);
// start at 0, so the index is right ...
for ( sal_Int32 n = 0; n <= nEndPortion; n++ )
{
- const TextPortion& rTextPortion = rParaPortion.GetTextPortions()[n];
+ const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[n];
if ( n < nStartPortion )
{
nIndex = nIndex + rTextPortion.GetLen();
@@ -636,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();
@@ -659,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:
@@ -669,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 )
@@ -717,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:
@@ -726,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;
}
}
@@ -741,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;
@@ -753,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:
@@ -771,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:
@@ -794,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;
@@ -806,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;
}
@@ -820,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;
}
@@ -835,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;
}
@@ -850,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;
}
@@ -859,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' );
}
@@ -868,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(
@@ -948,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;
}
@@ -965,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 );
}
@@ -974,15 +1011,15 @@ 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 )
@@ -990,9 +1027,9 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a
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() ) );
@@ -1000,7 +1037,7 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a
// Templates are not saved!
// (Only the name and family, template itself must be in App!)
- const MapUnit eMapUnit = aEditDoc.GetItemPool().GetMetric(DEF_METRIC);
+ const MapUnit eMapUnit = maEditDoc.GetItemPool().GetMetric(DEF_METRIC);
auto pTxtObj(std::make_unique<EditTextObjectImpl>(pPool, eMapUnit, GetVertical(), GetRotation(),
GetItemScriptType(aSel)));
@@ -1008,13 +1045,12 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a
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& rParaPortion = GetParaPortions()[nNode];
- nTextPortions += rParaPortion.GetTextPortions().Count();
+ nTextPortions += GetParaPortions().getRef(nNode).GetTextPortions().Count();
}
sal_Int32 nStartPos = 0;
@@ -1045,8 +1081,9 @@ 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!
@@ -1067,9 +1104,7 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a
aX.GetEnd() = nEndPos-nStartPos;
}
DBG_ASSERT( aX.GetEnd() <= (nEndPos-nStartPos), "CreateTextObject: Attribute too long!" );
- if ( !aX.GetLen() && !bEmptyPara )
- pTxtObj->DestroyAttrib(aX);
- else
+ if ( aX.GetLen() || bEmptyPara )
rCAttriblist.push_back(std::move(aX));
}
nAttr++;
@@ -1086,11 +1121,11 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a
// sleeper set up when Olli paragraphs not hacked!
if ( bAllowBigObjects && bOnlyFullParagraphs && IsFormatted() && IsUpdateLayout() && ( nTextPortions >= nBigObjectStart ) )
{
- XParaPortionList* pXList = new XParaPortionList( GetRefDevice(), GetColumnWidth(aPaperSize), nStretchX, nStretchY );
+ XParaPortionList* pXList = new XParaPortionList(GetRefDevice(), GetColumnWidth(maPaperSize), mfFontScaleX, mfFontScaleY, mfSpacingScaleX, mfSpacingScaleY);
pTxtObj->SetPortionInfo(std::unique_ptr<XParaPortionList>(pXList));
for ( nNode = nStartNode; nNode <= nEndNode; nNode++ )
{
- const ParaPortion& rParaPortion = GetParaPortions()[nNode];
+ ParaPortion const& rParaPortion = GetParaPortions().getRef(nNode);
XParaPortion* pX = new XParaPortion;
pXList->push_back(pX);
@@ -1112,17 +1147,16 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a
for ( n = 0; n < nCount; n++ )
{
const EditLine& rLine = rParaPortion.GetLines()[n];
- EditLine* pNew = rLine.Clone();
- pX->aLines.Append(pNew);
+ pX->aLines.Append(std::unique_ptr<EditLine>(rLine.Clone()));
}
#ifdef DBG_UTIL
sal_uInt16 nTest;
int nTPLen = 0, nTxtLen = 0;
- for ( nTest = rParaPortion.GetTextPortions().Count(); nTest; )
+ for (nTest = rParaPortion.GetTextPortions().Count(); nTest;)
nTPLen += rParaPortion.GetTextPortions()[--nTest].GetLen();
- for ( nTest = rParaPortion.GetLines().Count(); nTest; )
+ 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!" );
+ DBG_ASSERT(nTPLen == rParaPortion.GetNode()->Len() && nTxtLen == rParaPortion.GetNode()->Len(), "CreateBinTextObject: ParaPortion not completely formatted!");
#endif
}
}
@@ -1137,7 +1171,7 @@ void ImpEditEngine::SetText( const EditTextObject& rTextObject )
bool _bUndo = IsUndoEnabled();
SetText( OUString() );
- EditPaM aPaM = aEditDoc.GetStartPaM();
+ EditPaM aPaM = maEditDoc.GetStartPaM();
SetUpdateLayout( false );
EnableUndo( false );
@@ -1153,7 +1187,7 @@ void ImpEditEngine::SetText( const EditTextObject& rTextObject )
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() );
@@ -1164,16 +1198,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;
const EditTextObjectImpl& rTextObjectImpl = toImpl(rTextObject);
XParaPortionList* pPortionInfo = rTextObjectImpl.GetPortionInfo();
- if ( pPortionInfo && ( static_cast<tools::Long>(pPortionInfo->GetPaperWidth()) == GetColumnWidth(aPaperSize) )
- && ( pPortionInfo->GetRefMapMode() == GetRefDevice()->GetMapMode() )
- && ( pPortionInfo->GetStretchX() == nStretchX )
- && ( pPortionInfo->GetStretchY() == nStretchY ) )
+ if (pPortionInfo && ( static_cast<tools::Long>(pPortionInfo->GetPaperWidth()) == GetColumnWidth(maPaperSize))
+ && pPortionInfo->GetRefMapMode() == GetRefDevice()->GetMapMode()
+ && pPortionInfo->getFontScaleX() == mfFontScaleX
+ && pPortionInfo->getFontScaleY() == mfFontScaleY
+ && pPortionInfo->getSpacingScaleX() == mfSpacingScaleX
+ && pPortionInfo->getSpacingScaleY() == mfSpacingScaleY)
{
if ( (pPortionInfo->GetRefDevPtr() == GetRefDevice()) ||
(pPortionInfo->RefDevIsVirtual() && GetRefDevice()->IsVirtual()) )
@@ -1185,7 +1221,7 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject
if (rTextObjectImpl.HasMetric())
{
eSourceUnit = rTextObjectImpl.GetMetric();
- eDestUnit = aEditDoc.GetItemPool().GetMetric( DEF_METRIC );
+ eDestUnit = maEditDoc.GetItemPool().GetMetric( DEF_METRIC );
if ( eSourceUnit != eDestUnit )
bConvertMetricOfItems = true;
}
@@ -1195,7 +1231,7 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject
// number paragraphs and is fearlessly incremented.
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)
{
@@ -1205,8 +1241,9 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject
aPaM = ImpFastInsertText( aPaM, pC->GetText() );
- ParaPortion& rPortion = FindParaPortion( aPaM.GetNode() );
- rPortion.MarkInvalid( nStartPos, pC->GetText().getLength() );
+ ParaPortion* pPortion = FindParaPortion( aPaM.GetNode() );
+ DBG_ASSERT( pPortion, "Blind Portion in FastInsertText" );
+ pPortion->MarkInvalid( nStartPos, pC->GetText().getLength() );
// Character attributes ...
bool bAllreadyHasAttribs = aPaM.GetNode()->GetCharAttribs().Count() != 0;
@@ -1230,12 +1267,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 );
@@ -1246,7 +1283,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() );
}
}
}
@@ -1254,7 +1291,7 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject
UpdateFields();
// Otherwise, quick format => no attributes!
- rPortion.MarkSelectionInvalid( nStartPos );
+ pPortion->MarkSelectionInvalid( nStartPos );
}
#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
@@ -1274,57 +1311,58 @@ 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& rParaPortion = GetParaPortions()[ nPara ];
- rParaPortion.nHeight = rXP.nHeight;
- rParaPortion.nFirstLineOffset = rXP.nFirstLineOffset;
- rParaPortion.bForceRepaint = true;
- rParaPortion.SetValid(); // Do not format
+ ParaPortion* pParaPortion = GetParaPortions().SafeGetObject(nPara);
+ DBG_ASSERT( pParaPortion, "InsertBinTextObject: ParaPortion?" );
+ pParaPortion->mnHeight = rXP.nHeight;
+ pParaPortion->mnFirstLineOffset = rXP.nFirstLineOffset;
+ pParaPortion->mbForceRepaint = true;
+ pParaPortion->SetValid(); // Do not format
// The Text Portions
- rParaPortion.GetTextPortions().Reset();
+ pParaPortion->GetTextPortions().Reset();
sal_uInt16 nCount = rXP.aTextPortions.Count();
for ( sal_uInt16 _n = 0; _n < nCount; _n++ )
{
const TextPortion& rTextPortion = rXP.aTextPortions[_n];
TextPortion* pNew = new TextPortion( rTextPortion );
- rParaPortion.GetTextPortions().Append(pNew);
+ pParaPortion->GetTextPortions().Append(pNew);
}
// The lines
- rParaPortion.GetLines().Reset();
+ pParaPortion->GetLines().Reset();
nCount = rXP.aLines.Count();
for ( sal_uInt16 m = 0; m < nCount; m++ )
{
const EditLine& rLine = rXP.aLines[m];
EditLine* pNew = rLine.Clone();
pNew->SetInvalid(); // Paint again!
- rParaPortion.GetLines().Append(pNew);
+ pParaPortion->GetLines().Append(std::unique_ptr<EditLine>(pNew));
}
#ifdef DBG_UTIL
sal_uInt16 nTest;
int nTPLen = 0, nTxtLen = 0;
- 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() ), "InsertTextObject: ParaPortion not completely formatted!" );
+ 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() ), "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();
}
@@ -1344,7 +1382,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;
}
@@ -1380,73 +1418,82 @@ void ImpEditEngine::SetAllMisspellRanges( const std::vector<editeng::MisspellRan
}
}
-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, 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;
{
@@ -1456,16 +1503,16 @@ EESpellState ImpEditEngine::Spell(EditView* pEditView, weld::Widget* pDialogPare
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;
}
@@ -1474,11 +1521,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 ];
@@ -1489,8 +1536,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) ||
@@ -1512,15 +1559,15 @@ void ImpEditEngine::Convert( EditView* pEditView, weld::Widget* pDialogParent,
// 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
@@ -1538,16 +1585,16 @@ void ImpEditEngine::Convert( EditView* pEditView, weld::Widget* pDialogParent,
// 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( pDialogParent,
@@ -1577,15 +1624,15 @@ void ImpEditEngine::Convert( EditView* pEditView, weld::Widget* pDialogParent,
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();
}
@@ -1594,11 +1641,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?
@@ -1616,9 +1663,8 @@ void ImpEditEngine::SetLanguageAndFont(
}
// apply new attributes
- pActiveView->SetAttribs( aNewSet );
-
- pActiveView->SetSelection( aOldSel );
+ mpActiveView->SetAttribs(aNewSet);
+ mpActiveView->SetSelection(aOldSel);
}
@@ -1634,7 +1680,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;
@@ -1643,9 +1689,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,
@@ -1654,8 +1700,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;
@@ -1663,7 +1709,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 ];
@@ -1674,8 +1720,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) ||
@@ -1743,26 +1789,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() );
@@ -1776,12 +1822,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;
@@ -1792,10 +1838,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;
@@ -1805,7 +1851,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 )
{
@@ -1813,10 +1859,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;
}
@@ -1837,20 +1883,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;
}
@@ -1886,13 +1932,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;
}
}
@@ -1903,18 +1949,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
@@ -1953,7 +1999,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;
}
@@ -1970,14 +2016,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
@@ -2004,8 +2050,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().
@@ -2031,7 +2077,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;
@@ -2056,27 +2102,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
{
@@ -2088,7 +2134,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 );
@@ -2102,7 +2148,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 );
@@ -2110,7 +2156,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 );
}
@@ -2119,12 +2165,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
@@ -2133,7 +2179,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 );
@@ -2144,7 +2190,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 );
}
@@ -2156,28 +2202,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 );
if (IsUpdateLayout())
FormatAndLayout();
- aEditDoc.SetModified(true);
+ 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());
}
}
@@ -2195,18 +2241,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;
@@ -2257,7 +2303,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;
@@ -2321,10 +2367,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
@@ -2333,35 +2379,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...
@@ -2377,16 +2423,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;
@@ -2403,9 +2449,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 );
}
@@ -2415,12 +2461,12 @@ EESpellState ImpEditEngine::HasSpellErrors()
void ImpEditEngine::ClearSpellErrors()
{
- aEditDoc.ClearSpellErrors();
+ maEditDoc.ClearSpellErrors();
}
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 ) );
@@ -2431,13 +2477,13 @@ EESpellState ImpEditEngine::StartThesaurus(EditView* pEditView, weld::Widget* pD
EditAbstractDialogFactory* pFact = EditAbstractDialogFactory::Create();
ScopedVclPtr<AbstractThesaurusDialog> xDlg(pFact->CreateThesaurusDialog(pDialogParent, xThes,
- aWord, GetLanguage( aCurSel.Max() ) ));
+ 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);
}
@@ -2449,7 +2495,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 ) ||
@@ -2477,10 +2523,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 )
@@ -2496,13 +2542,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 );
+ pEditView->getImpl().SetEditSelection( aNewPaM );
FormatAndLayout( pEditView );
UndoActionEnd();
}
else
{
- pEditView->pImpEditView->DrawSelectionXOR();
+ pEditView->getImpl().DrawSelectionXOR();
pEditView->ShowCursor( true, false );
}
}
@@ -2511,8 +2557,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();
@@ -2525,18 +2571,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;
}
@@ -2549,15 +2595,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 );
@@ -2571,7 +2617,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();
@@ -2626,7 +2672,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 );
@@ -2634,9 +2680,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
@@ -2658,10 +2704,12 @@ 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 );
+ }
// tdf#107176: if there's still no range, just return aSel
if ( !aSel.HasRange() )
@@ -2669,8 +2717,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;
@@ -2681,7 +2729,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!
@@ -2738,6 +2786,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)
{
@@ -2748,7 +2811,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)
@@ -2826,6 +2889,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;
@@ -2833,7 +2902,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)
@@ -2863,7 +2932,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;
}
@@ -2906,7 +2975,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() );
@@ -2935,9 +3004,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& rParaPortion = GetParaPortions()[nSelNode];
- rParaPortion.MarkSelectionInvalid( rData.nStart );
+ sal_Int32 nSelNode = maEditDoc.GetPos( rData.aSelection.Min().GetNode() );
+ ParaPortion& rParaPortion = GetParaPortions().getRef(nSelNode);
+ rParaPortion.MarkSelectionInvalid(rData.nStart);
}
}
}
@@ -2995,7 +3064,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);
@@ -3007,9 +3076,9 @@ short ImpEditEngine::ReplaceTextOnly(
void ImpEditEngine::SetAsianCompressionMode( CharCompressType n )
{
- if ( n != nAsianCompressionMode )
+ if (n != mnAsianCompressionMode)
{
- nAsianCompressionMode = n;
+ mnAsianCompressionMode = n;
if ( ImplHasText() )
{
FormatFullDoc();
@@ -3020,9 +3089,9 @@ void ImpEditEngine::SetAsianCompressionMode( CharCompressType n )
void ImpEditEngine::SetKernAsianPunctuation( bool b )
{
- if ( b != bKernAsianPunctuation )
+ if ( b != mbKernAsianPunctuation )
{
- bKernAsianPunctuation = b;
+ mbKernAsianPunctuation = b;
if ( ImplHasText() )
{
FormatFullDoc();
@@ -3035,7 +3104,7 @@ void ImpEditEngine::SetAddExtLeading( bool bExtLeading )
{
if ( IsAddExtLeading() != bExtLeading )
{
- bAddExtLeading = bExtLeading;
+ mbAddExtLeading = bExtLeading;
if ( ImplHasText() )
{
FormatFullDoc();
@@ -3054,8 +3123,22 @@ 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);
+ auto nInputRounded = basegfx::fround(fInputPt);
+ return o3tl::convert(double(nInputRounded), o3tl::Length::pt, o3tl::Length::mm100);
+ }
+ else
+ {
+ return fInput;
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */