summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2013-09-20 15:46:06 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-09-20 15:49:55 +0200
commita516ac452e33d3f0df2572089041e2555808a5ee (patch)
tree57347ccb787146a26a3f527f8385924fbad03cfc
parent7794ae344c353794916c669b85040fa4fc6c990f (diff)
fdo#37606 testcase
Change-Id: I60d34906a90a5143163e516f618648cf7178430e
-rw-r--r--sw/CppunitTest_sw_odfimport.mk5
-rw-r--r--sw/qa/extras/odfimport/data/fdo37606.odtbin0 -> 11389 bytes
-rw-r--r--sw/qa/extras/odfimport/odfimport.cxx71
-rw-r--r--sw/source/ui/inc/swdtflvr.hxx2
4 files changed, 77 insertions, 1 deletions
diff --git a/sw/CppunitTest_sw_odfimport.mk b/sw/CppunitTest_sw_odfimport.mk
index 55805a85f258..756f1810bcc4 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 000000000000..462984f11303
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/fdo37606.odt
Binary files differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index a773eb3ca8f7..34d4f82ab55c 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 89ea0ad53d55..dbc78b081017 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;