Anonymous avatar Anonymous committed 5a07b2e

swbookmarkfixes01: removed layout from PageDescManager in test

Comments (0)

Files changed (7)

sw/inc/IDocumentPageDescAccess.hxx

                 return f;
             }
 
-            // Broadcast and Listener 
-            virtual bool AddListener( SfxListener& rListener ) =0;
-            virtual bool RemoveListener( SfxListener& rListener ) =0;
-
             virtual ~IDocumentPageDescAccess() {};
         private:
             virtual void ForEach_Impl(foreach_functor_type f) =0;
 
     //---------------- private Member --------------------------------
 
-	// -------------------------------------------------------------------
+    // broadcasters (created first, destructed last)
+    const ::boost::scoped_ptr< SfxBroadcaster > m_pStyleOperationBroadcaster;
+    const ::boost::scoped_ptr< SfxBroadcaster > m_pModelEventBroadcaster;
 	// die Objecte
 	SwNodes		aNodes;   	  	  	  	// Inhalt des Dokumentes
 	SwNodes 	aUndoNodes; 			// Inhalt fuer das Undo
     const ::boost::scoped_ptr< ::sw::mark::MarkManager > m_pMarkManager;
     const ::boost::scoped_ptr< ::sw::MetaFieldManager > m_pMetaFieldManager;
     const ::boost::scoped_ptr< ::sw::pagedesc::PageDescManager > m_pPageDescManager;
-    const ::boost::scoped_ptr< SfxBroadcaster > m_pStyleOperationBroadcaster;
 
 	// -------------------------------------------------------------------
 	// die Pointer
     //fuer Reader
     virtual void ChgPageDesc(SwPageDesc* pDesc, const SwPageDesc&);
 
-    // this should be moved into an apporpriate interface for style access
     SfxBroadcaster* getStyleOperationBroadcaster()
         { return m_pStyleOperationBroadcaster.get(); }
+    SfxBroadcaster* getModelEventBroadcaster()
+        { return m_pModelEventBroadcaster.get(); }
 
 		// Methoden fuer die Verzeichnisse:
 		// - Verzeichnismarke einfuegen loeschen travel

sw/qa/core/PageDescManager/PageDescManagerTest.cxx

 #include <editeng/frmdir.hxx>
 #include <set>
 
-
-#define _CALBCK_HXX
-class SwModify;
-class SwClient
-{
-    protected:
-        SwModify* pRegisteredIn;
-    public:
-        SwClient(SwModify*);
-        const SwModify* GetRegisteredIn() const { return pRegisteredIn; }
-};
-class SwModify : public SwClient {};
-class SwDepend : public SwClient {};
-class SwClientIter
-{
-    public:
-        SwClientIter(SwModify&);
-        SwClient* First(TypeId);
-        SwClient* Next();
-};
-
 #define _SWATRSET_HXX
 #include <svl/itemset.hxx>
 #include <svl/itempool.hxx>
 class SwPageDescExt : public SwPageDesc {};
 
 #include <mock/FormatAccessMockBase.hxx>
-#include <mock/LayoutAccessMockBase.hxx>
 #include <mock/UndoRedoMockBase.hxx>
 namespace
 {
         private:
             void Setup();
             void AddPageDesc(const String& rName);
-            scoped_ptr<IDocumentPageDescAccess> m_pPageDescAccess;
-            scoped_ptr<IDocumentLayoutAccess> m_pLayoutAccess;
             scoped_ptr<UndoRedoMock> m_pUndoRedo;
             scoped_ptr<FormatAccessMockBase> m_pFormatAccess;
             scoped_ptr<SwAttrPool> m_pPool;
+            scoped_ptr<SfxBroadcaster> m_pStyleOperationBroadcaster;
+            scoped_ptr<SfxBroadcaster> m_pModelEventBroadcaster;
+            scoped_ptr<IDocumentPageDescAccess> m_pPageDescAccess;
             static const String our_sName;
             static const String our_sOtherName;
             static const String our_sThirdName;
 
 void PageDescManagerTest::Setup()
 {
-    m_pLayoutAccess.reset(new LayoutAccessMockBase());
     m_pUndoRedo.reset(new UndoRedoMock());
     m_pFormatAccess.reset(new FormatAccessMockBase());
     m_pPool.reset(new SwAttrPool());
-    m_pPageDescAccess.reset(PageDescManager::Create(m_pLayoutAccess.get(), m_pUndoRedo.get(), m_pFormatAccess.get(),  m_pPool.get()));
+    m_pStyleOperationBroadcaster.reset(new SfxBroadcaster());
+    m_pModelEventBroadcaster.reset(new SfxBroadcaster());
+    m_pPageDescAccess.reset(PageDescManager::Create(
+        m_pUndoRedo.get(),
+        m_pFormatAccess.get(),
+        m_pPool.get(),
+        m_pStyleOperationBroadcaster.get(),
+        m_pModelEventBroadcaster.get()));
     CPPUNIT_ASSERT(m_pPageDescAccess.get()!=NULL);
 }
 

sw/source/core/doc/PageDescManager.cxx

 using ::boost::shared_ptr;
 using ::boost::scoped_ptr;
 
-PageDescManager::PageDescManager(IDocumentUndoRedo* io_pUndoRedo, IDocumentFormatAccess* io_pFormatAccess, SwAttrPool* io_pAttrPool)
+PageDescManager::PageDescManager(IDocumentUndoRedo* io_pUndoRedo, IDocumentFormatAccess* io_pFormatAccess, SwAttrPool* io_pAttrPool, SfxBroadcaster* io_pStyleOperationBroadcaster, SfxBroadcaster* io_pModelEventBroadcaster)
     : m_pUndoRedo(io_pUndoRedo)
     , m_pFormatAccess(io_pFormatAccess)
     , m_pAttrPool(io_pAttrPool)
-    , m_pBroadcaster(new SfxBroadcaster())
+    , m_pStyleOperationBroadcaster(io_pStyleOperationBroadcaster)
+    , m_pModelEventBroadcaster(io_pModelEventBroadcaster)
 {}
 
 // The HTML import cannot resist changing the page descriptions, I don't
     m_vPageDescs.push_back(pNew);
 
     if(bBroadcast)
-        m_pBroadcaster->Broadcast(::sw::style::StyleOperationHint(rName, SFX_STYLE_FAMILY_PAGE, SFX_STYLESHEET_CREATED));
+        m_pStyleOperationBroadcaster->Broadcast(::sw::style::StyleOperationHint(rName, SFX_STYLE_FAMILY_PAGE, SFX_STYLESHEET_CREATED));
 
     if(m_pUndoRedo->DoesUndo())
     {
     }
 
     if (bBroadcast)
-        m_pBroadcaster->Broadcast(::sw::style::StyleOperationHint(pPageDesc->GetName(), SFX_STYLE_FAMILY_PAGE, SFX_STYLESHEET_ERASED));
+        m_pStyleOperationBroadcaster->Broadcast(::sw::style::StyleOperationHint(pPageDesc->GetName(), SFX_STYLE_FAMILY_PAGE, SFX_STYLESHEET_ERASED));
 
     if (m_pUndoRedo->DoesUndo())
         m_pUndoRedo->AppendUndo(new SwUndoPageDescDelete(*pPageDesc, m_pUndoRedo));
 
     pPageDesc->Dispose();
-    ForEach(lcl_PageDescFollowClearer(pPageDesc, m_pBroadcaster.get()));
-    m_pBroadcaster->Broadcast(PageDescDisposingHint(pPageDesc));
+    ForEach(lcl_PageDescFollowClearer(pPageDesc, m_pModelEventBroadcaster));
+    m_pModelEventBroadcaster->Broadcast(PageDescDisposingHint(pPageDesc));
     m_vPageDescs.erase(ppPageDesc);
 
     m_pUndoRedo->SetModified();
 {
     ::std::for_each(m_vPageDescs.begin(), m_vPageDescs.end(), lcl_SharedPtrUnwrapper(f)).m_aFunctor;
 }
-
-bool PageDescManager::AddListener( SfxListener& rListener )
-    { return rListener.StartListening(*m_pBroadcaster); };
-
-bool PageDescManager::RemoveListener( SfxListener& rListener )
-    { return rListener.EndListening(*m_pBroadcaster); };

sw/source/core/doc/PageDescManager.hxx

     , public ::sw::pagedesc::IDocumentPageDescAccess
     {
     public:
-        static PageDescManager* Create(IDocumentUndoRedo* io_pUndoRedo, ::sw::format::IDocumentFormatAccess* io_pFormatAccess, SwAttrPool* io_pPool)
-            { return new PageDescManager(io_pUndoRedo, io_pFormatAccess, io_pPool); };
+        static PageDescManager* Create(IDocumentUndoRedo* io_pUndoRedo, ::sw::format::IDocumentFormatAccess* io_pFormatAccess, SwAttrPool* io_pPool, SfxBroadcaster* io_pStyleOperationBroadcaster, SfxBroadcaster* io_pModelEventBroadcaster)
+            { return new PageDescManager(io_pUndoRedo, io_pFormatAccess, io_pPool, io_pStyleOperationBroadcaster, io_pModelEventBroadcaster); };
         virtual difference_type GetPageDescCnt() const
         { return m_vPageDescs.size(); };
         virtual SwPageDesc* GetDefaultPageDesc()
         virtual void DelPageDesc(const String& rName, bool bBroadcast=false);
         virtual void DelAllPageDescs(bool bBroadcast);
         virtual void CheckDefaultPageFmt();
-        virtual bool AddListener(SfxListener&);
-        virtual bool RemoveListener(SfxListener&);
         // dispose removes all pagedescs including the default pagedesc
         // it is only to be called by the document upon destruction
         void Dispose();
 
     private:
         typedef ::std::vector< ::boost::shared_ptr< SwPageDesc > > container_t;
-        container_t m_vPageDescs;
-        ::boost::shared_ptr< SwPageDesc > m_pDefaultPageDesc;
         IDocumentUndoRedo* const m_pUndoRedo;
         ::sw::format::IDocumentFormatAccess* const m_pFormatAccess;
         SwAttrPool* m_pAttrPool;
-        const ::boost::scoped_ptr<SfxBroadcaster> m_pBroadcaster;
+	SfxBroadcaster* const m_pStyleOperationBroadcaster;
+	SfxBroadcaster* const m_pModelEventBroadcaster;
+        container_t m_vPageDescs;
+        ::boost::shared_ptr< SwPageDesc > m_pDefaultPageDesc;
 
         // class is final
-        PageDescManager(IDocumentUndoRedo* io_pUndoRedo, ::sw::format::IDocumentFormatAccess* io_pFormatAccess, SwAttrPool* io_pPool);
+        PageDescManager(IDocumentUndoRedo* io_pUndoRedo, ::sw::format::IDocumentFormatAccess* io_pFormatAccess, SwAttrPool* io_pPool, SfxBroadcaster* io_pStyleOperationBroadcaster, SfxBroadcaster* io_pModelEventBroadcaster);
 
         void CopyPageDescHeaderFooter(bool bCpyHeader, const SwFrmFmt& rSrcFmt, SwFrmFmt& rDestFmt);
         void DelPageDesc(container_t::iterator ppPageDesc, bool bBroadcast=false);

sw/source/core/doc/docnew.cxx

  */
 
 SwDoc::SwDoc() :
+    m_pStyleOperationBroadcaster(new SfxBroadcaster()),
+    m_pModelEventBroadcaster(new SfxBroadcaster()),
 	aNodes( this ),
 	aUndoNodes( this ),
 	mpAttrPool(new SwAttrPool(this)),
     m_pMarkManager(new ::sw::mark::MarkManager(*this)),
     m_pMetaFieldManager(new ::sw::MetaFieldManager()),
-    m_pPageDescManager(::sw::pagedesc::PageDescManager::Create(getIDocumentUndoRedo(), getIDocumentFormatAccess(), &GetAttrPool())),
-    m_pStyleOperationBroadcaster(new SfxBroadcaster()),
+    m_pPageDescManager(::sw::pagedesc::PageDescManager::Create(getIDocumentUndoRedo(), getIDocumentFormatAccess(), &GetAttrPool(), getStyleOperationBroadcaster(), getModelEventBroadcaster())),
 	pDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ),
 	pEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, pDfltFrmFmt ) ),
 	pColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, pDfltFrmFmt ) ),

sw/source/core/layout/newfrm.cxx

 	IDocumentLayoutAccess *pLayoutAccess = pFmt->getIDocumentLayoutAccess();
 	IDocumentFieldsAccess *pFieldsAccess = pFmt->getIDocumentFieldsAccess();
 	const IDocumentSettingAccess *pSettingAccess = pFmt->getIDocumentSettingAccess();
-    pFmt->GetDoc()->getIDocumentPageDescAccess()->AddListener(*m_pModelListener);
+    m_pModelListener->StartListening(*pFmt->GetDoc()->getModelEventBroadcaster());
 	pTimerAccess->StopIdling();
 	pLayoutAccess->SetRootFrm( this );		//Fuer das Erzeugen der Flys durch MakeFrms()
 	bCallbackActionEnabled = FALSE;	//vor Verlassen auf TRUE setzen!
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.