summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2010-11-29 15:59:10 +0000
committerCaolán McNamara <caolanm@redhat.com>2010-11-29 16:15:15 +0000
commitb8cd33a49426497aca5b06b97e77634e6f6ff52e (patch)
treef5e37077215ea18e2410a8c291db08b91433ce47 /starmath
parent753d24dfff7da81f9b881838894d38a7ea2a0a55 (diff)
equivalent tmEditMarker cppunit test
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/view.hxx2
-rw-r--r--starmath/qa/cppunit/makefile.mk2
-rw-r--r--starmath/qa/cppunit/test_starmath.cxx66
-rw-r--r--starmath/source/cursor.cxx1
-rw-r--r--starmath/source/document.cxx1
-rw-r--r--starmath/source/edit.cxx1
-rw-r--r--starmath/source/view.cxx9
7 files changed, 71 insertions, 11 deletions
diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx
index dbdef14195b8..081dc2388f8c 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 ceab4ffbff21..0433b200d3d7 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 aa2698e7e903..9dbba0d13b2f 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 bb493549ee2f..94b9e386ea95 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 20310b219241..7a831f7ccf68 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 db76392ac1dc..c95dd76e5901 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 1d1a9b95a038..932354116014 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);
}