[Libreoffice-commits] core.git: sw/CppunitTest_sw_odfimport.mk sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Sep 20 06:50:17 PDT 2013


 sw/CppunitTest_sw_odfimport.mk           |    5 ++
 sw/qa/extras/odfimport/data/fdo37606.odt |binary
 sw/qa/extras/odfimport/odfimport.cxx     |   71 +++++++++++++++++++++++++++++++
 sw/source/ui/inc/swdtflvr.hxx            |    2 
 4 files changed, 77 insertions(+), 1 deletion(-)

New commits:
commit a516ac452e33d3f0df2572089041e2555808a5ee
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Sep 20 15:46:06 2013 +0200

    fdo#37606 testcase
    
    Change-Id: I60d34906a90a5143163e516f618648cf7178430e

diff --git a/sw/CppunitTest_sw_odfimport.mk b/sw/CppunitTest_sw_odfimport.mk
index 55805a8..756f181 100644
--- a/sw/CppunitTest_sw_odfimport.mk
+++ b/sw/CppunitTest_sw_odfimport.mk
@@ -20,6 +20,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_odfimport, \
     cppu \
     cppuhelper \
     sal \
+	svt \
 	sw \
     test \
     unotest \
@@ -36,6 +37,7 @@ $(eval $(call gb_CppunitTest_use_externals,sw_odfimport,\
 $(eval $(call gb_CppunitTest_set_include,sw_odfimport,\
     -I$(SRCDIR)/sw/inc \
     -I$(SRCDIR)/sw/source/core/inc \
+    -I$(SRCDIR)/sw/source/ui/inc \
 	-I$(SRCDIR)/sw/qa/extras/inc \
     $$(INCLUDE) \
 ))
@@ -71,6 +73,9 @@ $(eval $(call gb_CppunitTest_use_components,sw_odfimport,\
     unotools/util/utl \
     unoxml/source/service/unoxml \
     uui/util/uui \
+    $(if $(filter-out MACOSX WNT,$(OS)), \
+		vcl/vcl.unx \
+    ) \
 	$(if $(filter DESKTOP,$(BUILD_TYPE)),xmlhelp/util/ucpchelp1) \
     xmloff/util/xo \
 ))
diff --git a/sw/qa/extras/odfimport/data/fdo37606.odt b/sw/qa/extras/odfimport/data/fdo37606.odt
new file mode 100644
index 0000000..462984f
Binary files /dev/null and b/sw/qa/extras/odfimport/data/fdo37606.odt differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index a773eb3..34d4f82 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -12,6 +12,12 @@
 #include <com/sun/star/text/XTextTable.hpp>
 #include <swmodeltestbase.hxx>
 
+#include <wrtsh.hxx>
+#include <ndtxt.hxx>
+#include <swdtflvr.hxx>
+#include <view.hxx>
+#include <edtwin.hxx>
+
 typedef std::map<OUString, com::sun::star::uno::Sequence< com::sun::star::table::BorderLine> > AllBordersMap;
 typedef std::pair<OUString, com::sun::star::uno::Sequence< com::sun::star::table::BorderLine> > StringSequencePair;
 
@@ -28,6 +34,8 @@ public:
     void testFdo56272();
     void testFdo55814();
     void testFdo68839();
+    void testFdo37606();
+    void testFdo37606Copy();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -52,6 +60,8 @@ void Test::run()
         {"fdo56272.odt", &Test::testFdo56272},
         {"fdo55814.odt", &Test::testFdo55814},
         {"fdo68839.odt", &Test::testFdo68839},
+        {"fdo37606.odt", &Test::testFdo37606},
+        {"fdo37606.odt", &Test::testFdo37606Copy},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -354,6 +364,67 @@ void Test::testFdo68839()
             getProperty<OUString>(xFrame2, "ChainNextName"));
 }
 
+void Test::testFdo37606()
+{
+    SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+    SwWrtShell* pWrtShell = pTxtDoc->GetDocShell()->GetWrtShell();
+    SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(false);
+
+    {
+        pWrtShell->SelAll();
+        SwTxtNode& rStart = dynamic_cast<SwTxtNode&>(pShellCrsr->Start()->nNode.GetNode());
+        CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart.GetTxt());
+
+        SwTxtNode& rEnd = dynamic_cast<SwTxtNode&>(pShellCrsr->End()->nNode.GetNode());
+        // This was "A1", i.e. Ctrl-A only selected the A1 cell of the table, not the whole document.
+        CPPUNIT_ASSERT_EQUAL(OUString("Hello."), rEnd.GetTxt());
+    }
+
+    {
+        pWrtShell->SttEndDoc(false); // Go to the end of the doc.
+        pWrtShell->SelAll(); // And now that we're outside of the table, try Ctrl-A again.
+        SwTxtNode& rStart = dynamic_cast<SwTxtNode&>(pShellCrsr->Start()->nNode.GetNode());
+        // This was "Hello", i.e. Ctrl-A did not select the starting table.
+        CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart.GetTxt());
+
+        SwTxtNode& rEnd = dynamic_cast<SwTxtNode&>(pShellCrsr->End()->nNode.GetNode());
+        CPPUNIT_ASSERT_EQUAL(OUString("Hello."), rEnd.GetTxt());
+    }
+
+    {
+        pWrtShell->Delete(); // Delete the selection
+        // And make sure the table got deleted as well.
+        SwNodes& rNodes = pWrtShell->GetDoc()->GetNodes();
+        SwNodeIndex nNode(rNodes.GetEndOfExtras());
+        SwCntntNode* pCntntNode = rNodes.GoNext(&nNode);
+        // First content node was in a table -> table wasn't deleted.
+        CPPUNIT_ASSERT(!pCntntNode->FindTableNode());
+    }
+}
+
+void Test::testFdo37606Copy()
+{
+    SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+    SwWrtShell* pWrtShell = pTxtDoc->GetDocShell()->GetWrtShell();
+    // Ctrl-A
+    pWrtShell->SelAll();
+
+    // Ctrl-C
+    SwTransferable* pTransferable = new SwTransferable(*pWrtShell);
+    uno::Reference<datatransfer::XTransferable> xTransferable(pTransferable);
+    pTransferable->Copy();
+
+    pWrtShell->SttEndDoc(false); // Go to the end of the doc.
+
+    // Ctrl-V
+    TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromSystemClipboard(&pWrtShell->GetView().GetEditWin()));
+    SwTransferable::Paste( *pWrtShell, aDataHelper );
+
+    // Previously copy&paste failed to copy the table in case it was the document-starting one.
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables->getCount());
+}
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
diff --git a/sw/source/ui/inc/swdtflvr.hxx b/sw/source/ui/inc/swdtflvr.hxx
index 89ea0ad..dbc78b0 100644
--- a/sw/source/ui/inc/swdtflvr.hxx
+++ b/sw/source/ui/inc/swdtflvr.hxx
@@ -53,7 +53,7 @@ namespace nsTransferBufferType
 }
 
 
-class SwTransferable : public TransferableHelper
+class SW_DLLPUBLIC SwTransferable : public TransferableHelper
 {
     friend class SwView_Impl;
     SfxObjectShellLock             aDocShellRef;


More information about the Libreoffice-commits mailing list