summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-02-12 21:53:49 +0100
committerMichael Stahl <mstahl@redhat.com>2012-02-13 00:25:04 +0100
commitdde3ce96de325f36d5eaa860c9e067485aa95d3e (patch)
tree0f24da8b0065e5cabb8a82233191f8e3d5501b00 /sw
parent85b5a185124589bbd0606432a5536ce12ae2f66c (diff)
sw: filters-test.cxx: failed attempt to layout loaded documents
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/core/filters-test.cxx55
1 files changed, 55 insertions, 0 deletions
diff --git a/sw/qa/core/filters-test.cxx b/sw/qa/core/filters-test.cxx
index 0af2275e19f4..a8682bdeeee3 100644
--- a/sw/qa/core/filters-test.cxx
+++ b/sw/qa/core/filters-test.cxx
@@ -30,6 +30,13 @@
#include <unotest/filters-test.hxx>
#include <test/bootstrapfixture.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+#include <com/sun/star/document/XDocumentEventListener.hpp>
+#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
+
+#include <comphelper/processfactory.hxx>
+
#include <sfx2/app.hxx>
#include <sfx2/docfilt.hxx>
#include <sfx2/docfile.hxx>
@@ -47,6 +54,29 @@ SO2_IMPL_REF(SwDocShell)
using namespace ::com::sun::star;
+
+class EventListener
+ : public ::cppu::WeakImplHelper1<document::XDocumentEventListener>
+{
+public:
+ bool m_bLayoutFinished;
+ explicit EventListener() : m_bLayoutFinished(false) { }
+ virtual void SAL_CALL documentEventOccured(
+ document::DocumentEvent const& rEvent)
+ throw (uno::RuntimeException)
+ {
+// fprintf(stderr, "EVENT: %s\n", ::rtl::OUStringToOString(rEvent.EventName, RTL_TEXTENCODING_UTF8).getStr());
+ if (rEvent.EventName.equalsAscii("OnLayoutFinished"))
+ {
+ m_bLayoutFinished = true;
+ }
+ }
+ virtual void SAL_CALL disposing(lang::EventObject const&)
+ throw (uno::RuntimeException)
+ {
+ }
+};
+
/* Implementation of Filters test */
class SwFiltersTest
@@ -71,6 +101,18 @@ private:
bool SwFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUString &rURL,
const rtl::OUString &rUserData)
{
+ ::rtl::Reference<EventListener> xListener;
+ if (false) // does not work: missing ViewShell, no VCL timers, or both
+ {
+ xListener.set(new EventListener);
+ uno::Reference<document::XDocumentEventBroadcaster> xGEB;
+ xGEB.set(::comphelper::getProcessServiceFactory()->createInstance(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.frame.GlobalEventBroadcaster"))),
+ uno::UNO_QUERY_THROW);
+ xGEB->addDocumentEventListener(
+ uno::Reference<document::XDocumentEventListener>(xListener.get()));
+ }
SfxFilter* pFilter = new SfxFilter(
rFilter,
rtl::OUString(), 0, 0, rtl::OUString(), 0, rtl::OUString(),
@@ -80,6 +122,19 @@ bool SwFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUString &rURL
SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ, true);
pSrcMed->SetFilter(pFilter);
bool bLoaded = xDocShRef->DoLoad(pSrcMed);
+ if (bLoaded && xListener.is())
+ {
+ TimeValue delay = {0, 100000000};
+ int tries(0);
+ while (!xListener->m_bLayoutFinished) {
+ osl_waitThread(& delay);
+ ++tries;
+ if (tries >= 300) {
+ fprintf(stderr, "timed out: no OnLayoutFinished received\n");
+ break;
+ }
+ }
+ }
if (xDocShRef.Is())
xDocShRef->DoClose();
return bLoaded;