Commits

Bjoern Michaelsen  committed 9208d70

swbookmarkfixes01: towards making the writer layout is a listener of the model

  • Participants
  • Parent commits 0f76c22

Comments (0)

Files changed (8)

File sw/inc/CheckPageDescHint.hxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _CHECKPAGEDESCHINT_HXX
+#define _CHECKPAGEDESCHINT_HXX
+
+#include <svl/hint.hxx>
+
+namespace sw { namespace pagedesc {
+
+class CheckPageDescHint : public SfxHint {};
+
+}}
+#endif

File sw/inc/PageDescDisposingHint.hxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _PAGEDESCDISPOSINGHINT_HXX
+#define _PAGEDESCDISPOSINGHINT_HXX
+
+#include <svl/hint.hxx>
+
+namespace sw { namespace pagedesc {
+
+class PageDescDisposingHint : public SfxHint
+{
+    public:
+        PageDescDisposingHint(const SwPageDesc* const pPageDesc) : m_pPageDesc(pPageDesc) {};
+        const SwPageDesc* GetPageDesc() const { return m_pPageDesc; };
+    private:
+        const SwPageDesc* const m_pPageDesc;
+};
+
+}}
+#endif

File sw/inc/frmfmt.hxx

 #ifndef _FRMFMT_HXX
 #define _FRMFMT_HXX
 
-// --> OD 2004-08-06 #i28749#
 #include <com/sun/star/text/PositionLayoutDir.hpp>
-// <--
-
 #include <cppuhelper/weakref.hxx>
-
 #include <format.hxx>
+#include <tools/mempool.hxx>
 
 #include "swdllapi.h"
 

File sw/qa/core/PageDescManager/PageDescManagerTest.cxx

 };
 
 
-#define _PAGEFRM_HXX
-#include <frame.hxx>
-class SwPageFrm : public SwFrm
-{
-    public:
-        bool IsFtnPage() const
-            { return true; };
-};
+//#define _PAGEFRM_HXX
+//#include <frame.hxx>
+//class SwPageFrm : public SwFrm
+//{
+//    public:
+//        bool IsFtnPage() const
+//            { return true; };
+//};
 
-#define _FRMFMT_HXX
-class SwFrmFmt : public SwModify
-{
-    public:
-        bool SetFmtAttr(const SfxPoolItem&) { return true; } ;
-        bool HasFootnotePageListener() const { return true; };
-        void DelFrms() {};
-};
+//#define _FRMFMT_HXX
+//class SwFrmFmt : public SwModify
+//{
+//   public:
+//        bool SetFmtAttr(const SfxPoolItem&) { return true; } ;
+//        bool HasFootnotePageListener() const { return true; };
+//        void DelFrms() {};
+//};
 
 #define _PAGEDESC_HXX
+#include <frmfmt.hxx>
 class SwDoc;
 class SwPageDesc
 {
 
 #include <source/core/doc/PageDescManager.cxx>
 
-void SwFrm::CheckPageDescs(SwPageFrm*, unsigned char)
-{}
+//void SwFrm::CheckPageDescs(SwPageFrm*, unsigned char)
+//{}
 
-void SwRootFrm::RemoveFtns(SwPageFrm*, unsigned char, unsigned char)
-{}
+//void SwRootFrm::RemoveFtns(SwPageFrm*, unsigned char, unsigned char)
+//{}
 
 
 using namespace ::boost;

File sw/source/core/doc/PageDescManager.cxx

 #include <rootfrm.hxx>	//Fuer DelPageDesc
 #include <svl/brdcst.hxx>
 #include <StyleOperationHint.hxx>
+#include <PageDescDisposingHint.hxx>
+#include <CheckPageDescHint.hxx>
 #include <swatrset.hxx>
 
 using namespace ::com::sun::star;
 {
     struct lcl_PageDescFollowClearer
     {
-        lcl_PageDescFollowClearer(const SwPageDesc* pPageDescToClear, SwRootFrm* pRootFrm)
+        lcl_PageDescFollowClearer(const SwPageDesc* pPageDescToClear, SfxBroadcaster* pBroadcaster)
             : m_pPageDescToClear(pPageDescToClear)
-            , m_pRootFrm(pRootFrm)
+            , m_pBroadcaster(pBroadcaster)
         { };
         const SwPageDesc* m_pPageDescToClear;
-        SwRootFrm* m_pRootFrm;
+        SfxBroadcaster* m_pBroadcaster;
         void operator()(SwPageDesc* pPageDesc)
         {
 		    if(pPageDesc->GetFollow() == m_pPageDescToClear)
             {
                 pPageDesc->SetFollow(NULL);
-                // notify layout
-                if(m_pRootFrm)
-                    m_pRootFrm->CheckPageDescs(static_cast<SwPageFrm*>(m_pRootFrm->Lower()));
+                m_pBroadcaster->Broadcast(::sw::pagedesc::CheckPageDescHint());
             }
         };
     };
         m_pUndoRedo->AppendUndo(new SwUndoPageDescDelete(*pPageDesc, m_pUndoRedo));
 
     pPageDesc->Dispose();
-    ForEach(lcl_PageDescFollowClearer(pPageDesc, m_pLayoutAccess->GetRootFrm()));
-
-	if(m_pLayoutAccess->GetRootFrm())
-	{
-        // pages pointing to master and left FrmFmts (f.e. Footnote pages)
-		// will be destroyed.
-        // when finding endnote pages, all footnotes will be discarded
-        // to guarantee the sequence of the pages 
-        if(pPageDesc->GetMaster().HasFootnotePageListener() || pPageDesc->GetLeft().HasFootnotePageListener())
-            m_pLayoutAccess->GetRootFrm()->RemoveFtns(0, false, true);
-        pPageDesc->GetMaster().DelFrms();
-        pPageDesc->GetLeft().DelFrms();
-	}
+    ForEach(lcl_PageDescFollowClearer(pPageDesc, m_pBroadcaster.get()));
+    m_pBroadcaster->Broadcast(PageDescDisposingHint(pPageDesc));
     m_vPageDescs.erase(ppPageDesc);
 
     m_pUndoRedo->SetModified();

File sw/source/core/inc/rootfrm.hxx

 #ifndef _ROOTFRM_HXX
 #define _ROOTFRM_HXX
 #include "layfrm.hxx"
+#include <boost/scoped_ptr.hpp>
 
 class SwCntntFrm;
 class ViewShell;
 
 #include <vector>
 
+namespace sw { namespace layout
+{
+    class ModelListener;
+}}
+
 class SwRootFrm: public SwLayoutFrm
 {
 	//Muss das Superfluous temporaer abschalten.
 
 	USHORT	nPhyPageNums;			//Anzahl der Seiten.
     sal_uInt16 nAccessibleShells;   // Number of accessible shells
+    const ::boost::scoped_ptr< ::sw::layout::ModelListener > m_pModelListener;
 
 	void ImplCalcBrowseWidth();
 	void ImplInvalidateBrowseWidth();

File sw/source/core/layout/newfrm.cxx

 #include "IDocumentDrawModelAccess.hxx"
 #include <hints.hxx>
 #include <viewopt.hxx>
+#include <svl/lstner.hxx>
+#include <CheckPageDescHint.hxx>
+#include <PageDescDisposingHint.hxx>
+#include <pagedesc.hxx>
+#include <pagefrm.hxx>
+
+namespace sw { namespace layout {
+
+class ModelListener : public SfxListener
+{
+    public:
+        ModelListener(SwRootFrm* pRootFrm) : m_pRootFrm(pRootFrm) {};
+        virtual void Notify(SfxBroadcaster&, const SfxHint& rHint)
+        {
+            const ::sw::pagedesc::PageDescDisposingHint* pPageDescDisposingHint;
+            if(dynamic_cast< const ::sw::pagedesc::CheckPageDescHint* >(&rHint))
+            {
+                m_pRootFrm->CheckPageDescs(static_cast<SwPageFrm*>(m_pRootFrm->Lower()));
+            }
+            else if( (pPageDescDisposingHint = dynamic_cast< const ::sw::pagedesc::PageDescDisposingHint* >(&rHint)) )
+            {
+                SwPageDesc* const pPageDesc = const_cast<SwPageDesc*>(pPageDescDisposingHint->GetPageDesc());
+                if(pPageDesc->GetMaster().HasFootnotePageListener() || pPageDesc->GetLeft().HasFootnotePageListener())
+                    m_pRootFrm->RemoveFtns(0, false, true);
+                pPageDesc->GetMaster().DelFrms();
+                pPageDesc->GetLeft().DelFrms();
+            }
+        }
+    private:
+        SwRootFrm* m_pRootFrm;
+};
+
+}}
 
 SwLayVout     *SwRootFrm::pVout = 0;
 BOOL 		   SwRootFrm::bInPaint = FALSE;
     pDrawPage( 0 ),
     pDestroy( 0 ),
 	nPhyPageNums( 0 ),
-    nAccessibleShells( 0 )
+    nAccessibleShells( 0 ),
+    m_pModelListener(new ::sw::layout::ModelListener(this))
 {
     nType = FRMC_ROOT;
 	bIdleFormat = bTurboAllowed = bAssertFlyPages = bIsNewLayout = TRUE;
 	IDocumentLayoutAccess *pLayoutAccess = pFmt->getIDocumentLayoutAccess();
 	IDocumentFieldsAccess *pFieldsAccess = pFmt->getIDocumentFieldsAccess();
 	const IDocumentSettingAccess *pSettingAccess = pFmt->getIDocumentSettingAccess();
+    pFmt->GetDoc()->getIDocumentPageDescAccess()->AddListener(*m_pModelListener);
 	pTimerAccess->StopIdling();
 	pLayoutAccess->SetRootFrm( this );		//Fuer das Erzeugen der Flys durch MakeFrms()
 	bCallbackActionEnabled = FALSE;	//vor Verlassen auf TRUE setzen!

File sw/source/ui/app/docshini.cxx

 	// wir als BroadCaster werden auch unser eigener Listener
 	// (fuer DocInfo/FileNamen/....)
 	StartListening( *this );
-	pDoc->getIDocumentPageDescAccess()->AddListener( *this );
     //position of the "Automatic" style filter for the stylist (app.src)
     SetAutoStyleFilterIndex(3);