diff options
author | Oliver-Rainer Wittmann <orw@apache.org> | 2013-12-19 18:50:58 +0000 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2014-04-29 17:05:04 +0200 |
commit | 9c85141edacd0ad73977f44b98158dbd969bbff3 (patch) | |
tree | a5bf857b60ddda4a70b2a5d4e1a584f2af75e3df /writerfilter | |
parent | be93b1bf4e417c23c89bb66be1872f8cd7190d65 (diff) |
123792: complete annotations on text ranges feature
- rely annotations on text ranges on new annotation marks
- support arbitrary text ranges for annotations
- fix undo/redo regarding annotations an text ranges
- support annotations on overlapping text ranges
- fix *.docx import for annotations on overlapping text ranges
- fix ODF import of annotations on text ranges
cherry-picked from branch ooxml-osba
(cherry picked from commit ebd2922ebd3cf2d3899fb80780d38f367197aadf)
Conflicts:
sw/Library_sw.mk
sw/inc/IDocumentMarkAccess.hxx
sw/inc/SidebarWin.hxx
sw/inc/doc.hxx
sw/inc/docufld.hxx
sw/inc/hintids.hxx
sw/inc/ndhints.hxx
sw/inc/txatbase.hxx
sw/inc/unobookmark.hxx
sw/inc/unofield.hxx
sw/inc/unoport.hxx
sw/source/core/access/accpara.cxx
sw/source/core/bastyp/init.cxx
sw/source/core/crsr/bookmrk.cxx
sw/source/core/crsr/findtxt.cxx
sw/source/core/doc/dbgoutsw.cxx
sw/source/core/doc/docbm.cxx
sw/source/core/doc/doccorr.cxx
sw/source/core/doc/docdde.cxx
sw/source/core/doc/docedt.cxx
sw/source/core/doc/docfld.cxx
sw/source/core/doc/doclay.cxx
sw/source/core/doc/tblrwcl.cxx
sw/source/core/docnode/ndcopy.cxx
sw/source/core/docnode/nodes.cxx
sw/source/core/docnode/section.cxx
sw/source/core/edit/edfld.cxx
sw/source/core/fields/docufld.cxx
sw/source/core/fields/postithelper.cxx
sw/source/core/fields/reffld.cxx
sw/source/core/inc/MarkManager.hxx
sw/source/core/inc/crossrefbookmark.hxx
sw/source/core/text/inftxt.cxx
sw/source/core/text/itratr.cxx
sw/source/core/text/txtfrm.cxx
sw/source/core/txtnode/atrfld.cxx
sw/source/core/txtnode/ndtxt.cxx
sw/source/core/txtnode/thints.cxx
sw/source/core/undo/undel.cxx
sw/source/core/undo/undobj.cxx
sw/source/core/unocore/unofield.cxx
sw/source/core/unocore/unoport.cxx
sw/source/core/unocore/unoportenum.cxx
sw/source/filter/html/htmlatr.cxx
sw/source/filter/html/htmlgrin.cxx
sw/source/filter/html/wrthtml.cxx
sw/source/filter/writer/writer.cxx
sw/source/filter/ww1/fltshell.cxx
sw/source/filter/ww8/wrtw8nds.cxx
sw/source/filter/ww8/ww8par.cxx
sw/source/ui/dialog/uiregionsw.cxx
sw/source/ui/dochdl/swdtflvr.cxx
sw/source/ui/docvw/PostItMgr.cxx
sw/source/ui/docvw/SidebarWin.cxx
sw/source/ui/fldui/fldmgr.cxx
sw/source/ui/fldui/fldref.cxx
sw/source/ui/inc/fldmgr.hxx
sw/source/ui/inc/wrtsh.hxx
sw/source/ui/shells/textfld.cxx
sw/source/ui/uiview/view2.cxx
sw/source/ui/utlui/navipi.cxx
sw/source/ui/wrtsh/wrtsh2.cxx
writerfilter/source/dmapper/DomainMapper_Impl.cxx
writerfilter/source/dmapper/DomainMapper_Impl.hxx
writerfilter/source/dmapper/PropertyMap.cxx
xmloff/inc/txtfldi.hxx
xmloff/source/text/txtfldi.cxx
xmloff/source/text/txtparae.cxx
(cherry picked from commit 0761f81643a6890457e9ef7d913ab5c88c2593a4)
Conflicts:
sw/source/core/access/accpara.cxx
sw/source/core/fields/reffld.cxx
sw/source/core/text/txtfrm.cxx
sw/source/core/txtnode/modeltoviewhelper.cxx
sw/source/core/txtnode/thints.cxx
sw/source/core/unocore/unoportenum.cxx
writerfilter/source/dmapper/DomainMapper_Impl.cxx
Change-Id: Ie4cc467dbb837054c73742262ee20f35c151ff3f
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 4 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 65 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 10 |
3 files changed, 48 insertions, 31 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index c7625e35033b..2e151c8010c5 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -1415,10 +1415,10 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) m_pImpl->SetCurrentRedlineId( nIntValue ); break; case NS_ooxml::LN_EG_RangeMarkupElements_commentRangeStart: - m_pImpl->AddAnnotationPosition(true); + m_pImpl->AddAnnotationPosition( true, nIntValue ); break; case NS_ooxml::LN_EG_RangeMarkupElements_commentRangeEnd: - m_pImpl->AddAnnotationPosition(false); + m_pImpl->AddAnnotationPosition( false, nIntValue ); break; case NS_ooxml::LN_CT_Comment_initials: m_pImpl->SetCurrentRedlineInitials(sStringValue); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 65916731df98..8cbe6f1417c3 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -171,6 +171,9 @@ DomainMapper_Impl::DomainMapper_Impl( m_bParaSectpr( false ), m_bUsingEnhancedFields( false ), m_bSdt(false), + m_xAnnotationField(), + m_nAnnotationId( -1 ), + m_aAnnotationPositions(), m_xInsertTextRange(xInsertTextRange), m_bIsNewDoc(bIsNewDoc), m_bInTableStyleRunProps(false), @@ -1679,33 +1682,30 @@ void DomainMapper_Impl::PopAnnotation() try { + if ( m_nAnnotationId != -1 ) + { // See if the annotation will be a single position or a range. - if (!m_aAnnotationPosition.m_xStart.is() || - !m_aAnnotationPosition.m_xEnd.is()) + AnnotationPosition& aAnnotationPosition = m_aAnnotationPositions[ m_nAnnotationId ]; + if ( !aAnnotationPosition.m_xStart.is() + || !aAnnotationPosition.m_xEnd.is() ) { uno::Sequence< beans::PropertyValue > aEmptyProperties; - appendTextContent(uno::Reference<text::XTextContent>( - m_xAnnotationField, uno::UNO_QUERY_THROW), aEmptyProperties); + appendTextContent( uno::Reference< text::XTextContent >( m_xAnnotationField, uno::UNO_QUERY_THROW ), aEmptyProperties ); } else { // Create a range that points to the annotation start/end. - uno::Reference<text::XText> const xText = - m_aAnnotationPosition.m_xStart->getText(); - uno::Reference<text::XTextCursor> const xCursor = - xText->createTextCursorByRange(m_aAnnotationPosition.m_xStart); - xCursor->gotoRange(m_aAnnotationPosition.m_xEnd, true); - uno::Reference<text::XTextRange> const xTextRange( - xCursor, uno::UNO_QUERY_THROW); + uno::Reference<text::XText> const xText = aAnnotationPosition.m_xStart->getText(); + uno::Reference<text::XTextCursor> const xCursor = xText->createTextCursorByRange(aAnnotationPosition.m_xStart); + xCursor->gotoRange(aAnnotationPosition.m_xEnd, true); + uno::Reference<text::XTextRange> const xTextRange(xCursor, uno::UNO_QUERY_THROW); // Attach the annotation to the range. - uno::Reference<text::XTextAppend> const xTextAppend = - m_aTextAppendStack.top().xTextAppend; - xTextAppend->insertTextContent(xTextRange, - uno::Reference<text::XTextContent>(m_xAnnotationField, - uno::UNO_QUERY_THROW), - !xCursor->isCollapsed()); + uno::Reference<text::XTextAppend> const xTextAppend = m_aTextAppendStack.top().xTextAppend; + xTextAppend->insertTextContent(xTextRange, uno::Reference<text::XTextContent>(m_xAnnotationField, uno::UNO_QUERY_THROW), !xCursor->isCollapsed()); } + m_aAnnotationPositions.erase( m_nAnnotationId ); + } } catch (uno::Exception const& e) { @@ -1713,10 +1713,8 @@ void DomainMapper_Impl::PopAnnotation() "Cannot insert annotation field: exception: " << e.Message); } - m_aAnnotationPosition.m_xStart.clear(); - m_aAnnotationPosition.m_xEnd.clear(); m_xAnnotationField.clear(); - + m_nAnnotationId = -1; } void DomainMapper_Impl::PushPendingShape( const uno::Reference< drawing::XShape > xShape ) @@ -3801,7 +3799,9 @@ void DomainMapper_Impl::AddBookmark( const OUString& rBookmarkName, const OUStri } } -void DomainMapper_Impl::AddAnnotationPosition(const bool bStart) +void DomainMapper_Impl::AddAnnotationPosition( + const bool bStart, + const sal_Int32 nAnnotationId) { if (m_aTextAppendStack.empty()) return; @@ -3821,10 +3821,16 @@ void DomainMapper_Impl::AddAnnotationPosition(const bool bStart) } // And save it, to be used by PopAnnotation() later. + AnnotationPosition& aAnnotationPosition = m_aAnnotationPositions[ nAnnotationId ]; if (bStart) - m_aAnnotationPosition.m_xStart = xCurrent; + { + aAnnotationPosition.m_xStart = xCurrent; + } else - m_aAnnotationPosition.m_xEnd = xCurrent; + { + aAnnotationPosition.m_xEnd = xCurrent; + } + m_aAnnotationPositions[ nAnnotationId ] = aAnnotationPosition; } GraphicImportPtr DomainMapper_Impl::GetGraphicImport(GraphicImportType eGraphicImportType) @@ -4032,9 +4038,16 @@ void DomainMapper_Impl::SetCurrentRedlineDate( OUString sDate ) void DomainMapper_Impl::SetCurrentRedlineId( sal_Int32 sId ) { - RedlineParamsPtr pCurrent( GetTopRedline( ) ); - if ( pCurrent.get( ) ) - pCurrent->m_nId = sId; + if (m_xAnnotationField.is()) + { + m_nAnnotationId = sId; + } + else + { + RedlineParamsPtr pCurrent( GetTopRedline( ) ); + if ( pCurrent.get( ) ) + pCurrent->m_nId = sId; + } } void DomainMapper_Impl::SetCurrentRedlineToken( sal_Int32 nToken ) diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 6792be2104ca..dec00c8d3d70 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -256,6 +256,7 @@ struct AnnotationPosition ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xStart; ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xEnd; }; +typedef boost::unordered_map< sal_Int32, AnnotationPosition > AnnotationPositions_t; struct RedlineParams { @@ -393,8 +394,9 @@ private: bool m_bSdt; //annotation import - uno::Reference< beans::XPropertySet > m_xAnnotationField; - AnnotationPosition m_aAnnotationPosition; + uno::Reference< beans::XPropertySet > m_xAnnotationField; + sal_Int32 m_nAnnotationId; + AnnotationPositions_t m_aAnnotationPositions; void GetCurrentLocale(::com::sun::star::lang::Locale& rLocale); void SetNumberFormat( const OUString& rCommand, @@ -611,7 +613,9 @@ public: void AddBookmark( const OUString& rBookmarkName, const OUString& rId ); - void AddAnnotationPosition(const bool bStart); + void AddAnnotationPosition( + const bool bStart, + const sal_Int32 nAnnotationId ); DomainMapperTableManager& getTableManager() { |