Commit Graph

105 Commits

Author SHA1 Message Date
Kohei Yoshida
a09a709594 Prevent hang during loading of xlsm doc.
* We need to call xmlInitParser() before using it in a multi-threaded
  way (according to the libxml2 doc).
* Better to use 'rEntity' which references the one stored in the vector
  rather than 'entity' whose copy gets stored in the vector. On Windows
  at least 'rEntity' and 'entity' hold different parser pointer values.
* Free the parser before popping the entity. Popping the entity first then
  freeing the parser using its pointer value stored in the entity looks
  weird.

Change-Id: I6b64a6d8ac9c1d4fea8339d8fb2d38dfffbba47b
2014-12-03 19:52:23 -05:00
Caolán McNamara
4a757923fe fix crash-190212-093017-986
Change-Id: I3d2d57850dcb1fde1c004b4455591071a1fe03fa
2014-12-02 14:53:01 +00:00
Kohei Yoshida
285cd8301c We need to tell libxml2 parser to decode entities.
Else we would get raw entity values such as '&' in lieu of '&'.

Change-Id: Ib700705fd9b68980306883aa9652579e1686040d
2014-12-01 22:26:05 -05:00
Matúš Kukan
373daf55d9 Add message to exception
Change-Id: I0e7cf850b51343e4afc1ea0a0409ad2c4e596435
2014-12-01 15:14:16 +01:00
Luboš Luňák
1307c65d74 proper error reporting from libxml2
Change-Id: Ia173f7f4c88c90b6d54c9a47d6ae18b933502678
2014-11-20 18:43:48 +01:00
Luboš Luňák
0df9ac47df make FastSaxParser provide the whole content in one characters() call
SAX interface is not required to provide the whole node content in one
characters() call (e.g. if there's an entity that needs decoding). However
it's easier to consumers to assume this (e.g. writerfilter's
DomainMapper::lcl_utext() handles datecontrol that way), and expat apparently
never used this. However this can happen with libxml2, so ensure such consumers
still work.

Change-Id: Ib564f372fbea8451f84553a6d49a07d091a950e9
2014-11-20 18:43:44 +01:00
Markus Mohrhard
169562ff26 windows blind fix 2014-11-15 12:23:04 +01:00
Luboš Luňák
82d08580e3 switch saxparser from expat to libxml2
Using SAX2 interface provides element/attribute names split into prefix/name,
and provides namespaces/urls, so FastSaxParserImpl::callbackStartElement()
does not have to figure out these on its own (and additionally libxml2
spends a noticeable portion in xmlStrdup() when not in SAX2 mode).
The switch saves about 5-10% time.

Change-Id: Idd424d7cc9b30c248179a5bad8ec79dbfc62e765
2014-11-14 17:20:00 +01:00
Luboš Luňák
6df3d5e93a remove pointless const_cast
Change-Id: I6026ab64f0cfe1d509c8f94ce3b9c6f700c823cf
2014-11-10 21:23:02 +01:00
Michael Meeks
e1c503a2e3 fastparser: avoid allocating un-used FastTokenLookup class.
This contained an rtl_Sequence complete with horror internal
allocator, caught red-handed serializing threaded loading to no
good purpose.

Change-Id: I837b2c17e4f70fd6a49bed33ad74a7d79f98f35c
2014-10-23 11:53:17 +02:00
Matúš Kukan
d7350545ac Better to throw than crash, if token handler is not set.
Change-Id: If6b2d39b487b5f673d5b6b2945a6e7d08777594e
2014-09-18 15:34:26 +02:00
Matúš Kukan
59f1e330f0 Use plain bool parameter here
Change-Id: Ic948889a0fac32adc48a7a4fb1e7f82ce8b08ba4
2014-08-30 09:20:44 +02:00
Stephan Bergmann
f740673ed7 Avoid incomplete type in fn sig to keep ubsan's RTTI-based checks happy
Change-Id: I2d4e4be562cc752e7545792b148d5ed0cf551f25
2014-08-07 18:35:59 +02:00
Michael Meeks
9af1cbf233 fdo#81214 - tolerate exceptions thrown inside XFastParser callbacks.
Not an ideal solution; ideally we should not throw the exceptions,
and stop the parser as soon as something bad like this happens; but
hopefully exception throwing is reasonable exceptional.

Change-Id: If619592533b2929c671e2b03eb8a83480bd92c54
2014-07-11 20:51:18 +01:00
Kohei Yoshida
dc93074f71 Use a new fast parser instance for each XML fragment.
Otherwise a crash ensues when the threaded XML parsing kicks in.

Change-Id: Ic41e5a29bbb860d7b63b70f2f0d8896264d9d53e
2014-06-30 20:06:33 -04:00
Kohei Yoshida
3f177756db Check for empty() before calling top().
Else it might crash sometimes.

Change-Id: I6a24fff83c3d36346debae5c0f2b8c0646a15c01
2014-06-30 14:02:50 -04:00
Kohei Yoshida
3ede68e1cc Don't go further and pop the stack if it's empty.
Change-Id: I27bd30ca65cf0066cd022b4b060757913ea01fed
2014-06-30 13:46:36 -04:00
Stephan Bergmann
a39ced415f Remove unused functions
Change-Id: Iddf4e29005aaa510af00c7345487996b75f41c41
2014-04-09 11:12:41 +02:00
Stephan Bergmann
70cc2b191b First batch of adding SAL_OVERRRIDE to overriding function declarations
...mostly done with a rewriting Clang plugin, with just some manual tweaking
necessary to fix poor macro usage.

Change-Id: I71fa20213e86be10de332ece0aa273239df7b61a
2014-03-26 16:39:26 +01:00
Markus Mohrhard
54ebae0eae remove whitespaces
Change-Id: I624ca41c3e51ba785e359649c429feb61cc9a647
2014-03-02 17:56:14 +01:00
Stephan Bergmann
5e21a413c7 cppuhelper: retrofit std::exception into overriding exception specs
Change-Id: I56e32131b7991ee9948ce46765632eb823d463b3
2014-02-26 18:22:20 +01:00
Alexander Wilms
ff0562fa4f Remove visual noise from sax
Change-Id: Ica31580f72b43456c33b2f6abbf2140a79efae1a
Reviewed-on: https://gerrit.libreoffice.org/8299
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
2014-02-26 08:02:52 -06:00
Alexander Wilms
0ce0c369aa Remove unneccessary comments
Change-Id: I939160ae72fecbe3d4a60ce755730bd4c38497fb
Reviewed-on: https://gerrit.libreoffice.org/8182
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
2014-02-23 03:38:49 +00:00
Caolán McNamara
12e0102f39 coverity#1130446 Uncaught exception
Change-Id: I9225b4ffd507fa3d666862a55dae349c9a76e91d
2014-02-08 20:52:41 +00:00
Caolán McNamara
7106e437bc 1158273 Uncaught exception
Change-Id: I3983da2d585762d81446902a710e9a97c6354669
2014-01-25 12:28:07 +00:00
Caolán McNamara
c5135af60f coverity#1158443 Uninitialized pointer field
Change-Id: I1602678c24c1aeec60acee05801e7decc914560f
2014-01-23 16:16:43 +00:00
Caolán McNamara
be090d5a50 coverity#1158444 Uninitialized scalar field
Change-Id: I15f6c6288e2a951543702a15e777167f2240899e
2014-01-23 16:14:49 +00:00
Jan Holesovsky
c2c530da69 Introduce static inline cppu::acquire(), and make use of that.
This is much better approach compared to the callback function, as it allows
passing arguments to the c++ constructor directly, while still allowing some
additional initialization after having acquired the instance.

Change-Id: I5a0f981915dd58f1522ee6054e53a3550b29d624
2014-01-22 15:09:28 +01:00
Jan Holesovsky
f278397787 Change _get_implementation()'s not to do initialization directly.
Many of the initalizations (in eg. framework) have to be done on an
acquire()'d object, so instead of doing the initialization directly, return
the initialization member function back to the createInstance() /
createInstanceWithContext() / ... and perform the initialization there.

As a sideeffect, I belive the calling initialize() from servicemanager is not
that much a hack any more - whoever converts the implementation to be
constructor-base has the choice to provide the callback, or still initialize
through XInitialization, where the callback is preferred by servicemanager
when it exists.

Change-Id: I8a87b75c54c1441ca0f184967d31ff4902fc4081
2014-01-21 21:25:22 +01:00
Jan Holesovsky
306efefe22 Minimize the constructor functions to a bare minimum.
Most of the constructors are supposed to be only a call of

  new TheInstance(arguments)

or an equivalent; so let's just change the constructor caller accordingly, to
accept unacquired new instance.

If there are exceptions that need to do more heavy lifting, they do not have
to use the constructor feature, or there can be a wrapper for the real
implementation, doing the additional work in their (C++) constructor.

Change-Id: I035c378778aeda60d15af4e56ca3761c586d5ded
2014-01-20 17:37:40 +01:00
Matúš Kukan
73eca35b0a Unify ctor functions for component implementations.
There is no need to use different styles for writing the same thing.
It also makes it easier in future to use search & replace.
But of course, there are also some more complicated functions.

Change-Id: I773da20378af0e0d5a27689d3903df7063fb8ac0
2014-01-18 17:02:40 +01:00
Matúš Kukan
a700ce8e2b Unify ctor functions to have _get_implementation suffix.
Change-Id: I07fe0671d0633ef9480a4f3431df6a64c7902db8
2014-01-15 15:12:01 +01:00
Matúš Kukan
4337a0664f Use const& arguments parameter for ctor functions.
Change-Id: I19ce8bd1a23123ac9a62a7fc95cd54fea5315221
2014-01-15 08:51:27 +01:00
Michael Meeks
91570fc3f3 fastparser: avoid boost::optional where it is un-necessary.
boost::optional appears to show up rather heavily on many profiles.
We already use mnElementToken == DONTKNOW to flag / use these guys.

Change-Id: Ibf2b0167f259cc601da2fb9703e880b78e60886e
2014-01-14 15:52:11 +00:00
Stephan Bergmann
fb9470825c Use bool
Change-Id: Iae455f53f8317eecb8edc38d111c9ef7398a36fb
2014-01-10 17:11:48 +01:00
Tor Lillqvist
308fdfb1a9 WaE: C4101: 'e' : unreferenced local variable
Change-Id: I06c0f9dc742736f632ed9210ae954e0dc19ca19d
2014-01-03 11:54:30 +02:00
Caolán McNamara
c6aea0bac0 don't call top on an empty stack
Change-Id: Ibe4b4d3785535816b40d46fd0baa60f01e1f9d33
2013-12-31 19:48:17 +00:00
Michael Meeks
4754b8ac50 fastparser: avoid std::stack::top() - cache it's results.
amazingly std::stack::top() takes 146 pseudo-cycles to do not much,
so instead cache the result in a single pointer in lieu of burning
that code.

Change-Id: Ie326be47da6cbad0850e5f1026a1632bb840b6b8
2013-12-31 14:06:21 +00:00
Michael Meeks
838a6011c1 fastparser: move lclGetErrorMessage into the anonymous namespace.
Change-Id: I70e1597f917c2a8dedb5b38807dfde7ec05a1a39
2013-12-20 16:45:15 +00:00
Michael Meeks
169eb25c86 fastparser:: move Entity:: code into the anonymous namespace.
Change-Id: I564e35aa63e4c01cc1a0fb45f674dc1a2a0e89ec
2013-12-20 16:37:03 +00:00
Michael Meeks
59003de73e fastparser: fix load regression
Remove erroneous assert: maSavedException is indeed empty for
XML parser reported exceptions. Clean cut/paste code, and comment.

Change-Id: Ia538bcc87a7efcd079d3021e00ac4d2eb62f3e8d
2013-12-20 16:21:43 +00:00
Stephan Bergmann
ae3a0c8da5 Add .component <implementation constructor="..." feature
...to directly call constructor functions of ComponentContext-based C++
implementations of (non-single-instance) UNO services.  The case where these
calls would need to be bridged across different environments (e.g., from gcc3
to gcc3:affine) is not yet implemented.

bootstrap.component and expwrap.component are adapted accordingly as a proof-of-
concept (which had previously been adapted to use the prefix="direct" feature,
which may become unnecessary again in the end, depending on how to handle
single-instance services/singletons).  More to follow.

Change-Id: I18682d75bcd29d3d427e31331b4ce8161dbb846d
2013-12-19 08:48:56 +01:00
Stephan Bergmann
71f33636da Change from ServiceManager- to ComponentContext-based implementations
Change-Id: Iba701c520ad27925bb5e67697e22132b53160ab2
2013-12-18 11:13:58 +01:00
Matúš Kukan
291e846db9 sax: various clean up. Move _getFactory next to the implementation.
Use more anonymous namespaces, de-duplicate code, bin some comments.
Makes the library smaller.

Change-Id: Id0cefdcaa72a74741303fc27e36038488ef8b059
2013-12-18 07:15:48 +01:00
Marcos Paulo de Souza
eebc1e9a8a fdo#60698: Merge fastsax and sax_shared into expwrap
Change-Id: I6f8c6827c00db50184a46f39968f882b944d18d4
Reviewed-on: https://gerrit.libreoffice.org/6967
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org>
2013-12-11 20:45:30 +00:00
Michael Stahl
b6785eb595 sax: stop using SAX_DLLIMPLEMENTATION for both sax and fastsax
Change-Id: I243ec20015beec6b98ee0af55eb7c387008f32f1
2013-12-03 13:29:35 +01:00
Markus Mohrhard
223fb84c0b no inheritance so no virtual needed
Change-Id: Ia6c481bbf5353db4c2801a53ae1455534c6978bd
2013-12-03 05:56:24 +01:00
Kohei Yoshida
4afa538b7b Hide the implementation.
Change-Id: Ibfd9bf626a40c3ec4eb18d09944e8943163595c8
2013-12-02 23:04:39 -05:00
Kohei Yoshida
532b2f4818 Add a means to check if a namespace exists.
Useful when we just need to check if the stream has a certain namespace
defined. Calling getNamespaceURL() may throw SAXException in such case.

Change-Id: Ib2b7b202492390158270d87bab95d1793c9d8a70
2013-12-02 19:32:28 -05:00
Kohei Yoshida
2130fd9d61 Move this header out into a public place.
Change-Id: I356b26947d1018276d8a9ff6012fdad3ca2c0fd8
2013-12-02 19:32:28 -05:00