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
90f7bd61
Kaydet (Commit)
90f7bd61
authored
May 16, 2014
tarafından
Kohei Yoshida
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fdo#77537: Write export test for this.
Change-Id: I2960713b1005c5f91fe78d12e33f1786978eac67
üst
fd70beac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
17 deletions
+96
-17
subsequent_export-test.cxx
sc/qa/unit/subsequent_export-test.cxx
+96
-17
No files found.
sc/qa/unit/subsequent_export-test.cxx
Dosyayı görüntüle @
90f7bd61
...
...
@@ -44,6 +44,7 @@
#include <editeng/section.hxx>
#include <editeng/crossedoutitem.hxx>
#include <editeng/borderline.hxx>
#include <editeng/fontitem.hxx>
#include <formula/grammar.hxx>
#include <com/sun/star/table/BorderLineStyle.hpp>
...
...
@@ -441,6 +442,19 @@ void setAttribute( ScFieldEditEngine& rEE, sal_Int32 nPara, sal_Int32 nStart, sa
}
}
void
setFont
(
ScFieldEditEngine
&
rEE
,
sal_Int32
nPara
,
sal_Int32
nStart
,
sal_Int32
nEnd
,
const
OUString
&
rFontName
)
{
ESelection
aSel
;
aSel
.
nStartPara
=
aSel
.
nEndPara
=
nPara
;
aSel
.
nStartPos
=
nStart
;
aSel
.
nEndPos
=
nEnd
;
SfxItemSet
aItemSet
=
rEE
.
GetEmptyItemSet
();
SvxFontItem
aItem
(
FAMILY_MODERN
,
rFontName
,
""
,
PITCH_VARIABLE
,
RTL_TEXTENCODING_UTF8
,
EE_CHAR_FONTINFO
);
aItemSet
.
Put
(
aItem
);
rEE
.
QuickSetAttribs
(
aItemSet
,
aSel
);
}
}
void
ScExportTest
::
testNamedRangeBugfdo62729
()
...
...
@@ -525,6 +539,23 @@ void ScExportTest::testRichTextExportODS()
return
false
;
}
static
bool
isFont
(
const
editeng
::
Section
&
rAttr
,
const
OUString
&
rFontName
)
{
if
(
rAttr
.
maAttributes
.
empty
())
return
false
;
std
::
vector
<
const
SfxPoolItem
*>::
const_iterator
it
=
rAttr
.
maAttributes
.
begin
(),
itEnd
=
rAttr
.
maAttributes
.
end
();
for
(;
it
!=
itEnd
;
++
it
)
{
const
SfxPoolItem
*
p
=
*
it
;
if
(
p
->
Which
()
!=
EE_CHAR_FONTINFO
)
continue
;
return
static_cast
<
const
SvxFontItem
*>
(
p
)
->
GetFamilyName
()
==
rFontName
;
}
return
false
;
}
bool
checkB2
(
const
EditTextObject
*
pText
)
const
{
if
(
!
pText
)
...
...
@@ -649,27 +680,62 @@ void ScExportTest::testRichTextExportODS()
return
true
;
}
bool
checkB7
(
const
EditTextObject
*
pText
)
const
{
if
(
!
pText
)
return
false
;
if
(
pText
->
GetParagraphCount
()
!=
1
)
return
false
;
if
(
pText
->
GetText
(
0
)
!=
"Font1 and Font2"
)
return
false
;
std
::
vector
<
editeng
::
Section
>
aSecAttrs
;
pText
->
GetAllSections
(
aSecAttrs
);
if
(
aSecAttrs
.
size
()
!=
3
)
return
false
;
// First section should have "Courier" font applied.
const
editeng
::
Section
*
pAttr
=
&
aSecAttrs
[
0
];
if
(
pAttr
->
mnParagraph
!=
0
||
pAttr
->
mnStart
!=
0
||
pAttr
->
mnEnd
!=
5
)
return
false
;
if
(
pAttr
->
maAttributes
.
size
()
!=
1
||
!
isFont
(
*
pAttr
,
"Courier"
))
return
false
;
// Last section should have "Luxi Mono" applied.
pAttr
=
&
aSecAttrs
[
2
];
if
(
pAttr
->
mnParagraph
!=
0
||
pAttr
->
mnStart
!=
10
||
pAttr
->
mnEnd
!=
15
)
return
false
;
if
(
pAttr
->
maAttributes
.
size
()
!=
1
||
!
isFont
(
*
pAttr
,
"Luxi Mono"
))
return
false
;
return
true
;
}
}
aCheckFunc
;
// Start with an empty document, put one edit text cell, and make sure it
// survives the save and reload.
ScDocShellRef
xOrigDocSh
=
loadDoc
(
"empty."
,
ODS
);
ScDocShellRef
xOrigDocSh
=
loadDoc
(
"empty."
,
ODS
,
true
);
ScDocument
*
pDoc
=
xOrigDocSh
->
GetDocument
();
CPPUNIT_ASSERT
(
pDoc
);
CPPUNIT_ASSERT_MESSAGE
(
"This document should at least have one sheet."
,
pDoc
->
GetTableCount
()
>
0
);
// Insert an edit text cell.
ScFieldEditEngine
&
rEE
=
pDoc
->
GetEditEngine
();
rEE
.
SetText
(
"Bold and Italic"
);
ScFieldEditEngine
*
pEE
=
&
pDoc
->
GetEditEngine
();
pEE
->
SetText
(
"Bold and Italic"
);
// Set the 'Bold' part bold.
setAttribute
(
r
EE
,
0
,
0
,
4
,
EE_CHAR_WEIGHT
);
setAttribute
(
*
p
EE
,
0
,
0
,
4
,
EE_CHAR_WEIGHT
);
// Set the 'Italic' part italic.
setAttribute
(
r
EE
,
0
,
9
,
15
,
EE_CHAR_ITALIC
);
setAttribute
(
*
p
EE
,
0
,
9
,
15
,
EE_CHAR_ITALIC
);
ESelection
aSel
;
aSel
.
nStartPara
=
aSel
.
nEndPara
=
0
;
// Set this edit text to cell B2.
pDoc
->
SetEditText
(
ScAddress
(
1
,
1
,
0
),
rEE
.
CreateTextObject
());
pDoc
->
SetEditText
(
ScAddress
(
1
,
1
,
0
),
pEE
->
CreateTextObject
());
const
EditTextObject
*
pEditText
=
pDoc
->
GetEditText
(
ScAddress
(
1
,
1
,
0
));
CPPUNIT_ASSERT_MESSAGE
(
"Incorret B2 value."
,
aCheckFunc
.
checkB2
(
pEditText
));
...
...
@@ -680,20 +746,22 @@ void ScExportTest::testRichTextExportODS()
pDoc
=
xNewDocSh
->
GetDocument
();
CPPUNIT_ASSERT
(
pDoc
);
CPPUNIT_ASSERT_MESSAGE
(
"Reloaded document should at least have one sheet."
,
pDoc
->
GetTableCount
()
>
0
);
pEE
=
&
pDoc
->
GetEditEngine
();
// Make sure the content of B2 is still intact.
CPPUNIT_ASSERT_MESSAGE
(
"Incorret B2 value."
,
aCheckFunc
.
checkB2
(
pEditText
));
// Insert a multi-line content to B4.
rEE
.
Clear
();
rEE
.
SetText
(
"One
\n
Two
\n
Three"
);
pDoc
->
SetEditText
(
ScAddress
(
3
,
1
,
0
),
rEE
.
CreateTextObject
());
pEE
->
Clear
();
pEE
->
SetText
(
"One
\n
Two
\n
Three"
);
pDoc
->
SetEditText
(
ScAddress
(
3
,
1
,
0
),
pEE
->
CreateTextObject
());
pEditText
=
pDoc
->
GetEditText
(
ScAddress
(
3
,
1
,
0
));
CPPUNIT_ASSERT_MESSAGE
(
"Incorret B4 value."
,
aCheckFunc
.
checkB4
(
pEditText
));
// Reload the doc again, and check the content of B2 and B4.
ScDocShellRef
xNewDocSh2
=
saveAndReload
(
xNewDocSh
,
ODS
);
pDoc
=
xNewDocSh2
->
GetDocument
();
pEE
=
&
pDoc
->
GetEditEngine
();
xNewDocSh
->
DoClose
();
pEditText
=
pDoc
->
GetEditText
(
ScAddress
(
1
,
1
,
0
));
...
...
@@ -702,22 +770,31 @@ void ScExportTest::testRichTextExportODS()
CPPUNIT_ASSERT_MESSAGE
(
"Incorret B4 value."
,
aCheckFunc
.
checkB4
(
pEditText
));
// Insert a multi-line content to B5, but this time, set some empty paragraphs.
rEE
.
Clear
();
rEE
.
SetText
(
"
\n
Two
\n
Three
\n\n
Five
\n
"
);
pDoc
->
SetEditText
(
ScAddress
(
4
,
1
,
0
),
rEE
.
CreateTextObject
());
pEE
->
Clear
();
pEE
->
SetText
(
"
\n
Two
\n
Three
\n\n
Five
\n
"
);
pDoc
->
SetEditText
(
ScAddress
(
4
,
1
,
0
),
pEE
->
CreateTextObject
());
pEditText
=
pDoc
->
GetEditText
(
ScAddress
(
4
,
1
,
0
));
CPPUNIT_ASSERT_MESSAGE
(
"Incorret B5 value."
,
aCheckFunc
.
checkB5
(
pEditText
));
// Insert a text with strikethrough in B6.
rEE
.
Clear
();
rEE
.
SetText
(
"Strike Me"
);
pEE
->
Clear
();
pEE
->
SetText
(
"Strike Me"
);
// Set the 'Strike' part strikethrough.
setAttribute
(
r
EE
,
0
,
0
,
6
,
EE_CHAR_STRIKEOUT
);
pDoc
->
SetEditText
(
ScAddress
(
5
,
1
,
0
),
rEE
.
CreateTextObject
());
setAttribute
(
*
p
EE
,
0
,
0
,
6
,
EE_CHAR_STRIKEOUT
);
pDoc
->
SetEditText
(
ScAddress
(
5
,
1
,
0
),
pEE
->
CreateTextObject
());
pEditText
=
pDoc
->
GetEditText
(
ScAddress
(
5
,
1
,
0
));
CPPUNIT_ASSERT_MESSAGE
(
"Incorret B6 value."
,
aCheckFunc
.
checkB6
(
pEditText
));
// Reload the doc again, and check the content of B2, B4 and B6.
// Insert a text with different font segments in B7.
pEE
->
Clear
();
pEE
->
SetText
(
"Font1 and Font2"
);
setFont
(
*
pEE
,
0
,
0
,
5
,
"Courier"
);
setFont
(
*
pEE
,
0
,
10
,
15
,
"Luxi Mono"
);
pDoc
->
SetEditText
(
ScAddress
(
6
,
1
,
0
),
pEE
->
CreateTextObject
());
pEditText
=
pDoc
->
GetEditText
(
ScAddress
(
6
,
1
,
0
));
CPPUNIT_ASSERT_MESSAGE
(
"Incorret B7 value."
,
aCheckFunc
.
checkB7
(
pEditText
));
// Reload the doc again, and check the content of B2, B4, B6 and B7.
ScDocShellRef
xNewDocSh3
=
saveAndReload
(
xNewDocSh2
,
ODS
);
pDoc
=
xNewDocSh3
->
GetDocument
();
xNewDocSh2
->
DoClose
();
...
...
@@ -730,6 +807,8 @@ void ScExportTest::testRichTextExportODS()
CPPUNIT_ASSERT_MESSAGE
(
"Incorret B5 value."
,
aCheckFunc
.
checkB5
(
pEditText
));
pEditText
=
pDoc
->
GetEditText
(
ScAddress
(
5
,
1
,
0
));
CPPUNIT_ASSERT_MESSAGE
(
"Incorret B6 value."
,
aCheckFunc
.
checkB6
(
pEditText
));
pEditText
=
pDoc
->
GetEditText
(
ScAddress
(
6
,
1
,
0
));
CPPUNIT_ASSERT_MESSAGE
(
"Incorret B7 value."
,
aCheckFunc
.
checkB7
(
pEditText
));
xNewDocSh3
->
DoClose
();
}
...
...
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