diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-05-17 11:16:17 +0200 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-05-17 12:55:51 +0200 |
commit | 6952d696439981962ad378aa28b0d16ea6e48f0e (patch) | |
tree | bc57f960da87507551b1121c5872b4b6fe71fe4f /xmloff/source/text/XMLTextFrameContext.cxx | |
parent | 848ce52063cd611413e508b59e400d8ecd4c63d4 (diff) |
tdf#100033: Frames with the same name are removed
Allow to have frames with the same name. For removing
real duplicated frames (generated by LO earlier)
check other things also next to the frame name:
position, size or whether the two frames are anchored
to the same position.
Change-Id: I191ae5128d0228eb85f78f065b44b1f0b3ba6dcf
Reviewed-on: https://gerrit.libreoffice.org/37702
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'xmloff/source/text/XMLTextFrameContext.cxx')
-rw-r--r-- | xmloff/source/text/XMLTextFrameContext.cxx | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index 539d41e4fd8e..ece946e001b6 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -368,6 +368,7 @@ class XMLTextFrameContext_Impl : public SvXMLImportContext bool bSyncHeight : 1; bool bCreateFailed : 1; bool bOwnBase64Stream : 1; + bool mbMultipleContent : 1; // This context is created based on a multiple content (image) void Create(); @@ -383,7 +384,8 @@ public: const css::uno::Reference<css::xml::sax::XAttributeList > & rAttrList, css::text::TextContentAnchorType eAnchorType, sal_uInt16 nType, - const css::uno::Reference<css::xml::sax::XAttributeList > & rFrameAttrList ); + const css::uno::Reference<css::xml::sax::XAttributeList > & rFrameAttrList, + bool bMultipleContent = false ); virtual void EndElement() override; @@ -405,6 +407,8 @@ public: void SetName(); + const OUString& GetOrigName() const { return m_sOrigName; } + css::text::TextContentAnchorType GetAnchorType() const { return eAnchorType; } const css::uno::Reference < css::beans::XPropertySet >& GetPropSet() const { return xPropSet; } @@ -520,6 +524,14 @@ void XMLTextFrameContext_Impl::Create() Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); + // Skip duplicated frames + if(!mbMultipleContent && // It's allowed to have multiple image for the same frame + xTextImportHelper->IsDuplicateFrame(sName, nX, nY, nWidth, nHeight)) + { + bCreateFailed = true; + return; + } + // set name Reference < XNamed > xNamed( xPropSet, UNO_QUERY ); if( xNamed.is() ) @@ -539,14 +551,9 @@ void XMLTextFrameContext_Impl::Create() xNamed->setName( sName ); if( sName != sOldName ) { - bool bSuccess = xTextImportHelper->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_FRAME, + xTextImportHelper->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_FRAME, sOldName, sName ); - if (!bSuccess && !sOldName.isEmpty()) - { - bCreateFailed = true; - return; - } } } } @@ -787,7 +794,8 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( const Reference< XAttributeList > & rAttrList, TextContentAnchorType eATyp, sal_uInt16 nNewType, - const Reference< XAttributeList > & rFrameAttrList ) + const Reference< XAttributeList > & rFrameAttrList, + bool bMultipleContent ) : SvXMLImportContext( rImport, nPrfx, rLName ) , mbListContextPushed( false ) , nType( nNewType ) @@ -810,6 +818,7 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( bSyncHeight = false; bCreateFailed = false; bOwnBase64Stream = false; + mbMultipleContent = bMultipleContent; rtl::Reference < XMLTextImportHelper > xTxtImport = GetImport().GetTextImport(); @@ -1363,6 +1372,8 @@ void XMLTextFrameContext::EndElement() m_pHyperlink.reset(); } + GetImport().GetTextImport()->StoreLastImportedFrameName(pImpl->GetOrigName()); + } } @@ -1466,7 +1477,7 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext( // read another image pContext = new XMLTextFrameContext_Impl( GetImport(), p_nPrefix, rLocalName, xAttrList, - m_eDefaultAnchorType, XML_TEXT_FRAME_GRAPHIC, m_xAttrList); + m_eDefaultAnchorType, XML_TEXT_FRAME_GRAPHIC, m_xAttrList, true); m_xImplContext = pContext; addContent(*m_xImplContext.get()); |