xub_StrLen and tools/string.hxx final straw

Thre is still some 0xffff limit left and possibly some
less than gracefully handled overflow/error cases

Change-Id: I00957ee3a30b02f73918ea49d7353056263dc638
Reviewed-on: https://gerrit.libreoffice.org/7787
Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com>
Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index be3922b..71a816d 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -348,14 +348,15 @@ bool lcl_hasWordBreak( const Reference< drawing::XShape >& rxShape )
                    sal_Int32 nParaCount = pTextForwarder->GetParagraphCount();
                    for ( sal_Int32 nPara = 0; nPara < nParaCount; ++nPara )
                    {
                        sal_uInt16 nLineCount = pTextForwarder->GetLineCount( nPara );
                        for ( sal_uInt16 nLine = 0; nLine < nLineCount; ++nLine )
                        sal_Int32 nLineCount = pTextForwarder->GetLineCount( nPara );
                        for ( sal_Int32 nLine = 0; nLine < nLineCount; ++nLine )
                        {
                            sal_uInt16 nLineStart = 0;
                            sal_uInt16 nLineEnd = 0;
                            sal_Int32 nLineStart = 0;
                            sal_Int32 nLineEnd = 0;
                            pTextForwarder->GetLineBoundaries( nLineStart, nLineEnd, nPara, nLine );
                            sal_uInt16 nWordStart = 0;
                            sal_uInt16 nWordEnd = 0;
                            assert(nLineStart >= 0);
                            sal_Int32 nWordStart = 0;
                            sal_Int32 nWordEnd = 0;
                            if ( pTextForwarder->GetWordIndices( nPara, nLineStart, nWordStart, nWordEnd ) &&
                                 ( nWordStart != nLineStart ) )
                            {
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index 27b910e..bae28f4 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -403,26 +403,26 @@ void Test::testSectionAttributes()

        // First section should be 0-3 of paragraph 0, and it should only have boldness applied.
        const editeng::Section* pSecAttr = &aAttrs[0];
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pSecAttr->mnEnd);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pSecAttr->maAttributes.size());
        CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(3, (int)pSecAttr->mnEnd);
        CPPUNIT_ASSERT_EQUAL(1, (int)pSecAttr->maAttributes.size());
        CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(*pSecAttr));

        // Second section should be 3-6, and it should be both bold and italic.
        pSecAttr = &aAttrs[1];
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(6), pSecAttr->mnEnd);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pSecAttr->maAttributes.size());
        CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(3, (int)pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(6, (int)pSecAttr->mnEnd);
        CPPUNIT_ASSERT_EQUAL(2, (int)pSecAttr->maAttributes.size());
        CPPUNIT_ASSERT_MESSAGE("This section must be bold and italic.", hasBold(*pSecAttr) && hasItalic(*pSecAttr));

        // Third section should be 6-9, and it should be only italic.
        pSecAttr = &aAttrs[2];
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(6), pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(9), pSecAttr->mnEnd);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pSecAttr->maAttributes.size());
        CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(6, (int)pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(9, (int)pSecAttr->mnEnd);
        CPPUNIT_ASSERT_EQUAL(1, (int)pSecAttr->maAttributes.size());
        CPPUNIT_ASSERT_MESSAGE("This section must be italic.", hasItalic(*pSecAttr));
    }

@@ -452,37 +452,37 @@ void Test::testSectionAttributes()

        // 1st, 3rd and 5th sections should correspond with 1st, 3rd and 5th paragraphs.
        const editeng::Section* pSecAttr = &aAttrs[0];
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pSecAttr->mnEnd);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pSecAttr->maAttributes.size());
        CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(3, (int)pSecAttr->mnEnd);
        CPPUNIT_ASSERT_EQUAL(1, (int)pSecAttr->maAttributes.size());
        CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(*pSecAttr));

        pSecAttr = &aAttrs[2];
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pSecAttr->mnEnd);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pSecAttr->maAttributes.size());
        CPPUNIT_ASSERT_EQUAL(2, (int)pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(3, (int)pSecAttr->mnEnd);
        CPPUNIT_ASSERT_EQUAL(1, (int)pSecAttr->maAttributes.size());
        CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(*pSecAttr));

        pSecAttr = &aAttrs[4];
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), pSecAttr->mnEnd);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pSecAttr->maAttributes.size());
        CPPUNIT_ASSERT_EQUAL(4, (int)pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(5, (int)pSecAttr->mnEnd);
        CPPUNIT_ASSERT_EQUAL(1, (int)pSecAttr->maAttributes.size());
        CPPUNIT_ASSERT_MESSAGE("This section must be bold.", hasBold(*pSecAttr));

        // The 2nd and 4th paragraphs should be empty.
        pSecAttr = &aAttrs[1];
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnEnd);
        CPPUNIT_ASSERT_EQUAL(1, (int)pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnEnd);
        CPPUNIT_ASSERT_MESSAGE("Attribute array should be empty.", pSecAttr->maAttributes.empty());

        pSecAttr = &aAttrs[3];
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnEnd);
        CPPUNIT_ASSERT_EQUAL(3, (int)pSecAttr->mnParagraph);
        CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnStart);
        CPPUNIT_ASSERT_EQUAL(0, (int)pSecAttr->mnEnd);
        CPPUNIT_ASSERT_MESSAGE("Attribute array should be empty.", pSecAttr->maAttributes.empty());
    }
}
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
index 001389b..7fc3f53 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -217,7 +217,7 @@ namespace accessibility

        rBoundary.startPos = rBoundary.endPos = -1;

        const sal_uInt16 nLineCount=rCacheTF.GetLineCount( nParaIndex );
        const sal_Int32 nLineCount=rCacheTF.GetLineCount( nParaIndex );

        if( nIndex == nTextLen )
        {
@@ -233,7 +233,7 @@ namespace accessibility
        else
        {
            // normal line search
            sal_uInt16 nLine;
            sal_Int32 nLine;
            sal_Int32 nCurIndex;
            for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine )
            {
@@ -650,9 +650,9 @@ namespace accessibility
        }
    }

    sal_Bool AccessibleEditableTextPara::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nIndex )
    sal_Bool AccessibleEditableTextPara::GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nIndex )
    {
        DBG_ASSERT(nIndex >= 0 && nIndex <= USHRT_MAX,
        DBG_ASSERT(nIndex >= 0 && nIndex <= SAL_MAX_INT32,
                   "AccessibleEditableTextPara::GetAttributeRun: index value overflow");

        DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= SAL_MAX_INT32,
@@ -1398,7 +1398,7 @@ namespace accessibility
        SolarMutexGuard aGuard;

        sal_Int32 nPara;
        sal_uInt16 nIndex;
        sal_Int32 nIndex;

        // offset from surrounding cell/shape
        Point aOffset( GetEEOffset() );
@@ -1821,7 +1821,7 @@ namespace accessibility
                }
                else
                {
                    sal_uInt16 nStartIndex, nEndIndex;
                    sal_Int32 nStartIndex, nEndIndex;
                    //For the bullet paragraph, the bullet string is ingnored for IAText::attributes() function.
                    SvxTextForwarder&   rCacheTF = GetTextForwarder();
                    // MT IA2: Not used? sal_Int32 nBulletLen = 0;
@@ -1852,7 +1852,7 @@ namespace accessibility
                CheckPosition(nIndex);
        if (nIndex != 0  && nIndex == getCharacterCount())
            --nIndex;
                sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( nParaIndex );
                sal_Int32 nLine, nLineCount=rCacheTF.GetLineCount( nParaIndex );
                sal_Int32 nCurIndex;
                //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line,
                //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed
@@ -1921,7 +1921,7 @@ namespace accessibility
            case AccessibleTextType::ATTRIBUTE_RUN:
            {
                const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( GetParagraphIndex() );
                sal_uInt16 nStartIndex, nEndIndex;
                sal_Int32 nStartIndex, nEndIndex;

                if( nIndex == nTextLen )
                {
@@ -1958,7 +1958,7 @@ namespace accessibility

                CheckPosition(nIndex);

                sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) );
                sal_Int32 nLine, nLineCount=rCacheTF.GetLineCount( nParaIndex );
                //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line,
                //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed
                //by the IAText::attributes(). So here must do special support for bullet line.
@@ -1981,7 +1981,7 @@ namespace accessibility
                        nLastLineLen = nCurLineLen - nBulletLen;
                    else
                        nLastLineLen = nCurLineLen;
                    nCurLineLen = rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine);
                    nCurLineLen = rCacheTF.GetLineLen( nParaIndex, nLine);
                    //nCurIndex += nCurLineLen;
                    if (nLine == 0)
                        nCurIndex += nCurLineLen - nBulletLen;
@@ -2083,7 +2083,7 @@ namespace accessibility
        {
            case AccessibleTextType::ATTRIBUTE_RUN:
            {
                sal_uInt16 nStartIndex, nEndIndex;
                sal_Int32 nStartIndex, nEndIndex;

                if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) )
                {
@@ -2109,7 +2109,7 @@ namespace accessibility

                CheckPosition(nIndex);

                sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) );
                sal_Int32 nLine, nLineCount = rCacheTF.GetLineCount( nParaIndex );
                sal_Int32 nCurIndex;
                //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line,
                //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed
@@ -2128,7 +2128,7 @@ namespace accessibility
                        }
                    }
                    //nCurIndex += rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine);
                    sal_Int32 nLineLen = rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine);
                    sal_Int32 nLineLen = rCacheTF.GetLineLen( nParaIndex, nLine);

                    if (nLine == 0)
                        nCurIndex += nLineLen - nBulletLen;
@@ -2139,7 +2139,7 @@ namespace accessibility
                        nLine < nLineCount-1 )
                    {
                        aResult.SegmentStart = nCurIndex;
                        aResult.SegmentEnd = nCurIndex + rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine+1);
                        aResult.SegmentEnd = nCurIndex + rCacheTF.GetLineLen( nParaIndex, nLine+1);
                        aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen);
                        break;
                    }
@@ -2780,7 +2780,7 @@ namespace accessibility
        {
            // we explicitly allow for the index to point at the character right behind the text
            if (0 <= nIndex && nIndex <= rCacheTF.GetTextLen( nPara ))
                nRes = rCacheTF.GetLineNumberAtIndex( nPara, static_cast< sal_uInt16 >(nIndex) );
                nRes = rCacheTF.GetLineNumberAtIndex( nPara, nIndex );
            else
                throw lang::IndexOutOfBoundsException();
        }
@@ -2800,9 +2800,9 @@ namespace accessibility
        {
            if (0 <= nLineNo && nLineNo < rCacheTF.GetLineCount( nPara ))
            {
                sal_uInt16 nStart = 0, nEnd = 0;
                rCacheTF.GetLineBoundaries( nStart, nEnd, nPara, static_cast< sal_uInt16 >(nLineNo) );
                if (nStart != 0xFFFF && nEnd != 0xFFFF)
                sal_Int32 nStart = 0, nEnd = 0;
                rCacheTF.GetLineBoundaries( nStart, nEnd, nPara, nLineNo );
                if (nStart >= 0 && nEnd >=  0)
                {
                    try
                    {
diff --git a/editeng/source/accessibility/AccessibleStaticTextBase.cxx b/editeng/source/accessibility/AccessibleStaticTextBase.cxx
index d7fa158..74dfa9f 100644
--- a/editeng/source/accessibility/AccessibleStaticTextBase.cxx
+++ b/editeng/source/accessibility/AccessibleStaticTextBase.cxx
@@ -926,7 +926,7 @@ namespace accessibility
        else if ( AccessibleTextType::ATTRIBUTE_RUN == aTextType )
        {
              SvxAccessibleTextAdapter& rTextForwarder = mpImpl->GetParagraph( aPos.nIndex ).GetTextForwarder();
              sal_uInt16 nStartIndex, nEndIndex;
              sal_Int32 nStartIndex, nEndIndex;
              if ( rTextForwarder.GetAttributeRun( nStartIndex, nEndIndex, aPos.nPara, aPos.nIndex, sal_True ) )
              {
                     aResult.SegmentText = getTextRange( nStartIndex, nEndIndex );
diff --git a/editeng/source/editeng/editattr.hxx b/editeng/source/editeng/editattr.hxx
index 3917427..035efda 100644
--- a/editeng/source/editeng/editattr.hxx
+++ b/editeng/source/editeng/editattr.hxx
@@ -117,28 +117,28 @@ inline sal_uInt16 EditCharAttrib::GetLen() const

inline void EditCharAttrib::MoveForward( sal_uInt16 nDiff )
{
    DBG_ASSERT( ((long)nEnd + nDiff) <= 0xFFFF, "EditCharAttrib: MoveForward?!" );
    DBG_ASSERT( SAL_MAX_INT32 - nDiff > nEnd, "EditCharAttrib: MoveForward?!" );
    nStart = nStart + nDiff;
    nEnd = nEnd + nDiff;
}

inline void EditCharAttrib::MoveBackward( sal_uInt16 nDiff )
{
    DBG_ASSERT( ((long)nStart - nDiff) >= 0, "EditCharAttrib: MoveBackward?!" );
    DBG_ASSERT( (nStart - nDiff) >= 0, "EditCharAttrib: MoveBackward?!" );
    nStart = nStart - nDiff;
    nEnd = nEnd - nDiff;
}

inline void EditCharAttrib::Expand( sal_uInt16 nDiff )
{
    DBG_ASSERT( ( ((long)nEnd + nDiff) <= (long)0xFFFF ), "EditCharAttrib: Expand?!" );
    DBG_ASSERT( SAL_MAX_INT32 - nDiff > nEnd, "EditCharAttrib: Expand?!" );
    DBG_ASSERT( !bFeature, "Please do not expand any features!" );
    nEnd = nEnd + nDiff;
}

inline void EditCharAttrib::Collaps( sal_uInt16 nDiff )
{
    DBG_ASSERT( (long)nEnd - nDiff >= (long)nStart, "EditCharAttrib: Collaps?!" );
    DBG_ASSERT( nEnd - nDiff >= nStart, "EditCharAttrib: Collaps?!" );
    DBG_ASSERT( !bFeature, "Please do not shrink any Features!" );
    nEnd = nEnd - nDiff;
}
diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx
index ed1ca6e..a857cb8 100644
--- a/editeng/source/editeng/editdbg.cxx
+++ b/editeng/source/editeng/editdbg.cxx
@@ -371,7 +371,7 @@ void EditDbg::ShowEditEngineData( EditEngine* pEE, sal_Bool bInfoBox )
        aPortionStr.append("\nA");
        aPortionStr.append(static_cast<sal_Int32>(nPortion));
        aPortionStr.append(": ");
        sal_uLong n = 0;
        sal_Int32 n = 0;
        for ( z = 0; z < nTextPortions; z++ )
        {
            TextPortion* pPortion = pPPortion->GetTextPortions()[z];
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index a581781..4732c62 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -252,7 +252,7 @@ const sal_uInt16 aV5Map[] = {
    4035, 4036, 4037, 4038
};

EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_uInt16 nS, sal_uInt16 nE )
EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_Int32 nS, sal_Int32 nE )
{
    // Create a new attribute in the pool
    const SfxPoolItem& rNew = rPool.Put( rAttr );
@@ -407,25 +407,25 @@ void TextPortionList::Reset()
    maPortions.clear();
}

void TextPortionList::DeleteFromPortion(size_t nDelFrom)
void TextPortionList::DeleteFromPortion(sal_Int32 nDelFrom)
{
    DBG_ASSERT( ( nDelFrom < maPortions.size() ) || ( (nDelFrom == 0) && maPortions.empty() ), "DeleteFromPortion: Out of range" );
    DBG_ASSERT( ( nDelFrom < (sal_Int32)maPortions.size() ) || ( (nDelFrom == 0) && maPortions.empty() ), "DeleteFromPortion: Out of range" );
    PortionsType::iterator it = maPortions.begin();
    std::advance(it, nDelFrom);
    maPortions.erase(it, maPortions.end());
}

size_t TextPortionList::Count() const
sal_Int32 TextPortionList::Count() const
{
    return maPortions.size();
    return (sal_Int32)maPortions.size();
}

const TextPortion* TextPortionList::operator[](size_t nPos) const
const TextPortion* TextPortionList::operator[](sal_Int32 nPos) const
{
    return &maPortions[nPos];
}

TextPortion* TextPortionList::operator[](size_t nPos)
TextPortion* TextPortionList::operator[](sal_Int32 nPos)
{
    return &maPortions[nPos];
}
@@ -435,12 +435,12 @@ void TextPortionList::Append(TextPortion* p)
    maPortions.push_back(p);
}

void TextPortionList::Insert(size_t nPos, TextPortion* p)
void TextPortionList::Insert(sal_Int32 nPos, TextPortion* p)
{
    maPortions.insert(maPortions.begin()+nPos, p);
}

void TextPortionList::Remove(size_t nPos)
void TextPortionList::Remove(sal_Int32 nPos)
{
    maPortions.erase(maPortions.begin()+nPos);
}
@@ -460,24 +460,24 @@ public:

}

size_t TextPortionList::GetPos(const TextPortion* p) const
sal_Int32 TextPortionList::GetPos(const TextPortion* p) const
{
    PortionsType::const_iterator it =
        std::find_if(maPortions.begin(), maPortions.end(), FindTextPortionByAddress(p));

    if (it == maPortions.end())
        return std::numeric_limits<size_t>::max(); // not found.
        return std::numeric_limits<sal_Int32>::max(); // not found.

    return std::distance(maPortions.begin(), it);
}

size_t TextPortionList::FindPortion(
    sal_uInt16 nCharPos, sal_uInt16& nPortionStart, bool bPreferStartingPortion) const
sal_Int32 TextPortionList::FindPortion(
    sal_Int32 nCharPos, sal_Int32& nPortionStart, bool bPreferStartingPortion) const
{
    // When nCharPos at portion limit, the left portion is found
    sal_uInt16 nTmpPos = 0;
    size_t n = maPortions.size();
    for (size_t i = 0; i < n; ++i)
    sal_Int32 nTmpPos = 0;
    sal_Int32 n = maPortions.size();
    for (sal_Int32 i = 0; i < n; ++i)
    {
        const TextPortion& rPortion = maPortions[i];
        nTmpPos = nTmpPos + rPortion.GetLen();
@@ -495,10 +495,10 @@ size_t TextPortionList::FindPortion(
    return n - 1;
}

sal_uInt16 TextPortionList::GetStartPos(size_t nPortion)
sal_Int32 TextPortionList::GetStartPos(sal_Int32 nPortion)
{
    sal_uInt16 nPos = 0;
    for (size_t i = 0; i < nPortion; ++i)
    sal_Int32 nPos = 0;
    for (sal_Int32 i = 0; i < nPortion; ++i)
    {
        const TextPortion& rPortion = maPortions[i];
        nPos = nPos + rPortion.GetLen();
@@ -524,7 +524,7 @@ ExtraPortionInfo::~ExtraPortionInfo()
    delete[] pOrgDXArray;
}

void ExtraPortionInfo::SaveOrgDXArray( const sal_Int32* pDXArray, sal_uInt16 nLen )
void ExtraPortionInfo::SaveOrgDXArray( const sal_Int32* pDXArray, sal_Int32 nLen )
{
    delete[] pOrgDXArray;
    pOrgDXArray = new sal_Int32[nLen];
@@ -551,7 +551,7 @@ ParaPortion::~ParaPortion()
{
}

void ParaPortion::MarkInvalid( sal_uInt16 nStart, short nDiff )
void ParaPortion::MarkInvalid( sal_Int32 nStart, sal_Int32 nDiff )
{
    if ( bInvalid == sal_False )
    {
@@ -577,7 +577,7 @@ void ParaPortion::MarkInvalid( sal_uInt16 nStart, short nDiff )
        {
//          nInvalidPosEnd = pNode->Len();
            DBG_ASSERT( ( nDiff >= 0 ) || ( (nStart+nDiff) >= 0 ), "MarkInvalid: Diff out of Range" );
            nInvalidPosStart = std::min( nInvalidPosStart, (sal_uInt16) ( nDiff < 0 ? nStart+nDiff : nDiff ) );
            nInvalidPosStart = std::min( nInvalidPosStart, ( nDiff < 0 ? nStart+nDiff : nDiff ) );
            nInvalidDiff = 0;
            bSimple = sal_False;
        }
@@ -587,7 +587,7 @@ void ParaPortion::MarkInvalid( sal_uInt16 nStart, short nDiff )
    aWritingDirectionInfos.clear();
}

void ParaPortion::MarkSelectionInvalid( sal_uInt16 nStart, sal_uInt16 /* nEnd */ )
void ParaPortion::MarkSelectionInvalid( sal_Int32 nStart, sal_Int32 /* nEnd */ )
{
    if ( bInvalid == sal_False )
    {
@@ -606,15 +606,15 @@ void ParaPortion::MarkSelectionInvalid( sal_uInt16 nStart, sal_uInt16 /* nEnd */
    aWritingDirectionInfos.clear();
}

sal_uInt16 ParaPortion::GetLineNumber( sal_uInt16 nIndex ) const
sal_Int32 ParaPortion::GetLineNumber( sal_Int32 nIndex ) const
{
    DBG_ASSERTWARNING( aLineList.Count(), "Empty ParaPortion in GetLine!" );
    DBG_ASSERT( bVisible, "Why GetLine() on an invisible paragraph?" );

    for ( sal_uInt16 nLine = 0; nLine < aLineList.Count(); nLine++ )
    for ( sal_Int32 nLine = 0; nLine < aLineList.Count(); nLine++ )
    {
        if ( aLineList[nLine]->IsIn( nIndex ) )
            return nLine;
            return (sal_Int32)nLine;
    }

    // Then it should be at the end of the last line!
@@ -627,16 +627,16 @@ void ParaPortion::SetVisible( sal_Bool bMakeVisible )
    bVisible = bMakeVisible;
}

void ParaPortion::CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormattedLine )
void ParaPortion::CorrectValuesBehindLastFormattedLine( sal_Int32 nLastFormattedLine )
{
    sal_uInt16 nLines = aLineList.Count();
    sal_Int32 nLines = aLineList.Count();
    DBG_ASSERT( nLines, "CorrectPortionNumbersFromLine: Empty Portion?" );
    if ( nLastFormattedLine < ( nLines - 1 ) )
    {
        const EditLine* pLastFormatted = aLineList[ nLastFormattedLine ];
        const EditLine* pUnformatted = aLineList[ nLastFormattedLine+1 ];
        short nPortionDiff = pUnformatted->GetStartPortion() - pLastFormatted->GetEndPortion();
        short nTextDiff = pUnformatted->GetStart() - pLastFormatted->GetEnd();
        sal_Int32 nPortionDiff = pUnformatted->GetStartPortion() - pLastFormatted->GetEndPortion();
        sal_Int32 nTextDiff = pUnformatted->GetStart() - pLastFormatted->GetEnd();
        nTextDiff++;    // LastFormatted->GetEnd() was included => 1 deducted too much!

        // The first unformatted must begin exactly one Portion behind the last
@@ -647,19 +647,15 @@ void ParaPortion::CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormatte
        int nTDiff = -( nTextDiff-1 );
        if ( nPDiff || nTDiff )
        {
            for ( sal_uInt16 nL = nLastFormattedLine+1; nL < nLines; nL++ )
            for ( sal_Int32 nL = nLastFormattedLine+1; nL < nLines; nL++ )
            {
                EditLine* pLine = aLineList[ nL ];

                pLine->GetStartPortion() = sal::static_int_cast< sal_uInt16 >(
                    pLine->GetStartPortion() + nPDiff);
                pLine->GetEndPortion() = sal::static_int_cast< sal_uInt16 >(
                    pLine->GetEndPortion() + nPDiff);
                pLine->GetStartPortion() = pLine->GetStartPortion() + nPDiff;
                pLine->GetEndPortion() = pLine->GetEndPortion() + nPDiff;

                pLine->GetStart() = sal::static_int_cast< sal_uInt16 >(
                    pLine->GetStart() + nTDiff);
                pLine->GetEnd() = sal::static_int_cast< sal_uInt16 >(
                    pLine->GetEnd() + nTDiff);
                pLine->GetStart() = pLine->GetStart() + nTDiff;
                pLine->GetEnd() = pLine->GetEnd() + nTDiff;

                pLine->SetValid();
            }
@@ -673,22 +669,22 @@ void ParaPortion::CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormatte
namespace {

template<typename _Array, typename _Val>
size_t FastGetPos(const _Array& rArray, const _Val* p, size_t& rLastPos)
sal_Int32 FastGetPos(const _Array& rArray, const _Val* p, sal_Int32& rLastPos)
{
    size_t nArrayLen = rArray.size();
    sal_Int32 nArrayLen = rArray.size();

    // Through certain filter code-paths we do a lot of appends, which in
    // turn call GetPos - creating some N^2 nightmares. If we have a
    // non-trivially large list, do a few checks from the end first.
    if (rLastPos > 16 && nArrayLen > 16)
    {
        size_t nEnd;
        sal_Int32 nEnd;
        if (rLastPos > nArrayLen - 2)
            nEnd = nArrayLen;
        else
            nEnd = rLastPos + 2;

        for (size_t nIdx = rLastPos - 2; nIdx < nEnd; ++nIdx)
        for (sal_Int32 nIdx = rLastPos - 2; nIdx < nEnd; ++nIdx)
        {
            if (&rArray.at(nIdx) == p)
            {
@@ -698,7 +694,7 @@ size_t FastGetPos(const _Array& rArray, const _Val* p, size_t& rLastPos)
        }
    }
    // The world's lamest linear search from svarray ...
    for (size_t nIdx = 0; nIdx < nArrayLen; ++nIdx)
    for (sal_Int32 nIdx = 0; nIdx < nArrayLen; ++nIdx)
        if (&rArray.at(nIdx) == p)
            return rLastPos = nIdx;

@@ -723,17 +719,17 @@ sal_Int32 ParaPortionList::GetPos(const ParaPortion* p) const

ParaPortion* ParaPortionList::operator [](sal_Int32 nPos)
{
    return 0 <= nPos && static_cast<size_t>(nPos) < maPortions.size() ? &maPortions[nPos] : NULL;
    return 0 <= nPos && nPos < (sal_Int32)maPortions.size() ? &maPortions[nPos] : NULL;
}

const ParaPortion* ParaPortionList::operator [](sal_Int32 nPos) const
{
    return 0 <= nPos && static_cast<size_t>(nPos) < maPortions.size() ? &maPortions[nPos] : NULL;
    return 0 <= nPos && nPos < (sal_Int32)maPortions.size() ? &maPortions[nPos] : NULL;
}

ParaPortion* ParaPortionList::Release(sal_Int32 nPos)
{
    if (nPos < 0 || maPortions.size() <= static_cast<size_t>(nPos))
    if (nPos < 0 || (sal_Int32)maPortions.size() <= nPos)
    {
        SAL_WARN( "editeng", "ParaPortionList::Release - out of bounds pos " << nPos);
        return NULL;
@@ -743,7 +739,7 @@ ParaPortion* ParaPortionList::Release(sal_Int32 nPos)

void ParaPortionList::Remove(sal_Int32 nPos)
{
    if (nPos < 0 || maPortions.size() <= static_cast<size_t>(nPos))
    if (nPos < 0 || (sal_Int32)maPortions.size() <= nPos)
    {
        SAL_WARN( "editeng", "ParaPortionList::Remove - out of bounds pos " << nPos);
        return;
@@ -753,7 +749,7 @@ void ParaPortionList::Remove(sal_Int32 nPos)

void ParaPortionList::Insert(sal_Int32 nPos, ParaPortion* p)
{
    if (nPos < 0 || maPortions.size() < static_cast<size_t>(nPos))
    if (nPos < 0 || (sal_Int32)maPortions.size() < nPos)
    {
        SAL_WARN( "editeng", "ParaPortionList::Insert - out of bounds pos " << nPos);
        return;
@@ -768,7 +764,7 @@ void ParaPortionList::Append(ParaPortion* p)

sal_Int32 ParaPortionList::Count() const
{
    size_t nSize = maPortions.size();
    sal_Int32 nSize = maPortions.size();
    if (nSize > SAL_MAX_INT32)
    {
        SAL_WARN( "editeng", "ParaPortionList::Count - overflow " << nSize);
@@ -785,7 +781,7 @@ void ParaPortionList::Reset()
long ParaPortionList::GetYOffset(const ParaPortion* pPPortion) const
{
    long nHeight = 0;
    for (size_t i = 0, n = maPortions.size(); i < n; ++i)
    for (sal_Int32 i = 0, n = maPortions.size(); i < n; ++i)
    {
        const ParaPortion* pTmpPortion = &maPortions[i];
        if ( pTmpPortion == pPPortion )
@@ -799,7 +795,7 @@ long ParaPortionList::GetYOffset(const ParaPortion* pPPortion) const
sal_Int32 ParaPortionList::FindParagraph(long nYOffset) const
{
    long nY = 0;
    for (size_t i = 0, n = maPortions.size(); i < n; ++i)
    for (sal_Int32 i = 0, n = maPortions.size(); i < n; ++i)
    {
        nY += maPortions[i].GetHeight(); // should also be correct even in bVisible!
        if ( nY > nYOffset )
@@ -810,19 +806,19 @@ sal_Int32 ParaPortionList::FindParagraph(long nYOffset) const

const ParaPortion* ParaPortionList::SafeGetObject(sal_Int32 nPos) const
{
    return 0 <= nPos && static_cast<size_t>(nPos) < maPortions.size() ? &maPortions[nPos] : NULL;
    return 0 <= nPos && nPos < (sal_Int32)maPortions.size() ? &maPortions[nPos] : NULL;
}

ParaPortion* ParaPortionList::SafeGetObject(sal_Int32 nPos)
{
    return 0 <= nPos && static_cast<size_t>(nPos) < maPortions.size() ? &maPortions[nPos] : NULL;
    return 0 <= nPos && nPos < (sal_Int32)maPortions.size() ? &maPortions[nPos] : NULL;
}

#if OSL_DEBUG_LEVEL > 2
void ParaPortionList::DbgCheck( EditDoc& rDoc)
{
    DBG_ASSERT( Count() == rDoc.Count(), "ParaPortionList::DbgCheck() - Count() unequal!" );
    for ( sal_uInt16 i = 0; i < Count(); i++ )
    for ( sal_Int32 i = 0; i < Count(); i++ )
    {
        DBG_ASSERT( SafeGetObject(i), "ParaPortionList::DbgCheck() - Null-Pointer in List!" );
        DBG_ASSERT( GetObject(i)->GetNode(), "ParaPortionList::DbgCheck() - Null-Pointer in List(2)!" );
@@ -1064,11 +1060,11 @@ Size EditLine::CalcTextSize( ParaPortion& rParaPortion )
    Size aTmpSz;
    TextPortion* pPortion;

    sal_uInt16 nIndex = GetStart();
    sal_Int32 nIndex = GetStart();

    DBG_ASSERT( rParaPortion.GetTextPortions().Count(), "GetTextSize before CreatePortions !" );

    for ( sal_uInt16 n = nStartPortion; n <= nEndPortion; n++ )
    for ( sal_Int32 n = nStartPortion; n <= nEndPortion; n++ )
    {
        pPortion = rParaPortion.GetTextPortions()[n];
        switch ( pPortion->GetKind() )
@@ -1110,18 +1106,18 @@ void EditLineList::Reset()
    maLines.clear();
}

void EditLineList::DeleteFromLine(size_t nDelFrom)
void EditLineList::DeleteFromLine(sal_Int32 nDelFrom)
{
    DBG_ASSERT( nDelFrom <= (maLines.size() - 1), "DeleteFromLine: Out of range" );
    DBG_ASSERT( nDelFrom <= ((sal_Int32)maLines.size() - 1), "DeleteFromLine: Out of range" );
    LinesType::iterator it = maLines.begin();
    std::advance(it, nDelFrom);
    maLines.erase(it, maLines.end());
}

size_t EditLineList::FindLine(sal_uInt16 nChar, bool bInclEnd)
sal_Int32 EditLineList::FindLine(sal_Int32 nChar, bool bInclEnd)
{
    size_t n = maLines.size();
    for (size_t i = 0; i < n; ++i)
    sal_Int32 n = maLines.size();
    for (sal_Int32 i = 0; i < n; ++i)
    {
        const EditLine& rLine = maLines[i];
        if ( (bInclEnd && (rLine.GetEnd() >= nChar)) ||
@@ -1135,17 +1131,17 @@ size_t EditLineList::FindLine(sal_uInt16 nChar, bool bInclEnd)
    return n - 1;
}

size_t EditLineList::Count() const
sal_Int32 EditLineList::Count() const
{
    return maLines.size();
}

const EditLine* EditLineList::operator[](size_t nPos) const
const EditLine* EditLineList::operator[](sal_Int32 nPos) const
{
    return &maLines[nPos];
}

EditLine* EditLineList::operator[](size_t nPos)
EditLine* EditLineList::operator[](sal_Int32 nPos)
{
    return &maLines[nPos];
}
@@ -1155,7 +1151,7 @@ void EditLineList::Append(EditLine* p)
    maLines.push_back(p);
}

void EditLineList::Insert(size_t nPos, EditLine* p)
void EditLineList::Insert(sal_Int32 nPos, EditLine* p)
{
    maLines.insert(maLines.begin()+nPos, p);
}
@@ -1306,7 +1302,7 @@ ContentNode::~ContentNode()
{
}

void ContentNode::ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNew, SfxItemPool& rItemPool )
void ContentNode::ExpandAttribs( sal_Int32 nIndex, sal_Int32 nNew, SfxItemPool& rItemPool )
{
    if ( !nNew )
        return;
@@ -1320,7 +1316,7 @@ void ContentNode::ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNew, SfxItemPool
    bool bResort = false;
    bool bExpandedEmptyAtIndexNull = false;

    size_t nAttr = 0;
    sal_Int32 nAttr = 0;
    CharAttribList::AttribsType& rAttribs = aCharAttribList.GetAttribs();
    EditCharAttrib* pAttrib = GetAttrib(rAttribs, nAttr);
    while ( pAttrib )
@@ -1442,7 +1438,7 @@ void ContentNode::ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNew, SfxItemPool
#endif
}

void ContentNode::CollapsAttribs( sal_uInt16 nIndex, sal_uInt16 nDeleted, SfxItemPool& rItemPool )
void ContentNode::CollapsAttribs( sal_Int32 nIndex, sal_Int32 nDeleted, SfxItemPool& rItemPool )
{
    if ( !nDeleted )
        return;
@@ -1451,9 +1447,9 @@ void ContentNode::CollapsAttribs( sal_uInt16 nIndex, sal_uInt16 nDeleted, SfxIte
    // can also the order of the start list be change!
    bool bResort = false;
    bool bDelAttr = false;
    sal_uInt16 nEndChanges = nIndex+nDeleted;
    sal_Int32 nEndChanges = nIndex+nDeleted;

    size_t nAttr = 0;
    sal_Int32 nAttr = 0;
    CharAttribList::AttribsType& rAttribs = aCharAttribList.GetAttribs();
    EditCharAttrib* pAttrib = GetAttrib(rAttribs, nAttr);
    while ( pAttrib )
@@ -1534,9 +1530,9 @@ void ContentNode::CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool,
{
    DBG_ASSERT( pPrevNode, "Copy of attributes to a null pointer?" );

    sal_uInt16 nCut = pPrevNode->Len();
    sal_Int32 nCut = pPrevNode->Len();

    size_t nAttr = 0;
    sal_Int32 nAttr = 0;
    CharAttribList::AttribsType& rPrevAttribs = pPrevNode->GetCharAttribs().GetAttribs();
    EditCharAttrib* pAttrib = GetAttrib(rPrevAttribs, nAttr);
    while ( pAttrib )
@@ -1586,13 +1582,13 @@ void ContentNode::AppendAttribs( ContentNode* pNextNode )
{
    DBG_ASSERT( pNextNode, "Copy of attributes to a null pointer?" );

    sal_uInt16 nNewStart = maString.getLength();
    sal_Int32 nNewStart = maString.getLength();

#if OSL_DEBUG_LEVEL > 2
    OSL_ENSURE( aCharAttribList.DbgCheckAttribs(), "Attribute before AppendAttribs broken" );
#endif

    size_t nAttr = 0;
    sal_Int32 nAttr = 0;
    CharAttribList::AttribsType& rNextAttribs = pNextNode->GetCharAttribs().GetAttribs();
    EditCharAttrib* pAttrib = GetAttrib(rNextAttribs, nAttr);
    while ( pAttrib )
@@ -1602,7 +1598,7 @@ void ContentNode::AppendAttribs( ContentNode* pNextNode )
        if ( ( pAttrib->GetStart() == 0 ) && ( !pAttrib->IsFeature() ) )
        {
            // Attributes can possibly be summarized as:
            size_t nTmpAttr = 0;
            sal_Int32 nTmpAttr = 0;
            EditCharAttrib* pTmpAttrib = GetAttrib( aCharAttribList.GetAttribs(), nTmpAttr );
            while ( !bMelted && pTmpAttrib )
            {
@@ -1671,12 +1667,12 @@ void ContentNode::SetStyleSheet( SfxStyleSheet* pS, sal_Bool bRecalcFont )
        CreateDefFont();
}

bool ContentNode::IsFeature( sal_uInt16 nPos ) const
bool ContentNode::IsFeature( sal_Int32 nPos ) const
{
    return maString[nPos] == CH_FEATURE;
}

sal_uInt16 ContentNode::Len() const
sal_Int32 ContentNode::Len() const
{
    return maString.getLength();
}
@@ -1686,12 +1682,12 @@ const OUString& ContentNode::GetString() const
    return maString;
}

void ContentNode::SetChar(sal_uInt16 nPos, sal_Unicode c)
void ContentNode::SetChar(sal_Int32 nPos, sal_Unicode c)
{
    maString = maString.replaceAt(nPos, 1, OUString(c));
}

void ContentNode::Insert(const OUString& rStr, sal_uInt16 nPos)
void ContentNode::Insert(const OUString& rStr, sal_Int32 nPos)
{
    maString = maString.replaceAt(nPos, 0, rStr);
}
@@ -1701,27 +1697,27 @@ void ContentNode::Append(const OUString& rStr)
    maString += rStr;
}

void ContentNode::Erase(sal_uInt16 nPos)
void ContentNode::Erase(sal_Int32 nPos)
{
    maString = maString.copy(0, nPos);
}

void ContentNode::Erase(sal_uInt16 nPos, sal_uInt16 nCount)
void ContentNode::Erase(sal_Int32 nPos, sal_Int32 nCount)
{
    maString = maString.replaceAt(nPos, nCount, "");
}

OUString ContentNode::Copy(sal_uInt16 nPos) const
OUString ContentNode::Copy(sal_Int32 nPos) const
{
    return maString.copy(nPos);
}

OUString ContentNode::Copy(sal_uInt16 nPos, sal_uInt16 nCount) const
OUString ContentNode::Copy(sal_Int32 nPos, sal_Int32 nCount) const
{
    return maString.copy(nPos, nCount);
}

sal_Unicode ContentNode::GetChar(sal_uInt16 nPos) const
sal_Unicode ContentNode::GetChar(sal_Int32 nPos) const
{
    return maString[nPos];
}
@@ -1846,7 +1842,7 @@ const SfxPoolItem* ItemList::First()

const SfxPoolItem* ItemList::Next()
{
    if ( CurrentItem + 1 < aItemPool.size() )
    if ( CurrentItem + 1 < (sal_Int32)aItemPool.size() )
    {
        ++CurrentItem;
        return aItemPool[ CurrentItem ];
@@ -1911,7 +1907,7 @@ void EditDoc::ImplDestroyContents()

void EditDoc::RemoveItemsFromPool(const ContentNode& rNode)
{
    for (size_t nAttr = 0; nAttr < rNode.GetCharAttribs().Count(); ++nAttr)
    for (sal_Int32 nAttr = 0; nAttr < rNode.GetCharAttribs().Count(); ++nAttr)
    {
        const EditCharAttrib& rAttr = rNode.GetCharAttribs().GetAttribs()[nAttr];
        GetItemPool().Remove(*rAttr.GetItem());
@@ -2016,12 +2012,12 @@ sal_Int32 EditDoc::GetPos(const ContentNode* p) const

const ContentNode* EditDoc::GetObject(sal_Int32 nPos) const
{
    return 0 <= nPos && static_cast<size_t>(nPos) < maContents.size() ? &maContents[nPos] : NULL;
    return 0 <= nPos && nPos < (sal_Int32)maContents.size() ? &maContents[nPos] : NULL;
}

ContentNode* EditDoc::GetObject(sal_Int32 nPos)
{
    return 0 <= nPos && static_cast<size_t>(nPos) < maContents.size() ? &maContents[nPos] : NULL;
    return 0 <= nPos && nPos < (sal_Int32)maContents.size() ? &maContents[nPos] : NULL;
}

const ContentNode* EditDoc::operator[](sal_Int32 nPos) const
@@ -2046,7 +2042,7 @@ void EditDoc::Insert(sal_Int32 nPos, ContentNode* p)

void EditDoc::Remove(sal_Int32 nPos)
{
    if (nPos < 0 || static_cast<size_t>(nPos) >= maContents.size())
    if (nPos < 0 || nPos >= (sal_Int32)maContents.size())
    {
        SAL_WARN( "editeng", "EditDoc::Remove - out of bounds pos " << nPos);
        return;
@@ -2056,7 +2052,7 @@ void EditDoc::Remove(sal_Int32 nPos)

void EditDoc::Release(sal_Int32 nPos)
{
    if (nPos < 0 || static_cast<size_t>(nPos) >= maContents.size())
    if (nPos < 0 || nPos >= (sal_Int32)maContents.size())
    {
        SAL_WARN( "editeng", "EditDoc::Release - out of bounds pos " << nPos);
        return;
@@ -2066,13 +2062,13 @@ void EditDoc::Release(sal_Int32 nPos)

sal_Int32 EditDoc::Count() const
{
    size_t nSize = maContents.size();
    sal_Int32 nSize = maContents.size();
    if (nSize > SAL_MAX_INT32)
    {
        SAL_WARN( "editeng", "EditDoc::Count - overflow " << nSize);
        return SAL_MAX_INT32;
    }
    return static_cast<sal_Int32>(nSize);
    return nSize;
}

OUString EditDoc::GetSepStr( LineEnd eEnd )
@@ -2121,19 +2117,19 @@ OUString EditDoc::GetParaAsString( sal_Int32 nNode ) const
}

OUString EditDoc::GetParaAsString(
    const ContentNode* pNode, sal_uInt16 nStartPos, sal_uInt16 nEndPos, bool bResolveFields) const
    const ContentNode* pNode, sal_Int32 nStartPos, sal_Int32 nEndPos, bool bResolveFields) const
{
    if ( nEndPos > pNode->Len() )
    if ( nEndPos < 0 || nEndPos > pNode->Len() )
        nEndPos = pNode->Len();

    DBG_ASSERT( nStartPos <= nEndPos, "Start and End reversed?" );

    sal_uInt16 nIndex = nStartPos;
    sal_Int32 nIndex = nStartPos;
    OUString aStr;
    const EditCharAttrib* pNextFeature = pNode->GetCharAttribs().FindFeature( nIndex );
    while ( nIndex < nEndPos )
    {
        sal_uInt16 nEnd = nEndPos;
        sal_Int32 nEnd = nEndPos;
        if ( pNextFeature && ( pNextFeature->GetStart() < nEnd ) )
            nEnd = pNextFeature->GetStart();
        else
@@ -2186,7 +2182,7 @@ sal_uLong EditDoc::GetTextLen() const
        nLen += pNode->Len();
        // Fields can be longer than the placeholder in the Node
        const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
        for (size_t nAttr = rAttrs.size(); nAttr; )
        for (sal_Int32 nAttr = rAttrs.size(); nAttr; )
        {
            const EditCharAttrib& rAttr = rAttrs[--nAttr];
            if (rAttr.Which() == EE_FEATURE_FIELD)
@@ -2349,7 +2345,7 @@ EditPaM EditDoc::ConnectParagraphs( ContentNode* pLeft, ContentNode* pRight )
    return aPaM;
}

EditPaM EditDoc::RemoveChars( EditPaM aPaM, sal_uInt16 nChars )
EditPaM EditDoc::RemoveChars( EditPaM aPaM, sal_Int32 nChars )
{
    // Maybe remove Features!
    aPaM.GetNode()->Erase( aPaM.GetIndex(), nChars );
@@ -2360,7 +2356,7 @@ EditPaM EditDoc::RemoveChars( EditPaM aPaM, sal_uInt16 nChars )
    return aPaM;
}

void EditDoc::InsertAttribInSelection( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, const SfxPoolItem& rPoolItem )
void EditDoc::InsertAttribInSelection( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, const SfxPoolItem& rPoolItem )
{
    DBG_ASSERT( pNode, "What to do with the attribute?" );
    DBG_ASSERT( nEnd <= pNode->Len(), "InsertAttrib: Attribute to large!" );
@@ -2397,14 +2393,14 @@ void EditDoc::InsertAttribInSelection( ContentNode* pNode, sal_uInt16 nStart, sa
    SetModified(true);
}

sal_Bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, sal_uInt16 nWhich )
sal_Bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, sal_uInt16 nWhich )
{
    EditCharAttrib* pStarting;
    EditCharAttrib* pEnding;
    return RemoveAttribs( pNode, nStart, nEnd, pStarting, pEnding, nWhich );
}

sal_Bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, EditCharAttrib*& rpStarting, EditCharAttrib*& rpEnding, sal_uInt16 nWhich )
sal_Bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, EditCharAttrib*& rpStarting, EditCharAttrib*& rpEnding, sal_uInt16 nWhich )
{

    DBG_ASSERT( pNode, "What to do with the attribute?" );
@@ -2420,7 +2416,7 @@ sal_Bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt
    DBG_ASSERT( nStart <= nEnd, "Small miscalculations in InsertAttribInSelection" );

    // iterate over the attributes ...
    size_t nAttr = 0;
    sal_Int32 nAttr = 0;
    CharAttribList::AttribsType& rAttribs = pNode->GetCharAttribs().GetAttribs();
    EditCharAttrib* pAttr = GetAttrib(rAttribs, nAttr);
    while ( pAttr )
@@ -2482,7 +2478,7 @@ sal_Bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt
                }
                else // Attribute must be split ...
                {
                    sal_uInt16 nOldEnd = pAttr->GetEnd();
                    sal_Int32 nOldEnd = pAttr->GetEnd();
                    pAttr->GetEnd() = nStart;
                    rpEnding = pAttr;
                    InsertAttrib( *pAttr->GetItem(), pNode, nEnd, nOldEnd );
@@ -2513,7 +2509,7 @@ sal_Bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt
    return bChanged;
}

void EditDoc::InsertAttrib( const SfxPoolItem& rPoolItem, ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd )
void EditDoc::InsertAttrib( const SfxPoolItem& rPoolItem, ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd )
{
    // This method no longer checks whether a corresponding attribute already
    // exists at this place!
@@ -2524,7 +2520,7 @@ void EditDoc::InsertAttrib( const SfxPoolItem& rPoolItem, ContentNode* pNode, sa
    SetModified( true );
}

void EditDoc::InsertAttrib( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, const SfxPoolItem& rPoolItem )
void EditDoc::InsertAttrib( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, const SfxPoolItem& rPoolItem )
{
    if ( nStart != nEnd )
    {
@@ -2548,7 +2544,7 @@ void EditDoc::InsertAttrib( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nE
            if ( pAttr->IsInside( nStart ) )    // split
            {
                // check again if really splitting, or return !
                sal_uInt16 nOldEnd = pAttr->GetEnd();
                sal_Int32 nOldEnd = pAttr->GetEnd();
                pAttr->GetEnd() = nStart;
                EditCharAttrib* pNew = MakeCharAttrib( GetItemPool(), *(pAttr->GetItem()), nStart, nOldEnd );
                rAttrList.InsertAttrib(pNew);
@@ -2567,7 +2563,7 @@ void EditDoc::InsertAttrib( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nE
    SetModified( true );
}

void EditDoc::FindAttribs( ContentNode* pNode, sal_uInt16 nStartPos, sal_uInt16 nEndPos, SfxItemSet& rCurSet )
void EditDoc::FindAttribs( ContentNode* pNode, sal_Int32 nStartPos, sal_Int32 nEndPos, SfxItemSet& rCurSet )
{
    DBG_ASSERT( pNode, "Where to search?" );
    DBG_ASSERT( nStartPos <= nEndPos, "Invalid region!" );
@@ -2707,12 +2703,12 @@ void CharAttribList::InsertAttrib( EditCharAttrib* pAttrib )
    // (InsertBinTextObject!) binary search would not be optimal here.
    // => Would bring something!

    const sal_uInt16 nStart = pAttrib->GetStart(); // may be better for Comp.Opt.
    const sal_Int32 nStart = pAttrib->GetStart(); // may be better for Comp.Opt.

    if ( pAttrib->IsEmpty() )
        bHasEmptyAttribs = true;

    for (size_t i = 0, n = aAttribs.size(); i < n; ++i)
    for (sal_Int32 i = 0, n = aAttribs.size(); i < n; ++i)
    {
        const EditCharAttrib& rCurAttrib = aAttribs[i];
        if (rCurAttrib.GetStart() > nStart)
@@ -2732,10 +2728,10 @@ void CharAttribList::ResortAttribs()

void CharAttribList::OptimizeRanges( SfxItemPool& rItemPool )
{
    for (size_t i = 0; i < aAttribs.size(); ++i)
    for (sal_Int32 i = 0; i < (sal_Int32)aAttribs.size(); ++i)
    {
        EditCharAttrib& rAttr = aAttribs[i];
        for (size_t nNext = i+1; nNext < aAttribs.size(); ++nNext)
        for (sal_Int32 nNext = i+1; nNext < (sal_Int32)aAttribs.size(); ++nNext)
        {
            EditCharAttrib& rNext = aAttribs[nNext];
            if (!rAttr.IsFeature() && rNext.GetStart() == rAttr.GetEnd() && rNext.Which() == rAttr.Which())
@@ -2756,12 +2752,12 @@ void CharAttribList::OptimizeRanges( SfxItemPool& rItemPool )
    }
}

size_t CharAttribList::Count() const
sal_Int32 CharAttribList::Count() const
{
    return aAttribs.size();
}

const EditCharAttrib* CharAttribList::FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos ) const
const EditCharAttrib* CharAttribList::FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos ) const
{
    // Backwards, if one ends where the next starts.
    // => The starting one is the valid one ...
@@ -2775,7 +2771,7 @@ const EditCharAttrib* CharAttribList::FindAttrib( sal_uInt16 nWhich, sal_uInt16 
    return NULL;
}

EditCharAttrib* CharAttribList::FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos )
EditCharAttrib* CharAttribList::FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos )
{
    // Backwards, if one ends where the next starts.
    // => The starting one is the valid one ...
@@ -2789,7 +2785,7 @@ EditCharAttrib* CharAttribList::FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos )
    return NULL;
}

const EditCharAttrib* CharAttribList::FindNextAttrib( sal_uInt16 nWhich, sal_uInt16 nFromPos ) const
const EditCharAttrib* CharAttribList::FindNextAttrib( sal_uInt16 nWhich, sal_Int32 nFromPos ) const
{
    DBG_ASSERT( nWhich, "FindNextAttrib: Which?" );
    AttribsType::const_iterator it = aAttribs.begin(), itEnd = aAttribs.end();
@@ -2802,7 +2798,7 @@ const EditCharAttrib* CharAttribList::FindNextAttrib( sal_uInt16 nWhich, sal_uIn
    return NULL;
}

bool CharAttribList::HasAttrib( sal_uInt16 nStartPos, sal_uInt16 nEndPos ) const
bool CharAttribList::HasAttrib( sal_Int32 nStartPos, sal_Int32 nEndPos ) const
{
    AttribsType::const_reverse_iterator it = aAttribs.rbegin(), itEnd = aAttribs.rend();
    for (; it != itEnd; ++it)
@@ -2846,9 +2842,9 @@ void CharAttribList::Remove(const EditCharAttrib* p)
        aAttribs.erase(it);
}

void CharAttribList::Remove(size_t nPos)
void CharAttribList::Remove(sal_Int32 nPos)
{
    if (nPos >= aAttribs.size())
    if (nPos >= (sal_Int32)aAttribs.size())
        return;

    aAttribs.erase(aAttribs.begin()+nPos);
@@ -2866,7 +2862,7 @@ void CharAttribList::SetHasEmptyAttribs(bool b)
    bHasEmptyAttribs = b;
}

bool CharAttribList::HasBoundingAttrib( sal_uInt16 nBound ) const
bool CharAttribList::HasBoundingAttrib( sal_Int32 nBound ) const
{
    // Backwards, if one ends where the next starts.
    // => The starting one is the valid one ...
@@ -2883,7 +2879,7 @@ bool CharAttribList::HasBoundingAttrib( sal_uInt16 nBound ) const
    return false;
}

const EditCharAttrib* CharAttribList::FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos ) const
const EditCharAttrib* CharAttribList::FindEmptyAttrib( sal_uInt16 nWhich, sal_Int32 nPos ) const
{
    if ( !bHasEmptyAttribs )
        return NULL;
@@ -2898,7 +2894,7 @@ const EditCharAttrib* CharAttribList::FindEmptyAttrib( sal_uInt16 nWhich, sal_uI
    return NULL;
}

EditCharAttrib* CharAttribList::FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos )
EditCharAttrib* CharAttribList::FindEmptyAttrib( sal_uInt16 nWhich, sal_Int32 nPos )
{
    if ( !bHasEmptyAttribs )
        return NULL;
@@ -2917,9 +2913,9 @@ namespace {

class FindByStartPos : std::unary_function<EditCharAttrib, bool>
{
    sal_uInt16 mnPos;
    sal_Int32 mnPos;
public:
    FindByStartPos(sal_uInt16 nPos) : mnPos(nPos) {}
    FindByStartPos(sal_Int32 nPos) : mnPos(nPos) {}
    bool operator() (const EditCharAttrib& r) const
    {
        return r.GetStart() >= mnPos;
@@ -2928,7 +2924,7 @@ public:

}

const EditCharAttrib* CharAttribList::FindFeature( sal_uInt16 nPos ) const
const EditCharAttrib* CharAttribList::FindFeature( sal_Int32 nPos ) const
{
    // First, find the first attribute that starts at or after specified position.
    AttribsType::const_iterator it =
@@ -2996,23 +2992,23 @@ SvxColorList::SvxColorList()

SvxColorList::~SvxColorList()
{
    for ( size_t i = 0, n = aColorList.size(); i < n; ++i )
    for ( sal_Int32 i = 0, n = aColorList.size(); i < n; ++i )
        delete aColorList[ i ];
    aColorList.clear();
}

size_t SvxColorList::GetId( const SvxColorItem& rColorItem )
sal_Int32 SvxColorList::GetId( const SvxColorItem& rColorItem )
{
    for ( size_t i = 0, n = aColorList.size(); i < n; ++i )
    for ( sal_Int32 i = 0, n = aColorList.size(); i < n; ++i )
        if ( *aColorList[ i ] == rColorItem )
            return i;
    DBG_WARNING( "Color not found: GetId()" );
    return 0;
}

void SvxColorList::Insert( SvxColorItem* pItem, size_t nIndex )
void SvxColorList::Insert( SvxColorItem* pItem, sal_Int32 nIndex )
{
    if ( nIndex >= aColorList.size() )
    if ( nIndex >= (sal_Int32)aColorList.size() )
    {
        aColorList.push_back( pItem );
    }
@@ -3024,9 +3020,9 @@ void SvxColorList::Insert( SvxColorItem* pItem, size_t nIndex )
    }
}

SvxColorItem* SvxColorList::GetObject( size_t nIndex )
SvxColorItem* SvxColorList::GetObject( sal_Int32 nIndex )
{
    return ( nIndex >= aColorList.size() ) ? NULL : aColorList[ nIndex ];
    return ( nIndex >= (sal_Int32)aColorList.size() ) ? NULL : aColorList[ nIndex ];
}

EditEngineItemPool::EditEngineItemPool( sal_Bool bPersistenRefCounts )
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 1c8bdf2..aa317f5 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -48,7 +48,7 @@ void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent = 
sal_uInt16 GetScriptItemId( sal_uInt16 nItemId, short nScriptType );
sal_Bool IsScriptItemValid( sal_uInt16 nItemId, short nScriptType );

EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_uInt16 nS, sal_uInt16 nE );
EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_Int32 nS, sal_Int32 nE );

class ContentNode;
class EditDoc;
@@ -80,10 +80,10 @@ inline sal_Bool EPaM::operator == ( const EPaM& r ) const
struct ScriptTypePosInfo
{
    short   nScriptType;
    sal_uInt16  nStartPos;
    sal_uInt16  nEndPos;
    sal_Int32  nStartPos;
    sal_Int32  nEndPos;

    ScriptTypePosInfo( short _Type, sal_uInt16 _Start, sal_uInt16 _End )
    ScriptTypePosInfo( short _Type, sal_Int32 _Start, sal_Int32 _End )
    : nScriptType(_Type)
    , nStartPos(_Start)
    , nEndPos(_End)
@@ -96,10 +96,10 @@ typedef std::deque< ScriptTypePosInfo > ScriptTypePosInfos;
struct WritingDirectionInfo
{
    sal_uInt8   nType;
    sal_uInt16  nStartPos;
    sal_uInt16  nEndPos;
    sal_Int32  nStartPos;
    sal_Int32  nEndPos;

    WritingDirectionInfo( sal_uInt8 _Type, sal_uInt16 _Start, sal_uInt16 _End )
    WritingDirectionInfo( sal_uInt8 _Type, sal_Int32 _Start, sal_Int32 _End )
    : nType(_Type)
    , nStartPos(_Start)
    , nEndPos(_End)
@@ -142,10 +142,10 @@ public:
            SvxColorList();
            ~SvxColorList();

    size_t  GetId( const SvxColorItem& rColor );
    size_t  Count() { return aColorList.size(); };
    void    Insert( SvxColorItem* pItem, size_t nIndex );
    SvxColorItem* GetObject( size_t nIndex );
    sal_Int32  GetId( const SvxColorItem& rColor );
    sal_Int32  Count() { return aColorList.size(); };
    void    Insert( SvxColorItem* pItem, sal_Int32 nIndex );
    SvxColorItem* GetObject( sal_Int32 nIndex );
};

//  ----------------------------------------------------------------------
@@ -157,13 +157,13 @@ class ItemList
private:
    typedef std::vector<const SfxPoolItem*> DummyItemList;
    DummyItemList aItemPool;
    size_t  CurrentItem;
    sal_Int32  CurrentItem;

public:
    ItemList();
    const SfxPoolItem*  First();
    const SfxPoolItem*  Next();
    size_t              Count() { return aItemPool.size(); };
    sal_Int32              Count() { return aItemPool.size(); };
    void                Insert( const SfxPoolItem* pItem );
    void                Clear() { aItemPool.clear(); };
};
@@ -215,18 +215,18 @@ public:
    void            DeleteEmptyAttribs(  SfxItemPool& rItemPool );
    void            RemoveItemsFromPool( SfxItemPool* pItemPool );

    const EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos ) const;
    EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
    const EditCharAttrib* FindNextAttrib( sal_uInt16 nWhich, sal_uInt16 nFromPos ) const;
    const EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos ) const;
    EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_uInt16 nPos );
    const EditCharAttrib* FindFeature( sal_uInt16 nPos ) const;
    const EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos ) const;
    EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos );
    const EditCharAttrib* FindNextAttrib( sal_uInt16 nWhich, sal_Int32 nFromPos ) const;
    const EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_Int32 nPos ) const;
    EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_Int32 nPos );
    const EditCharAttrib* FindFeature( sal_Int32 nPos ) const;


    void            ResortAttribs();
    void            OptimizeRanges( SfxItemPool& rItemPool );

    size_t Count() const;
    sal_Int32 Count() const;

    void            InsertAttrib( EditCharAttrib* pAttrib );

@@ -234,14 +234,14 @@ public:

    bool            HasEmptyAttribs() const { return bHasEmptyAttribs; }
    void SetHasEmptyAttribs(bool b);
    bool HasBoundingAttrib( sal_uInt16 nBound ) const;
    bool HasAttrib( sal_uInt16 nStartPos, sal_uInt16 nEndPos ) const;
    bool HasBoundingAttrib( sal_Int32 nBound ) const;
    bool HasAttrib( sal_Int32 nStartPos, sal_Int32 nEndPos ) const;

    AttribsType& GetAttribs();
    const AttribsType& GetAttribs() const;

    void Remove(const EditCharAttrib* p);
    void Remove(size_t nPos);
    void Remove(sal_Int32 nPos);
    void Release(const EditCharAttrib* p);

#if OSL_DEBUG_LEVEL > 2
@@ -271,8 +271,8 @@ public:
    CharAttribList& GetCharAttribs()        { return aCharAttribList; }
    const CharAttribList& GetCharAttribs() const { return aCharAttribList; }

    void            ExpandAttribs( sal_uInt16 nIndex, sal_uInt16 nNewChars, SfxItemPool& rItemPool );
    void            CollapsAttribs( sal_uInt16 nIndex, sal_uInt16 nDelChars, SfxItemPool& rItemPool );
    void            ExpandAttribs( sal_Int32 nIndex, sal_Int32 nNewChars, SfxItemPool& rItemPool );
    void            CollapsAttribs( sal_Int32 nIndex, sal_Int32 nDelChars, SfxItemPool& rItemPool );
    void            AppendAttribs( ContentNode* pNextNode );
    void            CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool, sal_Bool bKeepEndingAttribs );

@@ -291,19 +291,19 @@ public:
    void            CreateWrongList();
    void            DestroyWrongList();

    bool IsFeature( sal_uInt16 nPos ) const;
    bool IsFeature( sal_Int32 nPos ) const;

    sal_uInt16 Len() const;
    sal_Int32 Len() const;
    const OUString& GetString() const;

    void SetChar(sal_uInt16 nPos, sal_Unicode c);
    void Insert(const OUString& rStr, sal_uInt16 nPos);
    void SetChar(sal_Int32 nPos, sal_Unicode c);
    void Insert(const OUString& rStr, sal_Int32 nPos);
    void Append(const OUString& rStr);
    void Erase(sal_uInt16 nPos);
    void Erase(sal_uInt16 nPos, sal_uInt16 nCount);
    OUString Copy(sal_uInt16 nPos) const;
    OUString Copy(sal_uInt16 nPos, sal_uInt16 nCount) const;
    sal_Unicode GetChar(sal_uInt16 nPos) const;
    void Erase(sal_Int32 nPos);
    void Erase(sal_Int32 nPos, sal_Int32 nCount);
    OUString Copy(sal_Int32 nPos) const;
    OUString Copy(sal_Int32 nPos, sal_Int32 nCount) const;
    sal_Unicode GetChar(sal_Int32 nPos) const;
};

// -------------------------------------------------------------------------
@@ -372,7 +372,7 @@ struct ExtraPortionInfo
            ExtraPortionInfo();
            ~ExtraPortionInfo();

    void    SaveOrgDXArray( const sal_Int32* pDXArray, sal_uInt16 nLen );
    void    SaveOrgDXArray( const sal_Int32* pDXArray, sal_Int32 nLen );
};


@@ -383,7 +383,7 @@ class TextPortion
{
private:
    ExtraPortionInfo*   pExtraInfos;
    sal_uInt16              nLen;
    sal_Int32              nLen;
    Size                aOutSz;
    sal_uInt8               nKind;
    sal_uInt8                nRightToLeft;
@@ -401,7 +401,7 @@ private:
                }

public:
                TextPortion( sal_uInt16 nL )
                TextPortion( sal_Int32 nL )
                : pExtraInfos( NULL )
                , nLen( nL )
                , aOutSz( -1, -1 )
@@ -422,8 +422,8 @@ public:
                }


    sal_uInt16      GetLen() const              { return nLen; }
    void        SetLen( sal_uInt16 nL )         { nLen = nL; }
    sal_Int32      GetLen() const              { return nLen; }
    void        SetLen( sal_Int32 nL )         { nLen = nL; }

    Size&       GetSize()                   { return aOutSz; }
    const Size& GetSize() const             { return aOutSz; }
@@ -457,18 +457,18 @@ public:
            ~TextPortionList();

    void    Reset();
    size_t FindPortion(
        sal_uInt16 nCharPos, sal_uInt16& rPortionStart, bool bPreferStartingPortion = false) const;
    sal_uInt16 GetStartPos(size_t nPortion);
    void DeleteFromPortion(size_t nDelFrom);
    size_t Count() const;
    const TextPortion* operator[](size_t nPos) const;
    TextPortion* operator[](size_t nPos);
    sal_Int32 FindPortion(
        sal_Int32 nCharPos, sal_Int32& rPortionStart, bool bPreferStartingPortion = false) const;
    sal_Int32 GetStartPos(sal_Int32 nPortion);
    void DeleteFromPortion(sal_Int32 nDelFrom);
    sal_Int32 Count() const;
    const TextPortion* operator[](sal_Int32 nPos) const;
    TextPortion* operator[](sal_Int32 nPos);

    void Append(TextPortion* p);
    void Insert(size_t nPos, TextPortion* p);
    void Remove(size_t nPos);
    size_t GetPos(const TextPortion* p) const;
    void Insert(sal_Int32 nPos, TextPortion* p);
    void Remove(sal_Int32 nPos);
    sal_Int32 GetPos(const TextPortion* p) const;
};

class ParaPortion;
@@ -485,10 +485,10 @@ private:
    CharPosArrayType aPositions;
    long            nTxtWidth;
    sal_uInt16          nStartPosX;
    sal_uInt16          nStart;     // could be replaced by nStartPortion
    sal_uInt16          nEnd;       // could be replaced by nEndPortion
    sal_uInt16          nStartPortion;
    sal_uInt16          nEndPortion;
    sal_Int32          nStart;     // could be replaced by nStartPortion
    sal_Int32          nEnd;       // could be replaced by nEndPortion
    sal_Int32          nStartPortion;
    sal_Int32          nEndPortion;
    sal_uInt16          nHeight;    //  Total height of the line
    sal_uInt16          nTxtHeight; // Pure Text height
    sal_uInt16          nCrsrHeight;    // For contour flow high lines => cursor is large.
@@ -501,27 +501,27 @@ public:
                    EditLine( const EditLine& );
                    ~EditLine();

    sal_Bool            IsIn( sal_uInt16 nIndex ) const
    sal_Bool            IsIn( sal_Int32 nIndex ) const
                        { return ( (nIndex >= nStart ) && ( nIndex < nEnd ) ); }

    sal_Bool            IsIn( sal_uInt16 nIndex, sal_Bool bInclEnd ) const
    sal_Bool            IsIn( sal_Int32 nIndex, sal_Bool bInclEnd ) const
                        { return ( ( nIndex >= nStart ) && ( bInclEnd ? ( nIndex <= nEnd ) : ( nIndex < nEnd ) ) ); }

    void            SetStart( sal_uInt16 n )            { nStart = n; }
    sal_uInt16          GetStart() const                { return nStart; }
    sal_uInt16&         GetStart()                      { return nStart; }
    void            SetStart( sal_Int32 n )            { nStart = n; }
    sal_Int32          GetStart() const                { return nStart; }
    sal_Int32&         GetStart()                      { return nStart; }

    void            SetEnd( sal_uInt16 n )              { nEnd = n; }
    sal_uInt16          GetEnd() const                  { return nEnd; }
    sal_uInt16&         GetEnd()                        { return nEnd; }
    void            SetEnd( sal_Int32 n )              { nEnd = n; }
    sal_Int32          GetEnd() const                  { return nEnd; }
    sal_Int32&         GetEnd()                        { return nEnd; }

    void            SetStartPortion( sal_uInt16 n )     { nStartPortion = n; }
    sal_uInt16          GetStartPortion() const         { return nStartPortion; }
    sal_uInt16&         GetStartPortion()               { return nStartPortion; }
    void            SetStartPortion( sal_Int32 n )     { nStartPortion = n; }
    sal_Int32          GetStartPortion() const         { return nStartPortion; }
    sal_Int32&         GetStartPortion()               { return nStartPortion; }

    void            SetEndPortion( sal_uInt16 n )       { nEndPortion = n; }
    sal_uInt16          GetEndPortion() const           { return nEndPortion; }
    sal_uInt16&         GetEndPortion()                 { return nEndPortion; }
    void            SetEndPortion( sal_Int32 n )       { nEndPortion = n; }
    sal_Int32          GetEndPortion() const           { return nEndPortion; }
    sal_Int32&         GetEndPortion()                 { return nEndPortion; }

    void            SetHeight( sal_uInt16 nH, sal_uInt16 nTxtH = 0, sal_uInt16 nCrsrH = 0 );
    sal_uInt16          GetHeight() const               { return nHeight; }
@@ -537,7 +537,7 @@ public:
    void            SetHangingPunctuation( bool b )     { bHangingPunctuation = b; }
    bool            IsHangingPunctuation() const        { return bHangingPunctuation; }

    sal_uInt16          GetLen() const                  { return nEnd - nStart; }
    sal_Int32          GetLen() const                  { return nEnd - nStart; }

    sal_uInt16          GetStartPosX() const            { return nStartPosX; }
    void            SetStartPosX( long start );
@@ -574,14 +574,14 @@ public:
            ~EditLineList();

    void Reset();
    void DeleteFromLine(size_t nDelFrom);
    size_t FindLine(sal_uInt16 nChar, bool bInclEnd);
    size_t Count() const;
    const EditLine* operator[](size_t nPos) const;
    EditLine* operator[](size_t nPos);
    void DeleteFromLine(sal_Int32 nDelFrom);
    sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd);
    sal_Int32 Count() const;
    const EditLine* operator[](sal_Int32 nPos) const;
    EditLine* operator[](sal_Int32 nPos);

    void Append(EditLine* p);
    void Insert(size_t nPos, EditLine* p);
    void Insert(sal_Int32 nPos, EditLine* p);
};

// -------------------------------------------------------------------------
@@ -599,10 +599,10 @@ private:
    ScriptTypePosInfos      aScriptInfos;
    WritingDirectionInfos   aWritingDirectionInfos;

    sal_uInt16              nInvalidPosStart;
    sal_uInt16              nFirstLineOffset;   // For Writer-LineSpacing-Interpretation
    sal_uInt16              nBulletX;
    short                   nInvalidDiff;
    sal_Int32              nInvalidPosStart;
    sal_Int32              nFirstLineOffset;   // For Writer-LineSpacing-Interpretation
    sal_uInt16             nBulletX;
    sal_Int32              nInvalidDiff;

    sal_Bool                bInvalid            : 1;
    sal_Bool                bSimple             : 1;    // only linear Tap
@@ -615,7 +615,7 @@ public:
                        ParaPortion( ContentNode* pNode );
                        ~ParaPortion();

    sal_uInt16 GetLineNumber( sal_uInt16 nIndex ) const;
    sal_Int32 GetLineNumber( sal_Int32 nIndex ) const;

    EditLineList&       GetLines()                  { return aLineList; }
    const EditLineList& GetLines() const { return aLineList; }
@@ -630,8 +630,8 @@ public:
    sal_uInt16              GetBulletX() const          { return nBulletX; }
    void                SetBulletX( sal_uInt16 n )      { nBulletX = n; }

    void                MarkInvalid( sal_uInt16 nStart, short nDiff);
    void                MarkSelectionInvalid( sal_uInt16 nStart, sal_uInt16 nEnd );
    void                MarkInvalid( sal_Int32 nStart, sal_Int32 nDiff);
    void                MarkSelectionInvalid( sal_Int32 nStart, sal_Int32 nEnd );

    void                SetVisible( sal_Bool bVisible );
    bool                IsVisible() const { return bVisible; }
@@ -639,17 +639,17 @@ public:
    sal_Bool            IsEmpty() { return GetTextPortions().Count() == 1 && GetTextPortions()[0]->GetLen() == 0; }

    long                GetHeight() const           { return ( bVisible ? nHeight : 0 ); }
    sal_uInt16              GetFirstLineOffset() const  { return ( bVisible ? nFirstLineOffset : 0 ); }
    sal_Int32           GetFirstLineOffset() const  { return ( bVisible ? nFirstLineOffset : 0 ); }
    void                ResetHeight()   { nHeight = 0; nFirstLineOffset = 0; }

    ContentNode*        GetNode() const             { return pNode; }
    TextPortionList&    GetTextPortions()           { return aTextPortionList; }
    const TextPortionList& GetTextPortions() const { return aTextPortionList; }

    sal_uInt16              GetInvalidPosStart() const  { return nInvalidPosStart; }
    sal_Int32           GetInvalidPosStart() const  { return nInvalidPosStart; }
    short               GetInvalidDiff() const      { return nInvalidDiff; }

    void                CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormattedLine );
    void                CorrectValuesBehindLastFormattedLine( sal_Int32 nLastFormattedLine );
#if OSL_DEBUG_LEVEL > 2
    sal_Bool                DbgCheckTextPortions();
#endif
@@ -660,7 +660,7 @@ public:
// -------------------------------------------------------------------------
class ParaPortionList
{
    mutable size_t nLastCache;
    mutable sal_Int32 nLastCache;
    boost::ptr_vector<ParaPortion> maPortions;
public:
                    ParaPortionList();
@@ -749,7 +749,7 @@ public:
class EditDoc
{
private:
    mutable size_t nLastCache;
    mutable sal_Int32 nLastCache;
    boost::ptr_vector<ContentNode> maContents;

    SfxItemPool*    pItemPool;
@@ -792,7 +792,7 @@ public:

    EditPaM         Clear();
    EditPaM         RemoveText();
    EditPaM         RemoveChars( EditPaM aPaM, sal_uInt16 nChars );
    EditPaM         RemoveChars( EditPaM aPaM, sal_Int32 nChars );
    EditPaM         InsertText( EditPaM aPaM, const OUString& rStr );
    EditPaM         InsertParaBreak( EditPaM aPaM, sal_Bool bKeepEndingAttribs );
    EditPaM         InsertFeature( EditPaM aPaM, const SfxPoolItem& rItem );
@@ -802,7 +802,7 @@ public:
    sal_uLong       GetTextLen() const;

    OUString       GetParaAsString( sal_Int32 nNode ) const;
    OUString       GetParaAsString(const ContentNode* pNode, sal_uInt16 nStartPos = 0, sal_uInt16 nEndPos = 0xFFFF, bool bResolveFields = true) const;
    OUString       GetParaAsString(const ContentNode* pNode, sal_Int32 nStartPos = 0, sal_Int32 nEndPos = -1, bool bResolveFields = true) const;

    EditPaM GetStartPaM() const;
    EditPaM GetEndPaM() const;
@@ -812,12 +812,12 @@ public:

    void RemoveItemsFromPool(const ContentNode& rNode);

    void            InsertAttrib( const SfxPoolItem& rItem, ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd );
    void            InsertAttrib( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, const SfxPoolItem& rPoolItem );
    void            InsertAttribInSelection( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, const SfxPoolItem& rPoolItem );
    sal_Bool            RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, sal_uInt16 nWhich = 0 );
    sal_Bool            RemoveAttribs( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, EditCharAttrib*& rpStarting, EditCharAttrib*& rpEnding, sal_uInt16 nWhich = 0 );
    void            FindAttribs( ContentNode* pNode, sal_uInt16 nStartPos, sal_uInt16 nEndPos, SfxItemSet& rCurSet );
    void            InsertAttrib( const SfxPoolItem& rItem, ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd );
    void            InsertAttrib( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, const SfxPoolItem& rPoolItem );
    void            InsertAttribInSelection( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, const SfxPoolItem& rPoolItem );
    sal_Bool            RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, sal_uInt16 nWhich = 0 );
    sal_Bool            RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, EditCharAttrib*& rpStarting, EditCharAttrib*& rpEnding, sal_uInt16 nWhich = 0 );
    void            FindAttribs( ContentNode* pNode, sal_Int32 nStartPos, sal_Int32 nEndPos, SfxItemSet& rCurSet );

    sal_Int32 GetPos(const ContentNode* pNode) const;
    const ContentNode* GetObject(sal_Int32 nPos) const;
@@ -834,9 +834,9 @@ public:
    static OUString GetSepStr( LineEnd eEnd );
};

inline EditCharAttrib* GetAttrib(CharAttribList::AttribsType& rAttribs, size_t nAttr)
inline EditCharAttrib* GetAttrib(CharAttribList::AttribsType& rAttribs, sal_Int32 nAttr)
{
    return (nAttr < rAttribs.size()) ? &rAttribs[nAttr] : NULL;
    return (nAttr < (sal_Int32)rAttribs.size()) ? &rAttribs[nAttr] : NULL;
}

bool CheckOrderedList(const CharAttribList::AttribsType& rAttribs, bool bStart);
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index 1ba3329..9e6807f 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -477,7 +477,7 @@ LanguageType EditEngine::GetLanguage(const EditPaM& rPaM) const
    return pImpEditEngine->GetLanguage(rPaM);
}

LanguageType EditEngine::GetLanguage( sal_Int32 nPara, sal_uInt16 nPos ) const
LanguageType EditEngine::GetLanguage( sal_Int32 nPara, sal_Int32 nPos ) const
{
    ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
    DBG_ASSERT( pNode, "GetLanguage - nPara is invalid!" );
@@ -579,35 +579,35 @@ sal_Int32 EditEngine::GetParagraphCount() const
    return pImpEditEngine->aEditDoc.Count();
}

sal_uInt16 EditEngine::GetLineCount( sal_Int32 nParagraph ) const
sal_Int32 EditEngine::GetLineCount( sal_Int32 nParagraph ) const
{
    if ( !pImpEditEngine->IsFormatted() )
        pImpEditEngine->FormatDoc();
    return pImpEditEngine->GetLineCount( nParagraph );
}

sal_uInt16 EditEngine::GetLineLen( sal_Int32 nParagraph, sal_uInt16 nLine ) const
sal_Int32 EditEngine::GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const
{
    if ( !pImpEditEngine->IsFormatted() )
        pImpEditEngine->FormatDoc();
    return pImpEditEngine->GetLineLen( nParagraph, nLine );
}

void EditEngine::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nParagraph, sal_uInt16 nLine ) const
void EditEngine::GetLineBoundaries( /*out*/sal_Int32& rStart, /*out*/sal_Int32& rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const
{
    if ( !pImpEditEngine->IsFormatted() )
        pImpEditEngine->FormatDoc();
    return pImpEditEngine->GetLineBoundaries( rStart, rEnd, nParagraph, nLine );
}

sal_uInt16 EditEngine::GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nIndex ) const
sal_Int32 EditEngine::GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const
{
    if ( !pImpEditEngine->IsFormatted() )
        pImpEditEngine->FormatDoc();
    return pImpEditEngine->GetLineNumberAtIndex( nPara, nIndex );
}

sal_uInt32 EditEngine::GetLineHeight( sal_Int32 nParagraph, sal_uInt16 nLine )
sal_uInt32 EditEngine::GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine )
{
    // If someone calls GetLineHeight() with an empty Engine.
    if ( !pImpEditEngine->IsFormatted() )
@@ -625,7 +625,7 @@ sal_uInt32 EditEngine::GetTextHeight( sal_Int32 nParagraph ) const
     return nHeight;
}

OUString EditEngine::GetWord( sal_Int32 nPara, sal_uInt16 nIndex )
OUString EditEngine::GetWord( sal_Int32 nPara, sal_Int32 nIndex )
{
    ESelection aESel( nPara, nIndex, nPara, nIndex );
    EditSelection aSel( pImpEditEngine->CreateSel( aESel ) );
@@ -708,7 +708,7 @@ void EditEngine::InsertContent(ContentNode* pNode, sal_Int32 nPos)
    pImpEditEngine->InsertContent(pNode, nPos);
}

EditPaM EditEngine::SplitContent(sal_Int32 nNode, sal_uInt16 nSepPos)
EditPaM EditEngine::SplitContent(sal_Int32 nNode, sal_Int32 nSepPos)
{
    return pImpEditEngine->SplitContent(nNode, nSepPos);
}
@@ -828,7 +828,7 @@ EditSelection EditEngine::SelectWord(
}

long EditEngine::GetXPos(
        const ParaPortion* pParaPortion, const EditLine* pLine, sal_uInt16 nIndex, bool bPreferPortionStart) const
        const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nIndex, bool bPreferPortionStart) const
{
    return pImpEditEngine->GetXPos(pParaPortion, pLine, nIndex, bPreferPortionStart);
}
@@ -885,7 +885,7 @@ const ParaPortionList& EditEngine::GetParaPortions() const
}

void EditEngine::SeekCursor(
        ContentNode* pNode, sal_uInt16 nPos, SvxFont& rFont, OutputDevice* pOut, sal_uInt16 nIgnoreWhich)
        ContentNode* pNode, sal_Int32 nPos, SvxFont& rFont, OutputDevice* pOut, sal_uInt16 nIgnoreWhich)
{
    pImpEditEngine->SeekCursor(pNode, nPos, rFont, pOut, nIgnoreWhich);
}
@@ -1377,7 +1377,7 @@ sal_Bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditVie
        ( !IsVertical() && ( nCode != KEY_LEFT ) && ( nCode != KEY_RIGHT ) ) ||
         ( IsVertical() && ( nCode != KEY_UP ) && ( nCode != KEY_DOWN ) ))
    {
        pEditView->pImpEditView->SetCursorBidiLevel( 0xFFFF );
        pEditView->pImpEditView->SetCursorBidiLevel( CURSOR_BIDILEVEL_DONTKNOW );
    }

    if ( bSetCursorFlags )
@@ -1601,7 +1601,7 @@ void EditEngine::RemoveParagraph( sal_Int32 nPara )
    }
}

sal_uInt16 EditEngine::GetTextLen( sal_Int32 nPara ) const
sal_Int32 EditEngine::GetTextLen( sal_Int32 nPara ) const
{
    ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
    DBG_ASSERT( pNode, "Paragraph not found: GetTextLen" );
@@ -1736,7 +1736,7 @@ SfxItemSet EditEngine::GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAtt
    return pImpEditEngine->GetAttribs( aSel, bOnlyHardAttrib );
}

SfxItemSet EditEngine::GetAttribs( sal_Int32 nPara, sal_uInt16 nStart, sal_uInt16 nEnd, sal_uInt8 nFlags ) const
SfxItemSet EditEngine::GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, sal_uInt8 nFlags ) const
{
    return pImpEditEngine->GetAttribs( nPara, nStart, nEnd, nFlags );
}
@@ -1774,7 +1774,7 @@ void EditEngine::StripPortions()
    pImpEditEngine->Paint( &aTmpDev, aBigRect, Point(), sal_True );
}

void EditEngine::GetPortions( sal_Int32 nPara, std::vector<sal_uInt16>& rList )
void EditEngine::GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList )
{
    if ( !pImpEditEngine->IsFormatted() )
        pImpEditEngine->FormatFullDoc();
@@ -1782,9 +1782,9 @@ void EditEngine::GetPortions( sal_Int32 nPara, std::vector<sal_uInt16>& rList )
    const ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nPara );
    if ( pParaPortion )
    {
        sal_uInt16 nEnd = 0;
        sal_uInt16 nTextPortions = pParaPortion->GetTextPortions().Count();
        for ( sal_uInt16 n = 0; n < nTextPortions; n++ )
        sal_Int32 nEnd = 0;
        sal_Int32 nTextPortions = pParaPortion->GetTextPortions().Count();
        for ( sal_Int32 n = 0; n < nTextPortions; n++ )
        {
            nEnd = nEnd + pParaPortion->GetTextPortions()[n]->GetLen();
            rList.push_back( nEnd );
@@ -1977,7 +1977,7 @@ sal_Bool EditEngine::IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder )
            const ParaPortion* pParaPortion = pImpEditEngine->FindParaPortion( aPaM.GetNode() );
            DBG_ASSERT( pParaPortion, "ParaPortion?" );

            sal_uInt16 nLine = pParaPortion->GetLineNumber( aPaM.GetIndex() );
            sal_Int32 nLine = pParaPortion->GetLineNumber( aPaM.GetIndex() );
            const EditLine* pLine = pParaPortion->GetLines()[nLine];
            Range aLineXPosStartEnd = pImpEditEngine->GetLineXPosStartEnd( pParaPortion, pLine );
            if ( ( aDocPos.X() >= aLineXPosStartEnd.Min() - nBorder ) &&
@@ -2232,7 +2232,7 @@ void EditEngine::GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const

sal_Bool EditEngine::ShouldCreateBigTextObject() const
{
    sal_uInt32 nTextPortions = 0;
    sal_Int32 nTextPortions = 0;
    sal_Int32 nParas = pImpEditEngine->GetEditDoc().Count();
    for ( sal_Int32 nPara = 0; nPara < nParas; nPara++  )
    {
@@ -2428,8 +2428,8 @@ ParagraphInfos EditEngine::GetParagraphInfos( sal_Int32 nPara )
// =====================================================================
// ======================    Virtual Methods    ========================
// =====================================================================
void EditEngine::DrawingText( const Point&, const OUString&, sal_uInt16, sal_uInt16,
    const sal_Int32*, const SvxFont&, sal_Int32, sal_uInt16, sal_uInt8,
void EditEngine::DrawingText( const Point&, const OUString&, sal_Int32, sal_Int32,
    const sal_Int32*, const SvxFont&, sal_Int32, sal_Int32, sal_uInt8,
    const EEngineData::WrongSpellVector*, const SvxFieldData*, bool, bool, bool,
    const ::com::sun::star::lang::Locale*, const Color&, const Color&)

@@ -2438,7 +2438,7 @@ void EditEngine::DrawingText( const Point&, const OUString&, sal_uInt16, sal_uIn

void EditEngine::DrawingTab( const Point& /*rStartPos*/, long /*nWidth*/,
                                      const OUString& /*rChar*/, const SvxFont& /*rFont*/,
                                      sal_Int32 /*nPara*/, xub_StrLen /*nIndex*/,
                                      sal_Int32 /*nPara*/, sal_Int32 /*nIndex*/,
                                      sal_uInt8 /*nRightToLeft*/, bool /*bEndOfLine*/,
                                      bool /*bEndOfParagraph*/, const Color& /*rOverlineColor*/,
                                      const Color& /*rTextLineColor*/)
@@ -2559,16 +2559,16 @@ Rectangle EditEngine::GetBulletArea( sal_Int32 )
    return Rectangle( Point(), Point() );
}

OUString EditEngine::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_uInt16, Color*&, Color*& )
OUString EditEngine::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, Color*&, Color*& )
{
    return OUString(' ');
}

void EditEngine::FieldClicked( const SvxFieldItem&, sal_Int32, sal_uInt16 )
void EditEngine::FieldClicked( const SvxFieldItem&, sal_Int32, sal_Int32 )
{
}

void EditEngine::FieldSelected( const SvxFieldItem&, sal_Int32, sal_uInt16 )
void EditEngine::FieldSelected( const SvxFieldItem&, sal_Int32, sal_Int32 )
{
}

@@ -2781,7 +2781,7 @@ EFieldInfo::EFieldInfo()
}


EFieldInfo::EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_uInt16 nPos ) : aPosition( nPara, nPos )
EFieldInfo::EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_Int32 nPos ) : aPosition( nPara, nPos )
{
    pFieldItem = new SvxFieldItem( rFieldItem );
}
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index e812547..24cc1a8 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -892,9 +892,9 @@ namespace {

class FindByParagraph : std::unary_function<editeng::Section, bool>
{
    size_t mnPara;
    sal_Int32 mnPara;
public:
    FindByParagraph(size_t nPara) : mnPara(nPara) {}
    FindByParagraph(sal_Int32 nPara) : mnPara(nPara) {}
    bool operator() (const editeng::Section& rAttr) const
    {
        return rAttr.mnParagraph == mnPara;
@@ -903,10 +903,10 @@ public:

class FindBySectionStart : std::unary_function<editeng::Section, bool>
{
    size_t mnPara;
    size_t mnStart;
    sal_Int32 mnPara;
    sal_Int32 mnStart;
public:
    FindBySectionStart(size_t nPara, size_t nStart) : mnPara(nPara), mnStart(nStart) {}
    FindBySectionStart(sal_Int32 nPara, sal_Int32 nStart) : mnPara(nPara), mnStart(nStart) {}
    bool operator() (const editeng::Section& rAttr) const
    {
        return rAttr.mnParagraph == mnPara && rAttr.mnStart == mnStart;
@@ -982,7 +982,7 @@ void EditTextObjectImpl::GetAllSections( std::vector<editeng::Section>& rAttrs )

    // Go through all formatted paragraphs, and store format items.
    std::vector<editeng::Section>::iterator itAttr = aAttrs.begin();
    for (size_t nPara = 0; nPara < aContents.size(); ++nPara)
    for (sal_Int32 nPara = 0; nPara < (sal_Int32)aContents.size(); ++nPara)
    {
        const ContentInfo& rC = aContents[nPara];

@@ -998,7 +998,7 @@ void EditTextObjectImpl::GetAllSections( std::vector<editeng::Section>& rAttrs )
            if (!pItem)
                continue;

            size_t nStart = rXAttr.GetStart(), nEnd = rXAttr.GetEnd();
            sal_Int32 nStart = rXAttr.GetStart(), nEnd = rXAttr.GetEnd();
            std::vector<editeng::Section>::iterator itCurAttr = itAttr;

            // Find the container whose start position matches.
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index b32e3f6..fdedb5f 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -717,7 +717,7 @@ void EditView::StartTextConversion(
}


sal_uInt16 EditView::StartSearchAndReplace( const SvxSearchItem& rSearchItem )
sal_Int32 EditView::StartSearchAndReplace( const SvxSearchItem& rSearchItem )
{
    return PIMPEE->StartSearchAndReplace( this, rSearchItem );
}
@@ -1047,16 +1047,16 @@ void EditView::InsertField( const SvxFieldItem& rFld )
const SvxFieldItem* EditView::GetFieldUnderMousePointer() const
{
    sal_Int32 nPara;
    sal_uInt16 nPos;
    sal_Int32 nPos;
    return GetFieldUnderMousePointer( nPara, nPos );
}

const SvxFieldItem* EditView::GetField( const Point& rPos, sal_Int32* pPara, sal_uInt16* pPos ) const
const SvxFieldItem* EditView::GetField( const Point& rPos, sal_Int32* pPara, sal_Int32* pPos ) const
{
    return pImpEditView->GetField( rPos, pPara, pPos );
}

const SvxFieldItem* EditView::GetFieldUnderMousePointer( sal_Int32& nPara, sal_uInt16& nPos ) const
const SvxFieldItem* EditView::GetFieldUnderMousePointer( sal_Int32& nPara, sal_Int32& nPos ) const
{
    Point aPos = pImpEditView->GetWindow()->GetPointerPosPixel();
    aPos = pImpEditView->GetWindow()->PixelToLogic( aPos );
@@ -1133,19 +1133,19 @@ void EditView::ChangeFontSize( bool bGrow, const FontList* pFontList )
    {
        for( sal_Int32 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
        {
            std::vector<sal_uInt16> aPortions;
            std::vector<sal_Int32> aPortions;
            rEditEngine.GetPortions( nPara, aPortions );

            if( aPortions.empty() )
                aPortions.push_back( rEditEngine.GetTextLen(nPara) );

            const sal_uInt16 nBeginPos = (nPara == aSel.nStartPara) ? aSel.nStartPos : 0;
            const sal_uInt16 nEndPos = (nPara == aSel.nEndPara) ? aSel.nEndPos : EE_TEXTPOS_ALL;
            const sal_Int32 nBeginPos = (nPara == aSel.nStartPara) ? aSel.nStartPos : 0;
            const sal_Int32 nEndPos = (nPara == aSel.nEndPara) ? aSel.nEndPos : EE_TEXTPOS_ALL;

            for ( size_t nPos = 0; nPos < aPortions.size(); ++nPos )
            {
                sal_uInt16 nPortionEnd   = aPortions[ nPos ];
                sal_uInt16 nPortionStart = nPos > 0 ? aPortions[ nPos - 1 ] : 0;
                sal_Int32 nPortionEnd   = aPortions[ nPos ];
                sal_Int32 nPortionStart = nPos > 0 ? aPortions[ nPos - 1 ] : 0;

                if( (nPortionEnd < nBeginPos) || (nPortionStart > nEndPos) )
                    continue;
diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx
index e838c4e..160a77e 100644
--- a/editeng/source/editeng/edtspell.cxx
+++ b/editeng/source/editeng/edtspell.cxx
@@ -197,7 +197,7 @@ void EditSpellWrapper::CheckSpellTo()
    }
}

size_t WrongList::Valid = std::numeric_limits<size_t>::max();
sal_Int32 WrongList::Valid = std::numeric_limits<sal_Int32>::max();

WrongList::WrongList() : mnInvalidStart(0), mnInvalidEnd(Valid) {}

@@ -229,7 +229,7 @@ void WrongList::SetValid()
    mnInvalidEnd = 0;
}

void WrongList::SetInvalidRange( size_t nStart, size_t nEnd )
void WrongList::SetInvalidRange( sal_Int32 nStart, sal_Int32 nEnd )
{
    if (mnInvalidStart == Valid || nStart < mnInvalidStart)
        mnInvalidStart = nStart;
@@ -238,13 +238,13 @@ void WrongList::SetInvalidRange( size_t nStart, size_t nEnd )
        mnInvalidEnd = nEnd;
}

void WrongList::ResetInvalidRange( size_t nStart, size_t nEnd )
void WrongList::ResetInvalidRange( sal_Int32 nStart, sal_Int32 nEnd )
{
    mnInvalidStart = nStart;
    mnInvalidEnd = nEnd;
}

void WrongList::TextInserted( size_t nPos, size_t nLength, bool bPosIsSep )
void WrongList::TextInserted( sal_Int32 nPos, sal_Int32 nLength, bool bPosIsSep )
{
    if (IsValid())
    {
@@ -261,7 +261,7 @@ void WrongList::TextInserted( size_t nPos, size_t nLength, bool bPosIsSep )
            mnInvalidEnd = nPos + nLength;
    }

    for (size_t i = 0, n = maRanges.size(); i < n; ++i)
    for (sal_Int32 i = 0, n = (sal_Int32)maRanges.size(); i < n; ++i)
    {
        editeng::MisspellRange& rWrong = maRanges[i];
        bool bRefIsValid = true;
@@ -313,9 +313,9 @@ void WrongList::TextInserted( size_t nPos, size_t nLength, bool bPosIsSep )
    SAL_WARN_IF(DbgIsBuggy(), "editeng", "InsertWrong: WrongList broken!");
}

void WrongList::TextDeleted( size_t nPos, size_t nLength )
void WrongList::TextDeleted( sal_Int32 nPos, sal_Int32 nLength )
{
    size_t nEndPos = nPos + nLength;
    sal_Int32 nEndPos = nPos + nLength;
    if (IsValid())
    {
        sal_uInt16 nNewInvalidStart = nPos ? nPos - 1 : 0;
@@ -381,7 +381,7 @@ void WrongList::TextDeleted( size_t nPos, size_t nLength )
    SAL_WARN_IF(DbgIsBuggy(), "editeng", "TextDeleted: WrongList broken!");
}

bool WrongList::NextWrong( size_t& rnStart, size_t& rnEnd ) const
bool WrongList::NextWrong( sal_Int32& rnStart, sal_Int32& rnEnd ) const
{
    /*
        rnStart get the start position, is possibly adjusted wrt. Wrong start
@@ -399,7 +399,7 @@ bool WrongList::NextWrong( size_t& rnStart, size_t& rnEnd ) const
    return false;
}

bool WrongList::HasWrong( size_t nStart, size_t nEnd ) const
bool WrongList::HasWrong( sal_Int32 nStart, sal_Int32 nEnd ) const
{
    for (WrongList::const_iterator i = begin(); i != end(); ++i)
    {
@@ -411,7 +411,7 @@ bool WrongList::HasWrong( size_t nStart, size_t nEnd ) const
    return false;
}

bool WrongList::HasAnyWrong( size_t nStart, size_t nEnd ) const
bool WrongList::HasAnyWrong( sal_Int32 nStart, sal_Int32 nEnd ) const
{
    for (WrongList::const_iterator i = begin(); i != end(); ++i)
    {
@@ -423,12 +423,16 @@ bool WrongList::HasAnyWrong( size_t nStart, size_t nEnd ) const
    return false;
}

void WrongList::ClearWrongs( size_t nStart, size_t nEnd,
            const ContentNode* pNode )
void WrongList::ClearWrongs( sal_Int32 nStart, sal_Int32 nEnd,
                             const ContentNode* pNode )
{
    if(nEnd < 0)
    {
        nEnd = SAL_MAX_INT32;
    }
    for (WrongList::iterator i = begin(); i != end(); )
    {
        if (i->mnEnd > nStart && i->mnStart < nEnd)
        if ((i->mnEnd > nStart) && (i->mnStart < nEnd))
        {
            if (i->mnEnd > nEnd) // Runs out
            {
@@ -457,7 +461,7 @@ void WrongList::ClearWrongs( size_t nStart, size_t nEnd,
    SAL_WARN_IF(DbgIsBuggy(), "editeng", "ClearWrongs: WrongList broken!");
}

void WrongList::InsertWrong( size_t nStart, size_t nEnd )
void WrongList::InsertWrong( sal_Int32 nStart, sal_Int32 nEnd )
{
    WrongList::iterator nPos = end();
    for (WrongList::iterator i = begin(); i != end(); ++i)
diff --git a/editeng/source/editeng/edtspell.hxx b/editeng/source/editeng/edtspell.hxx
index 4951e79..2af8d1f 100644
--- a/editeng/source/editeng/edtspell.hxx
+++ b/editeng/source/editeng/edtspell.hxx
@@ -70,11 +70,11 @@ public:
 */
class WrongList
{
    static size_t Valid;
    static sal_Int32 Valid;

    std::vector<editeng::MisspellRange> maRanges;
    size_t mnInvalidStart;
    size_t mnInvalidEnd;
    sal_Int32 mnInvalidStart;
    sal_Int32 mnInvalidEnd;

    bool DbgIsBuggy() const;

@@ -91,20 +91,20 @@ public:

    bool IsValid() const;
    void SetValid();
    void SetInvalidRange( size_t nStart, size_t nEnd );
    void ResetInvalidRange( size_t nStart, size_t nEnd );
    void SetInvalidRange( sal_Int32 nStart, sal_Int32 nEnd );
    void ResetInvalidRange( sal_Int32 nStart, sal_Int32 nEnd );

    size_t GetInvalidStart() const { return mnInvalidStart; }
    size_t GetInvalidEnd() const   { return mnInvalidEnd; }
    sal_Int32 GetInvalidStart() const { return mnInvalidStart; }
    sal_Int32 GetInvalidEnd() const   { return mnInvalidEnd; }

    void TextInserted( size_t nPos, size_t nLength, bool bPosIsSep );
    void TextDeleted( size_t nPos, size_t nLength );
    void TextInserted( sal_Int32 nPos, sal_Int32 nLength, bool bPosIsSep );
    void TextDeleted( sal_Int32 nPos, sal_Int32 nLength );

    void InsertWrong( size_t nStart, size_t nEnd );
    bool NextWrong( size_t& rnStart, size_t& rnEnd ) const;
    bool HasWrong( size_t nStart, size_t nEnd ) const;
    bool HasAnyWrong( size_t nStart, size_t nEnd ) const;
    void ClearWrongs( size_t nStart, size_t nEnd, const ContentNode* pNode );
    void InsertWrong( sal_Int32 nStart, sal_Int32 nEnd );
    bool NextWrong( sal_Int32& rnStart, sal_Int32& rnEnd ) const;
    bool HasWrong( sal_Int32 nStart, sal_Int32 nEnd ) const;
    bool HasAnyWrong( sal_Int32 nStart, sal_Int32 nEnd ) const;
    void ClearWrongs( sal_Int32 nStart, sal_Int32 nEnd, const ContentNode* pNode );
    void MarkWrongsInvalid();

    WrongList*  Clone() const;
diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx
index c336a53..ce5bbcf 100644
--- a/editeng/source/editeng/eertfpar.cxx
+++ b/editeng/source/editeng/eertfpar.cxx
@@ -268,7 +268,7 @@ void EditRTFParser::MovePos( int bForward )
}

void EditRTFParser::SetEndPrevPara( SvxNodeIdx*& rpNodePos,
                                    sal_uInt16& rCntPos )
                                    sal_Int32& rCntPos )
{
    // The Intention is to: determine the current insert position of the
    //                      previous paragraph and set the end from this.
@@ -285,7 +285,7 @@ void EditRTFParser::SetEndPrevPara( SvxNodeIdx*& rpNodePos,
    rCntPos = pPrevNode->Len();
}

bool EditRTFParser::IsEndPara( SvxNodeIdx* pNd, sal_uInt16 nCnt ) const
bool EditRTFParser::IsEndPara( SvxNodeIdx* pNd, sal_Int32 nCnt ) const
{
    return ( nCnt == ( ((EditNodeIdx*)pNd)->GetNode()->Len()) );
}
@@ -622,7 +622,7 @@ sal_Int32 EditPosition::GetNodeIdx() const
    return mpEditEngine->GetEditDoc().GetPos(pN);
}

sal_uInt16 EditPosition::GetCntIdx() const
sal_Int32 EditPosition::GetCntIdx() const
{
    return mpCurSel->Max().GetIndex();
}
diff --git a/editeng/source/editeng/eertfpar.hxx b/editeng/source/editeng/eertfpar.hxx
index 206a262..df7d7d79 100644
--- a/editeng/source/editeng/eertfpar.hxx
+++ b/editeng/source/editeng/eertfpar.hxx
@@ -50,7 +50,7 @@ public:
    EditPosition(EditEngine* pIEE, EditSelection* pSel);

    virtual sal_Int32   GetNodeIdx() const;
    virtual sal_uInt16  GetCntIdx() const;
    virtual sal_Int32   GetCntIdx() const;

    // clone
    virtual SvxPosition* Clone() const;
@@ -81,12 +81,12 @@ protected:
    virtual void        InsertText();
    virtual void        MovePos( int bForward = sal_True );
    virtual void        SetEndPrevPara( SvxNodeIdx*& rpNodePos,
                                            sal_uInt16& rCntPos );
                                            sal_Int32& rCntPos );

    virtual void        UnknownAttrToken( int nToken, SfxItemSet* pSet );
    virtual void        NextToken( int nToken );
    virtual void        SetAttrInDoc( SvxRTFItemStackType &rSet );
    virtual bool        IsEndPara( SvxNodeIdx* pNd, sal_uInt16 nCnt ) const;
    virtual bool        IsEndPara( SvxNodeIdx* pNd, sal_Int32 nCnt ) const;
    virtual void        CalcValue();
    void                CreateStyleSheets();
    SfxStyleSheet*      CreateStyleSheet( SvxRTFStyleType* pRTFStyle );
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 5b50170..b91f9b1 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -256,8 +256,8 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, Region* pRegion, OutputD
            }
            else
            {
                sal_uInt16 nTmpStartIndex = nStartIndex;
                sal_uInt16 nWritingDirStart, nTmpEndIndex;
                sal_Int32 nTmpStartIndex = nStartIndex;
                sal_Int32 nWritingDirStart, nTmpEndIndex;

                while ( nTmpStartIndex < nEndIndex )
                {
@@ -652,7 +652,7 @@ void ImpEditView::ShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, sa

    EditPaM aPaM( aEditSelection.Max() );

    sal_uInt16 nTextPortionStart = 0;
    sal_Int32 nTextPortionStart = 0;
    sal_Int32 nPara = pEditEngine->GetEditDoc().GetPos( aPaM.GetNode() );
    if (nPara == EE_PARA_NOT_FOUND) // #i94322
        return;
@@ -680,7 +680,7 @@ void ImpEditView::ShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, sa
            // If we are behind a portion, and the next portion has other direction, we must change position...
            aEditCursor.Left() = aEditCursor.Right() = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GETCRSR_TXTONLY|GETCRSR_PREFERPORTIONSTART ).Left();

            sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, true );
            sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, true );
            const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
            if ( pTextPortion->GetKind() == PORTIONKIND_TAB )
            {
@@ -1173,7 +1173,7 @@ void ImpEditView::DeleteSelected()
    ShowCursor( DoAutoScroll(), sal_True );
}

const SvxFieldItem* ImpEditView::GetField( const Point& rPos, sal_Int32* pPara, sal_uInt16* pPos ) const
const SvxFieldItem* ImpEditView::GetField( const Point& rPos, sal_Int32* pPara, sal_Int32* pPos ) const
{
    if( !GetOutputArea().IsInside( rPos ) )
        return 0;
@@ -1547,7 +1547,7 @@ void ImpEditView::dragGestureRecognized( const ::com::sun::star::datatransfer::d
    {
        // Field?!
        sal_Int32 nPara;
        sal_uInt16 nPos;
        sal_Int32 nPos;
        Point aMousePos = GetWindow()->PixelToLogic( aMousePosPixel );
        const SvxFieldItem* pField = GetField( aMousePos, &nPara, &nPos );
        if ( pField )
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index dc3211bb..08a2e78 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -135,7 +135,7 @@ struct ImplIMEInfos
    OUString    aOldTextAfterStartPos;
    sal_uInt16* pAttribs;
    EditPaM     aPos;
    sal_uInt16  nLen;
    sal_Int32   nLen;
    sal_Bool    bCursor;
    sal_Bool    bWasCursorOverwrite;

@@ -359,7 +359,7 @@ public:
    sal_Bool        IsWrongSpelledWord( const EditPaM& rPaM, sal_Bool bMarkIfWrong );
    OUString        SpellIgnoreOrAddWord( sal_Bool bAdd );

    const SvxFieldItem* GetField( const Point& rPos, sal_Int32* pPara, sal_uInt16* pPos ) const;
    const SvxFieldItem* GetField( const Point& rPos, sal_Int32* pPara, sal_Int32* pPos ) const;
    void            DeleteSelected();

    //  If possible invalidate more than OutputArea, for the DrawingEngine text frame
@@ -429,7 +429,7 @@ private:

    EEHorizontalTextDirection eDefaultHorizontalTextDirection;

    sal_uInt16          nBigTextObjectStart;
    sal_Int32          nBigTextObjectStart;
    ::com::sun::star::uno::Reference<
        ::com::sun::star::linguistic2::XSpellChecker1 > xSpeller;
    ::com::sun::star::uno::Reference<
@@ -511,9 +511,9 @@ private:

    EditPaM             GetPaM( Point aDocPos, sal_Bool bSmart = sal_True );
    EditPaM             GetPaM( ParaPortion* pPortion, Point aPos, sal_Bool bSmart = sal_True );
    long GetXPos(const ParaPortion* pParaPortion, const EditLine* pLine, sal_uInt16 nIndex, bool bPreferPortionStart = false) const;
    long GetPortionXOffset(const ParaPortion* pParaPortion, const EditLine* pLine, sal_uInt16 nTextPortion) const;
    sal_uInt16 GetChar(const ParaPortion* pParaPortion, const EditLine* pLine, long nX, bool bSmart = true);
    long GetXPos(const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nIndex, bool bPreferPortionStart = false) const;
    long GetPortionXOffset(const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nTextPortion) const;
    sal_Int32 GetChar(const ParaPortion* pParaPortion, const EditLine* pLine, long nX, bool bSmart = true);
    Range               GetInvalidYOffsets( ParaPortion* pPortion );
    Range GetLineXPosStartEnd( const ParaPortion* pParaPortion, const EditLine* pLine ) const;

@@ -523,7 +523,7 @@ private:
    void                ParaAttribsToCharAttribs( ContentNode* pNode );
    void                GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const;

    EditTextObject*     CreateTextObject( EditSelection aSelection, SfxItemPool*, sal_Bool bAllowBigObjects = sal_False, sal_uInt16 nBigObjStart = 0 );
    EditTextObject*     CreateTextObject( EditSelection aSelection, SfxItemPool*, sal_Bool bAllowBigObjects = sal_False, sal_Int32 nBigObjStart = 0 );
    EditSelection       InsertTextObject( const EditTextObject&, EditPaM aPaM );
    EditSelection       InsertText( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rxDataObj, const OUString& rBaseURL, const EditPaM& rPaM, sal_Bool bUseSpecial );

@@ -534,14 +534,14 @@ private:
    void                CreateAndInsertEmptyLine( ParaPortion* pParaPortion, sal_uInt32 nStartPosY );
    sal_Bool            FinishCreateLines( ParaPortion* pParaPortion );
    void                CalcCharPositions( ParaPortion* pParaPortion );
    void                CreateTextPortions( ParaPortion* pParaPortion, sal_uInt16& rStartPos /*, sal_Bool bCreateBlockPortions */ );
    void                RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nStartPos, short nNewChars );
    sal_uInt16          SplitTextPortion( ParaPortion* pParaPortion, sal_uInt16 nPos,  EditLine* pCurLine = 0 );
    void                SeekCursor( ContentNode* pNode, sal_uInt16 nPos, SvxFont& rFont, OutputDevice* pOut = NULL, sal_uInt16 nIgnoreWhich = 0 );
    void                CreateTextPortions( ParaPortion* pParaPortion, sal_Int32& rStartPos /*, sal_Bool bCreateBlockPortions */ );
    void                RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nStartPos, sal_Int32 nNewChars );
    sal_Int32           SplitTextPortion( ParaPortion* pParaPortion, sal_Int32 nPos,  EditLine* pCurLine = 0 );
    void                SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFont, OutputDevice* pOut = NULL, sal_uInt16 nIgnoreWhich = 0 );
    void                RecalcFormatterFontMetrics( FormatterFontMetric& rCurMetrics, SvxFont& rFont );
    void                CheckAutoPageSize();

    void                ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, TextPortion* pPortion, sal_uInt16 nPortionStart, long nRemainingWidth, sal_Bool bCanHyphenate );
    void                ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, TextPortion* pPortion, sal_Int32 nPortionStart, long nRemainingWidth, sal_Bool bCanHyphenate );
    void                ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, long nRemainingSpace );
    EditPaM             ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pRight, sal_Bool bBackward = sal_False );
    EditPaM             ImpDeleteSelection(const EditSelection& rCurSel);
@@ -549,7 +549,7 @@ private:
    EditPaM             ImpInsertParaBreak( const EditSelection& rEditSelection, bool bKeepEndingAttribs = true );
    EditPaM             ImpInsertText(const EditSelection& aCurEditSelection, const OUString& rStr);
    EditPaM             ImpInsertFeature(const EditSelection& rCurSel, const SfxPoolItem& rItem);
    void                ImpRemoveChars( const EditPaM& rPaM, sal_uInt16 nChars, EditUndoRemoveChars* pCurUndo = 0 );
    void                ImpRemoveChars( const EditPaM& rPaM, sal_Int32 nChars, EditUndoRemoveChars* pCurUndo = 0 );
    void                ImpRemoveParagraph( sal_Int32 nPara );
    EditSelection       ImpMoveParagraphs( Range aParagraphs, sal_Int32 nNewPos );

@@ -560,10 +560,10 @@ private:

    bool                ImplHasText() const;

    void                ImpFindKashidas( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, std::vector<sal_uInt16>& rArray );
    void                ImpFindKashidas( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, std::vector<sal_Int32>& rArray );

    void                InsertContent( ContentNode* pNode, sal_Int32 nPos );
    EditPaM             SplitContent( sal_Int32 nNode, sal_uInt16 nSepPos );
    EditPaM             SplitContent( sal_Int32 nNode, sal_Int32 nSepPos );
    EditPaM             ConnectContents( sal_Int32 nLeftNode, sal_Bool bBackward );

    void                ShowParagraph( sal_Int32 nParagraph, bool bShow );
@@ -591,15 +591,15 @@ private:


    void                InitScriptTypes( sal_Int32 nPara );
    sal_uInt16          GetI18NScriptType( const EditPaM& rPaM, sal_uInt16* pEndPos = NULL ) const;
    sal_uInt16          GetI18NScriptType( const EditPaM& rPaM, sal_Int32* pEndPos = NULL ) const;
    sal_uInt16          GetItemScriptType( const EditSelection& rSel ) const;
    sal_Bool            IsScriptChange( const EditPaM& rPaM ) const;
    sal_Bool            HasScriptType( sal_Int32 nPara, sal_uInt16 nType ) const;

    bool                ImplCalcAsianCompression( ContentNode* pNode, TextPortion* pTextPortion, sal_uInt16 nStartPos, sal_Int32* pDXArray, sal_uInt16 n100thPercentFromMax, sal_Bool bManipulateDXArray );
    bool                ImplCalcAsianCompression( ContentNode* pNode, TextPortion* pTextPortion, sal_Int32 nStartPos, sal_Int32* pDXArray, sal_uInt16 n100thPercentFromMax, sal_Bool bManipulateDXArray );
    void                ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* pParaPortion, long nRemainingWidth );

    void                ImplInitLayoutMode( OutputDevice* pOutDev, sal_Int32 nPara, sal_uInt16 nIndex );
    void                ImplInitLayoutMode( OutputDevice* pOutDev, sal_Int32 nPara, sal_Int32 nIndex );
    LanguageType        ImplCalcDigitLang(LanguageType eCurLang) const;
    void                ImplInitDigitMode(OutputDevice* pOutDev, LanguageType eLang);
    OUString            convertDigits(const OUString &rString, sal_Int32 nStt, sal_Int32 nLen, LanguageType eDigitLang) const;
@@ -615,9 +615,9 @@ private:
    sal_uInt32          WriteHTML( SvStream& rOutput, EditSelection aSel );
    sal_uInt32 WriteBin( SvStream& rOutput, EditSelection aSel, bool bStoreUnicode = false );

    void                WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, sal_Int32 nPara, sal_uInt16 nPos,
    void                WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, sal_Int32 nPara, sal_Int32 nPos,
                        std::vector<SvxFontItem*>& rFontTable, SvxColorList& rColorList );
    sal_Bool            WriteItemListAsRTF( ItemList& rLst, SvStream& rOutput, sal_Int32 nPara, sal_uInt16 nPos,
    sal_Bool            WriteItemListAsRTF( ItemList& rLst, SvStream& rOutput, sal_Int32 nPara, sal_Int32 nPos,
                        std::vector<SvxFontItem*>& rFontTable, SvxColorList& rColorList );
    sal_Int32               LogicToTwips( sal_Int32 n );

@@ -709,7 +709,7 @@ public:

    void                    InitWritingDirections( sal_Int32 nPara );
    sal_Bool                    IsRightToLeft( sal_Int32 nPara ) const;
    sal_uInt8                    GetRightToLeft( sal_Int32 nPara, sal_uInt16 nChar, sal_uInt16* pStart = NULL, sal_uInt16* pEnd = NULL );
    sal_uInt8                    GetRightToLeft( sal_Int32 nPara, sal_Int32 nChar, sal_Int32* pStart = NULL, sal_Int32* pEnd = NULL );
    sal_Bool                    HasDifferentRTLLevels( const ContentNode* pNode );

    void                    SetTextRanger( TextRanger* pRanger );
@@ -786,14 +786,14 @@ public:
    sal_uInt32      GetTextHeightNTP() const;
    sal_uInt32      CalcTextWidth( sal_Bool bIgnoreExtraSpace );
    sal_uInt32      CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, sal_Bool bIgnoreExtraSpace );
    sal_uInt16      GetLineCount( sal_Int32 nParagraph ) const;
    sal_uInt16      GetLineLen( sal_Int32 nParagraph, sal_uInt16 nLine ) const;
    void            GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nParagraph, sal_uInt16 nLine ) const;
    sal_uInt16          GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nIndex ) const;
    sal_uInt16      GetLineHeight( sal_Int32 nParagraph, sal_uInt16 nLine );
    sal_Int32       GetLineCount( sal_Int32 nParagraph ) const;
    sal_Int32       GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const;
    void            GetLineBoundaries( /*out*/sal_Int32& rStart, /*out*/sal_Int32& rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const;
    sal_Int32       GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const;
    sal_uInt16      GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine );
    sal_uInt32      GetParaHeight( sal_Int32 nParagraph );

    SfxItemSet      GetAttribs( sal_Int32 nPara, sal_uInt16 nStart, sal_uInt16 nEnd, sal_uInt8 nFlags = 0xFF ) const;
    SfxItemSet      GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, sal_uInt8 nFlags = 0xFF ) const;
    SfxItemSet      GetAttribs( EditSelection aSel, sal_Bool bOnlyHardAttrib = sal_False  );
    void            SetAttribs( EditSelection aSel, const SfxItemSet& rSet, sal_uInt8 nSpecial = 0 );
    void            RemoveCharAttribs( EditSelection aSel, sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich = 0 );
@@ -807,7 +807,7 @@ public:
    const SfxPoolItem&  GetParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ) const;

    Rectangle       PaMtoEditCursor( EditPaM aPaM, sal_uInt16 nFlags = 0 );
    Rectangle       GetEditCursor( ParaPortion* pPortion, sal_uInt16 nIndex, sal_uInt16 nFlags = 0 );
    Rectangle       GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex, sal_uInt16 nFlags = 0 );

    sal_Bool        IsModified() const      { return aEditDoc.IsModified(); }
    void            SetModifyFlag( sal_Bool b ) { aEditDoc.SetModified( b ); }
@@ -841,7 +841,7 @@ public:
    sal_Bool            IsVisualCursorTravelingEnabled();
    sal_Bool            DoVisualCursorTraveling( const ContentNode* pNode );

    EditSelection ConvertSelection( sal_Int32 nStartPara, sal_uInt16 nStartPos, sal_Int32 nEndPara, sal_uInt16 nEndPos );
    EditSelection ConvertSelection( sal_Int32 nStartPara, sal_Int32 nStartPos, sal_Int32 nEndPara, sal_Int32 nEndPos );
    inline EPaM             CreateEPaM( const EditPaM& rPaM );
    inline EditPaM          CreateEditPaM( const EPaM& rEPaM );
    inline ESelection       CreateESel( const EditSelection& rSel );
@@ -903,7 +903,7 @@ public:


    LanguageType        GetLanguage( const EditSelection &rSelection ) const;
    LanguageType        GetLanguage( const EditPaM& rPaM, sal_uInt16* pEndPos = NULL ) const;
    LanguageType        GetLanguage( const EditPaM& rPaM, sal_Int32* pEndPos = NULL ) const;
    ::com::sun::star::lang::Locale GetLocale( const EditPaM& rPaM ) const;

    void DoOnlineSpelling( ContentNode* pThisNodeOnly = 0, bool bSpellAtCursorPos = false, bool bInteruptable = true );
@@ -955,7 +955,7 @@ public:

    sal_Bool            Search( const SvxSearchItem& rSearchItem, EditView* pView );
    sal_Bool            ImpSearch( const SvxSearchItem& rSearchItem, const EditSelection& rSearchSelection, const EditPaM& rStartPos, EditSelection& rFoundSel );
    sal_uInt16          StartSearchAndReplace( EditView* pEditView, const SvxSearchItem& rSearchItem );
    sal_Int32           StartSearchAndReplace( EditView* pEditView, const SvxSearchItem& rSearchItem );
    sal_Bool            HasText( const SvxSearchItem& rSearchItem );

    void                SetEditTextObjectPool( SfxItemPool* pP )    { pTextObjectPool = pP; }
@@ -972,8 +972,8 @@ public:
    void                SetCharStretching( sal_uInt16 nX, sal_uInt16 nY );
    inline void         GetCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const;

    void                SetBigTextObjectStart( sal_uInt16 nStartAtPortionCount )    { nBigTextObjectStart = nStartAtPortionCount; }
    sal_uInt16          GetBigTextObjectStart() const                               { return nBigTextObjectStart; }
    void                SetBigTextObjectStart( sal_Int32 nStartAtPortionCount )    { nBigTextObjectStart = nStartAtPortionCount; }
    sal_Int32           GetBigTextObjectStart() const                               { return nBigTextObjectStart; }

    inline EditEngine*  GetEditEnginePtr() const    { return pEditEngine; }

@@ -984,7 +984,7 @@ public:
    void                SetAutoCompleteText(const OUString& rStr, bool bUpdateTipWindow);

    EditSelection       TransliterateText( const EditSelection& rSelection, sal_Int32 nTransliterationMode );
    short               ReplaceTextOnly( ContentNode* pNode, sal_uInt16 nCurrentStart, xub_StrLen nLen, const OUString& rText, const ::com::sun::star::uno::Sequence< sal_Int32 >& rOffsets );
    short               ReplaceTextOnly( ContentNode* pNode, sal_Int32 nCurrentStart, sal_Int32 nLen, const OUString& rText, const ::com::sun::star::uno::Sequence< sal_Int32 >& rOffsets );


    void                SetAsianCompressionMode( sal_uInt16 n );
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 44c7715..d9884c6 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -432,7 +432,7 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
                              ( nOldIMETextLen < mpIMEInfos->aOldTextAfterStartPos.getLength() ) )
                    {
                        // overwrite
                        sal_uInt16 nOverwrite = nNewIMETextLen - nOldIMETextLen;
                        sal_Int32 nOverwrite = nNewIMETextLen - nOldIMETextLen;
                        if ( ( nOldIMETextLen + nOverwrite ) > mpIMEInfos->aOldTextAfterStartPos.getLength() )
                            nOverwrite = mpIMEInfos->aOldTextAfterStartPos.getLength() - nOldIMETextLen;
                        OSL_ENSURE( nOverwrite && (nOverwrite < 0xFF00), "IME Overwrite?!" );
@@ -479,13 +479,13 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
            EditPaM aPaM( pView->pImpEditView->GetEditSelection().Max() );
            Rectangle aR1 = PaMtoEditCursor( aPaM, 0 );

            sal_uInt16 nInputEnd = mpIMEInfos->aPos.GetIndex() + mpIMEInfos->nLen;
            sal_Int32 nInputEnd = mpIMEInfos->aPos.GetIndex() + mpIMEInfos->nLen;

            if ( !IsFormatted() )
                FormatDoc();

            ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( GetEditDoc().GetPos( aPaM.GetNode() ) );
            sal_uInt16 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), true );
            sal_Int32 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), true );
            const EditLine* pLine = pParaPortion->GetLines()[nLine];
            if ( pLine && ( nInputEnd > pLine->GetEnd() ) )
                nInputEnd = pLine->GetEnd();
@@ -527,7 +527,7 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )

            if ( aSelection.nStartPara != aSelection.nEndPara )
            {
                xub_StrLen aParaLen = pEditEngine->GetTextLen( aSelection.nStartPara );
                sal_Int32 aParaLen = pEditEngine->GetTextLen( aSelection.nStartPara );
                aSelection.nEndPara = aSelection.nStartPara;
                aSelection.nEndPos = aParaLen;
                pView->SetSelection( aSelection );
@@ -543,14 +543,14 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
                FormatDoc();

            ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( GetEditDoc().GetPos( aPaM.GetNode() ) );
            sal_uInt16 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), true );
            sal_Int32 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), true );
            const EditLine* pLine = pParaPortion->GetLines()[nLine];
            if ( pLine )
            {
                Rectangle* aRects = new Rectangle[ mpIMEInfos->nLen ];
                for (sal_uInt16 i = 0; i < mpIMEInfos->nLen; ++i)
                for (sal_Int32 i = 0; i < mpIMEInfos->nLen; ++i)
                {
                    sal_uInt16 nInputPos = mpIMEInfos->aPos.GetIndex() + i;
                    sal_Int32 nInputPos = mpIMEInfos->aPos.GetIndex() + i;
                    if ( nInputPos > pLine->GetEnd() )
                        nInputPos = pLine->GetEnd();
                    Rectangle aR2 = GetEditCursor( pParaPortion, nInputPos );
@@ -914,7 +914,7 @@ EditPaM ImpEditEngine::CursorVisualStartEnd( EditView* pEditView, const EditPaM&
    sal_Int32 nPara = GetEditDoc().GetPos( aPaM.GetNode() );
    ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara );

    sal_uInt16 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), false );
    sal_Int32 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), false );
    const EditLine* pLine = pParaPortion->GetLines()[nLine];
    bool bEmptyLine = pLine->GetStart() == pLine->GetEnd();

@@ -939,10 +939,10 @@ EditPaM ImpEditEngine::CursorVisualStartEnd( EditView* pEditView, const EditPaM&

        aPaM.SetIndex( nLogPos + pLine->GetStart() );

        sal_uInt16 nTmp;
        sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTmp, true );
        sal_Int32 nTmp;
        sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTmp, true );
        const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
        sal_uInt16 nRTLLevel = pTextPortion->GetRightToLeft();
        sal_Int32 nRTLLevel = pTextPortion->GetRightToLeft();
        sal_Bool bPortionRTL = (nRTLLevel%2) ? sal_True : sal_False;

        if ( bStart )
@@ -970,7 +970,7 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
    sal_Int32 nPara = GetEditDoc().GetPos( aPaM.GetNode() );
    ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara );

    sal_uInt16 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), false );
    sal_Int32 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), false );
    const EditLine* pLine = pParaPortion->GetLines()[nLine];
    bool bEmptyLine = pLine->GetStart() == pLine->GetEnd();

@@ -1003,19 +1003,19 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
    if ( !bDone && pEditView->IsInsertMode() )
    {
        // Check if we are within a portion and don't have overwrite mode, then it's easy...
        sal_uInt16 nPortionStart;
        sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nPortionStart, false );
        sal_Int32 nPortionStart;
        sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nPortionStart, false );
        const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];

        sal_Bool bPortionBoundary = ( aPaM.GetIndex() == nPortionStart ) || ( aPaM.GetIndex() == (nPortionStart+pTextPortion->GetLen()) );
        sal_uInt16 nRTLLevel = pTextPortion->GetRightToLeft();

        // Portion boundary doesn't matter if both have same RTL level
        sal_uInt16 nRTLLevelNextPortion = 0xFFFF;
        sal_Int32 nRTLLevelNextPortion = -1;
        if ( bPortionBoundary && aPaM.GetIndex() && ( aPaM.GetIndex() < aPaM.GetNode()->Len() ) )
        {
            sal_uInt16 nTmp;
            sal_uInt16 nNextTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex()+1, nTmp, bLogicalBackward ? sal_False : sal_True );
            sal_Int32 nTmp;
            sal_Int32 nNextTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex()+1, nTmp, bLogicalBackward ? sal_False : sal_True );
            const TextPortion* pNextTextPortion = pParaPortion->GetTextPortions()[nNextTextPortion];
            nRTLLevelNextPortion = pNextTextPortion->GetRightToLeft();
        }
@@ -1082,8 +1082,8 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
            if ( nPosInLine && ( !bBeforePortion ) ) // before the next portion
                bWasBehind = sal_True;  // step one back, otherwise visual will be unusable when rtl portion follows.

            sal_uInt16 nPortionStart;
            sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nPortionStart, bBeforePortion );
            sal_Int32 nPortionStart;
            sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nPortionStart, bBeforePortion );
            const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
            sal_Bool bRTLPortion = (pTextPortion->GetRightToLeft() % 2) != 0;

@@ -1108,9 +1108,9 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
                aPaM.SetIndex( pLine->GetStart() + ubidi_getLogicalIndex( pBidi, nVisPos, &nError ) );

                // RTL portion, stay visually on the left side.
                sal_uInt16 _nPortionStart;
                sal_Int32 _nPortionStart;
                // sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nPortionStart, !bRTLPortion );
                sal_uInt16 _nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), _nPortionStart, true );
                sal_Int32 _nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), _nPortionStart, true );
                const TextPortion* _pTextPortion = pParaPortion->GetTextPortions()[_nTextPortion];
                if ( bVisualToLeft && !bRTLPortion && ( _pTextPortion->GetRightToLeft() % 2 ) )
                    aPaM.SetIndex( aPaM.GetIndex()+1 );
@@ -1200,7 +1200,7 @@ EditPaM ImpEditEngine::CursorUp( const EditPaM& rPaM, EditView* pView )

    const ParaPortion* pPPortion = FindParaPortion( rPaM.GetNode() );
    OSL_ENSURE( pPPortion, "No matching portion found: CursorUp ");
    sal_uInt16 nLine = pPPortion->GetLineNumber( rPaM.GetIndex() );
    sal_Int32 nLine = pPPortion->GetLineNumber( rPaM.GetIndex() );
    const EditLine* pLine = pPPortion->GetLines()[nLine];

    long nX;
@@ -1245,7 +1245,7 @@ EditPaM ImpEditEngine::CursorDown( const EditPaM& rPaM, EditView* pView )

    const ParaPortion* pPPortion = FindParaPortion( rPaM.GetNode() );
    OSL_ENSURE( pPPortion, "No matching portion found: CursorDown" );
    sal_uInt16 nLine = pPPortion->GetLineNumber( rPaM.GetIndex() );
    sal_Int32 nLine = pPPortion->GetLineNumber( rPaM.GetIndex() );

    long nX;
    if ( pView->pImpEditView->nTravelXPos == TRAVEL_X_DONTKNOW )
@@ -1289,7 +1289,7 @@ EditPaM ImpEditEngine::CursorStartOfLine( const EditPaM& rPaM )
{
    const ParaPortion* pCurPortion = FindParaPortion( rPaM.GetNode() );
    OSL_ENSURE( pCurPortion, "No Portion for the PaM ?" );
    sal_uInt16 nLine = pCurPortion->GetLineNumber( rPaM.GetIndex() );
    sal_Int32 nLine = pCurPortion->GetLineNumber( rPaM.GetIndex() );
    const EditLine* pLine = pCurPortion->GetLines()[nLine];
    OSL_ENSURE( pLine, "Current line not found ?!" );

@@ -1302,7 +1302,7 @@ EditPaM ImpEditEngine::CursorEndOfLine( const EditPaM& rPaM )
{
    const ParaPortion* pCurPortion = FindParaPortion( rPaM.GetNode() );
    OSL_ENSURE( pCurPortion, "No Portion for the PaM ?" );
    sal_uInt16 nLine = pCurPortion->GetLineNumber( rPaM.GetIndex() );
    sal_Int32 nLine = pCurPortion->GetLineNumber( rPaM.GetIndex() );
    const EditLine* pLine = pCurPortion->GetLines()[nLine];
    OSL_ENSURE( pLine, "Current line not found ?!" );

@@ -1612,7 +1612,7 @@ void ImpEditEngine::InitScriptTypes( sal_Int32 nPara )
                aText = aText.replaceAt( pField->GetStart(), 1, aFldText.copy(0,1) );
                short nFldScriptType = _xBI->getScriptType( aFldText, 0 );

                for ( sal_uInt16 nCharInField = 1; nCharInField < aFldText.getLength(); nCharInField++ )
                for ( sal_Int32 nCharInField = 1; nCharInField < aFldText.getLength(); nCharInField++ )
                {
                    short nTmpType = _xBI->getScriptType( aFldText, nCharInField );

@@ -1637,15 +1637,15 @@ void ImpEditEngine::InitScriptTypes( sal_Int32 nPara )
        }

        OUString aOUText( aText );
        sal_uInt16 nTextLen = (sal_uInt16)aOUText.getLength();
        sal_Int32 nTextLen = aOUText.getLength();

        sal_Int32 nPos = 0;
        short nScriptType = _xBI->getScriptType( aOUText, nPos );
        rTypes.push_back( ScriptTypePosInfo( nScriptType, (sal_uInt16)nPos, nTextLen ) );
        rTypes.push_back( ScriptTypePosInfo( nScriptType, nPos, nTextLen ) );
        nPos = _xBI->endOfScript( aOUText, nPos, nScriptType );
        while ( ( nPos != (-1) ) && ( nPos < nTextLen ) )
        {
            rTypes.back().nEndPos = (sal_uInt16)nPos;
            rTypes.back().nEndPos = nPos;

            nScriptType = _xBI->getScriptType( aOUText, nPos );
            long nEndPos = _xBI->endOfScript( aOUText, nPos, nScriptType );
@@ -1653,7 +1653,7 @@ void ImpEditEngine::InitScriptTypes( sal_Int32 nPara )
            if ( ( nScriptType == i18n::ScriptType::WEAK ) || ( nScriptType == rTypes.back().nScriptType ) )
            {
                // Expand last ScriptTypePosInfo, don't create weak or unecessary portions
                rTypes.back().nEndPos = (sal_uInt16)nEndPos;
                rTypes.back().nEndPos = nEndPos;
            }
            else
            {
@@ -1668,7 +1668,7 @@ void ImpEditEngine::InitScriptTypes( sal_Int32 nPara )
                        break;
                    }
                }
                rTypes.push_back( ScriptTypePosInfo( nScriptType, (sal_uInt16)nPos, nTextLen ) );
                rTypes.push_back( ScriptTypePosInfo( nScriptType, nPos, nTextLen ) );
            }

            nPos = nEndPos;
@@ -1685,8 +1685,8 @@ void ImpEditEngine::InitScriptTypes( sal_Int32 nPara )
        WritingDirectionInfos& rDirInfos = pParaPortion->aWritingDirectionInfos;
        for ( size_t n = 0; n < rDirInfos.size(); ++n )
        {
            const xub_StrLen nStart = rDirInfos[n].nStartPos;
            const xub_StrLen nEnd   = rDirInfos[n].nEndPos;
            const sal_Int32 nStart = rDirInfos[n].nStartPos;
            const sal_Int32 nEnd   = rDirInfos[n].nEndPos;
            const sal_uInt8 nCurrDirType = rDirInfos[n].nType;

            if ( nCurrDirType % 2 == UBIDI_RTL  || // text in RTL run
@@ -1705,14 +1705,14 @@ void ImpEditEngine::InitScriptTypes( sal_Int32 nPara )
                // special case:
                if(nIdx < rTypes.size() && rTypes[nIdx].nStartPos < nStart && rTypes[nIdx].nEndPos > nEnd)
                {
                    rTypes.insert( rTypes.begin()+nIdx, ScriptTypePosInfo( rTypes[nIdx].nScriptType, (sal_uInt16)nEnd, rTypes[nIdx].nEndPos ) );
                    rTypes.insert( rTypes.begin()+nIdx, ScriptTypePosInfo( rTypes[nIdx].nScriptType, nEnd, rTypes[nIdx].nEndPos ) );
                    rTypes[nIdx].nEndPos = nStart;
                }

                if( nIdx )
                    rTypes[nIdx - 1].nEndPos = nStart;

                rTypes.insert( rTypes.begin()+nIdx, ScriptTypePosInfo( i18n::ScriptType::COMPLEX, (sal_uInt16)nStart, (sal_uInt16)nEnd) );
                rTypes.insert( rTypes.begin()+nIdx, ScriptTypePosInfo( i18n::ScriptType::COMPLEX, nStart, nEnd) );
                ++nIdx;

                if( nIdx < rTypes.size() )
@@ -1726,7 +1726,7 @@ namespace {

struct FindByPos
{
    FindByPos(sal_uInt16 nPos):
    FindByPos(sal_Int32 nPos):
        mnPos(nPos) {}

    bool operator()(const ScriptTypePosInfos::value_type& rValue)
@@ -1735,12 +1735,12 @@ struct FindByPos
    }

private:
    sal_uInt16 mnPos;
    sal_Int32 mnPos;
};

}

sal_uInt16 ImpEditEngine::GetI18NScriptType( const EditPaM& rPaM, sal_uInt16* pEndPos ) const
sal_uInt16 ImpEditEngine::GetI18NScriptType( const EditPaM& rPaM, sal_Int32* pEndPos ) const
{
    sal_uInt16 nScriptType = 0;

@@ -1787,8 +1787,8 @@ sal_uInt16 ImpEditEngine::GetItemScriptType( const EditSelection& rSel ) const
        const ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos;

        // find all the scripts of this range
        sal_uInt16 nS = ( nPara == nStartPara ) ? aSel.Min().GetIndex() : 0;
        sal_uInt16 nE = ( nPara == nEndPara ) ? aSel.Max().GetIndex() : pParaPortion->GetNode()->Len();
        sal_Int32 nS = ( nPara == nStartPara ) ? aSel.Min().GetIndex() : 0;
        sal_Int32 nE = ( nPara == nEndPara ) ? aSel.Max().GetIndex() : pParaPortion->GetNode()->Len();

        //no selection, just bare cursor
        if (nStartPara == nEndPara && nS == nE)
@@ -1904,7 +1904,7 @@ void ImpEditEngine::InitWritingDirections( sal_Int32 nPara )
            for (int32_t nIdx = 0; nIdx < nCount; ++nIdx)
            {
                ubidi_getLogicalRun( pBidi, nStart, &nEnd, &nCurrDir );
                rInfos.push_back( WritingDirectionInfo( nCurrDir, (sal_uInt16)nStart, (sal_uInt16)nEnd ) );
                rInfos.push_back( WritingDirectionInfo( nCurrDir, nStart, nEnd ) );
                nStart = nEnd;
            }
        }
@@ -1914,7 +1914,7 @@ void ImpEditEngine::InitWritingDirections( sal_Int32 nPara )

    // No infos mean no CTL and default dir is L2R...
    if ( rInfos.empty() )
        rInfos.push_back( WritingDirectionInfo( 0, 0, (sal_uInt16)pParaPortion->GetNode()->Len() ) );
        rInfos.push_back( WritingDirectionInfo( 0, 0, pParaPortion->GetNode()->Len() ) );

}

@@ -1956,7 +1956,7 @@ sal_Bool ImpEditEngine::HasDifferentRTLLevels( const ContentNode* pNode )
    sal_Bool bHasDifferentRTLLevels = sal_False;

    sal_uInt16 nRTLLevel = IsRightToLeft( nPara ) ? 1 : 0;
    for ( sal_uInt16 n = 0; n < pParaPortion->GetTextPortions().Count(); n++ )
    for ( sal_Int32 n = 0; n < (sal_Int32)pParaPortion->GetTextPortions().Count(); n++ )
    {
        const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[n];
        if ( pTextPortion->GetRightToLeft() != nRTLLevel )
@@ -1969,7 +1969,7 @@ sal_Bool ImpEditEngine::HasDifferentRTLLevels( const ContentNode* pNode )
}


sal_uInt8 ImpEditEngine::GetRightToLeft( sal_Int32 nPara, sal_uInt16 nPos, sal_uInt16* pStart, sal_uInt16* pEnd )
sal_uInt8 ImpEditEngine::GetRightToLeft( sal_Int32 nPara, sal_Int32 nPos, sal_Int32* pStart, sal_Int32* pEnd )
{
    sal_uInt8 nRightToLeft = 0;

@@ -1984,7 +1984,7 @@ sal_uInt8 ImpEditEngine::GetRightToLeft( sal_Int32 nPara, sal_uInt16 nPos, sal_u
        for ( size_t n = 0; n < rDirInfos.size(); n++ )
        {
            if ( ( rDirInfos[n].nStartPos <= nPos ) && ( rDirInfos[n].nEndPos >= nPos ) )
               {
            {
                nRightToLeft = rDirInfos[n].nType;
                if ( pStart )
                    *pStart = rDirInfos[n].nStartPos;
@@ -2034,7 +2034,7 @@ SvxCellVerJustify ImpEditEngine::GetVerJustification( sal_Int32 nPara ) const
//  Text changes
//  ----------------------------------------------------------------------

void ImpEditEngine::ImpRemoveChars( const EditPaM& rPaM, sal_uInt16 nChars, EditUndoRemoveChars* pCurUndo )
void ImpEditEngine::ImpRemoveChars( const EditPaM& rPaM, sal_Int32 nChars, EditUndoRemoveChars* pCurUndo )
{
    if ( IsUndoEnabled() && !IsInUndo() )
    {
@@ -2109,7 +2109,7 @@ EditSelection ImpEditEngine::ImpMoveParagraphs( Range aOldPositions, sal_Int32 n
        pRecalc3 = GetParaPortions()[0];
        pRecalc4 = GetParaPortions()[aOldPositions.Max()+1];
    }
    else if ( (sal_uInt16)aOldPositions.Max() == (nParaCount-1) )
    else if ( aOldPositions.Max() == (nParaCount-1) )
    {
        pRecalc3 = GetParaPortions()[aOldPositions.Max()];
        pRecalc4 = GetParaPortions()[aOldPositions.Min()-1];
@@ -2229,9 +2229,9 @@ EditPaM ImpEditEngine::ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pR

    if ( GetStatus().DoOnlineSpelling() )
    {
        xub_StrLen nEnd = pLeft->Len();
        xub_StrLen nInv = nEnd ? nEnd-1 : nEnd;
        pLeft->GetWrongList()->ClearWrongs( nInv, 0xFFFF, pLeft );  // Possibly remove one
        sal_Int32 nEnd = pLeft->Len();
        sal_Int32 nInv = nEnd ? nEnd-1 : nEnd;
        pLeft->GetWrongList()->ClearWrongs( nInv, -1, pLeft );  // Possibly remove one
        pLeft->GetWrongList()->SetInvalidRange(nInv, nEnd+1);
        // Take over misspelled words
        WrongList* pRWrongs = pRight->GetWrongList();
@@ -2806,7 +2806,7 @@ EditPaM ImpEditEngine::ImpInsertParaBreak( EditPaM& rPaM, bool bKeepEndingAttrib

    if ( GetStatus().DoOnlineSpelling() )
    {
        xub_StrLen nEnd = rPaM.GetNode()->Len();
        sal_Int32 nEnd = rPaM.GetNode()->Len();
        aPaM.GetNode()->CreateWrongList();
        WrongList* pLWrongs = rPaM.GetNode()->GetWrongList();
        WrongList* pRWrongs = aPaM.GetNode()->GetWrongList();
@@ -2825,12 +2825,12 @@ EditPaM ImpEditEngine::ImpInsertParaBreak( EditPaM& rPaM, bool bKeepEndingAttrib
            else if (i->mnStart < nEnd && i->mnEnd > nEnd)
                i->mnEnd = nEnd;
        }
        sal_uInt16 nInv = nEnd ? nEnd-1 : nEnd;
        sal_Int32 nInv = nEnd ? nEnd-1 : nEnd;
        if ( nEnd )
            pLWrongs->SetInvalidRange(nInv, nEnd);
        else
            pLWrongs->SetValid();
        pRWrongs->SetValid(); // otherwise 0 - 0xFFFF
        pRWrongs->SetValid();
        pRWrongs->SetInvalidRange(0, 1);  // Only test the first word
    }

@@ -3072,8 +3072,8 @@ sal_uInt32 ImpEditEngine::CalcTextWidth( sal_Bool bIgnoreExtraSpace )
            // --------------------------------------------------
            // On the lines of the paragraph ...
            // --------------------------------------------------
            sal_uLong nLines = pPortion->GetLines().Count();
            for ( sal_uInt16 nLine = 0; nLine < nLines; nLine++ )
            sal_Int32 nLines = (sal_Int32)pPortion->GetLines().Count();
            for ( sal_Int32 nLine = 0; nLine < nLines; nLine++ )
            {
                pLine = pPortion->GetLines()[nLine];
                OSL_ENSURE( pLine, "NULL-Pointer in the line iterator in CalcWidth" );
@@ -3118,14 +3118,14 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine,
    // potentially changing both)
    GetRefDevice()->Push( PUSH_TEXTLAYOUTMODE|PUSH_TEXTLANGUAGE );

    ImplInitLayoutMode( GetRefDevice(), nPara, 0xFFFF );
    ImplInitLayoutMode( GetRefDevice(), nPara, -1 );

    SvxAdjust eJustification = GetJustification( nPara );

    // Calculation of the width without the Indents ...
    sal_uInt32 nWidth = 0;
    sal_uInt16 nPos = pLine->GetStart();
    for ( sal_uInt16 nTP = pLine->GetStartPortion(); nTP <= pLine->GetEndPortion(); nTP++ )
    sal_Int32 nPos = pLine->GetStart();
    for ( sal_Int32 nTP = pLine->GetStartPortion(); nTP <= pLine->GetEndPortion(); nTP++ )
    {
        const TextPortion* pTextPortion = pPortion->GetTextPortions()[nTP];
        switch ( pTextPortion->GetKind() )
@@ -3193,7 +3193,7 @@ sal_uInt32 ImpEditEngine::CalcTextHeight( sal_uInt32* pHeightNTP )
    return nY;
}

sal_uInt16 ImpEditEngine::GetLineCount( sal_Int32 nParagraph ) const
sal_Int32 ImpEditEngine::GetLineCount( sal_Int32 nParagraph ) const
{
    OSL_ENSURE( 0 <= nParagraph && nParagraph < GetParaPortions().Count(), "GetLineCount: Out of range" );
    const ParaPortion* pPPortion = GetParaPortions().SafeGetObject( nParagraph );
@@ -3201,10 +3201,10 @@ sal_uInt16 ImpEditEngine::GetLineCount( sal_Int32 nParagraph ) const
    if ( pPPortion )
        return pPPortion->GetLines().Count();

    return 0xFFFF;
    return -1;
}

xub_StrLen ImpEditEngine::GetLineLen( sal_Int32 nParagraph, sal_uInt16 nLine ) const
sal_Int32 ImpEditEngine::GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const
{
    OSL_ENSURE( 0 <= nParagraph && nParagraph < GetParaPortions().Count(), "GetLineLen: Out of range" );
    const ParaPortion* pPPortion = GetParaPortions().SafeGetObject( nParagraph );
@@ -3216,15 +3216,15 @@ xub_StrLen ImpEditEngine::GetLineLen( sal_Int32 nParagraph, sal_uInt16 nLine ) c
        return pLine->GetLen();
    }

    return 0xFFFF;
    return -1;
}

void ImpEditEngine::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nParagraph, sal_uInt16 nLine ) const
void ImpEditEngine::GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const
{
    OSL_ENSURE( 0 <= nParagraph && nParagraph < GetParaPortions().Count(), "GetLineCount: Out of range" );
    const ParaPortion* pPPortion = GetParaPortions().SafeGetObject( nParagraph );
    OSL_ENSURE( pPPortion, "Paragraph not found: GetLineBoundaries" );
    rStart = rEnd = 0xFFFF;     // default values in case of error
    rStart = rEnd = -1;     // default values in case of error
    if ( pPPortion && ( nLine < pPPortion->GetLines().Count() ) )
    {
        const EditLine* pLine = pPPortion->GetLines()[nLine];
@@ -3234,9 +3234,9 @@ void ImpEditEngine::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uIn
    }
}

sal_uInt16 ImpEditEngine::GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nIndex ) const
sal_Int32 ImpEditEngine::GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const
{
    sal_uInt16 nLineNo = 0xFFFF;
    sal_Int32 nLineNo = -1;
    const ContentNode* pNode = GetEditDoc().GetObject( nPara );
    OSL_ENSURE( pNode, "GetLineNumberAtIndex: invalid paragraph index" );
    if (pNode)
@@ -3244,16 +3244,16 @@ sal_uInt16 ImpEditEngine::GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nInd
        // we explicitly allow for the index to point at the character right behind the text
        const bool bValidIndex = /*0 <= nIndex &&*/ nIndex <= pNode->Len();
        OSL_ENSURE( bValidIndex, "GetLineNumberAtIndex: invalid index" );
        const sal_uInt16 nLineCount = GetLineCount( nPara );
        const sal_Int32 nLineCount = GetLineCount( nPara );
        if (nIndex == pNode->Len())
            nLineNo = nLineCount > 0 ? nLineCount - 1 : 0;
        else if (bValidIndex)   // nIndex < pNode->Len()
        {
            sal_uInt16 nStart = USHRT_MAX, nEnd = USHRT_MAX;
            for (sal_uInt16 i = 0;  i < nLineCount && nLineNo == 0xFFFF;  ++i)
            sal_Int32 nStart = -1, nEnd = -1;
            for (sal_Int32 i = 0;  i < nLineCount && nLineNo == -1;  ++i)
            {
                GetLineBoundaries( nStart, nEnd, nPara, i );
                if (nStart <= nIndex && nIndex < nEnd)
                if (nStart >= 0 && nStart <= nIndex && nEnd >= 0 && nIndex < nEnd)
                    nLineNo = i;
            }
        }
@@ -3261,7 +3261,7 @@ sal_uInt16 ImpEditEngine::GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nInd
    return nLineNo;
}

sal_uInt16 ImpEditEngine::GetLineHeight( sal_Int32 nParagraph, sal_uInt16 nLine )
sal_uInt16 ImpEditEngine::GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine )
{
    OSL_ENSURE( 0 <= nParagraph && nParagraph < GetParaPortions().Count(), "GetLineCount: Out of range" );
    ParaPortion* pPPortion = GetParaPortions().SafeGetObject( nParagraph );
@@ -3354,13 +3354,13 @@ void ImpEditEngine::UpdateSelections()
}

EditSelection ImpEditEngine::ConvertSelection(
    sal_Int32 nStartPara, sal_uInt16 nStartPos, sal_Int32 nEndPara, sal_uInt16 nEndPos )
    sal_Int32 nStartPara, sal_Int32 nStartPos, sal_Int32 nEndPara, sal_Int32 nEndPos )
{
    EditSelection aNewSelection;

    // Start...
    ContentNode* pNode = aEditDoc.GetObject( nStartPara );
    sal_uInt16 nIndex = nStartPos;
    sal_Int32 nIndex = nStartPos;
    if ( !pNode )
    {
        pNode = aEditDoc[ aEditDoc.Count()-1 ];
@@ -3558,8 +3558,8 @@ Range ImpEditEngine::GetInvalidYOffsets( ParaPortion* pPortion )
                            ? GetYValue( rLSItem.GetInterLineSpace() ) : 0;

        // only from the top ...
        sal_uInt16 nFirstInvalid = 0xFFFF;
        sal_uInt16 nLine;
        sal_Int32 nFirstInvalid = -1;
        sal_Int32 nLine;
        for ( nLine = 0; nLine < pPortion->GetLines().Count(); nLine++ )
        {
            const EditLine* pL = pPortion->GetLines()[nLine];
@@ -3572,42 +3572,44 @@ Range ImpEditEngine::GetInvalidYOffsets( ParaPortion* pPortion )
                aRange.Min() += nSBL;
            aRange.Min() += pL->GetHeight();
        }
        OSL_ENSURE( nFirstInvalid != 0xFFFF, "No invalid line found in GetInvalidYOffset(1)" );
        OSL_ENSURE( nFirstInvalid != -1, "No invalid line found in GetInvalidYOffset(1)" );


        // Syndicate and more ...
        aRange.Max() = aRange.Min();
        aRange.Max() += pPortion->GetFirstLineOffset();
        if ( nFirstInvalid != 0 )   // Only if the first line is invalid
        if ( nFirstInvalid > 0 )   // Only if the first line is invalid
            aRange.Min() = aRange.Max();

        sal_uInt16 nLastInvalid = pPortion->GetLines().Count()-1;
        for ( nLine = nFirstInvalid; nLine < pPortion->GetLines().Count(); nLine++ )
        sal_Int32 nLastInvalid = pPortion->GetLines().Count()-1;
        if(nFirstInvalid > 0)
        {
            const EditLine* pL = pPortion->GetLines()[nLine];
            if ( pL->IsValid() )
            for ( nLine = nFirstInvalid; nLine < pPortion->GetLines().Count(); nLine++ )
            {
                nLastInvalid = nLine;
                break;
                const EditLine* pL = pPortion->GetLines()[nLine];
                if ( pL->IsValid() )
                {
                    nLastInvalid = nLine;
                    break;
                }
                if ( nLine && !aStatus.IsOutliner() )
                    aRange.Max() += nSBL;
                aRange.Max() += pL->GetHeight();
            }

            if ( nLine && !aStatus.IsOutliner() )
                aRange.Max() += nSBL;
            aRange.Max() += pL->GetHeight();
        }
            if( ( rLSItem.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP ) && rLSItem.GetPropLineSpace() &&
                ( rLSItem.GetPropLineSpace() < 100 ) )
            {
                const EditLine* pL = pPortion->GetLines()[nFirstInvalid];
                long n = pL->GetTxtHeight() * ( 100 - rLSItem.GetPropLineSpace() );
                n /= 100;
                aRange.Min() -= n;
                aRange.Max() += n;
            }

        if( ( rLSItem.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP ) && rLSItem.GetPropLineSpace() &&
            ( rLSItem.GetPropLineSpace() < 100 ) )
        {
            const EditLine* pL = pPortion->GetLines()[nFirstInvalid];
            long n = pL->GetTxtHeight() * ( 100 - rLSItem.GetPropLineSpace() );
            n /= 100;
            aRange.Min() -= n;
            aRange.Max() += n;
            if ( ( nLastInvalid == pPortion->GetLines().Count()-1 ) && ( !aStatus.IsOutliner() ) )
                aRange.Max() += GetYValue( rULSpace.GetLower() );
        }

        if ( ( nLastInvalid == pPortion->GetLines().Count()-1 ) && ( !aStatus.IsOutliner() ) )
            aRange.Max() += GetYValue( rULSpace.GetLower() );
    }
    return aRange;
}
@@ -3617,7 +3619,7 @@ EditPaM ImpEditEngine::GetPaM( ParaPortion* pPortion, Point aDocPos, sal_Bool bS
    OSL_ENSURE( pPortion->IsVisible(), "Why GetPaM() for an invisible paragraph?" );
    OSL_ENSURE( IsFormatted(), "GetPaM: Not formatted" );

    sal_uInt16 nCurIndex = 0;
    sal_Int32 nCurIndex = 0;
    EditPaM aPaM;
    aPaM.SetNode( pPortion->GetNode() );

@@ -3630,7 +3632,7 @@ EditPaM ImpEditEngine::GetPaM( ParaPortion* pPortion, Point aDocPos, sal_Bool bS
    OSL_ENSURE( pPortion->GetLines().Count(), "Empty ParaPortion in GetPaM!" );

    const EditLine* pLine = NULL;
    for ( sal_uInt16 nLine = 0; nLine < pPortion->GetLines().Count(); nLine++ )
    for ( sal_Int32 nLine = 0; nLine < pPortion->GetLines().Count(); nLine++ )
    {
        const EditLine* pTmpLine = pPortion->GetLines()[nLine];
        nY += pTmpLine->GetHeight();
@@ -3668,17 +3670,17 @@ EditPaM ImpEditEngine::GetPaM( ParaPortion* pPortion, Point aDocPos, sal_Bool bS
    return aPaM;
}

sal_uInt16 ImpEditEngine::GetChar(
sal_Int32 ImpEditEngine::GetChar(
    const ParaPortion* pParaPortion, const EditLine* pLine, long nXPos, bool bSmart)
{
    OSL_ENSURE( pLine, "No line received: GetChar" );

    sal_uInt16 nChar = 0xFFFF;
    sal_uInt16 nCurIndex = pLine->GetStart();
    sal_Int32 nChar = -1;
    sal_Int32 nCurIndex = pLine->GetStart();


    // Search best matching portion with GetPortionXOffset()
    for ( sal_uInt16 i = pLine->GetStartPortion(); i <= pLine->GetEndPortion(); i++ )
    for ( sal_Int32 i = pLine->GetStartPortion(); i <= pLine->GetEndPortion(); i++ )
    {
        const TextPortion* pPortion = pParaPortion->GetTextPortions()[i];
        long nXLeft = GetPortionXOffset( pParaPortion, pLine, i );
@@ -3703,16 +3705,16 @@ sal_uInt16 ImpEditEngine::GetChar(
            }
            else
            {
                sal_uInt16 nMax = pPortion->GetLen();
                sal_uInt16 nOffset = 0xFFFF;
                sal_uInt16 nTmpCurIndex = nChar - pLine->GetStart();
                sal_Int32 nMax = pPortion->GetLen();
                sal_Int32 nOffset = -1;
                sal_Int32 nTmpCurIndex = nChar - pLine->GetStart();

                long nXInPortion = nXPos - nXLeft;
                if ( pPortion->IsRightToLeft() )
                    nXInPortion = nXRight - nXPos;

                // Search in Array...
                for ( sal_uInt16 x = 0; x < nMax; x++ )
                for ( sal_Int32 x = 0; x < nMax; x++ )
                {
                    long nTmpPosMax = pLine->GetCharPosArray()[nTmpCurIndex+x];
                    if ( nTmpPosMax > nXInPortion )
@@ -3740,7 +3742,7 @@ sal_uInt16 ImpEditEngine::GetChar(
                // There should not be any inaccuracies when using the
                // CharPosArray! Maybe for kerning?
                // 0xFFF happens for example for Outline-Font when at the very end.
                if ( nOffset == 0xFFFF )
                if ( nOffset < 0 )
                    nOffset = nMax;

                OSL_ENSURE( nOffset <= nMax, "nOffset > nMax" );
@@ -3757,9 +3759,9 @@ sal_uInt16 ImpEditEngine::GetChar(
                        uno::Reference < i18n::XBreakIterator > _xBI( ImplGetBreakIterator() );
                        sal_Int32 nCount = 1;
                        lang::Locale aLocale = GetLocale( aPaM );
                        sal_uInt16 nRight = (sal_uInt16)_xBI->nextCharacters(
                        sal_Int32 nRight = _xBI->nextCharacters(
                            pParaPortion->GetNode()->GetString(), nChar, aLocale, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, nCount, nCount );
                        sal_uInt16 nLeft = (sal_uInt16)_xBI->previousCharacters(
                        sal_Int32 nLeft = _xBI->previousCharacters(
                            pParaPortion->GetNode()->GetString(), nRight, aLocale, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, nCount, nCount );
                        if ( ( nLeft != nChar ) && ( nRight != nChar ) )
                        {
@@ -3773,7 +3775,7 @@ sal_uInt16 ImpEditEngine::GetChar(
        nCurIndex = nCurIndex + pPortion->GetLen();
    }

    if ( nChar == 0xFFFF )
    if ( nChar == -1 )
    {
        nChar = ( nXPos <= pLine->GetStartPosX() ) ? pLine->GetStart() : pLine->GetEnd();
    }
@@ -3802,11 +3804,11 @@ Range ImpEditEngine::GetLineXPosStartEnd( const ParaPortion* pParaPortion, const
}

long ImpEditEngine::GetPortionXOffset(
    const ParaPortion* pParaPortion, const EditLine* pLine, sal_uInt16 nTextPortion) const
    const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nTextPortion) const
{
    long nX = pLine->GetStartPosX();

    for ( sal_uInt16 i = pLine->GetStartPortion(); i < nTextPortion; i++ )
    for ( sal_Int32 i = pLine->GetStartPortion(); i < nTextPortion; i++ )
    {
        const TextPortion* pPortion = pParaPortion->GetTextPortions()[i];
        switch ( pPortion->GetKind() )
@@ -3831,7 +3833,7 @@ long ImpEditEngine::GetPortionXOffset(
        if ( !bR2LPara && pDestPortion->GetRightToLeft() )
        {
            // Portions behind must be added, visual before this portion
            sal_uInt16 nTmpPortion = nTextPortion+1;
            sal_Int32 nTmpPortion = nTextPortion+1;
            while ( nTmpPortion <= pLine->GetEndPortion() )
            {
                const TextPortion* pNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
@@ -3856,7 +3858,7 @@ long ImpEditEngine::GetPortionXOffset(
        else if ( bR2LPara && !pDestPortion->IsRightToLeft() )
        {
            // Portions behind must be removed, visual behind this portion
            sal_uInt16 nTmpPortion = nTextPortion+1;
            sal_Int32 nTmpPortion = nTextPortion+1;
            while ( nTmpPortion <= pLine->GetEndPortion() )
            {
                const TextPortion* pNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
@@ -3892,7 +3894,7 @@ long ImpEditEngine::GetPortionXOffset(
}

long ImpEditEngine::GetXPos(
    const ParaPortion* pParaPortion, const EditLine* pLine, sal_uInt16 nIndex, bool bPreferPortionStart) const
    const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nIndex, bool bPreferPortionStart) const
{
    OSL_ENSURE( pLine, "No line received: GetXPos" );
    OSL_ENSURE( ( nIndex >= pLine->GetStart() ) && ( nIndex <= pLine->GetEnd() ) , "GetXPos has to be called properly!" );
@@ -3904,8 +3906,8 @@ long ImpEditEngine::GetXPos(
    else if ( nIndex == pLine->GetEnd() )
        bDoPreferPortionStart = sal_False;

    sal_uInt16 nTextPortionStart = 0;
    sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( nIndex, nTextPortionStart, bDoPreferPortionStart );
    sal_Int32 nTextPortionStart = 0;
    sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( nIndex, nTextPortionStart, bDoPreferPortionStart );

    OSL_ENSURE( ( nTextPortion >= pLine->GetStartPortion() ) && ( nTextPortion <= pLine->GetEndPortion() ), "GetXPos: Portion not in current line! " );

@@ -3927,7 +3929,7 @@ long ImpEditEngine::GetXPos(
            // End of Portion
            if ( pPortion->GetKind() == PORTIONKIND_TAB )
            {
                if ( static_cast<size_t>(nTextPortion+1) < pParaPortion->GetTextPortions().Count() )
                if ( nTextPortion+1 < pParaPortion->GetTextPortions().Count() )
                {
                    const TextPortion* pNextPortion = pParaPortion->GetTextPortions()[nTextPortion+1];
                    if ( pNextPortion->GetKind() != PORTIONKIND_TAB )
@@ -3955,8 +3957,8 @@ long ImpEditEngine::GetXPos(

            if( pLine->GetCharPosArray().size() )
            {
                sal_uInt16 nPos = nIndex - 1 - pLine->GetStart();
                if( nPos >= pLine->GetCharPosArray().size() )
                sal_Int32 nPos = nIndex - 1 - pLine->GetStart();
                if( nPos >= (sal_Int32)pLine->GetCharPosArray().size() )
                {
                    nPos = pLine->GetCharPosArray().size()-1;
                    OSL_FAIL("svx::ImpEditEngine::GetXPos(), index out of range!");
@@ -3982,7 +3984,7 @@ long ImpEditEngine::GetXPos(
                        sal_uInt8 nType = GetCharTypeForCompression( pParaPortion->GetNode()->GetChar( nIndex ) );
                        if ( nType == CHAR_PUNCTUATIONRIGHT )
                        {
                            sal_uInt16 n = nIndex - nTextPortionStart;
                            sal_Int32 n = nIndex - nTextPortionStart;
                            const sal_Int32* pDXArray = NULL;
                            if (!pLine->GetCharPosArray().empty())
                                pDXArray = &pLine->GetCharPosArray()[0]+( nTextPortionStart-pLine->GetStart() );
@@ -4032,7 +4034,7 @@ void ImpEditEngine::CalcHeight( ParaPortion* pPortion )
    if ( pPortion->IsVisible() )
    {
        OSL_ENSURE( pPortion->GetLines().Count(), "Paragraph with no lines in ParaPortion::CalcHeight" );
        for (size_t nLine = 0; nLine < pPortion->GetLines().Count(); ++nLine)
        for (sal_Int32 nLine = 0; nLine < pPortion->GetLines().Count(); ++nLine)
            pPortion->nHeight += pPortion->GetLines()[nLine]->GetHeight();

        if ( !aStatus.IsOutliner() )
@@ -4122,7 +4124,7 @@ void ImpEditEngine::CalcHeight( ParaPortion* pPortion )
    }
}

Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_uInt16 nIndex, sal_uInt16 nFlags )
Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex, sal_uInt16 nFlags )
{
    OSL_ENSURE( pPortion->IsVisible(), "Why GetEditCursor() for an invisible paragraph?" );
    OSL_ENSURE( IsFormatted() || GetTextRanger(), "GetEditCursor: Not formatted" );
@@ -4140,14 +4142,14 @@ Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_uInt16 nIndex
    sal_uInt16 nSBL = ( rLSItem.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_FIX )
                        ? GetYValue( rLSItem.GetInterLineSpace() ) : 0;

    sal_uInt16 nCurIndex = 0;
    size_t nLineCount = pPortion->GetLines().Count();
    sal_Int32 nCurIndex = 0;
    sal_Int32 nLineCount = pPortion->GetLines().Count();
    OSL_ENSURE( nLineCount, "Empty ParaPortion in GetEditCursor!" );
    if (nLineCount == 0)
        return Rectangle();
    const EditLine* pLine = NULL;
    sal_Bool bEOL = ( nFlags & GETCRSR_ENDOFLINE ) ? sal_True : sal_False;
    for (size_t nLine = 0; nLine < nLineCount; ++nLine)
    for (sal_Int32 nLine = 0; nLine < nLineCount; ++nLine)
    {
        const EditLine* pTmpLine = pPortion->GetLines()[nLine];
        if ( ( pTmpLine->GetStart() == nIndex ) || ( pTmpLine->IsIn( nIndex, bEOL ) ) )
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index c16adb7..aa9727b 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -90,8 +90,8 @@ struct TabInfo
    bool        bValid;

    SvxTabStop  aTabStop;
    xub_StrLen  nCharPos;
    sal_uInt16      nTabPortion;
    sal_Int32   nCharPos;
    sal_Int32   nTabPortion;
    long        nStartPosX;
    long        nTabPos;

@@ -148,8 +148,8 @@ static void lcl_DrawRedLines(
    OutputDevice* pOutDev,
    long nFontHeight,
    const Point& rPnt,
    sal_uInt16 nIndex,
    sal_uInt16 nMaxEnd,
    sal_Int32 nIndex,
    sal_Int32 nMaxEnd,
    const sal_Int32* pDXArray,
    WrongList* pWrongs,
    short nOrientation,
@@ -169,7 +169,7 @@ static void lcl_DrawRedLines(
        else
            nStyle = WAVE_FLAT;

        size_t nEnd, nStart = nIndex;
        sal_Int32 nEnd, nStart = nIndex;
        bool bWrong = pWrongs->NextWrong( nStart, nEnd );
        while ( bWrong )
        {
@@ -630,8 +630,8 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
    const sal_Bool bScriptSpace = ((const SvxScriptSpaceItem&) pNode->GetContentAttribs().GetItem( EE_PARA_ASIANCJKSPACING )).GetValue();

    const short nInvalidDiff = pParaPortion->GetInvalidDiff();
    const sal_uInt16 nInvalidStart = pParaPortion->GetInvalidPosStart();
    const sal_uInt16 nInvalidEnd =  nInvalidStart + std::abs( nInvalidDiff );
    const sal_Int32 nInvalidStart = pParaPortion->GetInvalidPosStart();
    const sal_Int32 nInvalidEnd =  nInvalidStart + std::abs( nInvalidDiff );

    bool bQuickFormat = false;
    if ( !bEmptyNodeWithPolygon && !HasScriptType( nPara, i18n::ScriptType::COMPLEX ) )
@@ -644,12 +644,12 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
        else if ( ( pParaPortion->IsSimpleInvalid() ) && ( nInvalidDiff < 0 ) )
        {
            // check if delete over the portion boundaries was done ...
            sal_uInt16 nStart = nInvalidStart;  // DOUBLE !!!!!!!!!!!!!!!
            sal_uInt16 nEnd = nStart - nInvalidDiff;  // negative
            sal_Int32 nStart = nInvalidStart;  // DOUBLE !!!!!!!!!!!!!!!
            sal_Int32 nEnd = nStart - nInvalidDiff;  // negative
            bQuickFormat = true;
            sal_uInt16 nPos = 0;
            sal_uInt16 nPortions = pParaPortion->GetTextPortions().Count();
            for ( sal_uInt16 nTP = 0; nTP < nPortions; nTP++ )
            sal_Int32 nPos = 0;
            sal_Int32 nPortions = pParaPortion->GetTextPortions().Count();
            for ( sal_Int32 nTP = 0; nTP < nPortions; nTP++ )
            {
                // There must be no start / end in the deleted area.
                TextPortion* const pTP = pParaPortion->GetTextPortions()[ nTP ];
@@ -668,9 +668,9 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
    // Saving both layout mode and language (since I'm potentially changing both)
    GetRefDevice()->Push( PUSH_TEXTLAYOUTMODE|PUSH_TEXTLANGUAGE );

    ImplInitLayoutMode( GetRefDevice(), nPara, 0xFFFF );
    ImplInitLayoutMode( GetRefDevice(), nPara, -1 );

    sal_uInt16 nRealInvalidStart = nInvalidStart;
    sal_Int32 nRealInvalidStart = nInvalidStart;

    if ( bEmptyNodeWithPolygon )
    {
@@ -694,8 +694,8 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
    // Flag the line => do not remove it !
    // ---------------------------------------------------------------

    sal_uInt16 nLine = pParaPortion->GetLines().Count()-1;
    for ( sal_uInt16 nL = 0; nL <= nLine; nL++ )
    sal_Int32 nLine = pParaPortion->GetLines().Count()-1;
    for ( sal_Int32 nL = 0; nL <= nLine; nL++ )
    {
        EditLine* pLine = pParaPortion->GetLines()[nL];
        if ( pLine->GetEnd() > nRealInvalidStart )  // not nInvalidStart!
@@ -726,10 +726,10 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
    // ---------------------------------------------------------------
    // Reformat all lines from here ...
    // ---------------------------------------------------------------
    sal_uInt16 nDelFromLine = 0xFFFF;
    sal_Int32 nDelFromLine = -1;
    bool bLineBreak = false;

    sal_uInt16 nIndex = pLine->GetStart();
    sal_Int32 nIndex = pLine->GetStart();
    EditLine aSaveLine( *pLine );
    SvxFont aTmpFont( pNode->GetCharAttribs().GetDefFont() );

@@ -748,8 +748,8 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )

        bool bEOL = false;
        bool bEOC = false;
        sal_uInt16 nPortionStart = 0;
        sal_uInt16 nPortionEnd = 0;
        sal_Int32 nPortionStart = 0;
        sal_Int32 nPortionEnd = 0;

        long nStartX = GetXValue( rLRItem.GetTxtLeft() + nSpaceBeforeAndMinLabelWidth );
        if ( nIndex == 0 )
@@ -790,8 +790,8 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
        if ( bCalcCharPositions )
            pLine->GetCharPosArray().clear();

        sal_uInt16 nTmpPos = nIndex;
        sal_uInt16 nTmpPortion = pLine->GetStartPortion();
        sal_Int32 nTmpPos = nIndex;
        sal_Int32 nTmpPortion = pLine->GetStartPortion();
        long nTmpWidth = 0;
        long nXWidth = nMaxLineWidth;
        if ( nXWidth <= nTmpWidth ) // while has to be looped once
@@ -845,9 +845,8 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
                // is the first one. Best with gaps.
                if ( pTextRanges->size() )
                {
                    sal_uInt16 n = 0;
                    long nA = pTextRanges->at(n++);
                    long nB = pTextRanges->at(n++);
                    long nA = pTextRanges->at(0);
                    long nB = pTextRanges->at(0);
                    DBG_ASSERT( nA <= nB, "TextRange distorted?" );
                    long nW = nB - nA;
                    if ( nW > nMaxRangeWidth )
@@ -887,7 +886,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
            {
                // Throw away a Portion, if necessary correct the one before,
                // if the Hyph portion has swallowed a character ...
                sal_uInt16 nTmpLen = pPortion->GetLen();
                sal_Int32 nTmpLen = pPortion->GetLen();
                pParaPortion->GetTextPortions().Remove( nTmpPortion );
                if (nTmpPortion && nTmpLen)
                {
@@ -1069,7 +1068,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
                }
                if ( bCalcCharPositions )
                {
                    sal_uInt16 nLen = pPortion->GetLen();
                    sal_Int32 nLen = pPortion->GetLen();
                    // The array is  generally flattened at the beginning
                    // => Always simply quick inserts.
                    size_t nPos = nTmpPos - pLine->GetStart();
@@ -1090,7 +1089,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )

                pPortion->SetRightToLeft( GetRightToLeft( nPara, nTmpPos+1 ) );

                sal_uInt16 _nPortionEnd = nTmpPos + pPortion->GetLen();
                sal_Int32 _nPortionEnd = nTmpPos + pPortion->GetLen();
                if( bScriptSpace && ( _nPortionEnd < pNode->Len() ) && ( nTmpWidth < nXWidth ) && IsScriptChange( EditPaM( pNode, _nPortionEnd ) ) )
                {
                    bool bAllow = false;
@@ -1113,7 +1112,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
            if ( aCurrentTab.bValid && ( nTmpPortion != aCurrentTab.nTabPortion ) )
            {
                long nWidthAfterTab = 0;
                for ( sal_uInt16 n = aCurrentTab.nTabPortion+1; n <= nTmpPortion; n++  )
                for ( sal_Int32 n = aCurrentTab.nTabPortion+1; n <= nTmpPortion; n++  )
                {
                    const TextPortion* pTP = pParaPortion->GetTextPortions()[n];
                    nWidthAfterTab += pTP->GetSize().Width();
@@ -1186,7 +1185,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
            {
                DBG_ASSERT( pPortion->GetKind() == PORTIONKIND_TEXT, "Len>1, but no TextPortion?" );
                nTmpWidth -= pPortion->GetSize().Width();
                sal_uInt16 nP = SplitTextPortion( pParaPortion, nTmpPos, pLine );
                sal_Int32 nP = SplitTextPortion( pParaPortion, nTmpPos, pLine );
                const TextPortion* p = pParaPortion->GetTextPortions()[nP];
                DBG_ASSERT( p, "Portion ?!" );
                nTmpWidth += p->GetSize().Width();
@@ -1230,7 +1229,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
            bEOC = true;
            pLine->SetEnd( nPortionEnd );
            DBG_ASSERT( pParaPortion->GetTextPortions().Count(), "No TextPortions?" );
            pLine->SetEndPortion( (sal_uInt16)pParaPortion->GetTextPortions().Count() - 1 );
            pLine->SetEndPortion( pParaPortion->GetTextPortions().Count() - 1 );
        }

        if ( aStatus.OneCharPerLine() )
@@ -1292,8 +1291,8 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
        // set anyway, because a large font only after wrapping suddenly ends
        // up in the next line => Font metrics too big.
        FormatterFontMetric aFormatterMetrics;
        sal_uInt16 nTPos = pLine->GetStart();
        for ( sal_uInt16 nP = pLine->GetStartPortion(); nP <= pLine->GetEndPortion(); nP++ )
        sal_Int32 nTPos = pLine->GetStart();
        for ( sal_Int32 nP = pLine->GetStartPortion(); nP <= pLine->GetEndPortion(); nP++ )
        {
            const TextPortion* pTP = pParaPortion->GetTextPortions()[nP];
            // problem with hard font height attribute, when everthing but the line break has this attribute
@@ -1392,7 +1391,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
            // check for rel width now, maybe create compression...
            long n = nMaxLineWidth - aTextSize.Width();
            TextPortion* const pTP = pParaPortion->GetTextPortions()[pLine->GetEndPortion()];
            sal_uInt16 nPosInArray = pLine->GetEnd()-1-pLine->GetStart();
            sal_Int32 nPosInArray = pLine->GetEnd()-1-pLine->GetStart();
            long nNewValue = ( nPosInArray ? pLine->GetCharPosArray()[ nPosInArray-1 ] : 0 ) + n;
            pLine->GetCharPosArray()[ nPosInArray ] = nNewValue;
            pTP->GetSize().Width() += n;
@@ -1475,8 +1474,8 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
            }
            else
            {
                sal_uInt16 nStart = pLine->GetStart();
                sal_uInt16 nEnd = pLine->GetEnd();
                sal_Int32 nStart = pLine->GetStart();
                sal_Int32 nEnd = pLine->GetEnd();

                if ( nStart > nInvalidEnd )
                {
@@ -1514,7 +1513,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
            nIndex = pLine->GetEnd();   // next line start = last line end
                                        // as nEnd points to the last character!

            sal_uInt16 nEndPortion = pLine->GetEndPortion();
            sal_Int32 nEndPortion = pLine->GetEndPortion();

            // Next line or maybe a new line....
            pLine = 0;
@@ -1555,7 +1554,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
        }
    }   // while ( Index < Len )

    if ( nDelFromLine != 0xFFFF )
    if ( nDelFromLine >= 0 )
        pParaPortion->GetLines().DeleteFromLine( nDelFromLine );

    DBG_ASSERT( pParaPortion->GetLines().Count(), "No line after CreateLines!" );
@@ -1712,7 +1711,7 @@ void ImpEditEngine::CreateAndInsertEmptyLine( ParaPortion* pParaPortion, sal_uIn
        DBG_ASSERT( pLastLine, "soft wrap no line?!" );
        DBG_ASSERT( pLastLine->GetEnd() == pParaPortion->GetNode()->Len(), "different anyway?" );
#endif
        sal_uInt16 nPos = (sal_uInt16) pParaPortion->GetTextPortions().Count() - 1 ;
        sal_Int32 nPos = pParaPortion->GetTextPortions().Count() - 1 ;
        pTmpLine->SetStartPortion( nPos );
        pTmpLine->SetEndPortion( nPos );
    }
@@ -1730,17 +1729,17 @@ sal_Bool ImpEditEngine::FinishCreateLines( ParaPortion* pParaPortion )
    return bRet;
}

void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, TextPortion* pPortion, sal_uInt16 nPortionStart, long nRemainingWidth, sal_Bool bCanHyphenate )
void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, TextPortion* pPortion, sal_Int32 nPortionStart, long nRemainingWidth, sal_Bool bCanHyphenate )
{
    ContentNode* const pNode = pParaPortion->GetNode();

    sal_uInt16 nBreakInLine = nPortionStart - pLine->GetStart();
    sal_uInt16 nMax = nBreakInLine + pPortion->GetLen();
    sal_Int32 nBreakInLine = nPortionStart - pLine->GetStart();
    sal_Int32 nMax = nBreakInLine + pPortion->GetLen();
    while ( ( nBreakInLine < nMax ) && ( pLine->GetCharPosArray()[nBreakInLine] < nRemainingWidth ) )
        nBreakInLine++;

    sal_uInt16 nMaxBreakPos = nBreakInLine + pLine->GetStart();
       sal_uInt16 nBreakPos = 0xFFFF;
    sal_Int32 nMaxBreakPos = nBreakInLine + pLine->GetStart();
    sal_Int32 nBreakPos = SAL_MAX_INT32;

    sal_Bool bCompressBlank = sal_False;
    sal_Bool bHyphenated = sal_False;
@@ -1759,7 +1758,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te
    }
    else
    {
        sal_uInt16 nMinBreakPos = pLine->GetStart();
        sal_Int32 nMinBreakPos = pLine->GetStart();
        const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
        for (size_t nAttr = rAttrs.size(); nAttr; )
        {
@@ -1789,7 +1788,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te

        i18n::LineBreakResults aLBR = _xBI->getLineBreak(
            pNode->GetString(), nMaxBreakPos, aLocale, nMinBreakPos, aHyphOptions, aUserOptions );
        nBreakPos = (sal_uInt16)aLBR.breakIndex;
        nBreakPos = aLBR.breakIndex;

        // BUG in I18N - under special condition (break behind field, #87327#) breakIndex is < nMinBreakPos
        if ( nBreakPos < nMinBreakPos )
@@ -1827,23 +1826,23 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te
        {
            i18n::Boundary aBoundary = _xBI->getWordBoundary(
                pNode->GetString(), nBreakPos, GetLocale( EditPaM( pNode, nBreakPos ) ), ::com::sun::star::i18n::WordType::DICTIONARY_WORD, true);
            sal_uInt16 nWordStart = nBreakPos;
            sal_uInt16 nWordEnd = (sal_uInt16) aBoundary.endPos;
            sal_Int32 nWordStart = nBreakPos;
            sal_Int32 nWordEnd = aBoundary.endPos;
            DBG_ASSERT( nWordEnd > nWordStart, "ImpBreakLine: Start >= End?" );

            sal_uInt16 nWordLen = nWordEnd - nWordStart;
            sal_Int32 nWordLen = nWordEnd - nWordStart;
            if ( ( nWordEnd >= nMaxBreakPos ) && ( nWordLen > 3 ) )
            {
                // May happen, because getLineBreak may differ from getWordBoudary with DICTIONARY_WORD
                OUString aWord = pNode->GetString().copy(nWordStart, nWordLen);
                sal_uInt16 nMinTrail = nWordEnd-nMaxBreakPos+1; //+1: Before the dickey letter
                sal_Int32 nMinTrail = nWordEnd-nMaxBreakPos+1; //+1: Before the dickey letter
                Reference< XHyphenatedWord > xHyphWord;
                if (xHyphenator.is())
                    xHyphWord = xHyphenator->hyphenate( aWord, aLocale, aWord.getLength() - nMinTrail, Sequence< PropertyValue >() );
                if (xHyphWord.is())
                {
                    sal_Bool bAlternate = xHyphWord->isAlternativeSpelling();
                    sal_uInt16 _nWordLen = 1 + xHyphWord->getHyphenPos();
                    sal_Int32 _nWordLen = 1 + xHyphWord->getHyphenPos();

                    if ( ( _nWordLen >= 2 ) && ( (nWordStart+_nWordLen) >= (pLine->GetStart() + 2 ) ) )
                    {
@@ -1877,10 +1876,10 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te
                 // We can thus actually not directly connect the index of the
                            // AlternativeWord to aWord. The whole issue will be simplified
                            // by a function in the  Hyphenator as soon as AMA builds this in...
                            sal_uInt16 nAltStart = _nWordLen - 1;
                            sal_uInt16 nTxtStart = nAltStart - (aAlt.getLength() - aWord.getLength());
                            sal_uInt16 nTxtEnd = nTxtStart;
                            sal_uInt16 nAltEnd = nAltStart;
                            sal_Int32 nAltStart = _nWordLen - 1;
                            sal_Int32 nTxtStart = nAltStart - (aAlt.getLength() - aWord.getLength());
                            sal_Int32 nTxtEnd = nTxtStart;
                            sal_Int32 nAltEnd = nAltStart;

                            // The regions between the nStart and nEnd is the
                            // difference between alternative and original string.
@@ -1930,7 +1929,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te
    // the dickey portion is the end portion
    pLine->SetEnd( nBreakPos );

    sal_uInt16 nEndPortion = SplitTextPortion( pParaPortion, nBreakPos, pLine );
    sal_Int32 nEndPortion = SplitTextPortion( pParaPortion, nBreakPos, pLine );

    if ( !bCompressBlank && !bHangingPunctuation )
    {
@@ -1947,7 +1946,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te
        TextPortion* const pTP = pParaPortion->GetTextPortions()[nEndPortion];
        DBG_ASSERT( pTP->GetKind() == PORTIONKIND_TEXT, "BlankRubber: No TextPortion!" );
        DBG_ASSERT( nBreakPos > pLine->GetStart(), "SplitTextPortion at the beginning of the line?" );
        sal_uInt16 nPosInArray = nBreakPos - 1 - pLine->GetStart();
        sal_Int32 nPosInArray = nBreakPos - 1 - pLine->GetStart();
        pTP->GetSize().Width() = ( nPosInArray && ( pTP->GetLen() > 1 ) ) ? pLine->GetCharPosArray()[ nPosInArray-1 ] : 0;
        pLine->GetCharPosArray()[ nPosInArray ] = pTP->GetSize().Width();
    }
@@ -1995,7 +1994,7 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine,
    DBG_ASSERT( nLastChar < pNode->Len(), "AdjustBlocks: Out of range!" );

    // Search blanks or Kashidas...
    std::vector<sal_uInt16> aPositions;
    std::vector<sal_Int32> aPositions;
    sal_uInt16 nLastScript = i18n::ScriptType::LATIN;
    for ( sal_Int32 nChar = nFirstChar; nChar <= nLastChar; nChar++ )
    {
@@ -2042,7 +2041,7 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine,
         ( MsLangId::getPrimaryLanguage( GetLanguage( EditPaM( pNode, nLastChar ) ) ) != LANGUAGE_ARABIC_PRIMARY_ONLY ) )
    {
        aPositions.pop_back();
        sal_uInt16 nPortionStart, nPortion;
        sal_Int32 nPortionStart, nPortion;
        nPortion = pParaPortion->GetTextPortions().FindPortion( nLastChar+1, nPortionStart );
        TextPortion* pLastPortion = pParaPortion->GetTextPortions()[ nPortion ];
        long nRealWidth = pLine->GetCharPosArray()[nLastChar-nFirstChar];
@@ -2070,12 +2069,12 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine,

    // Correct the positions in the Array and the portion widths:
    // Last character won't be considered ...
    for ( std::vector<sal_uInt16>::const_iterator it(aPositions.begin()); it != aPositions.end(); ++it )
    for ( std::vector<sal_Int32>::const_iterator it(aPositions.begin()); it != aPositions.end(); ++it )
    {
        sal_uInt16 nChar = *it;
        sal_Int32 nChar = *it;
        if ( nChar < nLastChar )
        {
            sal_uInt16 nPortionStart, nPortion;
            sal_Int32 nPortionStart, nPortion;
            nPortion = pParaPortion->GetTextPortions().FindPortion( nChar, nPortionStart, true );
            TextPortion* pLastPortion = pParaPortion->GetTextPortions()[ nPortion ];

@@ -2086,8 +2085,8 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine,

            // Correct positions in array
            // Even for kashidas just change positions, VCL will then draw the kashida automaticly
            sal_uInt16 nPortionEnd = nPortionStart + pLastPortion->GetLen();
            for ( sal_uInt16 _n = nChar; _n < nPortionEnd; _n++ )
            sal_Int32 nPortionEnd = nPortionStart + pLastPortion->GetLen();
            for ( sal_Int32 _n = nChar; _n < nPortionEnd; _n++ )
            {
                pLine->GetCharPosArray()[_n-nFirstChar] += nMore4Everyone;
                if ( nSomeExtraSpace )
@@ -2103,7 +2102,7 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine,
    pLine->SetTextWidth( pLine->GetTextWidth() + nRemainingSpace );
}

void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_uInt16 nStart, sal_uInt16 nEnd, std::vector<sal_uInt16>& rArray )
void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, std::vector<sal_Int32>& rArray )
{
    // the search has to be performed on a per word base

@@ -2220,7 +2219,7 @@ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_uInt16 nStart, sal_
    }
}

sal_uInt16 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_uInt16 nPos, EditLine* pCurLine )
sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_Int32 nPos, EditLine* pCurLine )
{
    DBG_ASSERT( pPortion, "SplitTextPortion: Which ?" );

@@ -2228,10 +2227,10 @@ sal_uInt16 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_uInt16 nP
    if ( nPos == 0 )
        return 0;

    sal_uInt16 nSplitPortion;
    sal_uInt16 nTmpPos = 0;
    sal_Int32 nSplitPortion;
    sal_Int32 nTmpPos = 0;
    TextPortion* pTextPortion = NULL;
    sal_uInt16 nPortions = pPortion->GetTextPortions().Count();
    sal_Int32 nPortions = pPortion->GetTextPortions().Count();
    for ( nSplitPortion = 0; nSplitPortion < nPortions; nSplitPortion++ )
    {
        TextPortion* pTP = pPortion->GetTextPortions()[nSplitPortion];
@@ -2250,7 +2249,7 @@ sal_uInt16 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_uInt16 nP
    DBG_ASSERT( pTextPortion, "Position outside the area!" );
    DBG_ASSERT( pTextPortion->GetKind() == PORTIONKIND_TEXT, "SplitTextPortion: No TextPortion!" );

    sal_uInt16 nOverlapp = nTmpPos - nPos;
    sal_Int32 nOverlapp = nTmpPos - nPos;
    pTextPortion->SetLen( pTextPortion->GetLen() - nOverlapp );
    TextPortion* pNewPortion = new TextPortion( nOverlapp );
    pPortion->GetTextPortions().Insert(nSplitPortion+1, pNewPortion);
@@ -2264,7 +2263,7 @@ sal_uInt16 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_uInt16 nP
        if ( pTextPortion->GetExtraInfos() && pTextPortion->GetExtraInfos()->bCompressed )
        {
            // We need the original size from the portion
            sal_uInt16 nTxtPortionStart = pPortion->GetTextPortions().GetStartPos( nSplitPortion );
            sal_Int32 nTxtPortionStart = pPortion->GetTextPortions().GetStartPos( nSplitPortion );
               SvxFont aTmpFont( pPortion->GetNode()->GetCharAttribs().GetDefFont() );
            SeekCursor( pPortion->GetNode(), nTxtPortionStart+1, aTmpFont );
            aTmpFont.SetPhysFont( GetRefDevice() );
@@ -2281,13 +2280,13 @@ sal_uInt16 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_uInt16 nP
    return nSplitPortion;
}

void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_uInt16& rStart )
void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_Int32& rStart )
{
    sal_uInt16 nStartPos = rStart;
    sal_Int32 nStartPos = rStart;
    ContentNode* pNode = pParaPortion->GetNode();
    DBG_ASSERT( pNode->Len(), "CreateTextPortions should not be used for empty paragraphs!" );

    ::std::set< sal_uInt32 > aPositions;
    ::std::set< sal_Int32 > aPositions;
    aPositions.insert( 0 );

    sal_uInt16 nAttr = 0;
@@ -2331,10 +2330,10 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_uInt16& r
    // From ... Delete:
    // Unfortunately, the number of text portions does not have to match
    // aPositions.Count(), since there might be line breaks...
    sal_uInt16 nPortionStart = 0;
    sal_uInt16 nInvPortion = 0;
    sal_uInt16 nP;
    for ( nP = 0; nP < pParaPortion->GetTextPortions().Count(); nP++ )
    sal_Int32 nPortionStart = 0;
    sal_Int32 nInvPortion = 0;
    sal_Int32 nP;
    for ( nP = 0; nP < (sal_Int32)pParaPortion->GetTextPortions().Count(); nP++ )
    {
        const TextPortion* pTmpPortion = pParaPortion->GetTextPortions()[nP];
        nPortionStart = nPortionStart + pTmpPortion->GetLen();
@@ -2360,14 +2359,14 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_uInt16& r
    // A portion may also have been formed by a line break:
    aPositions.insert( nPortionStart );

    ::std::set< sal_uInt32 >::iterator nInvPos = aPositions.find(  nPortionStart );
    ::std::set< sal_Int32 >::iterator nInvPos = aPositions.find(  nPortionStart );
    DBG_ASSERT( (nInvPos != aPositions.end()), "InvPos ?!" );

    ::std::set< sal_uInt32 >::iterator i = nInvPos;
    ::std::set< sal_Int32 >::iterator i = nInvPos;
    ++i;
    while ( i != aPositions.end() )
    {
        TextPortion* pNew = new TextPortion( static_cast<sal_uInt16>(*i++) - static_cast<sal_uInt16>(*nInvPos++) );
        TextPortion* pNew = new TextPortion( (*i++) - *nInvPos++ );
        pParaPortion->GetTextPortions().Append(pNew);
    }

@@ -2377,7 +2376,7 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_uInt16& r
#endif
}

void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nStartPos, short nNewChars )
void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nStartPos, sal_Int32 nNewChars )
{
    DBG_ASSERT( pParaPortion->GetTextPortions().Count(), "No Portions!" );
    DBG_ASSERT( nNewChars, "RecalcTextPortion with Diff == 0" );
@@ -2389,13 +2388,13 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nSt
        // otherwise the portion is extended at nStartPos.
        if ( pNode->GetCharAttribs().HasBoundingAttrib( nStartPos ) || IsScriptChange( EditPaM( pNode, nStartPos ) ) )
        {
            sal_uInt16 nNewPortionPos = 0;
            sal_Int32 nNewPortionPos = 0;
            if ( nStartPos )
                nNewPortionPos = SplitTextPortion( pParaPortion, nStartPos ) + 1;

            // A blank portion may be here, if the paragraph was empty,
            // or if a line was created by a hard line break.
            if ( ( nNewPortionPos < pParaPortion->GetTextPortions().Count() ) &&
            if ( ( nNewPortionPos < (sal_Int32)pParaPortion->GetTextPortions().Count() ) &&
                    !pParaPortion->GetTextPortions()[nNewPortionPos]->GetLen() )
            {
                TextPortion* const pTP = pParaPortion->GetTextPortions()[nNewPortionPos];
@@ -2410,8 +2409,8 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nSt
        }
        else
        {
            sal_uInt16 nPortionStart;
            const sal_uInt16 nTP = pParaPortion->GetTextPortions().
            sal_Int32 nPortionStart;
            const sal_Int32 nTP = pParaPortion->GetTextPortions().
                FindPortion( nStartPos, nPortionStart );
            TextPortion* const pTP = pParaPortion->GetTextPortions()[ nTP ];
            DBG_ASSERT( pTP, "RecalcTextPortion: Portion not found"  );
@@ -2428,10 +2427,10 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nSt
        // There must be no portions extending into the area or portions starting in
        // the area, so it must be:
        //    nStartPos <= nPos <= nStartPos - nNewChars(neg.)
        sal_uInt16 nPortion = 0;
        sal_uInt16 nPos = 0;
        sal_uInt16 nEnd = nStartPos-nNewChars;
        sal_uInt16 nPortions = pParaPortion->GetTextPortions().Count();
        sal_Int32 nPortion = 0;
        sal_Int32 nPos = 0;
        sal_Int32 nEnd = nStartPos-nNewChars;
        sal_Int32 nPortions = pParaPortion->GetTextPortions().Count();
        TextPortion* pTP = 0;
        for ( nPortion = 0; nPortion < nPortions; nPortion++ )
        {
@@ -2466,12 +2465,12 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nSt
            pTP->SetLen( pTP->GetLen() + nNewChars );
        }

        sal_uInt16 nPortionCount = pParaPortion->GetTextPortions().Count();
        sal_Int32 nPortionCount = pParaPortion->GetTextPortions().Count();
        assert( nPortionCount );
        if (nPortionCount)
        {
            // No HYPHENATOR portion is allowed to get stuck right at the end...
            sal_uInt16 nLastPortion = nPortionCount - 1;
            sal_Int32 nLastPortion = nPortionCount - 1;
            pTP = pParaPortion->GetTextPortions()[nLastPortion];
            if ( pTP->GetKind() == PORTIONKIND_HYPHENATOR )
            {
@@ -2542,7 +2541,7 @@ void ImpEditEngine::SetFixedCellHeight( sal_Bool bUseFixedCellHeight )
    }
}

void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_uInt16 nPos, SvxFont& rFont, OutputDevice* pOut, sal_uInt16 nIgnoreWhich )
void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFont, OutputDevice* pOut, sal_uInt16 nIgnoreWhich )
{
    // It was planned, SeekCursor( nStartPos, nEndPos, ... ), so that it would
    // only be searched anew at the StartPosition.
@@ -2884,7 +2883,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
            pPDFExtOutDevData->BeginStructureElement( vcl::PDFWriter::Paragraph );

        long nParaHeight = pPortion->GetHeight();
        sal_uInt16 nIndex = 0;
        sal_Int32 nIndex = 0;
        if ( pPortion->IsVisible() && (
                ( !IsVertical() && ( ( aStartPos.Y() + nParaHeight ) > aClipRect.Top() ) ) ||
                ( IsVertical() && ( ( aStartPos.X() - nParaHeight ) < aClipRect.Right() ) ) ) )
@@ -2893,8 +2892,8 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
            // --------------------------------------------------
            // Over the lines of the paragraph ...
            // --------------------------------------------------
            sal_uInt16 nLines = pPortion->GetLines().Count();
            sal_uInt16 nLastLine = nLines-1;
            sal_Int32 nLines = pPortion->GetLines().Count();
            sal_Int32 nLastLine = nLines-1;

            // #108052#
            bool bEndOfParagraphWritten(false);
@@ -2911,7 +2910,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
                                ? GetYValue( rLSItem.GetInterLineSpace() ) : 0;
            bool bPaintBullet (false);

            for ( sal_uInt16 nLine = 0; nLine < nLines; nLine++ )
            for ( sal_Int32 nLine = 0; nLine < nLines; nLine++ )
            {
                pLine = pPortion->GetLines()[nLine];
                nIndex = pLine->GetStart();
@@ -2959,7 +2958,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
                    bool bParsingFields = false;
                    ::std::vector< sal_Int32 >::iterator itSubLines;

                    for ( sal_uInt16 nPortion = pLine->GetStartPortion(); nPortion <= pLine->GetEndPortion(); nPortion++ )
                    for ( sal_Int32 nPortion = pLine->GetStartPortion(); nPortion <= pLine->GetEndPortion(); nPortion++ )
                    {
                        DBG_ASSERT( pPortion->GetTextPortions().Count(), "Line without Textportion in Paint!" );
                        const TextPortion* pTextPortion = pPortion->GetTextPortions()[nPortion];
@@ -3025,8 +3024,8 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
                                ImplInitDigitMode(pOutDev, aTmpFont.GetLanguage());

                                OUString aText;
                                sal_uInt16 nTextStart = 0;
                                sal_uInt16 nTextLen = 0;
                                sal_Int32 nTextStart = 0;
                                sal_Int32 nTextLen = 0;
                                const sal_Int32* pDXArray = 0;
                                sal_Int32* pTmpDXArray = 0;

@@ -3041,8 +3040,8 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
                                    // Paint control characters (#i55716#)
                                    if ( aStatus.MarkFields() )
                                    {
                                        xub_StrLen nTmpIdx;
                                        const xub_StrLen nTmpEnd = nTextStart + pTextPortion->GetLen();
                                        sal_Int32 nTmpIdx;
                                        const sal_Int32 nTmpEnd = nTextStart + pTextPortion->GetLen();

                                        for ( nTmpIdx = nTextStart; nTmpIdx <= nTmpEnd ; ++nTmpIdx )
                                        {
@@ -3230,9 +3229,9 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt

                                        if(pWrongs && !pWrongs->empty())
                                        {
                                            size_t nStart = nIndex, nEnd = 0;
                                            sal_Int32 nStart = nIndex, nEnd = 0;
                                            bool bWrong = pWrongs->NextWrong(nStart, nEnd);
                                            const sal_uInt16 nMaxEnd(nIndex + pTextPortion->GetLen());
                                            const sal_Int32 nMaxEnd(nIndex + pTextPortion->GetLen());

                                            while(bWrong)
                                            {
@@ -3851,7 +3850,7 @@ void ImpEditEngine::SetUpdateModeForAcc(bool bUp)
    bUpdateForAcc = bUp;
}

EditPaM ImpEditEngine::SplitContent( sal_Int32 nNode, sal_uInt16 nSepPos )
EditPaM ImpEditEngine::SplitContent( sal_Int32 nNode, sal_Int32 nSepPos )
{
    ContentNode* pNode = aEditDoc.GetObject( nNode );
    DBG_ASSERT( pNode, "Invalid Node in SplitContent" );
@@ -4063,7 +4062,7 @@ const ParaPortion* ImpEditEngine::GetNextVisPortion( const ParaPortion* pCurPort
long ImpEditEngine::CalcVertLineSpacing(Point& rStartPos) const
{
    long nTotalOccupiedHeight = 0;
    sal_uInt16 nTotalLineCount = 0;
    sal_Int32 nTotalLineCount = 0;
    const ParaPortionList& rParaPortions = GetParaPortions();
    sal_Int32 nParaCount = rParaPortions.Count();

@@ -4084,9 +4083,9 @@ long ImpEditEngine::CalcVertLineSpacing(Point& rStartPos) const
        long nUL = GetYValue( rULItem.GetLower() );

        const EditLineList& rLines = pPortion->GetLines();
        sal_uInt16 nLineCount = rLines.Count();
        sal_Int32 nLineCount = rLines.Count();
        nTotalLineCount += nLineCount;
        for (sal_uInt16 j = 0; j < nLineCount; ++j)
        for (sal_Int32 j = 0; j < nLineCount; ++j)
        {
            const EditLine* pLine = rLines[j];
            nTotalOccupiedHeight += pLine->GetHeight();
@@ -4293,11 +4292,11 @@ void ImpEditEngine::ImplInitDigitMode(OutputDevice* pOutDev, LanguageType eCurLa
        pOutDev->SetDigitLanguage(ImplCalcDigitLang(eCurLang));
}

void ImpEditEngine::ImplInitLayoutMode( OutputDevice* pOutDev, sal_Int32 nPara, sal_uInt16 nIndex )
void ImpEditEngine::ImplInitLayoutMode( OutputDevice* pOutDev, sal_Int32 nPara, sal_Int32 nIndex )
{
    sal_Bool bCTL = sal_False;
    sal_Bool bR2L = sal_False;
    if ( nIndex == 0xFFFF )
    if ( nIndex == -1 )
    {
        bCTL = HasScriptType( nPara, i18n::ScriptType::COMPLEX );
        bR2L = IsRightToLeft( nPara );
@@ -4377,7 +4376,7 @@ Color ImpEditEngine::GetAutoColor() const


bool ImpEditEngine::ImplCalcAsianCompression(ContentNode* pNode,
        TextPortion* pTextPortion, sal_uInt16 nStartPos, sal_Int32* pDXArray,
        TextPortion* pTextPortion, sal_Int32 nStartPos, sal_Int32* pDXArray,
        sal_uInt16 n100thPercentFromMax, sal_Bool bManipulateDXArray)
{
    DBG_ASSERT( GetAsianCompressionMode(), "ImplCalcAsianCompression - Why?" );
@@ -4392,8 +4391,8 @@ bool ImpEditEngine::ImplCalcAsianCompression(ContentNode* pNode,
    if ( GetI18NScriptType( EditPaM( pNode, nStartPos+1 ) ) == i18n::ScriptType::ASIAN )
    {
        long nNewPortionWidth = pTextPortion->GetSize().Width();
        sal_uInt16 nPortionLen = pTextPortion->GetLen();
        for ( sal_uInt16 n = 0; n < nPortionLen; n++ )
        sal_Int32 nPortionLen = pTextPortion->GetLen();
        for ( sal_Int32 n = 0; n < nPortionLen; n++ )
        {
            sal_uInt8 nType = GetCharTypeForCompression( pNode->GetChar( n+nStartPos ) );

@@ -4464,7 +4463,7 @@ bool ImpEditEngine::ImplCalcAsianCompression(ContentNode* pNode,
                            if ( n )
                            {
                                // -1: No entry for the last character
                                for ( sal_uInt16 i = n-1; i < (nPortionLen-1); i++ )
                                for ( sal_Int32 i = n-1; i < (nPortionLen-1); i++ )
                                    pDXArray[i] -= nCompress;
                            }
                            else
@@ -4476,7 +4475,7 @@ bool ImpEditEngine::ImplCalcAsianCompression(ContentNode* pNode,
                        else
                        {
                            // -1: No entry for the last character
                            for ( sal_uInt16 i = n; i < (nPortionLen-1); i++ )
                            for ( sal_Int32 i = n; i < (nPortionLen-1); i++ )
                                pDXArray[i] -= nCompress;
                        }
                    }
@@ -4510,7 +4509,7 @@ void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* 
    long nCompressed = 0;
    std::vector<TextPortion*> aCompressedPortions;

    sal_uInt16 nPortion = pLine->GetEndPortion();
    sal_Int32 nPortion = pLine->GetEndPortion();
    TextPortion* pTP = pParaPortion->GetTextPortions()[ nPortion ];
    while ( pTP && ( pTP->GetKind() == PORTIONKIND_TEXT ) )
    {
@@ -4541,8 +4540,8 @@ void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* 
            pTP->GetSize().Width() = pTP->GetExtraInfos()->nOrgWidth;
            if ( nCompressPercent )
            {
                size_t nTxtPortion = pParaPortion->GetTextPortions().GetPos( pTP );
                sal_uInt16 nTxtPortionStart = pParaPortion->GetTextPortions().GetStartPos( nTxtPortion );
                sal_Int32 nTxtPortion = pParaPortion->GetTextPortions().GetPos( pTP );
                sal_Int32 nTxtPortionStart = pParaPortion->GetTextPortions().GetStartPos( nTxtPortion );
                DBG_ASSERT( nTxtPortionStart >= pLine->GetStart(), "Portion doesn't belong to the line!!!" );
                sal_Int32* pDXArray = NULL;
                if (!pLine->GetCharPosArray().empty())
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 50713cf..7a61810 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -84,12 +84,6 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::linguistic2;

void Swapsal_uIt16s( sal_uInt16& rX, sal_uInt16& rY )
{
    sal_uInt16 n = rX;
    rX = rY;
    rY = n;
}

EditPaM ImpEditEngine::Read( SvStream& rInput, const OUString& rBaseURL, EETextFormat eFormat, EditSelection aSel, SvKeyValueIterator* pHTTPHeaderAttrs )
{
@@ -267,7 +261,7 @@ sal_uInt32 ImpEditEngine::WriteText( SvStream& rOutput, EditSelection aSel )
    return rOutput.GetError();
}

sal_Bool ImpEditEngine::WriteItemListAsRTF( ItemList& rLst, SvStream& rOutput, sal_Int32 nPara, sal_uInt16 nPos,
sal_Bool ImpEditEngine::WriteItemListAsRTF( ItemList& rLst, SvStream& rOutput, sal_Int32 nPara, sal_Int32 nPos,
                        std::vector<SvxFontItem*>& rFontTable, SvxColorList& rColorList )
{
    const SfxPoolItem* pAttrItem = rLst.First();
@@ -279,7 +273,7 @@ sal_Bool ImpEditEngine::WriteItemListAsRTF( ItemList& rLst, SvStream& rOutput, s
    return ( rLst.Count() ? sal_True : sal_False );
}

static void lcl_FindValidAttribs( ItemList& rLst, ContentNode* pNode, sal_uInt16 nIndex, sal_uInt16 nScriptType )
static void lcl_FindValidAttribs( ItemList& rLst, ContentNode* pNode, sal_Int32 nIndex, sal_uInt16 nScriptType )
{
    sal_uInt16 nAttr = 0;
    EditCharAttrib* pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr );
@@ -585,13 +579,13 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
        ParaPortion* pParaPortion = FindParaPortion( pNode );
        DBG_ASSERT( pParaPortion, "Portion not found: WriteRTF" );

        sal_uInt16 nIndex = 0;
        sal_uInt16 nStartPos = 0;
        sal_uInt16 nEndPos = pNode->Len();
        sal_uInt16 nStartPortion = 0;
        sal_uInt16 nEndPortion = (sal_uInt16)pParaPortion->GetTextPortions().Count() - 1;
        sal_Int32 nIndex = 0;
        sal_Int32 nStartPos = 0;
        sal_Int32 nEndPos = pNode->Len();
        sal_Int32 nStartPortion = 0;
        sal_Int32 nEndPortion = pParaPortion->GetTextPortions().Count() - 1;
        sal_Bool bFinishPortion = sal_False;
        sal_uInt16 nPortionStart;
        sal_Int32 nPortionStart;

        if ( nNode == nStartNode )
        {
@@ -619,7 +613,7 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )

        const EditCharAttrib* pNextFeature = pNode->GetCharAttribs().FindFeature(nIndex);
        // start at 0, so the index is right ...
        for ( sal_uInt16 n = 0; n <= nEndPortion; n++ )
        for ( sal_Int32 n = 0; n <= nEndPortion; n++ )
        {
            const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[n];
            if ( n < nStartPortion )
@@ -653,8 +647,8 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
                if ( WriteItemListAsRTF( aAttribItems, rOutput, nNode, nIndex, aFontTable, aColorList ) )
                    rOutput.WriteChar( ' ' );

                sal_uInt16 nS = nIndex;
                sal_uInt16 nE = nIndex + pTextPortion->GetLen();
                sal_Int32 nS = nIndex;
                sal_Int32 nE = nIndex + pTextPortion->GetLen();
                if ( n == nStartPortion )
                    nS = nStartPos;
                if ( n == nEndPortion )
@@ -688,7 +682,7 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
}


void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, sal_Int32 nPara, sal_uInt16 nPos,
void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, sal_Int32 nPara, sal_Int32 nPos,
                            std::vector<SvxFontItem*>& rFontTable, SvxColorList& rColorList )
{
    sal_uInt16 nWhich = rItem.Which();
@@ -1009,7 +1003,7 @@ EditTextObject* ImpEditEngine::CreateTextObject( EditSelection aSel )
    return CreateTextObject( aSel, GetEditTextObjectPool(), aStatus.AllowBigObjects(), nBigTextObjectStart );
}

EditTextObject* ImpEditEngine::CreateTextObject( EditSelection aSel, SfxItemPool* pPool, sal_Bool bAllowBigObjects, sal_uInt16 nBigObjectStart )
EditTextObject* ImpEditEngine::CreateTextObject( EditSelection aSel, SfxItemPool* pPool, sal_Bool bAllowBigObjects, sal_Int32 nBigObjectStart )
{
    EditTextObject* pTxtObj = new EditTextObject(pPool);
    pTxtObj->SetVertical( IsVertical() );
@@ -1019,7 +1013,7 @@ EditTextObject* ImpEditEngine::CreateTextObject( EditSelection aSel, SfxItemPool
        pTxtObj->mpImpl->GetPool()->SetDefaultMetric( (SfxMapUnit) eMapUnit );

    sal_Int32 nStartNode, nEndNode;
    sal_uInt32 nTextPortions = 0;
    sal_Int32 nTextPortions = 0;

    aSel.Adjust( aEditDoc );
    nStartNode = aEditDoc.GetPos( aSel.Min().GetNode() );
@@ -1046,8 +1040,8 @@ EditTextObject* ImpEditEngine::CreateTextObject( EditSelection aSel, SfxItemPool
            nTextPortions += pParaPortion->GetTextPortions().Count();
        }

        sal_uInt16 nStartPos = 0;
        sal_uInt16 nEndPos = pNode->Len();
        sal_Int32 nStartPos = 0;
        sal_Int32 nEndPos = pNode->Len();

        sal_Bool bEmptyPara = nEndPos ? sal_False : sal_True;

@@ -1414,7 +1408,7 @@ void ImpEditEngine::SetAllMisspellRanges( const std::vector<editeng::MisspellRan
    }
}

LanguageType ImpEditEngine::GetLanguage( const EditPaM& rPaM, sal_uInt16* pEndPos ) const
LanguageType ImpEditEngine::GetLanguage( const EditPaM& rPaM, sal_Int32* pEndPos ) const
{
    short nScriptType = GetI18NScriptType( rPaM, pEndPos ); // pEndPos will be valid now, pointing to ScriptChange or NodeLen
    sal_uInt16 nLangId = GetScriptItemId( EE_CHAR_LANGUAGE, nScriptType );
@@ -1512,12 +1506,12 @@ sal_Bool ImpEditEngine::HasConvertibleTextPortion( LanguageType nSrcLang )
    sal_Int32 nParas = pEditEngine->GetParagraphCount();
    for (sal_Int32 k = 0;  k < nParas;  ++k)
    {
        std::vector<sal_uInt16> aPortions;
        std::vector<sal_Int32> aPortions;
        pEditEngine->GetPortions( k, aPortions );
        for ( size_t nPos = 0; nPos < aPortions.size(); ++nPos )
        {
            sal_uInt16 nEnd   = aPortions[ nPos ];
            sal_uInt16 nStart = nPos > 0 ? aPortions[ nPos - 1 ] : 0;
            sal_Int32 nEnd   = aPortions[ nPos ];
            sal_Int32 nStart = nPos > 0 ? aPortions[ nPos - 1 ] : 0;

            // if the paragraph is not empty we need to increase the index
            // by one since the attribute of the character left to the
@@ -1703,7 +1697,7 @@ void ImpEditEngine::ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang,
        sal_Int32 nAttribEnd   = -1;
        sal_Int32 nCurPos      = -1;
        EPaM aCurStart = CreateEPaM( aCurSel.Min() );
        std::vector<sal_uInt16> aPortions;
        std::vector<sal_Int32> aPortions;
        pEditEngine->GetPortions( aCurStart.nPara, aPortions );
        for ( size_t nPos = 0; nPos < aPortions.size(); ++nPos )
        {
@@ -2066,7 +2060,7 @@ void ImpEditEngine::AddPortionIterated(
                    pFieldAttr->GetStart() == aCursor.GetIndex() &&
                    pFieldAttr->GetStart() != pFieldAttr->GetEnd() &&
                    pFieldAttr->Which() == EE_FEATURE_FIELD;
            sal_uInt16 nEndField = bIsField ? pFieldAttr->GetEnd() : USHRT_MAX;
            sal_Int32 nEndField = bIsField ? pFieldAttr->GetEnd() : USHRT_MAX;
            bool bIsEndField = false;
            do
            {
@@ -2117,7 +2111,7 @@ void ImpEditEngine::ApplyChangedSentence(EditView& rEditView,
        // 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() );
        xub_StrLen nOldLen = aOldSel.Max().GetNode()->Len();
        sal_Int32 nOldLen = aOldSel.Max().GetNode()->Len();

        UndoActionStart( EDITUNDO_INSERT );
        if(pSpellInfo->aLastSpellPortions.size() == rNewPortions.size())
@@ -2503,9 +2497,9 @@ EESpellState ImpEditEngine::StartThesaurus( EditView* pEditView )
    return EE_SPELL_OK;
}

sal_uInt16 ImpEditEngine::StartSearchAndReplace( EditView* pEditView, const SvxSearchItem& rSearchItem )
sal_Int32 ImpEditEngine::StartSearchAndReplace( EditView* pEditView, const SvxSearchItem& rSearchItem )
{
    sal_uInt16 nFound = 0;
    sal_Int32 nFound = 0;

    EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() );

@@ -2699,8 +2693,8 @@ namespace
{
    struct eeTransliterationChgData
    {
        sal_uInt16                  nStart;
        xub_StrLen                  nLen;
        sal_Int32                   nStart;
        sal_Int32                   nLen;
        EditSelection               aSelection;
        OUString                    aNewText;
        uno::Sequence< sal_Int32 >  aOffsets;
@@ -2738,8 +2732,8 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection,
        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!

        sal_uInt16 nCurrentStart = nStartPos;
        sal_uInt16 nCurrentEnd = nEndPos;
        sal_Int32 nCurrentStart = nStartPos;
        sal_Int32 nCurrentEnd = nEndPos;
        sal_uInt16 nLanguage = LANGUAGE_SYSTEM;

        // since we don't use Hiragana/Katakana or half-width/full-width transliterations here
@@ -2793,8 +2787,8 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection,
            i18n::Boundary aCurWordBndry( aSttBndry );
            while (aCurWordBndry.startPos <= aEndBndry.startPos)
            {
                nCurrentStart = (xub_StrLen)aCurWordBndry.startPos;
                nCurrentEnd   = (xub_StrLen)aCurWordBndry.endPos;
                nCurrentStart = aCurWordBndry.startPos;
                nCurrentEnd   = aCurWordBndry.endPos;
                sal_Int32 nLen = nCurrentEnd - nCurrentStart;
                DBG_ASSERT( nLen > 0, "invalid word length of 0" );
#if OSL_DEBUG_LEVEL > 1
@@ -2997,7 +2991,7 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection,
                sal_Int32 nSelNode = aEditDoc.GetPos( rData.aSelection.Min().GetNode() );
                ParaPortion* pParaPortion = GetParaPortions()[nSelNode];
                pParaPortion->MarkSelectionInvalid( rData.nStart,
                        std::max< sal_uInt16 >( rData.nStart + rData.nLen,
                        std::max< sal_Int32 >( rData.nStart + rData.nLen,
                                            rData.nStart + rData.aNewText.getLength() ) );
            }
        }
@@ -3025,20 +3019,19 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection,

short ImpEditEngine::ReplaceTextOnly(
    ContentNode* pNode,
    sal_uInt16 nCurrentStart, xub_StrLen nLen,
    sal_Int32 nCurrentStart, sal_Int32 nLen,
    const OUString& rNewText,
    const uno::Sequence< sal_Int32 >& rOffsets )
{
    (void)  nLen;

    // Change text without loosing the attributes
    sal_uInt16 nCharsAfterTransliteration =
        sal::static_int_cast< sal_uInt16 >(rOffsets.getLength());
    sal_Int32 nCharsAfterTransliteration = rOffsets.getLength();
    const sal_Int32* pOffsets = rOffsets.getConstArray();
    short nDiffs = 0;
    for ( sal_uInt16 n = 0; n < nCharsAfterTransliteration; n++ )
    for ( sal_Int32 n = 0; n < nCharsAfterTransliteration; n++ )
    {
        sal_uInt16 nCurrentPos = nCurrentStart+n;
        sal_Int32 nCurrentPos = nCurrentStart+n;
        sal_Int32 nDiff = (nCurrentPos-nDiffs) - pOffsets[n];

        if ( !nDiff )
@@ -3053,7 +3046,7 @@ short ImpEditEngine::ReplaceTextOnly(
            pNode->SetChar( nCurrentPos, rNewText[n] );

            DBG_ASSERT( (nCurrentPos+1) < pNode->Len(), "TransliterateText - String smaller than expected!" );
            GetEditDoc().RemoveChars( EditPaM( pNode, nCurrentPos+1 ), sal::static_int_cast< sal_uInt16 >(-nDiff) );
            GetEditDoc().RemoveChars( EditPaM( pNode, nCurrentPos+1 ), -nDiff);
        }
        else
        {
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index 8a1cbf7..3c6938e 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -391,7 +391,7 @@ SfxItemSet ImpEditEngine::GetAttribs( EditSelection aSel, sal_Bool bOnlyHardAttr
}


SfxItemSet ImpEditEngine::GetAttribs( sal_Int32 nPara, sal_uInt16 nStart, sal_uInt16 nEnd, sal_uInt8 nFlags ) const
SfxItemSet ImpEditEngine::GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, sal_uInt8 nFlags ) const
{
    // Optimized function with less Puts(), which cause unnecessary cloning from default items.
    // If this works, change GetAttribs( EditSelection ) to use this for each paragraph and merge the results!
@@ -434,7 +434,7 @@ SfxItemSet ImpEditEngine::GetAttribs( sal_Int32 nPara, sal_uInt16 nStart, sal_uI

                if ( nStart == nEnd )
                {
                    sal_uInt16 nCursorPos = nStart;
                    sal_Int32 nCursorPos = nStart;
                    if ( ( rAttr.GetStart() <= nCursorPos ) && ( rAttr.GetEnd() >= nCursorPos ) )
                    {
                        // To be used the attribute has to start BEFORE the position, or it must be a
@@ -744,14 +744,14 @@ void ImpEditEngine::GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& 
void ImpEditEngine::ParaAttribsToCharAttribs( ContentNode* pNode )
{
    pNode->GetCharAttribs().DeleteEmptyAttribs( GetEditDoc().GetItemPool() );
    xub_StrLen nEndPos = pNode->Len();
    sal_Int32 nEndPos = pNode->Len();
    for ( sal_uInt16 nWhich = EE_CHAR_START; nWhich <= EE_CHAR_END; nWhich++ )
    {
        if ( pNode->GetContentAttribs().HasItem( nWhich ) )
        {
            const SfxPoolItem& rItem = pNode->GetContentAttribs().GetItem( nWhich );
            // Fill the gap:
            sal_uInt16 nLastEnd = 0;
            sal_Int32 nLastEnd = 0;
            const EditCharAttrib* pAttr = pNode->GetCharAttribs().FindNextAttrib( nWhich, nLastEnd );
            while ( pAttr )
            {
diff --git a/editeng/source/editeng/misspellrange.cxx b/editeng/source/editeng/misspellrange.cxx
index 980a559..5e0cf23 100644
--- a/editeng/source/editeng/misspellrange.cxx
+++ b/editeng/source/editeng/misspellrange.cxx
@@ -12,9 +12,9 @@
namespace editeng {

MisspellRange::MisspellRange() : mnStart(0), mnEnd(0) {}
MisspellRange::MisspellRange(size_t nStart, size_t nEnd) : mnStart(nStart), mnEnd(nEnd) {}
MisspellRange::MisspellRange(sal_Int32 nStart, sal_Int32 nEnd) : mnStart(nStart), mnEnd(nEnd) {}

MisspellRanges::MisspellRanges(size_t nParagraph, const std::vector<MisspellRange>& rRanges) :
MisspellRanges::MisspellRanges(sal_Int32 nParagraph, const std::vector<MisspellRange>& rRanges) :
    mnParagraph(nParagraph), maRanges(rRanges) {}

}
diff --git a/editeng/source/editeng/section.cxx b/editeng/source/editeng/section.cxx
index 2e19d0d..3fc5abb 100644
--- a/editeng/source/editeng/section.cxx
+++ b/editeng/source/editeng/section.cxx
@@ -13,7 +13,7 @@ namespace editeng {

Section::Section() : mnParagraph(0), mnStart(0), mnEnd(0) {}

Section::Section(size_t nPara, size_t nStart, size_t nEnd) :
Section::Section(sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd) :
    mnParagraph(nPara), mnStart(nStart), mnEnd(nEnd){}

}
diff --git a/editeng/source/editeng/textconv.cxx b/editeng/source/editeng/textconv.cxx
index a204bfc..515f1fe 100644
--- a/editeng/source/editeng/textconv.cxx
+++ b/editeng/source/editeng/textconv.cxx
@@ -287,8 +287,8 @@ void TextConvWrapper::SelectNewUnit_impl(
    ESelection  aSelection = m_pEditView->GetSelection();
    DBG_ASSERT( aSelection.nStartPara == aSelection.nEndPara,
        "paragraph mismatch in selection" );
    aSelection.nStartPos = (sal_uInt16) (m_nLastPos + m_nUnitOffset + nUnitStart);
    aSelection.nEndPos   = (sal_uInt16) (m_nLastPos + m_nUnitOffset + nUnitEnd);
    aSelection.nStartPos = (m_nLastPos + m_nUnitOffset + nUnitStart);
    aSelection.nEndPos   = (m_nLastPos + m_nUnitOffset + nUnitEnd);
    m_pEditView->SetSelection( aSelection );
}

@@ -370,8 +370,7 @@ void TextConvWrapper::ReplaceUnit(
        default:
            OSL_FAIL( "unexpected case" );
    }
    m_nUnitOffset = sal::static_int_cast< sal_uInt16 >(
        m_nUnitOffset + nUnitStart + aNewTxt.getLength());
    m_nUnitOffset = m_nUnitOffset + nUnitStart + aNewTxt.getLength();

    // remember current original language for kater use
    ImpEditEngine *pImpEditEng = m_pEditView->GetImpEditEngine();
@@ -401,8 +400,7 @@ void TextConvWrapper::ReplaceUnit(

        ESelection aOldSel = m_pEditView->GetSelection();
        ESelection aNewSel( aOldSel );
        aNewSel.nStartPos = sal::static_int_cast< xub_StrLen >(
            aNewSel.nStartPos - aNewTxt.getLength());
        aNewSel.nStartPos = aNewSel.nStartPos - aNewTxt.getLength();

        if (pNewUnitLanguage)
        {
@@ -423,14 +421,12 @@ void TextConvWrapper::ReplaceUnit(
    {
        // Note: replacement is always done in the current paragraph
        // which is the one ConvContinue points to
        pConvInfo->aConvContinue.nIndex = sal::static_int_cast< sal_uInt16 >(
            pConvInfo->aConvContinue.nIndex + nDelta);
        pConvInfo->aConvContinue.nIndex = pConvInfo->aConvContinue.nIndex + nDelta;

        // if that is the same as the one where the conversions ends
        // the end needs to be updated also
        if (pConvInfo->aConvTo.nPara == pConvInfo->aConvContinue.nPara)
            pConvInfo->aConvTo.nIndex = sal::static_int_cast< sal_uInt16 >(
                pConvInfo->aConvTo.nIndex + nDelta);
            pConvInfo->aConvTo.nIndex = pConvInfo->aConvTo.nIndex + nDelta;
    }
}

diff --git a/editeng/source/outliner/outleeng.cxx b/editeng/source/outliner/outleeng.cxx
index 2b66d3b..20d7838 100644
--- a/editeng/source/outliner/outleeng.cxx
+++ b/editeng/source/outliner/outleeng.cxx
@@ -146,8 +146,8 @@ OUString OutlinerEditEng::GetUndoComment( sal_uInt16 nUndoId ) const
    }
}

void OutlinerEditEng::DrawingText( const Point& rStartPos, const OUString& rText, sal_uInt16 nTextStart, sal_uInt16 nTextLen,
    const sal_Int32* pDXArray, const SvxFont& rFont, sal_Int32 nPara, sal_uInt16 nIndex, sal_uInt8 nRightToLeft,
void OutlinerEditEng::DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, sal_Int32 nTextLen,
    const sal_Int32* pDXArray, const SvxFont& rFont, sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft,
    const EEngineData::WrongSpellVector* pWrongSpellVector,
    const SvxFieldData* pFieldData,
    bool bEndOfLine,
@@ -162,7 +162,7 @@ void OutlinerEditEng::DrawingText( const Point& rStartPos, const OUString& rText
}

void OutlinerEditEng::DrawingTab( const Point& rStartPos, long nWidth, const OUString& rChar,
    const SvxFont& rFont, sal_Int32 nPara, xub_StrLen nIndex, sal_uInt8 nRightToLeft,
    const SvxFont& rFont, sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft,
    bool bEndOfLine, bool bEndOfParagraph,
    const Color& rOverlineColor, const Color& rTextLineColor)
{
@@ -170,18 +170,18 @@ void OutlinerEditEng::DrawingTab( const Point& rStartPos, long nWidth, const OUS
            bEndOfLine, bEndOfParagraph, rOverlineColor, rTextLineColor );
}

void OutlinerEditEng::FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos )
void OutlinerEditEng::FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos )
{
    EditEngine::FieldClicked( rField, nPara, nPos );    // If URL
    pOwner->FieldClicked( rField, nPara, nPos );
}

void OutlinerEditEng::FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos )
void OutlinerEditEng::FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos )
{
    pOwner->FieldSelected( rField, nPara, nPos );
}

OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
{
    return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
}
diff --git a/editeng/source/outliner/outleeng.hxx b/editeng/source/outliner/outleeng.hxx
index 935b355..cc1925f 100644
--- a/editeng/source/outliner/outleeng.hxx
+++ b/editeng/source/outliner/outleeng.hxx
@@ -45,8 +45,8 @@ public:
    virtual void        ParagraphConnected( sal_Int32 nLeftParagraph, sal_Int32 nRightParagraph );

    virtual void DrawingText(
        const Point& rStartPos, const OUString& rText, sal_uInt16 nTextStart, sal_uInt16 nTextLen, const sal_Int32* pDXArray, const SvxFont& rFont,
        sal_Int32 nPara, sal_uInt16 nIndex, sal_uInt8 nRightToLeft,
        const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, sal_Int32 nTextLen, const sal_Int32* pDXArray, const SvxFont& rFont,
        sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft,
        const EEngineData::WrongSpellVector* pWrongSpellVector,
        const SvxFieldData* pFieldData,
        bool bEndOfLine,
@@ -58,7 +58,7 @@ public:

    virtual void DrawingTab(
        const Point& rStartPos, long nWidth, const OUString& rChar,
        const SvxFont& rFont, sal_Int32 nPara, xub_StrLen nIndex, sal_uInt8 nRightToLeft,
        const SvxFont& rFont, sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft,
        bool bEndOfLine,
        bool bEndOfParagraph,
        const Color& rOverlineColor,
@@ -72,9 +72,9 @@ public:
    // for text conversion
    virtual sal_Bool        ConvertNextDocument();

    virtual void        FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos );
    virtual void        FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos );
    virtual OUString    CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rTxtColor, Color*& rFldColor );
    virtual void        FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos );
    virtual void        FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos );
    virtual OUString    CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor );

    virtual Rectangle   GetBulletArea( sal_Int32 nPara );

diff --git a/editeng/source/outliner/outlin2.cxx b/editeng/source/outliner/outlin2.cxx
index c1a0b3c..902df8d 100644
--- a/editeng/source/outliner/outlin2.cxx
+++ b/editeng/source/outliner/outlin2.cxx
@@ -169,7 +169,7 @@ OUString Outliner::GetWordDelimiters() const
    return pEditEngine->GetWordDelimiters();
}

OUString Outliner::GetWord( sal_Int32 nPara, sal_uInt16 nIndex )
OUString Outliner::GetWord( sal_Int32 nPara, sal_Int32 nIndex )
{
    return pEditEngine->GetWord( nPara, nIndex );
}
@@ -324,12 +324,12 @@ sal_uLong Outliner::GetLineCount( sal_Int32 nParagraph ) const
    return pEditEngine->GetLineCount( nParagraph );
}

sal_uInt16 Outliner::GetLineLen( sal_Int32 nParagraph, sal_uInt16 nLine ) const
sal_Int32 Outliner::GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const
{
    return pEditEngine->GetLineLen( nParagraph, nLine );
}

sal_uLong Outliner::GetLineHeight( sal_Int32 nParagraph, sal_uInt16 nLine )
sal_uLong Outliner::GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine )
{
    return pEditEngine->GetLineHeight( nParagraph, nLine );
}
@@ -552,7 +552,7 @@ sal_uInt16 Outliner::GetScriptType( const ESelection& rSelection ) const
    return pEditEngine->GetScriptType( rSelection );
}

LanguageType Outliner::GetLanguage( sal_Int32 nPara, sal_uInt16 nPos ) const
LanguageType Outliner::GetLanguage( sal_Int32 nPara, sal_Int32 nPos ) const
{
    return pEditEngine->GetLanguage( nPara, nPos );
}
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index cf1c31a..1aaeb24 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -435,8 +435,8 @@ void Outliner::SetText( const OUString& rText, Paragraph* pPara )
        if (aText.endsWith("\x0A"))
            aText = aText.copy(0, aText.getLength()-1); // Delete the last break

        sal_uInt16 nCount = comphelper::string::getTokenCount(aText, '\x0A');
        sal_uInt16 nPos = 0;
        sal_Int32 nCount = comphelper::string::getTokenCount(aText, '\x0A');
        sal_Int32 nPos = 0;
        sal_Int32 nInsPos = nPara+1;
        while( nCount > nPos )
        {
@@ -502,7 +502,7 @@ bool Outliner::ImpConvertEdtToOut( sal_Int32 nPara,EditView* pView)
{

    bool bConverted = false;
    sal_uInt16 nTabs = 0;
    sal_Int32 nTabs = 0;
    ESelection aDelSel;

    OUString aName;
@@ -512,8 +512,8 @@ bool Outliner::ImpConvertEdtToOut( sal_Int32 nPara,EditView* pView)
    OUString aStr( pEditEngine->GetText( nPara ) );
    const sal_Unicode* pPtr = aStr.getStr();

    sal_uInt16 nHeadingNumberStart = 0;
    sal_uInt16 nNumberingNumberStart = 0;
    sal_Int32 nHeadingNumberStart = 0;
    sal_Int32 nNumberingNumberStart = 0;
    SfxStyleSheet* pStyle= pEditEngine->GetStyleSheet( nPara );
    if( pStyle )
    {
@@ -535,7 +535,7 @@ bool Outliner::ImpConvertEdtToOut( sal_Int32 nPara,EditView* pView)
            aDelSel = ESelection( nPara, 0, nPara, 2 );
        }

        sal_uInt16 nPos = nHeadingNumberStart ? nHeadingNumberStart : nNumberingNumberStart;
        sal_Int32 nPos = nHeadingNumberStart ? nHeadingNumberStart : nNumberingNumberStart;
        OUString aLevel = comphelper::string::stripStart(aName.copy(nPos), ' ');
        nTabs = sal::static_int_cast< sal_uInt16 >(aLevel.toInt32());
        if( nTabs )
@@ -649,7 +649,7 @@ void Outliner::AddText( const OutlinerParaObject& rPObj )
    pEditEngine->SetUpdateMode( bUpdate );
}

void Outliner::FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos )
void Outliner::FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos )
{

    if ( aFieldClickedHdl.IsSet() )
@@ -661,7 +661,7 @@ void Outliner::FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_uI
}


void Outliner::FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos )
void Outliner::FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos )
{
    if ( !aFieldClickedHdl.IsSet() )
        return;
@@ -672,7 +672,7 @@ void Outliner::FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, sal_u
}


OUString Outliner::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
OUString Outliner::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
{
    if ( !aCalcFieldValueHdl.IsSet() )
        return OUString( ' ' );
@@ -1018,7 +1018,7 @@ void Outliner::PaintBullet( sal_Int32 nPara, const Point& rStartPos,
                    }

                    DrawingText(aTextPos, pPara->GetText(), 0, pPara->GetText().getLength(), pBuf,
                        aSvxFont, nPara, 0xFFFF, bRightToLeftPara, 0, 0, false, false, true, 0, Color(), Color());
                        aSvxFont, nPara, -1, bRightToLeftPara, 0, 0, false, false, true, 0, Color(), Color());

                    delete[] pBuf;
                }
@@ -1743,8 +1743,8 @@ void Outliner::StripPortions()
    bStrippingPortions = sal_False;
}

void Outliner::DrawingText( const Point& rStartPos, const OUString& rText, sal_uInt16 nTextStart, sal_uInt16 nTextLen, const sal_Int32* pDXArray,const SvxFont& rFont,
    sal_Int32 nPara, sal_uInt16 nIndex, sal_uInt8 nRightToLeft,
void Outliner::DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, sal_Int32 nTextLen, const sal_Int32* pDXArray,const SvxFont& rFont,
    sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft,
    const EEngineData::WrongSpellVector* pWrongSpellVector,
    const SvxFieldData* pFieldData,
    bool bEndOfLine,
@@ -1765,7 +1765,7 @@ void Outliner::DrawingText( const Point& rStartPos, const OUString& rText, sal_u
}

void Outliner::DrawingTab( const Point& rStartPos, long nWidth, const OUString& rChar, const SvxFont& rFont,
    sal_Int32 nPara, xub_StrLen nIndex, sal_uInt8 nRightToLeft, bool bEndOfLine, bool bEndOfParagraph,
    sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft, bool bEndOfLine, bool bEndOfParagraph,
    const Color& rOverlineColor, const Color& rTextLineColor)
{
    if(aDrawPortionHdl.IsSet())
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index ef77731..6defd32 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -374,15 +374,15 @@ sal_Int32 OutlinerView::Select( Paragraph* pParagraph, sal_Bool bSelect,
    sal_Bool bWithChildren )
{
    sal_Int32 nPara = pOwner->pParaList->GetAbsPos( pParagraph );
    sal_uInt16 nEnd = 0;
    sal_Int32 nEnd = 0;
    if ( bSelect )
        nEnd = 0xffff;
        nEnd = SAL_MAX_INT32;

    sal_Int32 nChildCount = 0;
    if ( bWithChildren )
        nChildCount = pOwner->pParaList->GetChildCount( pParagraph );

    ESelection aSel( nPara, 0,nPara+nChildCount, nEnd );
    ESelection aSel( nPara, 0, nPara + nChildCount, nEnd );
    pEditView->SetSelection( aSel );
    return nChildCount+1;
}
@@ -1287,7 +1287,7 @@ void OutlinerView::StartTextConversion(
}


sal_uInt16 OutlinerView::StartSearchAndReplace( const SvxSearchItem& rSearchItem )
sal_Int32 OutlinerView::StartSearchAndReplace( const SvxSearchItem& rSearchItem )
{
    return pEditView->StartSearchAndReplace( rSearchItem );
}
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index cdd6fe8..44c16ee 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -1252,7 +1252,7 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
        return;

    SvxNodeIdx* pLastNd = pTmp->pEndNd;
    xub_StrLen nLastCnt = pTmp->nEndCnt;
    sal_Int32 nLastCnt = pTmp->nEndCnt;

    SfxItemSet aMrgSet( pTmp->aAttrSet );
    for( n = 1; n < pChildList->size(); ++n )
diff --git a/editeng/source/uno/unoedhlp.cxx b/editeng/source/uno/unoedhlp.cxx
index cccb809..da17745 100644
--- a/editeng/source/uno/unoedhlp.cxx
+++ b/editeng/source/uno/unoedhlp.cxx
@@ -108,7 +108,7 @@ SAL_WNODEPRECATED_DECLARATIONS_PUSH
}
SAL_WNODEPRECATED_DECLARATIONS_POP

sal_Bool SvxEditSourceHelper::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, const EditEngine& rEE, sal_Int32 nPara, sal_uInt16 nIndex, sal_Bool bInCell )
sal_Bool SvxEditSourceHelper::GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, const EditEngine& rEE, sal_Int32 nPara, sal_Int32 nIndex, sal_Bool bInCell )
{
    // IA2 CWS introduced bInCell, but also did many other changes here.
    // Need to verify implementation with AT (IA2 and ATK)
@@ -120,8 +120,8 @@ sal_Bool SvxEditSourceHelper::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt

    if (!aTempCharAttribs.empty())
    {
        sal_uInt32 nIndex2 = 0;
        sal_uInt32 nParaLen = rEE.GetTextLen(nPara);
        sal_Int32 nIndex2 = 0;
        sal_Int32 nParaLen = rEE.GetTextLen(nPara);
        for (size_t nAttr = 0; nAttr < aTempCharAttribs.size(); ++nAttr)
        {
            if (nIndex2 < aTempCharAttribs[nAttr].nStart)
@@ -143,7 +143,7 @@ sal_Bool SvxEditSourceHelper::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt
        }
    }
    // find closest index in front of nIndex
    sal_uInt16 nCurrIndex;
    sal_Int32 nCurrIndex;
    sal_Int32 nClosestStartIndex_s = 0, nClosestStartIndex_e = 0;
    for(std::vector<EECharAttrib>::iterator i = aCharAttribs.begin(); i < aCharAttribs.end(); ++i)
    {
@@ -184,29 +184,29 @@ sal_Bool SvxEditSourceHelper::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt
    }
    sal_Int32 nClosestEndIndex = nClosestEndIndex_s < nClosestEndIndex_e ? nClosestEndIndex_s : nClosestEndIndex_e;

    nStartIndex = static_cast<sal_uInt16>( nClosestStartIndex );
    nEndIndex = static_cast<sal_uInt16>( nClosestEndIndex );
    nStartIndex = nClosestStartIndex;
    nEndIndex = nClosestEndIndex;

    if ( bInCell )
    {
        EPosition aStartPos( nPara, nStartIndex ), aEndPos( nPara, nEndIndex );
        sal_uInt32 nParaCount = rEE.GetParagraphCount();
        sal_uInt32 nCrrntParaLen = rEE.GetTextLen(nPara);
        sal_Int32 nParaCount = rEE.GetParagraphCount();
        sal_Int32 nCrrntParaLen = rEE.GetTextLen(nPara);
        //need to find closest index in front of nIndex in the previous paragraphs
        if ( aStartPos.nIndex == 0 )
        {
            SfxItemSet aCrrntSet = rEE.GetAttribs( nPara, 0, 1, GETATTRIBS_CHARATTRIBS );
            for ( sal_Int32 nParaIdx = nPara-1; nParaIdx >= 0; nParaIdx-- )
            {
                sal_uInt32 nLen = rEE.GetTextLen( sal_uInt16(nParaIdx) );
                sal_uInt32 nLen = rEE.GetTextLen(nParaIdx);
                if ( nLen )
                {
                    sal_uInt16 nStartIdx, nEndIdx;
                    GetAttributeRun( nStartIdx, nEndIdx, rEE, sal_uInt16(nParaIdx), sal_uInt16(nLen), sal_False );
                    SfxItemSet aSet = rEE.GetAttribs( sal_uInt16(nParaIdx), sal_uInt16(nLen-1), sal_uInt16(nLen), GETATTRIBS_CHARATTRIBS );
                    sal_Int32 nStartIdx, nEndIdx;
                    GetAttributeRun( nStartIdx, nEndIdx, rEE, nParaIdx, nLen, sal_False );
                    SfxItemSet aSet = rEE.GetAttribs( nParaIdx, nLen-1, nLen, GETATTRIBS_CHARATTRIBS );
                    if ( aSet == aCrrntSet )
                    {
                        aStartPos.nPara = sal_uInt16(nParaIdx);
                        aStartPos.nPara = nParaIdx;
                        aStartPos.nIndex = nStartIdx;
                        if ( aStartPos.nIndex != 0 )
                        {
@@ -219,18 +219,18 @@ sal_Bool SvxEditSourceHelper::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt
        //need find closest index behind nIndex in the following paragrphs
        if ( aEndPos.nIndex == nCrrntParaLen )
        {
            SfxItemSet aCrrntSet = rEE.GetAttribs( nPara, sal_uInt16(nCrrntParaLen-1), sal_uInt16(nCrrntParaLen), GETATTRIBS_CHARATTRIBS );
            for ( sal_uInt32 nParaIdx = nPara+1; nParaIdx < nParaCount; nParaIdx++ )
            SfxItemSet aCrrntSet = rEE.GetAttribs( nPara, nCrrntParaLen-1, nCrrntParaLen, GETATTRIBS_CHARATTRIBS );
            for ( sal_Int32 nParaIdx = nPara+1; nParaIdx < nParaCount; nParaIdx++ )
            {
                sal_uInt32 nLen = rEE.GetTextLen( sal_uInt16(nParaIdx) );
                sal_Int32 nLen = rEE.GetTextLen( nParaIdx );
                if ( nLen )
                {
                    sal_uInt16 nStartIdx, nEndIdx;
                    GetAttributeRun( nStartIdx, nEndIdx, rEE, sal_uInt16(nParaIdx), 0, sal_False );
                    SfxItemSet aSet = rEE.GetAttribs( sal_uInt16(nParaIdx), 0, 1, GETATTRIBS_CHARATTRIBS );
                    sal_Int32 nStartIdx, nEndIdx;
                    GetAttributeRun( nStartIdx, nEndIdx, rEE, nParaIdx, 0, sal_False );
                    SfxItemSet aSet = rEE.GetAttribs( nParaIdx, 0, 1, GETATTRIBS_CHARATTRIBS );
                    if ( aSet == aCrrntSet )
                    {
                        aEndPos.nPara = sal_uInt16(nParaIdx);
                        aEndPos.nPara = nParaIdx;
                        aEndPos.nIndex = nEndIdx;
                        if ( aEndPos.nIndex != nLen )
                        {
@@ -243,7 +243,7 @@ sal_Bool SvxEditSourceHelper::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt
        nStartIndex = 0;
        if ( aStartPos.nPara > 0 )
        {
            for ( sal_uInt16 i = 0; i < aStartPos.nPara; i++ )
            for ( sal_Int32 i = 0; i < aStartPos.nPara; i++ )
            {
                nStartIndex += rEE.GetTextLen(i)+1;
            }
@@ -252,7 +252,7 @@ sal_Bool SvxEditSourceHelper::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt
        nEndIndex = 0;
        if ( aEndPos.nPara > 0 )
        {
           for ( sal_uInt16 i = 0; i < aEndPos.nPara; i++ )
           for ( sal_Int32 i = 0; i < aEndPos.nPara; i++ )
           {
               nEndIndex += rEE.GetTextLen(i)+1;
           }
diff --git a/editeng/source/uno/unoedprx.cxx b/editeng/source/uno/unoedprx.cxx
index 109e91f..eea3766 100644
--- a/editeng/source/uno/unoedprx.cxx
+++ b/editeng/source/uno/unoedprx.cxx
@@ -187,7 +187,7 @@ void SvxAccessibleTextIndex::SetEEIndex( sal_uInt16 nEEIndex, const SvxTextForwa
    mnEEIndex = nEEIndex;

    // calculate unknowns
    sal_uInt16                  nCurrField, nFieldCount = rTF.GetFieldCount( GetParagraph() );
    sal_Int32 nCurrField, nFieldCount = rTF.GetFieldCount( GetParagraph() );

    mnIndex = nEEIndex;

@@ -233,7 +233,7 @@ void SvxAccessibleTextIndex::SetIndex( sal_Int32 nIndex, const SvxTextForwarder&
    mnIndex = nIndex;

    // calculate unknowns
    sal_uInt16                  nCurrField, nFieldCount = rTF.GetFieldCount( GetParagraph() );
    sal_Int32 nCurrField, nFieldCount = rTF.GetFieldCount( GetParagraph() );

    DBG_ASSERT(nIndex >= 0 && nIndex <= USHRT_MAX,
               "SvxAccessibleTextIndex::SetIndex: index value overflow");
@@ -445,14 +445,14 @@ sal_Int32 SvxAccessibleTextAdapter::GetParagraphCount() const
    return mrTextForwarder->GetParagraphCount();
}

sal_uInt16 SvxAccessibleTextAdapter::GetTextLen( sal_Int32 nParagraph ) const
sal_Int32 SvxAccessibleTextAdapter::GetTextLen( sal_Int32 nParagraph ) const
{
    DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");

    SvxAccessibleTextIndex aIndex;
    aIndex.SetEEIndex( nParagraph, mrTextForwarder->GetTextLen( nParagraph ), *this );

    return static_cast< sal_uInt16 >(aIndex.GetIndex());
    return aIndex.GetIndex();
}

OUString SvxAccessibleTextAdapter::GetText( const ESelection& rSel ) const
@@ -557,7 +557,7 @@ void SvxAccessibleTextAdapter::RemoveAttribs( const ESelection& , sal_Bool , sal
    DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
}

void SvxAccessibleTextAdapter::GetPortions( sal_Int32 nPara, std::vector<sal_uInt16>& rList ) const
void SvxAccessibleTextAdapter::GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList ) const
{
    DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");

@@ -647,14 +647,14 @@ SfxItemPool* SvxAccessibleTextAdapter::GetPool() const
    return mrTextForwarder->GetPool();
}

OUString SvxAccessibleTextAdapter::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
OUString SvxAccessibleTextAdapter::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
{
    DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");

    return mrTextForwarder->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
}

void SvxAccessibleTextAdapter::FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, xub_StrLen nPos )
void SvxAccessibleTextAdapter::FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos )
{
    DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");

@@ -682,7 +682,7 @@ sal_Bool SvxAccessibleTextAdapter::IsValid() const
        return sal_False;
}

LanguageType SvxAccessibleTextAdapter::GetLanguage( sal_Int32 nPara, sal_uInt16 nPos ) const
LanguageType SvxAccessibleTextAdapter::GetLanguage( sal_Int32 nPara, sal_Int32 nPos ) const
{
    DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");

@@ -693,7 +693,7 @@ LanguageType SvxAccessibleTextAdapter::GetLanguage( sal_Int32 nPara, sal_uInt16 
    return mrTextForwarder->GetLanguage( nPara, aIndex.GetEEIndex() );
}

sal_uInt16 SvxAccessibleTextAdapter::GetFieldCount( sal_Int32 nPara ) const
sal_Int32 SvxAccessibleTextAdapter::GetFieldCount( sal_Int32 nPara ) const
{
    DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");

@@ -724,7 +724,7 @@ sal_Bool SvxAccessibleTextAdapter::GetUpdateModeForAcc( ) const
    return mrTextForwarder->GetUpdateModeForAcc();
}

Rectangle SvxAccessibleTextAdapter::GetCharBounds( sal_Int32 nPara, sal_uInt16 nIndex ) const
Rectangle SvxAccessibleTextAdapter::GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const
{
    DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");

@@ -733,7 +733,7 @@ Rectangle SvxAccessibleTextAdapter::GetCharBounds( sal_Int32 nPara, sal_uInt16 n

    // preset if anything goes wrong below
    // n-th char in GetParagraphIndex's paragraph
    Rectangle aRect = mrTextForwarder->GetCharBounds( nPara, static_cast< sal_uInt16 >( aIndex.GetEEIndex() ) );
    Rectangle aRect = mrTextForwarder->GetCharBounds( nPara, aIndex.GetEEIndex() );

    if( aIndex.InBullet() )
    {
@@ -771,7 +771,7 @@ Rectangle SvxAccessibleTextAdapter::GetCharBounds( sal_Int32 nPara, sal_uInt16 n
                                                  aFont,
                                                  mrTextForwarder->GetText( aSel ) );

                Rectangle aStartRect = mrTextForwarder->GetCharBounds( nPara, static_cast< sal_uInt16 >( aIndex.GetEEIndex() ) );
                Rectangle aStartRect = mrTextForwarder->GetCharBounds( nPara, aIndex.GetEEIndex() );

                if( !aStringWrap.GetCharacterBounds( aIndex.GetFieldOffset(), aRect ) )
                    aRect = aStartRect;
@@ -819,7 +819,7 @@ OutputDevice* SvxAccessibleTextAdapter::GetRefDevice() const
    return mrTextForwarder->GetRefDevice();
}

sal_Bool SvxAccessibleTextAdapter::GetIndexAtPoint( const Point& rPoint, sal_Int32& nPara, sal_uInt16& nIndex ) const
sal_Bool SvxAccessibleTextAdapter::GetIndexAtPoint( const Point& rPoint, sal_Int32& nPara, sal_Int32& nIndex ) const
{
    DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");

@@ -832,7 +832,7 @@ sal_Bool SvxAccessibleTextAdapter::GetIndexAtPoint( const Point& rPoint, sal_Int
    DBG_ASSERT(aIndex.GetIndex() >= 0 && aIndex.GetIndex() <= USHRT_MAX,
               "SvxAccessibleTextIndex::SetIndex: index value overflow");

    nIndex = static_cast< sal_uInt16 > (aIndex.GetIndex());
    nIndex = aIndex.GetIndex();

    EBulletInfo aBulletInfo = GetBulletInfo( nPara );

@@ -859,7 +859,7 @@ sal_Bool SvxAccessibleTextAdapter::GetIndexAtPoint( const Point& rPoint, sal_Int
                       aStringWrap.GetIndexAtPoint( aPoint ) <= USHRT_MAX,
                       "SvxAccessibleTextIndex::SetIndex: index value overflow");

            nIndex = static_cast< sal_uInt16 > (aStringWrap.GetIndexAtPoint( aPoint ));
            nIndex = aStringWrap.GetIndexAtPoint( aPoint );
            return sal_True;
        }
    }
@@ -887,14 +887,14 @@ sal_Bool SvxAccessibleTextAdapter::GetIndexAtPoint( const Point& rPoint, sal_Int
                   aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( rPoint ) <= USHRT_MAX,
                   "SvxAccessibleTextIndex::SetIndex: index value overflow");

        nIndex = static_cast< sal_uInt16 >(aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( aPoint ));
        nIndex = (aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( aPoint ));
        return sal_True;
    }

    return sal_True;
}

sal_Bool SvxAccessibleTextAdapter::GetWordIndices( sal_Int32 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const
sal_Bool SvxAccessibleTextAdapter::GetWordIndices( sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart, sal_Int32& nEnd ) const
{
    DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");

@@ -910,7 +910,7 @@ sal_Bool SvxAccessibleTextAdapter::GetWordIndices( sal_Int32 nPara, sal_uInt16 n

        // always treat bullet as separate word
        nStart = 0;
        nEnd = static_cast< sal_uInt16 > (aIndex.GetBulletLen());
        nEnd = aIndex.GetBulletLen();

        return sal_True;
    }
@@ -925,8 +925,8 @@ sal_Bool SvxAccessibleTextAdapter::GetWordIndices( sal_Int32 nPara, sal_uInt16 n

        // always treat field as separate word
        // TODO: to circumvent this, _we_ would have to do the break iterator stuff!
        nStart = static_cast< sal_uInt16 > (aIndex.GetIndex() - aIndex.GetFieldOffset());
        nEnd = static_cast< sal_uInt16 > (nStart + aIndex.GetFieldLen());
        nStart = aIndex.GetIndex() - aIndex.GetFieldOffset();
        nEnd = nStart + aIndex.GetFieldLen();

        return sal_True;
    }
@@ -938,18 +938,18 @@ sal_Bool SvxAccessibleTextAdapter::GetWordIndices( sal_Int32 nPara, sal_uInt16 n
    DBG_ASSERT(aIndex.GetIndex() >= 0 &&
               aIndex.GetIndex() <= USHRT_MAX,
               "SvxAccessibleTextIndex::SetIndex: index value overflow");
    nStart = static_cast< sal_uInt16 > (aIndex.GetIndex());
    nStart = aIndex.GetIndex();

    aIndex.SetEEIndex( nPara, nEnd, *this );
    DBG_ASSERT(aIndex.GetIndex() >= 0 &&
               aIndex.GetIndex() <= USHRT_MAX,
               "SvxAccessibleTextIndex::SetIndex: index value overflow");
    nEnd = static_cast< sal_uInt16 > (aIndex.GetIndex());
    nEnd = aIndex.GetIndex();

    return sal_True;
}

sal_Bool SvxAccessibleTextAdapter::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nPara, sal_uInt16 nIndex, sal_Bool /* bInCell */ ) const
sal_Bool SvxAccessibleTextAdapter::GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, sal_Bool /* bInCell */ ) const
{
    DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");

@@ -965,7 +965,7 @@ sal_Bool SvxAccessibleTextAdapter::GetAttributeRun( sal_uInt16& nStartIndex, sal

        // always treat bullet as distinct attribute
        nStartIndex = 0;
        nEndIndex = static_cast< sal_uInt16 > (aIndex.GetBulletLen());
        nEndIndex = aIndex.GetBulletLen();

        return sal_True;
    }
@@ -977,8 +977,8 @@ sal_Bool SvxAccessibleTextAdapter::GetAttributeRun( sal_uInt16& nStartIndex, sal
                   "SvxAccessibleTextIndex::SetIndex: index value overflow");

        // always treat field as distinct attribute
        nStartIndex = static_cast< sal_uInt16 > (aIndex.GetIndex() - aIndex.GetFieldOffset());
        nEndIndex = static_cast< sal_uInt16 > (nStartIndex + aIndex.GetFieldLen());
        nStartIndex = aIndex.GetIndex() - aIndex.GetFieldOffset();
        nEndIndex = nStartIndex + aIndex.GetFieldLen();

        return sal_True;
    }
@@ -990,32 +990,32 @@ sal_Bool SvxAccessibleTextAdapter::GetAttributeRun( sal_uInt16& nStartIndex, sal
    DBG_ASSERT(aIndex.GetIndex() >= 0 &&
               aIndex.GetIndex() <= USHRT_MAX,
               "SvxAccessibleTextIndex::SetIndex: index value overflow");
    nStartIndex = static_cast< sal_uInt16 > (aIndex.GetIndex());
    nStartIndex = aIndex.GetIndex();

    aIndex.SetEEIndex( nPara, nEndIndex, *this );
    DBG_ASSERT(aIndex.GetIndex() >= 0 &&
               aIndex.GetIndex() <= USHRT_MAX,
               "SvxAccessibleTextIndex::SetIndex: index value overflow");
    nEndIndex = static_cast< sal_uInt16 > (aIndex.GetIndex());
    nEndIndex = aIndex.GetIndex();

    return sal_True;
}

sal_uInt16 SvxAccessibleTextAdapter::GetLineCount( sal_Int32 nPara ) const
sal_Int32 SvxAccessibleTextAdapter::GetLineCount( sal_Int32 nPara ) const
{
    DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");

    return mrTextForwarder->GetLineCount( nPara );
}

sal_uInt16 SvxAccessibleTextAdapter::GetLineLen( sal_Int32 nPara, sal_uInt16 nLine ) const
sal_Int32 SvxAccessibleTextAdapter::GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const
{
    DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");

    SvxAccessibleTextIndex aStartIndex;
    SvxAccessibleTextIndex aEndIndex;
    sal_uInt16 nCurrLine;
    sal_uInt16 nCurrIndex, nLastIndex;
    sal_Int32 nCurrLine;
    sal_Int32 nCurrIndex, nLastIndex;
    for( nCurrLine=0, nCurrIndex=0, nLastIndex=0; nCurrLine<=nLine; ++nCurrLine )
    {
        nLastIndex = nCurrIndex;
@@ -1028,18 +1028,18 @@ sal_uInt16 SvxAccessibleTextAdapter::GetLineLen( sal_Int32 nPara, sal_uInt16 nLi
    {
        aStartIndex.SetEEIndex( nPara, nLastIndex, *this );

        return static_cast< sal_uInt16 >(aEndIndex.GetIndex() - aStartIndex.GetIndex());
        return aEndIndex.GetIndex() - aStartIndex.GetIndex();
    }
    else
        return static_cast< sal_uInt16 >(aEndIndex.GetIndex());
        return aEndIndex.GetIndex();
}

void SvxAccessibleTextAdapter::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nParagraph, sal_uInt16 nLine ) const
void SvxAccessibleTextAdapter::GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const
{
    mrTextForwarder->GetLineBoundaries( rStart, rEnd, nParagraph, nLine );
}

sal_uInt16 SvxAccessibleTextAdapter::GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nIndex ) const
sal_Int32 SvxAccessibleTextAdapter::GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const
{
    return mrTextForwarder->GetLineNumberAtIndex( nPara, nIndex );
}
@@ -1163,7 +1163,7 @@ void SvxAccessibleTextAdapter::AppendParagraph()
    OSL_FAIL( "not implemented" );
}

sal_uInt16 SvxAccessibleTextAdapter::AppendTextPortion( sal_Int32, const OUString &, const SfxItemSet & )
sal_Int32 SvxAccessibleTextAdapter::AppendTextPortion( sal_Int32, const OUString &, const SfxItemSet & )
{
    OSL_FAIL( "not implemented" );
    return 0;
@@ -1235,8 +1235,8 @@ sal_Bool SvxAccessibleTextEditViewAdapter::GetSelection( ESelection& rSel ) cons
               aEndIndex.GetIndex() >= 0 && aEndIndex.GetIndex() <= USHRT_MAX,
               "SvxAccessibleTextEditViewAdapter::GetSelection: index value overflow");

    rSel = ESelection( aStartIndex.GetParagraph(), static_cast< sal_uInt16 > (aStartIndex.GetIndex()),
                       aEndIndex.GetParagraph(), static_cast< sal_uInt16 > (aEndIndex.GetIndex()) );
    rSel = ESelection( aStartIndex.GetParagraph(), aStartIndex.GetIndex(),
                       aEndIndex.GetParagraph(), aEndIndex.GetIndex() );

    return sal_True;
}
diff --git a/editeng/source/uno/unofored.cxx b/editeng/source/uno/unofored.cxx
index 6b5e09a..6b91f88 100644
--- a/editeng/source/uno/unofored.cxx
+++ b/editeng/source/uno/unofored.cxx
@@ -51,7 +51,7 @@ sal_Int32 SvxEditEngineForwarder::GetParagraphCount() const
    return rEditEngine.GetParagraphCount();
}

sal_uInt16 SvxEditEngineForwarder::GetTextLen( sal_Int32 nParagraph ) const
sal_Int32 SvxEditEngineForwarder::GetTextLen( sal_Int32 nParagraph ) const
{
    return rEditEngine.GetTextLen( nParagraph );
}
@@ -122,7 +122,7 @@ SfxItemPool* SvxEditEngineForwarder::GetPool() const
    return rEditEngine.GetEmptyItemSet().GetPool();
}

void SvxEditEngineForwarder::GetPortions( sal_Int32 nPara, std::vector<sal_uInt16>& rList ) const
void SvxEditEngineForwarder::GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList ) const
{
    rEditEngine.GetPortions( nPara, rList );
}
@@ -154,12 +154,12 @@ sal_Bool SvxEditEngineForwarder::IsValid() const
    return rEditEngine.GetUpdateMode();
}

OUString SvxEditEngineForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
OUString SvxEditEngineForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
{
    return rEditEngine.CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
}

void SvxEditEngineForwarder::FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, xub_StrLen nPos )
void SvxEditEngineForwarder::FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos )
{
    rEditEngine.FieldClicked( rField, nPara, nPos );
}
@@ -178,11 +178,11 @@ sal_uInt16 GetSvxEditEngineItemState( EditEngine& rEditEngine, const ESelection&
        SfxItemState eParaState = SFX_ITEM_DEFAULT;

        // calculate start and endpos for this paragraph
        sal_uInt16 nPos = 0;
        sal_Int32 nPos = 0;
        if( rSel.nStartPara == nPara )
            nPos = rSel.nStartPos;

        sal_uInt16 nEndPos = rSel.nEndPos;
        sal_Int32 nEndPos = rSel.nEndPos;
        if( rSel.nEndPara != nPara )
            nEndPos = rEditEngine.GetTextLen( nPara );

@@ -192,7 +192,7 @@ sal_uInt16 GetSvxEditEngineItemState( EditEngine& rEditEngine, const ESelection&

        sal_Bool bEmpty = sal_True;     // we found no item inside the selektion of this paragraph
        sal_Bool bGaps  = sal_False;    // we found items but theire gaps between them
        sal_uInt16 nLastEnd = nPos;
        sal_Int32 nLastEnd = nPos;

        const SfxPoolItem* pParaItem = NULL;

@@ -268,12 +268,12 @@ sal_uInt16 SvxEditEngineForwarder::GetItemState( sal_Int32 nPara, sal_uInt16 nWh
    return rSet.GetItemState( nWhich );
}

LanguageType SvxEditEngineForwarder::GetLanguage( sal_Int32 nPara, sal_uInt16 nIndex ) const
LanguageType SvxEditEngineForwarder::GetLanguage( sal_Int32 nPara, sal_Int32 nIndex ) const
{
    return rEditEngine.GetLanguage(nPara, nIndex);
}

sal_uInt16 SvxEditEngineForwarder::GetFieldCount( sal_Int32 nPara ) const
sal_Int32 SvxEditEngineForwarder::GetFieldCount( sal_Int32 nPara ) const
{
    return rEditEngine.GetFieldCount(nPara);
}
@@ -288,7 +288,7 @@ EBulletInfo SvxEditEngineForwarder::GetBulletInfo( sal_Int32 ) const
    return EBulletInfo();
}

Rectangle SvxEditEngineForwarder::GetCharBounds( sal_Int32 nPara, sal_uInt16 nIndex ) const
Rectangle SvxEditEngineForwarder::GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const
{
    // #101701#
    // EditEngine's 'internal' methods like GetCharacterBounds()
@@ -374,7 +374,7 @@ OutputDevice* SvxEditEngineForwarder::GetRefDevice() const
    return rEditEngine.GetRefDevice();
}

sal_Bool SvxEditEngineForwarder::GetIndexAtPoint( const Point& rPos, sal_Int32& nPara, sal_uInt16& nIndex ) const
sal_Bool SvxEditEngineForwarder::GetIndexAtPoint( const Point& rPos, sal_Int32& nPara, sal_Int32& nIndex ) const
{
    Size aSize( rEditEngine.CalcTextWidth(), rEditEngine.GetTextHeight() );
    ::std::swap( aSize.Width(), aSize.Height() );
@@ -390,7 +390,7 @@ sal_Bool SvxEditEngineForwarder::GetIndexAtPoint( const Point& rPos, sal_Int32& 
    return sal_True;
}

sal_Bool SvxEditEngineForwarder::GetWordIndices( sal_Int32 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const
sal_Bool SvxEditEngineForwarder::GetWordIndices( sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart, sal_Int32& nEnd ) const
{
    ESelection aRes = rEditEngine.GetWord( ESelection(nPara, nIndex, nPara, nIndex), com::sun::star::i18n::WordType::DICTIONARY_WORD );

@@ -406,27 +406,27 @@ sal_Bool SvxEditEngineForwarder::GetWordIndices( sal_Int32 nPara, sal_uInt16 nIn
    return sal_False;
}

sal_Bool SvxEditEngineForwarder::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nPara, sal_uInt16 nIndex, sal_Bool bInCell ) const
sal_Bool SvxEditEngineForwarder::GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, sal_Bool bInCell ) const
{
    return SvxEditSourceHelper::GetAttributeRun( nStartIndex, nEndIndex, rEditEngine, nPara, nIndex, bInCell );
}

sal_uInt16 SvxEditEngineForwarder::GetLineCount( sal_Int32 nPara ) const
sal_Int32 SvxEditEngineForwarder::GetLineCount( sal_Int32 nPara ) const
{
    return rEditEngine.GetLineCount(nPara);
}

sal_uInt16 SvxEditEngineForwarder::GetLineLen( sal_Int32 nPara, sal_uInt16 nLine ) const
sal_Int32 SvxEditEngineForwarder::GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const
{
    return rEditEngine.GetLineLen(nPara, nLine);
}

void SvxEditEngineForwarder::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nPara, sal_uInt16 nLine ) const
void SvxEditEngineForwarder::GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nPara, sal_Int32 nLine ) const
{
    rEditEngine.GetLineBoundaries(rStart, rEnd, nPara, nLine);
}

sal_uInt16 SvxEditEngineForwarder::GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nIndex ) const
sal_Int32 SvxEditEngineForwarder::GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const
{
    return rEditEngine.GetLineNumberAtIndex(nPara, nIndex);
}
@@ -477,9 +477,9 @@ void SvxEditEngineForwarder::AppendParagraph()
    rEditEngine.InsertParagraph( rEditEngine.GetParagraphCount(), OUString() );
}

sal_uInt16 SvxEditEngineForwarder::AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet & /*rSet*/ )
sal_Int32 SvxEditEngineForwarder::AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet & /*rSet*/ )
{
    sal_uInt16 nLen = 0;
    sal_Int32 nLen = 0;

    sal_Int32 nParaCount = rEditEngine.GetParagraphCount();
    DBG_ASSERT( nPara < nParaCount, "paragraph index out of bounds" );
diff --git a/editeng/source/uno/unoforou.cxx b/editeng/source/uno/unoforou.cxx
index d671d9e..b7ddc3d 100644
--- a/editeng/source/uno/unoforou.cxx
+++ b/editeng/source/uno/unoforou.cxx
@@ -58,7 +58,7 @@ sal_Int32 SvxOutlinerForwarder::GetParagraphCount() const
    return rOutliner.GetParagraphCount();
}

sal_uInt16 SvxOutlinerForwarder::GetTextLen( sal_Int32 nParagraph ) const
sal_Int32 SvxOutlinerForwarder::GetTextLen( sal_Int32 nParagraph ) const
{
    return rOutliner.GetEditEngine().GetTextLen( nParagraph );
}
@@ -190,7 +190,7 @@ SfxItemPool* SvxOutlinerForwarder::GetPool() const
    return rOutliner.GetEmptyItemSet().GetPool();
}

void SvxOutlinerForwarder::GetPortions( sal_Int32 nPara, std::vector<sal_uInt16>& rList ) const
void SvxOutlinerForwarder::GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList ) const
{
    ((EditEngine&)rOutliner.GetEditEngine()).GetPortions( nPara, rList );
}
@@ -226,12 +226,12 @@ void SvxOutlinerForwarder::QuickSetAttribs( const SfxItemSet& rSet, const ESelec
    rOutliner.QuickSetAttribs( rSet, rSel );
}

OUString SvxOutlinerForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
OUString SvxOutlinerForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
{
    return rOutliner.CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
}

void SvxOutlinerForwarder::FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, xub_StrLen nPos )
void SvxOutlinerForwarder::FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos )
{
    rOutliner.FieldClicked( rField, nPara, nPos );
}
@@ -272,12 +272,12 @@ void SvxOutlinerForwarder::flushCache()
    }
}

LanguageType SvxOutlinerForwarder::GetLanguage( sal_Int32 nPara, sal_uInt16 nIndex ) const
LanguageType SvxOutlinerForwarder::GetLanguage( sal_Int32 nPara, sal_Int32 nIndex ) const
{
    return rOutliner.GetLanguage(nPara, nIndex);
}

sal_uInt16 SvxOutlinerForwarder::GetFieldCount( sal_Int32 nPara ) const
sal_Int32 SvxOutlinerForwarder::GetFieldCount( sal_Int32 nPara ) const
{
    return rOutliner.GetEditEngine().GetFieldCount(nPara);
}
@@ -292,7 +292,7 @@ EBulletInfo SvxOutlinerForwarder::GetBulletInfo( sal_Int32 nPara ) const
    return rOutliner.GetBulletInfo( nPara );
}

Rectangle SvxOutlinerForwarder::GetCharBounds( sal_Int32 nPara, sal_uInt16 nIndex ) const
Rectangle SvxOutlinerForwarder::GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const
{
    // EditEngine's 'internal' methods like GetCharacterBounds()
    // don't rotate for vertical text.
@@ -371,7 +371,7 @@ OutputDevice* SvxOutlinerForwarder::GetRefDevice() const
    return rOutliner.GetRefDevice();
}

sal_Bool SvxOutlinerForwarder::GetIndexAtPoint( const Point& rPos, sal_Int32& nPara, sal_uInt16& nIndex ) const
sal_Bool SvxOutlinerForwarder::GetIndexAtPoint( const Point& rPos, sal_Int32& nPara, sal_Int32& nIndex ) const
{
    Size aSize( rOutliner.CalcTextSize() );
    ::std::swap( aSize.Width(), aSize.Height() );
@@ -387,7 +387,7 @@ sal_Bool SvxOutlinerForwarder::GetIndexAtPoint( const Point& rPos, sal_Int32& nP
    return sal_True;
}

sal_Bool SvxOutlinerForwarder::GetWordIndices( sal_Int32 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const
sal_Bool SvxOutlinerForwarder::GetWordIndices( sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart, sal_Int32& nEnd ) const
{
    ESelection aRes = rOutliner.GetEditEngine().GetWord( ESelection(nPara, nIndex, nPara, nIndex), com::sun::star::i18n::WordType::DICTIONARY_WORD );

@@ -403,27 +403,27 @@ sal_Bool SvxOutlinerForwarder::GetWordIndices( sal_Int32 nPara, sal_uInt16 nInde
    return sal_False;
}

sal_Bool SvxOutlinerForwarder::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nPara, sal_uInt16 nIndex, sal_Bool bInCell ) const
sal_Bool SvxOutlinerForwarder::GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, sal_Bool bInCell ) const
{
    return SvxEditSourceHelper::GetAttributeRun( nStartIndex, nEndIndex, rOutliner.GetEditEngine(), nPara, nIndex, bInCell );
}

sal_uInt16 SvxOutlinerForwarder::GetLineCount( sal_Int32 nPara ) const
sal_Int32 SvxOutlinerForwarder::GetLineCount( sal_Int32 nPara ) const
{
    return static_cast < sal_uInt16 >( rOutliner.GetLineCount(nPara) );
    return rOutliner.GetLineCount(nPara);
}

sal_uInt16 SvxOutlinerForwarder::GetLineLen( sal_Int32 nPara, sal_uInt16 nLine ) const
sal_Int32 SvxOutlinerForwarder::GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const
{
    return rOutliner.GetLineLen(nPara, nLine);
}

void SvxOutlinerForwarder::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nPara, sal_uInt16 nLine ) const
void SvxOutlinerForwarder::GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nPara, sal_Int32 nLine ) const
{
    return rOutliner.GetEditEngine().GetLineBoundaries( rStart, rEnd, nPara, nLine );
}

sal_uInt16 SvxOutlinerForwarder::GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nIndex ) const
sal_Int32 SvxOutlinerForwarder::GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const
{
    return rOutliner.GetEditEngine().GetLineNumberAtIndex( nPara, nIndex );
}
@@ -489,7 +489,7 @@ sal_Bool SvxOutlinerForwarder::SetDepth( sal_Int32 nPara, sal_Int16 nNewDepth )
    return sal_False;
}

sal_Int16 SvxOutlinerForwarder::GetNumberingStartValue( sal_Int32 nPara )
sal_Int32 SvxOutlinerForwarder::GetNumberingStartValue( sal_Int32 nPara )
{
    if( 0 <= nPara && nPara < GetParagraphCount() )
    {
@@ -502,7 +502,7 @@ sal_Int16 SvxOutlinerForwarder::GetNumberingStartValue( sal_Int32 nPara )
    }
}

void SvxOutlinerForwarder::SetNumberingStartValue(  sal_Int32 nPara, sal_Int16 nNumberingStartValue )
void SvxOutlinerForwarder::SetNumberingStartValue(  sal_Int32 nPara, sal_Int32 nNumberingStartValue )
{
    if( 0 <= nPara && nPara < GetParagraphCount() )
    {
@@ -551,9 +551,9 @@ void SvxOutlinerForwarder::AppendParagraph()
    rEditEngine.InsertParagraph( rEditEngine.GetParagraphCount(), OUString() );
}

sal_uInt16 SvxOutlinerForwarder::AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet & /*rSet*/ )
sal_Int32 SvxOutlinerForwarder::AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet & /*rSet*/ )
{
    sal_uInt16 nLen = 0;
    sal_Int32 nLen = 0;

    EditEngine& rEditEngine = const_cast< EditEngine& >( rOutliner.GetEditEngine() );
    sal_Int32 nParaCount = rEditEngine.GetParagraphCount();
@@ -580,12 +580,12 @@ void  SvxOutlinerForwarder::CopyText(const SvxTextForwarder& rSource)
//------------------------------------------------------------------------


sal_Int16 SvxTextForwarder::GetNumberingStartValue( sal_Int32 )
sal_Int32 SvxTextForwarder::GetNumberingStartValue( sal_Int32 )
{
    return -1;
}

void SvxTextForwarder::SetNumberingStartValue( sal_Int32, sal_Int16 )
void SvxTextForwarder::SetNumberingStartValue( sal_Int32, sal_Int32 )
{
}

diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index ddce2d3..192f5fa 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -403,7 +403,7 @@ void SAL_CALL SvxUnoTextRangeBase::setString(const OUString& aString)
        //! on QuickInsertText...
        CollapseToStart();

        sal_uInt16 nLen = aConverted.getLength();
        sal_Int32 nLen = aConverted.getLength();
        if (nLen)
            GoRight( nLen, sal_True );
    }
@@ -1417,12 +1417,12 @@ sal_Bool SvxUnoTextRangeBase::GoRight(sal_Int16 nCount, sal_Bool Expand)  throw(
    {
        CheckSelection( maSelection, pForwarder );

        sal_uInt16 nNewPos = maSelection.nEndPos + nCount; //! Overflow???
        sal_Int32 nNewPos = maSelection.nEndPos + nCount; //! Overflow???
        sal_Int32  nNewPar = maSelection.nEndPara;

        sal_Bool bOk = sal_True;
        sal_Int32 nParCount = pForwarder->GetParagraphCount();
        sal_uInt16 nThisLen = pForwarder->GetTextLen( nNewPar );
        sal_Int32 nThisLen = pForwarder->GetTextLen( nNewPar );
        while ( nNewPos > nThisLen && bOk )
        {
            if ( nNewPar + 1 >= nParCount )
@@ -2209,9 +2209,9 @@ uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::appendTextPortion(
        DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" );
        sal_Int32 nPara = nParaCount - 1;
        SfxItemSet aSet( pTextForwarder->GetParaAttribs( nPara ) );
        sal_uInt16 nStart = pTextForwarder->AppendTextPortion( nPara, rText, aSet );
        sal_Int32 nStart = pTextForwarder->AppendTextPortion( nPara, rText, aSet );
        pEditSource->UpdateData();
        xub_StrLen nEnd   = pTextForwarder->GetTextLen( nPara );
        sal_Int32 nEnd   = pTextForwarder->GetTextLen( nPara );

        // set properties for the new text portion
        ESelection aSel( nPara, nStart, nPara, nEnd );
@@ -2437,7 +2437,7 @@ sal_Int32 SvxDummyTextSource::GetParagraphCount() const
    return 0;
}

sal_uInt16 SvxDummyTextSource::GetTextLen( sal_Int32 ) const
sal_Int32 SvxDummyTextSource::GetTextLen( sal_Int32 ) const
{
    return 0;
}
@@ -2468,7 +2468,7 @@ void SvxDummyTextSource::RemoveAttribs( const ESelection& , sal_Bool , sal_uInt1
{
}

void SvxDummyTextSource::GetPortions( sal_Int32, std::vector<sal_uInt16>& ) const
void SvxDummyTextSource::GetPortions( sal_Int32, std::vector<sal_Int32>& ) const
{
}

@@ -2503,12 +2503,12 @@ void SvxDummyTextSource::QuickInsertLineBreak( const ESelection& )
{
};

OUString SvxDummyTextSource::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_uInt16, Color*&, Color*& )
OUString SvxDummyTextSource::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, Color*&, Color*& )
{
    return OUString();
}

void SvxDummyTextSource::FieldClicked( const SvxFieldItem&, sal_Int32, xub_StrLen )
void SvxDummyTextSource::FieldClicked( const SvxFieldItem&, sal_Int32, sal_Int32 )
{
}

@@ -2521,12 +2521,12 @@ void SvxDummyTextSource::SetNotifyHdl( const Link& )
{
}

LanguageType SvxDummyTextSource::GetLanguage( sal_Int32, sal_uInt16 ) const
LanguageType SvxDummyTextSource::GetLanguage( sal_Int32, sal_Int32 ) const
{
    return LANGUAGE_DONTKNOW;
}

sal_uInt16 SvxDummyTextSource::GetFieldCount( sal_Int32 ) const
sal_Int32 SvxDummyTextSource::GetFieldCount( sal_Int32 ) const
{
    return 0;
}
@@ -2541,7 +2541,7 @@ EBulletInfo SvxDummyTextSource::GetBulletInfo( sal_Int32 ) const
    return EBulletInfo();
}

Rectangle SvxDummyTextSource::GetCharBounds( sal_Int32, sal_uInt16 ) const
Rectangle SvxDummyTextSource::GetCharBounds( sal_Int32, sal_Int32 ) const
{
    return Rectangle();
}
@@ -2561,37 +2561,37 @@ OutputDevice* SvxDummyTextSource::GetRefDevice() const
    return NULL;
}

sal_Bool SvxDummyTextSource::GetIndexAtPoint( const Point&, sal_Int32&, sal_uInt16& ) const
sal_Bool SvxDummyTextSource::GetIndexAtPoint( const Point&, sal_Int32&, sal_Int32& ) const
{
    return sal_False;
}

sal_Bool SvxDummyTextSource::GetWordIndices( sal_Int32, sal_uInt16, sal_uInt16&, sal_uInt16& ) const
sal_Bool SvxDummyTextSource::GetWordIndices( sal_Int32, sal_Int32, sal_Int32&, sal_Int32& ) const
{
    return sal_False;
}

sal_Bool SvxDummyTextSource::GetAttributeRun( sal_uInt16&, sal_uInt16&, sal_Int32, sal_uInt16, sal_Bool ) const
sal_Bool SvxDummyTextSource::GetAttributeRun( sal_Int32&, sal_Int32&, sal_Int32, sal_Int32, sal_Bool ) const
{
    return sal_False;
}

sal_uInt16 SvxDummyTextSource::GetLineCount( sal_Int32 ) const
sal_Int32 SvxDummyTextSource::GetLineCount( sal_Int32 ) const
{
    return 0;
}

sal_uInt16 SvxDummyTextSource::GetLineLen( sal_Int32, sal_uInt16 ) const
sal_Int32 SvxDummyTextSource::GetLineLen( sal_Int32, sal_Int32 ) const
{
    return 0;
}

void SvxDummyTextSource::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 /*nParagraph*/, sal_uInt16 /*nLine*/ ) const
void SvxDummyTextSource::GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 /*nParagraph*/, sal_Int32 /*nLine*/ ) const
{
    rStart = rEnd = 0;
}

sal_uInt16 SvxDummyTextSource::GetLineNumberAtIndex( sal_Int32 /*nPara*/, sal_uInt16 /*nIndex*/ ) const
sal_Int32 SvxDummyTextSource::GetLineNumberAtIndex( sal_Int32 /*nPara*/, sal_Int32 /*nIndex*/ ) const
{
    return 0;
}
@@ -2630,7 +2630,7 @@ void SvxDummyTextSource::AppendParagraph()
{
}

sal_uInt16 SvxDummyTextSource::AppendTextPortion( sal_Int32, const OUString &, const SfxItemSet & )
sal_Int32 SvxDummyTextSource::AppendTextPortion( sal_Int32, const OUString &, const SfxItemSet & )
{
    return 0;
}
diff --git a/editeng/source/uno/unotext2.cxx b/editeng/source/uno/unotext2.cxx
index 6a44ae9..8741bc4 100644
--- a/editeng/source/uno/unotext2.cxx
+++ b/editeng/source/uno/unotext2.cxx
@@ -290,7 +290,7 @@ sal_Bool SAL_CALL SvxUnoTextContent::hasElements()
    SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL;
    if( pForwarder )
    {
        std::vector<sal_uInt16> aPortions;
        std::vector<sal_Int32> aPortions;
        pForwarder->GetPortions( mnParagraph, aPortions );
        return !aPortions.empty();
    }
@@ -395,7 +395,7 @@ SvxUnoTextRangeEnumeration::SvxUnoTextRangeEnumeration( const SvxUnoTextBase& rT

    if( mpEditSource && mpEditSource->GetTextForwarder() )
    {
        mpPortions = new std::vector<sal_uInt16>;
        mpPortions = new std::vector<sal_Int32>;
        mpEditSource->GetTextForwarder()->GetPortions( nPara, *mpPortions );
    }
    else
diff --git a/include/editeng/AccessibleEditableTextPara.hxx b/include/editeng/AccessibleEditableTextPara.hxx
index d6f7d6f..0f62ce8 100644
--- a/include/editeng/AccessibleEditableTextPara.hxx
+++ b/include/editeng/AccessibleEditableTextPara.hxx
@@ -304,7 +304,7 @@ namespace accessibility

            @return sal_False, if the method was not able to determine the range
         */
        sal_Bool GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nIndex );
        sal_Bool GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nIndex );

        // syntactic sugar for FireEvent
        void GotPropertyEvent( const ::com::sun::star::uno::Any& rNewValue, const sal_Int16 nEventId ) const;
diff --git a/include/editeng/editdata.hxx b/include/editeng/editdata.hxx
index 2e16717..5f59e5d 100644
--- a/include/editeng/editdata.hxx
+++ b/include/editeng/editdata.hxx
@@ -46,9 +46,9 @@ enum EVAnchorMode       {
#define EE_PARA_ALL             SAL_MAX_INT32
#define EE_PARA_MAX_COUNT       SAL_MAX_INT32

#define EE_INDEX_NOT_FOUND      SAL_MAX_UINT16
#define EE_TEXTPOS_ALL          SAL_MAX_UINT16
#define EE_TEXTPOS_MAX_COUNT    SAL_MAX_UINT16
#define EE_INDEX_NOT_FOUND      SAL_MAX_INT32
#define EE_TEXTPOS_ALL          SAL_MAX_INT32
#define EE_TEXTPOS_MAX_COUNT    SAL_MAX_INT32

EDITENG_DLLPUBLIC extern const size_t EE_APPEND;

@@ -102,45 +102,42 @@ class SfxStyleSheet;
struct EPosition
{
    sal_Int32   nPara;
    xub_StrLen  nIndex;
    sal_Int32   nIndex;

    EPosition() :
        nPara( EE_PARA_NOT_FOUND ),
        nIndex( EE_INDEX_NOT_FOUND )
    {
    }
    EPosition()
        : nPara( EE_PARA_NOT_FOUND )
        , nIndex( EE_INDEX_NOT_FOUND )
        { }

    EPosition( sal_Int32 nPara_, xub_StrLen nPos_ ) :
        nPara( nPara_ ),
        nIndex( nPos_ )
    {
    }
    EPosition( sal_Int32 nPara_, sal_Int32 nPos_ )
        : nPara( nPara_ )
        , nIndex( nPos_ )
        { }
};

struct ESelection
{
    sal_Int32   nStartPara;
    xub_StrLen  nStartPos;
    sal_Int32   nStartPos;
    sal_Int32   nEndPara;
    xub_StrLen  nEndPos;
    sal_Int32   nEndPos;

    ESelection() : nStartPara( 0 ), nStartPos( 0 ), nEndPara( 0 ), nEndPos( 0 ) {}

    ESelection( sal_Int32 nStPara, xub_StrLen nStPos, sal_Int32 nEPara, xub_StrLen nEPos ) :
        nStartPara( nStPara ),
        nStartPos( nStPos ),
        nEndPara( nEPara ),
        nEndPos( nEPos )
    {
    }
    ESelection( sal_Int32 nStPara, sal_Int32 nStPos,
                sal_Int32 nEPara, sal_Int32 nEPos )
        : nStartPara( nStPara )
        , nStartPos( nStPos )
        , nEndPara( nEPara )
        , nEndPos( nEPos )
        { }

    ESelection( sal_Int32 nPara, xub_StrLen nPos ) :
        nStartPara( nPara ),
        nStartPos( nPos ),
        nEndPara( nPara ),
        nEndPos( nPos )
    {
    }
    ESelection( sal_Int32 nPara, sal_Int32 nPos )
        : nStartPara( nPara )
        , nStartPos( nPos )
        , nEndPara( nPara )
        , nEndPos( nPos )
        { }

    void    Adjust();
    bool    IsEqual( const ESelection& rS ) const;
@@ -185,15 +182,15 @@ inline bool ESelection::IsGreater( const ESelection& rS ) const

inline void ESelection::Adjust()
{
    sal_Bool bSwap = sal_False;
    bool bSwap = false;
    if ( nStartPara > nEndPara )
        bSwap = sal_True;
        bSwap = true;
    else if ( ( nStartPara == nEndPara ) && ( nStartPos > nEndPos ) )
        bSwap = sal_True;
        bSwap = true;

    if ( bSwap )
    {
        sal_Int32  nSPar = nStartPara; sal_uInt16 nSPos = nStartPos;
        sal_Int32  nSPar = nStartPara; sal_Int32 nSPos = nStartPos;
        nStartPara = nEndPara; nStartPos = nEndPos;
        nEndPara = nSPar; nEndPos = nSPos;
    }
@@ -206,7 +203,7 @@ struct EDITENG_DLLPUBLIC EFieldInfo
    EPosition       aPosition;

    EFieldInfo();
    EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_uInt16 nPos );
    EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_Int32 nPos );
    ~EFieldInfo();

    EFieldInfo( const EFieldInfo& );
@@ -275,8 +272,8 @@ struct EECharAttrib
    const SfxPoolItem*  pAttr;

    sal_Int32           nPara;
    xub_StrLen          nStart;
    xub_StrLen          nEnd;
    sal_Int32           nStart;
    sal_Int32           nEnd;
};

struct MoveParagraphsInfo
@@ -298,7 +295,7 @@ struct PasteOrDropInfos
    sal_Int32   nStartPara;
    sal_Int32   nEndPara;

    PasteOrDropInfos() : nAction(0), nStartPara(0xFFFFFFFF), nEndPara(0xFFFFFFFF)  {}
    PasteOrDropInfos() : nAction(0), nStartPara(-1), nEndPara(-1)  {}
};

enum EENotifyType
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx
index 77b9d53..090dc10 100644
--- a/include/editeng/editeng.hxx
+++ b/include/editeng/editeng.hxx
@@ -164,7 +164,7 @@ private:
        bool bAcceptStartOfWord = true);

    EDITENG_DLLPRIVATE long GetXPos(
        const ParaPortion* pParaPortion, const EditLine* pLine, sal_uInt16 nIndex, bool bPreferPortionStart = false) const;
        const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nIndex, bool bPreferPortionStart = false) const;

    EDITENG_DLLPRIVATE Range GetLineXPosStartEnd(
        const ParaPortion* pParaPortion, const EditLine* pLine) const;
@@ -196,23 +196,23 @@ public:
    MapMode         GetRefMapMode();

    void            SetUpdateMode( sal_Bool bUpdate );
    sal_Bool            GetUpdateMode() const;
    void                    SetUpdateModeForAcc( sal_Bool bUp);
    sal_Bool                GetUpdateModeForAcc( ) const;
    sal_Bool        GetUpdateMode() const;
    void            SetUpdateModeForAcc( sal_Bool bUp);
    sal_Bool        GetUpdateModeForAcc( ) const;

    void            SetBackgroundColor( const Color& rColor );
    Color           GetBackgroundColor() const;
    Color           GetAutoColor() const;
    void            EnableAutoColor( sal_Bool b );
    void            ForceAutoColor( sal_Bool b );
    sal_Bool            IsForceAutoColor() const;
    sal_Bool        IsForceAutoColor() const;

    void            InsertView(EditView* pEditView, size_t nIndex = EE_APPEND);
    EditView*       RemoveView( EditView* pEditView );
    EditView*       RemoveView(size_t nIndex = EE_APPEND);
    EditView*       GetView(size_t nIndex = 0) const;
    size_t          GetViewCount() const;
    sal_Bool            HasView( EditView* pView ) const;
    sal_Bool        HasView( EditView* pView ) const;
    EditView*       GetActiveView() const;
    void SetActiveView(EditView* pView);

@@ -227,9 +227,9 @@ public:
    void                        SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir );
    EEHorizontalTextDirection   GetDefaultHorizontalTextDirection() const;

    sal_uInt16          GetScriptType( const ESelection& rSelection ) const;
    sal_uInt16      GetScriptType( const ESelection& rSelection ) const;
    LanguageType    GetLanguage(const EditPaM& rPaM) const;
    LanguageType    GetLanguage( sal_Int32 nPara, sal_uInt16 nPos ) const;
    LanguageType    GetLanguage( sal_Int32 nPara, sal_Int32 nPos ) const;

    void            TransliterateText( const ESelection& rSelection, sal_Int32 nTransliterationMode );
    EditSelection   TransliterateText( const EditSelection& rSelection, sal_Int32 nTransliterationMode );
@@ -240,9 +240,9 @@ public:

    void            SetAddExtLeading( sal_Bool b );

    void                SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon );
    void                SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::B2DPolyPolygon* pLinePolyPolygon);
    void                ClearPolygon();
    void            SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon );
    void            SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::B2DPolyPolygon* pLinePolyPolygon);
    void            ClearPolygon();

    const Size&     GetMinAutoPaperSize() const;
    void            SetMinAutoPaperSize( const Size& rSz );
@@ -258,22 +258,22 @@ public:
    sal_uInt32      CalcTextWidth();

    OUString        GetText( sal_Int32 nParagraph ) const;
    xub_StrLen      GetTextLen( sal_Int32 nParagraph ) const;
    sal_Int32       GetTextLen( sal_Int32 nParagraph ) const;
    sal_uInt32      GetTextHeight( sal_Int32 nParagraph ) const;

    sal_Int32       GetParagraphCount() const;

    sal_uInt16      GetLineCount( sal_Int32 nParagraph ) const;
    xub_StrLen      GetLineLen( sal_Int32 nParagraph, sal_uInt16 nLine ) const;
    void            GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nParagraph, sal_uInt16 nLine ) const;
    sal_uInt16      GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nIndex ) const;
    sal_uInt32      GetLineHeight( sal_Int32 nParagraph, sal_uInt16 nLine = 0 );
    sal_Int32       GetLineCount( sal_Int32 nParagraph ) const;
    sal_Int32       GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const;
    void            GetLineBoundaries( /*out*/sal_Int32& rStart, /*out*/sal_Int32& rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const;
    sal_Int32       GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const;
    sal_uInt32      GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine = 0 );
    ParagraphInfos  GetParagraphInfos( sal_Int32 nPara );
    sal_Int32       FindParagraph( long nDocPosY );
    EPosition       FindDocPosition( const Point& rDocPos ) const;
    Rectangle       GetCharacterBounds( const EPosition& rPos ) const;

    OUString        GetWord(sal_Int32 nPara, xub_StrLen nIndex);
    OUString        GetWord(sal_Int32 nPara, sal_Int32 nIndex);

    ESelection      GetWord( const ESelection& rSelection, sal_uInt16 nWordType ) const;

@@ -296,7 +296,7 @@ public:

    void            GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const;

    SfxItemSet      GetAttribs( sal_Int32 nPara, sal_uInt16 nStart, sal_uInt16 nEnd, sal_uInt8 nFlags = 0xFF ) const;
    SfxItemSet      GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, sal_uInt8 nFlags = 0xFF ) const;
    SfxItemSet      GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib = EditEngineAttribs_All );

    sal_Bool        HasParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ) const;
@@ -317,7 +317,7 @@ public:
    sal_Bool        IsInUndo();

    void            EnableUndo( sal_Bool bEnable );
    sal_Bool            IsUndoEnabled();
    sal_Bool        IsUndoEnabled();

    /** returns the value last used for bTryMerge while calling ImpEditEngine::InsertUndo
        This is currently used in a bad but needed hack to get undo actions merged in the
@@ -326,20 +326,20 @@ public:

    void            ClearModifyFlag();
    void            SetModified();
    sal_Bool            IsModified() const;
    sal_Bool        IsModified() const;

    void            SetModifyHdl( const Link& rLink );
    Link            GetModifyHdl() const;

    sal_Bool            IsInSelectionMode() const;
    sal_Bool        IsInSelectionMode() const;

    void            StripPortions();
    void            GetPortions( sal_Int32 nPara, std::vector<sal_uInt16>& rList );
    void            GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList );

    long            GetFirstLineStartX( sal_Int32 nParagraph );
    Point           GetDocPosTopLeft( sal_Int32 nParagraph );
    Point           GetDocPos( const Point& rPaperPos ) const;
    sal_Bool            IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder = 0 );
    sal_Bool        IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder = 0 );

    // StartDocPos corrresponds to VisArea.TopLeft().
    void            Draw( OutputDevice* pOutDev, const Rectangle& rOutRect );
@@ -361,7 +361,7 @@ public:
    Link            GetImportHdl() const;

    // Do not evaluate font formatting => For Outliner
    sal_Bool            IsFlatMode() const;
    sal_Bool        IsFlatMode() const;
    void            SetFlatMode( sal_Bool bFlat );

    void            SetControlWord( sal_uInt32 nWord );
@@ -412,15 +412,15 @@ public:
    void            SetDefaultLanguage( LanguageType eLang );
    LanguageType    GetDefaultLanguage() const;

    sal_Bool            HasOnlineSpellErrors() const;
    sal_Bool        HasOnlineSpellErrors() const;
    void            CompleteOnlineSpelling();

    sal_Bool            ShouldCreateBigTextObject() const;
    sal_Bool        ShouldCreateBigTextObject() const;

    // For fast Pre-Test without view:
    EESpellState    HasSpellErrors();
    void ClearSpellErrors();
    sal_Bool            HasText( const SvxSearchItem& rSearchItem );
    sal_Bool        HasText( const SvxSearchItem& rSearchItem );

    //initialize sentence spelling
    void            StartSpelling(EditView& rEditView, sal_Bool bMultipleDoc);
@@ -462,8 +462,8 @@ public:
    virtual void    ParagraphHeightChanged( sal_Int32 nPara );

    virtual void DrawingText(
        const Point& rStartPos, const OUString& rText, sal_uInt16 nTextStart, sal_uInt16 nTextLen, const sal_Int32* pDXArray,
        const SvxFont& rFont, sal_Int32 nPara, xub_StrLen nIndex, sal_uInt8 nRightToLeft,
        const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, sal_Int32 nTextLen, const sal_Int32* pDXArray,
        const SvxFont& rFont, sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft,
        const EEngineData::WrongSpellVector* pWrongSpellVector,
        const SvxFieldData* pFieldData,
        bool bEndOfLine,
@@ -475,7 +475,7 @@ public:

    virtual void DrawingTab(
        const Point& rStartPos, long nWidth, const OUString& rChar,
        const SvxFont& rFont, sal_Int32 nPara, xub_StrLen nIndex, sal_uInt8 nRightToLeft,
        const SvxFont& rFont, sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft,
        bool bEndOfLine,
        bool bEndOfParagraph,
        const Color& rOverlineColor,
@@ -483,9 +483,9 @@ public:
    virtual OUString  GetUndoComment( sal_uInt16 nUndoId ) const;
    virtual sal_Bool    FormattingParagraph( sal_Int32 nPara );
    virtual sal_Bool    SpellNextDocument();
    virtual void    FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, xub_StrLen nPos );
    virtual void    FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, xub_StrLen nPos );
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, xub_StrLen nPos, Color*& rTxtColor, Color*& rFldColor );
    virtual void    FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos );
    virtual void    FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos );
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor );

    // to be overloaded if access to bullet information needs to be provided
    virtual const SvxNumberFormat * GetNumberFormat( sal_Int32 nPara ) const;
@@ -546,7 +546,7 @@ public:
        const EditPaM& rPaM, sal_uInt16 nCharacterIteratorMode = com::sun::star::i18n::CharacterIteratorMode::SKIPCELL);

    void SeekCursor(
        ContentNode* pNode, sal_uInt16 nPos, SvxFont& rFont, OutputDevice* pOut = NULL, sal_uInt16 nIgnoreWhich = 0);
        ContentNode* pNode, sal_Int32 nPos, SvxFont& rFont, OutputDevice* pOut = NULL, sal_uInt16 nIgnoreWhich = 0);

    EditPaM DeleteSelection(const EditSelection& rSel);

@@ -571,7 +571,7 @@ public:
    void UpdateSelections();

    void InsertContent(ContentNode* pNode, sal_Int32 nPos);
    EditPaM SplitContent(sal_Int32 nNode, sal_uInt16 nSepPos);
    EditPaM SplitContent(sal_Int32 nNode, sal_Int32 nSepPos);
    EditPaM ConnectContents(sal_Int32 nLeftNode, bool bBackward);

    EditPaM InsertFeature(const EditSelection& rEditSelection, const SfxPoolItem& rItem);
diff --git a/include/editeng/editstat.hxx b/include/editeng/editstat.hxx
index 59f5ae4..8fd9f40 100644
--- a/include/editeng/editstat.hxx
+++ b/include/editeng/editstat.hxx
@@ -90,10 +90,10 @@ class EditStatus
protected:
    sal_uLong   nStatusBits;
    sal_uLong   nControlBits;
    sal_uInt16  nPrevPara;                  // for EE_STAT_CRSRLEFTPARA
    sal_Int32   nPrevPara;                  // for EE_STAT_CRSRLEFTPARA

public:
            EditStatus()                { nStatusBits = 0; nControlBits = 0; nPrevPara = 0xFFFF; }
            EditStatus()                { nStatusBits = 0; nControlBits = 0; nPrevPara = -1; }

    void    Clear()                     { nStatusBits = 0; }
    void    SetControlBits( sal_uLong nMask, bool bOn )
@@ -105,8 +105,8 @@ public:
    sal_uLong   GetControlWord() const      { return nControlBits; }
    sal_uLong&  GetControlWord()            { return nControlBits; }

    sal_uInt16  GetPrevParagraph() const    { return nPrevPara; }
    sal_uInt16& GetPrevParagraph()          { return nPrevPara; }
    sal_Int32   GetPrevParagraph() const    { return nPrevPara; }
    sal_Int32&  GetPrevParagraph()          { return nPrevPara; }
};

#define SPELLCMD_IGNOREWORD         0x0001
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index 71339de..5b62c30 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -191,7 +191,7 @@ public:

    EESpellState    StartSpeller( sal_Bool bMultipleDoc = sal_False );
    EESpellState    StartThesaurus();
    sal_uInt16          StartSearchAndReplace( const SvxSearchItem& rSearchItem );
    sal_Int32       StartSearchAndReplace( const SvxSearchItem& rSearchItem );

    // for text conversion
    void            StartTextConversion( LanguageType nSrcLang, LanguageType nDestLang, const Font *pDestFont, sal_Int32 nOptions, sal_Bool bIsInteractive, sal_Bool bMultipleDoc );
@@ -202,13 +202,13 @@ public:
    sal_Bool        IsCursorAtWrongSpelledWord( sal_Bool bMarkIfWrong = sal_False );
    sal_Bool        IsWrongSpelledWordAtPos( const Point& rPosPixel, sal_Bool bMarkIfWrong = sal_False );
    sal_Bool        IsShapeParaFocusable();
    sal_Bool        WrongSpelledBreakPara(sal_Int32 nPara, sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nIndex);
    sal_Bool        WrongSpelledBreakPara(sal_Int32 nPara, sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nIndex);
    void            ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack = 0 );

    void                InsertField( const SvxFieldItem& rFld );
    const SvxFieldItem* GetFieldUnderMousePointer() const;
    const SvxFieldItem* GetFieldUnderMousePointer( sal_Int32& nPara, xub_StrLen& nPos ) const;
    const SvxFieldItem* GetField( const Point& rPos, sal_Int32* pnPara = NULL, xub_StrLen* pnPos = NULL ) const;
    const SvxFieldItem* GetFieldUnderMousePointer( sal_Int32& nPara, sal_Int32& nPos ) const;
    const SvxFieldItem* GetField( const Point& rPos, sal_Int32* pnPara = NULL, sal_Int32* pnPos = NULL ) const;

    const SvxFieldItem* GetFieldAtSelection() const;

diff --git a/include/editeng/eedata.hxx b/include/editeng/eedata.hxx
index 88a65af..38eff23 100644
--- a/include/editeng/eedata.hxx
+++ b/include/editeng/eedata.hxx
@@ -31,10 +31,10 @@ namespace EEngineData
    class WrongSpellClass
    {
    public:
        sal_uInt32 nStart;
        sal_uInt32 nEnd;
        sal_Int32 nStart;
        sal_Int32 nEnd;

        WrongSpellClass(sal_uInt32 nS, sal_uInt32 nE) : nStart(nS), nEnd(nE) {}
        WrongSpellClass(sal_Int32 nS, sal_Int32 nE) : nStart(nS), nEnd(nE) {}
    };

    typedef std::vector< WrongSpellClass > WrongSpellVector;
@@ -51,9 +51,9 @@ namespace EEngineData
    {
    public:
        TextMarkingType eType;
        sal_uInt32 nIndex;
        sal_Int32 nIndex;

        TextMarkingClass(TextMarkingType eT, sal_uInt32 nI) : eType(eT), nIndex(nI) {}
        TextMarkingClass(TextMarkingType eT, sal_Int32 nI) : eType(eT), nIndex(nI) {}
    };

    typedef std::vector< TextMarkingClass > TextMarkingVector;
diff --git a/include/editeng/misspellrange.hxx b/include/editeng/misspellrange.hxx
index 58c0935..2279f0f 100644
--- a/include/editeng/misspellrange.hxx
+++ b/include/editeng/misspellrange.hxx
@@ -18,19 +18,19 @@ namespace editeng {

struct EDITENG_DLLPUBLIC MisspellRange
{
    size_t mnStart;
    size_t mnEnd;
    sal_Int32 mnStart;
    sal_Int32 mnEnd;

    MisspellRange();
    MisspellRange(size_t nStart, size_t nEnd);
    MisspellRange(sal_Int32 nStart, sal_Int32 nEnd);
};

struct EDITENG_DLLPUBLIC MisspellRanges
{
    size_t mnParagraph;
    sal_Int32 mnParagraph;
    std::vector<MisspellRange> maRanges;

    MisspellRanges(size_t nParagraph, const std::vector<MisspellRange>& rRanges);
    MisspellRanges(sal_Int32 nParagraph, const std::vector<MisspellRange>& rRanges);
};

}
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 609c960..7d6e8ae 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -162,7 +162,7 @@ struct ParaRange
            ParaRange( sal_Int32 nS, sal_Int32 nE ) { nStartPara = nS, nEndPara = nE; }

    void    Adjust();
    sal_uInt16  Len() const { return 1 + ( ( nEndPara > nStartPara ) ? (nEndPara-nStartPara) : (nStartPara-nEndPara) ); }
    sal_Int32  Len() const { return 1 + ( ( nEndPara > nStartPara ) ? (nEndPara-nStartPara) : (nStartPara-nEndPara) ); }
};

inline void ParaRange::Adjust()
@@ -280,7 +280,7 @@ public:

    EESpellState    StartSpeller( sal_Bool bMultipleDoc = sal_False );
    EESpellState    StartThesaurus();
    sal_uInt16          StartSearchAndReplace( const SvxSearchItem& rSearchItem );
    sal_Int32          StartSearchAndReplace( const SvxSearchItem& rSearchItem );

    // for text conversion
    void            StartTextConversion( LanguageType nSrcLang, LanguageType nDestLang, const Font *pDestFont, sal_Int32 nOptions, sal_Bool bIsInteractive, sal_Bool bMultipleDoc );
@@ -368,10 +368,10 @@ class EDITENG_DLLPUBLIC DrawPortionInfo
public:
    const Point&        mrStartPos;
    const OUString      maText;
    sal_uInt16          mnTextStart;
    sal_uInt16          mnTextLen;
    sal_Int32           mnTextStart;
    sal_Int32           mnTextLen;
    sal_Int32           mnPara;
    xub_StrLen          mnIndex;
    sal_Int32           mnIndex;
    const SvxFont&      mrFont;
    const sal_Int32*    mpDXArray;

@@ -397,11 +397,11 @@ public:
    DrawPortionInfo(
        const Point& rPos,
        const OUString& rTxt,
        sal_uInt16 nTxtStart,
        sal_uInt16 nTxtLen,
        sal_Int32 nTxtStart,
        sal_Int32 nTxtLen,
        const SvxFont& rFnt,
        sal_Int32 nPar,
        xub_StrLen nIdx,
        sal_Int32 nIdx,
        const sal_Int32* pDXArr,
        const EEngineData::WrongSpellVector* pWrongSpellVector,
        const SvxFieldData* pFieldData,
@@ -481,8 +481,8 @@ private:
    OUString            aRepresentation;

    sal_Int32           nPara;
    xub_StrLen          nPos;
    sal_Bool                bSimpleClick;
    sal_Int32           nPos;
    sal_Bool            bSimpleClick;

                        EditFieldInfo();
                        EditFieldInfo( const EditFieldInfo& );
@@ -490,7 +490,7 @@ private:
    SdrPage*            mpSdrPage;

public:
                    EditFieldInfo( Outliner* pOutl, const SvxFieldItem& rFItem, sal_Int32 nPa, xub_StrLen nPo )
                    EditFieldInfo( Outliner* pOutl, const SvxFieldItem& rFItem, sal_Int32 nPa, sal_Int32 nPo )
                        : rFldItem( rFItem )
                    {
                        pOutliner = pOutl;
@@ -519,7 +519,7 @@ public:
                        { delete pFldColor; pFldColor = 0; }

    sal_Int32           GetPara() const { return nPara; }
    xub_StrLen          GetPos() const { return nPos; }
    sal_Int32           GetPos() const { return nPos; }

    sal_Bool            IsSimpleClick() const { return bSimpleClick; }
    void            SetSimpleClick( sal_Bool bSimple ) { bSimpleClick = bSimple; }
@@ -676,7 +676,7 @@ public:
    EEHorizontalTextDirection   GetDefaultHorizontalTextDirection() const;

    sal_uInt16          GetScriptType( const ESelection& rSelection ) const;
    LanguageType    GetLanguage( sal_Int32 nPara, sal_uInt16 nPos ) const;
    LanguageType    GetLanguage( sal_Int32 nPara, sal_Int32 nPos ) const;

    void            SetAsianCompressionMode( sal_uInt16 nCompressionMode );

@@ -832,13 +832,13 @@ public:

    void        SetWordDelimiters( const OUString& rDelimiters );
    OUString    GetWordDelimiters() const;
    OUString    GetWord( sal_Int32 nPara, xub_StrLen nIndex );
    OUString    GetWord( sal_Int32 nPara, sal_Int32 nIndex );

    void            StripPortions();

    virtual void DrawingText(
        const Point& rStartPos, const OUString& rText, sal_uInt16 nTextStart, sal_uInt16 nTextLen,
        const sal_Int32* pDXArray, const SvxFont& rFont, sal_Int32 nPara, xub_StrLen nIndex, sal_uInt8 nRightToLeft,
        const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, sal_Int32 nTextLen,
        const sal_Int32* pDXArray, const SvxFont& rFont, sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft,
        const EEngineData::WrongSpellVector* pWrongSpellVector,
        const SvxFieldData* pFieldData,
        bool bEndOfLine,
@@ -850,7 +850,7 @@ public:

    virtual void DrawingTab(
        const Point& rStartPos, long nWidth, const OUString& rChar,
        const SvxFont& rFont, sal_Int32 nPara, xub_StrLen nIndex, sal_uInt8 nRightToLeft,
        const SvxFont& rFont, sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft,
        bool bEndOfLine,
        bool bEndOfParagraph,
        const Color& rOverlineColor,
@@ -891,8 +891,8 @@ public:
    void            SetEndMovingHdl( const Link& rLink){aEndMovingHdl=rLink;}

    sal_uLong           GetLineCount( sal_Int32 nParagraph ) const;
    sal_uInt16          GetLineLen( sal_Int32 nParagraph, sal_uInt16 nLine ) const;
    sal_uLong           GetLineHeight( sal_Int32 nParagraph, sal_uInt16 nLine = 0 );
    sal_Int32           GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const;
    sal_uLong           GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine = 0 );

    sal_uLong           Read( SvStream& rInput, const OUString& rBaseURL, sal_uInt16, SvKeyValueIterator* pHTTPHeaderAttrs = NULL );

@@ -912,9 +912,9 @@ public:
    sal_Bool            UpdateFields();
    void            RemoveFields( sal_Bool bKeepFieldText, TypeId aType = NULL );

    virtual void    FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, xub_StrLen nPos );
    virtual void    FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, xub_StrLen nPos );
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, xub_StrLen nPos, Color*& rTxtColor, Color*& rFldColor );
    virtual void    FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos );
    virtual void    FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos );
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor );

    void            SetSpeller( ::com::sun::star::uno::Reference<
                            ::com::sun::star::linguistic2::XSpellChecker1 > &xSpeller );
diff --git a/include/editeng/section.hxx b/include/editeng/section.hxx
index ea9ed19..b9f6c37 100644
--- a/include/editeng/section.hxx
+++ b/include/editeng/section.hxx
@@ -20,14 +20,14 @@ namespace editeng {

struct EDITENG_DLLPUBLIC Section
{
    size_t mnParagraph;
    size_t mnStart;
    size_t mnEnd;
    sal_Int32 mnParagraph;
    sal_Int32 mnStart;
    sal_Int32 mnEnd;

    std::vector<const SfxPoolItem*> maAttributes;

    Section();
    Section(size_t nPara, size_t nStart, size_t nEnd);
    Section(sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd);
};

}
diff --git a/include/editeng/svxrtf.hxx b/include/editeng/svxrtf.hxx
index c5f9cc1..74ff45f 100644
--- a/include/editeng/svxrtf.hxx
+++ b/include/editeng/svxrtf.hxx
@@ -69,7 +69,7 @@ public:
    virtual ~SvxPosition() {}

    virtual sal_Int32   GetNodeIdx() const = 0;
    virtual xub_StrLen  GetCntIdx() const = 0;
    virtual sal_Int32   GetCntIdx() const = 0;

    virtual SvxPosition* Clone() const = 0; // Cloning itself
    virtual SvxNodeIdx* MakeNodeIdx() const = 0; // Cloning NodeIndex
@@ -275,7 +275,7 @@ protected:
    virtual void InsertText() = 0;
    virtual void MovePos( int bForward = sal_True ) = 0;
    virtual void SetEndPrevPara( SvxNodeIdx*& rpNodePos,
                                 xub_StrLen& rCntPos )=0;
                                 sal_Int32& rCntPos )=0;
    virtual void SetAttrInDoc( SvxRTFItemStackType &rSet );
    // for Tokens, which are not evaluated in ReadAttr
    virtual void UnknownAttrToken( int nToken, SfxItemSet* pSet );
@@ -328,7 +328,7 @@ public:
    inline const Color& GetColor( size_t nId ) const;
    const Font& GetFont( sal_uInt16 nId );      // Changes the dflt Font

    virtual bool IsEndPara( SvxNodeIdx* pNd, xub_StrLen nCnt ) const = 0;
    virtual bool IsEndPara( SvxNodeIdx* pNd, sal_Int32 nCnt ) const = 0;

    // to det a different attribute pool. May only be done prior to CallParser!
    // The maps are not generated anew!
@@ -359,7 +359,7 @@ class EDITENG_DLLPUBLIC SvxRTFItemStackType

    SfxItemSet  aAttrSet;
    SvxNodeIdx  *pSttNd, *pEndNd;
    xub_StrLen nSttCnt, nEndCnt;
    sal_Int32 nSttCnt, nEndCnt;
    SvxRTFItemStackList* pChildList;
    sal_uInt16 nStyleNo;

@@ -387,8 +387,8 @@ public:
    const SvxNodeIdx& GetSttNode() const { return *pSttNd; }
    const SvxNodeIdx& GetEndNode() const { return *pEndNd; }

    xub_StrLen GetSttCnt() const { return nSttCnt; }
    xub_StrLen GetEndCnt() const { return nEndCnt; }
    sal_Int32 GetSttCnt() const { return nSttCnt; }
    sal_Int32 GetEndCnt() const { return nEndCnt; }

          SfxItemSet& GetAttrSet()          { return aAttrSet; }
    const SfxItemSet& GetAttrSet() const    { return aAttrSet; }
diff --git a/include/editeng/unoedhlp.hxx b/include/editeng/unoedhlp.hxx
index 8f70e2f..8184561 100644
--- a/include/editeng/unoedhlp.hxx
+++ b/include/editeng/unoedhlp.hxx
@@ -100,7 +100,7 @@ public:

        @return sal_True, if the range has been successfully determined
     */
     static sal_Bool GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, const EditEngine& rEE, sal_Int32 nPara, sal_uInt16 nIndex, sal_Bool bInCell = sal_False);
     static sal_Bool GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, const EditEngine& rEE, sal_Int32 nPara, sal_Int32 nIndex, sal_Bool bInCell = sal_False);

    /** Convert point from edit engine to user coordinate space

diff --git a/include/editeng/unoedprx.hxx b/include/editeng/unoedprx.hxx
index dde5c06..c2b877c 100644
--- a/include/editeng/unoedprx.hxx
+++ b/include/editeng/unoedprx.hxx
@@ -34,13 +34,13 @@ public:
    virtual ~SvxAccessibleTextAdapter();

    virtual sal_Int32       GetParagraphCount() const;
    virtual sal_uInt16      GetTextLen( sal_Int32 nParagraph ) const;
    virtual sal_Int32       GetTextLen( sal_Int32 nParagraph ) const;
    virtual OUString        GetText( const ESelection& rSel ) const;
    virtual SfxItemSet      GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib = 0 ) const;
    virtual SfxItemSet      GetParaAttribs( sal_Int32 nPara ) const;
    virtual void            SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet );
    virtual void            RemoveAttribs( const ESelection& rSelection, sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich );
    virtual void            GetPortions( sal_Int32 nPara, std::vector<sal_uInt16>& rList ) const;
    virtual void            GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList ) const;

    virtual sal_uInt16          CalcEditEngineIndex( sal_Int32 nPara, sal_Int32 nLogicalIndex );

@@ -54,28 +54,28 @@ public:

    virtual SfxItemPool*    GetPool() const;

    virtual OUString        CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor );
    virtual void            FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, xub_StrLen nPos );
    virtual OUString        CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor );
    virtual void            FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos );

    virtual sal_Bool            IsValid() const;

    virtual LanguageType    GetLanguage( sal_Int32, sal_uInt16 ) const;
    virtual sal_uInt16          GetFieldCount( sal_Int32 nPara ) const;
    virtual LanguageType    GetLanguage( sal_Int32, sal_Int32 ) const;
    virtual sal_Int32       GetFieldCount( sal_Int32 nPara ) const;
    virtual EFieldInfo      GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const;
    virtual EBulletInfo     GetBulletInfo( sal_Int32 nPara ) const;
    virtual Rectangle       GetCharBounds( sal_Int32 nPara, sal_uInt16 nIndex ) const;
    virtual Rectangle       GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const;
    virtual Rectangle       GetParaBounds( sal_Int32 nPara ) const;
    virtual MapMode         GetMapMode() const;
    virtual OutputDevice*   GetRefDevice() const;
    virtual sal_Bool        GetIndexAtPoint( const Point&, sal_Int32& nPara, sal_uInt16& nIndex ) const;
    virtual sal_Bool        GetWordIndices( sal_Int32 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const;
    virtual sal_Bool        GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nPara, sal_uInt16 nIndex, sal_Bool bInCell = sal_False ) const;
    virtual sal_uInt16      GetLineCount( sal_Int32 nPara ) const;
    virtual sal_uInt16      GetLineLen( sal_Int32 nPara, sal_uInt16 nLine ) const;
    virtual sal_Bool        GetIndexAtPoint( const Point&, sal_Int32& nPara, sal_Int32& nIndex ) const;
    virtual sal_Bool        GetWordIndices( sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart, sal_Int32& nEnd ) const;
    virtual sal_Bool        GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, sal_Bool bInCell = sal_False ) const;
    virtual sal_Int32       GetLineCount( sal_Int32 nPara ) const;
    virtual sal_Int32       GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const;
    virtual void            SetUpdateModeForAcc( sal_Bool bUp);
    virtual sal_Bool        GetUpdateModeForAcc() const;
    virtual void            GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nParagraph, sal_uInt16 nLine ) const;
    virtual sal_uInt16      GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nIndex ) const;
    virtual void            GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const;
    virtual sal_Int32       GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const;

    virtual sal_Bool        Delete( const ESelection& );
    virtual sal_Bool        InsertText( const OUString&, const ESelection& );
@@ -88,7 +88,7 @@ public:
    // implementation functions for XParagraphAppend and XTextPortionAppend
    // (not needed for accessibility, only for new import API)
    virtual void        AppendParagraph();
    virtual sal_uInt16  AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet );
    virtual sal_Int32   AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet );

    //XTextCopy
    virtual void        CopyText(const SvxTextForwarder& rSource);
diff --git a/include/editeng/unoedsrc.hxx b/include/editeng/unoedsrc.hxx
index d99f532..1b89fcc 100644
--- a/include/editeng/unoedsrc.hxx
+++ b/include/editeng/unoedsrc.hxx
@@ -140,13 +140,13 @@ public:
    virtual             ~SvxTextForwarder();

    virtual sal_Int32   GetParagraphCount() const = 0;
    virtual sal_uInt16  GetTextLen( sal_Int32 nParagraph ) const = 0;
    virtual sal_Int32  GetTextLen( sal_Int32 nParagraph ) const = 0;
    virtual OUString    GetText( const ESelection& rSel ) const = 0;
    virtual SfxItemSet  GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib = 0 ) const = 0;
    virtual SfxItemSet  GetParaAttribs( sal_Int32 nPara ) const = 0;
    virtual void        SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet ) = 0;
    virtual void        RemoveAttribs( const ESelection& rSelection, sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich ) = 0;
    virtual void        GetPortions( sal_Int32 nPara, std::vector<sal_uInt16>& rList ) const = 0;
    virtual void        GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList ) const = 0;

    virtual sal_uInt16      GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const = 0;
    virtual sal_uInt16      GetItemState( sal_Int32 nPara, sal_uInt16 nWhich ) const = 0;
@@ -156,8 +156,8 @@ public:
    virtual void        QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ) = 0;
    virtual void        QuickInsertLineBreak( const ESelection& rSel ) = 0;

    virtual OUString    CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor ) = 0;
    virtual void         FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, xub_StrLen nPos ) = 0;
    virtual OUString    CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor ) = 0;
    virtual void         FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos ) = 0;

    virtual SfxItemPool* GetPool() const = 0;

@@ -165,7 +165,7 @@ public:

    // implementation functions for XParagraphAppend and XTextPortionAppend
    virtual void        AppendParagraph() = 0;
    virtual sal_uInt16  AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet ) = 0;
    virtual sal_Int32  AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet ) = 0;

    // XTextCopy
    virtual void        CopyText(const SvxTextForwarder& rSource) = 0;
@@ -184,14 +184,14 @@ public:
        @param nIndex[0 .. m-1]
        Index of character to query language of
     */
    virtual LanguageType    GetLanguage( sal_Int32 nPara, sal_uInt16 nIndex ) const = 0;
    virtual LanguageType    GetLanguage( sal_Int32 nPara, sal_Int32 nIndex ) const = 0;

    /** Query number of fields in the underlying edit engine

        @param nPara[0 .. n-1]
        Index of paragraph to query field number in
     */
    virtual sal_uInt16          GetFieldCount( sal_Int32 nPara ) const = 0;
    virtual sal_Int32          GetFieldCount( sal_Int32 nPara ) const = 0;

    /** Query information for given field number in the underlying edit engine

@@ -235,7 +235,7 @@ public:
        left corner of text. The coordinates returned here are to be
        interpreted in the map mode given by GetMapMode().
    */
    virtual Rectangle       GetCharBounds( sal_Int32 nPara, sal_uInt16 nIndex ) const = 0;
    virtual Rectangle       GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const = 0;

    /** Query the bounding rectangle of the given paragraph

@@ -283,7 +283,7 @@ public:
        @return sal_True, if the point is over any text and both rPara and rIndex are valid

     */
    virtual sal_Bool        GetIndexAtPoint( const Point& rPoint, sal_Int32& rPara, sal_uInt16& rIndex ) const = 0;
    virtual sal_Bool        GetIndexAtPoint( const Point& rPoint, sal_Int32& rPara, sal_Int32& rIndex ) const = 0;

    /** Get the start and the end index of the word at the given index

@@ -308,7 +308,7 @@ public:

        @return sal_True, if the result is non-empty
     */
    virtual sal_Bool        GetWordIndices( sal_Int32 nPara, sal_uInt16 nIndex, sal_uInt16& rStart, sal_uInt16& rEnd ) const = 0;
    virtual sal_Bool        GetWordIndices( sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& rStart, sal_Int32& rEnd ) const = 0;

    /** Query range of similar attributes

@@ -325,7 +325,7 @@ public:

        @return sal_True, if the range has been successfully determined
     */
    virtual sal_Bool        GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nPara, sal_uInt16 nIndex, sal_Bool bInCell = sal_False ) const = 0;
    virtual sal_Bool        GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, sal_Bool bInCell = sal_False ) const = 0;

    /** Query number of lines in the formatted paragraph

@@ -335,7 +335,7 @@ public:
        @return number of lines in given paragraph

     */
    virtual sal_uInt16          GetLineCount( sal_Int32 nPara ) const = 0;
    virtual sal_Int32          GetLineCount( sal_Int32 nPara ) const = 0;

    /** Query line length

@@ -346,7 +346,7 @@ public:
        Index of line in paragraph to query line length of

     */
    virtual sal_uInt16          GetLineLen( sal_Int32 nPara, sal_uInt16 nLine ) const = 0;
    virtual sal_Int32         GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const = 0;

    /** Query bounds of line in paragraph

@@ -363,7 +363,7 @@ public:
        Index of line in paragraph to query line length of

     */
    virtual void            GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nParagraph, sal_uInt16 nLine ) const = 0;
    virtual void            GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const = 0;

    /** Query the line number for a index in the paragraphs text

@@ -376,7 +376,7 @@ public:
        @returns [0 .. k-1]
        The line number of the chara in the paragraph
     */
    virtual sal_uInt16          GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nIndex ) const = 0;
    virtual sal_Int32          GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const = 0;

    /** Delete given text range and reformat text

@@ -432,8 +432,8 @@ public:
     */
    virtual sal_Bool        SetDepth( sal_Int32 nPara, sal_Int16 nNewDepth ) = 0;

    virtual sal_Int16 GetNumberingStartValue( sal_Int32 nPara );
    virtual void SetNumberingStartValue( sal_Int32 nPara, sal_Int16 nNumberingStartValue );
    virtual sal_Int32 GetNumberingStartValue( sal_Int32 nPara );
    virtual void SetNumberingStartValue( sal_Int32 nPara, sal_Int32 nNumberingStartValue );

    virtual sal_Bool IsParaIsNumberingRestart( sal_Int32 nPara );
    virtual void SetParaIsNumberingRestart( sal_Int32 nPara, sal_Bool bParaIsNumberingRestart );
@@ -538,7 +538,7 @@ public:

    virtual sal_Bool IsWrongSpelledWordAtPos( sal_Int32, sal_Int32 ) { return sal_False; };
    virtual sal_Bool IsShapeParaFocusable( ) { return sal_True; };
    virtual sal_Bool BreakParaWrongList(sal_Int32, sal_uInt16&, sal_uInt16&, sal_Int32){ return sal_False; };
    virtual sal_Bool BreakParaWrongList(sal_Int32, sal_Int32&, sal_Int32&, sal_Int32){ return sal_False; };
};

#endif
diff --git a/include/editeng/unofored.hxx b/include/editeng/unofored.hxx
index 69f5f3f..b726925 100644
--- a/include/editeng/unofored.hxx
+++ b/include/editeng/unofored.hxx
@@ -36,13 +36,13 @@ public:
    virtual             ~SvxEditEngineForwarder();

    virtual sal_Int32   GetParagraphCount() const;
    virtual sal_uInt16  GetTextLen( sal_Int32 nParagraph ) const;
    virtual sal_Int32   GetTextLen( sal_Int32 nParagraph ) const;
    virtual OUString    GetText( const ESelection& rSel ) const;
    virtual SfxItemSet  GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib = EditEngineAttribs_All ) const;
    virtual SfxItemSet  GetParaAttribs( sal_Int32 nPara ) const;
    virtual void        SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet );
    virtual void        RemoveAttribs( const ESelection& rSelection, sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich );
    virtual void        GetPortions( sal_Int32 nPara, std::vector<sal_uInt16>& rList ) const;
    virtual void        GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList ) const;

    virtual sal_uInt16      GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const;
    virtual sal_uInt16      GetItemState( sal_Int32 nPara, sal_uInt16 nWhich ) const;
@@ -54,25 +54,25 @@ public:

    virtual SfxItemPool* GetPool() const;

    virtual OUString     CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor );
    virtual void         FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, xub_StrLen nPos );
    virtual OUString     CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor );
    virtual void         FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos );
    virtual sal_Bool         IsValid() const;

    virtual LanguageType    GetLanguage( sal_Int32, sal_uInt16 ) const;
    virtual sal_uInt16      GetFieldCount( sal_Int32 nPara ) const;
    virtual LanguageType    GetLanguage( sal_Int32, sal_Int32 ) const;
    virtual sal_Int32       GetFieldCount( sal_Int32 nPara ) const;
    virtual EFieldInfo      GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const;
    virtual EBulletInfo     GetBulletInfo( sal_Int32 nPara ) const;
    virtual Rectangle       GetCharBounds( sal_Int32 nPara, sal_uInt16 nIndex ) const;
    virtual Rectangle       GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const;
    virtual Rectangle       GetParaBounds( sal_Int32 nPara ) const;
    virtual MapMode         GetMapMode() const;
    virtual OutputDevice*   GetRefDevice() const;
    virtual sal_Bool        GetIndexAtPoint( const Point&, sal_Int32& nPara, sal_uInt16& nIndex ) const;
    virtual sal_Bool        GetWordIndices( sal_Int32 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const;
    virtual sal_Bool        GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nPara, sal_uInt16 nIndex, sal_Bool bInCell = sal_False ) const;
    virtual sal_uInt16          GetLineCount( sal_Int32 nPara ) const;
    virtual sal_uInt16          GetLineLen( sal_Int32 nPara, sal_uInt16 nLine ) const;
    virtual void            GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nParagraph, sal_uInt16 nLine ) const;
    virtual sal_uInt16          GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nIndex ) const;
    virtual sal_Bool        GetIndexAtPoint( const Point&, sal_Int32& nPara, sal_Int32& nIndex ) const;
    virtual sal_Bool        GetWordIndices( sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart, sal_Int32& nEnd ) const;
    virtual sal_Bool        GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, sal_Bool bInCell = sal_False ) const;
    virtual sal_Int32          GetLineCount( sal_Int32 nPara ) const;
    virtual sal_Int32          GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const;
    virtual void            GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const;
    virtual sal_Int32          GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const;
    virtual sal_Bool        Delete( const ESelection& );
    virtual sal_Bool        InsertText( const OUString&, const ESelection& );
    virtual sal_Bool        QuickFormatDoc( sal_Bool bFull=sal_False );
@@ -83,7 +83,7 @@ public:

    // implementation functions for XParagraphAppend and XTextPortionAppend
    virtual void        AppendParagraph();
    virtual sal_uInt16  AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet );
    virtual sal_Int32  AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet );
    //XTextCopy
    virtual void        CopyText(const SvxTextForwarder& rSource);
};
diff --git a/include/editeng/unoforou.hxx b/include/editeng/unoforou.hxx
index b882be9..ae7e912 100644
--- a/include/editeng/unoforou.hxx
+++ b/include/editeng/unoforou.hxx
@@ -54,13 +54,13 @@ public:
    virtual             ~SvxOutlinerForwarder();

    virtual sal_Int32   GetParagraphCount() const;
    virtual sal_uInt16  GetTextLen( sal_Int32 nParagraph ) const;
    virtual sal_Int32   GetTextLen( sal_Int32 nParagraph ) const;
    virtual OUString    GetText( const ESelection& rSel ) const;
    virtual SfxItemSet  GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib = 0 ) const;
    virtual SfxItemSet  GetParaAttribs( sal_Int32 nPara ) const;
    virtual void        SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet );
    virtual void        RemoveAttribs( const ESelection& rSelection, sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich );
    virtual void        GetPortions( sal_Int32 nPara, std::vector<sal_uInt16>& rList ) const;
    virtual void        GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList ) const;

    virtual sal_uInt16      GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const;
    virtual sal_uInt16      GetItemState( sal_Int32 nPara, sal_uInt16 nWhich ) const;
@@ -72,35 +72,35 @@ public:

    virtual SfxItemPool* GetPool() const;

    virtual OUString    CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor );
    virtual void         FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, xub_StrLen nPos );
    virtual OUString    CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor );
    virtual void         FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos );

    virtual sal_Bool        IsValid() const;

    Outliner&           GetOutliner() const { return rOutliner; }

    virtual LanguageType    GetLanguage( sal_Int32, sal_uInt16 ) const;
    virtual sal_uInt16          GetFieldCount( sal_Int32 nPara ) const;
    virtual LanguageType    GetLanguage( sal_Int32, sal_Int32 ) const;
    virtual sal_Int32          GetFieldCount( sal_Int32 nPara ) const;
    virtual EFieldInfo      GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const;
    virtual EBulletInfo     GetBulletInfo( sal_Int32 nPara ) const;
    virtual Rectangle       GetCharBounds( sal_Int32 nPara, sal_uInt16 nIndex ) const;
    virtual Rectangle       GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const;
    virtual Rectangle       GetParaBounds( sal_Int32 nPara ) const;
    virtual MapMode         GetMapMode() const;
    virtual OutputDevice*   GetRefDevice() const;
    virtual sal_Bool        GetIndexAtPoint( const Point&, sal_Int32& nPara, sal_uInt16& nIndex ) const;
    virtual sal_Bool        GetWordIndices( sal_Int32 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const;
    virtual sal_Bool        GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nPara, sal_uInt16 nIndex, sal_Bool bInCell = sal_False ) const;
    virtual sal_uInt16          GetLineCount( sal_Int32 nPara ) const;
    virtual sal_uInt16          GetLineLen( sal_Int32 nPara, sal_uInt16 nLine ) const;
    virtual void            GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nPara, sal_uInt16 nLine ) const;
    virtual sal_uInt16          GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nIndex ) const;
    virtual sal_Bool        GetIndexAtPoint( const Point&, sal_Int32& nPara, sal_Int32& nIndex ) const;
    virtual sal_Bool        GetWordIndices( sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart, sal_Int32& nEnd ) const;
    virtual sal_Bool        GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, sal_Bool bInCell = sal_False ) const;
    virtual sal_Int32          GetLineCount( sal_Int32 nPara ) const;
    virtual sal_Int32          GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const;
    virtual void            GetLineBoundaries( /*out*/sal_Int32& rStart, /*out*/sal_Int32& rEnd, sal_Int32 nPara, sal_Int32 nLine ) const;
    virtual sal_Int32          GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const;
    virtual sal_Bool        Delete( const ESelection& );
    virtual sal_Bool        InsertText( const OUString&, const ESelection& );
    virtual sal_Bool        QuickFormatDoc( sal_Bool bFull=sal_False );
    virtual sal_Int16       GetDepth( sal_Int32 nPara ) const;
    virtual sal_Bool        SetDepth( sal_Int32 nPara, sal_Int16 nNewDepth );
    virtual sal_Int16       GetNumberingStartValue( sal_Int32 nPara );
    virtual void            SetNumberingStartValue( sal_Int32 nPara, sal_Int16 nNumberingStartValue );
    virtual sal_Int32       GetNumberingStartValue( sal_Int32 nPara );
    virtual void            SetNumberingStartValue( sal_Int32 nPara, sal_Int32 nNumberingStartValue );

    virtual sal_Bool        IsParaIsNumberingRestart( sal_Int32 nPara );
    virtual void            SetParaIsNumberingRestart( sal_Int32 nPara, sal_Bool bParaIsNumberingRestart );
@@ -112,7 +112,7 @@ public:

    // implementation functions for XParagraphAppend and XTextPortionAppend
    virtual void        AppendParagraph();
    virtual sal_uInt16  AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet );
    virtual sal_Int32   AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet );
    //XTextCopy
    virtual void        CopyText(const SvxTextForwarder& rSource);
};
diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx
index da054cd..02b47d6 100644
--- a/include/editeng/unotext.hxx
+++ b/include/editeng/unotext.hxx
@@ -173,13 +173,13 @@ public:

    // SvxTextForwarder
    virtual sal_Int32       GetParagraphCount() const;
    virtual sal_uInt16      GetTextLen( sal_Int32 nParagraph ) const;
    virtual sal_Int32       GetTextLen( sal_Int32 nParagraph ) const;
    virtual OUString        GetText( const ESelection& rSel ) const;
    virtual SfxItemSet      GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib = 0 ) const;
    virtual SfxItemSet      GetParaAttribs( sal_Int32 nPara ) const;
    virtual void            SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet );
    virtual void            RemoveAttribs( const ESelection& rSelection, sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich );
    virtual void            GetPortions( sal_Int32 nPara, std::vector<sal_uInt16>& rList ) const;
    virtual void            GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList ) const;

    sal_uInt16              GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const;
    sal_uInt16              GetItemState( sal_Int32 nPara, sal_uInt16 nWhich ) const;
@@ -191,27 +191,27 @@ public:
    virtual void            QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel );
    virtual void            QuickInsertLineBreak( const ESelection& rSel );

    virtual OUString        CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor );
    virtual void            FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, xub_StrLen nPos );
    virtual OUString        CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor );
    virtual void            FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos );

    virtual sal_Bool        IsValid() const;

    virtual void            SetNotifyHdl( const Link& );
    virtual LanguageType    GetLanguage( sal_Int32, sal_uInt16 ) const;
    virtual sal_uInt16      GetFieldCount( sal_Int32 nPara ) const;
    virtual LanguageType    GetLanguage( sal_Int32, sal_Int32 ) const;
    virtual sal_Int32       GetFieldCount( sal_Int32 nPara ) const;
    virtual EFieldInfo      GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const;
    virtual EBulletInfo     GetBulletInfo( sal_Int32 nPara ) const;
    virtual Rectangle       GetCharBounds( sal_Int32 nPara, sal_uInt16 nIndex ) const;
    virtual Rectangle       GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const;
    virtual Rectangle       GetParaBounds( sal_Int32 nPara ) const;
    virtual MapMode         GetMapMode() const;
    virtual OutputDevice*   GetRefDevice() const;
    virtual sal_Bool        GetIndexAtPoint( const Point&, sal_Int32& nPara, sal_uInt16& nIndex ) const;
    virtual sal_Bool        GetWordIndices( sal_Int32 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const;
    virtual sal_Bool        GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nPara, sal_uInt16 nIndex, sal_Bool bInCell = sal_False ) const;
    virtual sal_uInt16      GetLineCount( sal_Int32 nPara ) const;
    virtual sal_uInt16      GetLineLen( sal_Int32 nPara, sal_uInt16 nLine ) const;
    virtual void            GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nParagraph, sal_uInt16 nLine ) const;
    virtual sal_uInt16      GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nIndex ) const;
    virtual sal_Bool        GetIndexAtPoint( const Point&, sal_Int32& nPara, sal_Int32& nIndex ) const;
    virtual sal_Bool        GetWordIndices( sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart, sal_Int32& nEnd ) const;
    virtual sal_Bool        GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, sal_Bool bInCell = sal_False ) const;
    virtual sal_Int32       GetLineCount( sal_Int32 nPara ) const;
    virtual sal_Int32       GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const;
    virtual void            GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const;
    virtual sal_Int32       GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const;
    virtual sal_Bool        Delete( const ESelection& );
    virtual sal_Bool        InsertText( const OUString&, const ESelection& );
    virtual sal_Bool        QuickFormatDoc( sal_Bool bFull=sal_False );
@@ -222,7 +222,7 @@ public:

    // implementation functions for XParagraphAppend and XTextPortionAppend
    virtual void        AppendParagraph();
    virtual sal_uInt16  AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet );
    virtual sal_Int32   AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet );
    //XTextCopy
    virtual void        CopyText(const SvxTextForwarder& rSource);
};
@@ -583,7 +583,7 @@ private:
    ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > mxParentText;
    const SvxUnoTextBase&    mrParentText;
    sal_Int32                mnParagraph;
    std::vector<sal_uInt16>* mpPortions;
    std::vector<sal_Int32>*  mpPortions;
    sal_uInt16               mnNextPortion;

public:
diff --git a/include/formula/token.hxx b/include/formula/token.hxx
index 002cefb..b72897d 100644
--- a/include/formula/token.hxx
+++ b/include/formula/token.hxx
@@ -178,9 +178,9 @@ public:
    struct PrivateAccess { friend class FormulaCompiler; private: PrivateAccess() { }  };
    inline  void                NewOpCode( OpCode e, const PrivateAccess&  ) { eOp = e; }

    static  size_t              GetStrLenBytes( xub_StrLen nLen )
    static  sal_Int32           GetStrLenBytes( sal_Int32 nLen )
                                    { return nLen * sizeof(sal_Unicode); }
    static  size_t              GetStrLenBytes( const OUString& rStr )
    static  sal_Int32           GetStrLenBytes( const OUString& rStr )
                                    { return GetStrLenBytes( rStr.getLength() ); }
};

diff --git a/include/svx/svdoutl.hxx b/include/svx/svdoutl.hxx
index 4067c82..0c650ec 100644
--- a/include/svx/svdoutl.hxx
+++ b/include/svx/svdoutl.hxx
@@ -44,7 +44,7 @@ public:
    void setVisualizedPage(const SdrPage* pPage) { if(pPage != mpVisualizedPage) mpVisualizedPage = pPage; }
    const SdrPage* getVisualizedPage() const { return mpVisualizedPage; }

    virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor);
    virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor);
};

#endif // INCLUDED_SVX_SVDOUTL_HXX
diff --git a/include/tools/solar.h b/include/tools/solar.h
index 914f0de..f1ac0a7 100644
--- a/include/tools/solar.h
+++ b/include/tools/solar.h
@@ -115,8 +115,6 @@ inline void     DoubleToSVBT64( double n, SVBT64 p ) { p[0] = ((sal_uInt8*)&n)[7
#pragma warning(error : 4002 4003)
#endif

#define xub_StrLen      sal_uInt16

#if defined WNT
#define SVLIBRARY( Base ) Base "lo.dll"
#elif defined MACOSX
diff --git a/include/tools/string.hxx b/include/tools/string.hxx
deleted file mode 100644
index 6572bbc..0000000
--- a/include/tools/string.hxx
+++ /dev/null
@@ -1,31 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef _STRING_HXX
#define _STRING_HXX

/*******************************************************************************
 * THIS CODE IS DEPRECATED.  DO NOT USE IT IN ANY NEW CODE.
 ******************************************************************************/

#define STRING_MAXLEN      ((xub_StrLen)0xFFFF)

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 34cef91..c64ea91 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -467,7 +467,7 @@ public:
    void        CompileColRowNameFormula();

    sal_Int32   GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const;
    xub_StrLen  GetMaxNumberStringLen( sal_uInt16& nPrecision,
    sal_Int32   GetMaxNumberStringLen( sal_uInt16& nPrecision,
                                       SCROW nRowStart, SCROW nRowEnd ) const;

    sal_uInt16 GetTextWidth(SCROW nRow) const;
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 0a1763b..e258532 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -190,8 +190,8 @@ public:
    formula::FormulaToken* CreateToken() const;   // create typified token
    void Load( SvStream&, sal_uInt16 nVer );

    static xub_StrLen GetStrLen( const sal_Unicode* pStr ); // as long as a "string" is an array
    static size_t GetStrLenBytes( xub_StrLen nLen )
    static sal_Int32 GetStrLen( const sal_Unicode* pStr ); // as long as a "string" is an array
    static size_t GetStrLenBytes( sal_Int32 nLen )
        { return nLen * sizeof(sal_Unicode); }
    static size_t GetStrLenBytes( const sal_Unicode* pStr )
        { return GetStrLenBytes( GetStrLen( pStr ) ); }
@@ -327,7 +327,7 @@ private:
    bool   NextNewToken(bool bInArray = false);

    virtual void SetError(sal_uInt16 nError);
    xub_StrLen NextSymbol(bool bInArray);
    sal_Int32 NextSymbol(bool bInArray);
    bool IsValue( const OUString& );
    bool IsOpCode( const OUString&, bool bInArray );
    bool IsOpCode2( const OUString& );
@@ -451,7 +451,7 @@ public:
        in nFlags, all bits must match. If bTestLetterNumeric is false and
        char>=128, no LetterNumeric test is done and false is returned. */
    static bool IsCharFlagAllConventions(
        OUString const & rStr, xub_StrLen nPos, sal_uLong nFlags, bool bTestLetterNumeric = true );
        OUString const & rStr, sal_Int32 nPos, sal_uLong nFlags, bool bTestLetterNumeric = true );

private:
    // FormulaCompiler
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index ded209c..972a96c 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1961,7 +1961,7 @@ public:
    /** Maximum string length of numerical cells of a column, e.g. for dBase export.
        @return String length in characters (!) including the decimal
                separator, and the decimal precision needed. */
    xub_StrLen      GetMaxNumberStringLen( sal_uInt16& nPrecision,
    sal_Int32       GetMaxNumberStringLen( sal_uInt16& nPrecision,
                                           SCTAB nTab, SCCOL nCol,
                                           SCROW nRowStart, SCROW nRowEnd ) const;

diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index 2d3d4ce..a8cd1ab 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -226,8 +226,8 @@ public:

    void SetExecuteURL(bool bSet)    { bExecuteURL = bSet; }

    virtual void    FieldClicked( const SvxFieldItem& rField, sal_Int32, sal_uInt16 );
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rTxtColor, Color*& rFldColor );
    virtual void    FieldClicked( const SvxFieldItem& rField, sal_Int32, sal_Int32 );
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor );
};


@@ -239,7 +239,7 @@ private:

public:
    ScHeaderEditEngine( SfxItemPool* pEnginePool, sal_Bool bDeleteEnginePool = false );
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rTxtColor, Color*& rFldColor );
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor );

    void SetNumType(SvxNumType eNew)                { aData.eNumType = eNew; }
    void SetData(const ScHeaderFieldData& rNew)     { aData = rNew; }
diff --git a/sc/inc/funcdesc.hxx b/sc/inc/funcdesc.hxx
index ed4a85c..12ab0c7 100644
--- a/sc/inc/funcdesc.hxx
+++ b/sc/inc/funcdesc.hxx
@@ -236,13 +236,13 @@ public:

    const ScFuncDesc* GetFunction( sal_uInt32 nIndex ) const;

    xub_StrLen GetMaxFuncNameLen() const
    sal_Int32 GetMaxFuncNameLen() const
               { return nMaxFuncNameLen; }

private:
    ::std::vector<const ScFuncDesc*> aFunctionList; /**< List of functions */
    ::std::vector<const ScFuncDesc*>::iterator aFunctionListIter; /**< position in function list */
    xub_StrLen  nMaxFuncNameLen; /**< Length of longest function name */
    sal_Int32  nMaxFuncNameLen; /**< Length of longest function name */
};

/**
diff --git a/sc/inc/pch/precompiled_sc.hxx b/sc/inc/pch/precompiled_sc.hxx
index ea23135..dc8520f 100644
--- a/sc/inc/pch/precompiled_sc.hxx
+++ b/sc/inc/pch/precompiled_sc.hxx
@@ -936,7 +936,6 @@
#include <tools/shl.hxx>
#include <tools/solar.h>
#include <tools/stream.hxx>
#include <tools/string.hxx>
#include <tools/tenccvt.hxx>
#include <tools/urlobj.hxx>
#include <tools/wintypes.hxx>
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index eb17a18..22720e7 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -831,7 +831,7 @@ public:

    sal_Int32   GetMaxStringLen( SCCOL nCol,
                                    SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const;
    xub_StrLen  GetMaxNumberStringLen( sal_uInt16& nPrecision,
    sal_Int32  GetMaxNumberStringLen( sal_uInt16& nPrecision,
                                       SCCOL nCol,
                                       SCROW nRowStart, SCROW nRowEnd ) const;

diff --git a/sc/source/core/data/attrib.cxx b/sc/source/core/data/attrib.cxx
index da9a3e4..fa3e209 100644
--- a/sc/source/core/data/attrib.cxx
+++ b/sc/source/core/data/attrib.cxx
@@ -748,7 +748,7 @@ static void lcl_SetSpace( OUString& rStr, const ESelection& rSel )
{
    // Text replaced by a space to ensure they are positions:

    xub_StrLen nLen = rSel.nEndPos-rSel.nStartPos;
    sal_Int32 nLen = rSel.nEndPos-rSel.nStartPos;
    rStr = rStr.replaceAt( rSel.nStartPos, nLen, " " );
}

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 542fa88..fb6518e 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2680,7 +2680,7 @@ public:

}

xub_StrLen ScColumn::GetMaxNumberStringLen(
sal_Int32 ScColumn::GetMaxNumberStringLen(
    sal_uInt16& nPrecision, SCROW nRowStart, SCROW nRowEnd ) const
{
    nPrecision = pDocument->GetDocOptions().GetStdPrecision();
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index ed49696..23be5e5 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -596,7 +596,7 @@ sal_Int32 ScDocument::GetMaxStringLen( SCTAB nTab, SCCOL nCol,
        return 0;
}

xub_StrLen ScDocument::GetMaxNumberStringLen( sal_uInt16& nPrecision, SCTAB nTab,
sal_Int32 ScDocument::GetMaxNumberStringLen( sal_uInt16& nPrecision, SCTAB nTab,
                                    SCCOL nCol,
                                    SCROW nRowStart, SCROW nRowEnd ) const
{
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 4f13f68d..aed55b6 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -1280,7 +1280,7 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nTyp
                    sal_Int32 nLastPar = pEngine->GetParagraphCount();
                    if (nLastPar)
                        --nLastPar;
                    xub_StrLen nTxtLen = pEngine->GetTextLen(nLastPar);
                    sal_Int32 nTxtLen = pEngine->GetTextLen(nLastPar);
                    ESelection aSelAll( 0, 0, nLastPar, nTxtLen );

                    pEngine->TransliterateText( aSelAll, nType );
diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx
index 1262925..3d709f8 100644
--- a/sc/source/core/data/funcdesc.cxx
+++ b/sc/source/core/data/funcdesc.cxx
@@ -390,7 +390,7 @@ ScFunctionList::ScFunctionList() :
        nMaxFuncNameLen ( 0 )
{
    ScFuncDesc* pDesc = NULL;
    xub_StrLen nStrLen = 0;
    sal_Int32 nStrLen = 0;
    ::std::list<ScFuncDesc*> tmpFuncList;
    sal_uInt16 nDescBlock[] =
    {
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 16ed68d..5b51ac2 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1449,7 +1449,7 @@ public:
                    OUString aQuer( mpTransliteration->transliterate(
                        aQueryStr, ScGlobal::eLnge, 0, aQueryStr.getLength(),
                        NULL ) );
                    xub_StrLen nIndex = (rEntry.eOp == SC_ENDS_WITH
                    sal_Int32 nIndex = (rEntry.eOp == SC_ENDS_WITH
                        || rEntry.eOp == SC_DOES_NOT_END_WITH) ? (aCell.getLength()-aQuer.getLength()) : 0;
                    sal_Int32 nStrPos = aCell.indexOf( aQuer, nIndex );
                    switch (rEntry.eOp)
@@ -2299,7 +2299,7 @@ sal_Int32 ScTable::GetMaxStringLen( SCCOL nCol, SCROW nRowStart,
        return 0;
}

xub_StrLen ScTable::GetMaxNumberStringLen(
sal_Int32 ScTable::GetMaxNumberStringLen(
    sal_uInt16& nPrecision, SCCOL nCol, SCROW nRowStart, SCROW nRowEnd ) const
{
    if ( ValidCol(nCol) )
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 4e017c4..43b5e02 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -23,7 +23,6 @@
#include <math.h>
#include <rtl/math.hxx>
#include <rtl/ustring.hxx>
#include <tools/string.hxx>
#include "formula/errorcodes.hxx"
#include "formula/tokenarray.hxx"
#include "scdll.hxx"
@@ -906,7 +905,7 @@ inline bool ScInterpreter::MustHaveParamCountMin( short nAct, short nMin )

inline bool ScInterpreter::CheckStringResultLen( OUString& rResult, const OUString& rAdd )
{
    if ( (sal_uLong) rResult.getLength() + rAdd.getLength() > STRING_MAXLEN )
    if ( rResult.getLength() + rAdd.getLength() > SAL_MAX_UINT16 )
    {
        SetError( errStringOverflow );
        rResult = "";
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 6f37a71..710fa29f 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -32,7 +32,6 @@
#include <com/sun/star/sheet/ExternalLinkType.hpp>
#include <comphelper/string.hxx>
#include <sfx2/objsh.hxx>
#include <tools/string.hxx>
#include <tools/urlobj.hxx>

using namespace ::com::sun::star;
@@ -280,7 +279,7 @@ lcl_XL_ParseSheetRef( const sal_Unicode* start,
                if (*++p == '\'')
                {
                    aTabName += OUString( pCurrentStart,
                            sal::static_int_cast<xub_StrLen>( p - pCurrentStart));
                            sal::static_int_cast<sal_Int32>( p - pCurrentStart));
                    pCurrentStart = ++p;
                }
            }
@@ -292,7 +291,7 @@ lcl_XL_ParseSheetRef( const sal_Unicode* start,
                ++p;
        }
        if (pCurrentStart < p)
            aTabName += OUString( pCurrentStart, sal::static_int_cast<xub_StrLen>( p - pCurrentStart));
            aTabName += OUString( pCurrentStart, sal::static_int_cast<sal_Int32>( p - pCurrentStart));
        if (aTabName.isEmpty())
            return NULL;
        if (p == pMsoxlQuoteStop)
@@ -364,7 +363,7 @@ lcl_XL_ParseSheetRef( const sal_Unicode* start,
        if( *p != '!' && ( !allow_3d || *p != ':' ) )
            return (!allow_3d && *p == ':') ? p : start;

        aTabName += OUString( start, sal::static_int_cast<xub_StrLen>( p - start ) );
        aTabName += OUString( start, sal::static_int_cast<sal_Int32>( p - start ) );
    }

    rExternTabName = aTabName;
@@ -465,7 +464,7 @@ const sal_Unicode* ScRange::Parse_XL_Header(
            p = ScGlobal::UnicodeStrChr( start+1, ']' );
            if( p == NULL )
                return start;
            rExternDocName += OUString( start+1, sal::static_int_cast<xub_StrLen>( p-(start+1) ) );
            rExternDocName += OUString( start+1, sal::static_int_cast<sal_Int32>( p-(start+1) ) );
        }
        ++p;

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 62a37a7..d5ea156 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -28,7 +28,6 @@
#include <sal/macros.h>
#include <tools/rcid.h>
#include <tools/solar.h>
#include <tools/string.hxx>
#include <unotools/charclass.hxx>
#include <com/sun/star/lang/Locale.hpp>
#include <com/sun/star/sheet/FormulaOpCodeMapEntry.hpp>
@@ -468,7 +467,7 @@ static bool lcl_parseExternalName(
                aEndTabName, nFlags, true, pExternalLinks );
        if (!p || p == pStart)
            return false;
        i = xub_StrLen(p - pStart);
        i = sal_Int32(p - pStart);
        cPrev = *(p-1);
    }
    for ( ; i < nLen; ++i, ++p)
@@ -1727,7 +1726,7 @@ static sal_Unicode* lcl_UnicodeStrNCpy( sal_Unicode* pDst, const sal_Unicode* pS
//               | Sonst             | Symbol=Symbol+Zeichen | GetString
//---------------+-------------------+-----------------------+---------------

xub_StrLen ScCompiler::NextSymbol(bool bInArray)
sal_Int32 ScCompiler::NextSymbol(bool bInArray)
{
    cSymbol[MAXSTRLEN-1] = 0;       // Stopper
    sal_Unicode* pSym = cSymbol;
@@ -1739,7 +1738,7 @@ xub_StrLen ScCompiler::NextSymbol(bool bInArray)
    bool bQuote = false;
    mnRangeOpPosInSymbol = -1;
    ScanState eState = ssGetChar;
    xub_StrLen nSpaces = 0;
    sal_Int32 nSpaces = 0;
    sal_Unicode cSep = mxSymbols->getSymbolChar( ocSep);
    sal_Unicode cArrayColSep = mxSymbols->getSymbolChar( ocArrayColSep);
    sal_Unicode cArrayRowSep = mxSymbols->getSymbolChar( ocArrayRowSep);
@@ -2488,7 +2487,7 @@ bool ScCompiler::IsString()
    const sal_Unicode* p = cSymbol;
    while ( *p )
        p++;
    xub_StrLen nLen = sal::static_int_cast<xub_StrLen>( p - cSymbol - 1 );
    sal_Int32 nLen = sal::static_int_cast<sal_Int32>( p - cSymbol - 1 );
    bool bQuote = ((cSymbol[0] == '"') && (cSymbol[nLen] == '"'));
    if ((bQuote ? nLen-2 : nLen) > MAXSTRLEN-1)
    {
@@ -3254,8 +3253,8 @@ void ScCompiler::AutoCorrectParsedSymbol()
                OUString aSym, aTmp2;
                bool bLastAlp, bNextNum;
                bLastAlp = bNextNum = true;
                xub_StrLen nStrip = 0;
                xub_StrLen nCount = nRefs;
                sal_Int32 nStrip = 0;
                sal_Int32 nCount = nRefs;
                for ( sal_Int32 j=1; j<nCount; j++ )
                {
                    aTmp2 = aSymbol.getToken( 0, ':', nIndex );
@@ -3383,7 +3382,7 @@ static inline bool lcl_UpperAsciiOrI18n( OUString& rUpper, const OUString& rOrg,
bool ScCompiler::NextNewToken( bool bInArray )
{
    bool bAllowBooleans = bInArray;
    xub_StrLen nSpaces = NextSymbol(bInArray);
    sal_Int32 nSpaces = NextSymbol(bInArray);

    if (!cSymbol[0])
        return false;
@@ -4058,7 +4057,7 @@ void ScCompiler::MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc, const ScAddr
}

bool ScCompiler::IsCharFlagAllConventions(
    OUString const & rStr, xub_StrLen nPos, sal_uLong nFlags, bool bTestLetterNumeric )
    OUString const & rStr, sal_Int32 nPos, sal_uLong nFlags, bool bTestLetterNumeric )
{
    sal_Unicode c = rStr[ nPos ];
    sal_Unicode cLast = nPos > 0 ? rStr[ nPos-1 ] : 0;
diff --git a/sc/source/core/tool/ddelink.cxx b/sc/source/core/tool/ddelink.cxx
index 522ec5d..a66931e 100644
--- a/sc/source/core/tool/ddelink.cxx
+++ b/sc/source/core/tool/ddelink.cxx
@@ -181,7 +181,7 @@ sfx2::SvBaseLink::UpdateResult ScDdeLink::DataChanged(
            aLine = aLinkStr.getToken( (sal_Int32) nR, '\n' );
            for (SCSIZE nC=0; nC<nCols; nC++)
            {
                aEntry = aLine.getToken( (xub_StrLen) nC, '\t' );
                aEntry = aLine.getToken( (sal_Int32) nC, '\t' );
                sal_uInt32 nIndex = nStdFormat;
                double fVal = double();
                if ( nMode != SC_DDE_TEXT && pFormatter->IsNumberFormat( aEntry, nIndex, fVal ) )
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index 27fdf89..832fa77 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -649,16 +649,16 @@ void ScEditEngineDefaulter::RemoveParaAttribs()

        if ( pCharItems )
        {
            std::vector<sal_uInt16> aPortions;
            std::vector<sal_Int32> aPortions;
            GetPortions( nPar, aPortions );

            //  loop through the portions of the paragraph, and set only those items
            //  that are not overridden by existing character attributes

            sal_uInt16 nStart = 0;
            for ( std::vector<sal_uInt16>::const_iterator it(aPortions.begin()); it != aPortions.end(); ++it )
            sal_Int32 nStart = 0;
            for ( std::vector<sal_Int32>::const_iterator it(aPortions.begin()); it != aPortions.end(); ++it )
            {
                sal_uInt16 nEnd = *it;
                sal_Int32 nEnd = *it;
                ESelection aSel( nPar, nStart, nPar, nEnd );
                SfxItemSet aOldCharAttrs = GetAttribs( aSel );
                SfxItemSet aNewCharAttrs = *pCharItems;
@@ -800,7 +800,7 @@ ScHeaderEditEngine::ScHeaderEditEngine( SfxItemPool* pEnginePoolP, sal_Bool bDel
}

OUString ScHeaderEditEngine::CalcFieldValue( const SvxFieldItem& rField,
                                    sal_Int32 /* nPara */, sal_uInt16 /* nPos */,
                                    sal_Int32 /* nPara */, sal_Int32 /* nPos */,
                                    Color*& /* rTxtColor */, Color*& /* rFldColor */ )
{
    const SvxFieldData* pFieldData = rField.GetField();
@@ -868,7 +868,7 @@ ScFieldEditEngine::ScFieldEditEngine(
}

OUString ScFieldEditEngine::CalcFieldValue( const SvxFieldItem& rField,
                                    sal_Int32 /* nPara */, sal_uInt16 /* nPos */,
                                    sal_Int32 /* nPara */, sal_Int32 /* nPos */,
                                    Color*& rTxtColor, Color*& /* rFldColor */ )
{
    const SvxFieldData* pFieldData = rField.GetField();
@@ -879,7 +879,7 @@ OUString ScFieldEditEngine::CalcFieldValue( const SvxFieldItem& rField,
    return ScEditUtil::GetCellFieldValue(*pFieldData, mpDoc, &rTxtColor);
}

void ScFieldEditEngine::FieldClicked( const SvxFieldItem& rField, sal_Int32, sal_uInt16 )
void ScFieldEditEngine::FieldClicked( const SvxFieldItem& rField, sal_Int32, sal_Int32 )
{
    const SvxFieldData* pFld = rField.GetField();

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 5f13a43..bbc7110 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -7676,8 +7676,8 @@ void ScInterpreter::ScReplace()
        double fCount = ::rtl::math::approxFloor( GetDouble());
        double fPos   = ::rtl::math::approxFloor( GetDouble());
        OUString aOldStr = GetString().getString();
        if (fPos < 1.0 || fPos > static_cast<double>(STRING_MAXLEN)
                || fCount < 0.0 || fCount > static_cast<double>(STRING_MAXLEN))
        if (fPos < 1.0 || fPos > static_cast<double>(SAL_MAX_UINT16)
                || fCount < 0.0 || fCount > static_cast<double>(SAL_MAX_UINT16))
            PushIllegalArgument();
        else
        {
@@ -7801,7 +7801,7 @@ void ScInterpreter::ScLeft()
        if (nParamCount == 2)
        {
            double nVal = ::rtl::math::approxFloor(GetDouble());
            if ( nVal < 0.0 || nVal > STRING_MAXLEN )
            if ( nVal < 0.0 || nVal > SAL_MAX_UINT16 )
            {
                PushIllegalArgument();
                return ;
@@ -7909,7 +7909,7 @@ void ScInterpreter::ScRightB()
        if (nParamCount == 2)
        {
            double nVal = ::rtl::math::approxFloor(GetDouble());
            if ( nVal < 0.0 || nVal > STRING_MAXLEN )
            if ( nVal < 0.0 || nVal > SAL_MAX_UINT16 )
            {
                PushIllegalArgument();
                return ;
@@ -7960,7 +7960,7 @@ void ScInterpreter::ScLeftB()
        if (nParamCount == 2)
        {
            double nVal = ::rtl::math::approxFloor(GetDouble());
            if ( nVal < 0.0 || nVal > STRING_MAXLEN )
            if ( nVal < 0.0 || nVal > SAL_MAX_UINT16 )
            {
                PushIllegalArgument();
                return ;
@@ -7981,7 +7981,7 @@ void ScInterpreter::ScMidB()
        double fAnz    = ::rtl::math::approxFloor(GetDouble());
        double fAnfang = ::rtl::math::approxFloor(GetDouble());
        OUString aStr = GetString().getString();
        if (fAnfang < 1.0 || fAnz < 0.0 || fAnfang > double(STRING_MAXLEN) || fAnz > double(STRING_MAXLEN))
        if (fAnfang < 1.0 || fAnz < 0.0 || fAnfang > double(SAL_MAX_UINT16) || fAnz > double(SAL_MAX_UINT16))
            PushIllegalArgument();
        else
        {
@@ -8003,7 +8003,7 @@ void ScInterpreter::ScRight()
        if (nParamCount == 2)
        {
            double nVal = ::rtl::math::approxFloor(GetDouble());
            if ( nVal < 0.0 || nVal > STRING_MAXLEN )
            if ( nVal < 0.0 || nVal > SAL_MAX_UINT16 )
            {
                PushIllegalArgument();
                return ;
@@ -8030,7 +8030,7 @@ void ScInterpreter::ScSearch()
        if (nParamCount == 3)
        {
            fAnz = ::rtl::math::approxFloor(GetDouble());
            if (fAnz > double(STRING_MAXLEN))
            if (fAnz > double(SAL_MAX_UINT16))
            {
                PushIllegalArgument();
                return;
@@ -8067,7 +8067,7 @@ void ScInterpreter::ScMid()
        double fAnz    = ::rtl::math::approxFloor(GetDouble());
        double fAnfang = ::rtl::math::approxFloor(GetDouble());
        OUString aStr = GetString().getString();
        if (fAnfang < 1.0 || fAnz < 0.0 || fAnfang > double(STRING_MAXLEN) || fAnz > double(STRING_MAXLEN))
        if (fAnfang < 1.0 || fAnz < 0.0 || fAnfang > double(SAL_MAX_UINT16) || fAnz > double(SAL_MAX_UINT16))
            PushIllegalArgument();
        else
        {
@@ -8163,7 +8163,7 @@ void ScInterpreter::ScSubstitute()
        if (nParamCount == 4)
        {
            double fAnz = ::rtl::math::approxFloor(GetDouble());
            if( fAnz < 1 || fAnz > STRING_MAXLEN )
            if( fAnz < 1 || fAnz > SAL_MAX_UINT16 )
            {
                PushIllegalArgument();
                return;
@@ -8216,7 +8216,7 @@ void ScInterpreter::ScRept()
        OUString aStr = GetString().getString();
        if ( fAnz < 0.0 )
            PushIllegalArgument();
        else if ( fAnz * aStr.getLength() > STRING_MAXLEN )
        else if ( fAnz * aStr.getLength() > SAL_MAX_UINT16 )
        {
            PushError( errStringOverflow );
        }
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index d13f1e6..fa8f21b 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -2111,12 +2111,12 @@ void ScInterpreter::ScBase()
            0
        };
        static const int nDigits = (sizeof (pDigits)/sizeof(pDigits[0]))-1;
        xub_StrLen nMinLen;
        sal_Int32 nMinLen;
        if ( nParamCount == 3 )
        {
            double fLen = ::rtl::math::approxFloor( GetDouble() );
            if ( 1.0 <= fLen && fLen < STRING_MAXLEN )
                nMinLen = (xub_StrLen) fLen;
            if ( 1.0 <= fLen && fLen < SAL_MAX_UINT16 )
                nMinLen = (sal_Int32) fLen;
            else if ( fLen == 0.0 )
                nMinLen = 1;
            else
@@ -2129,12 +2129,12 @@ void ScInterpreter::ScBase()
        double fChars = ((fVal > 0.0 && fBase > 0.0) ?
            (ceil( log( fVal ) / log( fBase ) ) + 2.0) :
            2.0);
        if ( fChars >= STRING_MAXLEN )
        if ( fChars >= SAL_MAX_UINT16 )
            nMinLen = 0;    // Error

        if ( !nGlobalError && nMinLen && 2 <= fBase && fBase <= nDigits && 0 <= fVal )
        {
            const xub_StrLen nConstBuf = 128;
            const sal_Int32 nConstBuf = 128;
            sal_Unicode aBuf[nConstBuf];
            sal_Int32 nBuf = std::max<sal_Int32>( fChars, nMinLen + 1 );
            sal_Unicode* pBuf = (nBuf <= nConstBuf ? aBuf : new sal_Unicode[nBuf]);
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 7d22ea9..1fa293e 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -694,7 +694,7 @@ bool ScInterpreter::CreateStringArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
                            osl_getThreadTextEncoding()));
                        // In case the xub_StrLen will be longer than USHORT
                        // one day, and room for pad byte check.
                        if ( aTmp.getLength() > ((sal_uInt16)(~0)) - 2 )
                        if ( aTmp.getLength() > SAL_MAX_UINT16 - 2 )
                            return false;
                        // Append a 0-pad-byte if string length is odd
                        //! MUST be sal_uInt16 and not xub_StrLen
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index d91e69c..d5b576f 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -432,7 +432,7 @@ void ScRangeData::MakeValidName( OUString& rName )
{

    // strip leading invalid characters
    xub_StrLen nPos = 0;
    sal_Int32 nPos = 0;
    sal_Int32 nLen = rName.getLength();
    while ( nPos < nLen && !ScCompiler::IsCharFlagAllConventions( rName, nPos, SC_COMPILER_C_NAME) )
        ++nPos;
@@ -479,7 +479,7 @@ bool ScRangeData::IsNameValid( const OUString& rName, ScDocument* pDoc )
    sal_Char a('.');
    if (rName.indexOf(a) != -1)
        return false;
    xub_StrLen nPos = 0;
    sal_Int32 nPos = 0;
    sal_Int32 nLen = rName.getLength();
    if ( !nLen || !ScCompiler::IsCharFlagAllConventions( rName, nPos++, SC_COMPILER_C_CHAR_NAME ) )
        return false;
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 7d12e22..6bb060b 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -128,14 +128,14 @@ IMPL_FIXEDMEMPOOL_NEWDEL( ScDoubleRefToken )

// --- class ScRawToken -----------------------------------------------------

xub_StrLen ScRawToken::GetStrLen( const sal_Unicode* pStr )
sal_Int32 ScRawToken::GetStrLen( const sal_Unicode* pStr )
{
    if ( !pStr )
        return 0;
    const sal_Unicode* p = pStr;
    while ( *p )
        p++;
    return sal::static_int_cast<xub_StrLen>( p - pStr );
    return sal::static_int_cast<sal_Int32>( p - pStr );
}


@@ -278,7 +278,7 @@ void ScRawToken::SetExternal( const sal_Unicode* pStr )
{
    eOp   = ocExternal;
    eType = svExternal;
    xub_StrLen nLen = GetStrLen( pStr ) + 1;
    sal_Int32 nLen = GetStrLen( pStr ) + 1;
    if( nLen >= MAXSTRLEN )
        nLen = MAXSTRLEN-1;
    // Platz fuer Byte-Parameter lassen!
diff --git a/sc/source/filter/excel/tokstack.cxx b/sc/source/filter/excel/tokstack.cxx
index 5503409..aec31a9 100644
--- a/sc/source/filter/excel/tokstack.cxx
+++ b/sc/source/filter/excel/tokstack.cxx
@@ -685,7 +685,7 @@ const TokenId TokenPool::Store( const OUString& rString )

    if (ppP_Str[ nP_StrAkt ])
    {
        DBG_ASSERT( sizeof( xub_StrLen ) <= 2, "*TokenPool::Store(): StrLen doesn't match!" );
        /* attention trucate to 16 bits */
        pSize[ nElementAkt ] = ( sal_uInt16 ) ppP_Str[ nP_StrAkt ]->getLength();
    }

diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx
index efdc6d8..b46c5fe 100644
--- a/sc/source/filter/excel/xehelper.cxx
+++ b/sc/source/filter/excel/xehelper.cxx
@@ -388,7 +388,7 @@ XclExpStringRef lclCreateFormattedString(
        SvxFont aFont( XclExpFontHelper::GetFontFromItemSet( rRoot, rItemSet, nScript ) );

        // Excel start position of this portion
        sal_uInt16 nXclPortionStart = xString->Len();
        sal_Int32 nXclPortionStart = xString->Len();
        // add portion text to Excel string
        XclExpStringHelper::AppendString( *xString, rRoot, aOUText.copy( nPortionPos, nPortionEnd - nPortionPos ) );
        if( nXclPortionStart < xString->Len() )
@@ -446,13 +446,13 @@ XclExpStringRef lclCreateFormattedString(
        ESelection aSel( nPara, 0 );
        OUString aParaText( rEE.GetText( nPara ) );

        std::vector<sal_uInt16> aPosList;
        std::vector<sal_Int32> aPosList;
        rEE.GetPortions( nPara, aPosList );

        // process all portions in the paragraph
        for( std::vector<sal_uInt16>::const_iterator it(aPosList.begin()); it != aPosList.end(); ++it )
        for( std::vector<sal_Int32>::const_iterator it(aPosList.begin()); it != aPosList.end(); ++it )
        {
            aSel.nEndPos = static_cast< xub_StrLen >( *it );
            aSel.nEndPos =  *it;
            OUString aXclPortionText = aParaText.copy( aSel.nStartPos, aSel.nEndPos - aSel.nStartPos );

            aItemSet.ClearItem();
@@ -488,7 +488,7 @@ XclExpStringRef lclCreateFormattedString(
            }

            // Excel start position of this portion
            sal_uInt16 nXclPortionStart = xString->Len();
            sal_Int32 nXclPortionStart = xString->Len();
            // add portion text to Excel string
            XclExpStringHelper::AppendString( *xString, rRoot, aXclPortionText );
            if( (nXclPortionStart < xString->Len()) || (aParaText.isEmpty()) )
@@ -719,12 +719,12 @@ void XclExpHFConverter::AppendPortion( const EditTextObject* pTextObj, sal_Unico
        ESelection aSel( nPara, 0 );
        OUString aParaText;
        sal_Int32 nParaHeight = 0;
        std::vector<sal_uInt16> aPosList;
        std::vector<sal_Int32> aPosList;
        mrEE.GetPortions( nPara, aPosList );

        for( std::vector<sal_uInt16>::const_iterator it( aPosList.begin() ); it != aPosList.end(); ++it )
        for( std::vector<sal_Int32>::const_iterator it( aPosList.begin() ); it != aPosList.end(); ++it )
        {
            aSel.nEndPos = static_cast< xub_StrLen >( *it );
            aSel.nEndPos = *it;
            if( aSel.nStartPos < aSel.nEndPos )
            {

diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index f29cc24..e03cbf1 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -471,7 +471,7 @@ void XclExpPCField::InsertOrigTextItem( const OUString& rText )
    size_t nPos = 0;
    bool bFound = false;
    // #i76047# maximum item text length in pivot cache is 255
    OUString aShortText = rText.copy( 0, ::std::min( static_cast<sal_uInt16>(rText.getLength()), EXC_PC_MAXSTRLEN ) );
    OUString aShortText = rText.copy( 0, ::std::min(rText.getLength(), EXC_PC_MAXSTRLEN ) );
    for( size_t nSize = maOrigItemList.GetSize(); !bFound && (nPos < nSize); ++nPos )
        if( (bFound = maOrigItemList.GetRecord( nPos )->EqualsText( aShortText )) == true )
            InsertItemArrayIndex( nPos );
diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx
index 09a9c5c..552dc26 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -933,7 +933,7 @@ void XclImpWebQuery::ReadWqtables( XclImpStream& rStrm )

        const sal_Unicode cSep = ';';
        OUString aQuotedPairs( "\"\"" );
        xub_StrLen nTokenCnt = ScStringUtil::GetQuotedTokenCount( aTables, aQuotedPairs, ',' );
        sal_Int32 nTokenCnt = ScStringUtil::GetQuotedTokenCount( aTables, aQuotedPairs, ',' );
        maTables = "";
        sal_Int32 nStringIx = 0;
        for( sal_Int32 nToken = 0; nToken < nTokenCnt; ++nToken )
diff --git a/sc/source/filter/excel/xistring.cxx b/sc/source/filter/excel/xistring.cxx
index 6bb003f..d440575 100644
--- a/sc/source/filter/excel/xistring.cxx
+++ b/sc/source/filter/excel/xistring.cxx
@@ -166,7 +166,7 @@ XclImpStringIterator::XclImpStringIterator( const XclImpString& rString ) :
    if( !mrFormats.empty() && (mrFormats.front().mnChar == 0) )
        ++mnFormatsEnd;
    // find end position of the first portion
    mnTextEnd = static_cast< xub_StrLen >( (mnFormatsEnd < mrFormats.size()) ?
    mnTextEnd = (mnFormatsEnd < mrFormats.size() ?
        mrFormats[ mnFormatsEnd ].mnChar : mrText.getLength() );
}

@@ -194,8 +194,8 @@ XclImpStringIterator& XclImpStringIterator::operator++()
                ++mnFormatsEnd;
            // character positions of next portion
            mnTextBeg = mnTextEnd;
            mnTextEnd = static_cast< xub_StrLen >( (mnFormatsEnd < mrFormats.size()) ?
                mrFormats[ mnFormatsEnd ].mnChar : mrText.getLength() );
            mnTextEnd = (mnFormatsEnd < mrFormats.size()) ?
                mrFormats[ mnFormatsEnd ].mnChar : mrText.getLength();
        }
        while( Is() && (mnTextBeg == mnTextEnd) );
    }
diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx
index 7da57ce..d12a85a 100644
--- a/sc/source/filter/excel/xltools.cxx
+++ b/sc/source/filter/excel/xltools.cxx
@@ -512,7 +512,7 @@ sal_Unicode XclTools::GetBuiltInDefNameIndex( const OUString& rDefName )
            if( rDefName.matchIgnoreAsciiCase( aBuiltInName, nPrefixLen ) )
            {
                // name can be followed by underline or space character
                xub_StrLen nNextCharPos = nPrefixLen + nBuiltInLen;
                sal_Int32 nNextCharPos = nPrefixLen + nBuiltInLen;
                sal_Unicode cNextChar = (rDefName.getLength() > nNextCharPos) ? rDefName[nNextCharPos] : '\0';
                if( (cNextChar == '\0') || (cNextChar == ' ') || (cNextChar == '_') )
                    return cBuiltIn;
diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx
index 8461923..fe372e4 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -1146,7 +1146,7 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
            }
            else
            {
                xub_StrLen nStartPos = 0;
                sal_Int32 nStartPos = 0;
                do
                {
                    OUString aSingleLine = aStr.copy( nStartPos, nPos - nStartPos );
@@ -1195,12 +1195,12 @@ bool ScHTMLExport::WriteFieldText( const EditTextObject* pData )
        {
            if ( nPar > 0 )
                TAG_ON( OOO_STRING_SVTOOLS_HTML_linebreak );
            std::vector<sal_uInt16> aPortions;
            std::vector<sal_Int32> aPortions;
            rEngine.GetPortions( nPar, aPortions );
            sal_uInt16 nStart = 0;
            for ( std::vector<sal_uInt16>::const_iterator it(aPortions.begin()); it != aPortions.end(); ++it )
            sal_Int32 nStart = 0;
            for ( std::vector<sal_Int32>::const_iterator it(aPortions.begin()); it != aPortions.end(); ++it )
            {
                sal_uInt16 nEnd = *it;
                sal_Int32 nEnd = *it;
                ESelection aSel( nPar, nStart, nPar, nEnd );
                sal_Bool bUrl = false;
                // fields are single characters
diff --git a/sc/source/filter/inc/xistring.hxx b/sc/source/filter/inc/xistring.hxx
index 974af8d..9b7613f 100644
--- a/sc/source/filter/inc/xistring.hxx
+++ b/sc/source/filter/inc/xistring.hxx
@@ -101,8 +101,8 @@ private:
    const OUString&     mrText;         /// The processed string.
    const XclFormatRunVec& mrFormats;   /// The vector of formatting runs.
    size_t              mnPortion;      /// Current text portion.
    xub_StrLen          mnTextBeg;      /// First character of current portion.
    xub_StrLen          mnTextEnd;      /// First character of next portion.
    sal_Int32           mnTextBeg;      /// First character of current portion.
    sal_Int32           mnTextEnd;      /// First character of next portion.
    size_t              mnFormatsBeg;   /// Formatting run index for current portion.
    size_t              mnFormatsEnd;   /// Formatting run index for next portion.
};
diff --git a/sc/source/filter/inc/xlpivot.hxx b/sc/source/filter/inc/xlpivot.hxx
index 2f14e1c..cd8fccb 100644
--- a/sc/source/filter/inc/xlpivot.hxx
+++ b/sc/source/filter/inc/xlpivot.hxx
@@ -50,7 +50,7 @@ const sal_uInt16 EXC_PT_MAXSTRLEN           = 0xFFFE;
// pivot cache fields
const size_t EXC_PC_MAXFIELDCOUNT           = 0xFFFE;
const sal_uInt16 EXC_PC_NOFIELD             = 0xFFFF;
const xub_StrLen EXC_PC_MAXSTRLEN           = 255;
const sal_Int32 EXC_PC_MAXSTRLEN           = 255;

// pivot cache items
const size_t EXC_PC_MAXITEMCOUNT            = 32500;
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 6b71023..531a244 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -315,7 +315,7 @@ static void lcl_Replace( EditView* pView, const OUString& rNewStr, const ESelect
        //  dafuer muss oben die Selektion aufgehoben werden (vor QuickInsertText)
        pView->InsertText( EMPTY_OUSTRING, false );

        xub_StrLen nLen = pEngine->GetTextLen(0);
        sal_Int32 nLen = pEngine->GetTextLen(0);
        ESelection aSel( 0, nLen, 0, nLen );
        pView->SetSelection( aSel );                // Cursor ans Ende
    }
@@ -327,8 +327,8 @@ void ScInputHandler::UpdateRange( sal_uInt16 nIndex, const ScRange& rNew )
    if ( pDocView && pRangeFindList && nIndex < pRangeFindList->Count() )
    {
        ScRangeFindData* pData = pRangeFindList->GetObject( nIndex );
        xub_StrLen nOldStart = pData->nSelStart;
        xub_StrLen nOldEnd = pData->nSelEnd;
        sal_Int32 nOldStart = pData->nSelStart;
        sal_Int32 nOldEnd = pData->nSelEnd;

        ScRange aJustified = rNew;
        aJustified.Justify();           // Ref in der Formel immer richtigherum anzeigen
@@ -349,14 +349,14 @@ void ScInputHandler::UpdateRange( sal_uInt16 nIndex, const ScRange& rNew )
        long nDiff = aNewStr.getLength() - (long)(nOldEnd-nOldStart);

        pData->aRef = rNew;
        pData->nSelEnd = (xub_StrLen)(pData->nSelEnd + nDiff);
        pData->nSelEnd = pData->nSelEnd + nDiff;

        sal_uInt16 nCount = (sal_uInt16) pRangeFindList->Count();
        for (sal_uInt16 i=nIndex+1; i<nCount; i++)
        {
            ScRangeFindData* pNext = pRangeFindList->GetObject( i );
            pNext->nSelStart = (xub_StrLen)(pNext->nSelStart + nDiff);
            pNext->nSelEnd   = (xub_StrLen)(pNext->nSelEnd   + nDiff);
            pNext->nSelStart = pNext->nSelStart + nDiff;
            pNext->nSelEnd   = pNext->nSelEnd   + nDiff;
        }
    }
    else
@@ -395,7 +395,7 @@ static void lcl_RemoveLineEnd(OUString& rStr)
    removeChars(rStr, '\n');
}

static sal_Int32 lcl_MatchParenthesis( const OUString& rStr, xub_StrLen nPos )
static sal_Int32 lcl_MatchParenthesis( const OUString& rStr, sal_Int32 nPos )
{
    int nDir;
    sal_Unicode c1, c2 = 0;
@@ -820,10 +820,10 @@ void ScInputHandler::ShowTipCursor()
        {
            if ( aFormula.getLength() < aSel.nEndPos )
                return;
            xub_StrLen nPos = aSel.nEndPos;
            sal_Int32 nPos = aSel.nEndPos;
            OUString  aSelText = aFormula.copy( 0, nPos );
            sal_Int32   nNextFStart = 0;
            xub_StrLen  nArgPos = 0;
            sal_Int32  nArgPos = 0;
            const IFunctionDescription* ppFDesc;
            ::std::vector< OUString> aArgs;
            sal_uInt16      nArgs;
@@ -856,7 +856,7 @@ void ScInputHandler::ShowTipCursor()
                                sal_uInt16 nActive = 0;
                                for( sal_uInt16 i=0; i < nArgs; i++ )
                                {
                                    xub_StrLen nLength = static_cast<xub_StrLen>(aArgs[i].getLength());
                                    sal_Int32 nLength = aArgs[i].getLength();
                                    if( nArgPos <= aSelText.getLength()-1 )
                                    {
                                        nActive = i+1;
@@ -953,7 +953,7 @@ void ScInputHandler::ShowTipCursor()
                }
                else
                {
                    sal_uInt16 nPosition = 0;
                    sal_Int32 nPosition = 0;
                    OUString aText = pEngine->GetWord( 0, aSel.nEndPos-1 );
                    /* XXX: dubious, what is this condition supposed to exactly match? */
                    if (aSel.nEndPos <= aText.getLength() && aText[ aSel.nEndPos-1 ] == '=')
@@ -1055,11 +1055,11 @@ void ScInputHandler::UseFormulaData()

        if ( aSel.nEndPos > 0 )
        {
            xub_StrLen nPos = aSel.nEndPos;
            sal_Int32 nPos = aSel.nEndPos;
            OUString  aFormula = aTotal.copy( 0, nPos );;
            sal_Int32   nLeftParentPos = 0;
            sal_Int32   nNextFStart = 0;
            xub_StrLen  nArgPos = 0;
            sal_Int32  nArgPos = 0;
            const IFunctionDescription* ppFDesc;
            ::std::vector< OUString> aArgs;
            sal_uInt16      nArgs;
@@ -1107,7 +1107,7 @@ void ScInputHandler::UseFormulaData()
                            sal_uInt16 nActive = 0;
                            for( sal_uInt16 i=0; i < nArgs; i++ )
                            {
                                xub_StrLen nLength = static_cast<xub_StrLen>(aArgs[i].getLength());
                                sal_Int32 nLength = aArgs[i].getLength();
                                if( nArgPos <= aFormula.getLength()-1 )
                                {
                                    nActive = i+1;
@@ -1237,7 +1237,7 @@ static void lcl_CompleteFunction( EditView* pView, const OUString& rInsert, bool
        pView->SelectCurrentWord();

        OUString aInsStr = rInsert;
        xub_StrLen nInsLen = aInsStr.getLength();
        sal_Int32 nInsLen = aInsStr.getLength();
        bool bDoParen = ( nInsLen > 1 && aInsStr[nInsLen-2] == '('
                                      && aInsStr[nInsLen-1] == ')' );
        if ( bDoParen )
@@ -1409,7 +1409,7 @@ void ScInputHandler::PasteManualTip()
        if (!pActiveView->HasSelection())
        {
            //  nichts selektiert -> alles selektieren
            xub_StrLen nOldLen = pEngine->GetTextLen(0);
            sal_Int32 nOldLen = pEngine->GetTextLen(0);
            ESelection aAllSel( 0, 0, 0, nOldLen );
            if ( pTopView )
                pTopView->SetSelection( aAllSel );
@@ -1427,7 +1427,7 @@ void ScInputHandler::PasteManualTip()
                //  alles selektiert -> Anfuehrungszeichen weglassen
                if ( aInsert[0] == '"' )
                    aInsert = aInsert.copy(1);
                xub_StrLen nInsLen = aInsert.getLength();
                sal_Int32 nInsLen = aInsert.getLength();
                if ( aInsert.endsWith("\"") )
                    aInsert = aInsert.copy( 0, nInsLen-1 );
            }
@@ -1473,7 +1473,7 @@ bool ScInputHandler::CursorAtClosingPar()
    if ( pActiveView && !pActiveView->HasSelection() && bFormulaMode )
    {
        ESelection aSel = pActiveView->GetSelection();
        xub_StrLen nPos = aSel.nStartPos;
        sal_Int32 nPos = aSel.nStartPos;
        OUString aFormula = pEngine->GetText(0);
        if ( nPos < aFormula.getLength() && aFormula[nPos] == ')' )
            return true;
@@ -1545,7 +1545,7 @@ void ScInputHandler::UseColData()           // beim Tippen
        sal_Int32 nParCnt = pEngine->GetParagraphCount();
        if ( aSel.nEndPara+1 == nParCnt )
        {
            xub_StrLen nParLen = pEngine->GetTextLen( aSel.nEndPara );
            sal_Int32 nParLen = pEngine->GetTextLen( aSel.nEndPara );
            if ( aSel.nEndPos == nParLen )
            {
                OUString aText = GetEditText(pEngine);
@@ -1621,8 +1621,8 @@ void ScInputHandler::NextAutoEntry( bool bBack )
            if ( aSel.nEndPara+1 == nParCnt && aSel.nStartPara == aSel.nEndPara )
            {
                OUString aText = GetEditText(pEngine);
                xub_StrLen nSelLen = aSel.nEndPos - aSel.nStartPos;
                xub_StrLen nParLen = pEngine->GetTextLen( aSel.nEndPara );
                sal_Int32 nSelLen = aSel.nEndPos - aSel.nStartPos;
                sal_Int32 nParLen = pEngine->GetTextLen( aSel.nEndPara );
                if ( aSel.nEndPos == nParLen && aText.getLength() == aAutoSearch.getLength() + nSelLen )
                {
                    OUString aNew;
@@ -1689,7 +1689,7 @@ void ScInputHandler::UpdateParenthesis()
            {
                //  Das Zeichen links vom Cursor wird angeschaut

                xub_StrLen nPos = aSel.nStartPos - 1;
                sal_Int32 nPos = aSel.nStartPos - 1;
                OUString aFormula = pEngine->GetText(0);
                sal_Unicode c = aFormula[nPos];
                if ( c == '(' || c == ')' )
@@ -2093,7 +2093,7 @@ static void lcl_SetTopSelection( EditView* pEditView, ESelection& rSel )
    sal_Int32 nCount = pEngine->GetParagraphCount();
    if (nCount > 1)
    {
        xub_StrLen nParLen = pEngine->GetTextLen(rSel.nStartPara);
        sal_Int32 nParLen = pEngine->GetTextLen(rSel.nStartPara);
        while (rSel.nStartPos > nParLen && rSel.nStartPara+1 < nCount)
        {
            rSel.nStartPos -= nParLen + 1;          // incl. Leerzeichen vom Umbruch
@@ -3794,7 +3794,7 @@ bool ScInputHandler::GetTextAndFields( ScEditEngineDefaulter& rDestEngine )

            while ( nParCnt > 1 )
            {
                xub_StrLen nLen = rDestEngine.GetTextLen( 0 );
                sal_Int32 nLen = rDestEngine.GetTextLen( 0 );
                ESelection aSel( 0,nLen, 1,0 );
                rDestEngine.QuickInsertText( OUString(' '), aSel );       // Umbruch durch Space ersetzen
                --nParCnt;
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 3bc555c..b823146 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -483,7 +483,7 @@ void ScInputWindow::Select()
                                //! SetSelection am InputHandler ???
                                //! bSelIsRef setzen ???
                                const sal_Int32 nOpen = aFormula.indexOf('(');
                                const xub_StrLen nLen = aFormula.getLength();
                                const sal_Int32 nLen = aFormula.getLength();
                                if ( nOpen != -1 && nLen > nOpen )
                                {
                                    sal_uInt8 nAdd(1);
@@ -758,7 +758,7 @@ void ScInputWindow::SwitchToTextWin()
        if (pView)
        {
            sal_Int32 nPara =  pView->GetEditEngine()->GetParagraphCount() ? ( pView->GetEditEngine()->GetParagraphCount() - 1 ) : 0;
            xub_StrLen nLen = pView->GetEditEngine()->GetTextLen( nPara );
            sal_Int32 nLen = pView->GetEditEngine()->GetTextLen( nPara );
            ESelection aSel( nPara, nLen, nPara, nLen );
            pView->SetSelection( aSel );                // set cursor to end of text
        }
diff --git a/sc/source/ui/dbgui/scuiimoptdlg.cxx b/sc/source/ui/dbgui/scuiimoptdlg.cxx
index 1fba5ba..dbb4205b 100644
--- a/sc/source/ui/dbgui/scuiimoptdlg.cxx
+++ b/sc/source/ui/dbgui/scuiimoptdlg.cxx
@@ -53,8 +53,8 @@ public:
private:
    const OUString      theDelTab;
    const sal_Unicode   cSep;
    const xub_StrLen    nCount;
    xub_StrLen          nIter;
    const sal_Int32    nCount;
    sal_Int32          nIter;
};

//------------------------------------------------------------------------
@@ -65,7 +65,7 @@ sal_uInt16 ScDelimiterTable::GetCode( const OUString& rDel ) const

    if ( nCount >= 2 )
    {
        xub_StrLen i = 0;
        sal_Int32 i = 0;
        while ( i<nCount )
        {
            if ( rDel == theDelTab.getToken( i, cSep ) )
@@ -89,7 +89,7 @@ OUString ScDelimiterTable::GetDelimiter( sal_Unicode nCode ) const

    if ( nCount >= 2 )
    {
        xub_StrLen i = 0;
        sal_Int32 i = 0;
        while ( i<nCount )
        {
            if ( nCode == (sal_Unicode) theDelTab.getToken( i+1, cSep ).toInt32() )
diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx
index c2bf54e..c3def98 100644
--- a/sc/source/ui/docshell/arealink.cxx
+++ b/sc/source/ui/docshell/arealink.cxx
@@ -280,7 +280,7 @@ bool ScAreaLink::Refresh( const OUString& rNewFile, const OUString& rNewFilter,
    SCROW nHeight = 0;
    sal_Int32 nTokenCnt = comphelper::string::getTokenCount(aTempArea, ';');
    sal_Int32 nStringIx = 0;
    xub_StrLen nToken;
    sal_Int32 nToken;

    for( nToken = 0; nToken < nTokenCnt; nToken++ )
    {
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 5c4e728..101332d1 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -323,7 +323,7 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet)

                            if( *pNameBuffer == SC_COMPILER_FILE_TAB_SEP )  // after the last quote of the docname should be the # char
                            {
                                xub_StrLen nIndex = nNameLength - nLinkTabNameLength;
                                sal_Int32 nIndex = nNameLength - nLinkTabNameLength;
                                INetURLObject aINetURLObject(aDocURLBuffer.makeStringAndClear());
                                if(aName == aLinkTabName.copy(nIndex, nLinkTabNameLength) &&
                                    (aName[nIndex - 1] == '#') && // before the table name should be the # char
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index f8585b4..0e97eda 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -656,7 +656,7 @@ void lcl_GetColumnTypes(
        }
        else if ( nDbType == sdbc::DataType::DECIMAL )
        {   // maximale Feldbreite und Nachkommastellen bestimmen
            xub_StrLen nLen;
            sal_Int32 nLen;
            sal_uInt16 nPrec;
            nLen = pDoc->GetMaxNumberStringLen( nPrec, nTab, nCol,
                nFirstDataRow, nLastRow );
@@ -668,7 +668,7 @@ void lcl_GetColumnTypes(
            if ( bPrecDefined && nPrecision != nPrec )
            {   // Laenge auf vorgegebene Nachkommastellen anpassen
                if ( nPrecision )
                    nLen = sal::static_int_cast<xub_StrLen>( nLen + ( nPrecision - nPrec ) );
                    nLen = nLen + ( nPrecision - nPrec );
                else
                    nLen -= nPrec+1;            // auch den . mit raus
            }
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index d6ce4f3..737ec54 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -23,7 +23,6 @@
#include <i18nlangtag/languagetag.hxx>
#include <sot/formats.hxx>
#include <sfx2/mieclip.hxx>
#include <tools/string.hxx>
#include <com/sun/star/i18n/CalendarFieldIndex.hpp>

#include "global.hxx"
@@ -62,7 +61,7 @@
// times maximum cell content length, 2*1024*64K=128M, and because it's
// sal_Unicode that's 256MB. If it's 2GB of data without LF we're out of luck
// anyway.
static const sal_Int32 nArbitraryLineLengthLimit = 2 * MAXCOLCOUNT * STRING_MAXLEN;
static const sal_Int32 nArbitraryLineLengthLimit = 2 * MAXCOLCOUNT * 65536;

namespace
{
@@ -354,7 +353,7 @@ bool ScImportExport::ExportByteString( OString& rText, rtl_TextEncoding eEnc, sa
        eEnc = osl_getThreadTextEncoding();

    if (!nSizeLimit)
        nSizeLimit = STRING_MAXLEN;
        nSizeLimit = SAL_MAX_UINT16;

    SvMemoryStream aStrm;
    aStrm.SetStreamCharSet( eEnc );
@@ -365,7 +364,7 @@ bool ScImportExport::ExportByteString( OString& rText, rtl_TextEncoding eEnc, sa
        aStrm.WriteChar( (sal_Char) 0 );
        aStrm.Seek( STREAM_SEEK_TO_END );
        // Sicherheits-Check:
        if( aStrm.Tell() <= (sal_uLong) STRING_MAXLEN )
        if( aStrm.Tell() <= nSizeLimit )
        {
            rText = (const sal_Char*) aStrm.GetData();
            return true;
@@ -623,15 +622,15 @@ static QuoteType lcl_isEscapedOrFieldEndQuote( sal_Int32 nQuotes, const sal_Unic
 */
static bool lcl_appendLineData( OUString& rField, const sal_Unicode* p1, const sal_Unicode* p2 )
{
    OSL_ENSURE( rField.getLength() + (p2 - p1) <= STRING_MAXLEN, "lcl_appendLineData: data overflow");
    if (rField.getLength() + (p2 - p1) <= STRING_MAXLEN)
    OSL_ENSURE( rField.getLength() + (p2 - p1) <= SAL_MAX_UINT16, "lcl_appendLineData: data overflow");
    if (rField.getLength() + (p2 - p1) <= SAL_MAX_UINT16)
    {
        rField += OUString( p1, sal::static_int_cast<sal_Int32>( p2 - p1 ) );
        return true;
    }
    else
    {
        rField += OUString( p1, STRING_MAXLEN - rField.getLength() );
        rField += OUString( p1, SAL_MAX_UINT16 - rField.getLength() );
        return false;
    }
}
@@ -1247,26 +1246,26 @@ static OUString lcl_GetFixed( const OUString& rLine, sal_Int32 nStart, sal_Int32
    rbIsQuoted = (pStr[nStart] == '"' && pStr[nSpace-1] == '"');
    if (rbIsQuoted)
    {
        bool bFits = (nSpace - nStart - 3 <= STRING_MAXLEN);
        bool bFits = (nSpace - nStart - 3 <= SAL_MAX_UINT16);
        OSL_ENSURE( bFits, "lcl_GetFixed: line doesn't fit into data");
        if (bFits)
            return rLine.copy(nStart+1, nSpace-nStart-2);
        else
        {
            rbOverflowCell = true;
            return rLine.copy(nStart+1, STRING_MAXLEN);
            return rLine.copy(nStart+1, SAL_MAX_UINT16);
        }
    }
    else
    {
        bool bFits = (nSpace - nStart <= STRING_MAXLEN);
        bool bFits = (nSpace - nStart <= SAL_MAX_UINT16);
        OSL_ENSURE( bFits, "lcl_GetFixed: line doesn't fit into data");
        if (bFits)
            return rLine.copy(nStart, nSpace-nStart);
        else
        {
            rbOverflowCell = true;
            return rLine.copy(nStart, STRING_MAXLEN);
            return rLine.copy(nStart, SAL_MAX_UINT16);
        }
    }
}
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx
index 6d6206e..6271824 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -601,7 +601,7 @@ static void lcl_RemoveFields( OutlinerView& rOutView )
    ESelection aOldSel = rOutView.GetSelection();
    ESelection aSel = aOldSel;
    aSel.Adjust();
    xub_StrLen nNewEnd = aSel.nEndPos;
    sal_Int32 nNewEnd = aSel.nEndPos;

    sal_Bool bUpdate = pOutliner->GetUpdateMode();
    sal_Bool bChanged = false;
@@ -613,15 +613,14 @@ static void lcl_RemoveFields( OutlinerView& rOutView )
    for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
        if ( nPar >= aSel.nStartPara && nPar <= aSel.nEndPara )
        {
            std::vector<sal_uInt16> aPortions;
            std::vector<sal_Int32> aPortions;
            rEditEng.GetPortions( nPar, aPortions );
            //! GetPortions should use xub_StrLen instead of USHORT

            for ( size_t nPos = aPortions.size(); nPos; )
            {
                --nPos;
                sal_uInt16 nEnd = aPortions[ nPos ];
                sal_uInt16 nStart = nPos ? aPortions[ nPos - 1 ] : 0;
                sal_Int32 nEnd = aPortions[ nPos ];
                sal_Int32 nStart = nPos ? aPortions[ nPos - 1 ] : 0;
                // fields are single characters
                if ( nEnd == nStart+1 &&
                     ( nPar > aSel.nStartPara || nStart >= aSel.nStartPos ) &&
@@ -644,7 +643,7 @@ static void lcl_RemoveFields( OutlinerView& rOutView )
                        pOutliner->QuickInsertText( aFieldText, aFieldSel );
                        if ( nPar == aSel.nEndPara )
                        {
                            nNewEnd = sal::static_int_cast<xub_StrLen>( nNewEnd + aFieldText.getLength() );
                            nNewEnd = nNewEnd + aFieldText.getLength();
                            --nNewEnd;
                        }
                    }
diff --git a/sc/source/ui/inc/csvcontrol.hxx b/sc/source/ui/inc/csvcontrol.hxx
index bbea8e1..6898bd2 100644
--- a/sc/source/ui/inc/csvcontrol.hxx
+++ b/sc/source/ui/inc/csvcontrol.hxx
@@ -41,7 +41,7 @@ namespace com { namespace sun { namespace star { namespace accessibility {
/** Minimum character count for a column in separators mode. */
const sal_Int32 CSV_MINCOLWIDTH         = 8;
/** Maximum length of a cell string. */
const xub_StrLen CSV_MAXSTRLEN          = 0x7FFF;
const sal_Int32 CSV_MAXSTRLEN          = 0x7FFF;
/** Transparency for header color of selected columns. */
const sal_uInt16 CSV_HDR_TRANSPARENCY   = 85;
/** Minimum distance to border for auto scroll. */
@@ -78,7 +78,7 @@ struct ScCsvExpData
    sal_uInt8                   mnType;         /// External type of the column.

    inline                      ScCsvExpData() : mnIndex( 0 ), mnType( SC_COL_STANDARD ) {}
    inline                      ScCsvExpData( xub_StrLen nIndex, sal_uInt8 nType ) :
    inline                      ScCsvExpData( sal_Int32 nIndex, sal_uInt8 nType ) :
                                    mnIndex( nIndex ), mnType( nType ) {}
};

diff --git a/sc/source/ui/inc/rfindlst.hxx b/sc/source/ui/inc/rfindlst.hxx
index ba20555..090ea65 100644
--- a/sc/source/ui/inc/rfindlst.hxx
+++ b/sc/source/ui/inc/rfindlst.hxx
@@ -30,10 +30,10 @@ struct ScRangeFindData
{
    ScRange     aRef;
    sal_uInt16      nFlags;
    xub_StrLen  nSelStart;
    xub_StrLen  nSelEnd;
    sal_Int32  nSelStart;
    sal_Int32  nSelEnd;

    ScRangeFindData( const ScRange& rR, sal_uInt16 nF, xub_StrLen nS, xub_StrLen nE ) :
    ScRangeFindData( const ScRange& rR, sal_uInt16 nF, sal_Int32 nS, sal_Int32 nE ) :
        aRef(rR), nFlags(nF), nSelStart(nS), nSelEnd(nE) {}
};

diff --git a/sc/source/ui/navipi/navipi.cxx b/sc/source/ui/navipi/navipi.cxx
index 4263a61..b1e3e51 100644
--- a/sc/source/ui/navipi/navipi.cxx
+++ b/sc/source/ui/navipi/navipi.cxx
@@ -57,7 +57,7 @@
//  maximum values for UI
#define SCNAV_MAXCOL        (MAXCOLCOUNT)
// macro is sufficient since only used in ctor
#define SCNAV_COLDIGITS     (static_cast<xub_StrLen>( floor( log10( static_cast<double>(SCNAV_MAXCOL)))) + 1)   // 1...256...18278
#define SCNAV_COLDIGITS     (static_cast<sal_Int32>( floor( log10( static_cast<double>(SCNAV_MAXCOL)))) + 1)   // 1...256...18278
// precomputed constant because it is used in every change of spin button field
static const sal_Int32 SCNAV_COLLETTERS = ::ScColToAlpha(SCNAV_MAXCOL).getLength();    // A...IV...ZZZ

diff --git a/sc/source/ui/pagedlg/scuitphfedit.cxx b/sc/source/ui/pagedlg/scuitphfedit.cxx
index 2a71c5d..ba614027 100644
--- a/sc/source/ui/pagedlg/scuitphfedit.cxx
+++ b/sc/source/ui/pagedlg/scuitphfedit.cxx
@@ -495,7 +495,7 @@ bool ScHFEditPage::IsPageEntry(EditEngine*pEngine, EditTextObject* pTextObj)

    if(!pTextObj->IsFieldObject())
    {
        std::vector<sal_uInt16> aPosList;
        std::vector<sal_Int32> aPosList;
        pEngine->GetPortions(0,aPosList);
        if(aPosList.size() == 2)
        {
@@ -601,7 +601,7 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)

            OUString aPageOfEntry(" " + m_pFtOf->GetText() + " ");
            m_pWndCenter->GetEditEngine()->QuickInsertText(aPageOfEntry,ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aPageOfEntry.getLength() );
            aSel.nEndPos = aSel.nEndPos + aPageOfEntry.getLength();
            m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            pTextObj.reset(m_pWndCenter->GetEditEngine()->CreateTextObject());
            m_pWndCenter->SetText(*pTextObj);
@@ -641,7 +641,7 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)
            OUString aPageEntry(", " + m_pFtPage->GetText() + " ");
            m_pWndCenter->GetEditEngine()->QuickInsertText(aPageEntry, ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            aSel.nStartPos = aSel.nEndPos;
            aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aPageEntry.getLength() );
            aSel.nEndPos = aSel.nEndPos + aPageEntry.getLength();
            m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            pTextObj.reset(m_pWndCenter->GetEditEngine()->CreateTextObject());
            m_pWndCenter->SetText(*pTextObj);
@@ -670,7 +670,7 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)

            OUString aCommaSpace(", ");
            m_pWndCenter->GetEditEngine()->QuickInsertText(aCommaSpace,ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aCommaSpace.getLength() );
            aSel.nEndPos = aSel.nEndPos + aCommaSpace.getLength();
            m_pWndCenter->GetEditEngine()->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            pTextObj.reset(m_pWndCenter->GetEditEngine()->CreateTextObject());
            m_pWndCenter->SetText(*pTextObj);
@@ -690,7 +690,7 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)
            ++aSel.nEndPos;
            OUString aCommaSpace(", ");
            m_pWndCenter->GetEditEngine()->QuickInsertText(aCommaSpace,ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aCommaSpace.getLength() );
            aSel.nEndPos = aSel.nEndPos + aCommaSpace.getLength();
            m_pWndCenter->GetEditEngine()->QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
            pTextObj.reset(m_pWndCenter->GetEditEngine()->CreateTextObject());
            m_pWndCenter->SetText(*pTextObj);
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index 6f77905..c10cc72 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -173,23 +173,22 @@ class ScUnoEditEngine : public ScEditEngineDefaulter
    sal_Int32           mnFieldType;
    SvxFieldData*       pFound;         // lokale Kopie
    sal_Int32           nFieldPar;
    xub_StrLen          nFieldPos;
    sal_Int32           nFieldPos;
    sal_uInt16              nFieldIndex;

public:
                ScUnoEditEngine(ScEditEngineDefaulter* pSource);
                ~ScUnoEditEngine();

                    //! nPos should be xub_StrLen
    virtual OUString  CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos,
    virtual OUString  CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos,
                                    Color*& rTxtColor, Color*& rFldColor );

    sal_uInt16 CountFields();
    SvxFieldData* FindByIndex(sal_uInt16 nIndex);
    SvxFieldData* FindByPos(sal_Int32 nPar, xub_StrLen nPos, sal_Int32 nType);
    SvxFieldData* FindByPos(sal_Int32 nPar, sal_Int32 nPos, sal_Int32 nType);

    sal_Int32       GetFieldPar() const     { return nFieldPar; }
    xub_StrLen      GetFieldPos() const     { return nFieldPos; }
    sal_Int32       GetFieldPos() const     { return nFieldPos; }
};

ScUnoEditEngine::ScUnoEditEngine(ScEditEngineDefaulter* pSource) :
@@ -213,7 +212,7 @@ ScUnoEditEngine::~ScUnoEditEngine()
}

OUString ScUnoEditEngine::CalcFieldValue( const SvxFieldItem& rField,
            sal_Int32 nPara, sal_uInt16 nPos, Color*& rTxtColor, Color*& rFldColor )
            sal_Int32 nPara, sal_Int32 nPos, Color*& rTxtColor, Color*& rFldColor )
{
    OUString aRet(EditEngine::CalcFieldValue( rField, nPara, nPos, rTxtColor, rFldColor ));
    if (eMode != SC_UNO_COLLECT_NONE)
@@ -265,7 +264,7 @@ SvxFieldData* ScUnoEditEngine::FindByIndex(sal_uInt16 nIndex)
    return pFound;
}

SvxFieldData* ScUnoEditEngine::FindByPos(sal_Int32 nPar, xub_StrLen nPos, sal_Int32 nType)
SvxFieldData* ScUnoEditEngine::FindByPos(sal_Int32 nPar, sal_Int32 nPos, sal_Int32 nType)
{
    eMode = SC_UNO_COLLECT_FINDPOS;
    nFieldPar = nPar;
@@ -343,7 +342,7 @@ uno::Reference<text::XTextField> ScCellFieldsObj::GetObjectByIndex_Impl(sal_Int3
        return uno::Reference<text::XTextField>();

    sal_Int32 nPar = aTempEngine.GetFieldPar();
    xub_StrLen nPos = aTempEngine.GetFieldPos();
    sal_Int32 nPos = aTempEngine.GetFieldPos();
    ESelection aSelection( nPar, nPos, nPar, nPos+1 );      // Feld ist 1 Zeichen

    sal_Int32 eType = pData->GetClassId();
@@ -524,7 +523,7 @@ uno::Reference<text::XTextField> ScHeaderFieldsObj::GetObjectByIndex_Impl(sal_In
    xTextRange = xTemp;

    sal_Int32 nPar = aTempEngine.GetFieldPar();
    xub_StrLen nPos = aTempEngine.GetFieldPos();
    sal_Int32 nPos = aTempEngine.GetFieldPos();
    ESelection aSelection( nPar, nPos, nPar, nPos+1 );      // Field is 1 character

    sal_Int32 eRealType = pData->GetClassId();
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 16398a2..67d1841 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -309,7 +309,7 @@ void ScEditShell::Execute( SfxRequest& rReq )
                sal_Int32 nPar = pEngine->GetParagraphCount();
                if (nPar)
                {
                    xub_StrLen nLen = pEngine->GetTextLen(nPar-1);
                    sal_Int32 nLen = pEngine->GetTextLen(nPar-1);
                    pTableView->SetSelection(ESelection(0,0,nPar-1,nLen));
                    if (pTopView)
                        pTopView->SetSelection(ESelection(0,0,nPar-1,nLen));
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 8d55bb9..38b1e08 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -2138,13 +2138,13 @@ static void lcl_ScaleFonts( EditEngine& rEngine, long nPercent )
    sal_Int32 nParCount = rEngine.GetParagraphCount();
    for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
    {
        std::vector<sal_uInt16> aPortions;
        std::vector<sal_Int32> aPortions;
        rEngine.GetPortions( nPar, aPortions );

        sal_uInt16 nStart = 0;
        for ( std::vector<sal_uInt16>::const_iterator it(aPortions.begin()); it != aPortions.end(); ++it )
        sal_Int32 nStart = 0;
        for ( std::vector<sal_Int32>::const_iterator it(aPortions.begin()); it != aPortions.end(); ++it )
        {
            sal_uInt16 nEnd = *it;
            sal_Int32 nEnd = *it;
            ESelection aSel( nPar, nStart, nPar, nEnd );
            SfxItemSet aAttribs = rEngine.GetAttribs( aSel );

diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index 3269d1c..eb7504d 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -737,7 +737,7 @@ void ScViewFunc::InsertBookmark( const OUString& rDescription, const OUString& r
    sal_Int32 nPara = aEngine.GetParagraphCount();
    if (nPara)
        --nPara;
    xub_StrLen nTxtLen = aEngine.GetTextLen(nPara);
    sal_Int32 nTxtLen = aEngine.GetTextLen(nPara);
    ESelection aInsSel( nPara, nTxtLen, nPara, nTxtLen );

    if ( bTryReplace && HasBookmarkAtCursor( NULL ) )
diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx
index 632ddd6..5273e9f 100644
--- a/sd/source/filter/html/htmlex.cxx
+++ b/sd/source/filter/html/htmlex.cxx
@@ -1290,13 +1290,13 @@ OUString HtmlExport::ParagraphToHTMLString( SdrOutliner* pOutliner, sal_Int32 nP
        return OUString();

    HtmlState aState( (mbUserAttr || mbDocColors)  ? maTextColor : Color(COL_BLACK) );
    std::vector<sal_uInt16> aPortionList;
    std::vector<sal_Int32> aPortionList;
    rEditEngine.GetPortions( nPara, aPortionList );

    sal_uInt16 nPos1 = 0;
    for( std::vector<sal_uInt16>::const_iterator it( aPortionList.begin() ); it != aPortionList.end(); ++it )
    sal_Int32 nPos1 = 0;
    for( std::vector<sal_Int32>::const_iterator it( aPortionList.begin() ); it != aPortionList.end(); ++it )
    {
        sal_uInt16 nPos2 = *it;
        sal_Int32 nPos2 = *it;

        ESelection aSelection( nPara, nPos1, nPara, nPos2);

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index e1f5cc3..34e61d9 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -1418,7 +1418,7 @@ ESelection Outliner::GetSearchStartPosition (void)
            aPosition = ESelection();
        else
        {
            xub_StrLen nLastParagraphLength = GetEditEngine().GetTextLen (
            sal_Int32 nLastParagraphLength = GetEditEngine().GetTextLen (
                nParagraphCount-1);
            aPosition = ESelection (nParagraphCount-1, nLastParagraphLength);
        }
diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx
index 7b6a2c4..43dc44d 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -979,7 +979,7 @@ sal_Int32 SmTextForwarder::GetParagraphCount() const
    return pEditEngine ? pEditEngine->GetParagraphCount() : 0;
}

sal_uInt16 SmTextForwarder::GetTextLen( sal_Int32 nParagraph ) const
sal_Int32 SmTextForwarder::GetTextLen( sal_Int32 nParagraph ) const
{
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
    return pEditEngine ? pEditEngine->GetTextLen( nParagraph ) : 0;
@@ -1065,7 +1065,7 @@ void SmTextForwarder::RemoveAttribs( const ESelection& rSelection, sal_Bool bRem
        pEditEngine->RemoveAttribs( rSelection, bRemoveParaAttribs, nWhich );
}

void SmTextForwarder::GetPortions( sal_Int32 nPara, std::vector<sal_uInt16>& rList ) const
void SmTextForwarder::GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList ) const
{
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
    if (pEditEngine)
@@ -1108,13 +1108,13 @@ sal_Bool SmTextForwarder::IsValid() const
    return pEditEngine ? pEditEngine->GetUpdateMode() : sal_False;
}

OUString SmTextForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
OUString SmTextForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
{
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
    return pEditEngine ? pEditEngine->CalcFieldValue(rField, nPara, nPos, rpTxtColor, rpFldColor) : OUString();
}

void SmTextForwarder::FieldClicked(const SvxFieldItem&, sal_Int32, sal_uInt16)
void SmTextForwarder::FieldClicked(const SvxFieldItem&, sal_Int32, sal_Int32)
{
}

@@ -1132,11 +1132,11 @@ static sal_uInt16 GetSvxEditEngineItemState( EditEngine& rEditEngine, const ESel
        SfxItemState eParaState = SFX_ITEM_DEFAULT;

        // calculate start and endpos for this paragraph
        sal_uInt16 nPos = 0;
        sal_Int32 nPos = 0;
        if( rSel.nStartPara == nPara )
            nPos = rSel.nStartPos;

        sal_uInt16 nEndPos = rSel.nEndPos;
        sal_Int32 nEndPos = rSel.nEndPos;
        if( rSel.nEndPara != nPara )
            nEndPos = rEditEngine.GetTextLen( nPara );

@@ -1146,7 +1146,7 @@ static sal_uInt16 GetSvxEditEngineItemState( EditEngine& rEditEngine, const ESel

        bool bEmpty = true;     // we found no item inside the selektion of this paragraph
        bool bGaps  = false;    // we found items but theire gaps between them
        sal_uInt16 nLastEnd = nPos;
        sal_Int32 nLastEnd = nPos;

        const SfxPoolItem* pParaItem = NULL;

@@ -1231,13 +1231,13 @@ sal_uInt16 SmTextForwarder::GetItemState( sal_Int32 nPara, sal_uInt16 nWhich ) c
    return nState;
}

LanguageType SmTextForwarder::GetLanguage( sal_Int32 nPara, sal_uInt16 nIndex ) const
LanguageType SmTextForwarder::GetLanguage( sal_Int32 nPara, sal_Int32 nIndex ) const
{
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
    return pEditEngine ? pEditEngine->GetLanguage(nPara, nIndex) : LANGUAGE_NONE;
}

sal_uInt16 SmTextForwarder::GetFieldCount( sal_Int32 nPara ) const
sal_Int32 SmTextForwarder::GetFieldCount( sal_Int32 nPara ) const
{
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
    return pEditEngine ? pEditEngine->GetFieldCount(nPara) : 0;
@@ -1254,7 +1254,7 @@ EBulletInfo SmTextForwarder::GetBulletInfo( sal_Int32 /*nPara*/ ) const
    return EBulletInfo();
}

Rectangle SmTextForwarder::GetCharBounds( sal_Int32 nPara, sal_uInt16 nIndex ) const
Rectangle SmTextForwarder::GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const
{
    Rectangle aRect(0,0,0,0);
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
@@ -1306,7 +1306,7 @@ OutputDevice* SmTextForwarder::GetRefDevice() const
    return pEditEngine ? pEditEngine->GetRefDevice() : 0;
}

sal_Bool SmTextForwarder::GetIndexAtPoint( const Point& rPos, sal_Int32& nPara, sal_uInt16& nIndex ) const
sal_Bool SmTextForwarder::GetIndexAtPoint( const Point& rPos, sal_Int32& nPara, sal_Int32& nIndex ) const
{
    sal_Bool bRes = sal_False;
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
@@ -1320,7 +1320,7 @@ sal_Bool SmTextForwarder::GetIndexAtPoint( const Point& rPos, sal_Int32& nPara, 
    return bRes;
}

sal_Bool SmTextForwarder::GetWordIndices( sal_Int32 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const
sal_Bool SmTextForwarder::GetWordIndices( sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart, sal_Int32& nEnd ) const
{
    sal_Bool bRes = sal_False;
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
@@ -1341,7 +1341,7 @@ sal_Bool SmTextForwarder::GetWordIndices( sal_Int32 nPara, sal_uInt16 nIndex, sa
    return bRes;
}

sal_Bool SmTextForwarder::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nPara, sal_uInt16 nIndex, sal_Bool bInCell ) const
sal_Bool SmTextForwarder::GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, sal_Bool bInCell ) const
{
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
    return pEditEngine ?
@@ -1349,25 +1349,25 @@ sal_Bool SmTextForwarder::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& 
                : sal_False;
}

sal_uInt16 SmTextForwarder::GetLineCount( sal_Int32 nPara ) const
sal_Int32 SmTextForwarder::GetLineCount( sal_Int32 nPara ) const
{
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
    return pEditEngine ? pEditEngine->GetLineCount(nPara) : 0;
}

sal_uInt16 SmTextForwarder::GetLineLen( sal_Int32 nPara, sal_uInt16 nLine ) const
sal_Int32 SmTextForwarder::GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const
{
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
    return pEditEngine ? pEditEngine->GetLineLen(nPara, nLine) : 0;
}

void SmTextForwarder::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nPara, sal_uInt16 nLine ) const
void SmTextForwarder::GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nPara, sal_Int32 nLine ) const
{
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
    pEditEngine->GetLineBoundaries(rStart, rEnd, nPara, nLine);
}

sal_uInt16 SmTextForwarder::GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nIndex ) const
sal_Int32 SmTextForwarder::GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const
{
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
    return pEditEngine ? pEditEngine->GetLineNumberAtIndex(nPara, nIndex) : 0;
@@ -1445,7 +1445,7 @@ void SmTextForwarder::AppendParagraph()
    }
}

sal_uInt16 SmTextForwarder::AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet )
sal_Int32 SmTextForwarder::AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet )
{
    sal_uInt16 nRes = 0;
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
diff --git a/starmath/source/accessibility.hxx b/starmath/source/accessibility.hxx
index d0e5ebb..d9d30ae 100644
--- a/starmath/source/accessibility.hxx
+++ b/starmath/source/accessibility.hxx
@@ -202,13 +202,13 @@ public:
    virtual ~SmTextForwarder();

    virtual sal_Int32   GetParagraphCount() const;
    virtual sal_uInt16  GetTextLen( sal_Int32 nParagraph ) const;
    virtual sal_Int32   GetTextLen( sal_Int32 nParagraph ) const;
    virtual OUString    GetText( const ESelection& rSel ) const;
    virtual SfxItemSet  GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib = EditEngineAttribs_All ) const;
    virtual SfxItemSet  GetParaAttribs( sal_Int32 nPara ) const;
    virtual void        SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet );
    virtual void        RemoveAttribs( const ESelection& rSelection, sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich );
    virtual void        GetPortions( sal_Int32 nPara, std::vector<sal_uInt16>& rList ) const;
    virtual void        GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList ) const;

    virtual sal_uInt16      GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const;
    virtual sal_uInt16      GetItemState( sal_Int32 nPara, sal_uInt16 nWhich ) const;
@@ -220,25 +220,25 @@ public:

    virtual SfxItemPool* GetPool() const;

    virtual OUString    CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor );
    virtual void        FieldClicked(const SvxFieldItem&, sal_Int32, sal_uInt16);
    virtual OUString    CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor );
    virtual void        FieldClicked(const SvxFieldItem&, sal_Int32, sal_Int32);
    virtual sal_Bool         IsValid() const;

    virtual LanguageType    GetLanguage( sal_Int32, sal_uInt16 ) const;
    virtual sal_uInt16          GetFieldCount( sal_Int32 nPara ) const;
    virtual LanguageType    GetLanguage( sal_Int32, sal_Int32 ) const;
    virtual sal_Int32       GetFieldCount( sal_Int32 nPara ) const;
    virtual EFieldInfo      GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const;
    virtual EBulletInfo     GetBulletInfo( sal_Int32 nPara ) const;
    virtual Rectangle       GetCharBounds( sal_Int32 nPara, sal_uInt16 nIndex ) const;
    virtual Rectangle       GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const;
    virtual Rectangle       GetParaBounds( sal_Int32 nPara ) const;
    virtual MapMode         GetMapMode() const;
    virtual OutputDevice*   GetRefDevice() const;
    virtual sal_Bool        GetIndexAtPoint( const Point&, sal_Int32& nPara, sal_uInt16& nIndex ) const;
    virtual sal_Bool        GetWordIndices( sal_Int32 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const;
    virtual sal_Bool        GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nPara, sal_uInt16 nIndex, sal_Bool bInCell = sal_False ) const;
    virtual sal_uInt16      GetLineCount( sal_Int32 nPara ) const;
    virtual sal_uInt16      GetLineLen( sal_Int32 nPara, sal_uInt16 nLine ) const;
    virtual void            GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nParagraph, sal_uInt16 nLine ) const;
    virtual sal_uInt16          GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nLine ) const;
    virtual sal_Bool        GetIndexAtPoint( const Point&, sal_Int32& nPara, sal_Int32& nIndex ) const;
    virtual sal_Bool        GetWordIndices( sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart, sal_Int32& nEnd ) const;
    virtual sal_Bool        GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, sal_Bool bInCell = sal_False ) const;
    virtual sal_Int32       GetLineCount( sal_Int32 nPara ) const;
    virtual sal_Int32       GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const;
    virtual void            GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const;
    virtual sal_Int32       GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nLine ) const;
    virtual sal_Bool        Delete( const ESelection& );
    virtual sal_Bool        InsertText( const OUString&, const ESelection& );
    virtual sal_Bool        QuickFormatDoc( sal_Bool bFull=sal_False );
@@ -249,7 +249,7 @@ public:
    virtual const SfxItemSet*   GetEmptyItemSetPtr();
    // implementation functions for XParagraphAppend and XTextPortionAppend
    virtual void        AppendParagraph();
    virtual sal_uInt16  AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet );
    virtual sal_Int32   AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet );

    virtual void        CopyText(const SvxTextForwarder& rSource);
};
diff --git a/svtools/source/edit/editsyntaxhighlighter.cxx b/svtools/source/edit/editsyntaxhighlighter.cxx
index 178a13c..f62a428 100644
--- a/svtools/source/edit/editsyntaxhighlighter.cxx
+++ b/svtools/source/edit/editsyntaxhighlighter.cxx
@@ -49,8 +49,8 @@ void MultiLineEditSyntaxHighlight::SetText(const OUString& rNewText)
void MultiLineEditSyntaxHighlight::DoBracketHilight(sal_uInt16 nKey)
{
    TextSelection aCurrentPos = GetTextView()->GetSelection();
    xub_StrLen nStartPos = aCurrentPos.GetStart().GetIndex();
    sal_uLong nStartPara = aCurrentPos.GetStart().GetPara();
    sal_Int32 nStartPos = aCurrentPos.GetStart().GetIndex();
    sal_Int32 nStartPara = aCurrentPos.GetStart().GetPara();
    sal_uInt16 nCount = 0;
    int nChar = -1;

@@ -81,7 +81,7 @@ void MultiLineEditSyntaxHighlight::DoBracketHilight(sal_uInt16 nKey)

    if (nChar != -1)
    {
        for (long nPara = nStartPara; nPara>=0; --nPara)
        for (sal_Int32 nPara = nStartPara; nPara >= 0; --nPara)
        {
            if (nStartPos == 0)
                continue;
@@ -91,7 +91,7 @@ void MultiLineEditSyntaxHighlight::DoBracketHilight(sal_uInt16 nKey)
            if (aLine.isEmpty())
                continue;

            for (sal_Int32 i = ((sal_uLong)nPara==nStartPara) ? nStartPos-1 : aLine.getLength()-1; i>0; --i)
            for (sal_Int32 i = (nPara==nStartPara) ? nStartPos-1 : aLine.getLength()-1; i>0; --i)
            {
                if (aLine[i] == nChar)
                {
diff --git a/svx/source/accessibility/AccessibleEmptyEditSource.cxx b/svx/source/accessibility/AccessibleEmptyEditSource.cxx
index 8c8a689..fee79fd 100644
--- a/svx/source/accessibility/AccessibleEmptyEditSource.cxx
+++ b/svx/source/accessibility/AccessibleEmptyEditSource.cxx
@@ -96,7 +96,7 @@ namespace accessibility

        // SvxTextForwarder
        sal_Int32          GetParagraphCount() const { return 1; }
        sal_uInt16          GetTextLen( sal_Int32 /*nParagraph*/ ) const { return 0; }
        sal_Int32          GetTextLen( sal_Int32 /*nParagraph*/ ) const { return 0; }
        OUString        GetText( const ESelection& /*rSel*/ ) const { return OUString(); }
        SfxItemSet      GetAttribs( const ESelection& /*rSel*/, sal_Bool /*bOnlyHardAttrib*/ = 0 ) const
        {
@@ -108,7 +108,7 @@ namespace accessibility
        SfxItemSet      GetParaAttribs( sal_Int32 /*nPara*/ ) const { return GetAttribs(ESelection()); }
        void            SetParaAttribs( sal_Int32 /*nPara*/, const SfxItemSet& /*rSet*/ ) {}
        void            RemoveAttribs( const ESelection& /*rSelection*/, sal_Bool /*bRemoveParaAttribs*/, sal_uInt16 /*nWhich*/ ){}
        void            GetPortions( sal_Int32 /*nPara*/, std::vector<sal_uInt16>& /*rList*/ ) const {}
        void            GetPortions( sal_Int32 /*nPara*/, std::vector<sal_Int32>& /*rList*/ ) const {}

        sal_uInt16          GetItemState( const ESelection& /*rSel*/, sal_uInt16 /*nWhich*/ ) const { return 0; }
        sal_uInt16          GetItemState( sal_Int32 /*nPara*/, sal_uInt16 /*nWhich*/ ) const { return 0; }
@@ -123,35 +123,35 @@ namespace accessibility
        const SfxItemSet * GetEmptyItemSetPtr() { return 0; }

        void        AppendParagraph() {}
        sal_uInt16  AppendTextPortion( sal_Int32 /*nPara*/, const OUString & /*rText*/, const SfxItemSet & /*rSet*/ ) { return 0; }
        sal_Int32  AppendTextPortion( sal_Int32 /*nPara*/, const OUString & /*rText*/, const SfxItemSet & /*rSet*/ ) { return 0; }

        //XTextCopy
        void        CopyText(const SvxTextForwarder& ){}

        OUString    CalcFieldValue( const SvxFieldItem& /*rField*/, sal_Int32 /*nPara*/, sal_uInt16 /*nPos*/, Color*& /*rpTxtColor*/, Color*& /*rpFldColor*/ )
        OUString    CalcFieldValue( const SvxFieldItem& /*rField*/, sal_Int32 /*nPara*/, sal_Int32 /*nPos*/, Color*& /*rpTxtColor*/, Color*& /*rpFldColor*/ )
        {
            return  OUString();
        }
        void            FieldClicked( const SvxFieldItem&, sal_Int32, xub_StrLen ) {;}
        void            FieldClicked( const SvxFieldItem&, sal_Int32, sal_Int32 ) {;}

        sal_Bool            IsValid() const { return sal_True; }

        void            SetNotifyHdl( const Link& ) {}
        LanguageType    GetLanguage( sal_Int32, sal_uInt16 ) const { return LANGUAGE_DONTKNOW; }
        sal_uInt16          GetFieldCount( sal_Int32 ) const { return 0; }
        LanguageType    GetLanguage( sal_Int32, sal_Int32 ) const { return LANGUAGE_DONTKNOW; }
        sal_Int32          GetFieldCount( sal_Int32 ) const { return 0; }
        EFieldInfo      GetFieldInfo( sal_Int32, sal_uInt16 ) const { return EFieldInfo(); }
        EBulletInfo     GetBulletInfo( sal_Int32 ) const { return EBulletInfo(); }
        Rectangle       GetCharBounds( sal_Int32, sal_uInt16 ) const { return Rectangle(); }
        Rectangle       GetCharBounds( sal_Int32, sal_Int32 ) const { return Rectangle(); }
        Rectangle       GetParaBounds( sal_Int32 ) const { return Rectangle(); }
        MapMode         GetMapMode() const { return MapMode(); }
        OutputDevice*   GetRefDevice() const { return NULL; }
        sal_Bool        GetIndexAtPoint( const Point&, sal_Int32&, sal_uInt16& ) const { return sal_False; }
        sal_Bool        GetWordIndices( sal_Int32, sal_uInt16, sal_uInt16&, sal_uInt16& ) const { return sal_False; }
        sal_Bool        GetAttributeRun( sal_uInt16&, sal_uInt16&, sal_Int32, sal_uInt16, sal_Bool ) const { return sal_False; }
        sal_uInt16          GetLineCount( sal_Int32 nPara ) const { return nPara == 0 ? 1 : 0; }
        sal_uInt16          GetLineLen( sal_Int32, sal_uInt16 ) const { return 0; }
        void            GetLineBoundaries( /*out*/sal_uInt16 & rStart, /*out*/sal_uInt16 & rEnd, sal_Int32 /*nParagraph*/, sal_uInt16 /*nLine*/ ) const  { rStart = rEnd = 0; }
        sal_uInt16          GetLineNumberAtIndex( sal_Int32 /*nPara*/, sal_uInt16 /*nIndex*/ ) const   { return 0; }
        sal_Bool        GetIndexAtPoint( const Point&, sal_Int32&, sal_Int32& ) const { return sal_False; }
        sal_Bool        GetWordIndices( sal_Int32, sal_Int32, sal_Int32&, sal_Int32& ) const { return sal_False; }
        sal_Bool        GetAttributeRun( sal_Int32&, sal_Int32&, sal_Int32, sal_Int32, sal_Bool ) const { return sal_False; }
        sal_Int32          GetLineCount( sal_Int32 nPara ) const { return nPara == 0 ? 1 : 0; }
        sal_Int32          GetLineLen( sal_Int32, sal_Int32 ) const { return 0; }
        void            GetLineBoundaries( /*out*/sal_Int32 & rStart, /*out*/sal_Int32 & rEnd, sal_Int32 /*nParagraph*/, sal_Int32 /*nLine*/ ) const  { rStart = rEnd = 0; }
        sal_Int32          GetLineNumberAtIndex( sal_Int32 /*nPara*/, sal_Int32 /*nIndex*/ ) const   { return 0; }

        // the following two methods would, strictly speaking, require
        // a switch to a real EditSource, too. Fortunately, the
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx
index 4927d8d4..3ca4219 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -386,18 +386,18 @@ namespace
            // support for WrongSpellVector. Create WrongSpellPrimitives as needed
            if(rInfo.mpWrongSpellVector && !aDXArray.empty())
            {
                const sal_uInt32 nSize(rInfo.mpWrongSpellVector->size());
                const sal_uInt32 nDXCount(aDXArray.size());
                const sal_Int32 nSize(rInfo.mpWrongSpellVector->size());
                const sal_Int32 nDXCount(aDXArray.size());
                const basegfx::BColor aSpellColor(1.0, 0.0, 0.0); // red, hard coded

                for(sal_uInt32 a(0); a < nSize; a++)
                for(sal_Int32 a(0); a < nSize; a++)
                {
                    const EEngineData::WrongSpellClass& rCandidate = (*rInfo.mpWrongSpellVector)[a];

                    if(rCandidate.nStart >= rInfo.mnTextStart && rCandidate.nEnd >= rInfo.mnTextStart && rCandidate.nEnd > rCandidate.nStart)
                    {
                        const sal_uInt32 nStart(rCandidate.nStart - rInfo.mnTextStart);
                        const sal_uInt32 nEnd(rCandidate.nEnd - rInfo.mnTextStart);
                        const sal_Int32 nStart(rCandidate.nStart - rInfo.mnTextStart);
                        const sal_Int32 nEnd(rCandidate.nEnd - rInfo.mnTextStart);
                        double fStart(0.0);
                        double fEnd(0.0);

diff --git a/svx/source/svdraw/svdoutl.cxx b/svx/source/svdraw/svdoutl.cxx
index 01dfc2b..e0fa528 100644
--- a/svx/source/svdraw/svdoutl.cxx
+++ b/svx/source/svdraw/svdoutl.cxx
@@ -74,7 +74,7 @@ void SdrOutliner::SetTextObjNoInit( const SdrTextObj* pObj )
    mpTextObj.reset( const_cast< SdrTextObj* >(pObj) );
}

OUString SdrOutliner::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos,
OUString SdrOutliner::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos,
                                     Color*& rpTxtColor, Color*& rpFldColor)
{
    bool bOk = false;
diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx
index 7088968..249cfa6 100644
--- a/sw/source/ui/uno/unotxdoc.cxx
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -3263,15 +3263,15 @@ uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
            for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
            {
                //every paragraph
                std::vector<sal_uInt16> aPortions;
                std::vector<sal_Int32> aPortions;
                rEditEng.GetPortions( nPar, aPortions );

                for ( size_t nPos = aPortions.size(); nPos; )
                {
                    //every position
                    --nPos;
                    sal_uInt16 nEnd = aPortions[ nPos ];
                    sal_uInt16 nStart = nPos ? aPortions[ nPos - 1 ] : 0;
                    sal_Int32 nEnd = aPortions[ nPos ];
                    sal_Int32 nStart = nPos ? aPortions[ nPos - 1 ] : 0;
                    ESelection aSelection( nPar, nStart, nPar, nEnd );
                    SfxItemSet aAttr = rEditEng.GetAttribs( aSelection );

diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index 06ed0d5..a0e27e8 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -703,7 +703,7 @@ TextPaM TextEngine::ImpInsertText( sal_Unicode c, const TextSelection& rCurSel, 

        if (xISC.is())
        {
            xub_StrLen nTmpPos = aPaM.GetIndex();
            sal_Int32 nTmpPos = aPaM.GetIndex();
            sal_Int16 nCheckMode = aCTLOptions.IsCTLSequenceCheckingRestricted() ?
                    i18n::InputSequenceCheckMode::STRICT : i18n::InputSequenceCheckMode::BASIC;