[Libreoffice-commits] core.git: 4 commits - sw/source

Michael Stahl mstahl at redhat.com
Fri Apr 29 22:24:20 UTC 2016


 sw/source/core/inc/rolbck.hxx     |   20 ------
 sw/source/core/txtnode/ndtxt.cxx  |    3 
 sw/source/core/txtnode/thints.cxx |    1 
 sw/source/core/undo/rolbck.cxx    |  117 +++++++-------------------------------
 sw/source/core/undo/unattr.cxx    |   16 -----
 sw/source/ui/fldui/flddb.cxx      |    8 +-
 sw/source/ui/fldui/flddb.hxx      |    2 
 sw/source/ui/fldui/flddinf.cxx    |   12 ++-
 sw/source/ui/fldui/flddinf.hxx    |    2 
 sw/source/ui/fldui/flddok.cxx     |    8 +-
 sw/source/ui/fldui/flddok.hxx     |    2 
 sw/source/ui/fldui/fldfunc.cxx    |    8 +-
 sw/source/ui/fldui/fldfunc.hxx    |    2 
 sw/source/ui/fldui/fldpage.cxx    |    5 -
 sw/source/ui/fldui/fldpage.hxx    |    2 
 sw/source/ui/fldui/fldref.cxx     |    8 +-
 sw/source/ui/fldui/fldref.hxx     |    2 
 sw/source/ui/fldui/fldtdlg.cxx    |    4 -
 sw/source/ui/fldui/fldvar.cxx     |   10 +--
 sw/source/ui/fldui/fldvar.hxx     |    2 
 20 files changed, 66 insertions(+), 168 deletions(-)

New commits:
commit 17f4fc71164a1440e6805221fee19fae322129b9
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sat Apr 30 00:19:13 2016 +0200

    sw: SwHistoryResetAttrSet now unused, remove it
    
    Change-Id: I6b87b82cb359298e768dd4eb90a788cafe6b8b1c

diff --git a/sw/source/core/inc/rolbck.hxx b/sw/source/core/inc/rolbck.hxx
index 7f660c1..a756779 100644
--- a/sw/source/core/inc/rolbck.hxx
+++ b/sw/source/core/inc/rolbck.hxx
@@ -70,7 +70,6 @@ enum HISTORY_HINT {
     HSTRY_FLYCNT,
     HSTRY_BOOKMARK,
     HSTRY_SETATTRSET,
-    HSTRY_RESETATTRSET,
     HSTRY_CHGFLYANCHOR,
     HSTRY_CHGFLYCHAIN,
     HSTRY_CHGCHARFMT,
@@ -276,25 +275,6 @@ public:
 
 };
 
-class SwHistoryResetAttrSet : public SwHistoryHint
-{
-    const sal_uLong m_nNodeIndex;
-    const sal_Int32 m_nStart;
-    const sal_Int32 m_nEnd;
-    std::vector<sal_uInt16> m_Array;
-
-public:
-    SwHistoryResetAttrSet( const SfxItemSet& rSet, sal_uLong nNode,
-                        sal_Int32 nStt,
-                        sal_Int32 nEnd);
-    virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override;
-
-    const std::vector<sal_uInt16>& GetArr() const { return m_Array; }
-    sal_uLong GetNode() const               { return m_nNodeIndex; }
-    sal_Int32 GetContent() const         { return m_nStart; }
-
-};
-
 class SwHistoryChangeFlyAnchor : public SwHistoryHint
 {
     SwFrameFormat & m_rFormat;
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index 4b62d49..a8ea84e 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -773,90 +773,6 @@ void SwHistorySetAttrSet::SetInDoc( SwDoc* pDoc, bool )
     }
 }
 
-SwHistoryResetAttrSet::SwHistoryResetAttrSet( const SfxItemSet& rSet,
-                    sal_uLong nNodePos, sal_Int32 nAttrStt, sal_Int32 nAttrEnd )
-    : SwHistoryHint( HSTRY_RESETATTRSET )
-    , m_nNodeIndex( nNodePos ), m_nStart( nAttrStt ), m_nEnd( nAttrEnd )
-    , m_Array( (sal_uInt8)rSet.Count() )
-{
-    SfxItemIter aIter( rSet );
-    bool bAutoStyle = false;
-
-    while( true )
-    {
-        const sal_uInt16 nWhich = aIter.GetCurItem()->Which();
-
-#ifdef DBG_UTIL
-        switch (nWhich)
-        {
-            case RES_TXTATR_REFMARK:
-            case RES_TXTATR_TOXMARK:
-                if (m_nStart != m_nEnd) break; // else: fall through!
-            case RES_TXTATR_FIELD:
-            case RES_TXTATR_ANNOTATION:
-            case RES_TXTATR_FLYCNT:
-            case RES_TXTATR_FTN:
-            case RES_TXTATR_META:
-            case RES_TXTATR_METAFIELD:
-                OSL_ENSURE(rSet.Count() == 1,
-                    "text attribute with CH_TXTATR, but not the only one:"
-                    "\nnot such a good idea");
-                break;
-        }
-#endif // DBG_UTIL
-
-        // Character attribute cannot be inserted into the hints array
-        // anymore. Therefore we have to treat them as one RES_TXTATR_AUTOFMT:
-        if (isCHRATR(nWhich))
-        {
-            bAutoStyle = true;
-        }
-        else
-        {
-            m_Array.push_back( aIter.GetCurItem()->Which() );
-        }
-
-        if( aIter.IsAtEnd() )
-            break;
-
-        aIter.NextItem();
-    }
-
-    if ( bAutoStyle )
-    {
-        m_Array.push_back( RES_TXTATR_AUTOFMT );
-    }
-}
-
-void SwHistoryResetAttrSet::SetInDoc( SwDoc* pDoc, bool )
-{
-    ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
-
-    SwContentNode * pContentNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetContentNode();
-    OSL_ENSURE( pContentNd, "SwHistoryResetAttrSet: no ContentNode" );
-
-    if (pContentNd)
-    {
-        std::vector<sal_uInt16>::iterator it;
-        if ( USHRT_MAX == m_nEnd && USHRT_MAX == m_nStart )
-        {
-            // no area: use ContentNode
-            for ( it = m_Array.begin(); it != m_Array.end(); ++it )
-            {
-                pContentNd->ResetAttr( *it );
-            }
-        }
-        else
-        {
-            // area: use TextNode
-            for ( it = m_Array.begin(); it != m_Array.end(); ++it )
-            {
-                pContentNd->GetTextNode()-> DeleteAttributes( *it, m_nStart, m_nEnd );
-            }
-        }
-    }
-}
-
 SwHistoryChangeFlyAnchor::SwHistoryChangeFlyAnchor( SwFrameFormat& rFormat )
     : SwHistoryHint( HSTRY_CHGFLYANCHOR )
     , m_rFormat( rFormat )
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index adb31b0..52c5a11 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -816,22 +816,6 @@ void SwUndoAttr::RemoveIdx( SwDoc& rDoc )
         }
         break;
 
-        case HSTRY_RESETATTRSET: {
-            SwHistoryResetAttrSet * pHistoryHint
-                = static_cast<SwHistoryResetAttrSet*>(pHstHint);
-            nContent = pHistoryHint->GetContent();
-            if ( COMPLETE_STRING != nContent ) {
-                const std::vector<sal_uInt16>& rArr = pHistoryHint->GetArr();
-                for ( size_t i = rArr.size(); i; ) {
-                    if ( RES_TXTATR_FTN == rArr[ --i ] ) {
-                        nNode = pHistoryHint->GetNode();
-                        break;
-                    }
-                }
-            }
-        }
-        break;
-
         default:
             break;
         }
commit b44e70e3d17c79eaf78f9bfe8bd0275d7ed9325f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Apr 29 13:56:51 2016 +0200

    tdf#98512: sw: remove duplicate undo history add
    
    Follow-up to commit ed81bf39dd3431d28860fed6a2d4e8814126cc61.
    
    In almost all cases SetAttr() and InsertHint() will already add
    the history hint themselves, so this code in SwRegHistory::InsertItems()
    looks somewhat pointless as it inserts a duplicate.
    
    It turns out it's needed for hints that insert dummy characters, because
    firstly for the hints-without-end the NoteInHistory() was not called, and
    secondly when InsertText() inserts the dummy character it may actually
    delete the hints array if there are no pre-existing hints, and a new
    hints array will be created where the SwRegHistory isn't registered.
    
    It's not obvious how the hints array actually can become empty in
    SwTextNode::InsertText().
    
    Let's fix that and assert instead that the history hint was inserted.
    
    Change-Id: If8e0ff1fe28a162f144149a536a7566f94219c0d

diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 07e6027..ecc1d37 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -2004,7 +2004,8 @@ OUString SwTextNode::InsertText( const OUString & rStr, const SwIndex & rIdx,
         {
             m_pSwpHints->MergePortions(*this);
         }
-        TryDeleteSwpHints();
+        SAL_WARN_IF(m_pSwpHints->CanBeDeleted(), "sw.core",
+                "SwTextNode::InsertText: unexpected loss of hints");
     }
 
     if ( HasWriterListeners() )
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 6b5abd8..d6cc66e 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -3173,6 +3173,7 @@ bool SwpHints::TryInsertHint(
     if( !pHtEnd )
     {
         Insert( pHint );
+        NoteInHistory(pHint, true);
         CalcFlags();
 #ifdef DBG_UTIL
         if( !rNode.GetDoc()->IsInReading() )
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index 5c9e684..4b62d49 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -1375,9 +1375,9 @@ bool SwRegHistory::InsertItems( const SfxItemSet& rSet,
     if (!pTextNode)
         return false;
 
-    if ( pTextNode->GetpSwpHints() && m_pHistory )
+    if (m_pHistory)
     {
-        pTextNode->GetpSwpHints()->Register( this );
+        pTextNode->GetOrCreateSwpHints().Register(this);
     }
 
     const bool bInserted = pTextNode->SetAttr( rSet, nStart, nEnd, nFlags );
@@ -1392,16 +1392,29 @@ bool SwRegHistory::InsertItems( const SfxItemSet& rSet,
         pTextNode->GetpSwpHints()->DeRegister();
     }
 
-    // if (m_pHistory->Count()) return true, then it shouldn't to be pushed into
-    // the m_pHistory->m_SwpHstry again, or Undo Action will do the same thing twice
-    if ( m_pHistory && bInserted && !m_pHistory->Count() )
+#ifndef NDEBUG
+    if ( m_pHistory && bInserted )
     {
-        SwHistoryHint* pNewHstr = new SwHistoryResetAttrSet( rSet,
-                                    pTextNode->GetIndex(), nStart, nEnd );
-        // the NodeIndex might be moved!
-
-        m_pHistory->m_SwpHstry.push_back( pNewHstr );
+        SfxItemIter aIter(rSet);
+        for (SfxPoolItem const* pItem = aIter.FirstItem(); pItem; pItem = aIter.NextItem())
+        {   // check that the history recorded a hint to reset every item
+            sal_uInt16 const nWhich(pItem->Which());
+            RES_TXTATR const nExpected(
+                (isCHRATR(nWhich) || RES_TXTATR_UNKNOWN_CONTAINER == nWhich)
+                    ? RES_TXTATR_AUTOFMT
+                    : static_cast<RES_TXTATR>(nWhich));
+            if (RES_TXTATR_AUTOFMT == nExpected && 0 == nStart && pTextNode->Len() == nEnd)
+                continue; // special case, may get set on text node itself
+            assert(std::find_if(
+                m_pHistory->m_SwpHstry.begin(), m_pHistory->m_SwpHstry.end(),
+                [nExpected](SwHistoryHint *const pHint) -> bool {
+                    SwHistoryResetText const*const pReset(
+                            dynamic_cast<SwHistoryResetText const*>(pHint));
+                    return (pReset) ? pReset->GetWhich() == nExpected : false;
+                }) != m_pHistory->m_SwpHstry.end());
+        }
     }
+#endif
 
     return bInserted;
 }
commit 6d81c777232f3abeb3b05f89ad37f266d65eabbb
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Apr 29 16:48:45 2016 +0200

    sw: SwFieldVarPage: disable "Insert" button on "Input field"...
    
    ... if no variable name is selected.  It doesn't work in this case.
    
    Change-Id: I36745806bcfc688b54b1ec49d0376b05bb5bbea6

diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx
index 1c518ba..3d16272 100644
--- a/sw/source/ui/fldui/fldvar.cxx
+++ b/sw/source/ui/fldui/fldvar.cxx
@@ -937,7 +937,7 @@ IMPL_LINK_NOARG_TYPED(SwFieldVarPage, ModifyHdl, Edit&, void)
                 bInsert = false;
         }
 
-        if( !nLen && ( nTypeId == TYP_SETFLD ||
+        if (!nLen && (nTypeId == TYP_SETFLD || nTypeId == TYP_INPUTFLD ||
                         (!IsFieldEdit() && nTypeId == TYP_GETFLD ) ) )
             bInsert = false;
 
commit bf47fef3a87d8546f18a36ade4e85f7c6ecf993b
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Apr 29 16:36:25 2016 +0200

    sw: try to survive restoring a field dialog without SfxObjectShell
    
    The SFX will apparently restore the field dialog on startup if it was
    open on the last shutdown.  Since i don't know how to disable this
    useless "feature", let's fudge things a bit so we don't crash
    immediately.
    
    Change-Id: I2c401440374d055774fdc8fcbd79a1262c42da0b

diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx
index 445177b..d296333 100644
--- a/sw/source/ui/fldui/flddb.cxx
+++ b/sw/source/ui/fldui/flddb.cxx
@@ -33,9 +33,9 @@
 #define USER_DATA_VERSION_1     "1"
 #define USER_DATA_VERSION USER_DATA_VERSION_1
 
-SwFieldDBPage::SwFieldDBPage(vcl::Window* pParent, const SfxItemSet& rCoreSet)
+SwFieldDBPage::SwFieldDBPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet)
     : SwFieldPage(pParent, "FieldDbPage",
-        "modules/swriter/ui/flddbpage.ui", rCoreSet)
+        "modules/swriter/ui/flddbpage.ui", pCoreSet)
     , m_nOldFormat(0)
     , m_nOldSubType(0)
 {
@@ -265,9 +265,9 @@ bool SwFieldDBPage::FillItemSet(SfxItemSet* )
 }
 
 VclPtr<SfxTabPage> SwFieldDBPage::Create( vcl::Window* pParent,
-                                        const SfxItemSet* rAttrSet )
+                                        const SfxItemSet *const pAttrSet )
 {
-    return VclPtr<SwFieldDBPage>::Create( pParent, *rAttrSet );
+    return VclPtr<SwFieldDBPage>::Create( pParent, pAttrSet );
 }
 
 sal_uInt16 SwFieldDBPage::GetGroup()
diff --git a/sw/source/ui/fldui/flddb.hxx b/sw/source/ui/fldui/flddb.hxx
index 6fcf77e..dc63561 100644
--- a/sw/source/ui/fldui/flddb.hxx
+++ b/sw/source/ui/fldui/flddb.hxx
@@ -69,7 +69,7 @@ protected:
     virtual sal_uInt16      GetGroup() override;
 
 public:
-                        SwFieldDBPage(vcl::Window* pParent, const SfxItemSet& rSet);
+                        SwFieldDBPage(vcl::Window* pParent, const SfxItemSet* rSet);
 
                         virtual ~SwFieldDBPage();
     virtual void        dispose() override;
diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx
index 710d539..a270ce6 100644
--- a/sw/source/ui/fldui/flddinf.cxx
+++ b/sw/source/ui/fldui/flddinf.cxx
@@ -47,9 +47,9 @@
 using namespace nsSwDocInfoSubType;
 using namespace com::sun::star;
 
-SwFieldDokInfPage::SwFieldDokInfPage(vcl::Window* pParent, const SfxItemSet& rCoreSet)
+SwFieldDokInfPage::SwFieldDokInfPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet)
     :  SwFieldPage(pParent, "FieldDocInfoPage",
-        "modules/swriter/ui/flddocinfopage.ui", rCoreSet)
+        "modules/swriter/ui/flddocinfopage.ui", pCoreSet)
     , pSelEntry(nullptr)
     , nOldSel(0)
     , nOldFormat(0)
@@ -82,7 +82,9 @@ SwFieldDokInfPage::SwFieldDokInfPage(vcl::Window* pParent, const SfxItemSet& rCo
     //enable 'active' language selection
     m_pFormatLB->SetShowLanguageControl(true);
 
-    const SfxUnoAnyItem* pItem = rCoreSet.GetItem<SfxUnoAnyItem>(SID_DOCINFO, false);
+    const SfxUnoAnyItem* pItem = (pCoreSet)
+        ? pCoreSet->GetItem<SfxUnoAnyItem>(SID_DOCINFO, false)
+        : nullptr;
     if ( pItem )
         pItem->GetValue() >>= xCustomPropertySet;
 }
@@ -459,9 +461,9 @@ bool SwFieldDokInfPage::FillItemSet(SfxItemSet* )
 }
 
 VclPtr<SfxTabPage> SwFieldDokInfPage::Create( vcl::Window* pParent,
-                                            const SfxItemSet* rAttrSet )
+                                            const SfxItemSet *const pAttrSet)
 {
-    return VclPtr<SwFieldDokInfPage>::Create( pParent, *rAttrSet );
+    return VclPtr<SwFieldDokInfPage>::Create( pParent, pAttrSet );
 }
 
 sal_uInt16 SwFieldDokInfPage::GetGroup()
diff --git a/sw/source/ui/fldui/flddinf.hxx b/sw/source/ui/fldui/flddinf.hxx
index a15fcbc..f90394c 100644
--- a/sw/source/ui/fldui/flddinf.hxx
+++ b/sw/source/ui/fldui/flddinf.hxx
@@ -59,7 +59,7 @@ protected:
     virtual sal_uInt16      GetGroup() override;
 
 public:
-                        SwFieldDokInfPage(vcl::Window* pWindow, const SfxItemSet& rSet);
+                        SwFieldDokInfPage(vcl::Window* pWindow, const SfxItemSet* pSet);
 
                         virtual ~SwFieldDokInfPage();
     virtual void        dispose() override;
diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx
index 2916ebe..294e01c 100644
--- a/sw/source/ui/fldui/flddok.cxx
+++ b/sw/source/ui/fldui/flddok.cxx
@@ -34,9 +34,9 @@
 #define USER_DATA_VERSION_1 "1"
 #define USER_DATA_VERSION USER_DATA_VERSION_1
 
-SwFieldDokPage::SwFieldDokPage(vcl::Window* pParent, const SfxItemSet& rCoreSet )
+SwFieldDokPage::SwFieldDokPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet)
     : SwFieldPage(pParent, "FieldDocumentPage",
-        "modules/swriter/ui/flddocumentpage.ui", rCoreSet)
+        "modules/swriter/ui/flddocumentpage.ui", pCoreSet)
     , nOldSel(0)
     , nOldFormat(0)
 {
@@ -648,9 +648,9 @@ bool SwFieldDokPage::FillItemSet(SfxItemSet* )
 }
 
 VclPtr<SfxTabPage> SwFieldDokPage::Create( vcl::Window* pParent,
-                                         const SfxItemSet* rAttrSet )
+                                         const SfxItemSet *const pAttrSet)
 {
-    return VclPtr<SwFieldDokPage>::Create( pParent, *rAttrSet );
+    return VclPtr<SwFieldDokPage>::Create( pParent, pAttrSet );
 }
 
 sal_uInt16 SwFieldDokPage::GetGroup()
diff --git a/sw/source/ui/fldui/flddok.hxx b/sw/source/ui/fldui/flddok.hxx
index d103b8f..1c3245c 100644
--- a/sw/source/ui/fldui/flddok.hxx
+++ b/sw/source/ui/fldui/flddok.hxx
@@ -61,7 +61,7 @@ protected:
     virtual sal_uInt16      GetGroup() override;
 
 public:
-                        SwFieldDokPage(vcl::Window* pWindow, const SfxItemSet& rSet);
+                        SwFieldDokPage(vcl::Window* pWindow, const SfxItemSet * pSet);
 
                         virtual ~SwFieldDokPage();
     virtual void        dispose() override;
diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx
index 50df8c0..e2828bf 100644
--- a/sw/source/ui/fldui/fldfunc.cxx
+++ b/sw/source/ui/fldui/fldfunc.cxx
@@ -37,9 +37,9 @@
 
 using namespace ::com::sun::star;
 
-SwFieldFuncPage::SwFieldFuncPage(vcl::Window* pParent, const SfxItemSet& rCoreSet)
+SwFieldFuncPage::SwFieldFuncPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet)
     : SwFieldPage(pParent, "FieldFuncPage",
-        "modules/swriter/ui/fldfuncpage.ui", rCoreSet)
+        "modules/swriter/ui/fldfuncpage.ui", pCoreSet)
     , nOldFormat(0)
     , bDropDownLBChanged(false)
 {
@@ -630,9 +630,9 @@ OUString SwFieldFuncPage::TurnMacroString(const OUString &rMacro)
 }
 
 VclPtr<SfxTabPage> SwFieldFuncPage::Create( vcl::Window* pParent,
-                                          const SfxItemSet* rAttrSet )
+                                          const SfxItemSet *const pAttrSet)
 {
-    return VclPtr<SwFieldFuncPage>::Create( pParent, *rAttrSet );
+    return VclPtr<SwFieldFuncPage>::Create( pParent, pAttrSet );
 }
 
 sal_uInt16 SwFieldFuncPage::GetGroup()
diff --git a/sw/source/ui/fldui/fldfunc.hxx b/sw/source/ui/fldui/fldfunc.hxx
index 7effcb4..8615879 100644
--- a/sw/source/ui/fldui/fldfunc.hxx
+++ b/sw/source/ui/fldui/fldfunc.hxx
@@ -86,7 +86,7 @@ protected:
     virtual sal_uInt16      GetGroup() override;
 
 public:
-                        SwFieldFuncPage(vcl::Window* pParent, const SfxItemSet& rSet);
+                        SwFieldFuncPage(vcl::Window* pParent, const SfxItemSet* pSet);
 
                         virtual ~SwFieldFuncPage();
     virtual void        dispose() override;
diff --git a/sw/source/ui/fldui/fldpage.cxx b/sw/source/ui/fldui/fldpage.cxx
index 964feb7..d408493 100644
--- a/sw/source/ui/fldui/fldpage.cxx
+++ b/sw/source/ui/fldui/fldpage.cxx
@@ -41,9 +41,10 @@
 
 using namespace ::com::sun::star;
 
+// note: pAttrSet may be null if the dialog is restored on startup
 SwFieldPage::SwFieldPage(vcl::Window *pParent, const OString& rID,
-    const OUString& rUIXMLDescription, const SfxItemSet &rAttrSet)
-    : SfxTabPage(pParent, rID, rUIXMLDescription, &rAttrSet)
+    const OUString& rUIXMLDescription, const SfxItemSet *const pAttrSet)
+    : SfxTabPage(pParent, rID, rUIXMLDescription, pAttrSet)
     , m_pCurField(nullptr)
     , m_pWrtShell(nullptr)
     , m_nTypeSel(LISTBOX_ENTRY_NOTFOUND)
diff --git a/sw/source/ui/fldui/fldpage.hxx b/sw/source/ui/fldui/fldpage.hxx
index 1aaaa87..d97dc32 100644
--- a/sw/source/ui/fldui/fldpage.hxx
+++ b/sw/source/ui/fldui/fldpage.hxx
@@ -78,7 +78,7 @@ protected:
 
 public:
     SwFieldPage(vcl::Window *pParent, const OString& rID,
-        const OUString& rUIXMLDescription, const SfxItemSet &rAttrSet);
+        const OUString& rUIXMLDescription, const SfxItemSet *pAttrSet);
 
     virtual ~SwFieldPage();
 
diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx
index 670c50e..ae872e6 100644
--- a/sw/source/ui/fldui/fldref.cxx
+++ b/sw/source/ui/fldui/fldref.cxx
@@ -49,9 +49,9 @@ static sal_uInt16 nFieldDlgFormatSel = 0;
 #define USER_DATA_VERSION_1 "1"
 #define USER_DATA_VERSION USER_DATA_VERSION_1
 
-SwFieldRefPage::SwFieldRefPage(vcl::Window* pParent, const SfxItemSet& rCoreSet )
+SwFieldRefPage::SwFieldRefPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet )
     : SwFieldPage(pParent, "FieldRefPage",
-        "modules/swriter/ui/fldrefpage.ui", rCoreSet)
+        "modules/swriter/ui/fldrefpage.ui", pCoreSet)
     , maOutlineNodes()
     , maNumItems()
     , mpSavedSelectedTextNode(nullptr)
@@ -1029,9 +1029,9 @@ bool SwFieldRefPage::FillItemSet(SfxItemSet* )
 }
 
 VclPtr<SfxTabPage> SwFieldRefPage::Create( vcl::Window* pParent,
-                                         const SfxItemSet* rAttrSet )
+                                         const SfxItemSet *const pAttrSet)
 {
-    return VclPtr<SwFieldRefPage>::Create( pParent, *rAttrSet );
+    return VclPtr<SwFieldRefPage>::Create( pParent, pAttrSet );
 }
 
 sal_uInt16 SwFieldRefPage::GetGroup()
diff --git a/sw/source/ui/fldui/fldref.hxx b/sw/source/ui/fldui/fldref.hxx
index b881c43..bf2c76d 100644
--- a/sw/source/ui/fldui/fldref.hxx
+++ b/sw/source/ui/fldui/fldref.hxx
@@ -82,7 +82,7 @@ protected:
     virtual sal_uInt16      GetGroup() override;
 
 public:
-                        SwFieldRefPage(vcl::Window* pParent, const SfxItemSet& rSet);
+                        SwFieldRefPage(vcl::Window* pParent, const SfxItemSet* pSet);
 
                         virtual ~SwFieldRefPage();
     virtual void        dispose() override;
diff --git a/sw/source/ui/fldui/fldtdlg.cxx b/sw/source/ui/fldui/fldtdlg.cxx
index abb00aa..72cfc89 100644
--- a/sw/source/ui/fldui/fldtdlg.cxx
+++ b/sw/source/ui/fldui/fldtdlg.cxx
@@ -159,9 +159,9 @@ void SwFieldDlg::Initialize(SfxChildWinInfo *pInfo)
 
 SfxItemSet* SwFieldDlg::CreateInputItemSet( sal_uInt16 nID  )
 {
-    if ( nID == m_nDokInf )
+    SwDocShell *const pDocSh(static_cast<SwDocShell*>(SfxObjectShell::Current()));
+    if (nID == m_nDokInf && pDocSh) // might not have a shell if the dialog is restored on startup
     {
-        SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current());
         SfxItemSet* pISet = new SfxItemSet( pDocSh->GetPool(), SID_DOCINFO, SID_DOCINFO );
         using namespace ::com::sun::star;
         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx
index 5e38e3e..1c518ba 100644
--- a/sw/source/ui/fldui/fldvar.cxx
+++ b/sw/source/ui/fldui/fldvar.cxx
@@ -39,9 +39,9 @@
 #define USER_DATA_VERSION_1 "1"
 #define USER_DATA_VERSION USER_DATA_VERSION_1
 
-SwFieldVarPage::SwFieldVarPage(vcl::Window* pParent, const SfxItemSet& rCoreSet )
+SwFieldVarPage::SwFieldVarPage(vcl::Window* pParent, const SfxItemSet *const pCoreSet )
     : SwFieldPage(pParent, "FieldVarPage",
-        "modules/swriter/ui/fldvarpage.ui", rCoreSet)
+        "modules/swriter/ui/fldvarpage.ui", pCoreSet)
     , nOldFormat(0)
     , bInit(true)
 {
@@ -1240,9 +1240,9 @@ bool SwFieldVarPage::FillItemSet(SfxItemSet* )
 }
 
 VclPtr<SfxTabPage> SwFieldVarPage::Create( vcl::Window* pParent,
-                                         const SfxItemSet* rAttrSet )
+                                         const SfxItemSet *const pAttrSet)
 {
-    return VclPtr<SwFieldVarPage>::Create( pParent, *rAttrSet );
+    return VclPtr<SwFieldVarPage>::Create( pParent, pAttrSet );
 }
 
 sal_uInt16 SwFieldVarPage::GetGroup()
diff --git a/sw/source/ui/fldui/fldvar.hxx b/sw/source/ui/fldui/fldvar.hxx
index 7b7a6ff..f4c4022 100644
--- a/sw/source/ui/fldui/fldvar.hxx
+++ b/sw/source/ui/fldui/fldvar.hxx
@@ -91,7 +91,7 @@ protected:
     virtual sal_uInt16      GetGroup() override;
 
 public:
-                        SwFieldVarPage(vcl::Window* pParent, const SfxItemSet& rSet);
+                        SwFieldVarPage(vcl::Window* pParent, const SfxItemSet* pSet);
 
                         virtual ~SwFieldVarPage();
     virtual void        dispose() override;


More information about the Libreoffice-commits mailing list