Commits

Anonymous committed 8803ef1

swbookmarkfixes01: added mock objects

  • Participants
  • Parent commits 5d17f44

Comments (0)

Files changed (4)

File sw/qa/core/inc/mock/LayoutAccessMockBase.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 ILAYOUTACCESSMOCKBASE_HXX_INCLUDED
+#define ILAYOUTACCESSMOCKBASE_HXX_INCLUDED
+
+#include <IDocumentLayoutAccess.hxx>
+
+namespace sw { namespace mock {
+
+class LayoutAccessMockBase : public IDocumentLayoutAccess
+{
+    public:
+        LayoutAccessMockBase() {};
+        virtual const SwRootFrm* GetRootFrm() const { return NULL; };
+        virtual SwRootFrm* GetRootFrm() { return NULL; };
+        virtual void SetRootFrm(SwRootFrm*) {};
+        virtual SwFrmFmt* MakeLayoutFmt(RndStdIds, const SfxItemSet*) { return NULL; };
+        virtual SwLayouter* GetLayouter() { return NULL; };
+        virtual const SwLayouter* GetLayouter() const { return NULL; };
+        virtual void SetLayouter(SwLayouter*) {};
+        virtual void DelLayoutFmt(SwFrmFmt*) {};
+        virtual SwFrmFmt* CopyLayoutFmt(const SwFrmFmt&, const SwFmtAnchor&, bool, bool) { return NULL; };
+};
+
+}}
+#endif

File sw/qa/core/inc/mock/UndoRedoMockBase.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 UNDOREDOMOCKBASE_HXX_INCLUDED
+#define UNDOREDOMOCKBASE_HXX_INCLUDED
+
+#include <IDocumentUndoRedo.hxx>
+
+
+namespace sw { namespace mock {
+
+class UndoRedoMockBase : public IDocumentUndoRedo
+{
+    public:
+        UndoRedoMockBase() {};
+        virtual void SetUndoNoResetModified() {};
+        virtual bool IsUndoNoResetModified() const {return false; };
+        virtual void DoUndo(bool) {};
+        virtual bool DoesUndo() const { return false; };
+        virtual void DoGroupUndo(bool) {};
+        virtual bool DoesGroupUndo() const { return false; };
+        virtual bool Undo(SwUndoIter&) { return false; };
+        virtual SwUndoId StartUndo( SwUndoId, const SwRewriter*) { return SwUndoId(); };
+        virtual SwUndoId EndUndo(SwUndoId, const SwRewriter* ) { return SwUndoId(); };
+        virtual void DelAllUndoObj() {};
+        virtual SwUndoId GetUndoIds(String*, SwUndoIds*) const { return SwUndoId(); };
+        virtual String GetUndoIdsStr(String*, SwUndoIds*) const { return String(); };
+        virtual bool HasUndoId(SwUndoId) const { return false; };
+        virtual const SwNodes* GetUndoNds() const { return NULL; };
+        virtual SwUndo* RemoveLastUndo(SwUndoId) { return NULL; };
+        virtual bool HasTooManyUndos() const { return false; };
+        virtual bool Redo(SwUndoIter&) { return false; };
+        virtual SwUndoId GetRedoIds(String*, SwUndoIds*) const { return SwUndoId(); };
+        virtual String GetRedoIdsStr(String*, SwUndoIds*) const { return String(); };
+        virtual bool Repeat(SwUndoIter&, sal_uInt16) { return false; };
+        virtual SwUndoId GetRepeatIds(String*, SwUndoIds*) const { return SwUndoId(); };
+        virtual String GetRepeatIdsStr(String*, SwUndoIds*) const { return String(); };
+        virtual void AppendUndo(SwUndo*) {};
+        virtual void ClearRedo() {};
+        virtual void setUndoNoModifiedPosition( SwUndoNoModifiedPosition ) {};
+        virtual SwUndoNoModifiedPosition getUndoNoModifiedPosition() const { return SwUndoNoModifiedPosition(); };
+        virtual void SetModified() {};
+};
+
+}}
+#endif
+

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

         m_pUndoRedo->AppendUndo(new SwUndoPageDescCreate(pNew.get(), m_pDoc)); // #116530#
 
     m_pUndoRedo->SetModified();
-    return (m_vPageDescs.end()-1)->get();
+    if(!m_pDefaultPageDesc)
+        m_pDefaultPageDesc = pNew;
+    return pNew.get();
 }
 
 namespace
 void PageDescManager::DelPageDesc(container_t::iterator ppPageDesc, bool bBroadcast)
 {
     SwPageDesc* pPageDesc = ppPageDesc->get();
-    OSL_ENSURE(ppPageDesc != m_vPageDescs.begin(), "Default Pagedesc should never be deleted." );
-    if(ppPageDesc == m_vPageDescs.begin())
+    if(*ppPageDesc == m_pDefaultPageDesc)
+    {
+        OSL_ENSURE(false, "<PageDescManager::DelPageDesc(..)"
+            " - Default Pagedesc should never be deleted." );
         return;
+    }
 
     if (bBroadcast) // #116530#
         m_pDoc->BroadcastStyleOperation((pPageDesc)->GetName(),

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

 		{ return m_vPageDescs.size(); };
 	    virtual SwPageDesc* GetDefaultPageDesc()
 		{
-            OSL_ENSURE(m_vPageDescs.size() > 0, "<PageDescManager:GetDefaultPageDesc(..)>"
+            OSL_ENSURE(m_pDefaultPageDesc.get(), "<PageDescManager:GetDefaultPageDesc(..)>"
                 " - no default page description available.");
-            return m_vPageDescs[0].get();
+            return m_pDefaultPageDesc.get();
         }
 	    virtual const SwPageDesc* GetDefaultPageDesc() const
 		{ return const_cast<PageDescManager*>(this)->GetDefaultPageDesc(); }
 
 	private:
 	    typedef ::std::vector< ::boost::shared_ptr< SwPageDesc > > container_t;
+	    container_t m_vPageDescs;
+        ::boost::shared_ptr< SwPageDesc > m_pDefaultPageDesc;
 	    SwDoc* const m_pDoc;
         IDocumentLayoutAccess* const m_pLayoutAccess;
         IDocumentUndoRedo* const m_pUndoRedo;
-	    container_t m_vPageDescs;
 
         // class is final
 	    PageDescManager(SwDoc* io_pDoc, IDocumentLayoutAccess* io_pLayoutAccess,IDocumentUndoRedo* io_pUndoRedo) : m_pDoc(io_pDoc), m_pLayoutAccess(io_pLayoutAccess), m_pUndoRedo(io_pUndoRedo) {};