diff options
author | Justin Luth <justin_luth@sil.org> | 2015-06-24 23:02:57 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-07-03 16:40:52 +0000 |
commit | 4802bf32b84655f6e1d3389070c76371ede8fbce (patch) | |
tree | 72d4bb14ffbb440e710a6e332b3a8896455437d2 /sw/source/filter/ww8/wrtw8nds.cxx | |
parent | LOK: Don't try to absolutize URL's. (diff) | |
download | core-4802bf32b84655f6e1d3389070c76371ede8fbce.tar.gz core-4802bf32b84655f6e1d3389070c76371ede8fbce.zip |
tdf#87348 enable docx exporting linked textboxes that LO can import
Exporting linked textboxes to docx format is in terrible condition.
Spacing, textboxes instead of frames, duplicate links and orphaned
shapes lying around, not to mention being being unlinked in MSWord...
This fix resolves this situation slightly: what LO saves can be
re-imported and re-saved without breaking the links - an incremental
improvement.
Change-Id: I8f0aef39eeed88a2b3dfc673a565fb1d8f4713b0
Reviewed-on: https://gerrit.libreoffice.org/16516
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw/source/filter/ww8/wrtw8nds.cxx')
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 608d2b377d18..1cc28037c404 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -549,6 +549,69 @@ bool SwWW8AttrIter::IsAnchorLinkedToThisNode( sal_uLong nNodePos ) FlyProcessingState SwWW8AttrIter::OutFlys(sal_Int32 nSwPos) { + // collection point to first gather info about all of the potentially linked textboxes: to be analyzed later. + OUString sLinkChainName; + sw::FrameIter linkedTextboxesIter = maFlyIter; + while ( linkedTextboxesIter != maFlyFrms.end() ) + { + uno::Reference< drawing::XShape > xShape; + sw::Frame xFrame = *linkedTextboxesIter; + const SdrObject* pSdrObj = xFrame.GetFrameFormat().FindRealSdrObject(); + if( pSdrObj ) + xShape = uno::Reference< drawing::XShape >(const_cast<SdrObject*>(pSdrObj)->getUnoShape(), uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xPropertySet(xShape, uno::UNO_QUERY); + uno::Reference< beans::XPropertySetInfo > xPropertySetInfo; + if( xPropertySet.is() ) + xPropertySetInfo = xPropertySet->getPropertySetInfo(); + if( xPropertySetInfo.is() ) + { + MSWordExportBase::LinkedTextboxInfo aLinkedTextboxInfo = MSWordExportBase::LinkedTextboxInfo(); + + if( xPropertySetInfo->hasPropertyByName("LinkDisplayName") ) + xPropertySet->getPropertyValue("LinkDisplayName") >>= sLinkChainName; + else if( xPropertySetInfo->hasPropertyByName("ChainName") ) + xPropertySet->getPropertyValue("ChainName") >>= sLinkChainName; + + if( xPropertySetInfo->hasPropertyByName("ChainNextName") ) + xPropertySet->getPropertyValue("ChainNextName") >>= aLinkedTextboxInfo.sNextChain; + if( xPropertySetInfo->hasPropertyByName("ChainPrevName") ) + xPropertySet->getPropertyValue("ChainPrevName") >>= aLinkedTextboxInfo.sPrevChain; + + //collect a list of linked textboxes: those with a NEXT or PREVIOUS link + if( !aLinkedTextboxInfo.sNextChain.isEmpty() || !aLinkedTextboxInfo.sPrevChain.isEmpty() ) + { + assert( !sLinkChainName.isEmpty() ); + + //there are many discarded duplicates in documents - no duplicates allowed in the list, so try to find the real one. + //if this LinkDisplayName/ChainName already exists on a different shape... + // the earlier processed duplicates are thrown out unless this one can be proved as bad. (last processed duplicate usually is stored) + std::map<OUString,MSWordExportBase::LinkedTextboxInfo>::iterator linkFinder; + linkFinder = m_rExport.m_aLinkedTextboxesHelper.find(sLinkChainName); + if( linkFinder != m_rExport.m_aLinkedTextboxesHelper.end() ) + { + //If my NEXT/PREV targets have already been discovered, but don't match me, then assume I'm an abandoned remnant + // (this logic fails if both me and one of my links are duplicated, and the remnants were added first.) + linkFinder = m_rExport.m_aLinkedTextboxesHelper.find(aLinkedTextboxInfo.sNextChain); + if( (linkFinder != m_rExport.m_aLinkedTextboxesHelper.end()) && (linkFinder->second.sPrevChain != sLinkChainName) ) + { + ++linkedTextboxesIter; + break; + } + + linkFinder = m_rExport.m_aLinkedTextboxesHelper.find(aLinkedTextboxInfo.sPrevChain); + if( (linkFinder != m_rExport.m_aLinkedTextboxesHelper.end()) && (linkFinder->second.sNextChain != sLinkChainName) ) + { + ++linkedTextboxesIter; + break; + } + } + m_rExport.m_bLinkedTextboxesHelperInitialized = false; + m_rExport.m_aLinkedTextboxesHelper[sLinkChainName] = aLinkedTextboxInfo; + } + } + ++linkedTextboxesIter; + } + /* #i2916# May have an anchored graphic to be placed, loop through sorted array |