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
51ed3a63
Kaydet (Commit)
51ed3a63
authored
Ock 09, 2012
tarafından
Laurent Godard
Kaydeden (comit)
Markus Mohrhard
Ock 18, 2012
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
sc test : refactor importSheet tests
üst
206b748f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
220 additions
and
61 deletions
+220
-61
rangenamessrc.ods
sc/qa/extras/testdocuments/rangenamessrc.ods
+0
-0
xspreadsheets2.cxx
sc/qa/extras/xspreadsheets2.cxx
+220
-61
No files found.
sc/qa/extras/testdocuments/rangenamessrc.ods
Dosyayı görüntüle @
51ed3a63
No preview for this file type
sc/qa/extras/xspreadsheets2.cxx
Dosyayı görüntüle @
51ed3a63
...
...
@@ -40,6 +40,7 @@
#include <com/sun/star/table/XCell.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
...
...
@@ -51,6 +52,9 @@
#include <com/sun/star/table/CellVertJustify.hpp>
#include <rtl/oustringostreaminserter.hxx>
#include <rtl/string.hxx>
namespace
ScSpreadsheetObj
{
...
...
@@ -63,115 +67,186 @@ public:
virtual
void
setUp
();
virtual
void
tearDown
();
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
getDoc
(
const
rtl
::
OUString
);
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
getDoc
(
const
rtl
::
OUString
,
uno
::
Reference
<
lang
::
XComponent
>
);
uno
::
Reference
<
sheet
::
XNamedRanges
>
getNamedRanges
(
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
);
void
importSheetToCopy
();
bool
isExternalReference
(
const
rtl
::
OUString
aDestContent
,
const
rtl
::
OUString
aSrcContent
);
// XSpreadsheets2
void
testImportSheet
();
void
testImportedSheetNameAndIndex
();
void
testImportString
();
void
testImportValue
();
void
testImportFormulaBasicMath
();
void
testImportFormulaWithNamedRange
();
void
testImportOverExistingNamedRange
();
void
testImportNamedRangeDefinedInSource
();
void
testImportNamedRangeRedefinedInSource
();
void
testImportNewNamedRange
();
void
testImportCellStyle
();
CPPUNIT_TEST_SUITE
(
ScXSpreadsheets2
);
// disable test, test fails, might be the ongoing copy refs work
CPPUNIT_TEST
(
testImportSheet
);
CPPUNIT_TEST
(
testImportedSheetNameAndIndex
);
CPPUNIT_TEST
(
testImportString
);
CPPUNIT_TEST
(
testImportValue
);
CPPUNIT_TEST
(
testImportFormulaBasicMath
);
CPPUNIT_TEST
(
testImportFormulaWithNamedRange
);
CPPUNIT_TEST
(
testImportOverExistingNamedRange
);
CPPUNIT_TEST
(
testImportNamedRangeDefinedInSource
);
CPPUNIT_TEST
(
testImportNamedRangeRedefinedInSource
);
CPPUNIT_TEST
(
testImportNewNamedRange
);
CPPUNIT_TEST
(
testImportCellStyle
);
CPPUNIT_TEST_SUITE_END
();
private
:
static
int
nTest
;
static
uno
::
Reference
<
lang
::
XComponent
>
xComponent
;
static
bool
bIsSheetImported
;
static
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
xSrcDoc
;
static
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
xDestDoc
;
static
uno
::
Reference
<
container
::
XNameAccess
>
xSrcNamedRangesNameAccess
;
static
uno
::
Reference
<
container
::
XNameAccess
>
xDestNamedRangesNameAccess
;
static
uno
::
Reference
<
container
::
XNameAccess
>
xDestSheetNameAccess
;
static
uno
::
Reference
<
sheet
::
XSpreadsheet
>
xDestSheet
;
static
uno
::
Reference
<
sheet
::
XSpreadsheet
>
xSrcSheet
;
static
sal_Int32
nDestPosEffective
;
static
rtl
::
OUString
aSrcSheetName
;
static
rtl
::
OUString
aSrcFileBase
;
static
rtl
::
OUString
aDestFileBase
;
static
sal_Int32
nDestPos
;
};
int
ScXSpreadsheets2
::
nTest
=
0
;
uno
::
Reference
<
lang
::
XComponent
>
ScXSpreadsheets2
::
xComponent
;
void
ScXSpreadsheets2
::
testImportSheet
()
bool
ScXSpreadsheets2
::
bIsSheetImported
=
false
;
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
ScXSpreadsheets2
::
xSrcDoc
;
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
ScXSpreadsheets2
::
xDestDoc
;
uno
::
Reference
<
container
::
XNameAccess
>
ScXSpreadsheets2
::
xSrcNamedRangesNameAccess
;
uno
::
Reference
<
container
::
XNameAccess
>
ScXSpreadsheets2
::
xDestNamedRangesNameAccess
;
uno
::
Reference
<
container
::
XNameAccess
>
ScXSpreadsheets2
::
xDestSheetNameAccess
;
uno
::
Reference
<
sheet
::
XSpreadsheet
>
ScXSpreadsheets2
::
xDestSheet
;
uno
::
Reference
<
sheet
::
XSpreadsheet
>
ScXSpreadsheets2
::
xSrcSheet
;
rtl
::
OUString
ScXSpreadsheets2
::
aSrcSheetName
(
RTL_CONSTASCII_USTRINGPARAM
(
"SheetToCopy"
));
rtl
::
OUString
ScXSpreadsheets2
::
aSrcFileBase
(
RTL_CONSTASCII_USTRINGPARAM
(
"rangenamessrc.ods"
));
rtl
::
OUString
ScXSpreadsheets2
::
aDestFileBase
(
RTL_CONSTASCII_USTRINGPARAM
(
"rangenames.ods"
));
sal_Int32
ScXSpreadsheets2
::
nDestPos
=
0
;
sal_Int32
ScXSpreadsheets2
::
nDestPosEffective
;
void
ScXSpreadsheets2
::
testImportedSheetNameAndIndex
()
{
const
rtl
::
OUString
aSrcFileBase
(
RTL_CONSTASCII_USTRINGPARAM
(
"rangenamessrc.ods"
));
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
xSrcDoc
=
getDoc
(
aSrcFileBase
);
CPPUNIT_ASSERT
(
xSrcDoc
.
is
());
/**
Verfiy that the imported sheet has the correct name and is placed at the right requested index
*/
uno
::
Reference
<
container
::
XNameAccess
>
xSrcNamedRangesNameAccess
(
getNamedRanges
(
xSrcDoc
),
UNO_QUERY_THROW
);
importSheetToCopy
(
);
const
rtl
::
OUString
aDestFileBase
(
RTL_CONSTASCII_USTRINGPARAM
(
"rangenames.ods"
));
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
xDestDoc
=
getDoc
(
aDestFileBase
);
CPPUNIT_ASSERT
(
xDestDoc
.
is
());
uno
::
Reference
<
sheet
::
XSpreadsheets2
>
xDest
(
xDestDoc
->
getSheets
(),
UNO_QUERY_THROW
);
uno
::
Reference
<
container
::
XNameAccess
>
xDestNamedRangesNameAccess
(
getNamedRanges
(
xDestDoc
),
UNO_QUERY_THROW
);
// import sheet
const
sal_Int32
nDestPos
=
0
;
const
rtl
::
OUString
aSrcSheetName
(
RTL_CONSTASCII_USTRINGPARAM
(
"SheetToCopy"
));
sal_Int32
nDestPosEffective
=
xDest
->
importSheet
(
xSrcDoc
,
aSrcSheetName
,
nDestPos
);
//sheet index in dest is ok
CPPUNIT_ASSERT_MESSAGE
(
"Wrong sheet name"
,
xDestSheetNameAccess
->
hasByName
(
aSrcSheetName
));
CPPUNIT_ASSERT_MESSAGE
(
"Wrong sheet index"
,
nDestPosEffective
==
nDestPos
);
uno
::
Reference
<
container
::
XNameAccess
>
xDestSheetNameAccess
(
xDestDoc
->
getSheets
(),
UNO_QUERY_THROW
);
uno
::
Reference
<
sheet
::
XSpreadsheet
>
xDestSheet
(
xDestSheetNameAccess
->
getByName
(
aSrcSheetName
),
UNO_QUERY_THROW
);
uno
::
Reference
<
container
::
XNameAccess
>
xSrcSheetNameAccess
(
xSrcDoc
->
getSheets
(),
UNO_QUERY_THROW
);
uno
::
Reference
<
sheet
::
XSpreadsheet
>
xSrcSheet
(
xSrcSheetNameAccess
->
getByName
(
aSrcSheetName
),
UNO_QUERY_THROW
);
//new sheet name in dest is ok
CPPUNIT_ASSERT_MESSAGE
(
"Wrong sheet name"
,
xDestSheetNameAccess
->
hasByName
(
aSrcSheetName
));
}
uno
::
Reference
<
table
::
XCell
>
xDestCell
;
uno
::
Reference
<
table
::
XCell
>
xSrcCell
;
void
ScXSpreadsheets2
::
testImportString
()
{
/**
tests the cell A1 containing a string correctly imported
*/
importSheetToCopy
();
//imported string
xSrcCell
=
xSrcSheet
->
getCellByPosition
(
0
,
0
);
uno
::
Reference
<
table
::
XCell
>
xSrcCell
=
xSrcSheet
->
getCellByPosition
(
0
,
0
);
uno
::
Reference
<
text
::
XTextRange
>
xSrcTextRange
(
xSrcCell
,
UNO_QUERY_THROW
);
rtl
::
OUString
aSrcString
=
xSrcTextRange
->
getString
();
xDestCell
=
xDestSheet
->
getCellByPosition
(
0
,
0
);
uno
::
Reference
<
table
::
XCell
>
xDestCell
=
xDestSheet
->
getCellByPosition
(
0
,
0
);
uno
::
Reference
<
text
::
XTextRange
>
xDestTextRange
(
xDestCell
,
UNO_QUERY_THROW
);
rtl
::
OUString
aDestString
=
xDestTextRange
->
getString
();
CPPUNIT_ASSERT_MESSAGE
(
"Wrong string imported"
,
aDestString
.
equals
(
aSrcString
));
}
void
ScXSpreadsheets2
::
testImportValue
()
{
/**
tests the cell B1 containing a value correctly imported
*/
importSheetToCopy
();
//imported value
xSrcCell
=
xSrcSheet
->
getCellByPosition
(
1
,
0
);
uno
::
Reference
<
table
::
XCell
>
xSrcCell
=
xSrcSheet
->
getCellByPosition
(
1
,
0
);
sal_Int32
aSrcValue
=
xSrcCell
->
getValue
();
xDestCell
=
xDestSheet
->
getCellByPosition
(
1
,
0
);
uno
::
Reference
<
table
::
XCell
>
xDestCell
=
xDestSheet
->
getCellByPosition
(
1
,
0
);
sal_Int32
aDestValue
=
xDestCell
->
getValue
();
CPPUNIT_ASSERT_MESSAGE
(
"Wrong value imported"
,
aSrcValue
==
aDestValue
);
}
void
ScXSpreadsheets2
::
testImportFormulaBasicMath
()
{
/**
tests the cell C1 containing an arithmetic formula correctly imported
*/
importSheetToCopy
();
//mathematical formula
xSrcCell
=
xSrcSheet
->
getCellByPosition
(
2
,
0
);
uno
::
Reference
<
table
::
XCell
>
xSrcCell
=
xSrcSheet
->
getCellByPosition
(
2
,
0
);
rtl
::
OUString
aSrcFormula
=
xSrcCell
->
getFormula
();
xDestCell
=
xDestSheet
->
getCellByPosition
(
2
,
0
);
uno
::
Reference
<
table
::
XCell
>
xDestCell
=
xDestSheet
->
getCellByPosition
(
2
,
0
);
rtl
::
OUString
aDestFormula
=
xDestCell
->
getFormula
();
// potential problem later: formulas might be adjusted
// add some tests that the formulas are correctly adjusted
CPPUNIT_ASSERT_MESSAGE
(
"Wrong formula imported"
,
aDestFormula
.
equals
(
aSrcFormula
));
}
//formula with an already existing named range in dest - initial1
xSrcCell
=
xSrcSheet
->
getCellByPosition
(
3
,
0
);
aSrcFormula
=
xSrcCell
->
getFormula
();
void
ScXSpreadsheets2
::
testImportFormulaWithNamedRange
()
{
/**
tests the cell D1 containing a formula that uses a NamedRange expression
*/
importSheetToCopy
();
xDestCell
=
xDestSheet
->
getCellByPosition
(
3
,
0
);
aDestFormula
=
xDestCell
->
getFormula
();
uno
::
Reference
<
table
::
XCell
>
xSrcCell
=
xSrcSheet
->
getCellByPosition
(
3
,
0
);
rtl
::
OUString
aSrcFormula
=
xSrcCell
->
getFormula
();
uno
::
Reference
<
table
::
XCell
>
xDestCell
=
xDestSheet
->
getCellByPosition
(
3
,
0
);
rtl
::
OUString
aDestFormula
=
xDestCell
->
getFormula
();
CPPUNIT_ASSERT_MESSAGE
(
"Wrong Namedrange formula imported"
,
aDestFormula
.
equals
(
aSrcFormula
));
}
void
ScXSpreadsheets2
::
testImportOverExistingNamedRange
()
{
/**
Both Source and Target file define the named range initial1
in Source, initial1 is defined outside the copied sheet
In Target, after import sheet, initial1 should point on its initial definition $Sheet1.$B$1
NEED MORE WORK
*/
importSheetToCopy
();
// initial NamedRange content is correct
rtl
::
OUString
aNamedRangeString
(
RTL_CONSTASCII_USTRINGPARAM
(
"initial1"
));
uno
::
Any
aNr
=
xDestNamedRangesNameAccess
->
getByName
(
aNamedRangeString
);
uno
::
Reference
<
sheet
::
XNamedRange
>
xDestNamedRange
(
aNr
,
UNO_QUERY_THROW
);
rtl
::
OUString
aNrDestContent
=
xDestNamedRange
->
getContent
();
aNr
=
xSrcNamedRangesNameAccess
->
getByName
(
aNamedRangeString
);
uno
::
Reference
<
sheet
::
XNamedRange
>
xSrcNamedRange
(
aNr
,
UNO_QUERY_THROW
);
rtl
::
OUString
aNrSrcContent
=
xSrcNamedRange
->
getContent
();
std
::
cout
<<
"testImportSheet : initial1 aNrDestContent "
<<
aNrDestContent
<<
std
::
endl
;
// is $Sheet1.$B$1
std
::
cout
<<
"testImportSheet : initial1 aNrSrcContent "
<<
aNrSrcContent
<<
std
::
endl
;
// is $Sheet1.$B$2
rtl
::
OUString
aExpectedContent
(
RTL_CONSTASCII_USTRINGPARAM
(
"$Sheet1.$B$1"
));
// CPPUNIT_ASSERT_MESSAGE("Sheet name for initial1 has been changed in dest (expected $Sheet1.$B$1) ", aNrDestContent.equals(aExpectedContent));
std
::
cout
<<
"testImportSheet : initial1 aNrDestContent "
<<
aNrDestContent
<<
std
::
endl
;
CPPUNIT_ASSERT_MESSAGE
(
"Wrong address for initial1"
,
aNrDestContent
.
equals
(
aExpectedContent
));
}
void
ScXSpreadsheets2
::
testImportNamedRangeDefinedInSource
()
{
/**
in Source file, InSheetRangeName named range is defined in the copied sheet
it does not exists in target file
test that the range named is created in target and that it points in the target copied sheet
*/
importSheetToCopy
();
// New range name defined in imported sheet $SheetToCopy.$A$7
rtl
::
OUString
aNewInSheetNamedRangeString
(
RTL_CONSTASCII_USTRINGPARAM
(
"InSheetRangeName"
));
...
...
@@ -181,9 +256,20 @@ void ScXSpreadsheets2::testImportSheet()
uno
::
Reference
<
sheet
::
XNamedRange
>
xDestNewInSheetNamedRange
(
aNewInSheetNr
,
UNO_QUERY_THROW
);
rtl
::
OUString
aNewInSheetNrDestContent
=
xDestNewInSheetNamedRange
->
getContent
();
rtl
::
OUString
aNewInSheetExpectedContent
(
RTL_CONSTASCII_USTRINGPARAM
(
"$SheetToCopy.$A$7"
));
std
::
cout
<<
"testImportSheet : InSheetRangeName content "
<<
aNewInSheetNrDestContent
<<
std
::
endl
;
std
::
cout
<<
"testImportSheet : InSheetRangeName expected "
<<
aNewInSheetExpectedContent
<<
std
::
endl
;
CPPUNIT_ASSERT_MESSAGE
(
"Wrong address for InSheetRangeName"
,
aNewInSheetNrDestContent
.
equals
(
aNewInSheetExpectedContent
));
}
void
ScXSpreadsheets2
::
testImportNamedRangeRedefinedInSource
()
{
/**
in Source file, initial2 named range is defined in the copied sheet
it is defined in another sheet of target file
test that the range named points in the target copied sheet
*/
importSheetToCopy
();
// the source file redefines an existing named range in the imported sheet --> the target should not be changed
rtl
::
OUString
aRedefinedInSheetNamedRangeString
(
RTL_CONSTASCII_USTRINGPARAM
(
"initial2"
));
...
...
@@ -192,9 +278,19 @@ void ScXSpreadsheets2::testImportSheet()
uno
::
Any
aRedefinedInSheetNr
=
xDestNamedRangesNameAccess
->
getByName
(
aRedefinedInSheetNamedRangeString
);
uno
::
Reference
<
sheet
::
XNamedRange
>
xDestRedefinedInSheetNamedRange
(
aRedefinedInSheetNr
,
UNO_QUERY_THROW
);
rtl
::
OUString
aRedefinedInSheetNrDestContent
=
xDestRedefinedInSheetNamedRange
->
getContent
();
rtl
::
OUString
aRedefinedInSheetExpectedContent
(
RTL_CONSTASCII_USTRINGPARAM
(
"$Sheet
ToCopy.$A$10
"
));
rtl
::
OUString
aRedefinedInSheetExpectedContent
(
RTL_CONSTASCII_USTRINGPARAM
(
"$Sheet
1.$B$2
"
));
std
::
cout
<<
"testImportSheet : initial2 content "
<<
aRedefinedInSheetNrDestContent
<<
std
::
endl
;
CPPUNIT_ASSERT_MESSAGE
(
"Wrong address for Redefined InSheet named range"
,
aRedefinedInSheetNrDestContent
.
equals
(
aRedefinedInSheetExpectedContent
));
}
void
ScXSpreadsheets2
::
testImportNewNamedRange
()
{
/**
in Soucre file, new_rangename range named is defined outside the copied sheet
it does not exists in target file
test that new_rangename is created and its content points to source file as an external reference
*/
importSheetToCopy
();
//formula with a non-existant named range in dest - new_rangename
rtl
::
OUString
aNewNamedRangeString
(
RTL_CONSTASCII_USTRINGPARAM
(
"new_rangename"
));
...
...
@@ -210,7 +306,22 @@ void ScXSpreadsheets2::testImportSheet()
std
::
cout
<<
"testImportSheet : new_rangename aNewExpectedContent "
<<
aNewExpectedContent
<<
std
::
endl
;
std
::
cout
<<
"testImportSheet : new_rangename aNewNrDestContent "
<<
aNewNrDestContent
<<
std
::
endl
;
CPPUNIT_ASSERT_MESSAGE
(
"Wrong New NamedRange formula string value"
,
aNewExpectedContent
.
equals
(
aNewExpectedContent
));
CPPUNIT_ASSERT_MESSAGE
(
"Wrong New NamedRange formula string value"
,
isExternalReference
(
aNewNrDestContent
,
aNewExpectedContent
));
}
void
ScXSpreadsheets2
::
testImportCellStyle
()
{
/**
in source file, imported sheet uses a cellstyle that does not exists in target
test that
- an imported cell D1 uses the right cellStyle
- the cellStyle is created in CellStyles family
- a property of the cellStyle (VertJustify) is correctly set
*/
importSheetToCopy
();
uno
::
Reference
<
table
::
XCell
>
xSrcCell
=
xSrcSheet
->
getCellByPosition
(
3
,
0
);
uno
::
Reference
<
table
::
XCell
>
xDestCell
=
xDestSheet
->
getCellByPosition
(
3
,
0
);
//new style created in dest
uno
::
Reference
<
beans
::
XPropertySet
>
xSrcCellPropSet
(
xSrcCell
,
UNO_QUERY_THROW
);
...
...
@@ -241,17 +352,17 @@ void ScXSpreadsheets2::testImportSheet()
CPPUNIT_ASSERT_MESSAGE
(
"New style: VertJustify not set"
,
aVertJustify
==
table
::
CellVertJustify_CENTER
);
}
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
ScXSpreadsheets2
::
getDoc
(
const
rtl
::
OUString
aFileBase
)
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
ScXSpreadsheets2
::
getDoc
(
const
rtl
::
OUString
aFileBase
,
uno
::
Reference
<
lang
::
XComponent
>
xComp
)
{
rtl
::
OUString
aFileURL
;
createFileURL
(
aFileBase
,
aFileURL
);
if
(
!
xComp
onent
.
is
())
xComp
onent
=
loadFromDesktop
(
aFileURL
);
if
(
!
xComp
.
is
())
xComp
=
loadFromDesktop
(
aFileURL
);
CPPUNIT_ASSERT
(
xComp
onent
.
is
());
CPPUNIT_ASSERT
(
xComp
.
is
());
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
xDoc
(
xComp
onent
,
UNO_QUERY_THROW
);
uno
::
Reference
<
sheet
::
XSpreadsheetDocument
>
xDoc
(
xComp
,
UNO_QUERY_THROW
);
CPPUNIT_ASSERT
(
xDoc
.
is
());
return
xDoc
;
}
...
...
@@ -266,6 +377,54 @@ uno::Reference< sheet::XNamedRanges> ScXSpreadsheets2::getNamedRanges(uno::Refer
return
xNamedRanges
;
}
void
ScXSpreadsheets2
::
importSheetToCopy
()
{
if
(
!
bIsSheetImported
)
{
xSrcDoc
=
getDoc
(
aSrcFileBase
,
xComponent
);
CPPUNIT_ASSERT
(
xSrcDoc
.
is
());
xSrcNamedRangesNameAccess
=
uno
::
Reference
<
container
::
XNameAccess
>
(
getNamedRanges
(
xSrcDoc
),
UNO_QUERY_THROW
);
uno
::
Reference
<
lang
::
XComponent
>
xDestComponent
;
xDestDoc
=
getDoc
(
aDestFileBase
,
xDestComponent
);
CPPUNIT_ASSERT
(
xDestDoc
.
is
());
xDestNamedRangesNameAccess
=
uno
::
Reference
<
container
::
XNameAccess
>
(
getNamedRanges
(
xDestDoc
),
UNO_QUERY_THROW
);
// import sheet
uno
::
Reference
<
sheet
::
XSpreadsheets2
>
xDestSheets
(
xDestDoc
->
getSheets
(),
UNO_QUERY_THROW
);
nDestPosEffective
=
xDestSheets
->
importSheet
(
xSrcDoc
,
aSrcSheetName
,
nDestPos
);
uno
::
Reference
<
container
::
XNameAccess
>
xSrcSheetNameAccess
(
xSrcDoc
->
getSheets
(),
UNO_QUERY_THROW
);
xSrcSheet
=
uno
::
Reference
<
sheet
::
XSpreadsheet
>
(
xSrcSheetNameAccess
->
getByName
(
aSrcSheetName
),
UNO_QUERY_THROW
);
xDestSheetNameAccess
=
uno
::
Reference
<
container
::
XNameAccess
>
(
xDestDoc
->
getSheets
(),
UNO_QUERY_THROW
);
xDestSheet
=
uno
::
Reference
<
sheet
::
XSpreadsheet
>
(
xDestSheetNameAccess
->
getByName
(
aSrcSheetName
),
UNO_QUERY_THROW
);
bIsSheetImported
=
true
;
// store destFile
//uno::Reference< frame::XStorable > xStore (xDestDoc, UNO_QUERY_THROW);
//xStore->store();
}
}
bool
ScXSpreadsheets2
::
isExternalReference
(
rtl
::
OUString
aDestContent
,
rtl
::
OUString
aSrcContent
)
{
rtl
::
OUString
aStart
(
RTL_CONSTASCII_USTRINGPARAM
(
"'file://"
));
const
sal_Char
*
sSrcContent
=
rtl
::
OUStringToOString
(
aSrcContent
,
RTL_TEXTENCODING_UTF8
).
getStr
();
/*
std::cout << "aDestContent " << aDestContent << std::endl;
std::cout << "aSrcContent " << aSrcContent << std::endl;
std::cout << "endsWithIgnoreAsciiCaseAsciiL " << aDestContent.endsWithIgnoreAsciiCaseAsciiL(sSrcContent, aSrcContent.getLength()) << std::endl;
std::cout << "indexOf(aStart) " << aDestContent.indexOf(aStart) << std::endl;
std::cout << "indexOf(aSrcFileBase) " << aDestContent.indexOf(aSrcFileBase) << std::endl;
*/
return
(
aDestContent
.
endsWithIgnoreAsciiCaseAsciiL
(
sSrcContent
,
aSrcContent
.
getLength
())
// same cell address
&&
aDestContent
.
indexOf
(
aStart
)
==
0
// starts with 'file://
&&
aDestContent
.
indexOf
(
aSrcFileBase
)
>
0
);
// contains source file name
}
void
ScXSpreadsheets2
::
setUp
()
{
nTest
+=
1
;
...
...
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