[Libreoffice-commits] .: sw/inc sw/source

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Fri Oct 7 08:00:53 PDT 2011


 sw/inc/cmdid.h                      |    1 
 sw/inc/editsh.hxx                   |   17 +++++++-----
 sw/source/core/edit/edatmisc.cxx    |   31 +++++++++++++----------
 sw/source/core/edit/edattr.cxx      |   48 +++++++++++++++++++++---------------
 sw/source/core/edit/editsh.cxx      |    4 +--
 sw/source/core/edit/ednumber.cxx    |   19 +++++++-------
 sw/source/ui/docvw/PageBreakWin.cxx |   34 +++++++++++++++----------
 sw/source/ui/inc/uiitems.hxx        |   16 ++++++++++++
 sw/source/ui/inc/wrtsh.hxx          |    2 -
 sw/source/ui/shells/textsh1.cxx     |   41 +++++++++++++++++++++---------
 sw/source/ui/utlui/uiitems.cxx      |   25 ++++++++++++++++++
 sw/source/ui/wrtsh/wrtsh1.cxx       |    9 +++---
 12 files changed, 167 insertions(+), 80 deletions(-)

New commits:
commit eb0e2fcf15ed37f56c2334d292bdc1fb054bc287
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Fri Oct 7 16:55:03 2011 +0200

    Page Break: Fixed part of the Edit menu action cursors handling
    
    Added an optional SwPaM argument to SID_PARA_DLG action to avoid
    changing the current cursor before showing the dialog.
    
    Set the focus to SwEditWin after the action to continue editing the
    document.

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 97f6e10..fae2a95 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -1137,6 +1137,7 @@ included in c-context files, so c++ style stuff will cause problems.
 #define FN_SHAPE_POSITION_LAYOUT_DIR    (FN_PARAM2+24)
 #define FN_SHAPE_STARTPOSITION_IN_HORI_L2R (FN_PARAM2+25)
 #define FN_SHAPE_ENDPOSITION_IN_HORI_L2R   (FN_PARAM2+26)
+#define FN_PARAM_PAM                    (FN_PARAM2+27) /* Point and Mark */
 
 /*--------------------------------------------------------------------
     Bereich: Druckoptionen
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index d1e423f..f821dca 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -247,10 +247,12 @@ public:
     // the requested item set as a LR-SPACE item, if corresponding node has not
     // its own indent attributes and the position-and-space mode of the list
     // level is SvxNumberFormat::LABEL_ALIGNMENT.
+    sal_Bool GetPaMAttr( SwPaM* pPaM, SfxItemSet& ,
+                     const bool bMergeIndentValuesOfNumRule = false ) const;
     sal_Bool GetCurAttr( SfxItemSet& ,
                      const bool bMergeIndentValuesOfNumRule = false ) const;
     void SetAttr( const SfxPoolItem&, sal_uInt16 nFlags = 0 );
-    void SetAttr( const SfxItemSet&, sal_uInt16 nFlags = 0 );
+    void SetAttr( const SfxItemSet&, sal_uInt16 nFlags = 0, SwPaM* pCrsr = NULL );
 
     // Set attribute as new default attribute in document.
     void SetDefault( const SfxPoolItem& );
@@ -258,7 +260,7 @@ public:
     // Query default attribute of document.
     const SfxPoolItem& GetDefault( sal_uInt16 nFmtHint ) const;
 
-    void ResetAttr( const std::set<sal_uInt16> &attrs = std::set<sal_uInt16>() );
+    void ResetAttr( const std::set<sal_uInt16> &attrs = std::set<sal_uInt16>(), SwPaM* pCrsr = NULL );
     void GCAttr();
 
     // Returns the scripttpye of the selection.
@@ -296,6 +298,7 @@ public:
     sal_uInt16 GetTxtFmtCollCount() const;
     SwTxtFmtColl& GetTxtFmtColl( sal_uInt16 nTxtFmtColl) const;
     SwTxtFmtColl* GetCurTxtFmtColl() const;
+    SwTxtFmtColl* GetPaMTxtFmtColl( SwPaM* pPaM ) const;
 
     // #i62675#
     // Add 2nd optional parameter <bResetListAttrs> - see also <SwDoc::SetTxtFmtColl(..)>
@@ -489,11 +492,11 @@ public:
     void ChgNumRuleFmts( const SwNumRule& rRule );
 
     // Set (and query if) a numbering with StartFlag starts at current PointPos.
-    void SetNumRuleStart( sal_Bool bFlag = sal_True );
-    sal_Bool IsNumRuleStart() const;
-    void SetNodeNumStart( sal_uInt16 nStt );
+    void SetNumRuleStart( sal_Bool bFlag = sal_True, SwPaM* pCrsr = NULL );
+    sal_Bool IsNumRuleStart( SwPaM* pPaM = NULL ) const;
+    void SetNodeNumStart( sal_uInt16 nStt, SwPaM* = NULL );
 
-    sal_uInt16 GetNodeNumStart() const;
+    sal_uInt16 GetNodeNumStart( SwPaM* pPaM = NULL ) const;
 
     sal_Bool ReplaceNumRule( const String& rOldRule, const String& rNewRule );
 
@@ -760,7 +763,7 @@ public:
     sal_uInt16 GetINetAttrs( SwGetINetAttrs& rArr );
 
     String GetDropTxt( const sal_uInt16 nChars ) const;
-    void   ReplaceDropTxt( const String &rStr );
+    void   ReplaceDropTxt( const String &rStr, SwPaM* pPaM = NULL );
 
     // May an outline be moved or copied?
     // Check whether it's in text body, not in table, and not read-only (move).
diff --git a/sw/source/core/edit/edatmisc.cxx b/sw/source/core/edit/edatmisc.cxx
index c4ba463..6754314 100644
--- a/sw/source/core/edit/edatmisc.cxx
+++ b/sw/source/core/edit/edatmisc.cxx
@@ -44,20 +44,22 @@
  *************************************/
 
 
-void SwEditShell::ResetAttr( const std::set<sal_uInt16> &attrs )
+void SwEditShell::ResetAttr( const std::set<sal_uInt16> &attrs, SwPaM* pPaM )
 {
     SET_CURR_SHELL( this );
+    SwPaM* pCrsr = pPaM ? pPaM : GetCrsr( );
+
     StartAllAction();
-    sal_Bool bUndoGroup = GetCrsr()->GetNext() != GetCrsr();
+    sal_Bool bUndoGroup = pCrsr->GetNext() != pCrsr;
     if( bUndoGroup )
     {
         GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_RESETATTR, NULL);
     }
 
-        FOREACHPAM_START(this)
-
-                GetDoc()->ResetAttrs(*PCURCRSR, sal_True, attrs);
-        FOREACHPAM_END()
+        SwPaM* pStartCrsr = pCrsr;
+        do {
+                GetDoc()->ResetAttrs(*pCrsr, sal_True, attrs);
+        } while ( ( pCrsr = ( SwPaM* ) pCrsr->GetNext() ) != pStartCrsr );
 
     if( bUndoGroup )
     {
@@ -146,23 +148,26 @@ void SwEditShell::SetAttr( const SfxPoolItem& rHint, sal_uInt16 nFlags )
 }
 
 
-void SwEditShell::SetAttr( const SfxItemSet& rSet, sal_uInt16 nFlags )
+void SwEditShell::SetAttr( const SfxItemSet& rSet, sal_uInt16 nFlags, SwPaM* pPaM )
 {
     SET_CURR_SHELL( this );
+
+    SwPaM* pCrsr = pPaM ? pPaM : GetCrsr();
     StartAllAction();
-    SwPaM* pCrsr = GetCrsr();
     if( pCrsr->GetNext() != pCrsr )     // Ring von Cursorn
     {
         sal_Bool bIsTblMode = IsTableMode();
         GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL);
 
-        FOREACHPAM_START(this)
-            if( PCURCRSR->HasMark() && ( bIsTblMode ||
-                *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() ))
+        SwPaM* pTmpCrsr = pCrsr;
+        SwPaM* pStartPaM = pCrsr;
+        do {
+            if( pTmpCrsr->HasMark() && ( bIsTblMode ||
+                *pTmpCrsr->GetPoint() != *pTmpCrsr->GetMark() ))
             {
-                GetDoc()->InsertItemSet(*PCURCRSR, rSet, nFlags );
+                GetDoc()->InsertItemSet(*pTmpCrsr, rSet, nFlags );
             }
-        FOREACHPAM_END()
+        } while ( ( pTmpCrsr = (SwPaM*)pTmpCrsr->GetNext() ) != pStartPaM );
 
         GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL);
     }
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index a676634..9e8047d 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -71,7 +71,7 @@ const sal_uInt16& getMaxLookup()
     return nMaxLookup;
 }
 
-sal_Bool SwEditShell::GetCurAttr( SfxItemSet& rSet,
+sal_Bool SwEditShell::GetPaMAttr( SwPaM* pPaM, SfxItemSet& rSet,
                               const bool bMergeIndentValuesOfNumRule ) const
 {
     if( GetCrsrCnt() > getMaxLookup() )
@@ -83,14 +83,13 @@ sal_Bool SwEditShell::GetCurAttr( SfxItemSet& rSet,
     SfxItemSet aSet( *rSet.GetPool(), rSet.GetRanges() );
     SfxItemSet *pSet = &rSet;
 
-    FOREACHPAM_START(this)
-
+    SwPaM* pStartPaM = pPaM;
+    do {
         // #i27615# if the cursor is in front of the numbering label
         // the attributes to get are those from the numbering format.
-        if (PCURCRSR->IsInFrontOfLabel())
+        if (pPaM->IsInFrontOfLabel())
         {
-            SwTxtNode * pTxtNd =
-                PCURCRSR->GetPoint()->nNode.GetNode().GetTxtNode();
+            SwTxtNode * pTxtNd = pPaM->GetPoint()->nNode.GetNode().GetTxtNode();
 
             if (pTxtNd)
             {
@@ -111,10 +110,10 @@ sal_Bool SwEditShell::GetCurAttr( SfxItemSet& rSet,
             continue;
         }
 
-        sal_uLong nSttNd = PCURCRSR->GetMark()->nNode.GetIndex(),
-              nEndNd = PCURCRSR->GetPoint()->nNode.GetIndex();
-        xub_StrLen nSttCnt = PCURCRSR->GetMark()->nContent.GetIndex(),
-                   nEndCnt = PCURCRSR->GetPoint()->nContent.GetIndex();
+        sal_uLong nSttNd = pPaM->GetMark()->nNode.GetIndex(),
+              nEndNd = pPaM->GetPoint()->nNode.GetIndex();
+        xub_StrLen nSttCnt = pPaM->GetMark()->nContent.GetIndex(),
+                   nEndCnt = pPaM->GetPoint()->nContent.GetIndex();
 
         if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt ))
         {
@@ -167,24 +166,35 @@ sal_Bool SwEditShell::GetCurAttr( SfxItemSet& rSet,
             pSet = &aSet;
         }
 
-    FOREACHPAM_END()
+    } while ( ( pPaM = (SwPaM*)pPaM->GetNext() ) != pStartPaM );
 
     return sal_True;
 }
 
-SwTxtFmtColl* SwEditShell::GetCurTxtFmtColl() const
+sal_Bool SwEditShell::GetCurAttr( SfxItemSet& rSet,
+                              const bool bMergeIndentValuesOfNumRule ) const
+{
+    return GetPaMAttr( GetCrsr(), rSet, bMergeIndentValuesOfNumRule );
+}
+
+SwTxtFmtColl* SwEditShell::GetCurTxtFmtColl( ) const
+{
+    return GetPaMTxtFmtColl( GetCrsr() );
+}
+
+SwTxtFmtColl* SwEditShell::GetPaMTxtFmtColl( SwPaM* pPaM ) const
 {
     SwTxtFmtColl *pFmt = 0;
 
     if ( GetCrsrCnt() > getMaxLookup() )
         return 0;
 
-    FOREACHPAM_START(this)
-
-        sal_uLong nSttNd = PCURCRSR->GetMark()->nNode.GetIndex(),
-              nEndNd = PCURCRSR->GetPoint()->nNode.GetIndex();
-        xub_StrLen nSttCnt = PCURCRSR->GetMark()->nContent.GetIndex(),
-                   nEndCnt = PCURCRSR->GetPoint()->nContent.GetIndex();
+    SwPaM* pStartPaM = pPaM;
+    do {
+        sal_uLong nSttNd = pPaM->GetMark()->nNode.GetIndex(),
+              nEndNd = pPaM->GetPoint()->nNode.GetIndex();
+        xub_StrLen nSttCnt = pPaM->GetMark()->nContent.GetIndex(),
+                   nEndCnt = pPaM->GetPoint()->nContent.GetIndex();
 
         if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt ))
         {
@@ -209,8 +219,8 @@ SwTxtFmtColl* SwEditShell::GetCurTxtFmtColl() const
                     break;
             }
         }
+    } while ( ( pPaM = ( SwPaM* )pPaM->GetNext() ) != pStartPaM );
 
-    FOREACHPAM_END()
     return pFmt;
 }
 
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index e1a1a8a..85fd54e 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -574,9 +574,9 @@ String SwEditShell::GetDropTxt( const sal_uInt16 nChars ) const
     return aTxt;
 }
 
-void SwEditShell::ReplaceDropTxt( const String &rStr )
+void SwEditShell::ReplaceDropTxt( const String &rStr, SwPaM* pPaM )
 {
-    SwPaM* pCrsr = GetCrsr();
+    SwPaM* pCrsr = pPaM ? pPaM : GetCrsr();
     if( pCrsr->GetPoint()->nNode == pCrsr->GetMark()->nNode &&
         pCrsr->GetNode()->GetTxtNode()->IsTxtNode() )
     {
diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx
index 64b090a..1dba53c 100644
--- a/sw/source/core/edit/ednumber.cxx
+++ b/sw/source/core/edit/ednumber.cxx
@@ -719,11 +719,10 @@ sal_Bool SwEditShell::ReplaceNumRule( const String& rOldRule, const String& rNew
     return bRet;
 }
 
-void SwEditShell::SetNumRuleStart( sal_Bool bFlag )
+void SwEditShell::SetNumRuleStart( sal_Bool bFlag, SwPaM* pPaM )
 {
     StartAllAction();
-
-    SwPaM* pCrsr = GetCrsr();
+    SwPaM* pCrsr = pPaM ? pPaM : GetCrsr();
     if( pCrsr->GetNext() != pCrsr )         // Mehrfachselektion ?
     {
         GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
@@ -739,20 +738,21 @@ void SwEditShell::SetNumRuleStart( sal_Bool bFlag )
     EndAllAction();
 }
 
-sal_Bool SwEditShell::IsNumRuleStart() const
+sal_Bool SwEditShell::IsNumRuleStart( SwPaM* pPaM ) const
 {
     sal_Bool bResult = sal_False;
-    const SwTxtNode* pTxtNd = GetCrsr()->GetNode()->GetTxtNode();
+    SwPaM* pCrsr = pPaM ? pPaM : GetCrsr( );
+    const SwTxtNode* pTxtNd = pCrsr->GetNode()->GetTxtNode();
     if( pTxtNd )
         bResult = pTxtNd->IsListRestart() ? sal_True : sal_False;
     return bResult;
 }
 
-void SwEditShell::SetNodeNumStart( sal_uInt16 nStt )
+void SwEditShell::SetNodeNumStart( sal_uInt16 nStt, SwPaM* pPaM )
 {
     StartAllAction();
 
-    SwPaM* pCrsr = GetCrsr();
+    SwPaM* pCrsr = pPaM ? pPaM : GetCrsr();
     if( pCrsr->GetNext() != pCrsr )         // Mehrfachselektion ?
     {
         GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
@@ -768,9 +768,10 @@ void SwEditShell::SetNodeNumStart( sal_uInt16 nStt )
     EndAllAction();
 }
 
-sal_uInt16 SwEditShell::GetNodeNumStart() const
+sal_uInt16 SwEditShell::GetNodeNumStart( SwPaM* pPaM ) const
 {
-    const SwTxtNode* pTxtNd = GetCrsr()->GetNode()->GetTxtNode();
+    SwPaM* pCrsr = pPaM ? pPaM : GetCrsr();
+    const SwTxtNode* pTxtNd = pCrsr->GetNode()->GetTxtNode();
     // correction: check, if list restart value is set at text node and
     // use new method <SwTxtNode::GetAttrListRestartValue()>.
     // return USHRT_MAX, if no list restart value is found.
diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx
index 6566488..96ea560 100644
--- a/sw/source/ui/docvw/PageBreakWin.cxx
+++ b/sw/source/ui/docvw/PageBreakWin.cxx
@@ -38,6 +38,7 @@
 #include <PageBreakWin.hxx>
 #include <pagefrm.hxx>
 #include <PostItMgr.hxx>
+#include <uiitems.hxx>
 #include <view.hxx>
 #include <viewopt.hxx>
 #include <wrtsh.hxx>
@@ -248,30 +249,37 @@ void SwPageBreakWin::Select( )
 
                 if ( pBodyFrm )
                 {
-                    SwWrtShell& rSh = GetEditWin()->GetView().GetWrtShell();
-                    rSh.Push( );
-                    rSh.ClearMark();
-                    sal_Bool bOldLock = rSh.IsViewLocked();
-                    rSh.LockView( sal_True );
-
-                    SwCntntFrm *pCnt = const_cast< SwCntntFrm* >( pBodyFrm->ContainsCntnt() );
-                    SwCntntNode* pNd = pCnt->GetNode();
-                    rSh.SetSelection( *pNd );
-
                     if ( pBodyFrm->Lower()->IsTabFrm() )
                     {
+                        SwWrtShell& rSh = GetEditWin()->GetView().GetWrtShell();
+                        rSh.Push( );
+                        rSh.ClearMark();
+                        sal_Bool bOldLock = rSh.IsViewLocked();
+                        rSh.LockView( sal_True );
+
+                        SwCntntFrm *pCnt = const_cast< SwCntntFrm* >( pBodyFrm->ContainsCntnt() );
+                        SwCntntNode* pNd = pCnt->GetNode();
+                        rSh.SetSelection( *pNd );
+
                         SfxUInt16Item aItem( GetEditWin()->GetView().GetPool( ).GetWhich( FN_FORMAT_TABLE_DLG ), TP_TABLE_TEXTFLOW );
                         GetEditWin()->GetView().GetViewFrame()->GetDispatcher()->Execute(
                                 FN_FORMAT_TABLE_DLG, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aItem, NULL );
+
+                        rSh.LockView( bOldLock );
+                        rSh.Pop( sal_False );
                     }
                     else
                     {
+                        SwCntntFrm *pCnt = const_cast< SwCntntFrm* >( pBodyFrm->ContainsCntnt() );
+                        SwCntntNode* pNd = pCnt->GetNode();
+
+                        SwPaM aPaM( *pNd );
+                        SwPaMItem aPaMItem( GetEditWin()->GetView().GetPool( ).GetWhich( FN_PARAM_PAM ), &aPaM );
                         SfxUInt16Item aItem( GetEditWin()->GetView().GetPool( ).GetWhich( SID_PARA_DLG ), TP_PARA_EXT );
                         GetEditWin()->GetView().GetViewFrame()->GetDispatcher()->Execute(
-                                SID_PARA_DLG, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aItem, NULL );
+                                SID_PARA_DLG, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aItem, &aPaMItem, NULL );
                     }
-                    rSh.LockView( bOldLock );
-                    rSh.Pop( sal_False );
+                    GetEditWin()->GrabFocus( );
                 }
             }
             break;
diff --git a/sw/source/ui/inc/uiitems.hxx b/sw/source/ui/inc/uiitems.hxx
index d575593..5cb5791 100644
--- a/sw/source/ui/inc/uiitems.hxx
+++ b/sw/source/ui/inc/uiitems.hxx
@@ -32,6 +32,7 @@
 #include "swdllapi.h"
 #include "cmdid.h"
 #include "pagedesc.hxx"
+#include "pam.hxx"
 
 class SwNumRule;
 class IntlWrapper;
@@ -107,6 +108,21 @@ public:
     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = 0 ) const;
 };
 
+class SW_DLLPUBLIC SwPaMItem : public SfxPoolItem
+{
+    SwPaM* m_pPaM;
+
+public:
+    SwPaMItem( const sal_uInt16 nId = FN_PARAM_PAM, SwPaM* pPaM = NULL);
+    SwPaMItem( const SwPaMItem& rItem );
+
+    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
+    virtual int             operator==( const SfxPoolItem& ) const;
+
+    void    SetValue(SwPaM * pPaM)   { m_pPaM= pPaM; }
+    SwPaM*   GetValue() const        { return m_pPaM; }
+};
+
 #endif // _UIITEMS_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx
index 7d0bbfd..3a71ca8 100644
--- a/sw/source/ui/inc/wrtsh.hxx
+++ b/sw/source/ui/inc/wrtsh.hxx
@@ -454,7 +454,7 @@ typedef sal_Bool (SwWrtShell:: *FNSimpleMove)();
 
     // automatic update of styles
     void AutoUpdateFrame(SwFrmFmt* pFmt, const SfxItemSet& rStyleSet);
-    void AutoUpdatePara(SwTxtFmtColl* pColl, const SfxItemSet& rStyleSet);
+    void AutoUpdatePara(SwTxtFmtColl* pColl, const SfxItemSet& rStyleSet, SwPaM* pPaM = NULL );
 
     // link for inserting ranges via Drag&Drop/Clipboard
     DECL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSectionData* );
diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx
index 55a268e..9fdb4b4 100644
--- a/sw/source/ui/shells/textsh1.cxx
+++ b/sw/source/ui/shells/textsh1.cxx
@@ -123,6 +123,7 @@
 #include <pam.hxx>
 #include <sfx2/objface.hxx>
 #include <langhelper.hxx>
+#include <uiitems.hxx>
 
 using namespace ::com::sun::star;
 
@@ -859,6 +860,21 @@ void SwTextShell::Execute(SfxRequest &rReq)
         }
         case SID_PARA_DLG:
         {
+            SwPaM* pPaM = NULL;
+
+            if ( pArgs )
+            {
+                const SfxPoolItem* pPaMItem = 0;
+                pArgs->GetItemState( GetPool().GetWhich( FN_PARAM_PAM ), sal_False, &pPaMItem );
+                if ( pPaMItem )
+                    pPaM = static_cast< const SwPaMItem* >( pPaMItem )->GetValue( );
+            }
+
+            if ( !pPaM )
+                pPaM = rWrtSh.GetCrsr();
+
+            bool bUseCurCrsr = true;
+
             FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView()));
             SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
 
@@ -881,7 +897,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
                             FN_DROP_TEXT,               FN_DROP_CHAR_STYLE_NAME,
                             0);
             // get also the list level indent values merged as LR-SPACE item, if needed.
-            rWrtSh.GetCurAttr( aCoreSet, true );
+            rWrtSh.GetPaMAttr( pPaM, aCoreSet, true );
             aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE,
                             ::GetHtmlMode(GetView().GetDocShell())));
 
@@ -904,8 +920,9 @@ void SwTextShell::Execute(SfxRequest &rReq)
             SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff );
             aCoreSet.Put( aOff );
 
-            // BoxInfo setzen
-            ::PrepareBoxInfo( aCoreSet, rWrtSh );
+            // Setting the BoxInfo if based on the current cursor
+            if ( bUseCurCrsr )
+                ::PrepareBoxInfo( aCoreSet, rWrtSh );
 
             //aktuelles Seitenformat
             ::SwToSfxPageDescAttr( aCoreSet );
@@ -915,12 +932,12 @@ void SwTextShell::Execute(SfxRequest &rReq)
                 nDefPage = ((SfxUInt16Item *)pItem)->GetValue();
 
             // Numerierungseigenschaften
-            if(rWrtSh.GetCurNumRule())
+            if( rWrtSh.GetDoc()->GetCurrNumRule( *pPaM->GetPoint() ) )
             {
-                SfxBoolItem aStart( FN_NUMBER_NEWSTART, rWrtSh.IsNumRuleStart() );
+                SfxBoolItem aStart( FN_NUMBER_NEWSTART, rWrtSh.IsNumRuleStart( pPaM ) );
                 aCoreSet.Put(aStart);
                 SfxUInt16Item aStartAt( FN_NUMBER_NEWSTART_AT,
-                                        rWrtSh.GetNodeNumStart() );
+                                        rWrtSh.GetNodeNumStart( pPaM ) );
                 aCoreSet.Put(aStartAt);
             }
             SfxAbstractTabDialog* pDlg = NULL;
@@ -988,14 +1005,14 @@ void SwTextShell::Execute(SfxRequest &rReq)
                     if ( SFX_ITEM_SET == pSet->GetItemState(FN_DROP_TEXT, sal_False, &pItem) )
                     {
                         if ( ((SfxStringItem*)pItem)->GetValue().Len() )
-                            rWrtSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue());
+                            rWrtSh.ReplaceDropTxt(((SfxStringItem*)pItem)->GetValue(), pPaM);
                     }
-                    rWrtSh.SetAttr( *pSet );
+                    rWrtSh.SetAttr( *pSet, 0, pPaM );
                     rWrtSh.EndAction();
-                    SwTxtFmtColl* pColl = rWrtSh.GetCurTxtFmtColl();
+                    SwTxtFmtColl* pColl = rWrtSh.GetPaMTxtFmtColl( pPaM );
                     if(pColl && pColl->IsAutoUpdateFmt())
                     {
-                        rWrtSh.AutoUpdatePara(pColl, *pSet);
+                        rWrtSh.AutoUpdatePara(pColl, *pSet, pPaM);
                     }
                 }
 
@@ -1016,14 +1033,14 @@ void SwTextShell::Execute(SfxRequest &rReq)
                     {
                         nNumStart = ((SfxUInt16Item&)pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue();
                     }
-                    rWrtSh.SetNumRuleStart(bStart);
+                    rWrtSh.SetNumRuleStart(bStart, pPaM);
                     rWrtSh.SetNodeNumStart(nNumStart);
                 }
                 else if( SFX_ITEM_SET == pSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
                 {
                     sal_uInt16 nNumStart = ((SfxUInt16Item&)pSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue();
                     rWrtSh.SetNodeNumStart(nNumStart);
-                    rWrtSh.SetNumRuleStart(sal_False);
+                    rWrtSh.SetNumRuleStart(sal_False, pPaM);
                 }
                 // #i56253#
                 if ( bUndoNeeded )
diff --git a/sw/source/ui/utlui/uiitems.cxx b/sw/source/ui/utlui/uiitems.cxx
index 132d8cf..ef8e593 100644
--- a/sw/source/ui/utlui/uiitems.cxx
+++ b/sw/source/ui/utlui/uiitems.cxx
@@ -333,5 +333,30 @@ SfxPoolItem*     SwBackgroundDestinationItem::Clone( SfxItemPool * /*pPool*/ ) c
 }
 
 
+SwPaMItem::SwPaMItem( const sal_uInt16 nId, SwPaM* pPaM ) :
+    SfxPoolItem( nId ),
+    m_pPaM(pPaM)
+{
+}
+
+
+SwPaMItem::SwPaMItem( const SwPaMItem& rItem ) : SfxPoolItem( rItem )
+{
+    m_pPaM = rItem.m_pPaM;
+}
+
+
+SfxPoolItem* SwPaMItem::Clone( SfxItemPool * /*pPool*/ ) const
+{
+    return new SwPaMItem( *this );
+}
+
+int SwPaMItem::operator==( const SfxPoolItem& rAttr ) const
+{
+    OSL_ENSURE( SfxPoolItem::operator==(rAttr), "unequal types" );
+    const SwPaMItem& rItem = (SwPaMItem&)rAttr;
+    return ( m_pPaM == rItem.m_pPaM );
+}
+
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx
index 15efd5c..07a926d 100644
--- a/sw/source/ui/wrtsh/wrtsh1.cxx
+++ b/sw/source/ui/wrtsh/wrtsh1.cxx
@@ -1611,8 +1611,9 @@ void SwWrtShell::QuickUpdateStyle()
 }
 
 
-void SwWrtShell::AutoUpdatePara(SwTxtFmtColl* pColl, const SfxItemSet& rStyleSet)
+void SwWrtShell::AutoUpdatePara(SwTxtFmtColl* pColl, const SfxItemSet& rStyleSet, SwPaM* pPaM )
 {
+    SwPaM* pCrsr = pPaM ? pPaM : GetCrsr( );
     SfxItemSet aCoreSet( GetAttrPool(),
             RES_CHRATR_BEGIN,           RES_CHRATR_END - 1,
             RES_PARATR_BEGIN,           RES_PARATR_END - 1,
@@ -1624,7 +1625,7 @@ void SwWrtShell::AutoUpdatePara(SwTxtFmtColl* pColl, const SfxItemSet& rStyleSet
             SID_ATTR_PARA_MODEL,        SID_ATTR_PARA_KEEP,
             SID_ATTR_PARA_PAGENUM,      SID_ATTR_PARA_PAGENUM,
             0   );
-    GetCurAttr( aCoreSet );
+    GetPaMAttr( pCrsr, aCoreSet );
     sal_Bool bReset = sal_False;
     SfxItemIter aParaIter( aCoreSet );
     const SfxPoolItem* pParaItem = aParaIter.FirstItem();
@@ -1645,8 +1646,8 @@ void SwWrtShell::AutoUpdatePara(SwTxtFmtColl* pColl, const SfxItemSet& rStyleSet
     StartAction();
     if(bReset)
     {
-        ResetAttr();
-        SetAttr(aCoreSet);
+        ResetAttr( std::set<sal_uInt16>(), pCrsr );
+        SetAttr(aCoreSet, 0, pCrsr);
     }
     pDoc->ChgFmt(*pColl, rStyleSet );
     EndAction();


More information about the Libreoffice-commits mailing list