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
1f744121
Kaydet (Commit)
1f744121
authored
Şub 13, 2017
tarafından
David Tardon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
test result of text document import
Change-Id: I6830da0c6692f0be212e0d45597fa563917b5fb2
üst
d9b6edc0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
301 additions
and
7 deletions
+301
-7
CppunitTest_writerperfect_wpftimport.mk
writerperfect/CppunitTest_writerperfect_wpftimport.mk
+52
-0
Module_writerperfect.mk
writerperfect/Module_writerperfect.mk
+1
-0
TextImportTest.cxx
writerperfect/qa/unit/TextImportTest.cxx
+142
-0
WpftLoader.cxx
writerperfect/qa/unit/WpftLoader.cxx
+33
-7
WpftLoader.hxx
writerperfect/qa/unit/WpftLoader.hxx
+12
-0
wpftimport.cxx
writerperfect/qa/unit/wpftimport.cxx
+28
-0
wpftimport.hxx
writerperfect/qa/unit/wpftimport.hxx
+33
-0
No files found.
writerperfect/CppunitTest_writerperfect_wpftimport.mk
0 → 100644
Dosyayı görüntüle @
1f744121
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_CppunitTest_CppunitTest,writerperfect_wpftimport))
$(eval $(call gb_CppunitTest_set_include,writerperfect_wpftimport,\
-I$(SRCDIR)/writerperfect/inc \
-I$(SRCDIR)/writerperfect/source/writer \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_externals,writerperfect_wpftimport,\
odfgen \
revenge \
))
$(eval $(call gb_CppunitTest_use_sdk_api,writerperfect_wpftimport))
$(eval $(call gb_CppunitTest_use_libraries,writerperfect_wpftimport,\
comphelper \
cppu \
cppuhelper \
sal \
test \
unotest \
utl \
wpftqahelper \
writerperfect \
$(gb_UWINAPI) \
))
$(eval $(call gb_CppunitTest_use_ure,writerperfect_wpftimport))
$(eval $(call gb_CppunitTest_use_vcl,writerperfect_wpftimport))
$(eval $(call gb_CppunitTest_use_rdbs,writerperfect_wpftimport,\
services \
))
$(eval $(call gb_CppunitTest_use_configuration,writerperfect_wpftimport))
$(eval $(call gb_CppunitTest_add_exception_objects,writerperfect_wpftimport,\
writerperfect/qa/unit/TextImportTest \
writerperfect/qa/unit/wpftimport \
))
# vim: set noet sw=4 ts=4:
writerperfect/Module_writerperfect.mk
Dosyayı görüntüle @
1f744121
...
...
@@ -34,6 +34,7 @@ $(eval $(call gb_Module_add_l10n_targets,writerperfect,\
$(eval $(call gb_Module_add_check_targets,writerperfect,\
CppunitTest_writerperfect_stream \
CppunitTest_writerperfect_wpftimport \
))
$(eval $(call gb_Module_add_slowcheck_targets,writerperfect,\
...
...
writerperfect/qa/unit/TextImportTest.cxx
0 → 100644
Dosyayı görüntüle @
1f744121
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XEnumeration.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <rtl/ref.hxx>
#include "DocumentHandlerForOdt.hxx"
#include "ImportFilter.hxx"
#include "WpftFilterFixture.hxx"
#include "WpftLoader.hxx"
#include "wpftimport.hxx"
namespace
{
namespace
uno
=
css
::
uno
;
class
TextImportFilter
:
public
writerperfect
::
ImportFilter
<
OdtGenerator
>
{
public
:
explicit
TextImportFilter
(
const
uno
::
Reference
<
uno
::
XComponentContext
>
&
rxContext
)
:
writerperfect
::
ImportFilter
<
OdtGenerator
>
(
rxContext
)
{}
// XServiceInfo
virtual
rtl
::
OUString
SAL_CALL
getImplementationName
()
override
;
virtual
sal_Bool
SAL_CALL
supportsService
(
const
rtl
::
OUString
&
ServiceName
)
override
;
virtual
uno
::
Sequence
<
rtl
::
OUString
>
SAL_CALL
getSupportedServiceNames
()
override
;
private
:
virtual
bool
doDetectFormat
(
librevenge
::
RVNGInputStream
&
rInput
,
rtl
::
OUString
&
rTypeName
)
override
;
virtual
bool
doImportDocument
(
librevenge
::
RVNGInputStream
&
rInput
,
OdtGenerator
&
rGenerator
,
utl
::
MediaDescriptor
&
rDescriptor
)
override
;
void
generate
(
librevenge
::
RVNGTextInterface
&
rDocument
)
const
;
};
bool
TextImportFilter
::
doImportDocument
(
librevenge
::
RVNGInputStream
&
,
OdtGenerator
&
rGenerator
,
utl
::
MediaDescriptor
&
)
{
generate
(
rGenerator
);
return
true
;
}
bool
TextImportFilter
::
doDetectFormat
(
librevenge
::
RVNGInputStream
&
,
rtl
::
OUString
&
rTypeName
)
{
rTypeName
=
"WpftDummyText"
;
return
true
;
}
// XServiceInfo
rtl
::
OUString
SAL_CALL
TextImportFilter
::
getImplementationName
()
{
return
"org.libreoffice.comp.Wpft.QA.TextImportFilter"
;
}
sal_Bool
SAL_CALL
TextImportFilter
::
supportsService
(
const
rtl
::
OUString
&
rServiceName
)
{
return
cppu
::
supportsService
(
this
,
rServiceName
);
}
uno
::
Sequence
<
rtl
::
OUString
>
SAL_CALL
TextImportFilter
::
getSupportedServiceNames
()
{
return
{
"com.sun.star.document.ImportFilter"
,
"com.sun.star.document.ExtendedTypeDetection"
};
}
void
TextImportFilter
::
generate
(
librevenge
::
RVNGTextInterface
&
rDocument
)
const
{
using
namespace
librevenge
;
rDocument
.
startDocument
(
RVNGPropertyList
());
rDocument
.
openPageSpan
(
RVNGPropertyList
());
rDocument
.
openParagraph
(
RVNGPropertyList
());
rDocument
.
openSpan
(
RVNGPropertyList
());
rDocument
.
insertText
(
"My hovercraft is full of eels."
);
rDocument
.
closeSpan
();
rDocument
.
closeParagraph
();
rDocument
.
closePageSpan
();
rDocument
.
endDocument
();
}
}
namespace
{
class
TextImportTest
:
public
writerperfect
::
test
::
WpftFilterFixture
{
public
:
void
test
();
CPPUNIT_TEST_SUITE
(
TextImportTest
);
CPPUNIT_TEST
(
test
);
CPPUNIT_TEST_SUITE_END
();
};
void
TextImportTest
::
test
()
{
using
namespace
css
;
rtl
::
Reference
<
TextImportFilter
>
xFilter
{
new
TextImportFilter
(
m_xContext
)};
writerperfect
::
test
::
WpftLoader
aLoader
(
createDummyInput
(),
xFilter
.
get
(),
"private:factory/swriter"
,
m_xDesktop
,
m_xContext
);
uno
::
Reference
<
text
::
XTextDocument
>
xDoc
(
aLoader
.
getDocument
(),
uno
::
UNO_QUERY
);
CPPUNIT_ASSERT
(
xDoc
.
is
());
uno
::
Reference
<
container
::
XEnumerationAccess
>
xParaAccess
(
xDoc
->
getText
(),
uno
::
UNO_QUERY
);
CPPUNIT_ASSERT
(
xParaAccess
.
is
());
uno
::
Reference
<
container
::
XEnumeration
>
xParas
=
xParaAccess
->
createEnumeration
();
CPPUNIT_ASSERT
(
xParas
.
is
());
CPPUNIT_ASSERT
(
xParas
->
hasMoreElements
());
uno
::
Reference
<
container
::
XEnumerationAccess
>
xPortionsAccess
(
xParas
->
nextElement
(),
uno
::
UNO_QUERY
);
CPPUNIT_ASSERT
(
xPortionsAccess
.
is
());
uno
::
Reference
<
container
::
XEnumeration
>
xPortions
=
xPortionsAccess
->
createEnumeration
();
CPPUNIT_ASSERT
(
xPortions
.
is
());
CPPUNIT_ASSERT
(
xPortions
->
hasMoreElements
());
uno
::
Reference
<
beans
::
XPropertySet
>
xPortionProps
(
xPortions
->
nextElement
(),
uno
::
UNO_QUERY
);
CPPUNIT_ASSERT
(
xPortionProps
.
is
());
rtl
::
OUString
aPortionType
;
CPPUNIT_ASSERT
(
xPortionProps
->
getPropertyValue
(
"TextPortionType"
)
>>=
aPortionType
);
CPPUNIT_ASSERT_EQUAL
(
rtl
::
OUString
(
"Text"
),
aPortionType
);
uno
::
Reference
<
text
::
XTextRange
>
xPortion
(
xPortionProps
,
uno
::
UNO_QUERY
);
CPPUNIT_ASSERT
(
xPortion
.
is
());
CPPUNIT_ASSERT_EQUAL
(
rtl
::
OUString
(
"My hovercraft is full of eels."
),
xPortion
->
getString
());
CPPUNIT_ASSERT
(
!
xPortions
->
hasMoreElements
());
CPPUNIT_ASSERT
(
!
xParas
->
hasMoreElements
());
}
CPPUNIT_TEST_SUITE_REGISTRATION
(
TextImportTest
);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
writerperfect/qa/unit/WpftLoader.cxx
Dosyayı görüntüle @
1f744121
...
...
@@ -20,6 +20,7 @@
#include <com/sun/star/frame/XDesktop2.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
...
...
@@ -62,6 +63,23 @@ WpftLoader::WpftLoader(
impl_dispose
();
}
WpftLoader
::
WpftLoader
(
const
css
::
uno
::
Reference
<
css
::
io
::
XInputStream
>
&
rxInputStream
,
const
css
::
uno
::
Reference
<
css
::
document
::
XFilter
>
&
rxFilter
,
const
rtl
::
OUString
&
rFactoryURL
,
const
css
::
uno
::
Reference
<
css
::
frame
::
XDesktop2
>
&
rxDesktop
,
const
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>
&
rxContext
)
:
m_xInputStream
(
rxInputStream
)
,
m_aFactoryURL
(
rFactoryURL
)
,
m_xFilter
(
rxFilter
)
,
m_xDesktop
(
rxDesktop
)
,
m_xContext
(
rxContext
)
{
if
(
!
impl_load
())
impl_dispose
();
}
WpftLoader
::~
WpftLoader
()
{
try
...
...
@@ -117,14 +135,21 @@ bool WpftLoader::impl_load()
xImporter
->
setTargetDocument
(
m_xDoc
);
uno
::
Sequence
<
beans
::
PropertyValue
>
aDescriptor
(
3
);
ucbhelper
::
Content
aContent
(
m_aURL
,
uno
::
Reference
<
ucb
::
XCommandEnvironment
>
(),
m_xContext
);
aDescriptor
[
0
].
Name
=
"URL"
;
aDescriptor
[
0
].
Value
<<=
m_aURL
;
aDescriptor
[
1
].
Name
=
"InputStream"
;
aDescriptor
[
1
].
Value
<<=
aContent
.
openStream
();
aDescriptor
[
2
].
Name
=
"UCBContent"
;
aDescriptor
[
2
].
Value
<<=
aContent
.
get
();
if
(
m_xInputStream
.
is
())
{
aDescriptor
[
1
].
Name
=
"InputStream"
;
aDescriptor
[
1
].
Value
<<=
m_xInputStream
;
}
else
{
ucbhelper
::
Content
aContent
(
m_aURL
,
uno
::
Reference
<
ucb
::
XCommandEnvironment
>
(),
m_xContext
);
aDescriptor
[
1
].
Name
=
"InputStream"
;
aDescriptor
[
1
].
Value
<<=
aContent
.
openStream
();
aDescriptor
[
2
].
Name
=
"UCBContent"
;
aDescriptor
[
2
].
Value
<<=
aContent
.
get
();
}
const
uno
::
Reference
<
document
::
XExtendedFilterDetection
>
xDetector
(
m_xFilter
,
uno
::
UNO_QUERY_THROW
);
...
...
@@ -132,7 +157,8 @@ bool WpftLoader::impl_load()
if
(
aTypeName
.
isEmpty
())
throw
lang
::
IllegalArgumentException
();
impl_detectFilterName
(
aDescriptor
,
aTypeName
);
if
(
m_xTypeMap
.
is
())
impl_detectFilterName
(
aDescriptor
,
aTypeName
);
xModel
->
lockControllers
();
const
bool
bLoaded
=
m_xFilter
->
filter
(
aDescriptor
);
...
...
writerperfect/qa/unit/WpftLoader.hxx
Dosyayı görüntüle @
1f744121
...
...
@@ -40,6 +40,10 @@ namespace frame
class
XDesktop2
;
class
XFrame
;
}
namespace
io
{
class
XInputStream
;
}
namespace
lang
{
class
XComponent
;
...
...
@@ -68,6 +72,13 @@ public:
const
css
::
uno
::
Reference
<
css
::
container
::
XNameAccess
>
&
rxTypeMap
,
const
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>
&
rxContext
);
WpftLoader
(
const
css
::
uno
::
Reference
<
css
::
io
::
XInputStream
>
&
rxInputStream
,
const
css
::
uno
::
Reference
<
css
::
document
::
XFilter
>
&
rxFilter
,
const
rtl
::
OUString
&
rFactoryURL
,
const
css
::
uno
::
Reference
<
css
::
frame
::
XDesktop2
>
&
rxDesktop
,
const
css
::
uno
::
Reference
<
css
::
uno
::
XComponentContext
>
&
rxContext
);
~
WpftLoader
();
const
css
::
uno
::
Reference
<
css
::
lang
::
XComponent
>
&
getDocument
()
const
;
...
...
@@ -80,6 +91,7 @@ private:
private
:
const
rtl
::
OUString
m_aURL
;
const
css
::
uno
::
Reference
<
css
::
io
::
XInputStream
>
m_xInputStream
;
const
rtl
::
OUString
m_aFactoryURL
;
const
css
::
uno
::
Reference
<
css
::
document
::
XFilter
>
m_xFilter
;
const
css
::
uno
::
Reference
<
css
::
frame
::
XDesktop2
>
m_xDesktop
;
...
...
writerperfect/qa/unit/wpftimport.cxx
0 → 100644
Dosyayı görüntüle @
1f744121
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "wpftimport.hxx"
#include <cppunit/plugin/TestPlugIn.h>
#include <comphelper/seqstream.hxx>
#include <rtl/ref.hxx>
#include <sal/types.h>
css
::
uno
::
Reference
<
css
::
io
::
XInputStream
>
createDummyInput
()
{
rtl
::
Reference
<
comphelper
::
SequenceInputStream
>
xDummyInput
{
new
comphelper
::
SequenceInputStream
({})};
return
xDummyInput
.
get
();
}
CPPUNIT_PLUGIN_IMPLEMENT
();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
writerperfect/qa/unit/wpftimport.hxx
0 → 100644
Dosyayı görüntüle @
1f744121
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_WRITERPERFECT_QA_UNIT_WPFTIMPORT_HXX
#define INCLUDED_WRITERPERFECT_QA_UNIT_WPFTIMPORT_HXX
#include <com/sun/star/uno/Reference.hxx>
namespace
com
{
namespace
sun
{
namespace
star
{
namespace
io
{
class
XInputStream
;
}
}
}
}
css
::
uno
::
Reference
<
css
::
io
::
XInputStream
>
createDummyInput
();
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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