[Libreoffice-commits] core.git: 2 commits - sd/Library_sd.mk sd/source sw/qa writerfilter/source
Miklos Vajna
vmiklos at suse.cz
Fri Jul 26 03:55:13 PDT 2013
sd/Library_sd.mk | 8
sd/source/ui/remotecontrol/AvahiNetworkService.cxx | 2
sd/source/ui/remotecontrol/avahi-common/thread-watch.c | 191 +++++++++++++++++
sd/source/ui/remotecontrol/avahi-common/thread-watch.h | 82 +++++++
sw/qa/extras/rtfimport/data/groupshape-notext.rtf | 71 ++++++
sw/qa/extras/rtfimport/rtfimport.cxx | 1
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 5
writerfilter/source/rtftok/rtfdocumentimpl.hxx | 1
8 files changed, 359 insertions(+), 2 deletions(-)
New commits:
commit e849f5d84a4bc35a241c2d1231b48c57c43ecce4
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Jul 26 11:57:34 2013 +0200
RTF import: fix groupshape import when shapes don't contain text
Without this, the groupshape itself was created, not it had no child
shapes.
Change-Id: I5d3276498eb3ffe840f3d42dad16661849596da4
diff --git a/sw/qa/extras/rtfimport/data/groupshape-notext.rtf b/sw/qa/extras/rtfimport/data/groupshape-notext.rtf
new file mode 100644
index 0000000..98d3c8b
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/groupshape-notext.rtf
@@ -0,0 +1,71 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch0\stshfloch31506\stshfhich31506\stshfbi31506\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0
+{\shpgrp
+{\*\shpinst\shpleft1058\shptop353\shpright3443\shpbottom1148\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026
+{\sp
+{\sn groupLeft}
+{\sv 2475}
+}
+{\sp
+{\sn groupTop}
+{\sv 1770}
+}
+{\sp
+{\sn groupRight}
+{\sv 4860}
+}
+{\sp
+{\sn groupBottom}
+{\sv 2565}
+}
+{\shp
+{\*\shpinst\shplid1027
+{\sp
+{\sn relLeft}
+{\sv 2475}
+}
+{\sp
+{\sn relTop}
+{\sv 1770}
+}
+{\sp
+{\sn relRight}
+{\sv 3285}
+}
+{\sp
+{\sn relBottom}
+{\sv 2565}
+}
+{\sp
+{\sn shapeType}
+{\sv 2}
+}
+}
+}
+{\shp
+{\*\shpinst\shplid1028
+{\sp
+{\sn relLeft}
+{\sv 3900}
+}
+{\sp
+{\sn relTop}
+{\sv 1770}
+}
+{\sp
+{\sn relRight}
+{\sv 4860}
+}
+{\sp
+{\sn relBottom}
+{\sv 2565}
+}
+{\sp
+{\sn shapeType}
+{\sv 5}
+}
+}
+}
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index a25564d..eabdd69 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -294,6 +294,7 @@ void Test::run()
{"fdo47802.rtf", &Test::testFdo47802},
{"fdo39001.rtf", &Test::testFdo39001},
{"groupshape.rtf", &Test::testGroupshape},
+ {"groupshape-notext.rtf", &Test::testGroupshape},
{"fdo66565.rtf", &Test::testFdo66565},
{"fdo54900.rtf", &Test::testFdo54900},
{"fdo64637.rtf", &Test::testFdo64637},
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 840c2c2..56e1759 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1327,6 +1327,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
case RTF_SHP:
m_bNeedCrOrig = m_bNeedCr;
m_aStates.top().nDestinationState = DESTINATION_SHAPE;
+ m_aStates.top().bInShape = true;
break;
case RTF_SHPINST:
m_aStates.top().nDestinationState = DESTINATION_SHAPEINSTRUCTION;
@@ -3930,7 +3931,8 @@ int RTFDocumentImpl::popState()
break;
case DESTINATION_PICPROP:
case DESTINATION_SHAPEINSTRUCTION:
- if (!m_bObject && !aState.bInListpicture && !m_aStates.top().bHadShapeText && !m_aStates.top().bInShapeGroup)
+ // Don't trigger a shape import in case we're only leaving the \shpinst of the groupshape itself.
+ if (!m_bObject && !aState.bInListpicture && !aState.bHadShapeText && !(aState.bInShapeGroup && !aState.bInShape))
m_pSdrImport->resolve(m_aStates.top().aShape, true);
break;
case DESTINATION_BOOKMARKSTART:
@@ -4808,6 +4810,7 @@ RTFParserState::RTFParserState(RTFDocumentImpl *pDocumentImpl)
bInBackground(false),
bHadShapeText(false),
bInShapeGroup(false),
+ bInShape(false),
bCreatedShapeGroup(false),
bStartedTrackchange(false)
{
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index d55572e..86b6912 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -263,6 +263,7 @@ namespace writerfilter {
bool bHadShapeText;
bool bInShapeGroup; ///< If we're inside a \shpgrp group.
+ bool bInShape; ///< If we're inside a \shp group.
bool bCreatedShapeGroup; ///< A GroupShape was created and pushed to the parent stack.
bool bStartedTrackchange; ///< Track change is started, need to end it before popping.
};
commit af1ce3de97a6c1d583f82558ee18054b7917b03d
Author: Siqi <me at siqi.fr>
Date: Fri Jul 26 12:53:19 2013 +0200
add threaded pool support for avahi backward compatibility
As suggested by Avahi maintainer, we should ship threadedpool support with the build since it's not availble to avahi priori to 0.6.3
This keeps the avahi support backward compatible.
Change-Id: I70db9d5b3be3fba744e40c9bb183307819b7df4e
diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk
index 807926f..8484423 100644
--- a/sd/Library_sd.mk
+++ b/sd/Library_sd.mk
@@ -553,6 +553,14 @@ ifeq ($(ENABLE_AVAHI),TRUE)
$(eval $(call gb_Library_add_exception_objects,sd,\
sd/source/ui/remotecontrol/AvahiNetworkService \
))
+
+$(eval $(call gb_Library_add_cobjects,sd,\
+ sd/source/ui/remotecontrol/avahi-common/thread-watch \
+))
+
+$(eval $(call gb_Library_add_libs,sd,\
+ -lpthread \
+))
endif
$(eval $(call gb_Library_add_exception_objects,sd,\
diff --git a/sd/source/ui/remotecontrol/AvahiNetworkService.cxx b/sd/source/ui/remotecontrol/AvahiNetworkService.cxx
index 5cb52de..6043d49 100644
--- a/sd/source/ui/remotecontrol/AvahiNetworkService.cxx
+++ b/sd/source/ui/remotecontrol/AvahiNetworkService.cxx
@@ -10,7 +10,7 @@
#include <avahi-common/malloc.h>
#include <avahi-common/error.h>
#include <avahi-common/timeval.h>
-#include <avahi-common/thread-watch.h>
+#include "avahi-common/thread-watch.h"
#include "AvahiNetworkService.hxx"
#include "ZeroconfService.hxx"
diff --git a/sd/source/ui/remotecontrol/avahi-common/thread-watch.c b/sd/source/ui/remotecontrol/avahi-common/thread-watch.c
new file mode 100644
index 0000000..4bb277f
--- /dev/null
+++ b/sd/source/ui/remotecontrol/avahi-common/thread-watch.c
@@ -0,0 +1,191 @@
+/* $Id$ */
+
+/***
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+ Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <sys/poll.h>
+#include <assert.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <pthread.h>
+#include <signal.h>
+
+#include <avahi-common/llist.h>
+#include <avahi-common/malloc.h>
+#include <avahi-common/error.h>
+#include <avahi-common/timeval.h>
+#include <avahi-common/simple-watch.h>
+
+// Only introduced in 0.6.13. Place it here as advised by avahi maintainer
+#include "thread-watch.h"
+
+struct AvahiThreadedPoll {
+ AvahiSimplePoll *simple_poll;
+ pthread_t thread_id;
+ pthread_mutex_t mutex;
+ int thread_running;
+ int retval;
+};
+
+static int poll_func(struct pollfd *ufds, unsigned int nfds, int timeout, void *userdata) {
+ pthread_mutex_t *mutex = userdata;
+ int r;
+
+ /* Before entering poll() we unlock the mutex, so that
+ * avahi_simple_poll_quit() can succeed from another thread. */
+
+ pthread_mutex_unlock(mutex);
+ r = poll(ufds, nfds, timeout);
+ pthread_mutex_lock(mutex);
+
+ return r;
+}
+
+static void* thread(void *userdata){
+ AvahiThreadedPoll *p = userdata;
+ sigset_t mask;
+
+ /* Make sure that signals are delivered to the main thread */
+ sigfillset(&mask);
+ pthread_sigmask(SIG_BLOCK, &mask, NULL);
+
+ pthread_mutex_lock(&p->mutex);
+ p->retval = avahi_simple_poll_loop(p->simple_poll);
+ pthread_mutex_unlock(&p->mutex);
+
+ return NULL;
+}
+
+AvahiThreadedPoll *avahi_threaded_poll_new(void) {
+ AvahiThreadedPoll *p;
+
+ if (!(p = avahi_new(AvahiThreadedPoll, 1)))
+ goto fail; /* OOM */
+
+ if (!(p->simple_poll = avahi_simple_poll_new()))
+ goto fail;
+
+ pthread_mutex_init(&p->mutex, NULL);
+
+ avahi_simple_poll_set_func(p->simple_poll, poll_func, &p->mutex);
+
+ p->thread_running = 0;
+
+ return p;
+
+fail:
+ if (p) {
+ if (p->simple_poll) {
+ avahi_simple_poll_free(p->simple_poll);
+ pthread_mutex_destroy(&p->mutex);
+ }
+
+ avahi_free(p);
+ }
+
+ return NULL;
+}
+
+void avahi_threaded_poll_free(AvahiThreadedPoll *p) {
+ assert(p);
+
+ /* Make sure that this function is not called from the helper thread */
+ assert(!p->thread_running || !pthread_equal(pthread_self(), p->thread_id));
+
+ if (p->thread_running)
+ avahi_threaded_poll_stop(p);
+
+ if (p->simple_poll)
+ avahi_simple_poll_free(p->simple_poll);
+
+ pthread_mutex_destroy(&p->mutex);
+ avahi_free(p);
+}
+
+const AvahiPoll* avahi_threaded_poll_get(AvahiThreadedPoll *p) {
+ assert(p);
+
+ return avahi_simple_poll_get(p->simple_poll);
+}
+
+int avahi_threaded_poll_start(AvahiThreadedPoll *p) {
+ assert(p);
+
+ assert(!p->thread_running);
+
+ if (pthread_create(&p->thread_id, NULL, thread, p) < 0)
+ return -1;
+
+ p->thread_running = 1;
+
+ return 0;
+}
+
+int avahi_threaded_poll_stop(AvahiThreadedPoll *p) {
+ assert(p);
+
+ if (!p->thread_running)
+ return -1;
+
+ /* Make sure that this function is not called from the helper thread */
+ assert(!pthread_equal(pthread_self(), p->thread_id));
+
+ pthread_mutex_lock(&p->mutex);
+ avahi_simple_poll_quit(p->simple_poll);
+ pthread_mutex_unlock(&p->mutex);
+
+ pthread_join(p->thread_id, NULL);
+ p->thread_running = 0;
+
+ return p->retval;
+}
+
+void avahi_threaded_poll_quit(AvahiThreadedPoll *p) {
+ assert(p);
+
+ /* Make sure that this function is called from the helper thread */
+ assert(pthread_equal(pthread_self(), p->thread_id));
+
+ avahi_simple_poll_quit(p->simple_poll);
+}
+
+void avahi_threaded_poll_lock(AvahiThreadedPoll *p) {
+ assert(p);
+
+ /* Make sure that this function is not called from the helper thread */
+ assert(!p->thread_running || !pthread_equal(pthread_self(), p->thread_id));
+
+ pthread_mutex_lock(&p->mutex);
+}
+
+void avahi_threaded_poll_unlock(AvahiThreadedPoll *p) {
+ assert(p);
+
+ /* Make sure that this function is not called from the helper thread */
+ assert(!p->thread_running || !pthread_equal(pthread_self(), p->thread_id));
+
+ pthread_mutex_unlock(&p->mutex);
+}
\ No newline at end of file
diff --git a/sd/source/ui/remotecontrol/avahi-common/thread-watch.h b/sd/source/ui/remotecontrol/avahi-common/thread-watch.h
new file mode 100644
index 0000000..0f0a12d
--- /dev/null
+++ b/sd/source/ui/remotecontrol/avahi-common/thread-watch.h
@@ -0,0 +1,82 @@
+#ifndef foothreadedwatchhfoo
+#define foothreadedwatchhfoo
+
+/* $Id$ */
+
+/***
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+ Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+/** \file thread-watch.h Threaded poll() based main loop implementation */
+
+#include <sys/poll.h>
+#include <avahi-common/cdecl.h>
+#include <avahi-common/watch.h>
+
+AVAHI_C_DECL_BEGIN
+
+/** A main loop object that runs an AvahiSimplePoll in its own thread. \since 0.6.4 */
+typedef struct AvahiThreadedPoll AvahiThreadedPoll;
+
+/** Create a new event loop object. This will allocate the internal
+ * AvahiSimplePoll, but will not start the helper thread. \since 0.6.4 */
+AvahiThreadedPoll *avahi_threaded_poll_new(void);
+
+/** Free an event loop object. This will stop the associated event loop
+ * thread (if it is running). \since 0.6.4 */
+void avahi_threaded_poll_free(AvahiThreadedPoll *p);
+
+/** Return the abstracted poll API object for this event loop
+ * object. The will return the same pointer each time it is
+ * called. \since 0.6.4 */
+const AvahiPoll* avahi_threaded_poll_get(AvahiThreadedPoll *p);
+
+/** Start the event loop helper thread. After the thread has started
+ * you must make sure to access the event loop object
+ * (AvahiThreadedPoll, AvahiPoll and all its associated objects)
+ * synchronized, i.e. with proper locking. You may want to use
+ * avahi_threaded_poll_lock()/avahi_threaded_poll_unlock() for this,
+ * which will lock the the entire event loop. Please note that event
+ * loop callback functions are called from the event loop helper thread
+ * with that lock held, i.e. avahi_threaded_poll_lock() calls are not
+ * required from event callbacks. \since 0.6.4 */
+int avahi_threaded_poll_start(AvahiThreadedPoll *p);
+
+/** Request that the event loop quits and the associated thread
+ stops. Call this from outside the helper thread if you want to shut
+ it down. \since 0.6.4 */
+int avahi_threaded_poll_stop(AvahiThreadedPoll *p);
+
+/** Request that the event loop quits and the associated thread
+ stops. Call this from inside the helper thread if you want to shut it
+ down. \since 0.6.4 */
+void avahi_threaded_poll_quit(AvahiThreadedPoll *p);
+
+/** Lock the main loop object. Use this if you want to access the event
+ * loop objects (such as creating a new event source) from anything
+ * else but the event loop helper thread, i.e. from anything else but event
+ * loop callbacks \since 0.6.4 */
+void avahi_threaded_poll_lock(AvahiThreadedPoll *p);
+
+/** Unlock the event loop object, use this as counterpart to
+ * avahi_threaded_poll_lock() \since 0.6.4 */
+void avahi_threaded_poll_unlock(AvahiThreadedPoll *p);
+
+AVAHI_C_DECL_END
+
+#endif
\ No newline at end of file
More information about the Libreoffice-commits
mailing list