diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-11-28 15:14:45 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-11-28 16:50:43 +0100 |
commit | 4fb7967fb2e67717f79eb87519c1444a82350a83 (patch) | |
tree | 0d085b4c234d2887836ea6559bb9c4ae93045afe /sw/inc | |
parent | 0d678951df5bb5daa2d77600f5f8682a55d6f00e (diff) |
Revert "tdf#129183 sw: textboxes in group shapes - part 3"
This reverts commit eabcfb3f18a6944d9ad89cecd3eb3ca7a2259cf3.
Conflicts:
sw/source/core/doc/textboxhelper.cxx
It caused UITest_writer_tests4 to fail in an ASan build with
> ==2987325==ERROR: AddressSanitizer: heap-use-after-free on address 0x6130000e5048 at pc 0x7f20cb3112ac bp 0x7f1e62de92d0 sp 0x7f1e62de92c8
> WRITE of size 8 at 0x6130000e5048 thread T47
> #0 in SwFrameFormat::SetOtherTextBoxFormat(SwTextBoxNode*) at sw/inc/frmfmt.hxx:106:77
> #1 in SwTextBoxNode::~SwTextBoxNode() at sw/source/core/doc/textboxhelper.cxx:1680:30
> #2 in SwFrameFormat::~SwFrameFormat() at sw/source/core/layout/atrfrm.cxx:2564:9
> #3 in SwDrawFrameFormat::~SwDrawFrameFormat() at sw/source/core/layout/atrfrm.cxx:3455:1
> #4 in SwDrawFrameFormat::~SwDrawFrameFormat() at sw/source/core/layout/atrfrm.cxx:3453:1
> #5 in SwFrameFormats::DeleteAndDestroyAll(bool) at sw/source/core/doc/docfmt.cxx:2115:9
> #6 in SwDoc::~SwDoc() at sw/source/core/doc/docnew.cxx:565:28
> #7 in SwDoc::release() at sw/source/core/doc/doc.cxx:118:9
> #8 in rtl::Reference<SwDoc>::clear() at include/rtl/ref.hxx:196:19
> #9 in SwDocShell::RemoveLink() at sw/source/uibase/app/docshini.cxx:444:16
> #10 in SwDocShell::~SwDocShell() at sw/source/uibase/app/docshini.cxx:372:5
> #11 in SwDocShell::~SwDocShell() at sw/source/uibase/app/docshini.cxx:362:1
> #12 in SwDocShell::~SwDocShell() at sw/source/uibase/app/docshini.cxx:362:1
> #13 in SvRefBase::ReleaseRef() at include/tools/ref.hxx:163:29
> #14 in tools::SvRef<SfxObjectShell>::~SvRef() at include/tools/ref.hxx:56:36
> #15 in IMPL_SfxBaseModel_DataContainer::~IMPL_SfxBaseModel_DataContainer() at sfx2/source/doc/sfxbasemodel.cxx:245:5
> #16 in void std::destroy_at<IMPL_SfxBaseModel_DataContainer>(IMPL_SfxBaseModel_DataContainer*) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/stl_construct.h:88:15
> #17 in void std::allocator_traits<std::allocator<IMPL_SfxBaseModel_DataContainer> >::destroy<IMPL_SfxBaseModel_DataContainer>(std::allocator<IMPL_SfxBaseModel_DataContainer>&, IMPL_SfxBaseModel_DataContainer*) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/alloc_traits.h:537:4
> #18 in std::_Sp_counted_ptr_inplace<IMPL_SfxBaseModel_DataContainer, std::allocator<IMPL_SfxBaseModel_DataContainer>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:528:2
> #19 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:168:6
> #20 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:705:11
> #21 in std::__shared_ptr<IMPL_SfxBaseModel_DataContainer, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:1154:31
> #22 in std::__shared_ptr<IMPL_SfxBaseModel_DataContainer, (__gnu_cxx::_Lock_policy)2>::reset() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:1272:9
> #23 in SfxBaseModel::dispose() at sfx2/source/doc/sfxbasemodel.cxx:757:13
> #24 in SwXTextDocument::dispose() at sw/source/uibase/uno/unotxdoc.cxx:549:19
> #25 in SfxBaseModel::close(unsigned char) at sfx2/source/doc/sfxbasemodel.cxx:1482:5
> #26 in SwXTextDocument::close(unsigned char) at sw/source/uibase/uno/unotxdoc.cxx:562:19
> #27 in SfxBaseModel::dispose() at sfx2/source/doc/sfxbasemodel.cxx:718:13
> #28 in SwXTextDocument::dispose() at sw/source/uibase/uno/unotxdoc.cxx:549:19
> #29 in gcc3::callVirtualMethod(void*, unsigned int, void*, _typelib_TypeDescriptionReference*, bool, unsigned long*, unsigned int, unsigned long*, double*) at bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx:77:5
> #30 in cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy*, bridges::cpp_uno::shared::VtableSlot, _typelib_TypeDescriptionReference*, int, _typelib_MethodParameter*, void*, void**, _uno_Any**) at bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:233:13
> #31 in unoInterfaceProxyDispatch at bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx:413:13
> #32 in binaryurp::IncomingRequest::execute_throw(binaryurp::BinaryAny*, std::__debug::vector<binaryurp::BinaryAny, std::allocator<binaryurp::BinaryAny> >*) const at binaryurp/source/incomingrequest.cxx:235:13
> #33 in binaryurp::IncomingRequest::execute() const at binaryurp/source/incomingrequest.cxx:78:26
> #34 in request at binaryurp/source/reader.cxx:85:9
> #35 in cppu_threadpool::JobQueue::enter(void const*, bool) at cppu/source/threadpool/jobqueue.cxx:100:17
> #36 in cppu_threadpool::ORequestThread::run() at cppu/source/threadpool/thread.cxx:164:31
> #37 in threadFunc at include/osl/thread.hxx:189:15
> #38 in osl_thread_start_Impl(void*) at sal/osl/unx/thread.cxx:264:9
> #39 in start_thread at <null>
> #40 in __GI___clone3 at <null>
>
> 0x6130000e5048 is located 328 bytes inside of 376-byte region [0x6130000e4f00,0x6130000e5078)
> freed by thread T47 here:
> #0 in operator delete(void*, unsigned long) at ~/github.com/llvm/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:164:3
> #1 in SwFlyFrameFormat::~SwFlyFrameFormat() at sw/source/core/layout/atrfrm.cxx:2912:1
> #2 in SwFrameFormats::DeleteAndDestroyAll(bool) at sw/source/core/doc/docfmt.cxx:2115:9
> #3 in SwDoc::~SwDoc() at sw/source/core/doc/docnew.cxx:565:28
> #4 in SwDoc::release() at sw/source/core/doc/doc.cxx:118:9
> #5 in rtl::Reference<SwDoc>::clear() at include/rtl/ref.hxx:196:19
> #6 in SwDocShell::RemoveLink() at sw/source/uibase/app/docshini.cxx:444:16
> #7 in SwDocShell::~SwDocShell() at sw/source/uibase/app/docshini.cxx:372:5
> #8 in SwDocShell::~SwDocShell() at sw/source/uibase/app/docshini.cxx:362:1
> #9 in SwDocShell::~SwDocShell() at sw/source/uibase/app/docshini.cxx:362:1
> #10 in SvRefBase::ReleaseRef() at include/tools/ref.hxx:163:29
> #11 in tools::SvRef<SfxObjectShell>::~SvRef() at include/tools/ref.hxx:56:36
> #12 in IMPL_SfxBaseModel_DataContainer::~IMPL_SfxBaseModel_DataContainer() at sfx2/source/doc/sfxbasemodel.cxx:245:5
> #13 in void std::destroy_at<IMPL_SfxBaseModel_DataContainer>(IMPL_SfxBaseModel_DataContainer*) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/stl_construct.h:88:15
> #14 in void std::allocator_traits<std::allocator<IMPL_SfxBaseModel_DataContainer> >::destroy<IMPL_SfxBaseModel_DataContainer>(std::allocator<IMPL_SfxBaseModel_DataContainer>&, IMPL_SfxBaseModel_DataContainer*) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/alloc_traits.h:537:4
> #15 in std::_Sp_counted_ptr_inplace<IMPL_SfxBaseModel_DataContainer, std::allocator<IMPL_SfxBaseModel_DataContainer>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:528:2
> #16 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:168:6
> #17 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:705:11
> #18 in std::__shared_ptr<IMPL_SfxBaseModel_DataContainer, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:1154:31
> #19 in std::__shared_ptr<IMPL_SfxBaseModel_DataContainer, (__gnu_cxx::_Lock_policy)2>::reset() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:1272:9
>
> previously allocated by thread T10 here:
> #0 in operator new(unsigned long) at ~/github.com/llvm/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:95:3
> #1 in SwDoc::MakeFlyFrameFormat(rtl::OUString const&, SwFrameFormat*) at sw/source/core/doc/docfmt.cxx:756:33
> #2 in SwDoc::MakeFlySection_(SwPosition const&, SwContentNode const&, RndStdIds, SfxItemSet const*, SwFrameFormat*) at sw/source/core/doc/doclay.cxx:171:33
> #3 in SwDoc::MakeFlySection(RndStdIds, SwPosition const*, SfxItemSet const*, SwFrameFormat*, bool) at sw/source/core/doc/doclay.cxx:337:19
> #4 in SwXFrame::attachToRange(com::sun::star::uno::Reference<com::sun::star::text::XTextRange> const&, SwPaM const*) at sw/source/core/unocore/unoframe.cxx:2821:29
> #5 in SwXFrame::attach(com::sun::star::uno::Reference<com::sun::star::text::XTextRange> const&) at sw/source/core/unocore/unoframe.cxx:3115:9
> #6 in SwXTextFrame::attach(com::sun::star::uno::Reference<com::sun::star::text::XTextRange> const&) at sw/source/core/unocore/unoframe.cxx:3346:15
> #7 in SwXText::insertTextContent(com::sun::star::uno::Reference<com::sun::star::text::XTextRange> const&, com::sun::star::uno::Reference<com::sun::star::text::XTextContent> const&, unsigned char) at sw/source/core/unocore/unotext.cxx:615:15
> #8 in SwXText::insertTextContentWithProperties(com::sun::star::uno::Reference<com::sun::star::text::XTextContent> const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::text::XTextRange> const&) at sw/source/core/unocore/unotext.cxx:1472:5
> #9 in non-virtual thunk to SwXText::insertTextContentWithProperties(com::sun::star::uno::Reference<com::sun::star::text::XTextContent> const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::text::XTextRange> const&) at sw/source/core/unocore/unotext.cxx
> #10 in SwTextBoxHelper::create(SwFrameFormat*, SdrObject*, bool) at sw/source/core/doc/textboxhelper.cxx:100:29
> #11 in SwXShape::setPropertyValue(rtl::OUString const&, com::sun::star::uno::Any const&) at sw/source/core/unocore/unodraw.cxx:1165:25
> #12 in SdXMLShapeContext::SetStyle(bool) at xmloff/source/draw/ximpshap.cxx:701:27
> #13 in SdXMLCustomShapeContext::startFastElement(int, com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> const&) at xmloff/source/draw/ximpshap.cxx:3545:5
> #14 in SvXMLImport::startFastElement(int, com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> const&) at xmloff/source/core/xmlimp.cxx:805:15
> #15 in (anonymous namespace)::Entity::startElement((anonymous namespace)::Event const*) at sax/source/fastparser/fastparser.cxx:468:27
> #16 in sax_fastparser::FastSaxParserImpl::callbackStartElement(unsigned char const*, unsigned char const*, unsigned char const*, int, unsigned char const**, int, unsigned char const**) at sax/source/fastparser/fastparser.cxx:1304:21
> #17 in (anonymous namespace)::call_callbackStartElement(void*, unsigned char const*, unsigned char const*, unsigned char const*, int, unsigned char const**, int, int, unsigned char const**) at sax/source/fastparser/fastparser.cxx:331:18
> #18 in xmlParseStartTag2 at workdir/UnpackedTarball/libxml2/parser.c:9658:6
> #19 in xmlParseTryOrFinish at workdir/UnpackedTarball/libxml2/parser.c:11453:14
Change-Id: I752190e05fc3c282b75021724527f623f56ee6a6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125977
Tested-by: Jenkins
Tested-by: René Engelhard <rene@debian.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sw/inc')
-rw-r--r-- | sw/inc/textboxhelper.hxx | 74 | ||||
-rw-r--r-- | sw/inc/unomid.h | 4 | ||||
-rw-r--r-- | sw/inc/unoprnms.hxx | 1 |
3 files changed, 28 insertions, 51 deletions
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index 10841ed8626c..2e5b27cfccb0 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -11,7 +11,6 @@ #define INCLUDED_SW_INC_TEXTBOXHELPER_HXX #include <map> -#include <unordered_map> #include <optional> #include <set> #include <vector> @@ -61,16 +60,12 @@ public: /// the original text in the shape will be copied to the frame /// The textbox is created for the shape given by the pObject parameter. static void create(SwFrameFormat* pShape, SdrObject* pObject, bool bCopyText = false); - /// Sets the given textframe as textbox for the given (group member) shape. - static void set(SwFrameFormat* pShape, SdrObject* pObject, - css::uno::Reference<css::text::XTextFrame> xNew); /// Destroy a TextBox for a shape. If the format has more textboxes /// like group shapes, it will destroy only that textbox what belongs /// to the given pObject shape. static void destroy(const SwFrameFormat* pShape, const SdrObject* pObject); /// Get interface of a shape's TextBox, if there is any. - static css::uno::Any queryInterface(const SwFrameFormat* pShape, const css::uno::Type& rType, - SdrObject* pObj = nullptr); + static css::uno::Any queryInterface(const SwFrameFormat* pShape, const css::uno::Type& rType); /// Sync property of TextBox with the one of the shape. static void syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, @@ -95,7 +90,7 @@ public: /// Sets the surround to through for the textframe of the given shape, /// not to interfere with the layout. Returns true on success. - static bool setWrapThrough(SwFrameFormat* pShape, SdrObject* pObj = nullptr); + static bool setWrapThrough(SwFrameFormat* pShape); /// Sets the anchor of the associated textframe of the given shape, and /// returns true on success. @@ -105,20 +100,15 @@ public: /// returns true on success. static bool doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pObj); - /// Sets the correct size of textframe depending on the given SdrObject. - static bool setTextBoxSize(const SwFrameFormat* pShape, SdrObject* pObj); - /// Returns true if the anchor different for the given shape, and the /// associated textframe of the given shape. /// Note: In case of AS_CHAR anchor the anchor type must be different, /// because if not, layout breaks, but this situation also handled by /// this function, and returns true in that case too. - static std::optional<bool> isAnchorTypeDifferent(const SwFrameFormat* pShape, - SdrObject* pObj = nullptr); + static std::optional<bool> isAnchorTypeDifferent(const SwFrameFormat* pShape); /// Returns true if the given shape has a valid textframe. - static bool isTextBoxShapeHasValidTextFrame(const SwFrameFormat* pShape, - SdrObject* pObj = nullptr); + static bool isTextBoxShapeHasValidTextFrame(const SwFrameFormat* pShape); // Returns true on success. Synchronize z-order of the text frame of the given textbox // by setting it one level higher than the z-order of the shape of the textbox. @@ -187,26 +177,6 @@ public: /// Undo the effect of saveLinks() + individual resetLink() calls. static void restoreLinks(std::set<ZSortFly>& rOld, std::vector<SwFrameFormat*>& rNew, SavedLink& rSavedLinks); - - /// The following actions are implemented for groupshapes with textboxes too. - /// The selected action will be done for all of the group member textboxes. - enum GroupTextBoxActionType - { - POSITION_SIZE_AND_ANCHOR_CHANGE, - DELETE, - Z_ORDER_CHANGE - }; - - /// Does the selected action with ALL textboxes in the group. - /// Parameters: - /// - pGroupShapeFormat: The frame format of the group shape where the textboxes belongs to. - /// - pGroupObject: The drawing object for the group. - /// - eActionType: The action what the function is supposed to do. - /// WARN: This function will run recursive! ALL textboxes of the group will be handled by - /// the desired action! - static void handleTextBoxGroup(SwFrameFormat* pGroupShapeFormat, - GroupTextBoxActionType eActionType, - SdrObject* pGroupObject = nullptr); }; /// Textboxes are basically textframe + shape pairs. This means one shape has one frame. @@ -215,15 +185,27 @@ public: /// it can have multiple textboxes. class SwTextBoxNode { - // This map stores the textboxes what belongs to this node - std::unordered_map<const SdrObject*, SwFrameFormat*> m_pTextBoxTable; + // One TextBox-entry + struct SwTextBoxElement + { + // The textframe format + SwFrameFormat* m_pTextBoxFormat; + // The Draw object where the textbox belongs to + SdrObject* m_pDrawObject; + // This is for indicating if the textbox is in special case: for example during undo. + bool m_bIsActive; + }; + + // This vector stores the textboxes what belongs to this node + std::vector<SwTextBoxElement> m_pTextBoxes; // This is the pointer to the shape format, which has this node // (and the textboxes) SwFrameFormat* m_pOwnerShapeFormat; + +public: // Not needed. SwTextBoxNode() = delete; -public: // ctor SwTextBoxNode(SwFrameFormat* pOwnerShapeFormat); // dtor @@ -242,24 +224,24 @@ public: // Parameters: // pDrawObject: The shape which have the textbox to be deleted. void DelTextBox(const SdrObject* pDrawObject); - void DelTextBox(SwFrameFormat* pTextBox); // This will return with the frame format of the textbox what belongs // to the given shape (pDrawObject) SwFrameFormat* GetTextBox(const SdrObject* pDrawObject) const; + // Is this textbox has special state, undo for example? + bool IsTextBoxActive(const SdrObject* pDrawObject) const; + + // Setters for the state flag. + void SetTextBoxInactive(const SdrObject* pDrawObject); + void SetTextBoxActive(const SdrObject* pDrawObject); + // If this is a group shape, that returns true. - bool IsGroupTextBoxShape() const; + bool IsGroupTextBox() const; // This returns with the shape what this class belongs to. SwFrameFormat* GetOwnerShape() { return m_pOwnerShapeFormat; }; // This will give the current number of textboxes. - size_t GetTextBoxCount() const { return m_pTextBoxTable.size(); }; - - // Gives a const reference to the text box table, useful for undo and grouping. - const std::unordered_map<const SdrObject*, SwFrameFormat*>& GetTextBoxTable() const - { - return m_pTextBoxTable; - }; + size_t GetTextBoxCount() const { return m_pTextBoxes.size(); }; }; #endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX diff --git a/sw/inc/unomid.h b/sw/inc/unomid.h index 5b6e8a0cb6cd..d249b32fc25a 100644 --- a/sw/inc/unomid.h +++ b/sw/inc/unomid.h @@ -151,10 +151,6 @@ // SwFormatFollowTextFlow #define MID_FOLLOW_TEXT_FLOW 0 -// TextBox -#define MID_TEXTBOX 0 -#define MID_TEXTBOX_CONTENT 1 - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 1e16bc413d01..7ef5d0a58cd7 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -74,7 +74,6 @@ #define UNO_NAME_FOOTER_RIGHT_MARGIN "FooterRightMargin" #define UNO_NAME_TEXT_RANGE "TextRange" #define UNO_NAME_TEXT_BOX "TextBox" -#define UNO_NAME_TEXT_BOX_CONTENT "TextBoxContent" #define UNO_NAME_NAME "Name" #define UNO_NAME_CHAR_STYLE_NAME "CharStyleName" #define UNO_NAME_ANCHOR_CHAR_STYLE_NAME "AnchorCharStyleName" |