openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o..@apache.org
Subject svn commit: r1574113 - in /openoffice/branches/AOO410: ./ main/ main/sw/inc/ main/sw/source/core/bastyp/ main/sw/source/core/crsr/ main/sw/source/core/doc/ main/sw/source/core/inc/ main/sw/source/core/txtnode/
Date Tue, 04 Mar 2014 14:39:44 GMT
Author: orw
Date: Tue Mar  4 14:39:44 2014
New Revision: 1574113

URL: http://svn.apache.org/r1574113
Log:
124338: assure sorted mark containers when updating <SwIndex> instances due to inserted
characters

	cherry-picked from trunk


Modified:
    openoffice/branches/AOO410/   (props changed)
    openoffice/branches/AOO410/main/   (props changed)
    openoffice/branches/AOO410/main/sw/inc/IDocumentMarkAccess.hxx
    openoffice/branches/AOO410/main/sw/inc/ndtxt.hxx
    openoffice/branches/AOO410/main/sw/source/core/bastyp/index.cxx
    openoffice/branches/AOO410/main/sw/source/core/crsr/bookmrk.cxx
    openoffice/branches/AOO410/main/sw/source/core/crsr/crossrefbookmark.cxx
    openoffice/branches/AOO410/main/sw/source/core/doc/docbm.cxx
    openoffice/branches/AOO410/main/sw/source/core/inc/MarkManager.hxx
    openoffice/branches/AOO410/main/sw/source/core/inc/bookmrk.hxx
    openoffice/branches/AOO410/main/sw/source/core/inc/crossrefbookmark.hxx
    openoffice/branches/AOO410/main/sw/source/core/txtnode/ndtxt.cxx

Propchange: openoffice/branches/AOO410/
------------------------------------------------------------------------------
  Merged /openoffice/trunk:r1574058

Propchange: openoffice/branches/AOO410/main/
------------------------------------------------------------------------------
  Merged /openoffice/trunk/main:r1574058

Modified: openoffice/branches/AOO410/main/sw/inc/IDocumentMarkAccess.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/inc/IDocumentMarkAccess.hxx?rev=1574113&r1=1574112&r2=1574113&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/inc/IDocumentMarkAccess.hxx (original)
+++ openoffice/branches/AOO410/main/sw/inc/IDocumentMarkAccess.hxx Tue Mar  4 14:39:44 2014
@@ -193,6 +193,8 @@ class IDocumentMarkAccess
         */
         virtual void clearAllMarks() =0;
 
+        virtual void assureSortedMarkContainers() const = 0;
+
         /** returns a STL-like random access iterator to the begin of the sequence of marks.
         */
         virtual const_iterator_t getAllMarksBegin() const =0;

Modified: openoffice/branches/AOO410/main/sw/inc/ndtxt.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/inc/ndtxt.hxx?rev=1574113&r1=1574112&r2=1574113&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/inc/ndtxt.hxx (original)
+++ openoffice/branches/AOO410/main/sw/inc/ndtxt.hxx Tue Mar  4 14:39:44 2014
@@ -794,9 +794,7 @@ public:
     bool IsNotifiable() const;
 
     void SetListRestart( bool bRestart );
-    // --> OD 2005-11-02 #i51089 - TUNING#
     bool IsListRestart() const;
-    // <--
 
     void SetAttrListRestartValue( SwNumberTree::tSwNumTreeNumber nNum );
     bool HasAttrListRestartValue() const;

Modified: openoffice/branches/AOO410/main/sw/source/core/bastyp/index.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/core/bastyp/index.cxx?rev=1574113&r1=1574112&r2=1574113&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/core/bastyp/index.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/core/bastyp/index.cxx Tue Mar  4 14:39:44 2014
@@ -357,15 +357,17 @@ SwIndexReg::~SwIndexReg()
 }
 
 
-
-void SwIndexReg::Update( SwIndex const & rIdx, const xub_StrLen nDiff,
-    const bool bNeg, const bool /* argument is only used in derived class*/ )
+void SwIndexReg::Update(
+    SwIndex const & rIdx,
+    const xub_StrLen nDiff,
+    const bool bNeg,
+    const bool /* argument is only used in derived class*/ )
 {
     SwIndex* pStt = const_cast<SwIndex*>(&rIdx);
-	xub_StrLen nNewVal = rIdx.nIndex;
+	const xub_StrLen nNewVal = rIdx.nIndex;
 	if( bNeg )
 	{
-		xub_StrLen nLast = rIdx.GetIndex() + nDiff;
+		const xub_StrLen nLast = rIdx.GetIndex() + nDiff;
 		while( pStt && pStt->nIndex == nNewVal )
 		{
 			pStt->nIndex = nNewVal;

Modified: openoffice/branches/AOO410/main/sw/source/core/crsr/bookmrk.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/core/crsr/bookmrk.cxx?rev=1574113&r1=1574112&r2=1574113&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/core/crsr/bookmrk.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/core/crsr/bookmrk.cxx Tue Mar  4 14:39:44 2014
@@ -74,25 +74,29 @@ namespace
         const sal_Unicode aStartMark,
         const sal_Unicode aEndMark)
     {
-        SwPosition& rStart = pField->GetMarkStart();
-        SwPosition& rEnd = pField->GetMarkEnd();
-        SwTxtNode const*const pStartTxtNode =
-            rStart.nNode.GetNode().GetTxtNode();
-        SwTxtNode const*const pEndTxtNode = rEnd.nNode.GetNode().GetTxtNode();
-        const sal_Unicode ch_start=pStartTxtNode->GetTxt().GetChar(rStart.nContent.GetIndex());
-        const sal_Unicode ch_end=pEndTxtNode->GetTxt().GetChar(rEnd.nContent.GetIndex()-1);
-        SwPaM aStartPaM(rStart);
-        SwPaM aEndPaM(rEnd);
         io_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_UI_REPLACE, NULL);
+
+        SwPosition rStart = pField->GetMarkStart();
+        SwTxtNode const*const pStartTxtNode = rStart.nNode.GetNode().GetTxtNode();
+        const sal_Unicode ch_start=pStartTxtNode->GetTxt().GetChar(rStart.nContent.GetIndex());
         if(ch_start != aStartMark)
         {
+            SwPaM aStartPaM(rStart);
             io_pDoc->InsertString(aStartPaM, aStartMark);
             rStart.nContent--;
+            pField->SetMarkStartPos( rStart );
         }
+
+        const SwPosition& rEnd = pField->GetMarkEnd();
+        SwTxtNode const*const pEndTxtNode = rEnd.nNode.GetNode().GetTxtNode();
+        const sal_Unicode ch_end=pEndTxtNode->GetTxt().GetChar(rEnd.nContent.GetIndex()-1);
         if ( aEndMark && ( ch_end != aEndMark ) && ( rStart != rEnd ) )
         {
+            SwPaM aEndPaM(rEnd);
             io_pDoc->InsertString(aEndPaM, aEndMark);
         }
+
+
         io_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_UI_REPLACE, NULL);
     };
 
@@ -101,29 +105,31 @@ namespace
         const sal_Unicode aStartMark,
         const sal_Unicode aEndMark)
     {
-        SwPosition& rStart = pField->GetMarkStart();
-        SwPosition& rEnd = pField->GetMarkEnd();
+        io_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_UI_REPLACE, NULL);
+
+        const SwPosition& rStart = pField->GetMarkStart();
         SwTxtNode const*const pStartTxtNode = rStart.nNode.GetNode().GetTxtNode();
-        SwTxtNode const*const pEndTxtNode = rEnd.nNode.GetNode().GetTxtNode();
         const sal_Unicode ch_start=pStartTxtNode->GetTxt().GetChar(rStart.nContent.GetIndex());
-        xub_StrLen nEndPos = ( rEnd == rStart ||  rEnd.nContent.GetIndex() == 0 ) ?
-            rEnd.nContent.GetIndex() : rEnd.nContent.GetIndex() - 1;
-        const sal_Unicode ch_end=pEndTxtNode->GetTxt().GetChar( nEndPos );
-        SwPaM aStartPaM(rStart);
-        SwPaM aEndPaM(rEnd);
-        io_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_UI_REPLACE, NULL);
         if( ch_start == aStartMark )
         {
             SwPaM aStart(rStart, rStart);
             aStart.End()->nContent++;
             io_pDoc->DeleteRange(aStart);
         }
+
+        const SwPosition& rEnd = pField->GetMarkEnd();
+        SwTxtNode const*const pEndTxtNode = rEnd.nNode.GetNode().GetTxtNode();
+        const xub_StrLen nEndPos = ( rEnd == rStart ||  rEnd.nContent.GetIndex() == 0 )
+                                   ? rEnd.nContent.GetIndex()
+                                   : rEnd.nContent.GetIndex() - 1;
+        const sal_Unicode ch_end=pEndTxtNode->GetTxt().GetChar( nEndPos );
         if ( ch_end == aEndMark )
         {
             SwPaM aEnd(rEnd, rEnd);
             aEnd.Start()->nContent--;
             io_pDoc->DeleteRange(aEnd);
         }
+
         io_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_UI_REPLACE, NULL);
     };
 }
@@ -315,6 +321,22 @@ namespace sw { namespace mark
             SetOtherMarkPos(GetMarkPos());
     }
 
+    void Fieldmark::SetMarkStartPos( const SwPosition& rNewStartPos )
+    {
+        if ( GetMarkPos( ) <= GetOtherMarkPos( ) )
+            return SetMarkPos( rNewStartPos );
+        else
+            return SetOtherMarkPos( rNewStartPos );
+    }
+
+    void Fieldmark::SetMarkEndPos( const SwPosition& rNewEndPos )
+    {
+        if ( GetMarkPos( ) <= GetOtherMarkPos( ) )
+            return SetOtherMarkPos( rNewEndPos );
+        else
+            return SetMarkPos( rNewEndPos );
+    }
+
     rtl::OUString Fieldmark::ToString( ) const
     {
         rtl::OUStringBuffer buf;
@@ -363,7 +385,9 @@ namespace sw { namespace mark
 
         // For some reason the end mark is moved from 1 by the Insert: we don't
         // want this for checkboxes
-        this->GetMarkEnd( ).nContent--;
+        SwPosition aNewEndPos = this->GetMarkEnd();
+        aNewEndPos.nContent--;
+        SetMarkEndPos( aNewEndPos );
     }
     void CheckboxFieldmark::SetChecked(bool checked)
     {

Modified: openoffice/branches/AOO410/main/sw/source/core/crsr/crossrefbookmark.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/core/crsr/crossrefbookmark.cxx?rev=1574113&r1=1574112&r2=1574113&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/core/crsr/crossrefbookmark.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/core/crsr/crossrefbookmark.cxx Tue Mar  4 14:39:44
2014
@@ -58,7 +58,7 @@ namespace sw { namespace mark
         MarkBase::SetMarkPos(rNewPos);
     }
 
-    SwPosition& CrossRefBookmark::GetOtherMarkPos() const
+    const SwPosition& CrossRefBookmark::GetOtherMarkPos() const
     {
         OSL_PRECOND(false,
             "<SwCrossRefBookmark::GetOtherMarkPos(..)>"

Modified: openoffice/branches/AOO410/main/sw/source/core/doc/docbm.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/core/doc/docbm.cxx?rev=1574113&r1=1574112&r2=1574113&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/core/doc/docbm.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/core/doc/docbm.cxx Tue Mar  4 14:39:44 2014
@@ -820,28 +820,41 @@ namespace sw { namespace mark
             case IDocumentMarkAccess::BOOKMARK:
             case IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK:
             case IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK:
-                // if(dynamic_cast<IBookmark*>)
                 {
                     IDocumentMarkAccess::iterator_t ppBookmark = lcl_FindMark(m_vBookmarks,
*ppMark);
-                    OSL_ENSURE(ppBookmark != m_vBookmarks.end(),
-                        "<MarkManager::deleteMark(..)>"
-                        " - Bookmark not found.");
-                    m_vBookmarks.erase(ppBookmark);
+                    if ( ppBookmark != m_vBookmarks.end() )
+                    {
+                        m_vBookmarks.erase(ppBookmark);
+                    }
+                    else
+                    {
+                        OSL_ENSURE( false, "<MarkManager::deleteMark(..)> - Bookmark
not found in Bookmark container.");
+                    }
 
                     ppBookmark = lcl_FindMark(m_vCommonMarks, *ppMark);
-                    m_vCommonMarks.erase(ppBookmark);
+                    if ( ppBookmark != m_vCommonMarks.end() )
+                    {
+                        m_vCommonMarks.erase(ppBookmark);
+                    }
+                    else
+                    {
+                        OSL_ENSURE( false, "<MarkManager::deleteMark(..)> - Bookmark
not found in common mark container.");
+                    }
                 }
                 break;
 
             case IDocumentMarkAccess::TEXT_FIELDMARK:
             case IDocumentMarkAccess::CHECKBOX_FIELDMARK:
-                // if(dynamic_cast<IFieldmark*>
                 {
                     IDocumentMarkAccess::iterator_t ppFieldmark = lcl_FindMark(m_vFieldmarks,
*ppMark);
-                    OSL_ENSURE(ppFieldmark != m_vFieldmarks.end(),
-                        "<MarkManager::deleteMark(..)>"
-                        " - Bookmark not found.");
-                    m_vFieldmarks.erase(ppFieldmark);
+                    if ( ppFieldmark != m_vFieldmarks.end() )
+                    {
+                        m_vFieldmarks.erase(ppFieldmark);
+                    }
+                    else
+                    {
+                        OSL_ENSURE( false, "<MarkManager::deleteMark(..)> - Fieldmark
not found in Fieldmark container.");
+                    }
 
                     sw::mark::TextFieldmark* pTextFieldmark = dynamic_cast<sw::mark::TextFieldmark*>(ppMark->get());
                     if ( pTextFieldmark )
@@ -850,15 +863,28 @@ namespace sw { namespace mark
                     }
 
                     ppFieldmark = lcl_FindMark(m_vCommonMarks, *ppMark);
-                    m_vCommonMarks.erase(ppFieldmark);
+                    if ( ppFieldmark != m_vCommonMarks.end() )
+                    {
+                        m_vCommonMarks.erase(ppFieldmark);
+                    }
+                    else
+                    {
+                        OSL_ENSURE( false, "<MarkManager::deleteMark(..)> - Fieldmark
not found in common mark container.");
+                    }
                 }
                 break;
 
             case IDocumentMarkAccess::ANNOTATIONMARK:
                 {
                     IDocumentMarkAccess::iterator_t ppAnnotationMark = lcl_FindMark(m_vAnnotationMarks,
*ppMark);
-                    OSL_ENSURE( ppAnnotationMark != m_vAnnotationMarks.end(), "<MarkManager::deleteMark(..)>
- Annotation Mark not found." );
-                    m_vAnnotationMarks.erase(ppAnnotationMark);
+                    if ( ppAnnotationMark != m_vAnnotationMarks.end() )
+                    {
+                        m_vAnnotationMarks.erase(ppAnnotationMark);
+                    }
+                    else
+                    {
+                        OSL_ENSURE( false, "<MarkManager::deleteMark(..)> - Annotation
Mark not found in Annotation Mark container.");
+                    }
                 }
                 break;
 
@@ -867,7 +893,14 @@ namespace sw { namespace mark
             case IDocumentMarkAccess::UNO_BOOKMARK:
                 {
                     IDocumentMarkAccess::iterator_t ppOtherMark = lcl_FindMark(m_vCommonMarks,
*ppMark);
-                    m_vCommonMarks.erase(ppOtherMark);
+                    if ( ppOtherMark != m_vCommonMarks.end() )
+                    {
+                        m_vCommonMarks.erase(ppOtherMark);
+                    }
+                    else
+                    {
+                        OSL_ENSURE( false, "<MarkManager::deleteMark(..)> - Navigator
Reminder, DDE Mark or Uno Makr not found in common mark container.");
+                    }
                 }
                 break;
         }
@@ -1032,6 +1065,11 @@ namespace sw { namespace mark
         return sTmp;
     }
 
+    void MarkManager::assureSortedMarkContainers() const
+    {
+        const_cast< MarkManager* >(this)->sortMarks();
+    }
+
     void MarkManager::sortSubsetMarks()
     {
         sort(m_vCommonMarks.begin(), m_vCommonMarks.end(), &lcl_MarkOrderingByStart);

Modified: openoffice/branches/AOO410/main/sw/source/core/inc/MarkManager.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/core/inc/MarkManager.hxx?rev=1574113&r1=1574112&r2=1574113&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/core/inc/MarkManager.hxx (original)
+++ openoffice/branches/AOO410/main/sw/source/core/inc/MarkManager.hxx Tue Mar  4 14:39:44
2014
@@ -95,6 +95,8 @@ namespace sw { namespace mark
             virtual sal_Int32 getAnnotationMarksCount() const;
             virtual const_iterator_t findAnnotationMark( const ::rtl::OUString& rName
) const;
 
+            virtual void assureSortedMarkContainers() const;
+
         private:
             // make names
             ::rtl::OUString getUniqueMarkName(const ::rtl::OUString& rName) const;

Modified: openoffice/branches/AOO410/main/sw/source/core/inc/bookmrk.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/core/inc/bookmrk.hxx?rev=1574113&r1=1574112&r2=1574113&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/core/inc/bookmrk.hxx (original)
+++ openoffice/branches/AOO410/main/sw/source/core/inc/bookmrk.hxx Tue Mar  4 14:39:44 2014
@@ -49,17 +49,17 @@ namespace sw { namespace mark
     {
         public:
             //getters
-            virtual SwPosition& GetMarkPos() const
+            virtual const SwPosition& GetMarkPos() const
                 { return *m_pPos1; }
             virtual const ::rtl::OUString& GetName() const
                 { return m_aName; }
             virtual bool IsCoveringPosition(const SwPosition& rPos) const;
-            virtual SwPosition& GetOtherMarkPos() const
+            virtual const SwPosition& GetOtherMarkPos() const
             {
                 OSL_PRECOND(IsExpanded(), "<SwPosition::GetOtherMarkPos(..)> - I have
no other Pos set." );
                 return *m_pPos2;
             }
-            virtual SwPosition& GetMarkStart() const
+            virtual const SwPosition& GetMarkStart() const
             {
                 if( !IsExpanded() ) return GetMarkPos( );
                 if ( GetMarkPos( ) < GetOtherMarkPos( ) )
@@ -67,7 +67,7 @@ namespace sw { namespace mark
                 else
                     return GetOtherMarkPos( );
             }
-            virtual SwPosition& GetMarkEnd() const
+            virtual const SwPosition& GetMarkEnd() const
             {
                 if( !IsExpanded() ) return GetMarkPos();
                 if ( GetMarkPos( ) > GetOtherMarkPos( ) )
@@ -228,6 +228,9 @@ namespace sw { namespace mark
             virtual void SetFieldHelptext(const ::rtl::OUString& aFieldHelptext)
                 { m_aFieldHelptext = aFieldHelptext; }
 
+            void SetMarkStartPos( const SwPosition& rNewStartPos );
+            void SetMarkEndPos( const SwPosition& rNewEndPos );
+
             virtual void Invalidate();
             virtual rtl::OUString ToString() const;
         private:

Modified: openoffice/branches/AOO410/main/sw/source/core/inc/crossrefbookmark.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/core/inc/crossrefbookmark.hxx?rev=1574113&r1=1574112&r2=1574113&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/core/inc/crossrefbookmark.hxx (original)
+++ openoffice/branches/AOO410/main/sw/source/core/inc/crossrefbookmark.hxx Tue Mar  4 14:39:44
2014
@@ -41,10 +41,10 @@ namespace sw { namespace mark
                 const ::rtl::OUString& rPrefix);
 
             // getters
-            virtual SwPosition& GetOtherMarkPos() const;
-            virtual SwPosition& GetMarkStart() const
+            virtual const SwPosition& GetOtherMarkPos() const;
+            virtual const SwPosition& GetMarkStart() const
                 { return *m_pPos1; }
-            virtual SwPosition& GetMarkEnd() const
+            virtual const SwPosition& GetMarkEnd() const
                 { return *m_pPos1; }
             virtual bool IsExpanded() const
                 { return false; }

Modified: openoffice/branches/AOO410/main/sw/source/core/txtnode/ndtxt.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/sw/source/core/txtnode/ndtxt.cxx?rev=1574113&r1=1574112&r2=1574113&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/sw/source/core/txtnode/ndtxt.cxx (original)
+++ openoffice/branches/AOO410/main/sw/source/core/txtnode/ndtxt.cxx Tue Mar  4 14:39:44 2014
@@ -1028,6 +1028,7 @@ void SwTxtNode::Update(
         }
     }
 
+    bool bSortMarks = false;
     SwIndexReg aTmpIdxReg;
     if ( !bNegative && !bDelete )
     {
@@ -1086,6 +1087,7 @@ void SwTxtNode::Update(
                     rPos.GetIndex() == rIdx.GetIndex() )
                 {
                     rIdx.Assign( &aTmpIdxReg, rIdx.GetIndex() );
+                    bSortMarks = true;
                 }
             }
         }
@@ -1104,6 +1106,10 @@ void SwTxtNode::Update(
     }
 
     aTmpIdxReg.MoveTo( *this );
+    if ( bSortMarks )
+    {
+        getIDocumentMarkAccess()->assureSortedMarkContainers();
+    }
 }
 
 void SwTxtNode::_ChgTxtCollUpdateNum( const SwTxtFmtColl *pOldColl,



Mime
View raw message