[Libreoffice-commits] core.git: accessibility/source basctl/source compilerplugins/clang cui/source dbaccess/source editeng/source idl/inc idl/source include/svtools oox/inc oox/source sc/inc sc/qa sc/source sd/source svtools/source svx/source sw/inc sw/source vcl/source

Noel Grandin noel at peralex.com
Mon Jul 6 00:05:29 PDT 2015


 accessibility/source/extended/accessiblelistboxentry.cxx              |    6 
 basctl/source/basicide/moduldl2.cxx                                   |    6 
 compilerplugins/clang/returnbyref.cxx                                 |   56 +
 cui/source/customize/macropg.cxx                                      |    3 
 cui/source/options/fontsubs.cxx                                       |   18 
 cui/source/options/optHeaderTabListbox.cxx                            |    4 
 cui/source/options/optaboutconfig.cxx                                 |    6 
 cui/source/options/optfltr.cxx                                        |   32 -
 cui/source/tabpages/autocdlg.cxx                                      |   18 
 cui/source/tabpages/macroass.cxx                                      |    8 
 dbaccess/source/ui/browser/dsEntriesNoExp.cxx                         |   10 
 dbaccess/source/ui/control/tabletree.cxx                              |   10 
 editeng/source/editeng/editdbg.cxx                                    |   22 
 editeng/source/editeng/editdoc.cxx                                    |   51 -
 editeng/source/editeng/editdoc.hxx                                    |   10 
 editeng/source/editeng/editeng.cxx                                    |   16 
 editeng/source/editeng/impedit.cxx                                    |   23 
 editeng/source/editeng/impedit2.cxx                                   |  285 ++++------
 editeng/source/editeng/impedit3.cxx                                   |  233 ++++----
 editeng/source/editeng/impedit4.cxx                                   |   32 -
 idl/inc/database.hxx                                                  |    2 
 idl/inc/lex.hxx                                                       |    2 
 idl/source/objects/bastype.cxx                                        |    8 
 idl/source/objects/module.cxx                                         |   20 
 idl/source/objects/object.cxx                                         |   11 
 idl/source/objects/slot.cxx                                           |   12 
 idl/source/objects/types.cxx                                          |   10 
 idl/source/prj/database.cxx                                           |   32 -
 include/svtools/treelistentry.hxx                                     |    4 
 include/svtools/viewdataentry.hxx                                     |    4 
 oox/inc/drawingml/chart/converterbase.hxx                             |    2 
 oox/source/drawingml/chart/chartspaceconverter.cxx                    |    5 
 oox/source/drawingml/chart/converterbase.cxx                          |    4 
 oox/source/drawingml/chart/datasourceconverter.cxx                    |   53 -
 sc/inc/column.hxx                                                     |    2 
 sc/inc/detdata.hxx                                                    |    2 
 sc/inc/dpdimsave.hxx                                                  |    4 
 sc/inc/dpobject.hxx                                                   |    4 
 sc/inc/userlist.hxx                                                   |    4 
 sc/qa/unit/subsequent_filters-test.cxx                                |    4 
 sc/qa/unit/ucalc_pivottable.cxx                                       |    3 
 sc/source/core/data/clipcontext.cxx                                   |    2 
 sc/source/core/data/column.cxx                                        |    4 
 sc/source/core/data/column3.cxx                                       |    6 
 sc/source/core/data/documen3.cxx                                      |    8 
 sc/source/core/data/dpdimsave.cxx                                     |    8 
 sc/source/core/data/dpobject.cxx                                      |    8 
 sc/source/core/data/table2.cxx                                        |    2 
 sc/source/core/data/table3.cxx                                        |   19 
 sc/source/core/tool/appoptio.cxx                                      |    2 
 sc/source/core/tool/detdata.cxx                                       |    4 
 sc/source/core/tool/userlist.cxx                                      |    8 
 sc/source/filter/excel/excimp8.cxx                                    |    4 
 sc/source/filter/excel/xechart.cxx                                    |    4 
 sc/source/filter/excel/xeescher.cxx                                   |    2 
 sc/source/filter/excel/xeformula.cxx                                  |    2 
 sc/source/filter/excel/xename.cxx                                     |    4 
 sc/source/filter/excel/xepivot.cxx                                    |   38 -
 sc/source/filter/excel/xepivotxml.cxx                                 |    9 
 sc/source/filter/excel/xichart.cxx                                    |    2 
 sc/source/filter/excel/xicontent.cxx                                  |    4 
 sc/source/filter/excel/xiname.cxx                                     |    2 
 sc/source/filter/excel/xipivot.cxx                                    |    4 
 sc/source/filter/excel/xlroot.cxx                                     |    4 
 sc/source/filter/inc/xlroot.hxx                                       |    2 
 sc/source/filter/xcl97/XclImpChangeTrack.cxx                          |    4 
 sc/source/filter/xcl97/xcl97esc.cxx                                   |   10 
 sc/source/filter/xml/XMLExportDataPilot.cxx                           |   43 -
 sc/source/filter/xml/xmlexprt.cxx                                     |   19 
 sc/source/ui/app/inputhdl.cxx                                         |   20 
 sc/source/ui/dbgui/PivotLayoutDialog.cxx                              |    4 
 sc/source/ui/dbgui/PivotLayoutTreeList.cxx                            |    8 
 sc/source/ui/dbgui/PivotLayoutTreeListData.cxx                        |   20 
 sc/source/ui/dbgui/tpsort.cxx                                         |    2 
 sc/source/ui/dbgui/tpsubt.cxx                                         |    2 
 sc/source/ui/docshell/docfunc.cxx                                     |   49 -
 sc/source/ui/docshell/docsh.cxx                                       |    6 
 sc/source/ui/docshell/docsh5.cxx                                      |    8 
 sc/source/ui/inc/PivotLayoutDialog.hxx                                |    2 
 sc/source/ui/inc/areasave.hxx                                         |    4 
 sc/source/ui/inc/rfindlst.hxx                                         |   16 
 sc/source/ui/miscdlgs/solveroptions.cxx                               |    8 
 sc/source/ui/navipi/content.cxx                                       |    4 
 sc/source/ui/optdlg/calcoptionsdlg.cxx                                |    6 
 sc/source/ui/optdlg/tpusrlst.cxx                                      |   10 
 sc/source/ui/undo/areasave.cxx                                        |   18 
 sc/source/ui/unoobj/appluno.cxx                                       |    2 
 sc/source/ui/unoobj/dapiuno.cxx                                       |   58 --
 sc/source/ui/view/dbfunc3.cxx                                         |   27 
 sc/source/ui/view/gridwin.cxx                                         |   16 
 sc/source/ui/view/gridwin2.cxx                                        |    4 
 sc/source/ui/view/gridwin4.cxx                                        |    6 
 sc/source/ui/view/tabview3.cxx                                        |    4 
 sd/source/ui/dlg/sdtreelb.cxx                                         |    4 
 svtools/source/contnr/simptabl.cxx                                    |    2 
 svtools/source/contnr/svimpbox.cxx                                    |   12 
 svtools/source/contnr/svtabbx.cxx                                     |   40 -
 svtools/source/contnr/treelistbox.cxx                                 |   61 +-
 svtools/source/contnr/treelistentry.cxx                               |    8 
 svtools/source/contnr/viewdataentry.cxx                               |    8 
 svtools/source/uno/treecontrolpeer.cxx                                |    8 
 svx/source/dialog/docrecovery.cxx                                     |    4 
 svx/source/inc/svdobjuserdatalist.hxx                                 |    2 
 svx/source/svdraw/svdobj.cxx                                          |    2 
 svx/source/svdraw/svdobjplusdata.cxx                                  |    2 
 svx/source/svdraw/svdobjuserdatalist.cxx                              |    4 
 svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx |    2 
 sw/inc/SidebarWin.hxx                                                 |    2 
 sw/inc/docsh.hxx                                                      |    6 
 sw/inc/format.hxx                                                     |   16 
 sw/inc/node.hxx                                                       |   22 
 sw/inc/shellio.hxx                                                    |    8 
 sw/inc/unotbl.hxx                                                     |    4 
 sw/inc/unotextcursor.hxx                                              |    2 
 sw/inc/unotextrange.hxx                                               |    4 
 sw/inc/viewsh.hxx                                                     |   26 
 sw/source/core/access/accmap.cxx                                      |    2 
 sw/source/core/access/parachangetrackinginfo.cxx                      |   15 
 sw/source/core/attr/format.cxx                                        |   16 
 sw/source/core/crsr/crbm.cxx                                          |    6 
 sw/source/core/crsr/viscrs.cxx                                        |    2 
 sw/source/core/doc/docdraw.cxx                                        |    2 
 sw/source/core/doc/notxtfrm.cxx                                       |    2 
 sw/source/core/doc/tblrwcl.cxx                                        |    4 
 sw/source/core/docnode/ndtbl.cxx                                      |    4 
 sw/source/core/docnode/node.cxx                                       |   22 
 sw/source/core/draw/dcontact.cxx                                      |   53 -
 sw/source/core/edit/edfld.cxx                                         |    6 
 sw/source/core/edit/edglbldc.cxx                                      |   20 
 sw/source/core/edit/editsh.cxx                                        |    4 
 sw/source/core/fields/ddetbl.cxx                                      |    4 
 sw/source/core/fields/postithelper.cxx                                |    6 
 sw/source/core/frmedt/fefly1.cxx                                      |    2 
 sw/source/core/frmedt/feshview.cxx                                    |   24 
 sw/source/core/graphic/ndgrf.cxx                                      |   18 
 sw/source/core/inc/flyfrm.hxx                                         |    2 
 sw/source/core/inc/frame.hxx                                          |    2 
 sw/source/core/inc/unoport.hxx                                        |    8 
 sw/source/core/layout/anchoredobject.cxx                              |    4 
 sw/source/core/layout/calcmove.cxx                                    |    6 
 sw/source/core/layout/flowfrm.cxx                                     |   18 
 sw/source/core/layout/fly.cxx                                         |   36 -
 sw/source/core/layout/flycnt.cxx                                      |    2 
 sw/source/core/layout/flyincnt.cxx                                    |    2 
 sw/source/core/layout/flylay.cxx                                      |    2 
 sw/source/core/layout/frmtool.cxx                                     |    2 
 sw/source/core/layout/layact.cxx                                      |   30 -
 sw/source/core/layout/newfrm.cxx                                      |   22 
 sw/source/core/layout/objectformatter.cxx                             |    2 
 sw/source/core/layout/pagechg.cxx                                     |    2 
 sw/source/core/layout/paintfrm.cxx                                    |   30 -
 sw/source/core/layout/sectfrm.cxx                                     |    4 
 sw/source/core/layout/sortedobjs.cxx                                  |    6 
 sw/source/core/layout/tabfrm.cxx                                      |   12 
 sw/source/core/layout/wsfrm.cxx                                       |   14 
 sw/source/core/objectpositioning/anchoredobjectposition.cxx           |    4 
 sw/source/core/text/EnhancedPDFExportHelper.cxx                       |    2 
 sw/source/core/text/frmcrsr.cxx                                       |    2 
 sw/source/core/text/frmpaint.cxx                                      |   14 
 sw/source/core/text/inftxt.cxx                                        |    2 
 sw/source/core/text/itratr.cxx                                        |    6 
 sw/source/core/text/porlay.cxx                                        |    4 
 sw/source/core/text/porrst.cxx                                        |   10 
 sw/source/core/text/redlnitr.cxx                                      |    8 
 sw/source/core/text/txtfly.cxx                                        |    8 
 sw/source/core/text/txtfrm.cxx                                        |    4 
 sw/source/core/text/txtftn.cxx                                        |    2 
 sw/source/core/txtnode/atrfld.cxx                                     |    4 
 sw/source/core/txtnode/fntcache.cxx                                   |    2 
 sw/source/core/txtnode/swfntcch.cxx                                   |    2 
 sw/source/core/unocore/unobkm.cxx                                     |    2 
 sw/source/core/unocore/unodraw.cxx                                    |    6 
 sw/source/core/unocore/unofield.cxx                                   |    2 
 sw/source/core/unocore/unoflatpara.cxx                                |    4 
 sw/source/core/unocore/unoframe.cxx                                   |    2 
 sw/source/core/unocore/unoftn.cxx                                     |    6 
 sw/source/core/unocore/unoidx.cxx                                     |    4 
 sw/source/core/unocore/unoobj.cxx                                     |    4 
 sw/source/core/unocore/unoobj2.cxx                                    |  104 +--
 sw/source/core/unocore/unoport.cxx                                    |   95 +--
 sw/source/core/unocore/unoportenum.cxx                                |    2 
 sw/source/core/unocore/unoredline.cxx                                 |   36 -
 sw/source/core/unocore/unorefmk.cxx                                   |    4 
 sw/source/core/unocore/unosect.cxx                                    |    2 
 sw/source/core/unocore/unotbl.cxx                                     |  106 +--
 sw/source/core/unocore/unotext.cxx                                    |   32 -
 sw/source/core/unocore/unotextmarkup.cxx                              |    6 
 sw/source/core/view/pagepreviewlayout.cxx                             |    2 
 sw/source/core/view/vdraw.cxx                                         |   14 
 sw/source/core/view/viewimp.cxx                                       |   18 
 sw/source/core/view/viewsh.cxx                                        |  106 +--
 sw/source/core/view/vnew.cxx                                          |    4 
 sw/source/filter/html/css1atr.cxx                                     |    4 
 sw/source/filter/html/svxcss1.hxx                                     |    2 
 sw/source/filter/writer/writer.cxx                                    |    8 
 sw/source/filter/ww8/wrtw8esh.cxx                                     |    2 
 sw/source/filter/ww8/wrtww8.cxx                                       |    4 
 sw/source/filter/xml/XMLRedlineImportHelper.cxx                       |    4 
 sw/source/filter/xml/xmlexpit.cxx                                     |   20 
 sw/source/filter/xml/xmlitmap.hxx                                     |    2 
 sw/source/filter/xml/xmlitmpr.cxx                                     |    4 
 sw/source/ui/config/optcomp.cxx                                       |    2 
 sw/source/ui/config/optpage.cxx                                       |    2 
 sw/source/ui/dbui/mmoutputpage.cxx                                    |    6 
 sw/source/ui/envelp/mailmrge.cxx                                      |  166 ++---
 sw/source/ui/misc/linenum.cxx                                         |    4 
 sw/source/uibase/app/appenv.cxx                                       |   16 
 sw/source/uibase/app/applab.cxx                                       |    4 
 sw/source/uibase/app/appopt.cxx                                       |    6 
 sw/source/uibase/app/docsh.cxx                                        |   14 
 sw/source/uibase/app/docshini.cxx                                     |    6 
 sw/source/uibase/app/docst.cxx                                        |    4 
 sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx                  |    2 
 sw/source/uibase/docvw/PostItMgr.cxx                                  |    8 
 sw/source/uibase/docvw/SidebarWin.cxx                                 |   20 
 sw/source/uibase/docvw/edtwin2.cxx                                    |    3 
 sw/source/uibase/lingu/sdrhhcwrap.cxx                                 |    2 
 sw/source/uibase/misc/redlndlg.cxx                                    |    4 
 sw/source/uibase/ribbar/inputwin.cxx                                  |    6 
 sw/source/uibase/shells/drwbassh.cxx                                  |    2 
 sw/source/uibase/shells/textsh.cxx                                    |    2 
 sw/source/uibase/shells/textsh1.cxx                                   |    2 
 sw/source/uibase/table/chartins.cxx                                   |    2 
 sw/source/uibase/uiview/pview.cxx                                     |    8 
 sw/source/uibase/uiview/srcview.cxx                                   |    2 
 sw/source/uibase/uiview/view0.cxx                                     |    3 
 sw/source/uibase/uiview/view2.cxx                                     |   26 
 sw/source/uibase/uiview/viewdraw.cxx                                  |    2 
 sw/source/uibase/uiview/viewprt.cxx                                   |   20 
 sw/source/uibase/uiview/viewstat.cxx                                  |    2 
 sw/source/uibase/uiview/viewtab.cxx                                   |    2 
 sw/source/uibase/uno/unoatxt.cxx                                      |    4 
 sw/source/uibase/uno/unomailmerge.cxx                                 |    6 
 sw/source/uibase/uno/unotxdoc.cxx                                     |    8 
 sw/source/uibase/uno/unotxvw.cxx                                      |   16 
 sw/source/uibase/utlui/content.cxx                                    |   14 
 sw/source/uibase/utlui/glbltree.cxx                                   |    4 
 vcl/source/edit/textdoc.cxx                                           |  110 +--
 vcl/source/edit/textdoc.hxx                                           |    2 
 vcl/source/edit/texteng.cxx                                           |   26 
 240 files changed, 1642 insertions(+), 1821 deletions(-)

New commits:
commit e9c3583c2cc27fc88ee81047c236ec99dd51e8de
Author: Noel Grandin <noel at peralex.com>
Date:   Fri Jul 3 11:31:14 2015 +0200

    improve the returnbyref loplugin
    
    Change-Id: I1b510a6194282dfa4a9001d473127c5ebc8b44eb
    Reviewed-on: https://gerrit.libreoffice.org/16731
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/accessibility/source/extended/accessiblelistboxentry.cxx b/accessibility/source/extended/accessiblelistboxentry.cxx
index e145b98..2438f60 100644
--- a/accessibility/source/extended/accessiblelistboxentry.cxx
+++ b/accessibility/source/extended/accessiblelistboxentry.cxx
@@ -462,9 +462,9 @@ namespace accessibility
         sal_uInt16 iTotleItemCount = pEntry->ItemCount();
         while( iCount < iTotleItemCount )
         {
-            const SvLBoxItem* pItem = pEntry->GetItem( iCount );
-            if ( pItem->GetType() == SV_ITEM_ID_LBOXSTRING &&
-                 !static_cast<const SvLBoxString*>( pItem )->GetText().isEmpty() )
+            const SvLBoxItem& rItem = pEntry->GetItem( iCount );
+            if ( rItem.GetType() == SV_ITEM_ID_LBOXSTRING &&
+                 !static_cast<const SvLBoxString&>( rItem ).GetText().isEmpty() )
             {
                 iRealItemCount++;
             }
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index 8218920..5f57528 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -126,7 +126,7 @@ void LibLBoxString::Paint(const Point& rPos, SvTreeListBox& /*rDev*/, vcl::Rende
     {
         ScriptDocument aDocument(static_cast<LibUserData*>(rEntry.GetUserData())->GetDocument());
 
-        OUString aLibName = static_cast<const SvLBoxString*>(rEntry.GetItem(1))->GetText();
+        OUString aLibName = static_cast<const SvLBoxString&>(rEntry.GetItem(1)).GetText();
         Reference<script::XLibraryContainer2> xModLibContainer(aDocument.getLibraryContainer(E_SCRIPTS), UNO_QUERY);
         Reference<script::XLibraryContainer2 > xDlgLibContainer(aDocument.getLibraryContainer(E_DIALOGS), UNO_QUERY);
         bReadOnly = (xModLibContainer.is() && xModLibContainer->hasByName(aLibName) && xModLibContainer->isLibraryReadOnly(aLibName))
@@ -251,8 +251,8 @@ void CheckBox::InitEntry(SvTreeListEntry* pEntry, const OUString& rTxt,
         sal_uInt16 nCount = pEntry->ItemCount();
         for ( sal_uInt16 nCol = 1; nCol < nCount; ++nCol )
         {
-            SvLBoxString* pCol = static_cast<SvLBoxString*>(pEntry->GetItem( nCol ));
-            LibLBoxString* pStr = new LibLBoxString( pEntry, 0, pCol->GetText() );
+            SvLBoxString& rCol = static_cast<SvLBoxString&>(pEntry->GetItem( nCol ));
+            LibLBoxString* pStr = new LibLBoxString( pEntry, 0, rCol.GetText() );
             pEntry->ReplaceItem( pStr, nCol );
         }
     }
diff --git a/compilerplugins/clang/returnbyref.cxx b/compilerplugins/clang/returnbyref.cxx
index b3044f3..d5052d6 100644
--- a/compilerplugins/clang/returnbyref.cxx
+++ b/compilerplugins/clang/returnbyref.cxx
@@ -34,6 +34,8 @@ public:
     virtual void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
 
     bool VisitCXXMethodDecl(const CXXMethodDecl * decl);
+private:
+    std::string getFilename(SourceLocation loc);
 };
 
 bool ReturnByRef::VisitCXXMethodDecl(const CXXMethodDecl * functionDecl) {
@@ -64,13 +66,26 @@ bool ReturnByRef::VisitCXXMethodDecl(const CXXMethodDecl * functionDecl) {
         return true;
     }
 
+    std::string aFilename = getFilename(functionDecl->getCanonicalDecl()->getLocStart());
+    if (aFilename == SRCDIR "/include/o3tl/cow_wrapper.hxx")
+    {
+        return true;
+    }
+    if ( functionDecl->getNameAsString() == "operator->") {
+        return true;
+    }
+    /*
+    std::string aParentName = functionDecl->getParent()->getQualifiedNameAsString();
+    std::string fqn = aParentName + "::" + functionDecl->getNameAsString();
+    if (aFilename == "TextCharAttribList::GetAttrib") {
+        return true;
+    }*/
+
     /*
       The AST here looks like:
       -CompoundStmt
        `-ReturnStmt
           `-UnaryOperator
-            `-MemberExpr
-              `-CXXThisExpr
     */
 
     const CompoundStmt* compoundStmt = dyn_cast< CompoundStmt >( functionDecl->getBody() );
@@ -87,34 +102,33 @@ bool ReturnByRef::VisitCXXMethodDecl(const CXXMethodDecl * functionDecl) {
     if (unaryOperator == nullptr || unaryOperator->getOpcode() != UO_AddrOf) {
         return true;
     }
-
-    nextStmt = dyn_cast<Expr>(*unaryOperator->child_begin())->IgnoreParens();
-    const MemberExpr* memberExpr = dyn_cast<MemberExpr>(nextStmt);
-    if (memberExpr == nullptr) {
-        return true;
-    }
-
-    nextStmt = dyn_cast<Expr>(*memberExpr->child_begin())->IgnoreParens();
-    const CXXThisExpr* cXXThisExpr = dyn_cast<CXXThisExpr>(nextStmt);
-    if (cXXThisExpr == nullptr) {
-        return true;
-    }
-
+nextStmt->dump();
     report(
         DiagnosticsEngine::Warning,
-        "rather return by reference",
+        "rather return by reference ",
         functionDecl->getSourceRange().getBegin())
       << functionDecl->getSourceRange();
+
     // display the location of the class member declaration so I don't have to search for it by hand
-    report(
-        DiagnosticsEngine::Note,
-        "rather return by reference",
-        functionDecl->getCanonicalDecl()->getSourceRange().getBegin())
-      << functionDecl->getCanonicalDecl()->getSourceRange();
+    auto otherLoc = functionDecl->getCanonicalDecl()->getSourceRange().getBegin();
+    if (otherLoc != functionDecl->getSourceRange().getBegin())
+    {
+        report(
+            DiagnosticsEngine::Note,
+            "rather return by reference",
+            functionDecl->getCanonicalDecl()->getSourceRange().getBegin())
+          << functionDecl->getCanonicalDecl()->getSourceRange();
+    }
 
     return true;
 }
 
+std::string ReturnByRef::getFilename(SourceLocation loc)
+{
+    SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(loc);
+    return compiler.getSourceManager().getFilename(spellingLocation);
+}
+
 loplugin::Plugin::Registration< ReturnByRef > X("returnbyref");
 
 }
diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx
index a57fb4b..0e14b0f 100644
--- a/cui/source/customize/macropg.cxx
+++ b/cui/source/customize/macropg.cxx
@@ -216,8 +216,7 @@ void _SvxMacroTabPage::EnableButtons()
     const SvTreeListEntry* pE = mpImpl->pEventLB->GetListBox().FirstSelected();
     if ( pE )
     {
-        const SvLBoxString* pEventMacro = static_cast<const SvLBoxString*>(pE->GetItem( LB_MACROS_ITEMPOS ));
-        mpImpl->pDeletePB->Enable( 0 != pEventMacro && !mpImpl->bReadOnly );
+        mpImpl->pDeletePB->Enable( !mpImpl->bReadOnly );
 
         mpImpl->pAssignPB->Enable( !mpImpl->bReadOnly );
         if( mpImpl->pAssignComponentPB )
diff --git a/cui/source/options/fontsubs.cxx b/cui/source/options/fontsubs.cxx
index 95bedee..f3888b6 100644
--- a/cui/source/options/fontsubs.cxx
+++ b/cui/source/options/fontsubs.cxx
@@ -502,23 +502,22 @@ bool SvxFontSubstCheckListBox::IsChecked(SvTreeListEntry* pEntry, sal_uInt16 nCo
 
 void SvxFontSubstCheckListBox::SetCheckButtonState( SvTreeListEntry* pEntry, sal_uInt16 nCol, SvButtonState eState)
 {
-    SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetItem(nCol + 1));
+    SvLBoxButton& rItem = static_cast<SvLBoxButton&>(pEntry->GetItem(nCol + 1));
 
-    DBG_ASSERT(pItem,"SetCheckButton:Item not found");
-    if (pItem->GetType() == SV_ITEM_ID_LBOXBUTTON)
+    if (rItem.GetType() == SV_ITEM_ID_LBOXBUTTON)
     {
         switch( eState )
         {
             case SV_BUTTON_CHECKED:
-                pItem->SetStateChecked();
+                rItem.SetStateChecked();
                 break;
 
             case SV_BUTTON_UNCHECKED:
-                pItem->SetStateUnchecked();
+                rItem.SetStateUnchecked();
                 break;
 
             case SV_BUTTON_TRISTATE:
-                pItem->SetStateTristate();
+                rItem.SetStateTristate();
                 break;
         }
         InvalidateEntry( pEntry );
@@ -528,12 +527,11 @@ void SvxFontSubstCheckListBox::SetCheckButtonState( SvTreeListEntry* pEntry, sal
 SvButtonState SvxFontSubstCheckListBox::GetCheckButtonState( SvTreeListEntry* pEntry, sal_uInt16 nCol )
 {
     SvButtonState eState = SV_BUTTON_UNCHECKED;
-    SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetItem(nCol + 1));
-    DBG_ASSERT(pItem,"GetChButnState:Item not found");
+    SvLBoxButton& rItem = static_cast<SvLBoxButton&>(pEntry->GetItem(nCol + 1));
 
-    if (pItem->GetType() == SV_ITEM_ID_LBOXBUTTON)
+    if (rItem.GetType() == SV_ITEM_ID_LBOXBUTTON)
     {
-        SvItemStateFlags nButtonFlags = pItem->GetButtonFlags();
+        SvItemStateFlags nButtonFlags = rItem.GetButtonFlags();
         eState = SvLBoxButtonData::ConvertToButtonState( nButtonFlags );
     }
 
diff --git a/cui/source/options/optHeaderTabListbox.cxx b/cui/source/options/optHeaderTabListbox.cxx
index bba08c0..09c8e7e 100644
--- a/cui/source/options/optHeaderTabListbox.cxx
+++ b/cui/source/options/optHeaderTabListbox.cxx
@@ -70,8 +70,8 @@ void OptHeaderTabListBox::InitEntry( SvTreeListEntry* pEntry, const OUString& rT
     for ( sal_uInt16 nCol = 1; nCol < _nTabCount; ++nCol )
     {
         // initialize all columns with own class (column 0 == Bitmap)
-        SvLBoxString* pCol = static_cast<SvLBoxString*>(pEntry->GetItem( nCol ));
-        OptLBoxString_Impl* pStr = new OptLBoxString_Impl( pEntry, 0, pCol->GetText() );
+        SvLBoxString& rCol = static_cast<SvLBoxString&>(pEntry->GetItem( nCol ));
+        OptLBoxString_Impl* pStr = new OptLBoxString_Impl( pEntry, 0, rCol.GetText() );
         pEntry->ReplaceItem( pStr, nCol );
     }
 }
diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx
index 3b846b8..02acd70 100644
--- a/cui/source/options/optaboutconfig.cxx
+++ b/cui/source/options/optaboutconfig.cxx
@@ -747,8 +747,8 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl )
                 SvTreeListEntries::iterator it = std::find_if(m_prefBoxEntries.begin(), m_prefBoxEntries.end(),
                   [&pUserData, &sPropertyName](SvTreeListEntry &entry) -> bool
                   {
-                      return static_cast< SvLBoxString* >( entry.GetItem(1) )->GetText().equals( pUserData->sPropertyPath ) &&
-                              static_cast< SvLBoxString* >( entry.GetItem(2) )->GetText().equals( sPropertyName );
+                      return static_cast< SvLBoxString& >( entry.GetItem(1) ).GetText().equals( pUserData->sPropertyPath ) &&
+                              static_cast< SvLBoxString& >( entry.GetItem(2) ).GetText().equals( sPropertyName );
                   }
                 );
                 if (it != m_prefBoxEntries.end())
@@ -793,7 +793,7 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, SearchHdl_Impl)
 
             for(size_t i = 1; i < it->ItemCount(); ++i)
             {
-                OUString scrTxt = static_cast< SvLBoxString* >( it->GetItem(i) )->GetText();
+                OUString scrTxt = static_cast< SvLBoxString& >( it->GetItem(i) ).GetText();
                 endPos = scrTxt.getLength();
                 if( textSearch.SearchForward( scrTxt, &startPos, &endPos ) )
                 {
diff --git a/cui/source/options/optfltr.cxx b/cui/source/options/optfltr.cxx
index 0de47b4..6ee34bf 100644
--- a/cui/source/options/optfltr.cxx
+++ b/cui/source/options/optfltr.cxx
@@ -237,10 +237,10 @@ bool OfaMSFilterTabPage2::FillItemSet( SfxItemSet* )
         SvTreeListEntry* pEntry = GetEntry4Type( pArr->eType );
         if( pEntry )
         {
-            SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetItem( nCol ));
-            if (pItem && pItem->GetType() == SV_ITEM_ID_LBOXBUTTON)
+            SvLBoxButton& rItem = static_cast<SvLBoxButton&>(pEntry->GetItem( nCol ));
+            if (rItem.GetType() == SV_ITEM_ID_LBOXBUTTON)
             {
-                SvItemStateFlags nButtonFlags = pItem->GetButtonFlags();
+                SvItemStateFlags nButtonFlags = rItem.GetButtonFlags();
                 bCheck = SV_BUTTON_CHECKED ==
                         SvLBoxButtonData::ConvertToButtonState( nButtonFlags );
 
@@ -305,13 +305,13 @@ void OfaMSFilterTabPage2::Reset( const SfxItemSet* )
         SvTreeListEntry* pEntry = GetEntry4Type( static_cast< sal_IntPtr >( pArr->eType ) );
         if( pEntry )
         {
-            SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetItem( nCol ));
-            if (pItem && pItem->GetType() == SV_ITEM_ID_LBOXBUTTON)
+            SvLBoxButton& rItem = static_cast<SvLBoxButton&>(pEntry->GetItem( nCol ));
+            if (rItem.GetType() == SV_ITEM_ID_LBOXBUTTON)
             {
                 if( (rOpt.*pArr->FnIs)() )
-                    pItem->SetStateChecked();
+                    rItem.SetStateChecked();
                 else
-                    pItem->SetStateUnchecked();
+                    rItem.SetStateUnchecked();
                 m_pCheckLB->InvalidateEntry( pEntry );
             }
         }
@@ -391,23 +391,22 @@ void OfaMSFilterTabPage2::MSFltrSimpleTable::HBarClick()
 void OfaMSFilterTabPage2::MSFltrSimpleTable::SetCheckButtonState(
                             SvTreeListEntry* pEntry, sal_uInt16 nCol, SvButtonState eState)
 {
-    SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetItem(nCol + 1));
+    SvLBoxButton& rItem = static_cast<SvLBoxButton&>(pEntry->GetItem(nCol + 1));
 
-    DBG_ASSERT(pItem,"SetCheckButton:Item not found");
-    if (pItem->GetType() == SV_ITEM_ID_LBOXBUTTON)
+    if (rItem.GetType() == SV_ITEM_ID_LBOXBUTTON)
     {
         switch( eState )
         {
             case SV_BUTTON_CHECKED:
-                pItem->SetStateChecked();
+                rItem.SetStateChecked();
                 break;
 
             case SV_BUTTON_UNCHECKED:
-                pItem->SetStateUnchecked();
+                rItem.SetStateUnchecked();
                 break;
 
             case SV_BUTTON_TRISTATE:
-                pItem->SetStateTristate();
+                rItem.SetStateTristate();
                 break;
         }
         InvalidateEntry( pEntry );
@@ -418,12 +417,11 @@ SvButtonState OfaMSFilterTabPage2::MSFltrSimpleTable::GetCheckButtonState(
                                     SvTreeListEntry* pEntry, sal_uInt16 nCol )
 {
     SvButtonState eState = SV_BUTTON_UNCHECKED;
-    SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetItem(nCol + 1));
-    DBG_ASSERT(pItem,"GetChButnState:Item not found");
+    SvLBoxButton& rItem = static_cast<SvLBoxButton&>(pEntry->GetItem(nCol + 1));
 
-    if (pItem->GetType() == SV_ITEM_ID_LBOXBUTTON)
+    if (rItem.GetType() == SV_ITEM_ID_LBOXBUTTON)
     {
-        SvItemStateFlags nButtonFlags = pItem->GetButtonFlags();
+        SvItemStateFlags nButtonFlags = rItem.GetButtonFlags();
         eState = SvLBoxButtonData::ConvertToButtonState( nButtonFlags );
     }
 
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx
index 69f5147..ca6f668 100644
--- a/cui/source/tabpages/autocdlg.cxx
+++ b/cui/source/tabpages/autocdlg.cxx
@@ -795,23 +795,22 @@ bool OfaACorrCheckListBox::IsChecked(sal_uLong nPos, sal_uInt16 nCol)
 
 void OfaACorrCheckListBox::SetCheckButtonState( SvTreeListEntry* pEntry, sal_uInt16 nCol, SvButtonState eState)
 {
-    SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetItem(nCol + 1));
+    SvLBoxButton& rItem = static_cast<SvLBoxButton&>(pEntry->GetItem(nCol + 1));
 
-    DBG_ASSERT(pItem,"SetCheckButton:Item not found");
-    if (pItem->GetType() == SV_ITEM_ID_LBOXBUTTON)
+    if (rItem.GetType() == SV_ITEM_ID_LBOXBUTTON)
     {
         switch( eState )
         {
             case SV_BUTTON_CHECKED:
-                pItem->SetStateChecked();
+                rItem.SetStateChecked();
                 break;
 
             case SV_BUTTON_UNCHECKED:
-                pItem->SetStateUnchecked();
+                rItem.SetStateUnchecked();
                 break;
 
             case SV_BUTTON_TRISTATE:
-                pItem->SetStateTristate();
+                rItem.SetStateTristate();
                 break;
         }
         InvalidateEntry( pEntry );
@@ -821,12 +820,11 @@ void OfaACorrCheckListBox::SetCheckButtonState( SvTreeListEntry* pEntry, sal_uIn
 SvButtonState OfaACorrCheckListBox::GetCheckButtonState( SvTreeListEntry* pEntry, sal_uInt16 nCol )
 {
     SvButtonState eState = SV_BUTTON_UNCHECKED;
-    SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetItem(nCol + 1));
-    DBG_ASSERT(pItem,"GetChButnState:Item not found");
+    SvLBoxButton& rItem = static_cast<SvLBoxButton&>(pEntry->GetItem(nCol + 1));
 
-    if (pItem->GetType() == SV_ITEM_ID_LBOXBUTTON)
+    if (rItem.GetType() == SV_ITEM_ID_LBOXBUTTON)
     {
-        SvItemStateFlags nButtonFlags = pItem->GetButtonFlags();
+        SvItemStateFlags nButtonFlags = rItem.GetButtonFlags();
         eState = SvLBoxButtonData::ConvertToButtonState( nButtonFlags );
     }
 
diff --git a/cui/source/tabpages/macroass.cxx b/cui/source/tabpages/macroass.cxx
index cb096ca..5bc3697 100644
--- a/cui/source/tabpages/macroass.cxx
+++ b/cui/source/tabpages/macroass.cxx
@@ -126,7 +126,7 @@ void _SfxMacroTabPage::EnableButtons()
         const SvxMacro* pM = aTbl.Get( (sal_uInt16)reinterpret_cast<sal_uLong>(pE->GetUserData()) );
         mpImpl->pDeletePB->Enable( 0 != pM && !mpImpl->bReadOnly );
 
-        OUString sEventMacro = static_cast<const SvLBoxString*>(pE->GetItem( LB_MACROS_ITEMPOS ))->GetText();
+        OUString sEventMacro = static_cast<const SvLBoxString&>(pE->GetItem( LB_MACROS_ITEMPOS )).GetText();
 
         OUString sScriptURI = mpImpl->pMacroLB->GetSelectedScriptURI();
         mpImpl->pAssignPB->Enable( !mpImpl->bReadOnly && !sScriptURI.equalsIgnoreAsciiCase( sEventMacro ) );
@@ -415,10 +415,10 @@ void _SfxMacroTabPage::FillEvents()
         SvTreeListEntry*    pE = rListBox.GetEntry( n );
         if( pE )
         {
-            SvLBoxString*   pLItem = static_cast<SvLBoxString*>( pE->GetItem( LB_MACROS_ITEMPOS ) );
-            DBG_ASSERT( pLItem && SV_ITEM_ID_LBOXSTRING == pLItem->GetType(), "_SfxMacroTabPage::FillEvents(): no LBoxString" );
+            SvLBoxString&     rLItem = static_cast<SvLBoxString&>( pE->GetItem( LB_MACROS_ITEMPOS ) );
+            DBG_ASSERT( SV_ITEM_ID_LBOXSTRING == rLItem.GetType(), "_SfxMacroTabPage::FillEvents(): no LBoxString" );
 
-            OUString          sOld( pLItem->GetText() );
+            OUString          sOld( rLItem.GetText() );
             OUString          sNew;
             sal_uInt16        nEventId = ( sal_uInt16 ) reinterpret_cast<sal_uLong>( pE->GetUserData() );
             if( aTbl.IsKeyValid( nEventId ) )
diff --git a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
index 50d477d..8563021 100644
--- a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
+++ b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
@@ -231,14 +231,14 @@ void SbaTableQueryBrowser::notifyHiContrastChanged()
             sal_uInt16 nCount = pEntryLoop->ItemCount();
             for (sal_uInt16 i=0;i<nCount;++i)
             {
-                SvLBoxItem* pItem = pEntryLoop->GetItem(i);
-                if (!pItem || pItem->GetType() != SV_ITEM_ID_LBOXCONTEXTBMP)
+                SvLBoxItem& rItem = pEntryLoop->GetItem(i);
+                if (rItem.GetType() != SV_ITEM_ID_LBOXCONTEXTBMP)
                     continue;
 
-                SvLBoxContextBmp* pContextBitmapItem = static_cast< SvLBoxContextBmp* >( pItem );
+                SvLBoxContextBmp& rContextBitmapItem = static_cast< SvLBoxContextBmp& >( rItem );
 
-                pContextBitmapItem->SetBitmap1( aImage );
-                pContextBitmapItem->SetBitmap2( aImage );
+                rContextBitmapItem.SetBitmap1( aImage );
+                rContextBitmapItem.SetBitmap2( aImage );
                 break;
             }
 
diff --git a/dbaccess/source/ui/control/tabletree.cxx b/dbaccess/source/ui/control/tabletree.cxx
index ed0083b..352b85c 100644
--- a/dbaccess/source/ui/control/tabletree.cxx
+++ b/dbaccess/source/ui/control/tabletree.cxx
@@ -112,10 +112,10 @@ void OTableTreeListBox::notifyHiContrastChanged()
         size_t nCount = pEntryLoop->ItemCount();
         for (size_t i=0;i<nCount;++i)
         {
-            SvLBoxItem* pItem = pEntryLoop->GetItem(i);
-            if (pItem && pItem->GetType() == SV_ITEM_ID_LBOXCONTEXTBMP)
+            SvLBoxItem& rItem = pEntryLoop->GetItem(i);
+            if (rItem.GetType() == SV_ITEM_ID_LBOXCONTEXTBMP)
             {
-                SvLBoxContextBmp* pContextBitmapItem = static_cast< SvLBoxContextBmp* >( pItem );
+                SvLBoxContextBmp& rContextBitmapItem = static_cast< SvLBoxContextBmp& >( rItem );
 
                 Image aImage;
                 if ( isFolderEntry( pEntryLoop ) )
@@ -128,8 +128,8 @@ void OTableTreeListBox::notifyHiContrastChanged()
                     m_xImageProvider->getImages( sCompleteName, DatabaseObject::TABLE, aImage );
                 }
 
-                pContextBitmapItem->SetBitmap1( aImage );
-                pContextBitmapItem->SetBitmap2( aImage );
+                rContextBitmapItem.SetBitmap1( aImage );
+                rContextBitmapItem.SetBitmap2( aImage );
                 break;
             }
         }
diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx
index 34f7ddf..a4cbb28 100644
--- a/editeng/source/editeng/editdbg.cxx
+++ b/editeng/source/editeng/editdbg.cxx
@@ -385,17 +385,17 @@ void EditDbg::ShowEditEngineData( EditEngine* pEE, bool bInfoBox )
         sal_Int32 n = 0;
         for ( z = 0; z < nTextPortions; z++ )
         {
-            TextPortion* pPortion = pPPortion->GetTextPortions()[z];
+            TextPortion& rPortion = pPPortion->GetTextPortions()[z];
             aPortionStr.append(' ');
-            aPortionStr.append(static_cast<sal_Int32>(pPortion->GetLen()));
+            aPortionStr.append(static_cast<sal_Int32>(rPortion.GetLen()));
             aPortionStr.append('(');
-            aPortionStr.append(static_cast<sal_Int32>(pPortion->GetSize().Width()));
+            aPortionStr.append(static_cast<sal_Int32>(rPortion.GetSize().Width()));
             aPortionStr.append(')');
             aPortionStr.append('[');
-            aPortionStr.append(static_cast<sal_Int32>(pPortion->GetKind()));
+            aPortionStr.append(static_cast<sal_Int32>(rPortion.GetKind()));
             aPortionStr.append(']');
             aPortionStr.append(';');
-            n += pPortion->GetLen();
+            n += rPortion.GetLen();
         }
         aPortionStr.append("\nA");
         aPortionStr.append(static_cast<sal_Int32>(nPortion));
@@ -410,17 +410,17 @@ void EditDbg::ShowEditEngineData( EditEngine* pEE, bool bInfoBox )
         sal_uInt16 nLine;
         for ( nLine = 0; nLine < pPPortion->GetLines().Count(); nLine++ )
         {
-            EditLine* pLine = pPPortion->GetLines()[nLine];
+            EditLine& rLine = pPPortion->GetLines()[nLine];
 
-            OString aLine(OUStringToOString(pPPortion->GetNode()->Copy(pLine->GetStart(), pLine->GetEnd() - pLine->GetStart()), RTL_TEXTENCODING_ASCII_US));
+            OString aLine(OUStringToOString(pPPortion->GetNode()->Copy(rLine.GetStart(), rLine.GetEnd() - rLine.GetStart()), RTL_TEXTENCODING_ASCII_US));
             fprintf( fp, "\nLine %i\t>%s<", nLine, aLine.getStr() );
         }
         // then the internal data ...
         for ( nLine = 0; nLine < pPPortion->GetLines().Count(); nLine++ )
         {
-            EditLine* pLine = pPPortion->GetLines()[nLine];
-            fprintf( fp, "\nZeile %i:\tStart: %" SAL_PRIdINT32 ",\tEnd: %" SAL_PRIdINT32, nLine, pLine->GetStart(), pLine->GetEnd() );
-            fprintf( fp, "\t\tPortions: %" SAL_PRIdINT32 " - %" SAL_PRIdINT32 ".\tHight: %i, Ascent=%i", pLine->GetStartPortion(), pLine->GetEndPortion(), pLine->GetHeight(), pLine->GetMaxAscent() );
+            EditLine& rLine = pPPortion->GetLines()[nLine];
+            fprintf( fp, "\nZeile %i:\tStart: %" SAL_PRIdINT32 ",\tEnd: %" SAL_PRIdINT32, nLine, rLine.GetStart(), rLine.GetEnd() );
+            fprintf( fp, "\t\tPortions: %" SAL_PRIdINT32 " - %" SAL_PRIdINT32 ".\tHight: %i, Ascent=%i", rLine.GetStartPortion(), rLine.GetEndPortion(), rLine.GetHeight(), rLine.GetMaxAscent() );
         }
 
         fprintf( fp, "\n-----------------------------------------------------------------------------" );
@@ -494,7 +494,7 @@ bool ParaPortion::DbgCheckTextPortions(ParaPortion const& rPara)
     sal_uInt16 nXLen = 0;
     for (sal_Int32 nPortion = 0; nPortion < rPara.aTextPortionList.Count(); nPortion++)
     {
-        nXLen = nXLen + rPara.aTextPortionList[nPortion]->GetLen();
+        nXLen = nXLen + rPara.aTextPortionList[nPortion].GetLen();
     }
     return nXLen == rPara.pNode->Len();
 }
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index d1211eea..3f1e342 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -439,14 +439,14 @@ sal_Int32 TextPortionList::Count() const
     return (sal_Int32)maPortions.size();
 }
 
-const TextPortion* TextPortionList::operator[](sal_Int32 nPos) const
+const TextPortion& TextPortionList::operator[](sal_Int32 nPos) const
 {
-    return &maPortions[nPos];
+    return maPortions[nPos];
 }
 
-TextPortion* TextPortionList::operator[](sal_Int32 nPos)
+TextPortion& TextPortionList::operator[](sal_Int32 nPos)
 {
-    return &maPortions[nPos];
+    return maPortions[nPos];
 }
 
 void TextPortionList::Append(TextPortion* p)
@@ -636,12 +636,12 @@ sal_Int32 ParaPortion::GetLineNumber( sal_Int32 nIndex ) const
 
     for ( sal_Int32 nLine = 0; nLine < aLineList.Count(); nLine++ )
     {
-        if ( aLineList[nLine]->IsIn( nIndex ) )
+        if ( aLineList[nLine].IsIn( nIndex ) )
             return (sal_Int32)nLine;
     }
 
     // Then it should be at the end of the last line!
-    DBG_ASSERT( nIndex == aLineList[ aLineList.Count() - 1 ]->GetEnd(), "Index dead wrong!" );
+    DBG_ASSERT( nIndex == aLineList[ aLineList.Count() - 1 ].GetEnd(), "Index dead wrong!" );
     return (aLineList.Count()-1);
 }
 
@@ -656,10 +656,10 @@ void ParaPortion::CorrectValuesBehindLastFormattedLine( sal_Int32 nLastFormatted
     DBG_ASSERT( nLines, "CorrectPortionNumbersFromLine: Empty Portion?" );
     if ( nLastFormattedLine < ( nLines - 1 ) )
     {
-        const EditLine* pLastFormatted = aLineList[ nLastFormattedLine ];
-        const EditLine* pUnformatted = aLineList[ nLastFormattedLine+1 ];
-        sal_Int32 nPortionDiff = pUnformatted->GetStartPortion() - pLastFormatted->GetEndPortion();
-        sal_Int32 nTextDiff = pUnformatted->GetStart() - pLastFormatted->GetEnd();
+        const EditLine& rLastFormatted = aLineList[ nLastFormattedLine ];
+        const EditLine& rUnformatted = aLineList[ nLastFormattedLine+1 ];
+        sal_Int32 nPortionDiff = rUnformatted.GetStartPortion() - rLastFormatted.GetEndPortion();
+        sal_Int32 nTextDiff = rUnformatted.GetStart() - rLastFormatted.GetEnd();
         nTextDiff++;    // LastFormatted->GetEnd() was included => 1 deducted too much!
 
         // The first unformatted must begin exactly one Portion behind the last
@@ -672,19 +672,19 @@ void ParaPortion::CorrectValuesBehindLastFormattedLine( sal_Int32 nLastFormatted
         {
             for ( sal_Int32 nL = nLastFormattedLine+1; nL < nLines; nL++ )
             {
-                EditLine* pLine = aLineList[ nL ];
+                EditLine& rLine = aLineList[ nL ];
 
-                pLine->GetStartPortion() = pLine->GetStartPortion() + nPDiff;
-                pLine->GetEndPortion() = pLine->GetEndPortion() + nPDiff;
+                rLine.GetStartPortion() = rLine.GetStartPortion() + nPDiff;
+                rLine.GetEndPortion() = rLine.GetEndPortion() + nPDiff;
 
-                pLine->GetStart() = pLine->GetStart() + nTDiff;
-                pLine->GetEnd() = pLine->GetEnd() + nTDiff;
+                rLine.GetStart() = rLine.GetStart() + nTDiff;
+                rLine.GetEnd() = rLine.GetEnd() + nTDiff;
 
-                pLine->SetValid();
+                rLine.SetValid();
             }
         }
     }
-    DBG_ASSERT( aLineList[ aLineList.Count()-1 ]->GetEnd() == pNode->Len(), "CorrectLines: The end is not right!" );
+    DBG_ASSERT( aLineList[ aLineList.Count()-1 ].GetEnd() == pNode->Len(), "CorrectLines: The end is not right!" );
 }
 
 // Shared reverse lookup acceleration pieces ...
@@ -1074,20 +1074,19 @@ Size EditLine::CalcTextSize( ParaPortion& rParaPortion )
 {
     Size aSz;
     Size aTmpSz;
-    TextPortion* pPortion;
 
     DBG_ASSERT( rParaPortion.GetTextPortions().Count(), "GetTextSize before CreatePortions !" );
 
     for ( sal_Int32 n = nStartPortion; n <= nEndPortion; n++ )
     {
-        pPortion = rParaPortion.GetTextPortions()[n];
-        switch ( pPortion->GetKind() )
+        TextPortion& rPortion = rParaPortion.GetTextPortions()[n];
+        switch ( rPortion.GetKind() )
         {
             case PortionKind::TEXT:
             case PortionKind::FIELD:
             case PortionKind::HYPHENATOR:
             {
-                aTmpSz = pPortion->GetSize();
+                aTmpSz = rPortion.GetSize();
                 aSz.Width() += aTmpSz.Width();
                 if ( aSz.Height() < aTmpSz.Height() )
                     aSz.Height() = aTmpSz.Height();
@@ -1095,7 +1094,7 @@ Size EditLine::CalcTextSize( ParaPortion& rParaPortion )
             break;
             case PortionKind::TAB:
             {
-                aSz.Width() += pPortion->GetSize().Width();
+                aSz.Width() += rPortion.GetSize().Width();
             }
             break;
             case PortionKind::LINEBREAK: break;
@@ -1150,14 +1149,14 @@ sal_Int32 EditLineList::Count() const
     return maLines.size();
 }
 
-const EditLine* EditLineList::operator[](sal_Int32 nPos) const
+const EditLine& EditLineList::operator[](sal_Int32 nPos) const
 {
-    return &maLines[nPos];
+    return maLines[nPos];
 }
 
-EditLine* EditLineList::operator[](sal_Int32 nPos)
+EditLine& EditLineList::operator[](sal_Int32 nPos)
 {
-    return &maLines[nPos];
+    return maLines[nPos];
 }
 
 void EditLineList::Append(EditLine* p)
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index 503b91a..ce5e117 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -459,8 +459,8 @@ public:
     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);
+    const TextPortion& operator[](sal_Int32 nPos) const;
+    TextPortion& operator[](sal_Int32 nPos);
 
     void Append(TextPortion* p);
     void Insert(sal_Int32 nPos, TextPortion* p);
@@ -574,8 +574,8 @@ public:
     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);
+    const EditLine& operator[](sal_Int32 nPos) const;
+    EditLine& operator[](sal_Int32 nPos);
 
     void Append(EditLine* p);
     void Insert(sal_Int32 nPos, EditLine* p);
@@ -633,7 +633,7 @@ public:
     void                SetVisible( bool bVisible );
     bool                IsVisible() const { return bVisible; }
 
-    bool            IsEmpty() { return GetTextPortions().Count() == 1 && GetTextPortions()[0]->GetLen() == 0; }
+    bool            IsEmpty() { return GetTextPortions().Count() == 1 && GetTextPortions()[0].GetLen() == 0; }
 
     long                GetHeight() const           { return ( bVisible ? nHeight : 0 ); }
     sal_Int32           GetFirstLineOffset() const  { return ( bVisible ? nFirstLineOffset : 0 ); }
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index b8aaa65..e6c2fc0 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -1777,7 +1777,7 @@ void EditEngine::GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList )
         sal_Int32 nTextPortions = pParaPortion->GetTextPortions().Count();
         for ( sal_Int32 n = 0; n < nTextPortions; n++ )
         {
-            nEnd = nEnd + pParaPortion->GetTextPortions()[n]->GetLen();
+            nEnd = nEnd + pParaPortion->GetTextPortions()[n].GetLen();
             rList.push_back( nEnd );
         }
     }
@@ -1884,8 +1884,8 @@ long EditEngine::GetFirstLineStartX( sal_Int32 nParagraph )
         DBG_ASSERT( pImpEditEngine->IsFormatted() || !pImpEditEngine->IsFormatting(), "GetFirstLineStartX: Doc not formatted - unable to format!" );
         if ( !pImpEditEngine->IsFormatted() )
             pImpEditEngine->FormatDoc();
-        const EditLine* pFirstLine = pPPortion->GetLines()[0];
-        nX = pFirstLine->GetStartPosX();
+        const EditLine& rFirstLine = pPPortion->GetLines()[0];
+        nX = rFirstLine.GetStartPosX();
     }
     return nX;
 }
@@ -1916,8 +1916,8 @@ Point EditEngine::GetDocPosTopLeft( sal_Int32 nParagraph )
         if ( pPPortion->GetLines().Count() )
         {
             // Correct it if large Bullet.
-            const EditLine* pFirstLine = pPPortion->GetLines()[0];
-            aPoint.X() = pFirstLine->GetStartPosX();
+            const EditLine& rFirstLine = pPPortion->GetLines()[0];
+            aPoint.X() = rFirstLine.GetStartPosX();
         }
         else
         {
@@ -1968,8 +1968,8 @@ bool EditEngine::IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder )
             DBG_ASSERT( pParaPortion, "ParaPortion?" );
 
             sal_Int32 nLine = pParaPortion->GetLineNumber( aPaM.GetIndex() );
-            const EditLine* pLine = pParaPortion->GetLines()[nLine];
-            Range aLineXPosStartEnd = pImpEditEngine->GetLineXPosStartEnd( pParaPortion, pLine );
+            const EditLine& rLine = pParaPortion->GetLines()[nLine];
+            Range aLineXPosStartEnd = pImpEditEngine->GetLineXPosStartEnd( pParaPortion, &rLine );
             if ( ( aDocPos.X() >= aLineXPosStartEnd.Min() - nBorder ) &&
                  ( aDocPos.X() <= aLineXPosStartEnd.Max() + nBorder ) )
             {
@@ -2387,7 +2387,7 @@ ParagraphInfos EditEngine::GetParagraphInfos( sal_Int32 nPara )
     {
         const ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions()[nPara];
         const EditLine* pLine = (pParaPortion && pParaPortion->GetLines().Count()) ?
-                pParaPortion->GetLines()[0] : NULL;
+                &pParaPortion->GetLines()[0] : NULL;
         DBG_ASSERT( pParaPortion && pLine, "GetParagraphInfos - Paragraph out of range" );
         if ( pParaPortion && pLine )
         {
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 6037249..2331196 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -251,12 +251,11 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
 
         for ( sal_uInt16 nLine = nStartLine; nLine <= nEndLine; nLine++ )
         {
-            const EditLine* pLine = pTmpPortion->GetLines()[nLine];
-            DBG_ASSERT( pLine, "Line not found: DrawSelection()" );
+            const EditLine& rLine = pTmpPortion->GetLines()[nLine];
 
             bool bPartOfLine = false;
-            sal_Int32 nStartIndex = pLine->GetStart();
-            sal_Int32 nEndIndex = pLine->GetEnd();
+            sal_Int32 nStartIndex = rLine.GetStart();
+            sal_Int32 nEndIndex = rLine.GetEnd();
             if ( ( nPara == nStartPara ) && ( nLine == nStartLine ) && ( nStartIndex != aTmpSel.Min().GetIndex() ) )
             {
                 nStartIndex = aTmpSel.Min().GetIndex();
@@ -289,7 +288,7 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
             // Now that we have Bidi, the first/last index doesn't have to be the 'most outside' position
             if ( !bPartOfLine )
             {
-                Range aLineXPosStartEnd = pEditEngine->GetLineXPosStartEnd(pTmpPortion, pLine);
+                Range aLineXPosStartEnd = pEditEngine->GetLineXPosStartEnd(pTmpPortion, &rLine);
                 aTopLeft.X() = aLineXPosStartEnd.Min();
                 aBottomRight.X() = aLineXPosStartEnd.Max();
                 ImplDrawHighlightRect( pTarget, aTopLeft, aBottomRight, pPolyPoly );
@@ -307,8 +306,8 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
 
                     DBG_ASSERT( nTmpEndIndex > nTmpStartIndex, "DrawSelection, Start >= End?" );
 
-                    long nX1 = pEditEngine->GetXPos(pTmpPortion, pLine, nTmpStartIndex, true);
-                    long nX2 = pEditEngine->GetXPos(pTmpPortion, pLine, nTmpEndIndex);
+                    long nX1 = pEditEngine->GetXPos(pTmpPortion, &rLine, nTmpStartIndex, true);
+                    long nX2 = pEditEngine->GetXPos(pTmpPortion, &rLine, nTmpEndIndex);
 
                     Point aPt1( std::min( nX1, nX2 ), aTopLeft.Y() );
                     Point aPt2( std::max( nX1, nX2 ), aBottomRight.Y() );
@@ -762,10 +761,10 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, sal_uInt16
             aEditCursor.Left() = aEditCursor.Right() = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GETCRSR_TXTONLY|GETCRSR_PREFERPORTIONSTART ).Left();
 
             sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, true );
-            const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
-            if ( pTextPortion->GetKind() == PortionKind::TAB )
+            const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
+            if ( rTextPortion.GetKind() == PortionKind::TAB )
             {
-                aEditCursor.Right() += pTextPortion->GetSize().Width();
+                aEditCursor.Right() += rTextPortion.GetSize().Width();
             }
             else
             {
@@ -946,8 +945,8 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor, sal_uInt16
         if ( IsInsertMode() && !aEditSelection.HasRange() && ( pEditEngine->pImpEditEngine->HasDifferentRTLLevels( aPaM.GetNode() ) ) )
         {
             sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, (nShowCursorFlags & GETCRSR_PREFERPORTIONSTART) != 0 );
-            const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
-            sal_uInt16 nRTLLevel = pTextPortion->GetRightToLeft();
+            const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
+            sal_uInt16 nRTLLevel = rTextPortion.GetRightToLeft();
             if ( nRTLLevel%2 )
                 nCursorDir = CursorDirection::RTL;
             else
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 6d1321b..8795dc0 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -486,9 +486,9 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
 
             ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( GetEditDoc().GetPos( aPaM.GetNode() ) );
             sal_Int32 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), true );
-            const EditLine* pLine = pParaPortion->GetLines()[nLine];
-            if ( pLine && ( nInputEnd > pLine->GetEnd() ) )
-                nInputEnd = pLine->GetEnd();
+            const EditLine& rLine = pParaPortion->GetLines()[nLine];
+            if ( nInputEnd > rLine.GetEnd() )
+                nInputEnd = rLine.GetEnd();
             Rectangle aR2 = PaMtoEditCursor( EditPaM( aPaM.GetNode(), nInputEnd ), GETCRSR_ENDOFLINE );
             Rectangle aRect = pView->GetImpEditView()->GetWindowPos( aR1 );
             pView->GetWindow()->SetCursorRect( &aRect, aR2.Left()-aR1.Right() );
@@ -544,20 +544,17 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
 
             ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( GetEditDoc().GetPos( aPaM.GetNode() ) );
             sal_Int32 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), true );
-            const EditLine* pLine = pParaPortion->GetLines()[nLine];
-            if ( pLine )
+            const EditLine& rLine = pParaPortion->GetLines()[nLine];
+            std::unique_ptr<Rectangle[]> aRects(new Rectangle[ mpIMEInfos->nLen ]);
+            for (sal_Int32 i = 0; i < mpIMEInfos->nLen; ++i)
             {
-                std::unique_ptr<Rectangle[]> aRects(new Rectangle[ mpIMEInfos->nLen ]);
-                for (sal_Int32 i = 0; i < mpIMEInfos->nLen; ++i)
-                {
-                    sal_Int32 nInputPos = mpIMEInfos->aPos.GetIndex() + i;
-                    if ( nInputPos > pLine->GetEnd() )
-                        nInputPos = pLine->GetEnd();
-                    Rectangle aR2 = GetEditCursor( pParaPortion, nInputPos );
-                    aRects[ i ] = pView->GetImpEditView()->GetWindowPos( aR2 );
-                }
-                pView->GetWindow()->SetCompositionCharRect( aRects.get(), mpIMEInfos->nLen );
+                sal_Int32 nInputPos = mpIMEInfos->aPos.GetIndex() + i;
+                if ( nInputPos > rLine.GetEnd() )
+                    nInputPos = rLine.GetEnd();
+                Rectangle aR2 = GetEditCursor( pParaPortion, nInputPos );
+                aRects[ i ] = pView->GetImpEditView()->GetWindowPos( aR2 );
             }
+            pView->GetWindow()->SetCompositionCharRect( aRects.get(), mpIMEInfos->nLen );
         }
     }
 
@@ -927,14 +924,14 @@ EditPaM ImpEditEngine::CursorVisualStartEnd( EditView* pEditView, const EditPaM&
     ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara );
 
     sal_Int32 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), false );
-    const EditLine* pLine = pParaPortion->GetLines()[nLine];
-    bool bEmptyLine = pLine->GetStart() == pLine->GetEnd();
+    const EditLine& rLine = pParaPortion->GetLines()[nLine];
+    bool bEmptyLine = rLine.GetStart() == rLine.GetEnd();
 
     pEditView->pImpEditView->nExtraCursorFlags = 0;
 
     if ( !bEmptyLine )
     {
-        OUString aLine = aPaM.GetNode()->GetString().copy(pLine->GetStart(), pLine->GetEnd() - pLine->GetStart());
+        OUString aLine = aPaM.GetNode()->GetString().copy(rLine.GetStart(), rLine.GetEnd() - rLine.GetStart());
 
         const sal_Unicode* pLineString = aLine.getStr();
 
@@ -949,12 +946,12 @@ EditPaM ImpEditEngine::CursorVisualStartEnd( EditView* pEditView, const EditPaM&
 
         ubidi_close( pBidi );
 
-        aPaM.SetIndex( nLogPos + pLine->GetStart() );
+        aPaM.SetIndex( nLogPos + rLine.GetStart() );
 
         sal_Int32 nTmp;
         sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTmp, true );
-        const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
-        sal_Int32 nRTLLevel = pTextPortion->GetRightToLeft();
+        const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
+        sal_Int32 nRTLLevel = rTextPortion.GetRightToLeft();
         bool bPortionRTL = (nRTLLevel%2) != 0;
 
         if ( bStart )
@@ -983,8 +980,8 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
     ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( nPara );
 
     sal_Int32 nLine = pParaPortion->GetLines().FindLine( aPaM.GetIndex(), false );
-    const EditLine* pLine = pParaPortion->GetLines()[nLine];
-    bool bEmptyLine = pLine->GetStart() == pLine->GetEnd();
+    const EditLine& rLine = pParaPortion->GetLines()[nLine];
+    bool bEmptyLine = rLine.GetStart() == rLine.GetEnd();
 
     pEditView->pImpEditView->nExtraCursorFlags = 0;
 
@@ -1017,10 +1014,10 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
         // Check if we are within a portion and don't have overwrite mode, then it's easy...
         sal_Int32 nPortionStart;
         sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nPortionStart, false );
-        const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
+        const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
 
-        bool bPortionBoundary = ( aPaM.GetIndex() == nPortionStart ) || ( aPaM.GetIndex() == (nPortionStart+pTextPortion->GetLen()) );
-        sal_uInt16 nRTLLevel = pTextPortion->GetRightToLeft();
+        bool bPortionBoundary = ( aPaM.GetIndex() == nPortionStart ) || ( aPaM.GetIndex() == (nPortionStart+rTextPortion.GetLen()) );
+        sal_uInt16 nRTLLevel = rTextPortion.GetRightToLeft();
 
         // Portion boundary doesn't matter if both have same RTL level
         sal_Int32 nRTLLevelNextPortion = -1;
@@ -1028,8 +1025,8 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
         {
             sal_Int32 nTmp;
             sal_Int32 nNextTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex()+1, nTmp, !bLogicalBackward );
-            const TextPortion* pNextTextPortion = pParaPortion->GetTextPortions()[nNextTextPortion];
-            nRTLLevelNextPortion = pNextTextPortion->GetRightToLeft();
+            const TextPortion& rNextTextPortion = pParaPortion->GetTextPortions()[nNextTextPortion];
+            nRTLLevelNextPortion = rNextTextPortion.GetRightToLeft();
         }
 
         if ( !bPortionBoundary || ( nRTLLevel == nRTLLevelNextPortion ) )
@@ -1053,8 +1050,8 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
         bool bGotoStartOfNextLine = false;
         bool bGotoEndOfPrevLine = false;
 
-        OUString aLine = aPaM.GetNode()->GetString().copy(pLine->GetStart(), pLine->GetEnd() - pLine->GetStart());
-        const sal_Int32 nPosInLine = aPaM.GetIndex() - pLine->GetStart();
+        OUString aLine = aPaM.GetNode()->GetString().copy(rLine.GetStart(), rLine.GetEnd() - rLine.GetStart());
+        const sal_Int32 nPosInLine = aPaM.GetIndex() - rLine.GetStart();
 
         const sal_Unicode* pLineString = aLine.getStr();
 
@@ -1083,7 +1080,7 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
 
             if ( !bGotoEndOfPrevLine && !bGotoStartOfNextLine )
             {
-                aPaM.SetIndex( pLine->GetStart() + ubidi_getLogicalIndex( pBidi, nVisPos, &nError ) );
+                aPaM.SetIndex( rLine.GetStart() + ubidi_getLogicalIndex( pBidi, nVisPos, &nError ) );
                 pEditView->pImpEditView->SetCursorBidiLevel( 0 );
             }
         }
@@ -1096,8 +1093,8 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
 
             sal_Int32 nPortionStart;
             sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nPortionStart, bBeforePortion );
-            const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
-            bool bRTLPortion = (pTextPortion->GetRightToLeft() % 2) != 0;
+            const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
+            bool bRTLPortion = (rTextPortion.GetRightToLeft() % 2) != 0;
 
             // -1: We are 'behind' the character
             long nVisPos = (long)ubidi_getVisualIndex( pBidi, bWasBehind ? nPosInLine-1 : nPosInLine, &nError );
@@ -1117,16 +1114,16 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
 
             if ( !bGotoEndOfPrevLine && !bGotoStartOfNextLine )
             {
-                aPaM.SetIndex( pLine->GetStart() + ubidi_getLogicalIndex( pBidi, nVisPos, &nError ) );
+                aPaM.SetIndex( rLine.GetStart() + ubidi_getLogicalIndex( pBidi, nVisPos, &nError ) );
 
                 // RTL portion, stay visually on the left side.
                 sal_Int32 _nPortionStart;
                 // sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nPortionStart, !bRTLPortion );
                 sal_Int32 _nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), _nPortionStart, true );
-                const TextPortion* _pTextPortion = pParaPortion->GetTextPortions()[_nTextPortion];
-                if ( bVisualToLeft && !bRTLPortion && ( _pTextPortion->GetRightToLeft() % 2 ) )
+                const TextPortion& _rTextPortion = pParaPortion->GetTextPortions()[_nTextPortion];
+                if ( bVisualToLeft && !bRTLPortion && ( _rTextPortion.GetRightToLeft() % 2 ) )
                     aPaM.SetIndex( aPaM.GetIndex()+1 );
-                else if ( !bVisualToLeft && bRTLPortion && ( bWasBehind || !(_pTextPortion->GetRightToLeft() % 2 )) )
+                else if ( !bVisualToLeft && bRTLPortion && ( bWasBehind || !(_rTextPortion.GetRightToLeft() % 2 )) )
                     aPaM.SetIndex( aPaM.GetIndex()+1 );
 
                 pEditView->pImpEditView->SetCursorBidiLevel( _nPortionStart );
@@ -1213,12 +1210,12 @@ EditPaM ImpEditEngine::CursorUp( const EditPaM& rPaM, EditView* pView )
     const ParaPortion* pPPortion = FindParaPortion( rPaM.GetNode() );
     OSL_ENSURE( pPPortion, "No matching portion found: CursorUp ");
     sal_Int32 nLine = pPPortion->GetLineNumber( rPaM.GetIndex() );
-    const EditLine* pLine = pPPortion->GetLines()[nLine];
+    const EditLine& rLine = pPPortion->GetLines()[nLine];
 
     long nX;
     if ( pView->pImpEditView->nTravelXPos == TRAVEL_X_DONTKNOW )
     {
-        nX = GetXPos( pPPortion, pLine, rPaM.GetIndex() );
+        nX = GetXPos( pPPortion, &rLine, rPaM.GetIndex() );
         pView->pImpEditView->nTravelXPos = nX+nOnePixelInRef;
     }
     else
@@ -1227,13 +1224,13 @@ EditPaM ImpEditEngine::CursorUp( const EditPaM& rPaM, EditView* pView )
     EditPaM aNewPaM( rPaM );
     if ( nLine )    // same paragraph
     {
-        const EditLine* pPrevLine = pPPortion->GetLines()[nLine-1];
-        aNewPaM.SetIndex( GetChar( pPPortion, pPrevLine, nX ) );
+        const EditLine& rPrevLine = pPPortion->GetLines()[nLine-1];
+        aNewPaM.SetIndex( GetChar( pPPortion, &rPrevLine, nX ) );
         // If a previous automatically wrapped line, and one has to be exactly
         // at the end of this line, the cursor lands on the current line at the
         // beginning. See Problem: Last character of an automatically wrapped
         // Row = cursor
-        if ( aNewPaM.GetIndex() && ( aNewPaM.GetIndex() == pLine->GetStart() ) )
+        if ( aNewPaM.GetIndex() && ( aNewPaM.GetIndex() == rLine.GetStart() ) )
             aNewPaM = CursorLeft( aNewPaM );
     }
     else    // previous paragraph
@@ -1241,10 +1238,9 @@ EditPaM ImpEditEngine::CursorUp( const EditPaM& rPaM, EditView* pView )
         const ParaPortion* pPrevPortion = GetPrevVisPortion( pPPortion );
         if ( pPrevPortion )
         {
-            pLine = pPrevPortion->GetLines()[pPrevPortion->GetLines().Count()-1];
-            OSL_ENSURE( pLine, "Line in front not found: CursorUp" );
+            const EditLine& rLine2 = pPrevPortion->GetLines()[pPrevPortion->GetLines().Count()-1];
             aNewPaM.SetNode( pPrevPortion->GetNode() );
-            aNewPaM.SetIndex( GetChar( pPrevPortion, pLine, nX+nOnePixelInRef ) );
+            aNewPaM.SetIndex( GetChar( pPrevPortion, &rLine2, nX+nOnePixelInRef ) );
         }
     }
 
@@ -1262,8 +1258,8 @@ EditPaM ImpEditEngine::CursorDown( const EditPaM& rPaM, EditView* pView )
     long nX;
     if ( pView->pImpEditView->nTravelXPos == TRAVEL_X_DONTKNOW )
     {
-        const EditLine* pLine = pPPortion->GetLines()[nLine];
-        nX = GetXPos( pPPortion, pLine, rPaM.GetIndex() );
+        const EditLine& rLine = pPPortion->GetLines()[nLine];
+        nX = GetXPos( pPPortion, &rLine, rPaM.GetIndex() );
         pView->pImpEditView->nTravelXPos = nX+nOnePixelInRef;
     }
     else
@@ -1272,10 +1268,10 @@ EditPaM ImpEditEngine::CursorDown( const EditPaM& rPaM, EditView* pView )
     EditPaM aNewPaM( rPaM );
     if ( nLine < pPPortion->GetLines().Count()-1 )
     {
-        const EditLine* pNextLine = pPPortion->GetLines()[nLine+1];
-        aNewPaM.SetIndex( GetChar( pPPortion, pNextLine, nX ) );
+        const EditLine& rNextLine = pPPortion->GetLines()[nLine+1];
+        aNewPaM.SetIndex( GetChar( pPPortion, &rNextLine, nX ) );
         // Special treatment, see CursorUp ...
-        if ( ( aNewPaM.GetIndex() == pNextLine->GetEnd() ) && ( aNewPaM.GetIndex() > pNextLine->GetStart() ) && ( aNewPaM.GetIndex() < pPPortion->GetNode()->Len() ) )
+        if ( ( aNewPaM.GetIndex() == rNextLine.GetEnd() ) && ( aNewPaM.GetIndex() > rNextLine.GetStart() ) && ( aNewPaM.GetIndex() < pPPortion->GetNode()->Len() ) )
             aNewPaM = CursorLeft( aNewPaM );
     }
     else    // next paragraph
@@ -1283,13 +1279,12 @@ EditPaM ImpEditEngine::CursorDown( const EditPaM& rPaM, EditView* pView )
         const ParaPortion* pNextPortion = GetNextVisPortion( pPPortion );
         if ( pNextPortion )
         {
-            const EditLine* pLine = pNextPortion->GetLines()[0];
-            OSL_ENSURE( pLine, "Line in front not found: CursorUp" );
+            const EditLine& rLine = pNextPortion->GetLines()[0];
             aNewPaM.SetNode( pNextPortion->GetNode() );
             // Never at the very end when several lines, because then a line
             // below the cursor appears.
-            aNewPaM.SetIndex( GetChar( pNextPortion, pLine, nX+nOnePixelInRef ) );
-            if ( ( aNewPaM.GetIndex() == pLine->GetEnd() ) && ( aNewPaM.GetIndex() > pLine->GetStart() ) && ( pNextPortion->GetLines().Count() > 1 ) )
+            aNewPaM.SetIndex( GetChar( pNextPortion, &rLine, nX+nOnePixelInRef ) );
+            if ( ( aNewPaM.GetIndex() == rLine.GetEnd() ) && ( aNewPaM.GetIndex() > rLine.GetStart() ) && ( pNextPortion->GetLines().Count() > 1 ) )
                 aNewPaM = CursorLeft( aNewPaM );
         }
     }
@@ -1302,11 +1297,10 @@ EditPaM ImpEditEngine::CursorStartOfLine( const EditPaM& rPaM )
     const ParaPortion* pCurPortion = FindParaPortion( rPaM.GetNode() );
     OSL_ENSURE( pCurPortion, "No Portion for the PaM ?" );
     sal_Int32 nLine = pCurPortion->GetLineNumber( rPaM.GetIndex() );
-    const EditLine* pLine = pCurPortion->GetLines()[nLine];
-    OSL_ENSURE( pLine, "Current line not found ?!" );
+    const EditLine& rLine = pCurPortion->GetLines()[nLine];
 
     EditPaM aNewPaM( rPaM );
-    aNewPaM.SetIndex( pLine->GetStart() );
+    aNewPaM.SetIndex( rLine.GetStart() );
     return aNewPaM;
 }
 
@@ -1315,12 +1309,11 @@ EditPaM ImpEditEngine::CursorEndOfLine( const EditPaM& rPaM )
     const ParaPortion* pCurPortion = FindParaPortion( rPaM.GetNode() );
     OSL_ENSURE( pCurPortion, "No Portion for the PaM ?" );
     sal_Int32 nLine = pCurPortion->GetLineNumber( rPaM.GetIndex() );
-    const EditLine* pLine = pCurPortion->GetLines()[nLine];
-    OSL_ENSURE( pLine, "Current line not found ?!" );
+    const EditLine& rLine = pCurPortion->GetLines()[nLine];
 
     EditPaM aNewPaM( rPaM );
-    aNewPaM.SetIndex( pLine->GetEnd() );
-    if ( pLine->GetEnd() > pLine->GetStart() )
+    aNewPaM.SetIndex( rLine.GetEnd() );
+    if ( rLine.GetEnd() > rLine.GetStart() )
     {
         if ( aNewPaM.GetNode()->IsFeature( aNewPaM.GetIndex() - 1 ) )
         {
@@ -1970,8 +1963,8 @@ bool ImpEditEngine::HasDifferentRTLLevels( const ContentNode* pNode )
     sal_uInt16 nRTLLevel = IsRightToLeft( nPara ) ? 1 : 0;
     for ( sal_Int32 n = 0; n < (sal_Int32)pParaPortion->GetTextPortions().Count(); n++ )
     {
-        const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[n];
-        if ( pTextPortion->GetRightToLeft() != nRTLLevel )
+        const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[n];
+        if ( rTextPortion.GetRightToLeft() != nRTLLevel )
         {
             bHasDifferentRTLLevels = true;
             break;
@@ -3059,8 +3052,6 @@ sal_uInt32 ImpEditEngine::CalcTextWidth( bool bIgnoreExtraSpace )
     if ( !IsFormatted() && !IsFormatting() )
         FormatDoc();
 
-    EditLine* pLine;
-
     long nMaxWidth = 0;
     long nCurWidth = 0;
 
@@ -3082,8 +3073,7 @@ sal_uInt32 ImpEditEngine::CalcTextWidth( bool bIgnoreExtraSpace )
             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" );
+                EditLine& rLine = pPortion->GetLines()[nLine];
                 // nCurWidth = pLine->GetStartPosX();
                 // For Center- or Right- alignment it depends on the paper
                 // width, here not preferred. I general, it is best not leave it
@@ -3102,7 +3092,7 @@ sal_uInt32 ImpEditEngine::CalcTextWidth( bool bIgnoreExtraSpace )
                     }
                 }
                 nCurWidth += GetXValue( rLRItem.GetRight() );
-                nCurWidth += CalcLineWidth( pPortion, pLine, bIgnoreExtraSpace );
+                nCurWidth += CalcLineWidth( pPortion, &rLine, bIgnoreExtraSpace );
                 if ( nCurWidth > nMaxWidth )
                 {
                     nMaxWidth = nCurWidth;
@@ -3132,21 +3122,21 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine,
     sal_Int32 nPos = pLine->GetStart();
     for ( sal_Int32 nTP = pLine->GetStartPortion(); nTP <= pLine->GetEndPortion(); nTP++ )
     {
-        const TextPortion* pTextPortion = pPortion->GetTextPortions()[nTP];
-        switch ( pTextPortion->GetKind() )
+        const TextPortion& rTextPortion = pPortion->GetTextPortions()[nTP];
+        switch ( rTextPortion.GetKind() )
         {
             case PortionKind::FIELD:
             case PortionKind::HYPHENATOR:
             case PortionKind::TAB:
             {
-                nWidth += pTextPortion->GetSize().Width();
+                nWidth += rTextPortion.GetSize().Width();
             }
             break;
             case PortionKind::TEXT:
             {
                 if ( ( eJustification != SVX_ADJUST_BLOCK ) || ( !bIgnoreExtraSpace ) )
                 {
-                    nWidth += pTextPortion->GetSize().Width();
+                    nWidth += rTextPortion.GetSize().Width();
                 }
                 else
                 {
@@ -3154,13 +3144,13 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine,
                     SeekCursor( pPortion->GetNode(), nPos+1, aTmpFont );
                     aTmpFont.SetPhysFont( GetRefDevice() );
                     ImplInitDigitMode(GetRefDevice(), aTmpFont.GetLanguage());
-                    nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(), pPortion->GetNode()->GetString(), nPos, pTextPortion->GetLen(), NULL ).Width();
+                    nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(), pPortion->GetNode()->GetString(), nPos, rTextPortion.GetLen(), NULL ).Width();
                 }
             }
             break;
             case PortionKind::LINEBREAK: break;
         }
-        nPos = nPos + pTextPortion->GetLen();
+        nPos = nPos + rTextPortion.GetLen();
     }
 
     GetRefDevice()->Pop();
@@ -3217,9 +3207,8 @@ sal_Int32 ImpEditEngine::GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) con
     OSL_ENSURE( pPPortion, "Paragraph not found: GetLineLen" );
     if ( pPPortion && ( nLine < pPPortion->GetLines().Count() ) )
     {
-        const EditLine* pLine = pPPortion->GetLines()[nLine];
-        OSL_ENSURE( pLine, "Line not found: GetLineHeight" );
-        return pLine->GetLen();
+        const EditLine& rLine = pPPortion->GetLines()[nLine];
+        return rLine.GetLen();
     }
 
     return -1;
@@ -3233,10 +3222,9 @@ void ImpEditEngine::GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int3
     rStart = rEnd = -1;     // default values in case of error
     if ( pPPortion && ( nLine < pPPortion->GetLines().Count() ) )
     {
-        const EditLine* pLine = pPPortion->GetLines()[nLine];
-        assert(pLine && "Line not found: GetLineBoundaries");
-        rStart = pLine->GetStart();
-        rEnd   = pLine->GetEnd();
+        const EditLine& rLine = pPPortion->GetLines()[nLine];
+        rStart = rLine.GetStart();
+        rEnd   = rLine.GetEnd();
     }
 }
 
@@ -3274,9 +3262,8 @@ sal_uInt16 ImpEditEngine::GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine )
     OSL_ENSURE( pPPortion, "Paragraph not found: GetLineHeight" );
     if ( pPPortion && ( nLine < pPPortion->GetLines().Count() ) )
     {
-        const EditLine* pLine = pPPortion->GetLines()[nLine];
-        OSL_ENSURE( pLine, "Paragraph not found: GetLineHeight" );
-        return pLine->GetHeight();
+        const EditLine& rLine = pPPortion->GetLines()[nLine];
+        return rLine.GetHeight();
     }
 
     return 0xFFFF;
@@ -3565,15 +3552,15 @@ Range ImpEditEngine::GetInvalidYOffsets( ParaPortion* pPortion )
         sal_Int32 nLine;
         for ( nLine = 0; nLine < pPortion->GetLines().Count(); nLine++ )
         {
-            const EditLine* pL = pPortion->GetLines()[nLine];
-            if ( pL->IsInvalid() )
+            const EditLine& rL = pPortion->GetLines()[nLine];
+            if ( rL.IsInvalid() )
             {
                 nFirstInvalid = nLine;
                 break;
             }
             if ( nLine && !aStatus.IsOutliner() )   // not the first line
                 aRange.Min() += nSBL;
-            aRange.Min() += pL->GetHeight();
+            aRange.Min() += rL.GetHeight();
         }
         OSL_ENSURE( nFirstInvalid != -1, "No invalid line found in GetInvalidYOffset(1)" );
 
@@ -3589,22 +3576,22 @@ Range ImpEditEngine::GetInvalidYOffsets( ParaPortion* pPortion )
         {
             for ( nLine = nFirstInvalid; nLine < pPortion->GetLines().Count(); nLine++ )
             {
-                const EditLine* pL = pPortion->GetLines()[nLine];
-                if ( pL->IsValid() )
+                const EditLine& rL = pPortion->GetLines()[nLine];
+                if ( rL.IsValid() )
                 {
                     nLastInvalid = nLine;
                     break;
                 }
                 if ( nLine && !aStatus.IsOutliner() )
                     aRange.Max() += nSBL;
-                aRange.Max() += pL->GetHeight();
+                aRange.Max() += rL.GetHeight();
             }
 
             if( ( rLSItem.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP ) && rLSItem.GetPropLineSpace() &&
                 ( rLSItem.GetPropLineSpace() < 100 ) )
             {
-                const EditLine* pL = pPortion->GetLines()[nFirstInvalid];
-                long n = pL->GetTxtHeight() * ( 100L - rLSItem.GetPropLineSpace() );
+                const EditLine& rL = pPortion->GetLines()[nFirstInvalid];
+                long n = rL.GetTxtHeight() * ( 100L - rLSItem.GetPropLineSpace() );
                 n /= 100;
                 aRange.Min() -= n;
                 aRange.Max() += n;
@@ -3637,17 +3624,17 @@ EditPaM ImpEditEngine::GetPaM( ParaPortion* pPortion, Point aDocPos, bool bSmart
     const EditLine* pLine = NULL;
     for ( sal_Int32 nLine = 0; nLine < pPortion->GetLines().Count(); nLine++ )
     {
-        const EditLine* pTmpLine = pPortion->GetLines()[nLine];
-        nY += pTmpLine->GetHeight();
+        const EditLine& rTmpLine = pPortion->GetLines()[nLine];
+        nY += rTmpLine.GetHeight();
         if ( !aStatus.IsOutliner() )
             nY += nSBL;
         if ( nY > aDocPos.Y() )
         {
-            pLine = pTmpLine;
+            pLine = &rTmpLine;
             break;                  // correct Y-position is not of interest
         }
 
-        nCurIndex = nCurIndex + pTmpLine->GetLen();
+        nCurIndex = nCurIndex + rTmpLine.GetLen();
     }
 
     if ( !pLine ) // may happen only in the range of SA!
@@ -3665,7 +3652,7 @@ EditPaM ImpEditEngine::GetPaM( ParaPortion* pPortion, Point aDocPos, bool bSmart
     aPaM.SetIndex( nCurIndex );
 
     if ( nCurIndex && ( nCurIndex == pLine->GetEnd() ) &&
-         ( pLine != pPortion->GetLines()[pPortion->GetLines().Count()-1] ) )
+         ( pLine != &pPortion->GetLines()[pPortion->GetLines().Count()-1] ) )
     {
         aPaM = CursorLeft( aPaM, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL );
     }
@@ -3685,9 +3672,9 @@ sal_Int32 ImpEditEngine::GetChar(
     // Search best matching portion with GetPortionXOffset()
     for ( sal_Int32 i = pLine->GetStartPortion(); i <= pLine->GetEndPortion(); i++ )
     {
-        const TextPortion* pPortion = pParaPortion->GetTextPortions()[i];
+        const TextPortion& rPortion = pParaPortion->GetTextPortions()[i];
         long nXLeft = GetPortionXOffset( pParaPortion, pLine, i );
-        long nXRight = nXLeft + pPortion->GetSize().Width();
+        long nXRight = nXLeft + rPortion.GetSize().Width();
         if ( ( nXLeft <= nXPos ) && ( nXRight >= nXPos ) )
         {
              nChar = nCurIndex;
@@ -3695,7 +3682,7 @@ sal_Int32 ImpEditEngine::GetChar(
             // Search within Portion...
 
             // Don't search within special portions...
-            if ( pPortion->GetKind() != PortionKind::TEXT )
+            if ( rPortion.GetKind() != PortionKind::TEXT )
             {
                 // ...but check on which side
                 if ( bSmart )
@@ -3708,12 +3695,12 @@ sal_Int32 ImpEditEngine::GetChar(
             }
             else
             {
-                sal_Int32 nMax = pPortion->GetLen();
+                sal_Int32 nMax = rPortion.GetLen();
                 sal_Int32 nOffset = -1;
                 sal_Int32 nTmpCurIndex = nChar - pLine->GetStart();
 
                 long nXInPortion = nXPos - nXLeft;
-                if ( pPortion->IsRightToLeft() )
+                if ( rPortion.IsRightToLeft() )
                     nXInPortion = nXRight - nXPos;
 
                 // Search in Array...
@@ -3775,7 +3762,7 @@ sal_Int32 ImpEditEngine::GetChar(
             }
         }
 
-        nCurIndex = nCurIndex + pPortion->GetLen();
+        nCurIndex = nCurIndex + rPortion.GetLen();
     }
 
     if ( nChar == -1 )
@@ -3813,15 +3800,15 @@ long ImpEditEngine::GetPortionXOffset(
 
     for ( sal_Int32 i = pLine->GetStartPortion(); i < nTextPortion; i++ )
     {
-        const TextPortion* pPortion = pParaPortion->GetTextPortions()[i];
-        switch ( pPortion->GetKind() )
+        const TextPortion& rPortion = pParaPortion->GetTextPortions()[i];
+        switch ( rPortion.GetKind() )
         {
             case PortionKind::FIELD:
             case PortionKind::TEXT:
             case PortionKind::HYPHENATOR:
             case PortionKind::TAB:
             {
-                nX += pPortion->GetSize().Width();
+                nX += rPortion.GetSize().Width();
             }
             break;
             case PortionKind::LINEBREAK: break;
@@ -3831,18 +3818,18 @@ long ImpEditEngine::GetPortionXOffset(
     sal_Int32 nPara = GetEditDoc().GetPos( pParaPortion->GetNode() );
     bool bR2LPara = IsRightToLeft( nPara );
 
-    const TextPortion* pDestPortion = pParaPortion->GetTextPortions()[nTextPortion];
-    if ( pDestPortion->GetKind() != PortionKind::TAB )
+    const TextPortion& rDestPortion = pParaPortion->GetTextPortions()[nTextPortion];
+    if ( rDestPortion.GetKind() != PortionKind::TAB )
     {
-        if ( !bR2LPara && pDestPortion->GetRightToLeft() )
+        if ( !bR2LPara && rDestPortion.GetRightToLeft() )
         {
             // Portions behind must be added, visual before this portion
             sal_Int32 nTmpPortion = nTextPortion+1;
             while ( nTmpPortion <= pLine->GetEndPortion() )
             {
-                const TextPortion* pNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
-                if ( pNextTextPortion->GetRightToLeft() && ( pNextTextPortion->GetKind() != PortionKind::TAB ) )
-                    nX += pNextTextPortion->GetSize().Width();
+                const TextPortion& rNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
+                if ( rNextTextPortion.GetRightToLeft() && ( rNextTextPortion.GetKind() != PortionKind::TAB ) )
+                    nX += rNextTextPortion.GetSize().Width();
                 else
                     break;
                 nTmpPortion++;
@@ -3852,22 +3839,22 @@ long ImpEditEngine::GetPortionXOffset(
             while ( nTmpPortion > pLine->GetStartPortion() )
             {
                 --nTmpPortion;
-                const TextPortion* pPrevTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
-                if ( pPrevTextPortion->GetRightToLeft() && ( pPrevTextPortion->GetKind() != PortionKind::TAB ) )
-                    nX -= pPrevTextPortion->GetSize().Width();
+                const TextPortion& rPrevTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
+                if ( rPrevTextPortion.GetRightToLeft() && ( rPrevTextPortion.GetKind() != PortionKind::TAB ) )
+                    nX -= rPrevTextPortion.GetSize().Width();
                 else
                     break;
             }
         }
-        else if ( bR2LPara && !pDestPortion->IsRightToLeft() )
+        else if ( bR2LPara && !rDestPortion.IsRightToLeft() )
         {
             // Portions behind must be removed, visual behind this portion
             sal_Int32 nTmpPortion = nTextPortion+1;
             while ( nTmpPortion <= pLine->GetEndPortion() )
             {
-                const TextPortion* pNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
-                if ( !pNextTextPortion->IsRightToLeft() && ( pNextTextPortion->GetKind() != PortionKind::TAB ) )
-                    nX += pNextTextPortion->GetSize().Width();
+                const TextPortion& rNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
+                if ( !rNextTextPortion.IsRightToLeft() && ( rNextTextPortion.GetKind() != PortionKind::TAB ) )
+                    nX += rNextTextPortion.GetSize().Width();
                 else
                     break;
                 nTmpPortion++;
@@ -3877,9 +3864,9 @@ long ImpEditEngine::GetPortionXOffset(
             while ( nTmpPortion > pLine->GetStartPortion() )
             {
                 --nTmpPortion;
-                const TextPortion* pPrevTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
-                if ( !pPrevTextPortion->IsRightToLeft() && ( pPrevTextPortion->GetKind() != PortionKind::TAB ) )
-                    nX -= pPrevTextPortion->GetSize().Width();
+                const TextPortion& rPrevTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
+                if ( !rPrevTextPortion.IsRightToLeft() && ( rPrevTextPortion.GetKind() != PortionKind::TAB ) )
+                    nX -= rPrevTextPortion.GetSize().Width();
                 else
                     break;
             }
@@ -3891,7 +3878,7 @@ long ImpEditEngine::GetPortionXOffset(
         OSL_ENSURE( GetTextRanger() || GetPaperSize().Width(), "GetPortionXOffset - paper size?!" );
         OSL_ENSURE( GetTextRanger() || (nX <= GetPaperSize().Width()), "GetPortionXOffset - position out of paper size!" );
         nX = GetPaperSize().Width() - nX;
-        nX -= pDestPortion->GetSize().Width();
+        nX -= rDestPortion.GetSize().Width();
     }
 
     return nX;
@@ -3915,28 +3902,28 @@ long ImpEditEngine::GetXPos(
 
     OSL_ENSURE( ( nTextPortion >= pLine->GetStartPortion() ) && ( nTextPortion <= pLine->GetEndPortion() ), "GetXPos: Portion not in current line! " );
 
-    const TextPortion* pPortion = pParaPortion->GetTextPortions()[nTextPortion];
+    const TextPortion& rPortion = pParaPortion->GetTextPortions()[nTextPortion];
 
     long nX = GetPortionXOffset( pParaPortion, pLine, nTextPortion );
 
     // calc text width, portion size may include CJK/CTL spacing...
     // But the array might not be init yet, if using text ranger this method is called within CreateLines()...
-    long nPortionTextWidth = pPortion->GetSize().Width();
-    if ( ( pPortion->GetKind() == PortionKind::TEXT ) && pPortion->GetLen() && !GetTextRanger() )
-        nPortionTextWidth = pLine->GetCharPosArray()[nTextPortionStart + pPortion->GetLen() - 1 - pLine->GetStart()];
+    long nPortionTextWidth = rPortion.GetSize().Width();
+    if ( ( rPortion.GetKind() == PortionKind::TEXT ) && rPortion.GetLen() && !GetTextRanger() )
+        nPortionTextWidth = pLine->GetCharPosArray()[nTextPortionStart + rPortion.GetLen() - 1 - pLine->GetStart()];
 
     if ( nTextPortionStart != nIndex )
     {
         // Search within portion...
-        if ( nIndex == ( nTextPortionStart + pPortion->GetLen() ) )
+        if ( nIndex == ( nTextPortionStart + rPortion.GetLen() ) )
         {
             // End of Portion
-            if ( pPortion->GetKind() == PortionKind::TAB )
+            if ( rPortion.GetKind() == PortionKind::TAB )
             {
                 if ( nTextPortion+1 < pParaPortion->GetTextPortions().Count() )
                 {
-                    const TextPortion* pNextPortion = pParaPortion->GetTextPortions()[nTextPortion+1];
-                    if ( pNextPortion->GetKind() != PortionKind::TAB )
+                    const TextPortion& rNextPortion = pParaPortion->GetTextPortions()[nTextPortion+1];
+                    if ( rNextPortion.GetKind() != PortionKind::TAB )
                     {
                         if ( !bPreferPortionStart )
                             nX = GetXPos( pParaPortion, pLine, nIndex, true );
@@ -3949,12 +3936,12 @@ long ImpEditEngine::GetXPos(
                     nX += nPortionTextWidth;
                 }
             }
-            else if ( !pPortion->IsRightToLeft() )
+            else if ( !rPortion.IsRightToLeft() )
             {
                 nX += nPortionTextWidth;
             }
         }
-        else if ( pPortion->GetKind() == PortionKind::TEXT )
+        else if ( rPortion.GetKind() == PortionKind::TEXT )
         {
             OSL_ENSURE( nIndex != pLine->GetStart(), "Strange behavior in new GetXPos()" );
             OSL_ENSURE( pLine && pLine->GetCharPosArray().size(), "svx::ImpEditEngine::GetXPos(), portion in an empty line?" );
@@ -3971,7 +3958,7 @@ long ImpEditEngine::GetXPos(
                 // old code restored see #i112788 (which leaves #i74188 unfixed again)
                 long nPosInPortion = pLine->GetCharPosArray()[nPos];
 
-                if ( !pPortion->IsRightToLeft() )
+                if ( !rPortion.IsRightToLeft() )
                 {
                     nX += nPosInPortion;
                 }
@@ -3980,28 +3967,28 @@ long ImpEditEngine::GetXPos(
                     nX += nPortionTextWidth - nPosInPortion;
                 }
 
-                if ( pPortion->GetExtraInfos() && pPortion->GetExtraInfos()->bCompressed )
+                if ( rPortion.GetExtraInfos() && rPortion.GetExtraInfos()->bCompressed )
                 {
-                    nX += pPortion->GetExtraInfos()->nPortionOffsetX;
-                    if ( pPortion->GetExtraInfos()->nAsianCompressionTypes & CHAR_PUNCTUATIONRIGHT )
+                    nX += rPortion.GetExtraInfos()->nPortionOffsetX;
+                    if ( rPortion.GetExtraInfos()->nAsianCompressionTypes & CHAR_PUNCTUATIONRIGHT )
                     {
                         sal_uInt8 nType = GetCharTypeForCompression( pParaPortion->GetNode()->GetChar( nIndex ) );
                         if ( nType == CHAR_PUNCTUATIONRIGHT && !pLine->GetCharPosArray().empty() )
                         {
                             sal_Int32 n = nIndex - nTextPortionStart;
                             const long* pDXArray = &pLine->GetCharPosArray()[0]+( nTextPortionStart-pLine->GetStart() );
-                            sal_Int32 nCharWidth = ( ( (n+1) < pPortion->GetLen() ) ? pDXArray[n] : pPortion->GetSize().Width() )
+                            sal_Int32 nCharWidth = ( ( (n+1) < rPortion.GetLen() ) ? pDXArray[n] : rPortion.GetSize().Width() )
                                                             - ( n ? pDXArray[n-1] : 0 );
-                            if ( (n+1) < pPortion->GetLen() )
+                            if ( (n+1) < rPortion.GetLen() )
                             {
                                 // smaller, when char behind is CHAR_PUNCTUATIONRIGHT also
                                 nType = GetCharTypeForCompression( pParaPortion->GetNode()->GetChar( nIndex+1 ) );
                                 if ( nType == CHAR_PUNCTUATIONRIGHT )
                                 {
-                                    sal_Int32 nNextCharWidth = ( ( (n+2) < pPortion->GetLen() ) ? pDXArray[n+1] : pPortion->GetSize().Width() )
+                                    sal_Int32 nNextCharWidth = ( ( (n+2) < rPortion.GetLen() ) ? pDXArray[n+1] : rPortion.GetSize().Width() )
                                                                     - pDXArray[n];
                                     sal_Int32 nCompressed = nNextCharWidth/2;
-                                    nCompressed *= pPortion->GetExtraInfos()->nMaxCompression100thPercent;
+                                    nCompressed *= rPortion.GetExtraInfos()->nMaxCompression100thPercent;
                                     nCompressed /= 10000;
                                     nCharWidth += nCompressed;
                                 }
@@ -4019,7 +4006,7 @@ long ImpEditEngine::GetXPos(
     }
     else // if ( nIndex == pLine->GetStart() )
     {
-        if ( pPortion->IsRightToLeft() )
+        if ( rPortion.IsRightToLeft() )
         {
             nX += nPortionTextWidth;
         }
@@ -4037,7 +4024,7 @@ void ImpEditEngine::CalcHeight( ParaPortion* pPortion )
     {
         OSL_ENSURE( pPortion->GetLines().Count(), "Paragraph with no lines in ParaPortion::CalcHeight" );
         for (sal_Int32 nLine = 0; nLine < pPortion->GetLines().Count(); ++nLine)
-            pPortion->nHeight += pPortion->GetLines()[nLine]->GetHeight();
+            pPortion->nHeight += pPortion->GetLines()[nLine].GetHeight();
 
         if ( !aStatus.IsOutliner() )
         {
@@ -4153,15 +4140,15 @@ Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex,
     bool bEOL = ( nFlags & GETCRSR_ENDOFLINE ) != 0;
     for (sal_Int32 nLine = 0; nLine < nLineCount; ++nLine)
     {
-        const EditLine* pTmpLine = pPortion->GetLines()[nLine];
-        if ( ( pTmpLine->GetStart() == nIndex ) || ( pTmpLine->IsIn( nIndex, bEOL ) ) )
+        const EditLine& rTmpLine = pPortion->GetLines()[nLine];
+        if ( ( rTmpLine.GetStart() == nIndex ) || ( rTmpLine.IsIn( nIndex, bEOL ) ) )
         {
-            pLine = pTmpLine;
+            pLine = &rTmpLine;
             break;
         }
 
-        nCurIndex = nCurIndex + pTmpLine->GetLen();
-        nY += pTmpLine->GetHeight();
+        nCurIndex = nCurIndex + rTmpLine.GetLen();
+        nY += rTmpLine.GetHeight();
         if ( !aStatus.IsOutliner() )
             nY += nSBL;
     }
@@ -4170,7 +4157,7 @@ Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex,
         // Cursor at the End of the paragraph.
         OSL_ENSURE( nIndex == nCurIndex, "Index dead wrong in GetEditCursor!" );
 
-        pLine = pPortion->GetLines()[nLineCount-1];
+        pLine = &pPortion->GetLines()[nLineCount-1];
         nY -= pLine->GetHeight();
         if ( !aStatus.IsOutliner() )
             nY -= nSBL;
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 2cace76..7511b33 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -638,8 +638,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
             for ( sal_Int32 nTP = 0; nTP < nPortions; nTP++ )
             {
                 // There must be no start / end in the deleted area.
-                TextPortion* const pTP = pParaPortion->GetTextPortions()[ nTP ];
-                nPos = nPos + pTP->GetLen();
+                const TextPortion& rTP = pParaPortion->GetTextPortions()[ nTP ];
+                nPos = nPos + rTP.GetLen();
                 if ( ( nPos > nStart ) && ( nPos < nEnd ) )
                 {
                     bQuickFormat = false;
@@ -683,20 +683,20 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
     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!
+        EditLine& rLine = pParaPortion->GetLines()[nL];
+        if ( rLine.GetEnd() > nRealInvalidStart )  // not nInvalidStart!
         {
             nLine = nL;
             break;
         }
-        pLine->SetValid();
+        rLine.SetValid();
     }
     // Begin one line before...
     // If it is typed at the end, the line in front cannot change.
     if ( nLine && ( !pParaPortion->IsSimpleInvalid() || ( nInvalidEnd < pNode->Len() ) || ( nInvalidDiff <= 0 ) ) )
         nLine--;
 
-    EditLine* pLine = pParaPortion->GetLines()[nLine];
+    EditLine* pLine = &pParaPortion->GetLines()[nLine];
 
     static Rectangle aZeroArea = Rectangle( Point(), Point() );
     Rectangle aBulletArea( aZeroArea );
@@ -868,7 +868,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
         while ( ( nTmpWidth < nXWidth ) && !bEOL && ( nTmpPortion < pParaPortion->GetTextPortions().Count() ) )
         {
             nPortionStart = nTmpPos;
-            pPortion = pParaPortion->GetTextPortions()[nTmpPortion];
+            pPortion = &pParaPortion->GetTextPortions()[nTmpPortion];
             if ( pPortion->GetKind() == PortionKind::HYPHENATOR )
             {
                 // Throw away a Portion, if necessary correct the one before,
@@ -878,16 +878,16 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
                 if (nTmpPortion && nTmpLen)
                 {
                     nTmpPortion--;
-                    TextPortion* pPrev = pParaPortion->GetTextPortions()[nTmpPortion];
-                    DBG_ASSERT( pPrev->GetKind() == PortionKind::TEXT, "Portion?!" );
-                    nTmpWidth -= pPrev->GetSize().Width();
-                    nTmpPos = nTmpPos - pPrev->GetLen();
-                    pPrev->SetLen(pPrev->GetLen() + nTmpLen);
-                    pPrev->GetSize().Width() = (-1);
+                    TextPortion& rPrev = pParaPortion->GetTextPortions()[nTmpPortion];
+                    DBG_ASSERT( rPrev.GetKind() == PortionKind::TEXT, "Portion?!" );
+                    nTmpWidth -= rPrev.GetSize().Width();
+                    nTmpPos = nTmpPos - rPrev.GetLen();
+                    rPrev.SetLen(rPrev.GetLen() + nTmpLen);
+                    rPrev.GetSize().Width() = (-1);
                 }
 
                 DBG_ASSERT( nTmpPortion < pParaPortion->GetTextPortions().Count(), "No more Portions left!" );
-                pPortion = pParaPortion->GetTextPortions()[nTmpPortion];
+                pPortion = &pParaPortion->GetTextPortions()[nTmpPortion];
             }
             DBG_ASSERT( pPortion->GetKind() != PortionKind::HYPHENATOR, "CreateLines: Hyphenator-Portion!" );
             DBG_ASSERT( pPortion->GetLen() || bProcessingEmptyLine, "Empty Portion in CreateLines ?!" );
@@ -1101,8 +1101,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
                 long nWidthAfterTab = 0;
                 for ( sal_Int32 n = aCurrentTab.nTabPortion+1; n <= nTmpPortion; n++  )
                 {
-                    const TextPortion* pTP = pParaPortion->GetTextPortions()[n];
-                    nWidthAfterTab += pTP->GetSize().Width();
+                    const TextPortion& rTP = pParaPortion->GetTextPortions()[n];
+                    nWidthAfterTab += rTP.GetSize().Width();
                 }
                 long nW = nWidthAfterTab;   // Length before tab position
                 if ( aCurrentTab.aTabStop.GetAdjustment() == SVX_TAB_ADJUST_RIGHT )
@@ -1119,7 +1119,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
                     sal_Int32 nDecPos = aText.indexOf( aCurrentTab.aTabStop.GetDecimal() );
                     if ( nDecPos != -1 )
                     {
-                        nW -= pParaPortion->GetTextPortions()[nTmpPortion]->GetSize().Width();
+                        nW -= pParaPortion->GetTextPortions()[nTmpPortion].GetSize().Width();
                         nW += aTmpFont.QuickGetTextSize( GetRefDevice(), pParaPortion->GetNode()->GetString(), nTmpPos, nDecPos, NULL ).Width();
                         aCurrentTab.bValid = false;
                     }
@@ -1134,9 +1134,9 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
                     nW = nMaxW;
                     aCurrentTab.bValid = false;
                 }
-                TextPortion* const pTabPortion = pParaPortion->GetTextPortions()[aCurrentTab.nTabPortion];
-                pTabPortion->GetSize().Width() = aCurrentTab.nTabPos - aCurrentTab.nStartPosX - nW - nStartX;
-                nTmpWidth = aCurrentTab.nStartPosX + pTabPortion->GetSize().Width() + nWidthAfterTab;
+                TextPortion& rTabPortion = pParaPortion->GetTextPortions()[aCurrentTab.nTabPortion];
+                rTabPortion.GetSize().Width() = aCurrentTab.nTabPos - aCurrentTab.nStartPosX - nW - nStartX;
+                nTmpWidth = aCurrentTab.nStartPosX + rTabPortion.GetSize().Width() + nWidthAfterTab;
             }
 
             nTmpPos = nTmpPos + pPortion->GetLen();
@@ -1173,9 +1173,7 @@ 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_Int32 nP = SplitTextPortion( pParaPortion, nTmpPos, pLine );
-                const TextPortion* p = pParaPortion->GetTextPortions()[nP];
-                DBG_ASSERT( p, "Portion ?!" );
-                nTmpWidth += p->GetSize().Width();
+                nTmpWidth += pParaPortion->GetTextPortions()[nP].GetSize().Width();
             }
         }
         else if ( nTmpWidth >= nXWidth )
@@ -1283,16 +1281,16 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
         sal_Int32 nTPos = pLine->GetStart();
         for ( sal_Int32 nP = pLine->GetStartPortion(); nP <= pLine->GetEndPortion(); nP++ )
         {
-            const TextPortion* pTP = pParaPortion->GetTextPortions()[nP];
+            const TextPortion& rTP = pParaPortion->GetTextPortions()[nP];
             // problem with hard font height attribute, when everything but the line break has this attribute
-            if ( pTP->GetKind() != PortionKind::LINEBREAK )
+            if ( rTP.GetKind() != PortionKind::LINEBREAK )
             {
                 SeekCursor( pNode, nTPos+1, aTmpFont );
                 aTmpFont.SetPhysFont( GetRefDevice() );
                 ImplInitDigitMode(GetRefDevice(), aTmpFont.GetLanguage());
                 RecalcFormatterFontMetrics( aFormatterMetrics, aTmpFont );
             }
-            nTPos = nTPos + pTP->GetLen();
+            nTPos = nTPos + rTP.GetLen();
         }
         sal_uInt16 nLineHeight = aFormatterMetrics.GetHeight();
         if ( nLineHeight > pLine->GetHeight() )
@@ -1379,11 +1377,11 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
             // Width from HangingPunctuation was set to 0 in ImpBreakLine,
             // check for rel width now, maybe create compression...
             long n = nMaxLineWidth - aTextSize.Width();
-            TextPortion* const pTP = pParaPortion->GetTextPortions()[pLine->GetEndPortion()];
+            TextPortion& rTP = pParaPortion->GetTextPortions()[pLine->GetEndPortion()];
             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;
+            rTP.GetSize().Width() += n;
         }
 
         pLine->SetTextWidth( aTextSize.Width() );
@@ -1507,7 +1505,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
             // Next line or maybe a new line....
             pLine = 0;
             if ( nLine < pParaPortion->GetLines().Count()-1 )
-                pLine = pParaPortion->GetLines()[++nLine];
+                pLine = &pParaPortion->GetLines()[++nLine];
             if ( pLine && ( nIndex >= pNode->Len() ) )
             {
                 nDelFromLine = nLine;
@@ -1696,9 +1694,8 @@ void ImpEditEngine::CreateAndInsertEmptyLine( ParaPortion* pParaPortion, sal_uIn
     {
         // -2: The new one is already inserted.
 #ifdef DBG_UTIL
-        EditLine* pLastLine = pParaPortion->GetLines()[pParaPortion->GetLines().Count()-2];
-        DBG_ASSERT( pLastLine, "soft wrap no line?!" );
-        DBG_ASSERT( pLastLine->GetEnd() == pParaPortion->GetNode()->Len(), "different anyway?" );
+        EditLine& rLastLine = pParaPortion->GetLines()[pParaPortion->GetLines().Count()-2];
+        DBG_ASSERT( rLastLine.GetEnd() == pParaPortion->GetNode()->Len(), "different anyway?" );
 #endif
         sal_Int32 nPos = pParaPortion->GetTextPortions().Count() - 1 ;
         pTmpLine->SetStartPortion( nPos );
@@ -1943,12 +1940,12 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te
 
     if ( bCompressBlank || bHangingPunctuation )
     {
-        TextPortion* const pTP = pParaPortion->GetTextPortions()[nEndPortion];
-        DBG_ASSERT( pTP->GetKind() == PortionKind::TEXT, "BlankRubber: No TextPortion!" );
+        TextPortion& rTP = pParaPortion->GetTextPortions()[nEndPortion];
+        DBG_ASSERT( rTP.GetKind() == PortionKind::TEXT, "BlankRubber: No TextPortion!" );
         DBG_ASSERT( nBreakPos > pLine->GetStart(), "SplitTextPortion at the beginning of the line?" );
         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();
+        rTP.GetSize().Width() = ( nPosInArray && ( rTP.GetLen() > 1 ) ) ? pLine->GetCharPosArray()[ nPosInArray-1 ] : 0;
+        pLine->GetCharPosArray()[ nPosInArray ] = rTP.GetSize().Width();
     }
     else if ( bHyphenated )
     {
@@ -1958,13 +1955,13 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te
         OUString aHyphText(CH_HYPH);
         if ( (cAlternateReplChar || cAlternateExtraChar) && bAltFullRight ) // alternation after the break doesn't supported
         {
-            TextPortion* pPrev = pParaPortion->GetTextPortions()[nEndPortion];
-            DBG_ASSERT( pPrev && pPrev->GetLen(), "Hyphenate: Prev portion?!" );
-            pPrev->SetLen( pPrev->GetLen() - nAltDelChar );
+            TextPortion& rPrev = pParaPortion->GetTextPortions()[nEndPortion];
+            DBG_ASSERT( rPrev.GetLen(), "Hyphenate: Prev portion?!" );
+            rPrev.SetLen( rPrev.GetLen() - nAltDelChar );
             pHyphPortion->SetLen( nAltDelChar );
             if (cAlternateReplChar && !bAltFullLeft) pHyphPortion->SetExtraValue( cAlternateReplChar );
             // Correct width of the portion above:
-            pPrev->GetSize().Width() =
+            rPrev.GetSize().Width() =
                 pLine->GetCharPosArray()[ nBreakPos-1 - pLine->GetStart() - nAltDelChar ];
         }
 
@@ -2043,18 +2040,18 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine,
         aPositions.pop_back();
         sal_Int32 nPortionStart, nPortion;
         nPortion = pParaPortion->GetTextPortions().FindPortion( nLastChar+1, nPortionStart );
-        TextPortion* pLastPortion = pParaPortion->GetTextPortions()[ nPortion ];
+        TextPortion& rLastPortion = pParaPortion->GetTextPortions()[ nPortion ];
         long nRealWidth = pLine->GetCharPosArray()[nLastChar-nFirstChar];
         long nBlankWidth = nRealWidth;
         if ( nLastChar > nPortionStart )
             nBlankWidth -= pLine->GetCharPosArray()[nLastChar-nFirstChar-1];
         // Possibly the blank has already been deducted in ImpBreakLine:
-        if ( nRealWidth == pLastPortion->GetSize().Width() )
+        if ( nRealWidth == rLastPortion.GetSize().Width() )
         {
             // For the last character the portion must stop behind the blank
             // => Simplify correction:
-            DBG_ASSERT( ( nPortionStart + pLastPortion->GetLen() ) == ( nLastChar+1 ), "Blank actually not at the end of the portion!?");
-            pLastPortion->GetSize().Width() -= nBlankWidth;
+            DBG_ASSERT( ( nPortionStart + rLastPortion.GetLen() ) == ( nLastChar+1 ), "Blank actually not at the end of the portion!?");
+            rLastPortion.GetSize().Width() -= nBlankWidth;
             nRemainingSpace += nBlankWidth;
         }
         pLine->GetCharPosArray()[nLastChar-nFirstChar] -= nBlankWidth;
@@ -2076,16 +2073,16 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine,
         {
             sal_Int32 nPortionStart, nPortion;
             nPortion = pParaPortion->GetTextPortions().FindPortion( nChar, nPortionStart, true );
-            TextPortion* pLastPortion = pParaPortion->GetTextPortions()[ nPortion ];
+            TextPortion& rLastPortion = pParaPortion->GetTextPortions()[ nPortion ];
 
             // The width of the portion:
-            pLastPortion->GetSize().Width() += nMore4Everyone;
+            rLastPortion.GetSize().Width() += nMore4Everyone;
             if ( nSomeExtraSpace )
-                pLastPortion->GetSize().Width()++;
+                rLastPortion.GetSize().Width()++;
 
             // Correct positions in array
             // Even for kashidas just change positions, VCL will then draw the kashida automatically
-            sal_Int32 nPortionEnd = nPortionStart + pLastPortion->GetLen();
+            sal_Int32 nPortionEnd = nPortionStart + rLastPortion.GetLen();
             for ( sal_Int32 _n = nChar; _n < nPortionEnd; _n++ )
             {
                 pLine->GetCharPosArray()[_n-nFirstChar] += nMore4Everyone;
@@ -2233,15 +2230,15 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_Int32 nPos
     sal_Int32 nPortions = pPortion->GetTextPortions().Count();
     for ( nSplitPortion = 0; nSplitPortion < nPortions; nSplitPortion++ )
     {
-        TextPortion* pTP = pPortion->GetTextPortions()[nSplitPortion];
-        nTmpPos = nTmpPos + pTP->GetLen();
+        TextPortion& rTP = pPortion->GetTextPortions()[nSplitPortion];
+        nTmpPos = nTmpPos + rTP.GetLen();
         if ( nTmpPos >= nPos )
         {
             if ( nTmpPos == nPos )  // then nothing needs to be split
             {
                 return nSplitPortion;
             }
-            pTextPortion = pTP;
+            pTextPortion = &rTP;
             break;
         }
     }
@@ -2339,24 +2336,24 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_Int32& rS
     sal_Int32 nP;
     for ( nP = 0; nP < (sal_Int32)pParaPortion->GetTextPortions().Count(); nP++ )
     {
-        const TextPortion* pTmpPortion = pParaPortion->GetTextPortions()[nP];
-        nPortionStart = nPortionStart + pTmpPortion->GetLen();
+        const TextPortion& rTmpPortion = pParaPortion->GetTextPortions()[nP];
+        nPortionStart = nPortionStart + rTmpPortion.GetLen();
         if ( nPortionStart >= nStartPos )
         {
-            nPortionStart = nPortionStart - pTmpPortion->GetLen();
+            nPortionStart = nPortionStart - rTmpPortion.GetLen();
             rStart = nPortionStart;
             nInvPortion = nP;
             break;
         }
     }
     DBG_ASSERT( nP < pParaPortion->GetTextPortions().Count() || !pParaPortion->GetTextPortions().Count(), "Nothing to delete: CreateTextPortions" );
-    if ( nInvPortion && ( nPortionStart+pParaPortion->GetTextPortions()[nInvPortion]->GetLen() > nStartPos ) )
+    if ( nInvPortion && ( nPortionStart+pParaPortion->GetTextPortions()[nInvPortion].GetLen() > nStartPos ) )
     {
         // prefer one in front ...
         // But only if it was in the middle of the portion of, otherwise it
         // might be the only one in the row in front!
         nInvPortion--;
-        nPortionStart = nPortionStart - pParaPortion->GetTextPortions()[nInvPortion]->GetLen();
+        nPortionStart = nPortionStart - pParaPortion->GetTextPortions()[nInvPortion].GetLen();
     }
     pParaPortion->GetTextPortions().DeleteFromPortion( nInvPortion );
 
@@ -2399,11 +2396,11 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nSta
             // A blank portion may be here, if the paragraph was empty,
             // or if a line was created by a hard line break.
             if ( ( nNewPortionPos < (sal_Int32)pParaPortion->GetTextPortions().Count() ) &&
-                    !pParaPortion->GetTextPortions()[nNewPortionPos]->GetLen() )
+                    !pParaPortion->GetTextPortions()[nNewPortionPos].GetLen() )
             {
-                TextPortion* const pTP = pParaPortion->GetTextPortions()[nNewPortionPos];
-                DBG_ASSERT( pTP->GetKind() == PortionKind::TEXT, "the empty portion was no TextPortion!" );
-                pTP->SetLen( pTP->GetLen() + nNewChars );
+                TextPortion& rTP = pParaPortion->GetTextPortions()[nNewPortionPos];
+                DBG_ASSERT( rTP.GetKind() == PortionKind::TEXT, "the empty portion was no TextPortion!" );
+                rTP.SetLen( rTP.GetLen() + nNewChars );
             }
             else
             {
@@ -2416,10 +2413,9 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nSta
             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"  );
-            pTP->SetLen( pTP->GetLen() + nNewChars );
-            pTP->GetSize().Width() = (-1);
+            TextPortion& rTP = pParaPortion->GetTextPortions()[ nTP ];
+            rTP.SetLen( rTP.GetLen() + nNewChars );
+            rTP.GetSize().Width() = (-1);
         }
     }
     else
@@ -2438,7 +2434,7 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nSta
         TextPortion* pTP = 0;
         for ( nPortion = 0; nPortion < nPortions; nPortion++ )
         {
-            pTP = pParaPortion->GetTextPortions()[ nPortion ];
+            pTP = &pParaPortion->GetTextPortions()[ nPortion ];
             if ( ( nPos+pTP->GetLen() ) > nStartPos )
             {
                 DBG_ASSERT( nPos <= nStartPos, "Wrong Start!" );

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list