[Libreoffice-commits] core.git: 7 commits - include/svl include/svx svl/source svx/source sw/inc sw/source

Michael Stahl mstahl at redhat.com
Mon Sep 7 07:55:21 PDT 2015


 include/svl/style.hxx                            |    5 
 include/svx/CommonStylePreviewRenderer.hxx       |    2 
 svl/source/items/style.cxx                       |    5 
 svx/source/styles/CommonStylePreviewRenderer.cxx |   89 ++++++++-------
 svx/source/tbxctrls/tbcontrl.cxx                 |   35 +++--
 sw/inc/docstyle.hxx                              |    7 -
 sw/inc/tblsel.hxx                                |   28 +++-
 sw/source/core/doc/docsort.cxx                   |   66 +++++------
 sw/source/core/doc/tblcpy.cxx                    |   46 ++++---
 sw/source/core/doc/tblrwcl.cxx                   |  136 ++++++++++++-----------
 sw/source/core/docnode/ndtbl.cxx                 |   40 +++---
 sw/source/core/docnode/ndtbl1.cxx                |    9 -
 sw/source/core/frmedt/fetab.cxx                  |    8 -
 sw/source/core/frmedt/tblsel.cxx                 |   33 ++---
 sw/source/ui/misc/srtdlg.cxx                     |    2 
 sw/source/uibase/app/docstyle.cxx                |   78 ++++++++++++-
 16 files changed, 360 insertions(+), 229 deletions(-)

New commits:
commit 07df816d73884d094f0f56be022aa0b4eff00b2d
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Sep 7 16:40:20 2015 +0200

    svx: fix font rendering in the style preview
    
    If the style does not actually have any font items, as is the case for
    frame, page and number styles in Writer, the maFont will be
    default-initialized and the maPixelSize incorrect.
    Avoid using these variables.
    
    Change-Id: I084cd8faa90a3d53310ceec55e8dae3af3dd586c

diff --git a/include/svx/CommonStylePreviewRenderer.hxx b/include/svx/CommonStylePreviewRenderer.hxx
index 49717b5..505c4bf 100644
--- a/include/svx/CommonStylePreviewRenderer.hxx
+++ b/include/svx/CommonStylePreviewRenderer.hxx
@@ -22,7 +22,7 @@ namespace svx
 
 class SVX_DLLPUBLIC CommonStylePreviewRenderer : public sfx2::StylePreviewRenderer
 {
-    SvxFont maFont;
+    std::unique_ptr<SvxFont> m_pFont;
     Color maFontColor;
     Color maBackgroundColor;
     Size maPixelSize;
diff --git a/svx/source/styles/CommonStylePreviewRenderer.cxx b/svx/source/styles/CommonStylePreviewRenderer.cxx
index 19bce5f..21876e9 100644
--- a/svx/source/styles/CommonStylePreviewRenderer.cxx
+++ b/svx/source/styles/CommonStylePreviewRenderer.cxx
@@ -47,7 +47,7 @@ CommonStylePreviewRenderer::CommonStylePreviewRenderer(
                                 const SfxObjectShell& rShell, OutputDevice& rOutputDev,
                                 SfxStyleSheetBase* pStyle, long nMaxHeight)
     : StylePreviewRenderer(rShell, rOutputDev, pStyle, nMaxHeight)
-    , maFont()
+    , m_pFont()
     , maFontColor(COL_AUTO)
     , maBackgroundColor(COL_AUTO)
     , maPixelSize()
@@ -60,53 +60,55 @@ CommonStylePreviewRenderer::~CommonStylePreviewRenderer()
 
 bool CommonStylePreviewRenderer::recalculate()
 {
-    maFont = SvxFont();
+    m_pFont.reset();
 
     std::unique_ptr<SfxItemSet> pItemSet(mpStyle->GetItemSetForPreview());
 
     if (!pItemSet) return false;
 
+    std::unique_ptr<SvxFont> pFont(new SvxFont);
+
     const SfxPoolItem* pItem;
 
     if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_WEIGHT)) != nullptr)
     {
-        maFont.SetWeight(static_cast<const SvxWeightItem*>(pItem)->GetWeight());
+        pFont->SetWeight(static_cast<const SvxWeightItem*>(pItem)->GetWeight());
     }
     if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_POSTURE)) != nullptr)
     {
-        maFont.SetItalic(static_cast<const SvxPostureItem*>(pItem)->GetPosture());
+        pFont->SetItalic(static_cast<const SvxPostureItem*>(pItem)->GetPosture());
     }
     if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_CONTOUR)) != nullptr)
     {
-        maFont.SetOutline(static_cast< const SvxContourItem*>(pItem)->GetValue());
+        pFont->SetOutline(static_cast< const SvxContourItem*>(pItem)->GetValue());
     }
     if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_SHADOWED)) != nullptr)
     {
-        maFont.SetShadow(static_cast<const SvxShadowedItem*>(pItem)->GetValue());
+        pFont->SetShadow(static_cast<const SvxShadowedItem*>(pItem)->GetValue());
     }
     if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_RELIEF)) != nullptr)
     {
-        maFont.SetRelief(static_cast<FontRelief>(static_cast<const SvxCharReliefItem*>(pItem)->GetValue()));
+        pFont->SetRelief(static_cast<FontRelief>(static_cast<const SvxCharReliefItem*>(pItem)->GetValue()));
     }
     if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_UNDERLINE)) != nullptr)
     {
-        maFont.SetUnderline(static_cast< const SvxUnderlineItem*>(pItem)->GetLineStyle());
+        pFont->SetUnderline(static_cast< const SvxUnderlineItem*>(pItem)->GetLineStyle());
     }
     if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_OVERLINE)) != nullptr)
     {
-        maFont.SetOverline(static_cast<FontUnderline>(static_cast<const SvxOverlineItem*>(pItem)->GetValue()));
+        pFont->SetOverline(static_cast<FontUnderline>(static_cast<const SvxOverlineItem*>(pItem)->GetValue()));
     }
     if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_STRIKEOUT)) != nullptr)
     {
-        maFont.SetStrikeout(static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout());
+        pFont->SetStrikeout(static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout());
     }
     if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_CASEMAP)) != nullptr)
     {
-        maFont.SetCaseMap(static_cast<const SvxCaseMapItem*>(pItem)->GetCaseMap());
+        pFont->SetCaseMap(static_cast<const SvxCaseMapItem*>(pItem)->GetCaseMap());
     }
     if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_EMPHASISMARK)) != nullptr)
     {
-        maFont.SetEmphasisMark(static_cast<const SvxEmphasisMarkItem*>(pItem)->GetEmphasisMark());
+        pFont->SetEmphasisMark(static_cast<const SvxEmphasisMarkItem*>(pItem)->GetEmphasisMark());
     }
     if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_COLOR)) != nullptr)
     {
@@ -131,8 +133,8 @@ bool CommonStylePreviewRenderer::recalculate()
     if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_FONT)) != nullptr)
     {
         const SvxFontItem* pFontItem = static_cast<const SvxFontItem*>(pItem);
-        maFont.SetName(pFontItem->GetFamilyName());
-        maFont.SetStyleName(pFontItem->GetStyleName());
+        pFont->SetName(pFontItem->GetFamilyName());
+        pFont->SetStyleName(pFontItem->GetStyleName());
     }
     else
     {
@@ -144,11 +146,11 @@ bool CommonStylePreviewRenderer::recalculate()
         const SvxFontHeightItem* pFontHeightItem = static_cast<const SvxFontHeightItem*>(pItem);
         Size aFontSize(0, pFontHeightItem->GetHeight());
         maPixelSize = Size(mrOutputDev.LogicToPixel(aFontSize, mrShell.GetMapUnit()));
-        maFont.SetSize(maPixelSize);
+        pFont->SetSize(maPixelSize);
 
         vcl::Font aOldFont(mrOutputDev.GetFont());
 
-        mrOutputDev.SetFont(maFont);
+        mrOutputDev.SetFont(*pFont);
         Rectangle aTextRect;
         mrOutputDev.GetTextBoundRect(aTextRect, mpStyle->GetName());
         if (aTextRect.Bottom() > mnMaxHeight)
@@ -156,7 +158,7 @@ bool CommonStylePreviewRenderer::recalculate()
             double ratio = double(mnMaxHeight) / aTextRect.Bottom();
             maPixelSize.Width() *= ratio;
             maPixelSize.Height() *= ratio;
-            maFont.SetSize(maPixelSize);
+            pFont->SetSize(maPixelSize);
         }
         mrOutputDev.SetFont(aOldFont);
     }
@@ -165,12 +167,14 @@ bool CommonStylePreviewRenderer::recalculate()
         return false;
     }
 
+    m_pFont = std::move(pFont);
     return true;
 }
 
 Size CommonStylePreviewRenderer::getRenderSize()
 {
-    maPixelSize = maFont.GetTextSize(&mrOutputDev, maStyleName);
+    assert(m_pFont);
+    maPixelSize = m_pFont->GetTextSize(&mrOutputDev, maStyleName);
     if (maPixelSize.Height() > mnMaxHeight)
         maPixelSize.Height() = mnMaxHeight;
     return maPixelSize;
@@ -191,20 +195,25 @@ bool CommonStylePreviewRenderer::render(const Rectangle& aRectangle, RenderAlign
         mrOutputDev.DrawRect(aRectangle);
     }
 
-    mrOutputDev.SetFont(maFont);
+    if (m_pFont)
+    {
+        mrOutputDev.SetFont(*m_pFont);
+    }
     if (maFontColor != COL_AUTO)
         mrOutputDev.SetTextColor(maFontColor);
 
+    Size aPixelSize((m_pFont) ? maPixelSize : mrOutputDev.GetFont().GetSize());
+
     Point aFontDrawPosition = aRectangle.TopLeft();
     if (eRenderAlign == RenderAlign::CENTER)
     {
-        if (aRectangle.GetHeight() > maPixelSize.Height())
-            aFontDrawPosition.Y() += (aRectangle.GetHeight() - maPixelSize.Height()) / 2;
+        if (aRectangle.GetHeight() > aPixelSize.Height())
+            aFontDrawPosition.Y() += (aRectangle.GetHeight() - aPixelSize.Height()) / 2;
     }
     else if (eRenderAlign == RenderAlign::BOTTOM)
     {
-        if (aRectangle.GetHeight() > maPixelSize.Height())
-            aFontDrawPosition.Y() += aRectangle.GetHeight() - maPixelSize.Height();
+        if (aRectangle.GetHeight() > aPixelSize.Height())
+            aFontDrawPosition.Y() += aRectangle.GetHeight() - aPixelSize.Height();
     }
 
     mrOutputDev.DrawText(aFontDrawPosition, rText);
commit 779b547ca6271156a59965569fa44fbeb3f63ce5
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Sep 7 16:18:53 2015 +0200

    tdf#90991: sw: fix style preview creating undo objects
    
    SwDocStyleSheet::FillStyleSheet() already takes care to remove all
    temporarily created styles, so assume that works and suppress the
    creation of user-visible Undo objects.
    
    Change-Id: I748f0e8304c42e767b331ebd22be0290b9c0d89d

diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx
index 0f824c8..6aa4b79 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -1777,6 +1777,9 @@ bool SwDocStyleSheet::FillStyleSheet(
         bPhysical = 0 != pCharFormat;
         if( bFillOnlyInfo && !bPhysical )
         {
+            // create style (plus all needed parents) and clean it up
+            // later - without affecting the undo/redo stack
+            ::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
             bDeleteInfo = true;
             ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
             pCharFormat = lcl_FindCharFormat(rDoc, aName, this );
@@ -1804,6 +1807,7 @@ bool SwDocStyleSheet::FillStyleSheet(
             bPhysical = 0 != pColl;
             if( bFillOnlyInfo && !bPhysical )
             {
+                ::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
                 bDeleteInfo = true;
                 ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
                 pColl = lcl_FindParaFormat(rDoc, aName, this );
@@ -1827,6 +1831,7 @@ bool SwDocStyleSheet::FillStyleSheet(
         bPhysical = 0 != pFrameFormat;
         if (bFillOnlyInfo && !bPhysical)
         {
+            ::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
             bDeleteInfo = true;
             ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
             pFrameFormat = lcl_FindFrameFormat(rDoc, aName, this );
@@ -1846,6 +1851,7 @@ bool SwDocStyleSheet::FillStyleSheet(
         bPhysical = 0 != pDesc;
         if( bFillOnlyInfo && !pDesc )
         {
+            ::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
             bDeleteInfo = true;
             ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
             pDesc = lcl_FindPageDesc( rDoc, aName, this );
@@ -1874,6 +1880,7 @@ bool SwDocStyleSheet::FillStyleSheet(
         bPhysical = 0 != pNumRule;
         if( bFillOnlyInfo && !pNumRule )
         {
+            ::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
             bDeleteInfo = true;
             ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
             pNumRule = lcl_FindNumRule( rDoc, aName, this );
@@ -1946,7 +1953,10 @@ bool SwDocStyleSheet::FillStyleSheet(
         SetMask( _nMask );
     }
     if( bDeleteInfo && bFillOnlyInfo )
+    {
+        ::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
         ::lcl_DeleteInfoStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
+    }
     return bRet;
 }
 
commit 93067f37cf22aa119db5878c4345fea500cbbb42
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Sep 7 16:36:24 2015 +0200

    tdf#91383: sw: prevent style preview from actually creating styles
    
    The dialog/sidebar should not actually create styles that don't exist yet,
    because it messes up Undo and the (unused) styles are then unnecessarily
    exported to documents.
    
    Due to Writer's ... unusual SwDocStyleSheet class this is a bit tricky.
    
    Add a new function GetItemSetForPreview() and use it from the style preview
    code.
    
    The implementation does not use FillPhysical so will temporarily create and
    then delete any non-existing styles.
    
    Skip page and numbering styles for now since they don't have a useful preview.
    
    (regression from ca95307638207db5d662059aa61594151a13e927)
    
    Change-Id: Id6ee30ea467fc24c991547a4c23a9ce14fdd86c7

diff --git a/include/svl/style.hxx b/include/svl/style.hxx
index dafa95e..3451312 100644
--- a/include/svl/style.hxx
+++ b/include/svl/style.hxx
@@ -139,6 +139,11 @@ public:
     virtual void   SetHelpId( const OUString& r, sal_uLong nId );
 
     virtual SfxItemSet& GetItemSet();
+    /// Due to writer's usual lack of sanity this is a separate function for
+    /// preview only; it shall not create the style in case it does not exist.
+    /// If the style has parents, it is _not_ required that the returned item
+    /// set has parents (i.e. use it for display purposes only).
+    virtual std::unique_ptr<SfxItemSet> GetItemSetForPreview();
 };
 
 /* Class to iterate and search on a SfxStyleSheetBasePool */
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index 5e9e524..930bf92 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -284,6 +284,11 @@ SfxItemSet& SfxStyleSheetBase::GetItemSet()
     return *pSet;
 }
 
+std::unique_ptr<SfxItemSet> SfxStyleSheetBase::GetItemSetForPreview()
+{
+    return std::unique_ptr<SfxItemSet>(new SfxItemSet(GetItemSet()));
+}
+
 /**
  * Set help file and ID and return it
  */
diff --git a/svx/source/styles/CommonStylePreviewRenderer.cxx b/svx/source/styles/CommonStylePreviewRenderer.cxx
index 2d9ac3f..19bce5f 100644
--- a/svx/source/styles/CommonStylePreviewRenderer.cxx
+++ b/svx/source/styles/CommonStylePreviewRenderer.cxx
@@ -60,65 +60,67 @@ CommonStylePreviewRenderer::~CommonStylePreviewRenderer()
 
 bool CommonStylePreviewRenderer::recalculate()
 {
-    const SfxItemSet& aItemSet = mpStyle->GetItemSet();
-
     maFont = SvxFont();
 
+    std::unique_ptr<SfxItemSet> pItemSet(mpStyle->GetItemSetForPreview());
+
+    if (!pItemSet) return false;
+
     const SfxPoolItem* pItem;
 
-    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_WEIGHT)) != nullptr)
+    if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_WEIGHT)) != nullptr)
     {
         maFont.SetWeight(static_cast<const SvxWeightItem*>(pItem)->GetWeight());
     }
-    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_POSTURE)) != nullptr)
+    if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_POSTURE)) != nullptr)
     {
         maFont.SetItalic(static_cast<const SvxPostureItem*>(pItem)->GetPosture());
     }
-    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_CONTOUR)) != nullptr)
+    if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_CONTOUR)) != nullptr)
     {
         maFont.SetOutline(static_cast< const SvxContourItem*>(pItem)->GetValue());
     }
-    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_SHADOWED)) != nullptr)
+    if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_SHADOWED)) != nullptr)
     {
         maFont.SetShadow(static_cast<const SvxShadowedItem*>(pItem)->GetValue());
     }
-    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_RELIEF)) != nullptr)
+    if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_RELIEF)) != nullptr)
     {
         maFont.SetRelief(static_cast<FontRelief>(static_cast<const SvxCharReliefItem*>(pItem)->GetValue()));
     }
-    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_UNDERLINE)) != nullptr)
+    if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_UNDERLINE)) != nullptr)
     {
         maFont.SetUnderline(static_cast< const SvxUnderlineItem*>(pItem)->GetLineStyle());
     }
-    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_OVERLINE)) != nullptr)
+    if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_OVERLINE)) != nullptr)
     {
         maFont.SetOverline(static_cast<FontUnderline>(static_cast<const SvxOverlineItem*>(pItem)->GetValue()));
     }
-    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_STRIKEOUT)) != nullptr)
+    if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_STRIKEOUT)) != nullptr)
     {
         maFont.SetStrikeout(static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout());
     }
-    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_CASEMAP)) != nullptr)
+    if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_CASEMAP)) != nullptr)
     {
         maFont.SetCaseMap(static_cast<const SvxCaseMapItem*>(pItem)->GetCaseMap());
     }
-    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_EMPHASISMARK)) != nullptr)
+    if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_EMPHASISMARK)) != nullptr)
     {
         maFont.SetEmphasisMark(static_cast<const SvxEmphasisMarkItem*>(pItem)->GetEmphasisMark());
     }
-    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_COLOR)) != nullptr)
+    if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_COLOR)) != nullptr)
     {
         maFontColor = Color(static_cast<const SvxColorItem*>(pItem)->GetValue());
     }
 
     if (mpStyle->GetFamily() == SFX_STYLE_FAMILY_PARA)
     {
-        if ((pItem = aItemSet.GetItem(XATTR_FILLSTYLE)) != nullptr)
+        if ((pItem = pItemSet->GetItem(XATTR_FILLSTYLE)) != nullptr)
         {
             sal_uInt16 aFillStyle = static_cast<const XFillStyleItem*>(pItem)->GetValue();
             if (aFillStyle == drawing::FillStyle_SOLID)
             {
-                if ((pItem = aItemSet.GetItem(XATTR_FILLCOLOR)) != nullptr)
+                if ((pItem = pItemSet->GetItem(XATTR_FILLCOLOR)) != nullptr)
                 {
                     maBackgroundColor = Color(static_cast<const XFillColorItem*>(pItem)->GetColorValue());
                 }
@@ -126,7 +128,7 @@ bool CommonStylePreviewRenderer::recalculate()
         }
     }
 
-    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_FONT)) != nullptr)
+    if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_FONT)) != nullptr)
     {
         const SvxFontItem* pFontItem = static_cast<const SvxFontItem*>(pItem);
         maFont.SetName(pFontItem->GetFamilyName());
@@ -137,7 +139,7 @@ bool CommonStylePreviewRenderer::recalculate()
         return false;
     }
 
-    if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_FONTHEIGHT)) != nullptr)
+    if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_FONTHEIGHT)) != nullptr)
     {
         const SvxFontHeightItem* pFontHeightItem = static_cast<const SvxFontHeightItem*>(pItem);
         Size aFontSize(0, pFontHeightItem->GetHeight());
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 4bb0294..81fad32 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -638,10 +638,13 @@ void SvxStyleBox_Impl::SetupEntry(vcl::RenderContext& rRenderContext, vcl::Windo
 
         if (pStyle )
         {
-            const SfxItemSet& aItemSet = pStyle->GetItemSet();
+            std::unique_ptr<const SfxItemSet> const pItemSet(pStyle->GetItemSetForPreview());
+            if (!pItemSet) return;
 
-            const SvxFontItem *pFontItem = static_cast< const SvxFontItem* >( aItemSet.GetItem( SID_ATTR_CHAR_FONT ) );
-            const SvxFontHeightItem *pFontHeightItem = static_cast< const SvxFontHeightItem* >( aItemSet.GetItem( SID_ATTR_CHAR_FONTHEIGHT ) );
+            const SvxFontItem * const pFontItem =
+                static_cast<const SvxFontItem*>(pItemSet->GetItem(SID_ATTR_CHAR_FONT));
+            const SvxFontHeightItem * const pFontHeightItem =
+                static_cast<const SvxFontHeightItem*>(pItemSet->GetItem(SID_ATTR_CHAR_FONTHEIGHT));
 
             if ( pFontItem && pFontHeightItem )
             {
@@ -654,43 +657,43 @@ void SvxStyleBox_Impl::SetupEntry(vcl::RenderContext& rRenderContext, vcl::Windo
                 aFont.SetStyleName(pFontItem->GetStyleName());
                 aFont.SetSize(aPixelSize);
 
-                const SfxPoolItem *pItem = aItemSet.GetItem( SID_ATTR_CHAR_WEIGHT );
+                const SfxPoolItem *pItem = pItemSet->GetItem( SID_ATTR_CHAR_WEIGHT );
                 if ( pItem )
                     aFont.SetWeight( static_cast< const SvxWeightItem* >( pItem )->GetWeight() );
 
-                pItem = aItemSet.GetItem( SID_ATTR_CHAR_POSTURE );
+                pItem = pItemSet->GetItem( SID_ATTR_CHAR_POSTURE );
                 if ( pItem )
                     aFont.SetItalic( static_cast< const SvxPostureItem* >( pItem )->GetPosture() );
 
-                pItem = aItemSet.GetItem( SID_ATTR_CHAR_CONTOUR );
+                pItem = pItemSet->GetItem( SID_ATTR_CHAR_CONTOUR );
                 if ( pItem )
                     aFont.SetOutline( static_cast< const SvxContourItem* >( pItem )->GetValue() );
 
-                pItem = aItemSet.GetItem( SID_ATTR_CHAR_SHADOWED );
+                pItem = pItemSet->GetItem( SID_ATTR_CHAR_SHADOWED );
                 if ( pItem )
                     aFont.SetShadow( static_cast< const SvxShadowedItem* >( pItem )->GetValue() );
 
-                pItem = aItemSet.GetItem( SID_ATTR_CHAR_RELIEF );
+                pItem = pItemSet->GetItem( SID_ATTR_CHAR_RELIEF );
                 if ( pItem )
                     aFont.SetRelief( static_cast< FontRelief >( static_cast< const SvxCharReliefItem* >( pItem )->GetValue() ) );
 
-                pItem = aItemSet.GetItem( SID_ATTR_CHAR_UNDERLINE );
+                pItem = pItemSet->GetItem( SID_ATTR_CHAR_UNDERLINE );
                 if ( pItem )
                     aFont.SetUnderline( static_cast< const SvxUnderlineItem* >( pItem )->GetLineStyle() );
 
-                pItem = aItemSet.GetItem( SID_ATTR_CHAR_OVERLINE );
+                pItem = pItemSet->GetItem( SID_ATTR_CHAR_OVERLINE );
                 if ( pItem )
                     aFont.SetOverline( static_cast< FontUnderline >( static_cast< const SvxOverlineItem* >( pItem )->GetValue() ) );
 
-                pItem = aItemSet.GetItem( SID_ATTR_CHAR_STRIKEOUT );
+                pItem = pItemSet->GetItem( SID_ATTR_CHAR_STRIKEOUT );
                 if ( pItem )
                     aFont.SetStrikeout( static_cast< const SvxCrossedOutItem* >( pItem )->GetStrikeout() );
 
-                pItem = aItemSet.GetItem( SID_ATTR_CHAR_CASEMAP );
+                pItem = pItemSet->GetItem( SID_ATTR_CHAR_CASEMAP );
                 if ( pItem )
                     aFont.SetCaseMap(static_cast<const SvxCaseMapItem*>(pItem)->GetCaseMap());
 
-                pItem = aItemSet.GetItem( SID_ATTR_CHAR_EMPHASISMARK );
+                pItem = pItemSet->GetItem( SID_ATTR_CHAR_EMPHASISMARK );
                 if ( pItem )
                     aFont.SetEmphasisMark( static_cast< const SvxEmphasisMarkItem* >( pItem )->GetEmphasisMark() );
 
@@ -701,14 +704,14 @@ void SvxStyleBox_Impl::SetupEntry(vcl::RenderContext& rRenderContext, vcl::Windo
 
                 rRenderContext.SetFont(aFont);
 
-                pItem = aItemSet.GetItem( SID_ATTR_CHAR_COLOR );
+                pItem = pItemSet->GetItem( SID_ATTR_CHAR_COLOR );
                 // text color, when nothing is selected
                 if ( (NULL != pItem) && bIsNotSelected)
                     aFontCol = Color( static_cast< const SvxColorItem* >( pItem )->GetValue() );
 
                 sal_uInt16 style = drawing::FillStyle_NONE;
                 // which kind of Fill style is selected
-                pItem = aItemSet.GetItem( XATTR_FILLSTYLE );
+                pItem = pItemSet->GetItem( XATTR_FILLSTYLE );
                 // only when ok and not selected
                 if ( (NULL != pItem) && bIsNotSelected)
                     style = static_cast< const XFillStyleItem* >( pItem )->GetValue();
@@ -718,7 +721,7 @@ void SvxStyleBox_Impl::SetupEntry(vcl::RenderContext& rRenderContext, vcl::Windo
                     case drawing::FillStyle_SOLID:
                     {
                         // set background color
-                        pItem = aItemSet.GetItem( XATTR_FILLCOLOR );
+                        pItem = pItemSet->GetItem( XATTR_FILLCOLOR );
                         if ( NULL != pItem )
                             aBackCol = Color( static_cast< const XFillColorItem* >( pItem )->GetColorValue() );
 
diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx
index f874ac5..e50c3c0 100644
--- a/sw/inc/docstyle.hxx
+++ b/sw/inc/docstyle.hxx
@@ -61,10 +61,12 @@ class SW_DLLPUBLIC SwDocStyleSheet : public SfxStyleSheetBase
     enum FillStyleType {
         FillOnlyName,
         FillAllInfo,
-        FillPhysical
+        FillPhysical,
+        FillPreview,
     };
 
-    SAL_DLLPRIVATE bool FillStyleSheet( FillStyleType eFType );
+    SAL_DLLPRIVATE bool FillStyleSheet(FillStyleType eFType,
+            std::unique_ptr<SfxItemSet> * o_ppFlatSet = nullptr);
 
 protected:
     virtual ~SwDocStyleSheet();
@@ -99,6 +101,7 @@ public:
                                         const bool bResetIndentAttrsAtParagraphStyle = false );
 
     virtual SfxItemSet&     GetItemSet() SAL_OVERRIDE;
+    virtual std::unique_ptr<SfxItemSet> GetItemSetForPreview() override;
     /** new method for paragraph styles to merge indent attributes of applied list
      style into the given item set, if the list style indent attributes are applicable. */
     void MergeIndentAttrsOfListStyle( SfxItemSet& rSet );
diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx
index 9f4dbdc..0f824c8 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -1163,6 +1163,61 @@ bool   SwDocStyleSheet::SetFollow( const OUString& rStr)
     return true;
 }
 
+static
+std::unique_ptr<SfxItemSet> lcl_SwFormatToFlatItemSet(SwFormat *const pFormat)
+{
+    // note: we don't add the odd items that GetItemSet() would add
+    // because they don't seem relevant for preview
+    std::vector<SfxItemSet const*> sets;
+    sets.push_back(&pFormat->GetAttrSet());
+    while (SfxItemSet const*const pParent = sets.back()->GetParent())
+    {
+        sets.push_back(pParent);
+    }
+    // start by copying top-level parent set
+    std::unique_ptr<SfxItemSet> pRet(new SfxItemSet(*sets.back()));
+    sets.pop_back();
+    for (auto iter = sets.rbegin(); iter != sets.rend(); ++iter)
+    {   // in reverse so child overrides parent
+        pRet->Put(**iter);
+    }
+    return pRet;
+}
+
+std::unique_ptr<SfxItemSet> SwDocStyleSheet::GetItemSetForPreview()
+{
+    if (SFX_STYLE_FAMILY_PAGE == nFamily || SFX_STYLE_FAMILY_PSEUDO == nFamily)
+    {
+        SAL_WARN("sw.ui", "GetItemSetForPreview not implemented for page or number style");
+        return std::unique_ptr<SfxItemSet>();
+    }
+    if (!bPhysical)
+    {
+        // because not only this style, but also any number of its parents
+        // (or follow style) may not actually exist in the document at this
+        // time, return one "flattened" item set that contains all items from
+        // all parents.
+        std::unique_ptr<SfxItemSet> pRet;
+        FillStyleSheet(FillPreview, &pRet);
+        assert(pRet);
+        return pRet;
+    }
+    else
+    {
+        switch (nFamily)
+        {
+            case SFX_STYLE_FAMILY_CHAR:
+                return lcl_SwFormatToFlatItemSet(pCharFormat);
+            case SFX_STYLE_FAMILY_PARA:
+                return lcl_SwFormatToFlatItemSet(pColl);
+            case SFX_STYLE_FAMILY_FRAME:
+                return lcl_SwFormatToFlatItemSet(pFrameFormat);
+            default:
+                assert(false);
+        }
+    }
+}
+
 // extract ItemSet to Name and Family, Mask
 
 SfxItemSet&   SwDocStyleSheet::GetItemSet()
@@ -1703,7 +1758,8 @@ static void lcl_DeleteInfoStyles( sal_uInt16 nFamily, std::vector<void*>& rArr,
 }
 
 // determine the format
-bool SwDocStyleSheet::FillStyleSheet( FillStyleType eFType )
+bool SwDocStyleSheet::FillStyleSheet(
+    FillStyleType const eFType, std::unique_ptr<SfxItemSet> *const o_ppFlatSet)
 {
     bool bRet = false;
     sal_uInt16 nPoolId = USHRT_MAX;
@@ -1711,7 +1767,7 @@ bool SwDocStyleSheet::FillStyleSheet( FillStyleType eFType )
 
     bool bCreate = FillPhysical == eFType;
     bool bDeleteInfo = false;
-    bool bFillOnlyInfo = FillAllInfo == eFType;
+    bool bFillOnlyInfo = FillAllInfo == eFType || FillPreview == eFType;
     std::vector<void*> aDelArr;
 
     switch(nFamily)
@@ -1879,6 +1935,12 @@ bool SwDocStyleSheet::FillStyleSheet( FillStyleType eFType )
 
             if( RES_CONDTXTFMTCOLL == pFormat->Which() )
                 _nMask |= SWSTYLEBIT_CONDCOLL;
+
+            if (FillPreview == eFType)
+            {
+                assert(o_ppFlatSet);
+                *o_ppFlatSet = lcl_SwFormatToFlatItemSet(pFormat);
+            }
         }
 
         SetMask( _nMask );
commit 110dc43d97d559b6369bca308f9dd39fd02e751e
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Sep 7 16:21:53 2015 +0200

    sw: fix not-quite-copypaste code in SwDocStyleSheet::FillStyleSheet()
    
    This causes the temporary creation of frame styles to fail.
    
    Change-Id: I5d148ae008660d9c0f457a4c0e9dc256e0dfc49a

diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx
index eb7f841..9f4dbdc 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -1769,7 +1769,7 @@ bool SwDocStyleSheet::FillStyleSheet( FillStyleType eFType )
     case SFX_STYLE_FAMILY_FRAME:
         pFrameFormat = lcl_FindFrameFormat(rDoc,  aName, this, bCreate);
         bPhysical = 0 != pFrameFormat;
-        if( bFillOnlyInfo && bPhysical )
+        if (bFillOnlyInfo && !bPhysical)
         {
             bDeleteInfo = true;
             ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
commit a68eaa09a4979dc4814301f137e4186c85dee54f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Sep 4 21:30:15 2015 +0200

    sw: convert boost::ptr_vector to std::vector<std::unique_ptr>
    
    Change-Id: I341fb7c0712dff77ebfed41560a487f85c27c25a

diff --git a/sw/inc/tblsel.hxx b/sw/inc/tblsel.hxx
index 2979dc9..1b7000e 100644
--- a/sw/inc/tblsel.hxx
+++ b/sw/inc/tblsel.hxx
@@ -153,7 +153,7 @@ void MakeSelUnions( SwSelUnions&, const SwLayoutFrm *pStart,
 class _FndBox;
 class _FndLine;
 
-typedef boost::ptr_vector<_FndBox> _FndBoxes;
+typedef std::vector<std::unique_ptr<_FndBox>> FndBoxes_t;
 typedef std::vector<std::unique_ptr<_FndLine>> FndLines_t;
 
 class _FndBox
@@ -194,12 +194,16 @@ public:
 class _FndLine
 {
     SwTableLine* pLine;
-    _FndBoxes aBoxes;
+    FndBoxes_t m_Boxes;
     _FndBox* pUpper;
+
+    _FndLine(_FndLine const&) = delete;
+    _FndLine& operator=(_FndLine const&) = delete;
+
 public:
     _FndLine(SwTableLine* pL, _FndBox* pFB=0) : pLine(pL), pUpper(pFB) {}
-    const _FndBoxes&    GetBoxes() const    { return aBoxes; }
-        _FndBoxes&      GetBoxes()          { return aBoxes; }
+    const FndBoxes_t&   GetBoxes() const    { return m_Boxes; }
+        FndBoxes_t&     GetBoxes()          { return m_Boxes; }
     const SwTableLine*  GetLine() const     { return pLine; }
         SwTableLine*    GetLine()           { return pLine; }
     const _FndBox*      GetUpper() const    { return pUpper; }
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index 138d4a6..9c4dd17 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -776,12 +776,12 @@ FlatFndBox::~FlatFndBox()
 bool FlatFndBox::CheckLineSymmetry(const _FndBox& rBox)
 {
     const FndLines_t &rLines = rBox.GetLines();
-    _FndBoxes::size_type nBoxes {0};
+    FndBoxes_t::size_type nBoxes {0};
 
     for (FndLines_t::size_type i=0; i < rLines.size(); ++i)
     {
         const _FndLine* pLn = rLines[i].get();
-        const _FndBoxes& rBoxes = pLn->GetBoxes();
+        const FndBoxes_t& rBoxes = pLn->GetBoxes();
 
         // Number of Boxes of all Lines is unequal -> no symmetry
         if( i  && nBoxes != rBoxes.size())
@@ -797,12 +797,12 @@ bool FlatFndBox::CheckLineSymmetry(const _FndBox& rBox)
 /// Check Box for symmetry (All Boxes of a Line need to have same number of Lines)
 bool FlatFndBox::CheckBoxSymmetry(const _FndLine& rLn)
 {
-    const _FndBoxes &rBoxes = rLn.GetBoxes();
+    const FndBoxes_t &rBoxes = rLn.GetBoxes();
     FndLines_t::size_type nLines {0};
 
-    for(_FndBoxes::size_type i=0; i < rBoxes.size(); ++i)
+    for (FndBoxes_t::size_type i = 0; i < rBoxes.size(); ++i)
     {
-        _FndBox const*const pBox = &rBoxes[i];
+        _FndBox const*const pBox = rBoxes[i].get();
         const FndLines_t& rLines = pBox->GetLines();
 
         // Number of Lines of all Boxes is unequal -> no symmetry
@@ -829,10 +829,11 @@ sal_uInt16 FlatFndBox::GetColCount(const _FndBox& rBox)
     {
         // The Boxes of a Line
         sal_uInt16 nCount = 0;
-        const _FndBoxes& rBoxes = pLine->GetBoxes();
-        for( const auto &rB : rBoxes )
-            // Iterate recursively over the Lines
-            nCount += rB.GetLines().empty() ? 1 : GetColCount(rB);
+        const FndBoxes_t& rBoxes = pLine->GetBoxes();
+        for (const auto &rpB : rBoxes)
+        {   // Iterate recursively over the Lines
+            nCount += rpB->GetLines().empty() ? 1 : GetColCount(*rpB);
+        }
 
         if( nSum < nCount )
             nSum = nCount;
@@ -850,12 +851,15 @@ sal_uInt16 FlatFndBox::GetRowCount(const _FndBox& rBox)
     sal_uInt16 nLines = 0;
     for (const auto & pLine : rLines)
     {   // The Boxes of a Line
-        const _FndBoxes& rBoxes = pLine->GetBoxes();
+        const FndBoxes_t& rBoxes = pLine->GetBoxes();
         sal_uInt16 nLn = 1;
-        for(const auto &rB : rBoxes)
-            if (rB.GetLines().size())
-                // Iterate recursively over the Lines
-                nLn = std::max(GetRowCount(rB), nLn);
+        for (const auto &rpB : rBoxes)
+        {
+            if (rpB->GetLines().size())
+            {   // Iterate recursively over the Lines
+                nLn = std::max(GetRowCount(*rpB), nLn);
+            }
+        }
 
         nLines = nLines + nLn;
     }
@@ -873,12 +877,12 @@ void FlatFndBox::FillFlat(const _FndBox& rBox, bool bLastBox)
     for (const auto & pLine : rLines)
     {
         // The Boxes of a Line
-        const _FndBoxes& rBoxes = pLine->GetBoxes();
+        const FndBoxes_t& rBoxes = pLine->GetBoxes();
         sal_uInt16 nOldCol = nCol;
-        for( _FndBoxes::size_type j = 0; j < rBoxes.size(); ++j )
+        for( FndBoxes_t::size_type j = 0; j < rBoxes.size(); ++j )
         {
             // Check the Box if it's an atomic one
-            const _FndBox *const pBox = &rBoxes[j];
+            const _FndBox *const pBox = rBoxes[j].get();
 
             if( pBox->GetLines().empty() )
             {
diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx
index a31e926..08fd897 100644
--- a/sw/source/core/doc/tblcpy.cxx
+++ b/sw/source/core/doc/tblcpy.cxx
@@ -213,8 +213,8 @@ namespace
                         SwTableLine *pLine2 = rLines[ ++nEndLn ];
                         SwTableBox *pTmpBox = pLine2->GetTabBoxes()[0];
                         _FndLine *pInsLine = new _FndLine( pLine2, &rFndBox );
-                        _FndBox *pFndBox = new _FndBox( pTmpBox, pInsLine );
-                        pInsLine->GetBoxes().insert(pInsLine->GetBoxes().begin(), pFndBox);
+                        std::unique_ptr<_FndBox> pFndBox(new _FndBox(pTmpBox, pInsLine));
+                        pInsLine->GetBoxes().insert(pInsLine->GetBoxes().begin(), std::move(pFndBox));
                         rFndLines.push_back(std::unique_ptr<_FndLine>(pInsLine));
                     }
                 }
@@ -858,7 +858,7 @@ bool SwTable::InsTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
                 // See if the Box count is high enough for the Lines
                 SwTableLine* pLastLn = GetTabLines().back();
 
-                pSttBox = pFLine->GetBoxes()[0].GetBox();
+                pSttBox = pFLine->GetBoxes()[0]->GetBox();
                 const SwTableBoxes::size_type nSttBox = pFLine->GetLine()->GetTabBoxes().GetPos( pSttBox );
                 for( SwTableLines::size_type n = rCpyTable.GetTabLines().size() - nNewLns;
                         n < rCpyTable.GetTabLines().size(); ++n )
@@ -902,7 +902,7 @@ bool SwTable::InsTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
             // We have enough rows, so check the Boxes per row
             pFLine = aFndBox.GetLines()[ nLn % nFndCnt ].get();
             SwTableLine* pLine = pFLine->GetLine();
-            pSttBox = pFLine->GetBoxes()[0].GetBox();
+            pSttBox = pFLine->GetBoxes()[0]->GetBox();
             const SwTableBoxes::size_type nSttBox = pLine->GetTabBoxes().GetPos( pSttBox );
             if( nLn >= nFndCnt )
             {
@@ -926,7 +926,7 @@ bool SwTable::InsTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
                 }
 
                 // Test for nesting
-                for( _FndBoxes::size_type nBx = 0; nBx < pFLine->GetBoxes().size(); ++nBx )
+                for (FndBoxes_t::size_type nBx = 0; nBx < pFLine->GetBoxes().size(); ++nBx)
                 {
                     SwTableBox *pTmpBox = pLine->GetTabBoxes()[ nSttBox + nBx ];
                     if( !pTmpBox->GetSttNd() )
@@ -936,7 +936,8 @@ bool SwTable::InsTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
                     }
                     // if Ok, insert the Box into the FndLine
                     pFndBox = new _FndBox( pTmpBox, pInsFLine );
-                    pInsFLine->GetBoxes().insert( pInsFLine->GetBoxes().begin() + nBx, pFndBox );
+                    pInsFLine->GetBoxes().insert( pInsFLine->GetBoxes().begin() + nBx,
+                            std::unique_ptr<_FndBox>(pFndBox));
                 }
                 aFndBox.GetLines().insert( aFndBox.GetLines().begin() + nLn, std::unique_ptr<_FndLine>(pInsFLine));
             }
@@ -957,7 +958,8 @@ bool SwTable::InsTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
                     if( nBx == pFLine->GetBoxes().size() )
                     {
                         pFndBox = new _FndBox( pTmpBox, pFLine );
-                        pFLine->GetBoxes().insert( pFLine->GetBoxes().begin() + nBx, pFndBox );
+                        pFLine->GetBoxes().insert(pFLine->GetBoxes().begin() + nBx,
+                                std::unique_ptr<_FndBox>(pFndBox));
                     }
                 }
             }
@@ -970,9 +972,11 @@ bool SwTable::InsTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
                     return false;
 
                 // Test for nesting
-                for( auto &rBox : pFLine->GetBoxes() )
-                    if (!rBox.GetBox()->GetSttNd())
+                for (auto &rpBox : pFLine->GetBoxes())
+                {
+                    if (!rpBox->GetBox()->GetSttNd())
                         return false;
+                }
             }
         }
 
@@ -1007,12 +1011,12 @@ bool SwTable::InsTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
             pFLine = aFndBox.GetLines()[ nLn ].get();
             SwTableLine* pCpyLn = rCpyTable.GetTabLines()[
                                 nLn % rCpyTable.GetTabLines().size() ];
-            for( _FndBoxes::size_type nBx = 0; nBx < pFLine->GetBoxes().size(); ++nBx )
+            for (FndBoxes_t::size_type nBx = 0; nBx < pFLine->GetBoxes().size(); ++nBx)
             {
                 // Copy the pCpyBox into pMyBox
                 lcl_CpyBox( rCpyTable, pCpyLn->GetTabBoxes()[
                             nBx % pCpyLn->GetTabBoxes().size() ],
-                    *this, pFLine->GetBoxes()[nBx].GetBox(), true, pUndo );
+                    *this, pFLine->GetBoxes()[nBx]->GetBox(), true, pUndo );
             }
         }
 
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index beea076..4083146 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -322,11 +322,11 @@ static void lcl_CopyCol( _FndBox & rFndBox, _CpyPara *const pCpyPara)
             if( bDiffCount )
             {
                 // The first Line should be enough
-                _FndBoxes const& rFndBoxes = pCmpLine->GetBoxes();
+                FndBoxes_t const& rFndBoxes = pCmpLine->GetBoxes();
                 long nSz = 0;
                 for( auto n = rFndBoxes.size(); n; )
                 {
-                    nSz += rFndBoxes[--n].GetBox()->
+                    nSz += rFndBoxes[--n]->GetBox()->
                             GetFrameFormat()->GetFrmSize().GetWidth();
                 }
                 aFrmSz.SetWidth( aFrmSz.GetWidth() -
@@ -385,10 +385,10 @@ static void lcl_CopyCol( _FndBox & rFndBox, _CpyPara *const pCpyPara)
         ::_InsTableBox( pCpyPara->pDoc, pCpyPara->pTableNd, pCpyPara->pInsLine,
                     aFindFrm.pNewFrameFormat, pBox, pCpyPara->nInsPos++ );
 
-        const _FndBoxes& rFndBxs = rFndBox.GetUpper()->GetBoxes();
+        const FndBoxes_t& rFndBxs = rFndBox.GetUpper()->GetBoxes();
         if( 8 > pCpyPara->nDelBorderFlag
                 ? pCpyPara->nDelBorderFlag != 0
-                : &rFndBox == &rFndBxs[rFndBxs.size() - 1] )
+                : &rFndBox == rFndBxs[rFndBxs.size() - 1].get())
         {
             const SvxBoxItem& rBoxItem = pBox->GetFrameFormat()->GetBox();
             if( 8 > pCpyPara->nDelBorderFlag
@@ -441,8 +441,7 @@ static void lcl_CopyRow(_FndLine& rFndLine, _CpyPara *const pCpyPara)
     }
 
     _CpyPara aPara( *pCpyPara, pNewLine );
-    for (_FndBoxes::iterator it = rFndLine.GetBoxes().begin();
-         it != rFndLine.GetBoxes().end(); ++it)
+    for (auto const& it : rFndLine.GetBoxes())
     {
         lcl_CopyCol(*it, &aPara);
     }
@@ -456,7 +455,7 @@ static void lcl_InsCol( _FndLine* pFndLn, _CpyPara& rCpyPara, sal_uInt16 nCpyCnt
     // Bug 29124: Not only copy in the BaseLines. If possible, we go down as far as possible
     _FndBox* pFBox;
     if( 1 == pFndLn->GetBoxes().size() &&
-        !( pFBox = &pFndLn->GetBoxes()[0] )->GetBox()->GetSttNd() )
+        !( pFBox = pFndLn->GetBoxes()[0].get() )->GetBox()->GetSttNd() )
     {
         // A Box with multiple Lines, so insert into these Lines
         for (auto &rpLine : pFBox->GetLines())
@@ -468,7 +467,7 @@ static void lcl_InsCol( _FndLine* pFndLn, _CpyPara& rCpyPara, sal_uInt16 nCpyCnt
     {
         rCpyPara.pInsLine = pFndLn->GetLine();
         SwTableBox* pBox = pFndLn->GetBoxes()[ bBehind ?
-                    pFndLn->GetBoxes().size()-1 : 0 ].GetBox();
+                    pFndLn->GetBoxes().size()-1 : 0 ]->GetBox();
         rCpyPara.nInsPos = pFndLn->GetLine()->GetTabBoxes().GetPos( pBox );
         if( bBehind )
             ++rCpyPara.nInsPos;
@@ -479,8 +478,7 @@ static void lcl_InsCol( _FndLine* pFndLn, _CpyPara& rCpyPara, sal_uInt16 nCpyCnt
                 rCpyPara.nDelBorderFlag = 9;
             else
                 rCpyPara.nDelBorderFlag = 8;
-            for (_FndBoxes::iterator it = pFndLn->GetBoxes().begin();
-                 it != pFndLn->GetBoxes().end(); ++it)
+            for (auto const& it : pFndLn->GetBoxes())
             {
                 lcl_CopyCol(*it, &rCpyPara);
             }
@@ -580,7 +578,7 @@ bool SwTable::_InsertRow( SwDoc* pDoc, const SwSelBoxes& rBoxes,
             1 == (pFndLine = pFndBox->GetLines()[0].get())->GetBoxes().size())
         {
             // Don't go down too far! One Line with Box needs to remain!
-            _FndBox* pTmpBox = &pFndLine->GetBoxes().front();
+            _FndBox *const pTmpBox = pFndLine->GetBoxes().front().get();
             if( !pTmpBox->GetLines().empty() )
                 pFndBox = pTmpBox;
             else
@@ -1465,8 +1463,8 @@ static void lcl_Merge_MoveLine(_FndLine& rFndLine, _InsULPara *const pULPara)
                         &pFndLn->GetUpper()->GetTabLines() :
                         &pULPara->pTableNd->GetTable().GetTabLines();
 
-        SwTableBox* pLBx = rFndLine.GetBoxes().front().GetBox();
-        SwTableBox* pRBx = rFndLine.GetBoxes().back().GetBox();
+        SwTableBox* pLBx = rFndLine.GetBoxes().front()->GetBox();
+        SwTableBox* pRBx = rFndLine.GetBoxes().back()->GetBox();
         sal_uInt16 nLeft = pFndLn->GetTabBoxes().GetPos( pLBx );
         sal_uInt16 nRight = pFndLn->GetTabBoxes().GetPos( pRBx );
 
@@ -1533,11 +1531,11 @@ static void lcl_Merge_MoveLine(_FndLine& rFndLine, _InsULPara *const pULPara)
         static_cast<SwTableLineFormat*>(rFndLine.GetLine()->GetFrameFormat()), 0, pULPara->pInsBox );
     _InsULPara aPara( *pULPara );       // copying
     aPara.pInsLine = pNewLine;
-    _FndBoxes & rLineBoxes = rFndLine.GetBoxes();
-    for (_FndBoxes::iterator it = rLineBoxes.begin() + nStt;
+    FndBoxes_t & rLineBoxes = rFndLine.GetBoxes();
+    for (FndBoxes_t::iterator it = rLineBoxes.begin() + nStt;
          it != rLineBoxes.begin() + nEnd; ++it)
     {
-        lcl_Merge_MoveBox(*it, &aPara);
+        lcl_Merge_MoveBox(**it, &aPara);
     }
 
     if( !pNewLine->GetTabBoxes().empty() )
@@ -1587,7 +1585,7 @@ bool SwTable::OldMerge( SwDoc* pDoc, const SwSelBoxes& rBoxes,
     while( 1 == pFndBox->GetLines().size() &&
             1 == pFndBox->GetLines().front()->GetBoxes().size() )
     {
-        pFndBox = &pFndBox->GetLines().front()->GetBoxes().front();
+        pFndBox = pFndBox->GetLines().front()->GetBoxes().front().get();
     }
 
     SwTableLine* pInsLine = new SwTableLine(
@@ -1619,13 +1617,13 @@ bool SwTable::OldMerge( SwDoc* pDoc, const SwSelBoxes& rBoxes,
     // Move the overlapping upper/lower Lines of the selected Area
     for (auto & it : pFndBox->GetLines().front()->GetBoxes())
     {
-        lcl_Merge_MoveBox(it, &aPara);
+        lcl_Merge_MoveBox(*it, &aPara);
     }
     aPara.SetLower( pInsLine );
     const auto nEnd = pFndBox->GetLines().size()-1;
     for (auto & it : pFndBox->GetLines()[nEnd]->GetBoxes())
     {
-        lcl_Merge_MoveBox(it, &aPara);
+        lcl_Merge_MoveBox(*it, &aPara);
     }
 
     // Move the Boxes extending into the selected Area from left/right
@@ -1702,7 +1700,7 @@ static sal_uInt16 lcl_GetBoxOffset( const _FndBox& rBox )
     const _FndBox* pFirstBox = &rBox;
     while (!pFirstBox->GetLines().empty())
     {
-        pFirstBox = &pFirstBox->GetLines().front()->GetBoxes().front();
+        pFirstBox = pFirstBox->GetLines().front()->GetBoxes().front().get();
     }
 
     sal_uInt16 nRet = 0;
@@ -1726,7 +1724,7 @@ static sal_uInt16 lcl_GetLineWidth( const _FndLine& rLine )
     sal_uInt16 nRet = 0;
     for( auto n = rLine.GetBoxes().size(); n; )
     {
-        nRet = nRet + static_cast<sal_uInt16>(rLine.GetBoxes()[--n].GetBox()
+        nRet = nRet + static_cast<sal_uInt16>(rLine.GetBoxes()[--n]->GetBox()
                             ->GetFrameFormat()->GetFrmSize().GetWidth());
     }
     return nRet;
@@ -1755,7 +1753,7 @@ static void lcl_CalcNewWidths(const FndLines_t& rFndLines, _CpyPara& rPara)
                     sal_uLong nPos = 0;
                     // The first selected box...
                     const SwTableBox *const pSel =
-                        pFndLine->GetBoxes().front().GetBox();
+                        pFndLine->GetBoxes().front()->GetBox();
                     size_t nBox = 0;
                     // Sum up the width of all boxes before the first selected box
                     while( nBox < nBoxCount )
@@ -1777,7 +1775,7 @@ static void lcl_CalcNewWidths(const FndLines_t& rFndLines, _CpyPara& rPara)
                     for( nBox = 0; nBox < nBoxCount; )
                     {
                         nPos += pFndLine->GetBoxes()[nBox]
-                            .GetBox()->GetFrameFormat()->GetFrmSize().GetWidth();
+                            ->GetBox()->GetFrameFormat()->GetFrmSize().GetWidth();
                         rWidth[ ++nBox ] = nPos;
                     }
                     // nPos: The right border of the last selected box
@@ -1997,14 +1995,16 @@ lcl_CopyLineToDoc(const _FndLine& rFndLine, _CpyPara *const pCpyPara)
     }
     else
         // Calculate it
-        for( auto &rBox : rFndLine.GetBoxes() )
+        for (auto &rpBox : rFndLine.GetBoxes())
         {
-            aPara.nOldSize += rBox.GetBox()->GetFrameFormat()->GetFrmSize().GetWidth();
+            aPara.nOldSize += rpBox->GetBox()->GetFrameFormat()->GetFrmSize().GetWidth();
         }
 
-    const _FndBoxes& rBoxes = rFndLine.GetBoxes();
-    for (_FndBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it)
+    const FndBoxes_t& rBoxes = rFndLine.GetBoxes();
+    for (auto const& it : rBoxes)
+    {
         lcl_CopyBoxToDoc(*it, &aPara);
+    }
     if( pCpyPara->pTableNd->GetTable().IsNewModel() )
         ++pCpyPara->nLnIdx;
 }
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 3635c4a..5f50cc9 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1860,7 +1860,7 @@ bool SwDoc::DeleteRow( const SwCursor& rCursor )
         while( 1 == pFndBox->GetLines().size() &&
                 1 == pFndBox->GetLines().front()->GetBoxes().size() )
         {
-            _FndBox *const pTmp = & pFndBox->GetLines().front()->GetBoxes()[0];
+            _FndBox *const pTmp = pFndBox->GetLines().front()->GetBoxes()[0].get();
             if( pTmp->GetBox()->GetSttNd() )
                 break; // Else it gets too far
             pFndBox = pTmp;
@@ -3657,8 +3657,7 @@ static bool lcl_SetAFormatLine(_FndLine &, _SetAFormatTabPara *pPara);
 
 static bool lcl_SetAFormatLine(_FndLine & rLine, _SetAFormatTabPara *pPara)
 {
-    for (_FndBoxes::iterator it = rLine.GetBoxes().begin();
-         it != rLine.GetBoxes().end(); ++it)
+    for (auto const& it : rLine.GetBoxes())
     {
         lcl_SetAFormatBox(*it, pPara);
     }
@@ -3749,7 +3748,7 @@ bool SwDoc::SetTableAutoFormat( const SwSelBoxes& rBoxes, const SwTableAutoForma
     while( 1 == pFndBox->GetLines().size() &&
             1 == pFndBox->GetLines().front()->GetBoxes().size())
     {
-        pFndBox = &pFndBox->GetLines().front()->GetBoxes()[0];
+        pFndBox = pFndBox->GetLines().front()->GetBoxes()[0].get();
     }
 
     if( pFndBox->GetLines().empty() ) // One too far? (only one sel. Box)
@@ -3789,8 +3788,7 @@ bool SwDoc::SetTableAutoFormat( const SwSelBoxes& rBoxes, const SwTableAutoForma
         aPara.nCurBox = 0;
         aPara.nEndBox = pLine->GetBoxes().size()-1;
         aPara.pUndo = pUndo;
-        for (_FndBoxes::iterator it = pLine->GetBoxes().begin();
-             it != pLine->GetBoxes().end(); ++it)
+        for (auto const& it : pLine->GetBoxes())
         {
             lcl_SetAFormatBox(*it, &aPara);
         }
@@ -3836,7 +3834,7 @@ bool SwDoc::GetTableAutoFormat( const SwSelBoxes& rBoxes, SwTableAutoFormat& rGe
     while( 1 == pFndBox->GetLines().size() &&
             1 == pFndBox->GetLines().front()->GetBoxes().size())
     {
-        pFndBox = &pFndBox->GetLines().front()->GetBoxes()[0];
+        pFndBox = pFndBox->GetLines().front()->GetBoxes()[0].get();
     }
 
     if( pFndBox->GetLines().empty() ) // One too far? (only one sel. Box)
@@ -3862,7 +3860,7 @@ bool SwDoc::GetTableAutoFormat( const SwSelBoxes& rBoxes, SwTableAutoFormat& rGe
 
         for( sal_uInt8 nBox = 0; nBox < 4; ++nBox )
         {
-            SwTableBox* pFBox = rLine.GetBoxes()[ aBoxArr[ nBox ] ].GetBox();
+            SwTableBox* pFBox = rLine.GetBoxes()[ aBoxArr[ nBox ] ]->GetBox();
             // Always apply to the first ones
             while( !pFBox->GetSttNd() )
                 pFBox = pFBox->GetTabLines()[0]->GetTabBoxes()[0];
diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx
index 51d5fa7..797c159 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -207,8 +207,7 @@ bool _FindBox( _FndBox & rBox, LinesAndTable* pPara )
 
 bool _FindLine( _FndLine& rLine, LinesAndTable* pPara )
 {
-    for (_FndBoxes::iterator it = rLine.GetBoxes().begin();
-         it != rLine.GetBoxes().end(); ++it)
+    for (auto const& it : rLine.GetBoxes())
     {
         _FindBox(*it, pPara);
     }
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index 3a2bea9..4735403 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -376,7 +376,7 @@ bool SwFEShell::DeleteRow(bool bCompleteTable)
             while( 1 == pFndBox->GetLines().size() &&
                     1 == pFndBox->GetLines().front()->GetBoxes().size())
             {
-                _FndBox* pTmp = &pFndBox->GetLines().front()->GetBoxes()[0];
+                _FndBox *const pTmp = pFndBox->GetLines().front()->GetBoxes()[0].get();
                 if( pTmp->GetBox()->GetSttNd() )
                     break;      // otherwise too far
                 pFndBox = pTmp;
diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx
index a2aab4a..26a5d16 100644
--- a/sw/source/core/frmedt/tblsel.cxx
+++ b/sw/source/core/frmedt/tblsel.cxx
@@ -1391,8 +1391,7 @@ static bool lcl_CheckCol(_FndBox const&, bool* pPara);
 
 static bool lcl_CheckRow( const _FndLine& rFndLine, bool* pPara )
 {
-    for (_FndBoxes::const_iterator it = rFndLine.GetBoxes().begin();
-         it != rFndLine.GetBoxes().end(); ++it)
+    for (auto const& it : rFndLine.GetBoxes())
     {
         lcl_CheckCol(*it, pPara);
     }
@@ -1460,7 +1459,7 @@ sal_uInt16 CheckMergeSel( const SwSelBoxes& rBoxes )
             {
                 pFndLine = pFndBox->GetLines().front().get();
                 if( 1 == pFndLine->GetBoxes().size() )
-                    pFndBox = &pFndLine->GetBoxes().front();
+                    pFndBox = pFndLine->GetBoxes().front().get();
                 else
                     pFndBox = 0;
             }
@@ -1473,8 +1472,7 @@ sal_uInt16 CheckMergeSel( const SwSelBoxes& rBoxes )
             }
             else if( pFndLine )
             {
-                for (_FndBoxes::const_iterator it = pFndLine->GetBoxes().begin(),
-                        end = pFndLine->GetBoxes().end(); it != end; ++it)
+                for (auto const& it : pFndLine->GetBoxes())
                 {
                     lcl_CheckCol(*it, &bMergeSelOk);
                 }
@@ -2057,7 +2055,7 @@ static void _FndBoxCopyCol( SwTableBox* pBox, _FndPara* pFndPara )
             return;
         }
     }
-    pFndPara->pFndLine->GetBoxes().push_back( pFndBox );
+    pFndPara->pFndLine->GetBoxes().push_back(std::unique_ptr<_FndBox>(pFndBox));
 }
 
 static void _FndLineCopyCol( SwTableLine* pLine, _FndPara* pFndPara )
commit b7a5b788f37707f9d0c473877be9777ce784175a
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Sep 4 18:29:01 2015 +0200

    sw: convert boost::ptr_vector to std::vector<std::unique_ptr>
    
    Change-Id: If8d9770717c21875b4472b0d94a1fa5a9d136085

diff --git a/sw/inc/tblsel.hxx b/sw/inc/tblsel.hxx
index aa10016..2979dc9 100644
--- a/sw/inc/tblsel.hxx
+++ b/sw/inc/tblsel.hxx
@@ -23,10 +23,13 @@
 #include <swrect.hxx>
 #include "swdllapi.h"
 
-#include <deque>
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <o3tl/sorted_vector.hxx>
 
+#include <memory>
+#include <deque>
+#include <vector>
+
 class SwCrsrShell;
 class SwCursor;
 class SwTableCursor;
@@ -151,23 +154,26 @@ class _FndBox;
 class _FndLine;
 
 typedef boost::ptr_vector<_FndBox> _FndBoxes;
-typedef boost::ptr_vector<_FndLine> _FndLines;
+typedef std::vector<std::unique_ptr<_FndLine>> FndLines_t;
 
 class _FndBox
 {
     SwTableBox* pBox;
-    _FndLines aLines;
+    FndLines_t m_Lines;
     _FndLine* pUpper;
 
     SwTableLine *pLineBefore;   // For deleting/restoring the layout.
     SwTableLine *pLineBehind;
 
+    _FndBox(_FndBox const&) = delete;
+    _FndBox& operator=(_FndBox const&) = delete;
+
 public:
     _FndBox( SwTableBox* pB, _FndLine* pFL ) :
         pBox(pB), pUpper(pFL), pLineBefore( 0 ), pLineBehind( 0 ) {}
 
-    const _FndLines&    GetLines() const    { return aLines; }
-        _FndLines&      GetLines()          { return aLines; }
+    const FndLines_t&   GetLines() const    { return m_Lines; }
+        FndLines_t&     GetLines()          { return m_Lines; }
     const SwTableBox*   GetBox() const      { return pBox; }
         SwTableBox*     GetBox()            { return pBox; }
     const _FndLine*     GetUpper() const    { return pUpper; }
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index a492b46..138d4a6 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -494,17 +494,17 @@ bool SwDoc::SortTable(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt)
     if( !getIDocumentRedlineAccess().IsIgnoreRedline() && !getIDocumentRedlineAccess().GetRedlineTable().empty() )
         getIDocumentRedlineAccess().DeleteRedline( *pTableNd, true, USHRT_MAX );
 
-    _FndLines::size_type nStart = 0;
+    FndLines_t::size_type nStart = 0;
     if( pTableNd->GetTable().GetRowsToRepeat() > 0 && rOpt.eDirection == SRT_ROWS )
     {
         // Uppermost selected Cell
-        _FndLines& rLines = aFndBox.GetLines();
+        FndLines_t& rLines = aFndBox.GetLines();
 
         while( nStart < rLines.size() )
         {
             // Respect Split Merge nesting,
             // extract the upper most
-            SwTableLine* pLine = rLines[nStart].GetLine();
+            SwTableLine* pLine = rLines[nStart]->GetLine();
             while ( pLine->GetUpper() )
                 pLine = pLine->GetUpper()->GetUpper();
 
@@ -775,12 +775,12 @@ FlatFndBox::~FlatFndBox()
 /// All Lines of a Box need to have same number of Boxes
 bool FlatFndBox::CheckLineSymmetry(const _FndBox& rBox)
 {
-    const _FndLines &rLines = rBox.GetLines();
+    const FndLines_t &rLines = rBox.GetLines();
     _FndBoxes::size_type nBoxes {0};
 
-    for(_FndLines::size_type i=0; i < rLines.size(); ++i)
+    for (FndLines_t::size_type i=0; i < rLines.size(); ++i)
     {
-        const _FndLine* pLn = &rLines[i];
+        const _FndLine* pLn = rLines[i].get();
         const _FndBoxes& rBoxes = pLn->GetBoxes();
 
         // Number of Boxes of all Lines is unequal -> no symmetry
@@ -798,12 +798,12 @@ bool FlatFndBox::CheckLineSymmetry(const _FndBox& rBox)
 bool FlatFndBox::CheckBoxSymmetry(const _FndLine& rLn)
 {
     const _FndBoxes &rBoxes = rLn.GetBoxes();
-    _FndLines::size_type nLines {0};
+    FndLines_t::size_type nLines {0};
 
     for(_FndBoxes::size_type i=0; i < rBoxes.size(); ++i)
     {
         _FndBox const*const pBox = &rBoxes[i];
-        const _FndLines& rLines = pBox->GetLines();
+        const FndLines_t& rLines = pBox->GetLines();
 
         // Number of Lines of all Boxes is unequal -> no symmetry
         if( i && nLines != rLines.size() )
@@ -819,17 +819,17 @@ bool FlatFndBox::CheckBoxSymmetry(const _FndLine& rLn)
 /// Maximum count of Columns (Boxes)
 sal_uInt16 FlatFndBox::GetColCount(const _FndBox& rBox)
 {
-    const _FndLines& rLines = rBox.GetLines();
+    const FndLines_t& rLines = rBox.GetLines();
     // Iterate over Lines
     if( rLines.empty() )
         return 1;
 
     sal_uInt16 nSum = 0;
-    for( const auto &rLine : rLines )
+    for (const auto & pLine : rLines)
     {
         // The Boxes of a Line
         sal_uInt16 nCount = 0;
-        const _FndBoxes& rBoxes = rLine.GetBoxes();
+        const _FndBoxes& rBoxes = pLine->GetBoxes();
         for( const auto &rB : rBoxes )
             // Iterate recursively over the Lines
             nCount += rB.GetLines().empty() ? 1 : GetColCount(rB);
@@ -843,14 +843,14 @@ sal_uInt16 FlatFndBox::GetColCount(const _FndBox& rBox)
 /// Maximum count of Rows (Lines)
 sal_uInt16 FlatFndBox::GetRowCount(const _FndBox& rBox)
 {
-    const _FndLines& rLines = rBox.GetLines();
+    const FndLines_t& rLines = rBox.GetLines();
     if( rLines.empty() )
         return 1;
 
     sal_uInt16 nLines = 0;
-    for(const auto &rLine : rLines )
+    for (const auto & pLine : rLines)
     {   // The Boxes of a Line
-        const _FndBoxes& rBoxes = rLine.GetBoxes();
+        const _FndBoxes& rBoxes = pLine->GetBoxes();
         sal_uInt16 nLn = 1;
         for(const auto &rB : rBoxes)
             if (rB.GetLines().size())
@@ -866,14 +866,14 @@ sal_uInt16 FlatFndBox::GetRowCount(const _FndBox& rBox)
 void FlatFndBox::FillFlat(const _FndBox& rBox, bool bLastBox)
 {
     bool bModRow = false;
-    const _FndLines& rLines = rBox.GetLines();
+    const FndLines_t& rLines = rBox.GetLines();
 
     // Iterate over Lines
     sal_uInt16 nOldRow = nRow;
-    for( const auto &rLine : rLines )
+    for (const auto & pLine : rLines)
     {
         // The Boxes of a Line
-        const _FndBoxes& rBoxes = rLine.GetBoxes();
+        const _FndBoxes& rBoxes = pLine->GetBoxes();
         sal_uInt16 nOldCol = nCol;
         for( _FndBoxes::size_type j = 0; j < rBoxes.size(); ++j )
         {
diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx
index 760de52..a31e926 100644
--- a/sw/source/core/doc/tblcpy.cxx
+++ b/sw/source/core/doc/tblcpy.cxx
@@ -186,14 +186,14 @@ namespace
         if( !rFndBox.GetLines().empty() )
         {
             bool bNoSelection = rSelBoxes.size() < 2;
-            _FndLines &rFndLines = rFndBox.GetLines();
+            FndLines_t &rFndLines = rFndBox.GetLines();
             maCols.push_front(0);
-            const SwTableLine* pLine = rFndLines.front().GetLine();
+            const SwTableLine* pLine = rFndLines.front()->GetLine();
             const sal_uInt16 nStartLn = rTable.GetTabLines().GetPos( pLine );
             sal_uInt16 nEndLn = nStartLn;
             if( rFndLines.size() > 1 )
             {
-                pLine = rFndLines.back().GetLine();
+                pLine = rFndLines.back()->GetLine();
                 nEndLn = rTable.GetTabLines().GetPos( pLine );
             }
             if( nStartLn < USHRT_MAX && nEndLn < USHRT_MAX )
@@ -215,7 +215,7 @@ namespace
                         _FndLine *pInsLine = new _FndLine( pLine2, &rFndBox );
                         _FndBox *pFndBox = new _FndBox( pTmpBox, pInsLine );
                         pInsLine->GetBoxes().insert(pInsLine->GetBoxes().begin(), pFndBox);
-                        rFndLines.push_back( pInsLine );
+                        rFndLines.push_back(std::unique_ptr<_FndLine>(pInsLine));
                     }
                 }
                 maLines.resize( nEndLn - nStartLn + 1 );
@@ -831,13 +831,13 @@ bool SwTable::InsTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
     {
         _FndBox* pFndBox;
 
-        const _FndLines::size_type nFndCnt = aFndBox.GetLines().size();
+        const FndLines_t::size_type nFndCnt = aFndBox.GetLines().size();
         if( !nFndCnt )
             return false;
 
         // Check if we have enough space for all Lines and Boxes
         SwTableLines::size_type nTstLns = 0;
-        pFLine = &aFndBox.GetLines().front();
+        pFLine = aFndBox.GetLines().front().get();
         sal_uInt16 nSttLine = GetTabLines().GetPos( pFLine->GetLine() );
         // Do we have as many rows, actually?
         if( 1 == nFndCnt )
@@ -900,7 +900,7 @@ bool SwTable::InsTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
         for( SwTableLines::size_type nLn = 0; nLn < nTstLns; ++nLn )
         {
             // We have enough rows, so check the Boxes per row
-            pFLine = &aFndBox.GetLines()[ nLn % nFndCnt ];
+            pFLine = aFndBox.GetLines()[ nLn % nFndCnt ].get();
             SwTableLine* pLine = pFLine->GetLine();
             pSttBox = pFLine->GetBoxes()[0].GetBox();
             const SwTableBoxes::size_type nSttBox = pLine->GetTabBoxes().GetPos( pSttBox );
@@ -938,7 +938,7 @@ bool SwTable::InsTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
                     pFndBox = new _FndBox( pTmpBox, pInsFLine );
                     pInsFLine->GetBoxes().insert( pInsFLine->GetBoxes().begin() + nBx, pFndBox );
                 }
-                aFndBox.GetLines().insert( aFndBox.GetLines().begin() + nLn, pInsFLine );
+                aFndBox.GetLines().insert( aFndBox.GetLines().begin() + nLn, std::unique_ptr<_FndLine>(pInsFLine));
             }
             else if( pFLine->GetBoxes().size() == 1 )
             {
@@ -1002,9 +1002,9 @@ bool SwTable::InsTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
         }
     }
     else
-        for( _FndLines::size_type nLn = 0; nLn < aFndBox.GetLines().size(); ++nLn )
+        for (FndLines_t::size_type nLn = 0; nLn < aFndBox.GetLines().size(); ++nLn)
         {
-            pFLine = &aFndBox.GetLines()[ nLn ];
+            pFLine = aFndBox.GetLines()[ nLn ].get();
             SwTableLine* pCpyLn = rCpyTable.GetTabLines()[
                                 nLn % rCpyTable.GetTabLines().size() ];
             for( _FndBoxes::size_type nBx = 0; nBx < pFLine->GetBoxes().size(); ++nBx )
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index 520df3f..beea076 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -314,7 +314,7 @@ static void lcl_CopyCol( _FndBox & rFndBox, _CpyPara *const pCpyPara)
             bool bDiffCount = false;
             if( pBox->GetTabLines().size() )
             {
-                pCmpLine = &rFndBox.GetLines().front();
+                pCmpLine = rFndBox.GetLines().front().get();
                 if ( pCmpLine->GetBoxes().size() != pCmpLine->GetLine()->GetTabBoxes().size() )
                     bDiffCount = true;
             }
@@ -375,8 +375,10 @@ static void lcl_CopyCol( _FndBox & rFndBox, _CpyPara *const pCpyPara)
         _CpyPara aPara( *pCpyPara, pBox );
         aPara.nDelBorderFlag &= 7;
 
-        for( _FndLine & rFndLine : rFndBox.GetLines() )
-            lcl_CopyRow( rFndLine, &aPara );
+        for (auto const& pFndLine : rFndBox.GetLines())
+        {
+            lcl_CopyRow(*pFndLine, &aPara);
+        }
     }
     else
     {
@@ -457,8 +459,10 @@ static void lcl_InsCol( _FndLine* pFndLn, _CpyPara& rCpyPara, sal_uInt16 nCpyCnt
         !( pFBox = &pFndLn->GetBoxes()[0] )->GetBox()->GetSttNd() )
     {
         // A Box with multiple Lines, so insert into these Lines
-        for( auto &rLine : pFBox->GetLines() )
-            lcl_InsCol( &rLine, rCpyPara, nCpyCnt, bBehind );
+        for (auto &rpLine : pFBox->GetLines())
+        {
+            lcl_InsCol( rpLine.get(), rCpyPara, nCpyCnt, bBehind );
+        }
     }
     else
     {
@@ -526,8 +530,10 @@ bool SwTable::InsertCol( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCnt,
         _CpyTabFrms aTabFrmArr;
         _CpyPara aCpyPara( pTableNd, nCnt, aTabFrmArr );
 
-        for( auto &rLine : aFndBox.GetLines() )
-            lcl_InsCol( &rLine, aCpyPara, nCnt, bBehind );
+        for (auto & rpLine : aFndBox.GetLines())
+        {
+            lcl_InsCol( rpLine.get(), aCpyPara, nCnt, bBehind );
+        }
 
         // clean up this Line's structure once again, generally all of them
         GCLines();
@@ -571,7 +577,7 @@ bool SwTable::_InsertRow( SwDoc* pDoc, const SwSelBoxes& rBoxes,
     {
         _FndLine* pFndLine;
         while( 1 == pFndBox->GetLines().size() &&
-                1 == ( pFndLine = &pFndBox->GetLines()[ 0 ])->GetBoxes().size() )
+            1 == (pFndLine = pFndBox->GetLines()[0].get())->GetBoxes().size())
         {
             // Don't go down too far! One Line with Box needs to remain!
             _FndBox* pTmpBox = &pFndLine->GetBoxes().front();
@@ -599,7 +605,7 @@ bool SwTable::_InsertRow( SwDoc* pDoc, const SwSelBoxes& rBoxes,
     _CpyPara aCpyPara( pTableNd, 0, aTabFrmArr );
 
     SwTableLine* pLine = pFndBox->GetLines()[ bBehind ?
-                    pFndBox->GetLines().size()-1 : 0 ].GetLine();
+                    pFndBox->GetLines().size()-1 : 0 ]->GetLine();
     if( &aFndBox == pFndBox )
         aCpyPara.nInsPos = GetTabLines().GetPos( pLine );
     else
@@ -620,8 +626,8 @@ bool SwTable::_InsertRow( SwDoc* pDoc, const SwSelBoxes& rBoxes,
     {
         if( bBehind )
             aCpyPara.nDelBorderFlag = 1;
-        for( _FndLine& rFndLine : pFndBox->GetLines() )
-            lcl_CopyRow( rFndLine, &aCpyPara );
+        for (auto & rpFndLine : pFndBox->GetLines())
+            lcl_CopyRow( *rpFndLine, &aCpyPara );
     }
 
     // clean up this Line's structure once again, generally all of them
@@ -1428,10 +1434,10 @@ static void lcl_Merge_MoveBox(_FndBox & rFndBox, _InsULPara *const pULPara)
                 0, pULPara->pInsLine );
         _InsULPara aPara( *pULPara );
         aPara.pInsBox = pBox;
-        for (_FndLines::iterator it = rFndBox.GetLines().begin() + nStt;
+        for (FndLines_t::iterator it = rFndBox.GetLines().begin() + nStt;
              it != rFndBox.GetLines().begin() + nEnd; ++it )
         {
-            lcl_Merge_MoveLine(*it, &aPara );
+            lcl_Merge_MoveLine(**it, &aPara);
         }
         if( pBox->GetTabLines().size() )
         {
@@ -1579,13 +1585,13 @@ bool SwTable::OldMerge( SwDoc* pDoc, const SwSelBoxes& rBoxes,
 
     _FndBox* pFndBox = &aFndBox;
     while( 1 == pFndBox->GetLines().size() &&
-            1 == pFndBox->GetLines().front().GetBoxes().size() )
+            1 == pFndBox->GetLines().front()->GetBoxes().size() )
     {
-        pFndBox = &pFndBox->GetLines().front().GetBoxes().front();
+        pFndBox = &pFndBox->GetLines().front()->GetBoxes().front();
     }
 
     SwTableLine* pInsLine = new SwTableLine(
-                static_cast<SwTableLineFormat*>(pFndBox->GetLines().front().GetLine()->GetFrameFormat()), 0,
+                static_cast<SwTableLineFormat*>(pFndBox->GetLines().front()->GetLine()->GetFrameFormat()), 0,
                 !pFndBox->GetUpper() ? 0 : pFndBox->GetBox() );
     pInsLine->ClaimFrameFormat()->ResetFormatAttr( RES_FRM_SIZE );
 
@@ -1593,7 +1599,7 @@ bool SwTable::OldMerge( SwDoc* pDoc, const SwSelBoxes& rBoxes,
     SwTableLines* pLines =  pFndBox->GetUpper() ?
                   &pFndBox->GetBox()->GetTabLines() :  &GetTabLines();
 
-    SwTableLine* pNewLine = pFndBox->GetLines().front().GetLine();
+    SwTableLine* pNewLine = pFndBox->GetLines().front()->GetLine();
     sal_uInt16 nInsPos = pLines->GetPos( pNewLine );
     pLines->insert( pLines->begin() + nInsPos, pInsLine );
 
@@ -1611,25 +1617,29 @@ bool SwTable::OldMerge( SwDoc* pDoc, const SwSelBoxes& rBoxes,
     _InsULPara aPara( pTableNd, true, true, pLeftBox, pMergeBox, pRightBox, pInsLine );
 
     // Move the overlapping upper/lower Lines of the selected Area
-    for (auto & it : pFndBox->GetLines().front().GetBoxes())
+    for (auto & it : pFndBox->GetLines().front()->GetBoxes())
     {
         lcl_Merge_MoveBox(it, &aPara);
     }
     aPara.SetLower( pInsLine );
     const auto nEnd = pFndBox->GetLines().size()-1;
-    for (auto & it : pFndBox->GetLines()[nEnd].GetBoxes())
+    for (auto & it : pFndBox->GetLines()[nEnd]->GetBoxes())
     {
         lcl_Merge_MoveBox(it, &aPara);
     }
 
     // Move the Boxes extending into the selected Area from left/right
     aPara.SetLeft( pLeftBox );
-    for (_FndLine& rFndLine : pFndBox->GetLines() )
-        lcl_Merge_MoveLine( rFndLine, &aPara );
+    for (auto & rpFndLine : pFndBox->GetLines())
+    {
+        lcl_Merge_MoveLine( *rpFndLine, &aPara );
+    }
 
     aPara.SetRight( pRightBox );
-    for(_FndLine& rFndLine : pFndBox->GetLines() )
-        lcl_Merge_MoveLine( rFndLine, &aPara );
+    for (auto & rpFndLine : pFndBox->GetLines())
+    {
+        lcl_Merge_MoveLine( *rpFndLine, &aPara );
+    }
 
     if( pLeftBox->GetTabLines().empty() )
         _DeleteBox( *this, pLeftBox, 0, false, false );
@@ -1690,8 +1700,10 @@ static sal_uInt16 lcl_GetBoxOffset( const _FndBox& rBox )
 {
     // Find the first Box
     const _FndBox* pFirstBox = &rBox;
-    while( !pFirstBox->GetLines().empty() )
-        pFirstBox = &pFirstBox->GetLines().front().GetBoxes().front();
+    while (!pFirstBox->GetLines().empty())
+    {
+        pFirstBox = &pFirstBox->GetLines().front()->GetBoxes().front();
+    }
 
     sal_uInt16 nRet = 0;
     // Calculate the position relative to above via the Lines
@@ -1720,7 +1732,7 @@ static sal_uInt16 lcl_GetLineWidth( const _FndLine& rLine )
     return nRet;
 }
 
-static void lcl_CalcNewWidths( const _FndLines& rFndLines, _CpyPara& rPara )
+static void lcl_CalcNewWidths(const FndLines_t& rFndLines, _CpyPara& rPara)
 {
     rPara.pWidths.reset();
     const size_t nLineCount = rFndLines.size();
@@ -1733,7 +1745,7 @@ static void lcl_CalcNewWidths( const _FndLines& rFndLines, _CpyPara& rPara )
         for( size_t nLine = 0; nLine < nLineCount; ++nLine )
         {
             std::vector< sal_uLong > &rWidth = (*rPara.pWidths.get())[ nLine ];
-            const _FndLine *pFndLine = &rFndLines[ nLine ];
+            const _FndLine *pFndLine = rFndLines[ nLine ].get();
             if( pFndLine && pFndLine->GetBoxes().size() )
             {
                 const SwTableLine *pLine = pFndLine->GetLine();
@@ -1868,8 +1880,10 @@ static void lcl_CopyBoxToDoc(_FndBox const& rFndBox, _CpyPara *const pCpyPara)
             pCpyPara->pInsLine->GetTabBoxes().insert( pCpyPara->pInsLine->GetTabBoxes().begin() + pCpyPara->nInsPos++, pBox );
             _CpyPara aPara( *pCpyPara, pBox );
             aPara.nNewSize = nSize;     // get the size
-            for(_FndLine const& rFndLine : rFndBox.GetLines())
-                lcl_CopyLineToDoc( rFndLine, &aPara );
+            for (auto const& rpFndLine : rFndBox.GetLines())
+            {
+                lcl_CopyLineToDoc( *rpFndLine, &aPara );
+            }
         }
         else
         {
@@ -2024,8 +2038,10 @@ bool SwTable::CopyHeadlineIntoTable( SwTableNode& rTableNd )
     // Copy
     if( IsNewModel() )
         lcl_CalcNewWidths( aFndBox.GetLines(), aPara );
-    for( _FndLine& rFndLine : aFndBox.GetLines() )
-         lcl_CopyLineToDoc( rFndLine, &aPara );
+    for (auto & rpFndLine : aFndBox.GetLines())
+    {
+         lcl_CopyLineToDoc( *rpFndLine, &aPara );
+    }
     if( rTableNd.GetTable().IsNewModel() )
     {   // The copied line must not contain any row span attributes > 1
         SwTableLine* pLine = rTableNd.GetTable().GetTabLines()[0];
@@ -2116,12 +2132,14 @@ bool SwTable::MakeCopy( SwDoc* pInsDoc, const SwPosition& rPos,
     if( IsNewModel() )
         lcl_CalcNewWidths( aFndBox.GetLines(), aPara );
     // Copy
-    for( _FndLine& rFndLine : aFndBox.GetLines() )
-         lcl_CopyLineToDoc( rFndLine, &aPara );
+    for (auto & rpFndLine : aFndBox.GetLines())
+    {
+         lcl_CopyLineToDoc( *rpFndLine, &aPara );
+    }
 
     // Set the "right" margin above/below
     {
-        _FndLine* pFndLn = &aFndBox.GetLines().front();
+        _FndLine* pFndLn = aFndBox.GetLines().front().get();
         SwTableLine* pLn = pFndLn->GetLine();
         const SwTableLine* pTmp = pLn;
         sal_uInt16 nLnPos = GetTabLines().GetPos( pTmp );
@@ -2146,7 +2164,7 @@ bool SwTable::MakeCopy( SwDoc* pInsDoc, const SwPosition& rPos,
             }
         }
 
-        pFndLn = &aFndBox.GetLines().back();
+        pFndLn = aFndBox.GetLines().back().get();
         pLn = pFndLn->GetLine();
         pTmp = pLn;
         nLnPos = GetTabLines().GetPos( pTmp );
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 70b5636..3635c4a 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1858,15 +1858,15 @@ bool SwDoc::DeleteRow( const SwCursor& rCursor )
 
         _FndBox* pFndBox = &aFndBox;
         while( 1 == pFndBox->GetLines().size() &&
-                1 == pFndBox->GetLines().front().GetBoxes().size() )
+                1 == pFndBox->GetLines().front()->GetBoxes().size() )
         {
-            _FndBox *const pTmp = & pFndBox->GetLines().front().GetBoxes()[0];
+            _FndBox *const pTmp = & pFndBox->GetLines().front()->GetBoxes()[0];
             if( pTmp->GetBox()->GetSttNd() )
                 break; // Else it gets too far
             pFndBox = pTmp;
         }
 
-        SwTableLine* pDelLine = pFndBox->GetLines().back().GetLine();
+        SwTableLine* pDelLine = pFndBox->GetLines().back()->GetLine();
         SwTableBox* pDelBox = pDelLine->GetTabBoxes().back();
         while( !pDelBox->GetSttNd() )
         {
@@ -1882,7 +1882,7 @@ bool SwDoc::DeleteRow( const SwCursor& rCursor )
 
         if( !pNextBox ) // No succeeding Boxes? Then take the preceding one
         {
-            pDelLine = pFndBox->GetLines().front().GetLine();
+            pDelLine = pFndBox->GetLines().front()->GetLine();
             pDelBox = pDelLine->GetTabBoxes()[ 0 ];
             while( !pDelBox->GetSttNd() )
                 pDelBox = pDelBox->GetTabLines()[0]->GetTabBoxes()[0];
@@ -3712,8 +3712,10 @@ static bool lcl_SetAFormatBox( _FndBox & rBox, _SetAFormatTabPara *pSetPara )
     }
     else
     {
-        for( _FndLine& rFndLine : rBox.GetLines() )
-            lcl_SetAFormatLine( rFndLine, pSetPara );
+        for (auto const& rpFndLine : rBox.GetLines())
+        {
+            lcl_SetAFormatLine( *rpFndLine, pSetPara );
+        }
     }
 
     if (!rBox.GetUpper()->GetUpper()) // a BaseLine
@@ -3745,9 +3747,9 @@ bool SwDoc::SetTableAutoFormat( const SwSelBoxes& rBoxes, const SwTableAutoForma
 
     _FndBox* pFndBox = &aFndBox;
     while( 1 == pFndBox->GetLines().size() &&
-            1 == pFndBox->GetLines().front().GetBoxes().size() )
+            1 == pFndBox->GetLines().front()->GetBoxes().size())
     {
-        pFndBox = &pFndBox->GetLines().front().GetBoxes()[0];
+        pFndBox = &pFndBox->GetLines().front()->GetBoxes()[0];
     }
 
     if( pFndBox->GetLines().empty() ) // One too far? (only one sel. Box)
@@ -3766,11 +3768,11 @@ bool SwDoc::SetTableAutoFormat( const SwSelBoxes& rBoxes, const SwTableAutoForma
     rNew.RestoreTableProperties(table);
 
     _SetAFormatTabPara aPara( rNew );
-    _FndLines& rFLns = pFndBox->GetLines();
+    FndLines_t& rFLns = pFndBox->GetLines();
 
-    for( _FndLines::size_type n = 0; n < rFLns.size(); ++n )
+    for (FndLines_t::size_type n = 0; n < rFLns.size(); ++n)
     {
-        _FndLine* pLine = &rFLns[n];
+        _FndLine* pLine = rFLns[n].get();
 
         // Set Upper to 0 (thus simulate BaseLine)
         _FndBox* pSaveBox = pLine->GetUpper();
@@ -3832,15 +3834,15 @@ bool SwDoc::GetTableAutoFormat( const SwSelBoxes& rBoxes, SwTableAutoFormat& rGe
 
     _FndBox* pFndBox = &aFndBox;
     while( 1 == pFndBox->GetLines().size() &&
-            1 == pFndBox->GetLines().front().GetBoxes().size() )
+            1 == pFndBox->GetLines().front()->GetBoxes().size())
     {
-        pFndBox = &pFndBox->GetLines().front().GetBoxes()[0];
+        pFndBox = &pFndBox->GetLines().front()->GetBoxes()[0];
     }
 
     if( pFndBox->GetLines().empty() ) // One too far? (only one sel. Box)
         pFndBox = pFndBox->GetUpper()->GetUpper();
 
-    _FndLines& rFLns = pFndBox->GetLines();
+    FndLines_t& rFLns = pFndBox->GetLines();
 
     sal_uInt16 aLnArr[4];
     aLnArr[0] = 0;
@@ -3850,7 +3852,7 @@ bool SwDoc::GetTableAutoFormat( const SwSelBoxes& rBoxes, SwTableAutoFormat& rGe
 
     for( sal_uInt8 nLine = 0; nLine < 4; ++nLine )
     {
-        _FndLine& rLine = rFLns[ aLnArr[ nLine ] ];
+        _FndLine& rLine = *rFLns[ aLnArr[ nLine ] ];
 
         sal_uInt16 aBoxArr[4];
         aBoxArr[0] = 0;
diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx
index 578cd50..51d5fa7 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -179,8 +179,10 @@ bool _FindBox( _FndBox & rBox, LinesAndTable* pPara )
     if (!rBox.GetLines().empty())
     {
         pPara->m_bInsertLines = true;
-        for (_FndLine & rFndLine : rBox.GetLines())
-            _FindLine(rFndLine, pPara);
+        for (auto const& rpFndLine : rBox.GetLines())
+        {
+            _FindLine(*rpFndLine, pPara);
+        }
 
         if (pPara->m_bInsertLines)
         {
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index 2c92b8e..3a2bea9 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -374,15 +374,15 @@ bool SwFEShell::DeleteRow(bool bCompleteTable)
 
             _FndBox* pFndBox = &aFndBox;
             while( 1 == pFndBox->GetLines().size() &&
-                    1 == pFndBox->GetLines().front().GetBoxes().size() )
+                    1 == pFndBox->GetLines().front()->GetBoxes().size())
             {
-                _FndBox* pTmp = &pFndBox->GetLines().front().GetBoxes()[0];
+                _FndBox* pTmp = &pFndBox->GetLines().front()->GetBoxes()[0];
                 if( pTmp->GetBox()->GetSttNd() )
                     break;      // otherwise too far
                 pFndBox = pTmp;
             }
 
-            SwTableLine* pDelLine = pFndBox->GetLines().back().GetLine();
+            SwTableLine* pDelLine = pFndBox->GetLines().back()->GetLine();
             SwTableBox* pDelBox = pDelLine->GetTabBoxes().back();
             while( !pDelBox->GetSttNd() )
             {
@@ -397,7 +397,7 @@ bool SwFEShell::DeleteRow(bool bCompleteTable)
 
             if( !pNextBox )         // no next? then the previous
             {
-                pDelLine = pFndBox->GetLines().front().GetLine();
+                pDelLine = pFndBox->GetLines().front()->GetLine();
                 pDelBox = pDelLine->GetTabBoxes()[ 0 ];
                 while( !pDelBox->GetSttNd() )
                     pDelBox = pDelBox->GetTabLines()[0]->GetTabBoxes()[0];
diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx
index 16ff319..a2aab4a 100644
--- a/sw/source/core/frmedt/tblsel.cxx
+++ b/sw/source/core/frmedt/tblsel.cxx
@@ -1410,8 +1410,10 @@ static bool lcl_CheckCol( _FndBox const& rFndBox, bool* pPara )
         }
         else
         {
-            for( _FndLine const& rFndLine : rFndBox.GetLines() )
-                lcl_CheckRow( rFndLine, pPara );
+            for (auto const& rpFndLine : rFndBox.GetLines())
+            {
+                lcl_CheckRow( *rpFndLine, pPara );
+            }
         }
     }
     // is box protected ??
@@ -1456,7 +1458,7 @@ sal_uInt16 CheckMergeSel( const SwSelBoxes& rBoxes )
             _FndLine* pFndLine = 0;
             while( pFndBox && 1 == pFndBox->GetLines().size() )
             {
-                pFndLine = &pFndBox->GetLines().front();
+                pFndLine = pFndBox->GetLines().front().get();
                 if( 1 == pFndLine->GetBoxes().size() )
                     pFndBox = &pFndLine->GetBoxes().front();
                 else
@@ -1464,8 +1466,7 @@ sal_uInt16 CheckMergeSel( const SwSelBoxes& rBoxes )
             }
             if( pFndBox )
             {
-                for (_FndLines::const_iterator it = pFndBox->GetLines().begin(),
-                        end = pFndBox->GetLines().end(); it != end; ++it)
+                for (auto const& it : pFndBox->GetLines())
                 {
                     lcl_CheckRow(*it, &bMergeSelOk);
                 }
@@ -2061,17 +2062,15 @@ static void _FndBoxCopyCol( SwTableBox* pBox, _FndPara* pFndPara )
 
 static void _FndLineCopyCol( SwTableLine* pLine, _FndPara* pFndPara )
 {
-    _FndLine* pFndLine = new _FndLine( pLine, pFndPara->pFndBox );
-    _FndPara aPara( *pFndPara, pFndLine );
+    std::unique_ptr<_FndLine> pFndLine(new _FndLine(pLine, pFndPara->pFndBox));
+    _FndPara aPara(*pFndPara, pFndLine.get());
     for( SwTableBoxes::iterator it = pFndLine->GetLine()->GetTabBoxes().begin();
              it != pFndLine->GetLine()->GetTabBoxes().end(); ++it)
         _FndBoxCopyCol(*it, &aPara );
     if( pFndLine->GetBoxes().size() )
     {
-        pFndPara->pFndBox->GetLines().push_back( pFndLine );
+        pFndPara->pFndBox->GetLines().push_back( std::move(pFndLine) );
     }
-    else
-        delete pFndLine;
 }
 
 void ForEach_FndLineCopyCol(SwTableLines& rLines, _FndPara* pFndPara )
@@ -2124,13 +2123,13 @@ void _FndBox::SetTableLines( const SwTable &rTable )
     if( GetLines().empty() )
         return;
 
-    SwTableLine* pTmpLine = GetLines().front().GetLine();
+    SwTableLine* pTmpLine = GetLines().front()->GetLine();
     sal_uInt16 nPos = rTable.GetTabLines().GetPos( pTmpLine );
     OSL_ENSURE( USHRT_MAX != nPos, "Line steht nicht in der Tabelle" );
     if( nPos )
         pLineBefore = rTable.GetTabLines()[ nPos - 1 ];
 
-    pTmpLine = GetLines().back().GetLine();
+    pTmpLine = GetLines().back()->GetLine();
     nPos = rTable.GetTabLines().GetPos( pTmpLine );
     OSL_ENSURE( USHRT_MAX != nPos, "Line steht nicht in der Tabelle" );
     if( ++nPos < rTable.GetTabLines().size() )
diff --git a/sw/source/ui/misc/srtdlg.cxx b/sw/source/ui/misc/srtdlg.cxx
index d86b6bf..a6c7ef7 100644
--- a/sw/source/ui/misc/srtdlg.cxx
+++ b/sw/source/ui/misc/srtdlg.cxx
@@ -101,7 +101,7 @@ static bool lcl_GetSelTable( SwWrtShell &rSh, sal_uInt16& rX, sal_uInt16& rY )
     if( !rX )
         return false;
 
-    rY = aFndBox.GetLines().front().GetBoxes().size();
+    rY = aFndBox.GetLines().front()->GetBoxes().size();
     return true;
 }
 
commit 8bf0e60d1da6d1ab79455dc916fd8701122812d2
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Sep 4 21:53:34 2015 +0200

    sw: erroneous vector assignment in SwTable::OldMerge()
    
    +    rLineBoxes = pFndBox->GetLines()[nEnd]->GetBoxes();
    
    This actually assigns the boxes vector of the last line to the first
    line, which the previous code didn't do.
    
    Notably after converting the types from boost::ptr_vector to
    std::vector<std::unique_ptr>, the assignment produces a several page
    error message from both GCC and clang, and infuriatingly neither
    compiler was able to tell on which line in tblrwcl.cxx the template
    was instantiated, so i had to bisect that.
    
    (regression from be5e4247e2a164bd1f2eacf9a33d6d73df16d0e3)
    
    Change-Id: I646e3ca678895480d38ec48f38d720458860a985

diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index ec0070f..520df3f 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -1611,17 +1611,15 @@ bool SwTable::OldMerge( SwDoc* pDoc, const SwSelBoxes& rBoxes,
     _InsULPara aPara( pTableNd, true, true, pLeftBox, pMergeBox, pRightBox, pInsLine );
 
     // Move the overlapping upper/lower Lines of the selected Area
-    _FndBoxes& rLineBoxes = pFndBox->GetLines().front().GetBoxes();
-    for (_FndBoxes::iterator it = rLineBoxes.begin(); it != rLineBoxes.end(); ++it)
+    for (auto & it : pFndBox->GetLines().front().GetBoxes())
     {
-        lcl_Merge_MoveBox(*it, &aPara);
+        lcl_Merge_MoveBox(it, &aPara);
     }
     aPara.SetLower( pInsLine );
     const auto nEnd = pFndBox->GetLines().size()-1;
-    rLineBoxes = pFndBox->GetLines()[nEnd].GetBoxes();
-    for (_FndBoxes::iterator it = rLineBoxes.begin(); it != rLineBoxes.end(); ++it)
+    for (auto & it : pFndBox->GetLines()[nEnd].GetBoxes())
     {
-        lcl_Merge_MoveBox(*it, &aPara);
+        lcl_Merge_MoveBox(it, &aPara);
     }
 
     // Move the Boxes extending into the selected Area from left/right


More information about the Libreoffice-commits mailing list