Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
770493f3
Kaydet (Commit)
770493f3
authored
Haz 05, 2016
tarafından
Marco Cecchetti
Kaydeden (comit)
Jan Holesovsky
Haz 06, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
tdf#84411 - unit test
Change-Id: I0be17c6e9e7f14d73597410a52539240f22a9b68
üst
5c2f9705
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
0 deletions
+99
-0
copy_paste_test.cxx
sc/qa/unit/copy_paste_test.cxx
+99
-0
No files found.
sc/qa/unit/copy_paste_test.cxx
Dosyayı görüntüle @
770493f3
...
...
@@ -32,9 +32,11 @@ public:
virtual
void
tearDown
()
override
;
void
testCopyPasteXLS
();
void
testTdf84411
();
CPPUNIT_TEST_SUITE
(
ScCopyPasteTest
);
CPPUNIT_TEST
(
testCopyPasteXLS
);
CPPUNIT_TEST
(
testTdf84411
);
CPPUNIT_TEST_SUITE_END
();
private
:
...
...
@@ -121,6 +123,103 @@ void ScCopyPasteTest::testCopyPasteXLS()
xComponent
->
dispose
();
}
void
lcl_copy
(
const
OUString
&
rSrcRange
,
const
OUString
&
rDstRange
,
ScDocument
&
rDoc
,
ScTabViewShell
*
pViewShell
)
{
ScDocument
aClipDoc
(
SCDOCMODE_CLIP
);
// 1. Copy
ScRange
aSrcRange
;
ScRefFlags
nRes
=
aSrcRange
.
Parse
(
rSrcRange
,
&
rDoc
,
rDoc
.
GetAddressConvention
());
CPPUNIT_ASSERT_MESSAGE
(
"Failed to parse."
,
(
nRes
&
ScRefFlags
::
VALID
));
pViewShell
->
GetViewData
().
GetMarkData
().
SetMarkArea
(
aSrcRange
);
pViewShell
->
GetViewData
().
GetView
()
->
CopyToClip
(
&
aClipDoc
,
false
,
false
,
false
,
false
);
// 2. Paste
ScRange
aDstRange
;
nRes
=
aDstRange
.
Parse
(
rDstRange
,
&
rDoc
,
rDoc
.
GetAddressConvention
());
CPPUNIT_ASSERT_MESSAGE
(
"Failed to parse."
,
(
nRes
&
ScRefFlags
::
VALID
));
pViewShell
->
GetViewData
().
GetMarkData
().
SetMarkArea
(
aDstRange
);
pViewShell
->
GetViewData
().
GetView
()
->
PasteFromClip
(
InsertDeleteFlags
::
ALL
,
&
aClipDoc
);
}
void
ScCopyPasteTest
::
testTdf84411
()
{
uno
::
Reference
<
frame
::
XDesktop2
>
xDesktop
=
frame
::
Desktop
::
create
(
::
comphelper
::
getProcessComponentContext
());
CPPUNIT_ASSERT
(
xDesktop
.
is
()
);
// create a frame
Reference
<
frame
::
XFrame
>
xTargetFrame
=
xDesktop
->
findFrame
(
"_blank"
,
0
);
CPPUNIT_ASSERT
(
xTargetFrame
.
is
()
);
// 1. Create spreadsheet
uno
::
Sequence
<
beans
::
PropertyValue
>
aEmptyArgList
;
uno
::
Reference
<
lang
::
XComponent
>
xComponent
=
xDesktop
->
loadComponentFromURL
(
"private:factory/scalc"
,
"_blank"
,
0
,
aEmptyArgList
);
CPPUNIT_ASSERT
(
xComponent
.
is
()
);
// Get the document model
SfxObjectShell
*
pFoundShell
=
SfxObjectShell
::
GetShellFromComponent
(
xComponent
);
CPPUNIT_ASSERT_MESSAGE
(
"Failed to access document shell"
,
pFoundShell
);
ScDocShellRef
xDocSh
=
dynamic_cast
<
ScDocShell
*>
(
pFoundShell
);
CPPUNIT_ASSERT
(
xDocSh
!=
nullptr
);
uno
::
Reference
<
frame
::
XModel2
>
xModel2
(
xDocSh
->
GetModel
(),
UNO_QUERY
);
CPPUNIT_ASSERT
(
xModel2
.
is
()
);
Reference
<
frame
::
XController2
>
xController
(
xModel2
->
createDefaultViewController
(
xTargetFrame
),
UNO_QUERY
);
CPPUNIT_ASSERT
(
xController
.
is
()
);
// introduce model/view/controller to each other
xController
->
attachModel
(
xModel2
.
get
()
);
xModel2
->
connectController
(
xController
.
get
()
);
xTargetFrame
->
setComponent
(
xController
->
getComponentWindow
(),
xController
.
get
()
);
xController
->
attachFrame
(
xTargetFrame
);
xModel2
->
setCurrentController
(
xController
.
get
()
);
ScDocument
&
rDoc
=
xDocSh
->
GetDocument
();
// Get the document controller
ScTabViewShell
*
pViewShell
=
xDocSh
->
GetBestViewShell
(
false
);
CPPUNIT_ASSERT
(
pViewShell
!=
nullptr
);
// 2. Setup data and formulas
for
(
unsigned
int
r
=
0
;
r
<=
4991
;
++
r
)
for
(
unsigned
int
c
=
0
;
c
<=
14
;
++
c
)
rDoc
.
SetValue
(
ScAddress
(
c
,
r
,
0
),
(
r
+
1
)
*
(
c
+
1
)
);
rDoc
.
SetString
(
ScAddress
(
15
,
10000
,
0
),
"=AVERAGE(A10001:O10001)"
);
rDoc
.
SetString
(
ScAddress
(
16
,
10000
,
0
),
"=MIN(A10001:O10001)"
);
rDoc
.
SetString
(
ScAddress
(
17
,
10000
,
0
),
"=MAX(A10001:O10001)"
);
lcl_copy
(
"P10001:R10001"
,
"P10002:R12500"
,
rDoc
,
pViewShell
);
// 3. Disable OpenCL
ScModelObj
*
pModel
=
ScModelObj
::
getImplementation
(
pFoundShell
->
GetModel
());
CPPUNIT_ASSERT
(
pModel
!=
nullptr
);
pModel
->
enableOpenCL
(
false
);
CPPUNIT_ASSERT
(
ScCalcConfig
::
isOpenCLEnabled
()
==
false
);
pModel
->
enableAutomaticCalculation
(
true
);
CPPUNIT_ASSERT
(
ScCalcConfig
::
isSwInterpreterEnabled
()
);
// 4. Copy and Paste
lcl_copy
(
"A1:O2500"
,
"A10001:O12500"
,
rDoc
,
pViewShell
);
lcl_copy
(
"A2501:O5000"
,
"A12501:O15000"
,
rDoc
,
pViewShell
);
lcl_copy
(
"P10001:R10001"
,
"P12501:R15000"
,
rDoc
,
pViewShell
);
// 5. Close the document (Ctrl-W)
xComponent
->
dispose
();
}
ScCopyPasteTest
::
ScCopyPasteTest
()
:
ScBootstrapFixture
(
"/sc/qa/unit/data"
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment