Kaydet (Commit) a516ac45 authored tarafından Miklos Vajna's avatar Miklos Vajna

fdo#37606 testcase

Change-Id: I60d34906a90a5143163e516f618648cf7178430e
üst 7794ae34
......@@ -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 \
))
......
......@@ -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);
......
......@@ -53,7 +53,7 @@ namespace nsTransferBufferType
}
class SwTransferable : public TransferableHelper
class SW_DLLPUBLIC SwTransferable : public TransferableHelper
{
friend class SwView_Impl;
SfxObjectShellLock aDocShellRef;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment