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
4b419d30
Kaydet (Commit)
4b419d30
authored
Eki 26, 2012
tarafından
Markus Mohrhard
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
implement export password test
Change-Id: I90ef759639c8b1410ec314fed4ff0fd877d8e224
üst
f48886d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
subsequent_export-test.cxx
sc/qa/unit/subsequent_export-test.cxx
+85
-0
No files found.
sc/qa/unit/subsequent_export-test.cxx
Dosyayı görüntüle @
4b419d30
...
@@ -16,10 +16,12 @@
...
@@ -16,10 +16,12 @@
#include <sfx2/app.hxx>
#include <sfx2/app.hxx>
#include <sfx2/docfilt.hxx>
#include <sfx2/docfilt.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/frame.hxx>
#include <sfx2/sfxmodelfactory.hxx>
#include <sfx2/sfxmodelfactory.hxx>
#include <svl/stritem.hxx>
#include <svl/stritem.hxx>
#include <unotools/tempfile.hxx>
#include <unotools/tempfile.hxx>
#include <comphelper/storagehelper.hxx>
#define CALC_DEBUG_OUTPUT 0
#define CALC_DEBUG_OUTPUT 0
#define TEST_BUG_FILES 0
#define TEST_BUG_FILES 0
...
@@ -70,10 +72,14 @@ public:
...
@@ -70,10 +72,14 @@ public:
virtual
void
tearDown
();
virtual
void
tearDown
();
ScDocShellRef
saveAndReload
(
ScDocShell
*
,
const
rtl
::
OUString
&
,
const
rtl
::
OUString
&
,
const
rtl
::
OUString
&
,
sal_uLong
);
ScDocShellRef
saveAndReload
(
ScDocShell
*
,
const
rtl
::
OUString
&
,
const
rtl
::
OUString
&
,
const
rtl
::
OUString
&
,
sal_uLong
);
ScDocShellRef
saveAndReloadPassword
(
ScDocShell
*
,
const
rtl
::
OUString
&
,
const
rtl
::
OUString
&
,
const
rtl
::
OUString
&
,
sal_uLong
);
void
test
();
void
test
();
void
testPasswordExport
();
CPPUNIT_TEST_SUITE
(
ScExportTest
);
CPPUNIT_TEST_SUITE
(
ScExportTest
);
CPPUNIT_TEST
(
test
);
CPPUNIT_TEST
(
test
);
CPPUNIT_TEST
(
testPasswordExport
);
CPPUNIT_TEST_SUITE_END
();
CPPUNIT_TEST_SUITE_END
();
private
:
private
:
...
@@ -92,6 +98,60 @@ void ScFiltersTest::createFileURL(const rtl::OUString& aFileBase, const rtl::OUS
...
@@ -92,6 +98,60 @@ void ScFiltersTest::createFileURL(const rtl::OUString& aFileBase, const rtl::OUS
}
}
*/
*/
ScDocShellRef
ScExportTest
::
saveAndReloadPassword
(
ScDocShell
*
pShell
,
const
rtl
::
OUString
&
rFilter
,
const
rtl
::
OUString
&
rUserData
,
const
rtl
::
OUString
&
rTypeName
,
sal_uLong
nFormatType
)
{
utl
::
TempFile
aTempFile
;
//aTempFile.EnableKillingFile();
SfxMedium
aStoreMedium
(
aTempFile
.
GetURL
(),
STREAM_STD_WRITE
);
sal_uInt32
nExportFormat
=
0
;
if
(
nFormatType
)
nExportFormat
=
SFX_FILTER_EXPORT
|
SFX_FILTER_USESOPTIONS
;
SfxFilter
*
pExportFilter
=
new
SfxFilter
(
rFilter
,
rtl
::
OUString
(),
nFormatType
,
nExportFormat
,
rTypeName
,
0
,
rtl
::
OUString
(),
rUserData
,
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"private:factory/scalc*"
))
);
pExportFilter
->
SetVersion
(
SOFFICE_FILEFORMAT_CURRENT
);
aStoreMedium
.
SetFilter
(
pExportFilter
);
SfxItemSet
*
pExportSet
=
aStoreMedium
.
GetItemSet
();
uno
::
Sequence
<
beans
::
NamedValue
>
aEncryptionData
=
comphelper
::
OStorageHelper
::
CreatePackageEncryptionData
(
rtl
::
OUString
(
"test"
)
);
uno
::
Any
xEncryptionData
;
xEncryptionData
<<=
aEncryptionData
;
pExportSet
->
Put
(
SfxUnoAnyItem
(
SID_ENCRYPTIONDATA
,
xEncryptionData
));
uno
::
Reference
<
embed
::
XStorage
>
xMedStorage
=
aStoreMedium
.
GetStorage
();
::
comphelper
::
OStorageHelper
::
SetCommonStorageEncryptionData
(
xMedStorage
,
aEncryptionData
);
pShell
->
DoSaveAs
(
aStoreMedium
);
pShell
->
DoClose
();
std
::
cout
<<
"File: "
<<
aTempFile
.
GetURL
()
<<
std
::
endl
;
sal_uInt32
nFormat
=
0
;
if
(
nFormatType
)
nFormat
=
SFX_FILTER_IMPORT
|
SFX_FILTER_USESOPTIONS
;
SfxFilter
*
pFilter
=
new
SfxFilter
(
rFilter
,
rtl
::
OUString
(),
nFormatType
,
nFormat
,
rTypeName
,
0
,
rtl
::
OUString
(),
rUserData
,
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"private:factory/scalc*"
))
);
pFilter
->
SetVersion
(
SOFFICE_FILEFORMAT_CURRENT
);
ScDocShellRef
xDocShRef
=
new
ScDocShell
;
SfxMedium
*
pSrcMed
=
new
SfxMedium
(
aTempFile
.
GetURL
(),
STREAM_STD_READ
);
SfxItemSet
*
pSet
=
pSrcMed
->
GetItemSet
();
pSet
->
Put
(
SfxStringItem
(
SID_PASSWORD
,
rtl
::
OUString
(
RTL_CONSTASCII_USTRINGPARAM
(
"test"
))));
pSrcMed
->
SetFilter
(
pFilter
);
if
(
!
xDocShRef
->
DoLoad
(
pSrcMed
))
{
xDocShRef
->
DoClose
();
// load failed.
xDocShRef
.
Clear
();
}
return
xDocShRef
;
}
ScDocShellRef
ScExportTest
::
saveAndReload
(
ScDocShell
*
pShell
,
const
rtl
::
OUString
&
rFilter
,
ScDocShellRef
ScExportTest
::
saveAndReload
(
ScDocShell
*
pShell
,
const
rtl
::
OUString
&
rFilter
,
const
rtl
::
OUString
&
rUserData
,
const
rtl
::
OUString
&
rTypeName
,
sal_uLong
nFormatType
)
const
rtl
::
OUString
&
rUserData
,
const
rtl
::
OUString
&
rTypeName
,
sal_uLong
nFormatType
)
{
{
...
@@ -160,6 +220,31 @@ void ScExportTest::test()
...
@@ -160,6 +220,31 @@ void ScExportTest::test()
CPPUNIT_ASSERT_DOUBLES_EQUAL
(
aVal
,
1.0
,
1e-8
);
CPPUNIT_ASSERT_DOUBLES_EQUAL
(
aVal
,
1.0
,
1e-8
);
}
}
void
ScExportTest
::
testPasswordExport
()
{
ScDocShell
*
pShell
=
new
ScDocShell
(
SFXMODEL_STANDARD
|
SFXMODEL_DISABLE_EMBEDDED_SCRIPTS
|
SFXMODEL_DISABLE_DOCUMENT_RECOVERY
);
pShell
->
DoInitNew
();
ScDocument
*
pDoc
=
pShell
->
GetDocument
();
pDoc
->
SetValue
(
0
,
0
,
0
,
1.0
);
CPPUNIT_ASSERT
(
pDoc
);
sal_Int32
nFormat
=
ODS
;
rtl
::
OUString
aFileExtension
(
aFileFormats
[
nFormat
].
pName
,
strlen
(
aFileFormats
[
nFormat
].
pName
),
RTL_TEXTENCODING_UTF8
);
rtl
::
OUString
aFilterName
(
aFileFormats
[
nFormat
].
pFilterName
,
strlen
(
aFileFormats
[
nFormat
].
pFilterName
),
RTL_TEXTENCODING_UTF8
)
;
rtl
::
OUString
aFilterType
(
aFileFormats
[
nFormat
].
pTypeName
,
strlen
(
aFileFormats
[
nFormat
].
pTypeName
),
RTL_TEXTENCODING_UTF8
);
ScDocShellRef
xDocSh
=
saveAndReloadPassword
(
pShell
,
aFilterName
,
rtl
::
OUString
(),
aFilterType
,
aFileFormats
[
nFormat
].
nFormatType
);
CPPUNIT_ASSERT
(
xDocSh
.
Is
());
ScDocument
*
pLoadedDoc
=
xDocSh
->
GetDocument
();
double
aVal
=
pLoadedDoc
->
GetValue
(
0
,
0
,
0
);
CPPUNIT_ASSERT_DOUBLES_EQUAL
(
aVal
,
1.0
,
1e-8
);
}
ScExportTest
::
ScExportTest
()
ScExportTest
::
ScExportTest
()
:
m_aBaseString
(
RTL_CONSTASCII_USTRINGPARAM
(
"/sc/qa/unit/data"
))
:
m_aBaseString
(
RTL_CONSTASCII_USTRINGPARAM
(
"/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