sw/inc/docary.hxx | 26 ++++++++++ sw/inc/redline.hxx | 10 ++++ sw/source/core/doc/docredln.cxx | 87 ++++++++++++++++++++++++++++++++++++ sw/source/core/docnode/nodedump.cxx | 22 +++++++++ 4 files changed, 145 insertions(+)
New commits: commit 7949b380e054342c80035d406c89ddc5badacfad Author: Adam Co <rattles2...@gmail.com> Date: Thu Jan 16 16:51:09 2014 +0200 New redline object and table for non-ranged redlines called 'SwExtraRedline' Added a new redline object for non-ranged redlines called 'SwExtraRedline'. Examples for such redlines are 'table row was inserted \ deleted', 'table properties changed', 'text was moved' etc. Also - added a table for these redlines called 'SwExtraRedlineTbl'. Change-Id: I9190093c97108b7e4923bc8a9feb441ad5c5694f Reviewed-on: https://gerrit.libreoffice.org/7464 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index ea868e8..ed78fd2 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -34,6 +34,7 @@ class SwUndo; class SwSectionFmt; class SwNumRule; class SwRangeRedline; +class SwExtraRedline; class SwUnoCrsr; class SwOLENode; class SwTxtFmtColl; @@ -182,6 +183,31 @@ public: using _SwRedlineTbl::empty; }; +/// Table that holds 'extra' redlines, such as 'table row insert\delete', 'paragraph moves' etc... +class SwExtraRedlineTbl +{ +private: + std::vector<SwExtraRedline*> m_aExtraRedlines; + +public: + bool Contains(const SwExtraRedline* p) const; + sal_uInt16 GetPos(const SwExtraRedline* p) const; + + bool Insert( SwExtraRedline* p ); + + void Remove( sal_uInt16 nPos ); + bool Remove( const SwExtraRedline* p ); + void DeleteAndDestroy( sal_uInt16 nPos, sal_uInt16 nLen = 1 ); + void DeleteAndDestroyAll(); + + void dumpAsXml(xmlTextWriterPtr w); + + sal_uInt16 GetSize() const { return m_aExtraRedlines.size(); } + SwExtraRedline* GetRedline( sal_uInt16 uIndex ) const { return m_aExtraRedlines.operator[]( uIndex ); } + sal_uInt16 IsEmpty() const { return m_aExtraRedlines.empty(); } +}; + + class SwUnoCrsrTbl : public std::set<SwUnoCrsr*> { public: /// the destructor will free all objects still in the set diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx index b946618..3fe682e 100644 --- a/sw/inc/redline.hxx +++ b/sw/inc/redline.hxx @@ -299,6 +299,16 @@ public: bool operator<( const SwRangeRedline& ) const; }; +/// Base object for 'Redlines' that are not of 'Ranged' type (like table row insert\delete) +class SW_DLLPUBLIC SwExtraRedline +{ +public: + SwExtraRedline( RedlineType_t eType ); + SwExtraRedline( const SwExtraRedline& ); + virtual ~SwExtraRedline(); +}; + + class SW_DLLPUBLIC SwRedlineHint : public SfxHint { #define SWREDLINE_INSERTED 1 diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 7df8b57..ac9ce2d 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -3876,4 +3876,91 @@ bool SwDoc::IsInRedlines(const SwNode & rNode) const return aPam.ContainsPosition(aPos); } +bool SwExtraRedlineTbl::Contains(const SwExtraRedline* p) const +{ + return GetPos(p) != USHRT_MAX; +} + +sal_uInt16 SwExtraRedlineTbl::GetPos(const SwExtraRedline* p) const +{ + std::vector<SwExtraRedline*>::const_iterator it = std::find(m_aExtraRedlines.begin(), m_aExtraRedlines.end(), p); + if( it == m_aExtraRedlines.end() ) + return USHRT_MAX; + return it - m_aExtraRedlines.begin(); +} + +bool SwExtraRedlineTbl::Insert( SwExtraRedline* p ) +{ + m_aExtraRedlines.push_back( p ); + //p->CallDisplayFunc(); + return true; +} + +void SwExtraRedlineTbl::Remove( sal_uInt16 nPos ) +{ + /* + SwDoc* pDoc = 0; + if( !nP && 1 == size() ) + pDoc = front()->GetDoc(); + */ + + m_aExtraRedlines.erase( m_aExtraRedlines.begin() + nPos ); + + /* + SwViewShell* pSh; + if( pDoc && !pDoc->IsInDtor() && + 0 != ( pSh = pDoc->GetCurrentViewShell()) ) + pSh->InvalidateWindows( SwRect( 0, 0, LONG_MAX, LONG_MAX ) ); + */ +} + +bool SwExtraRedlineTbl::Remove( const SwExtraRedline* p ) +{ + sal_uInt16 nPos = GetPos(p); + if (nPos != USHRT_MAX) + Remove(nPos); + return nPos != USHRT_MAX; +} + +void SwExtraRedlineTbl::DeleteAndDestroy( sal_uInt16 nPos, sal_uInt16 nLen ) +{ + /* + SwDoc* pDoc = 0; + if( !nP && nL && nL == size() ) + pDoc = front()->GetDoc(); + */ + + for( std::vector<SwExtraRedline*>::iterator it = m_aExtraRedlines.begin() + nPos; it != m_aExtraRedlines.begin() + nPos + nLen; ++it ) + delete *it; + + m_aExtraRedlines.erase( m_aExtraRedlines.begin() + nPos, m_aExtraRedlines.begin() + nPos + nLen ); + + /* + SwViewShell* pSh; + if( pDoc && !pDoc->IsInDtor() && + 0 != ( pSh = pDoc->GetCurrentViewShell() ) ) + pSh->InvalidateWindows( SwRect( 0, 0, LONG_MAX, LONG_MAX ) ); + */ +} + +void SwExtraRedlineTbl::DeleteAndDestroyAll() +{ + DeleteAndDestroy(0, m_aExtraRedlines.size()); +} + + +SwExtraRedline::SwExtraRedline( RedlineType_t eTyp ) +{ + (void)eTyp; +} + +SwExtraRedline::SwExtraRedline( const SwExtraRedline& rCpy ) +{ + (void)rCpy; +} + +SwExtraRedline::~SwExtraRedline() +{ +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/docnode/nodedump.cxx b/sw/source/core/docnode/nodedump.cxx index 53e24e0..4959207 100644 --- a/sw/source/core/docnode/nodedump.cxx +++ b/sw/source/core/docnode/nodedump.cxx @@ -601,4 +601,26 @@ void SwRedlineTbl::dumpAsXml( xmlTextWriterPtr w ) writer.endElement( ); // swredlinetbl } +void SwExtraRedlineTbl::dumpAsXml( xmlTextWriterPtr w ) +{ + WriterHelper writer( w ); + + writer.startElement( "swextraredlinetbl" ); + writer.writeFormatAttribute( "ptr", "%p", this ); + + const SwExtraRedlineTbl& extraRedlineTbl = (*this); + + for( sal_uInt16 nCurExtraRedlinePos = 0; nCurExtraRedlinePos < GetSize(); ++nCurExtraRedlinePos ) + { + const SwExtraRedline* pExtraRedline = extraRedlineTbl.GetRedline( nCurExtraRedlinePos ); + + writer.startElement( "swextraredline" ); + writer.writeFormatAttribute( "ptr", "%p", pExtraRedline ); + + writer.endElement( ); // extra_redline_data + } + + writer.endElement( ); // swextraredlinetbl +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits