summaryrefslogtreecommitdiff
path: root/writerfilter/source/filter/RtfFilter.cxx
AgeCommit message (Collapse)AuthorFilesLines
8 daysmove writerfilter inside swNoel Grandin1-220/+0
writerfilter wants to convert incoming RTF and OOXML files into writer's document model. But it currently has to do so by manipulating the limited subset that we expose through the UNO API. This is both slower and less accurate than having access to the full document model. So move it inside, and then we can strip out various hacks, and optimise imports. Change-Id: Ie1114d28130ef5f9a786531bc552cb8ee7768015 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165953 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-06-04Use getXWeak in writerfilterMike Kaganski1-1/+1
Change-Id: I3e0e68c44750f30bd1998c79dc74a13f2c9ade9b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150886 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-08-18Move tools/diagnose_ex.h to comphelper/diagnose_ex.hxxStephan Bergmann1-1/+1
...so that its TOOLS_WARN_EXCEPTION can be used in comphelper/source/misc/logging.cxx in a follow-up commit. (And while at it, rename from diangose_ex.h to the more appropriate diagnose_ex.hxx. The comphelper module is sufficiently low-level for this immediate use case, so use that at least for now; o3tl might be even more suitable but doesn't have a Library until now. Also, for the immediate use case it would have sufficed to only break DbgGetCaughtException, exceptionToString, TOOLS_WARN_EXCEPTION, TOOLS_WARN_EXCEPTION_IF, and TOOLS_INFO_EXCEPTION out of include/tools/diagnose_ex.h into an additional new include/comphelper/diagnose_ex.hxx, but its probably easier overall to just move the complete include file as is.) Change-Id: I9f3222d4ccf1a9ac29d7eb9ba1530d53e2affaee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138451 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-05-02Just use Any ctor instead of makeAny in writerfilterStephan Bergmann1-2/+2
Change-Id: I3db5381c5dc72f0498171d9e61479ae6763312bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133708 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-11-08use more OUStringLiteral in MediaDescriptorNoel Grandin1-3/+3
Change-Id: I0567d103db8db401c737fed98483912a39352929 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124835 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2020-03-31RTF import: reset writerfilter bit even if the import failsMiklos Vajna1-6/+8
The old code did not handle when e.g. a lang::WrappedTargetRuntimeException is thrown between the set and unset. The DOCX import had the same problem. Change-Id: I7336d08057a875db985e8b647b320abd97c6eb81 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91381 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-03-24ofz#21168 sw,writerfilter: limit writerfilter hack to writerfilterCaolán McNamara1-0/+14
The problem is that at the end of WW8 import, a delete redline is inserted that ends up calling DeleteAndJoin from inside AppendRedline(). A fly is anchored AT_CHAR at (node 46, offset 0) and the deletion goes from (node 46, offset 0) to (node 48, offset 13) hence the special case check in IsDestroyFrameAnchoredAtChar() for the IsInReading() prevents it from being deleted, and then its anchor is still registered at the node 46 when it gets deleted. So try to restrict the WriterfilterHack to writerfilter, so it won't affect WW8 import. Unfortunately this is far less obvious than expected, because import can happen for creating a new file, in which case it's all done via UNO in writerfilter, or when inserting into an existing file, in which case SwReader::Read() is used. The SwDocShell's pMedium can't be used becuse in insert file case it will be the loaded file, not the inserted file. There isn't any obvious alternative to adding a silly UNO property for the writerfilter to use. Change-Id: Ia7fdc9bb1925202f6692ebee6e4b6b1fe50e5345 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90384 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2020-03-05Remove some unused includesMiklos Vajna1-1/+0
Change-Id: I808b7e3f6b580ee6f1876aa06038b5741d7ff6a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90001 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-03-04comphelper: allow simple ad-hoc measuring with ProfileZonesMiklos Vajna1-4/+0
And then remove the manual measuring from the RTF import. Sample output: comphelper::ProfileZone: RtfFilter::filter finished in 180 ms Change-Id: I85e2e12d82ff491a2991a41e5a6f6d1410e12363 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89905 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2019-11-25Turn on clang-format for these filesMiklos Vajna1-46/+40
I (tried to) keep these files consistent locally with astyle in the past, switching to clang-format makes sure that the recent problem with introducing inconsistencies with automatic loplugin rewrites doesn't happen again. Change-Id: I86def0d13a1d16f8cedb7cf9927a48ce14c2b3bf Reviewed-on: https://gerrit.libreoffice.org/83690 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2019-11-22Extend loplugin:external to warn about classesStephan Bergmann1-0/+4
...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend loplugin:external to warn about enums". Cases where free functions were moved into an unnamed namespace along with a class, to not break ADL, are in: filter/source/svg/svgexport.cxx sc/source/filter/excel/xelink.cxx sc/source/filter/excel/xilink.cxx svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx All other free functions mentioning moved classes appear to be harmless and not give rise to (silent, even) ADL breakage. (One remaining TODO in compilerplugins/clang/external.cxx is that derived classes are not covered by computeAffectedTypes, even though they could also be affected by ADL-breakage--- but don't seem to be in any acutal case across the code base.) For friend declarations using elaborate type specifiers, like class C1 {}; class C2 { friend class C1; }; * If C2 (but not C1) is moved into an unnamed namespace, the friend declaration must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither qualified nor a template-id and the declaration is a function or an elaborated-type-specifier, the lookup to determine whether the entity has been previously declared shall not consider any scopes outside the innermost enclosing namespace.") * If C1 (but not C2) is moved into an unnamed namespace, the friend declaration must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882> "elaborated-type-specifier friend not looked up in unnamed namespace". Apart from that, to keep changes simple and mostly mechanical (which should help avoid regressions), out-of-line definitions of class members have been left in the enclosing (named) namespace. But explicit specializations of class templates had to be moved into the unnamed namespace to appease <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of template from unnamed namespace using unqualified-id in enclosing namespace". Also, accompanying declarations (of e.g. typedefs or static variables) that could arguably be moved into the unnamed namespace too have been left alone. And in some cases, mention of affected types in blacklists in other loplugins needed to be adapted. And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is not moved into an unnamed namespace (because it is declared in sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler doesn’t give this warning for types defined in the main .C file, as those are unlikely to have multiple definitions." (<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The warned-about classes also don't have multiple definitions in the given test, so disable the warning when including the .cxx. Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4 Reviewed-on: https://gerrit.libreoffice.org/83239 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-07-31Improved loplugin:stringconstant (now that GCC 7 supports it): writerfilterStephan Bergmann1-1/+1
Change-Id: I79a920d7f2d46f17fa14394120a7cb872013eec9 Reviewed-on: https://gerrit.libreoffice.org/76626 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-06-18loplugin:logexceptionnicely in writerfilterNoel Grandin1-2/+3
Change-Id: Ie01d0e6af6af0cfeb46cdde38f52ab068b64db6b Reviewed-on: https://gerrit.libreoffice.org/74284 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-05-13fix wrong SET/QUERY flags passed to uno::ReferenceNoel Grandin1-1/+1
By creating deleted methods for the wrong calls. Avoids the compiler needing to construct a temporary Change-Id: I3b8c648d6bb22d22827bf74f21ea5a2a17fc0f6a Reviewed-on: https://gerrit.libreoffice.org/72103 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-07-12Add missing sal/log.hxx headersGabor Kelemen1-0/+1
rtl/string.hxx and rtl/ustring.hxx both unnecessarily #include <sal/log.hxx> (and don't make use of it themselves), but many other files happen to depend on it. This is a continuation of commit 6ff2d84ade299cb3d14d4110e4cf1a4b8070c030 to be able to remove those unneeded includes. This commit adds missing headers to every file found by: grep -FwL sal/log.hxx $(git grep -Elw 'SAL_INFO|SAL_INFO_IF|SAL_WARN|SAL_WARN_IF|SAL_DETAIL_LOG_STREAM|SAL_WHERE|SAL_STREAM|SAL_DEBUG') to directories w* x* Change-Id: I27bff44da3d34d24262031c7489e755311599bc5 Reviewed-on: https://gerrit.libreoffice.org/57307 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2018-07-10pass SvStream around by std::unique_ptrNoel Grandin1-2/+2
and give utl::OStreamWrapper a new constructor so that it knows it is taking ownership of the SvStream, which appears to fix several leaks Change-Id: Idcbcca9b81a4f0345fd8b8c8a2f4e84213686a6b Reviewed-on: https://gerrit.libreoffice.org/57187 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-06-08look for unnecessary calls to Reference::is() after an UNO_QUERY_THROWNoel Grandin1-4/+0
Since the previous call would throw if there was nothing to be assigned to the value. Idea from tml. Used the following script to find places: git grep -A3 -n UNO_QUERY_THROW | grep -B3 -F 'is()' Change-Id: I36ba7b00bcd014bdf16c0455ab91056f82194969 Reviewed-on: https://gerrit.libreoffice.org/55417 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tor Lillqvist <tml@collabora.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2018-05-25Improve re-throwing of UNO exceptionsNoel Grandin1-2/+4
(*) if we are already throwing a Wrapped*Exception, get the exception using cppu::getCaughtexception. (*) when catching and then immediately throwing UNO exceptions, use cppu::getCaughtException to prevent exception slicing (*) if we are going to catch an exception and then immediately throw a RuntimeException, rather throw a WrappedTargetRuntimeException and preserve the original exception information. Change-Id: Ia7a501a50ae0e6f4d05186333c8517fdcb17d558 Reviewed-on: https://gerrit.libreoffice.org/54692 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-01-04tdf#42949 Fix some more Include What You Use warningsMiklos Vajna1-1/+1
Change-Id: I2040315707674dc99a37aedb96ac61dca274c13a Reviewed-on: https://gerrit.libreoffice.org/47348 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
2017-12-11loplugin:salcall fix functionsNoel Grandin1-1/+1
since cdecl is the default calling convention on Windows for such functions, the annotation is redundant. Change-Id: I1a85fa27e5ac65ce0e04a19bde74c90800ffaa2d Reviewed-on: https://gerrit.libreoffice.org/46164 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-10-04add << operator for css::uno::ExceptionNoel Grandin1-1/+1
Change-Id: Ia23dafd07133779144965682df3b7125a3214235 Reviewed-on: https://gerrit.libreoffice.org/43046 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
2017-09-07writerfilter: size() > 0 -> !empty() and other small cleanupsMiklos Vajna1-1/+1
Change-Id: I808a3ed8180b6f2164f14d736e2c8dc4bb8948bc Reviewed-on: https://gerrit.libreoffice.org/42037 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
2017-08-25writerfilter: fix inconsistent param naming in interface/implementationMiklos Vajna1-4/+4
Talking about names when those are numbers is confusing. Change-Id: Icfeed8924daeb1d6f658118515f9d4a76229106e Reviewed-on: https://gerrit.libreoffice.org/41540 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
2017-07-03writerfilter: fix indentationMiklos Vajna1-2/+2
Change-Id: Ibc258a02ddb6385fb50206a6cc694f169432bd22
2017-06-28loplugin:oncevar in writerfilter..xmlhelpNoel Grandin1-2/+4
Change-Id: I1319494e16586f7e0b5149faecd3d1c36e336b1b Reviewed-on: https://gerrit.libreoffice.org/39343 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-02-15writerfilter: can use std::move() hereMiklos Vajna1-3/+3
Change-Id: I48980ae44cd68b9526d915f877a37f6a559910e5
2017-01-26Remove dynamic exception specificationsStephan Bergmann1-16/+16
...(for now, from LIBO_INTERNAL_CODE only). See the mail thread starting at <https://lists.freedesktop.org/archives/libreoffice/2017-January/076665.html> "Dynamic Exception Specifications" for details. Most changes have been done automatically by the rewriting loplugin:dynexcspec (after enabling the rewriting mode, to be committed shortly). The way it only removes exception specs from declarations if it also sees a definition, it identified some dead declarations-w/o-definitions (that have been removed manually) and some cases where a definition appeared in multiple include files (which have also been cleaned up manually). There's also been cases of macro paramters (that were used to abstract over exception specs) that have become unused now (and been removed). Furthermore, some code needed to be cleaned up manually (avmedia/source/quicktime/ and connectivity/source/drivers/kab/), as I had no configurations available that would actually build that code. Missing @throws documentation has not been applied in such manual clean-up. Change-Id: I3408691256c9b0c12bc5332de976743626e13960 Reviewed-on: https://gerrit.libreoffice.org/33574 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-11-24loplugin:unnecessaryoverride (dtors) in writerfilterStephan Bergmann1-3/+0
Change-Id: I2d21d47e8471daf3125a6c81b5b3919820caef46
2016-06-15writerfilter: clean up virtual keywords where override already implies thatMiklos Vajna1-9/+9
Change-Id: I04938ceba4e4740535caee396ca8e13ca50a003c Reviewed-on: https://gerrit.libreoffice.org/26288 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
2016-05-20writerfilter: use '= default;'Miklos Vajna1-3/+1
Replace default bodies of these trivial special member functions. Also remove RTFSprms::operator=() as it matches what the compiler would generate anyway. Change-Id: Ib5e30dfdd9b428a6d7800cec056c3f55ca92f4a4 Reviewed-on: https://gerrit.libreoffice.org/25187 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
2016-04-20loplugin:salbool: Automatic rewrite of sal_False/TrueStephan Bergmann1-2/+2
Change-Id: I5f38167cc2fd0104ad388c63f766bda6acae96e2
2016-02-23tdf#59699 RTF import: handle INCLUDEPICTURE fieldMiklos Vajna1-1/+1
On one hand, don't handle a fieldmark for it in dmapper. On the other hand, handle the field in the RTF tokenizer as it would be {\pict ...hexdump... }, that will result in an inline picture, as wanted. Change-Id: I554fdf017920350144300fd86617bf74eed8995b
2016-01-30Remove unused includesMiklos Vajna1-1/+0
Change-Id: I38784900d5b4fcf99d5fc881f0ec7a9833fe2d5b Reviewed-on: https://gerrit.libreoffice.org/21917 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
2015-10-19writerfilter: dmapper ctor can read TextInsertModeRange directlyMiklos Vajna1-3/+1
Change-Id: If17ae09266134b4bc410eab1a1b2f5139ba93a12
2015-10-12Replace "SAL_OVERRIDE" with "override" in LIBO_INTERNAL_ONLY codeStephan Bergmann1-8/+8
Change-Id: I2ea407acd763ef2d7dae2d3b8f32525523ac8274
2015-08-18this debugging code can definitely use oslCaolán McNamara1-3/+3
Change-Id: I420e7f242868a25a2f9a473c23c67dfd9a285b7c
2015-05-12tdf#90260 writerfilter: pasted RTF documents may contain no \parMiklos Vajna1-1/+2
sw core is not yet adapted, will be done in the next commit. Change-Id: If8da12427e0cdaced4c1c1776b9f0b8cbde5c57c
2015-05-04writerfilter: noExplicitConstructor cppcheck fixesMiklos Vajna1-1/+1
Change-Id: I4195fc8a7736a29a6f08d0745f39a0907a5545e8
2015-02-21writerfilter: clean up RtfFilterMiklos Vajna1-27/+57
Change-Id: I4bcff4ddde2869a4aeecfdfda02c685d61d65531
2015-02-19writerfilter: use constructor for writerfilter moduleChris Sherlock1-3/+4
Change-Id: Iada80d2c6989de2811cf35cb288a430e2eeba8e9 Reviewed-on: https://gerrit.libreoffice.org/14536 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
2015-02-08writerfilter: make sure that these headers are self-containedMiklos Vajna1-1/+1
Change-Id: I3486e8ba5f6d2a937176c9fe549d707a97eb5655
2015-01-25Use std::initializer_list ctorMiklos Vajna1-5/+6
Change-Id: I5ce7b48a3c867fe8c5fdbe0f6fc8e3f33e457082 Reviewed-on: https://gerrit.libreoffice.org/14169 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
2015-01-07fdo#84938: convert STREAM_ #defines to 'enum class'Noel Grandin1-2/+2
Change-Id: Ibbf14c7e9a5c1883c1311d4c86f948f74f8e473e
2014-12-28RtfFilter::filter: don't leak pInMiklos Vajna1-5/+4
Change-Id: I2510cd7faa48c0287498bdbc2511e29dbc62860a
2014-12-25writerfilter: turn SourceDocumentType into a C++11 scoped enumerationMiklos Vajna1-1/+2
Change-Id: I11c550d0ec5a10f17116ac8f7025c0283e292f2e
2014-12-20writerfilter: clean up copy&pasted dmapper_logger start / endMiklos Vajna1-14/+0
Change-Id: Iacae41a32acec153b1db1e1a03b2f2913d114d9b
2014-12-20writerfilter: pass the whole MediaDescriptor to dmapperMiklos Vajna1-1/+1
This gives dmapper access to the document URL. Change-Id: I4844c2fe97815f788de87b53170d4a1d1faebde8
2014-12-15Unused includesMiklos Vajna1-1/+0
Change-Id: I84e475a64cf09e4eeea524b73f8febf7f0a1a46b
2014-12-12writerfilter: add a factory for DomainMapperMiklos Vajna1-2/+3
Ideally the XFilter implementations should only know that DomainMapper implements Stream, nothing more. Add a factory and use it in RtfFilter. When ImportFilter will do the same, then the DomainMapper class definition can be an implementation detail. Change-Id: If19cf23e61c2f78189d834261d57c569b9173b12
2014-11-17sal: clean up public headers with include-what-you-useMichael Stahl1-0/+1
Sadly cannot forward declare "struct {...} TimeValue;". rtl/(u)?string.hxx still include sal/log.hxx but removing osl/diagnose.h was painful enough for now... Change-Id: Id41e17f3870c4f24c53ce7b11f2c40a3d14d1f05