[Libreoffice-commits] .: starmath/inc starmath/qa starmath/source

Caolán McNamara caolan at kemper.freedesktop.org
Mon Nov 29 08:15:24 PST 2010


 starmath/inc/view.hxx                 |    2 -
 starmath/qa/cppunit/makefile.mk       |    2 +
 starmath/qa/cppunit/test_starmath.cxx |   66 +++++++++++++++++++++++++++++++---
 starmath/source/cursor.cxx            |    1 
 starmath/source/document.cxx          |    1 
 starmath/source/edit.cxx              |    1 
 starmath/source/view.cxx              |    9 ++--
 7 files changed, 71 insertions(+), 11 deletions(-)

New commits:
commit f2062bc6b45cdf88172e44c5b17009325338f3b4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Nov 29 15:59:10 2010 +0000

    equivalent tmEditMarker cppunit test

diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx
index e5899ce..10e9626 100644
--- a/starmath/inc/view.hxx
+++ b/starmath/inc/view.hxx
@@ -39,7 +39,6 @@
 #include <svtools/colorcfg.hxx>
 #include "edit.hxx"
 #include "node.hxx"
-#include "accessibility.hxx"
 
 class Menu;
 class DataChangedEvent;
@@ -47,6 +46,7 @@ class SmClipboardChangeListener;
 class SmDocShell;
 class SmViewShell;
 class SmPrintUIOptions;
+class SmGraphicAccessible;
 
 /**************************************************************************/
 
diff --git a/starmath/qa/cppunit/makefile.mk b/starmath/qa/cppunit/makefile.mk
index ceab4ff..0433b20 100644
--- a/starmath/qa/cppunit/makefile.mk
+++ b/starmath/qa/cppunit/makefile.mk
@@ -112,6 +112,8 @@ $(MISC)/$(TARGET)/services.rdb .ERRREMOVE : $(MISC)/$(TARGET)/udkapi.rdb
     $(MKDIRHIER) $(@:d)
     $(REGCOMP) -register -br $(MISC)/$(TARGET)/udkapi.rdb -r $@ -wop \
         -c $(DLLPRE)fwk$(DLLPOSTFIX)$(DLLPOST) \
+        -c $(DLLPRE)tk$(DLLPOSTFIX)$(DLLPOST) \
+        -c $(DLLPRE)sfx$(DLLPOSTFIX)$(DLLPOST) \
         -c i18npool.uno$(DLLPOST)
 
 #Tweak things so that we use the .res files in the solver
diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx
index aa2698e..9dbba0d 100644
--- a/starmath/qa/cppunit/test_starmath.cxx
+++ b/starmath/qa/cppunit/test_starmath.cxx
@@ -7,13 +7,17 @@
 
 #include <cppuhelper/bootstrap.hxx>
 #include <comphelper/processfactory.hxx>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
 
 #include <vcl/svapp.hxx>
 #include <smdll.hxx>
 #include <document.hxx>
+#include <view.hxx>
 
 #include <sfx2/bindings.hxx>
 #include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
 
 #include <svl/stritem.hxx>
 
@@ -45,21 +49,23 @@ public:
     void createDocument();
     void tmEditUndoRedo(SmDocShellRef &rDocShRef);
     void tmEditFailure(SmDocShellRef &rDocShRef);
+    void tmEditMarker(SfxViewFrame &rViewShell);
 
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(createDocument);
     CPPUNIT_TEST_SUITE_END();
 
 private:
-    uno::Reference< uno::XComponentContext > m_context;
+    uno::Reference<uno::XComponentContext> m_xContext;
+    uno::Reference<lang::XMultiComponentFactory> m_xFactory;
 };
 
 void Test::setUp()
 {
-    m_context = cppu::defaultBootstrap_InitialComponentContext();
+    m_xContext = cppu::defaultBootstrap_InitialComponentContext();
+    m_xFactory = m_xContext->getServiceManager();
 
-    uno::Reference<lang::XMultiComponentFactory> xFactory(m_context->getServiceManager());
-    uno::Reference<lang::XMultiServiceFactory> xSM(xFactory, uno::UNO_QUERY_THROW);
+    uno::Reference<lang::XMultiServiceFactory> xSM(m_xFactory, uno::UNO_QUERY_THROW);
 
     //Without this we're crashing because callees are using
     //getProcessServiceFactory.  In general those should be removed in favour
@@ -73,7 +79,46 @@ void Test::setUp()
 
 void Test::tearDown()
 {
-    uno::Reference< lang::XComponent >(m_context, uno::UNO_QUERY_THROW)->dispose();
+    uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose();
+}
+
+void Test::tmEditMarker(SfxViewFrame &rViewFrame)
+{
+    SfxBindings aBindings;
+    SfxDispatcher aDispatcher(&rViewFrame);
+    aBindings.SetDispatcher(&aDispatcher);
+    SmCmdBoxWindow aSmCmdBoxWindow(&aBindings, NULL, NULL);
+    SmEditWindow aEditWindow(aSmCmdBoxWindow);
+    aEditWindow.Flush();
+
+    {
+        rtl::OUString sMarkedText(RTL_CONSTASCII_USTRINGPARAM("<?> under <?> under <?>"));
+        aEditWindow.SetText(sMarkedText);
+        aEditWindow.Flush();
+        rtl::OUString sFinalText = aEditWindow.GetText();
+        CPPUNIT_ASSERT_MESSAGE("Should be equal text", sFinalText == sMarkedText);
+    }
+
+    {
+        rtl::OUString sTargetText(RTL_CONSTASCII_USTRINGPARAM("a under b under c"));
+
+        aEditWindow.SelNextMark();
+        aEditWindow.Cut();
+        aEditWindow.InsertText(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("a")));
+
+        aEditWindow.SelNextMark();
+        aEditWindow.SelNextMark();
+        aEditWindow.Cut();
+        aEditWindow.InsertText(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("c")));
+
+        aEditWindow.SelPrevMark();
+        aEditWindow.Cut();
+        aEditWindow.InsertText(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("b")));
+
+        aEditWindow.Flush();
+        rtl::OUString sFinalText = aEditWindow.GetText();
+        CPPUNIT_ASSERT_MESSAGE("Should be a under b under c", sFinalText == sTargetText);
+    }
 }
 
 void Test::tmEditFailure(SmDocShellRef &rDocShRef)
@@ -152,6 +197,16 @@ void Test::tmEditUndoRedo(SmDocShellRef &rDocShRef)
 void Test::createDocument()
 {
     SmDocShellRef xDocShRef = new SmDocShell(SFXOBJECTSHELL_STD_NORMAL);
+    xDocShRef->DoInitNew(0);
+
+    uno::Reference< frame::XFrame > xDesktop
+        (m_xFactory->createInstanceWithContext(
+        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")), m_xContext),
+        uno::UNO_QUERY_THROW );
+
+    SfxViewFrame *pViewFrame = SfxViewFrame::LoadHiddenDocument(*xDocShRef, 0);
+
+    CPPUNIT_ASSERT_MESSAGE("Should have SfxViewFrame", pViewFrame);
 
     EditEngine &rEditEngine = xDocShRef->GetEditEngine();
     Window aFoo(NULL, 0);
@@ -160,6 +215,7 @@ void Test::createDocument()
 
     tmEditUndoRedo(xDocShRef);
     tmEditFailure(xDocShRef);
+    tmEditMarker(*pViewFrame);
 
     xDocShRef.Clear();
 }
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index bb49354..94b9e38 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -29,6 +29,7 @@
 #include "visitors.hxx"
 #include "document.hxx"
 #include "view.hxx"
+#include "accessibility.hxx"
 
 void SmCursor::Move(OutputDevice* pDev, SmMovementDirection direction, bool bMoveAnchor){
     SmCaretPosGraphEntry* NewPos = NULL;
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index 2eee87e..f473ea5 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -99,6 +99,7 @@
 #include <svx/svxids.hrc>
 #include "cursor.hxx"
 #include "visitors.hxx"
+#include "accessibility.hxx"
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::accessibility;
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 1218ae5..b618fcc 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -64,6 +64,7 @@
 #include "view.hxx"
 #include "document.hxx"
 #include "config.hxx"
+#include "accessibility.hxx"
 
 #define SCROLL_LINE 		24
 
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 23a6083..97a9035 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -78,6 +78,7 @@
 #include "toolbox.hxx"
 #include "mathmlimport.hxx"
 #include "cursor.hxx"
+#include "accessibility.hxx"
 
 #define MINWIDTH		200
 #define MINHEIGHT		200
@@ -211,10 +212,7 @@ void SmGraphicWindow::MouseButtonDown(const MouseEvent& rMEvt)
 
 bool SmGraphicWindow::IsInlineEditEnabled() const
 {
-    //Avoid crash on startup (happens when starmath is selected from splash screen)
-    if(pViewShell->GetEditWindow())
-        return pViewShell->GetEditWindow()->IsInlineEditEnabled();
-    return false;
+    return pViewShell->IsInlineEditEnabled();
 }
 
 void SmGraphicWindow::GetFocus()
@@ -704,7 +702,8 @@ SmCmdBoxWindow::~SmCmdBoxWindow ()
 
 SmViewShell * SmCmdBoxWindow::GetView()
 {
-    SfxViewShell *pView = GetBindings().GetDispatcher()->GetFrame()->GetViewShell();
+    SfxDispatcher *pDispatcher = GetBindings().GetDispatcher();
+    SfxViewShell *pView = pDispatcher ? pDispatcher->GetFrame()->GetViewShell() : NULL;
     return PTR_CAST(SmViewShell, pView);
 }
 


More information about the Libreoffice-commits mailing list