diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-03-12 12:43:10 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-03-25 14:35:46 +0100 |
commit | 0185241456971f06a7795fb4f304317027f50db9 (patch) | |
tree | 8cafdcb8db8449ad7e3abcbb7d530f094e544b6d /sw | |
parent | 3d264dc8742733a797a3e315033851d0bda3bffd (diff) |
ofz#21168 sw,writerfilter: limit writerfilter hack to writerfilter
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>
(cherry picked from commit c4dab726caaa73be9f9c731312080143b0a0b89d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90951
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/doc.hxx | 3 | ||||
-rw-r--r-- | sw/inc/unomap.hxx | 1 | ||||
-rw-r--r-- | sw/qa/core/data/ww6/pass/ofz21168-1.doc | bin | 0 -> 35098 bytes | |||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 1 | ||||
-rw-r--r-- | sw/source/core/undo/undobj.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/unocore/unomap.cxx | 1 | ||||
-rw-r--r-- | sw/source/filter/basflt/shellio.cxx | 7 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 12 |
8 files changed, 27 insertions, 2 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index c5075b20f844..b80e1157a7c9 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -301,6 +301,7 @@ private: bool mbInReading : 1; //< TRUE: Document is in the process of being read. bool mbInMailMerge : 1; //< TRUE: Document is in the process of being written by mail merge. bool mbInXMLImport : 1; //< TRUE: During xml import, attribute portion building is not necessary. + bool mbInWriterfilterImport : 1; //< TRUE: writerfilter import (DOCX,RTF) bool mbUpdateTOX : 1; //< TRUE: After loading document, update TOX. bool mbInLoadAsynchron : 1; //< TRUE: Document is in the process of being loaded asynchronously. bool mbIsAutoFormatRedline : 1; //< TRUE: Redlines are recorded by Autoformat. @@ -962,6 +963,8 @@ public: bool IsInXMLImport() const { return mbInXMLImport; } void SetInXMLImport( bool bNew ) { mbInXMLImport = bNew; } + bool IsInWriterfilterImport() const { return mbInWriterfilterImport; } + void SetInWriterfilterImport(bool const b) { mbInWriterfilterImport = b; } // Manage types of tables/indices sal_uInt16 GetTOXTypeCount( TOXTypes eTyp ) const; diff --git a/sw/inc/unomap.hxx b/sw/inc/unomap.hxx index 36f8766e0e03..caee6bc5c209 100644 --- a/sw/inc/unomap.hxx +++ b/sw/inc/unomap.hxx @@ -245,6 +245,7 @@ struct SfxItemPropertyMapEntry; #define WID_DOC_LOCK_UPDATES 1016 #define WID_DOC_HAS_VALID_SIGNATURES 1017 #define WID_DOC_INTEROP_GRAB_BAG 1018 +#define WID_DOC_WRITERFILTER 1019 #define WID_DOC_BUILDID 1024 #define WID_DOC_ISTEMPLATEID 1025 #define WID_DOC_DEFAULT_PAGE_MODE 1069 diff --git a/sw/qa/core/data/ww6/pass/ofz21168-1.doc b/sw/qa/core/data/ww6/pass/ofz21168-1.doc Binary files differnew file mode 100644 index 000000000000..3bafb1d36bf7 --- /dev/null +++ b/sw/qa/core/data/ww6/pass/ofz21168-1.doc diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 21d250ce59c3..984f2335bc45 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -242,6 +242,7 @@ SwDoc::SwDoc() mbInReading(false), mbInMailMerge(false), mbInXMLImport(false), + mbInWriterfilterImport(false), mbUpdateTOX(false), mbInLoadAsynchron(false), mbIsAutoFormatRedline(false), diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index 378df9595e50..3b3f8f2fd583 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -1555,7 +1555,7 @@ bool IsDestroyFrameAnchoredAtChar(SwPosition const & rAnchorPos, } if ((nDelContentType & DelContentType::WriterfilterHack) - && rAnchorPos.GetDoc()->IsInReading()) + && rAnchorPos.GetDoc()->IsInWriterfilterImport()) { // FIXME hack for writerfilter RemoveLastParagraph() and MakeFlyAndMove(); can't test file format more specific? return (rStart < rAnchorPos) && (rAnchorPos < rEnd); } @@ -1592,7 +1592,7 @@ bool IsSelectFrameAnchoredAtPara(SwPosition const & rAnchorPos, } if ((nDelContentType & DelContentType::WriterfilterHack) - && rAnchorPos.GetDoc()->IsInReading()) + && rAnchorPos.GetDoc()->IsInWriterfilterImport()) { // FIXME hack for writerfilter RemoveLastParagraph() and MakeFlyAndMove(); can't test file format more specific? // but it MUST NOT be done during the SetRedlineFlags at the end of ODF // import, where the IsInXMLImport() cannot be checked because the diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index 4bba72a38fee..05695e8585b2 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -672,6 +672,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s { OUString(UNO_NAME_APPLY_FORM_DESIGN_MODE), WID_DOC_APPLY_FORM_DESIGN_MODE, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, { OUString(UNO_NAME_RUNTIME_UID), WID_DOC_RUNTIME_UID, cppu::UnoType<OUString>::get(), PropertyAttribute::READONLY, 0}, { OUString(UNO_NAME_LOCK_UPDATES), WID_DOC_LOCK_UPDATES, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, + { OUString("UndocumentedWriterfilterHack"), WID_DOC_WRITERFILTER, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, { OUString(UNO_NAME_HAS_VALID_SIGNATURES), WID_DOC_HAS_VALID_SIGNATURES, cppu::UnoType<bool>::get(), PropertyAttribute::READONLY, 0}, { OUString(UNO_NAME_BUILDID), WID_DOC_BUILDID, cppu::UnoType<OUString>::get(), 0, 0}, { OUString(UNO_NAME_DOC_INTEROP_GRAB_BAG), WID_DOC_INTEROP_GRAB_BAG, cppu::UnoType< cppu::UnoSequenceType<css::beans::PropertyValue> >::get(), PROPERTY_NONE, 0 }, diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index 708e13c2535b..cba064de3e09 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -25,6 +25,7 @@ #include <svl/fstathelper.hxx> #include <unotools/moduleoptions.hxx> #include <sfx2/docfile.hxx> +#include <sfx2/docfilt.hxx> #include <editeng/lrspitem.hxx> #include <editeng/ulspitem.hxx> #include <editeng/boxitem.hxx> @@ -36,6 +37,7 @@ #include <fmtpdsc.hxx> #include <swtypes.hxx> #include <shellio.hxx> +#include <iodetect.hxx> #include <doc.hxx> #include <IDocumentUndoRedo.hxx> #include <IDocumentSettingAccess.hxx> @@ -104,6 +106,10 @@ ErrCode SwReader::Read( const Reader& rOptions ) mxDoc->SetInReading( true ); mxDoc->SetInXMLImport( dynamic_cast< XMLReader* >(po) != nullptr ); + mxDoc->SetInWriterfilterImport(pMedium && pMedium->GetFilter() + && (pMedium->GetFilter()->GetUserData() == FILTER_RTF + || pMedium->GetFilter()->GetUserData() == sRtfWH + || pMedium->GetFilter()->GetUserData() == FILTER_DOCX)); SwPaM *pPam; if( pCursor ) @@ -341,6 +347,7 @@ ErrCode SwReader::Read( const Reader& rOptions ) mxDoc->SetInReading( false ); mxDoc->SetInXMLImport( false ); + mxDoc->SetInWriterfilterImport(false); mxDoc->InvalidateNumRules(); mxDoc->UpdateNumRule(); diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 9060ac40172a..2e172dbf6488 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -1979,7 +1979,19 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any& SwDoc* pDoc = pDocShell->GetDoc(); bool bBool (false); if( aValue >>= bBool ) + { pDoc->SetInReading( bBool ); + } + } + break; + case WID_DOC_WRITERFILTER: + { + SwDoc* pDoc = pDocShell->GetDoc(); + bool bBool = {}; + if (aValue >>= bBool) + { // HACK: writerfilter has to use API to set this :( + pDoc->SetInWriterfilterImport(bBool); + } } break; case WID_DOC_BUILDID: |