[Libreoffice-commits] core.git: 2 commits - editeng/source svx/source

Noel Grandin noel.grandin at collabora.co.uk
Wed Nov 23 07:35:15 UTC 2016


 editeng/source/editeng/editeng.cxx  |   10 ++++----
 editeng/source/editeng/editview.cxx |    2 -
 editeng/source/editeng/impedit.cxx  |   20 ++++++++---------
 editeng/source/editeng/impedit.hxx  |   42 ++++++++++++++++++++++--------------
 editeng/source/editeng/impedit2.cxx |   22 +++++++++---------
 svx/source/svdraw/svdedxv.cxx       |   22 +++++++++++-------
 6 files changed, 66 insertions(+), 52 deletions(-)

New commits:
commit 1a4cb47b27c059d92b4e94b249ca3974b72b35da
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Nov 23 09:19:10 2016 +0200

    convert GETCRSR constants to o3tl::typed_flags
    
    Change-Id: Ia367d9a1b73d6c5b7a7989da45af0f002c43413c

diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index c151c67..11912f6 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -958,7 +958,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v
     bool bAllowIdle = true;
     bool bReadOnly  = pEditView->IsReadOnly();
 
-    sal_uInt16 nNewCursorFlags = 0;
+    GetCursorFlags nNewCursorFlags = GetCursorFlags::NONE;
     bool bSetCursorFlags = true;
 
     EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() );
@@ -1091,9 +1091,9 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v
 
                     bMoved = true;
                     if ( nCode == KEY_HOME )
-                        nNewCursorFlags |= GETCRSR_STARTOFLINE;
+                        nNewCursorFlags |= GetCursorFlags::StartOfLine;
                     else if ( nCode == KEY_END )
-                        nNewCursorFlags |= GETCRSR_ENDOFLINE;
+                        nNewCursorFlags |= GetCursorFlags::EndOfLine;
 
                 }
 #if OSL_DEBUG_LEVEL > 1
@@ -2367,8 +2367,8 @@ Rectangle EditEngine::GetCharacterBounds( const EPosition& rPos ) const
     // Check against index, not paragraph
     if ( pNode && ( rPos.nIndex < pNode->Len() ) )
     {
-        aBounds = pImpEditEngine->PaMtoEditCursor( EditPaM( pNode, rPos.nIndex ), GETCRSR_TXTONLY );
-        Rectangle aR2 = pImpEditEngine->PaMtoEditCursor( EditPaM( pNode, rPos.nIndex+1 ), GETCRSR_TXTONLY|GETCRSR_ENDOFLINE );
+        aBounds = pImpEditEngine->PaMtoEditCursor( EditPaM( pNode, rPos.nIndex ), GetCursorFlags::TextOnly );
+        Rectangle aR2 = pImpEditEngine->PaMtoEditCursor( EditPaM( pNode, rPos.nIndex+1 ), GetCursorFlags::TextOnly|GetCursorFlags::EndOfLine );
         if ( aR2.Right() > aBounds.Right() )
             aBounds.Right() = aR2.Right();
     }
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 2d0ace8..732f774 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -971,7 +971,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link<SpellCallbackInfo
 
         aPopupMenu->RemoveDisabledEntries( true, true );
 
-        Rectangle aTempRect = pImpEditView->pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GETCRSR_TXTONLY );
+        Rectangle aTempRect = pImpEditView->pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly );
         Point aScreenPos = pImpEditView->GetWindowPos( aTempRect.TopLeft() );
         aScreenPos = pImpEditView->GetWindow()->OutputToScreenPixel( aScreenPos );
         aTempRect = pImpEditView->GetWindow()->LogicToPixel( Rectangle(aScreenPos, aTempRect.GetSize() ));
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index eeacfe0..1b8349b 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -82,7 +82,7 @@ ImpEditView::ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindo
     mpViewShell         = nullptr;
     mpOtherShell        = nullptr;
     nScrollDiffX        = 0;
-    nExtraCursorFlags   = 0;
+    nExtraCursorFlags   = GetCursorFlags::NONE;
     nCursorBidiLevel    = CURSOR_BIDILEVEL_DONTKNOW;
     pCursor             = nullptr;
     pDragAndDropInfo    = nullptr;
@@ -816,7 +816,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
 
     const ParaPortion* pParaPortion = pEditEngine->GetParaPortions()[nPara];
 
-    sal_uInt16 nShowCursorFlags = nExtraCursorFlags | GETCRSR_TXTONLY;
+    GetCursorFlags nShowCursorFlags = nExtraCursorFlags | GetCursorFlags::TextOnly;
 
     // Use CursorBidiLevel 0/1 in meaning of
     // 0: prefer portion end, normal mode
@@ -824,7 +824,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
 
     if ( ( GetCursorBidiLevel() != CURSOR_BIDILEVEL_DONTKNOW ) && GetCursorBidiLevel() )
     {
-        nShowCursorFlags |= GETCRSR_PREFERPORTIONSTART;
+        nShowCursorFlags |= GetCursorFlags::PreferPortionStart;
     }
 
     Rectangle aEditCursor = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, nShowCursorFlags );
@@ -833,7 +833,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
         if ( aPaM.GetNode()->Len() && ( aPaM.GetIndex() < aPaM.GetNode()->Len() ) )
         {
             // If we are behind a portion, and the next portion has other direction, we must change position...
-            aEditCursor.Left() = aEditCursor.Right() = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GETCRSR_TXTONLY|GETCRSR_PREFERPORTIONSTART ).Left();
+            aEditCursor.Left() = aEditCursor.Right() = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly|GetCursorFlags::PreferPortionStart ).Left();
 
             sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, true );
             const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
@@ -844,9 +844,9 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
             else
             {
                 EditPaM aNext = pEditEngine->CursorRight( aPaM );
-                Rectangle aTmpRect = pEditEngine->pImpEditEngine->PaMtoEditCursor( aNext, GETCRSR_TXTONLY );
+                Rectangle aTmpRect = pEditEngine->pImpEditEngine->PaMtoEditCursor( aNext, GetCursorFlags::TextOnly );
                 if ( aTmpRect.Top() != aEditCursor.Top() )
-                    aTmpRect = pEditEngine->pImpEditEngine->PaMtoEditCursor( aNext, GETCRSR_TXTONLY|GETCRSR_ENDOFLINE );
+                    aTmpRect = pEditEngine->pImpEditEngine->PaMtoEditCursor( aNext, GetCursorFlags::TextOnly|GetCursorFlags::EndOfLine );
                 aEditCursor.Right() = aTmpRect.Left();
             }
         }
@@ -1036,7 +1036,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
         CursorDirection nCursorDir = CursorDirection::NONE;
         if ( IsInsertMode() && !aEditSelection.HasRange() && ( pEditEngine->pImpEditEngine->HasDifferentRTLLevels( aPaM.GetNode() ) ) )
         {
-            sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, (nShowCursorFlags & GETCRSR_PREFERPORTIONSTART) != 0 );
+            sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, bool(nShowCursorFlags & GetCursorFlags::PreferPortionStart) );
             const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
             if (rTextPortion.IsRightToLeft())
                 nCursorDir = CursorDirection::RTL;
@@ -1237,7 +1237,7 @@ bool ImpEditView::MouseButtonUp( const MouseEvent& rMouseEvent )
     }
     nTravelXPos = TRAVEL_X_DONTKNOW;
     nCursorBidiLevel = CURSOR_BIDILEVEL_DONTKNOW;
-    nExtraCursorFlags = 0;
+    nExtraCursorFlags = GetCursorFlags::NONE;
     bClickedInSelection = false;
 
     if ( rMouseEvent.IsMiddle() && !bReadOnly &&
@@ -1265,8 +1265,8 @@ bool ImpEditView::MouseButtonDown( const MouseEvent& rMouseEvent )
     pEditEngine->CheckIdleFormatter();  // If fast typing and mouse button downs
     if ( pEditEngine->GetInternalEditStatus().NotifyCursorMovements() )
         pEditEngine->GetInternalEditStatus().GetPrevParagraph() = pEditEngine->GetEditDoc().GetPos( GetEditSelection().Max().GetNode() );
-    nTravelXPos = TRAVEL_X_DONTKNOW;
-    nExtraCursorFlags = 0;
+    nTravelXPos         = TRAVEL_X_DONTKNOW;
+    nExtraCursorFlags   = GetCursorFlags::NONE;
     nCursorBidiLevel    = CURSOR_BIDILEVEL_DONTKNOW;
     bClickedInSelection = IsSelectionAtPoint( rMouseEvent.GetPosPixel() );
     return pEditEngine->pImpEditEngine->MouseButtonDown( rMouseEvent, GetEditViewPtr() );
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 5cb4feb..2909167 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -56,23 +56,11 @@
 #include <i18nlangtag/lang.h>
 #include <rtl/ref.hxx>
 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
+#include <o3tl/typed_flags_set.hxx>
 
 #include <memory>
 #include <vector>
 
-#define DEL_LEFT    1
-#define DEL_RIGHT   2
-#define TRAVEL_X_DONTKNOW   0xFFFFFFFF
-#define CURSOR_BIDILEVEL_DONTKNOW   0xFFFF
-#define MAXCHARSINPARA      0x3FFF-CHARPOSGROW  // Max 16K, because WYSIWYG array
-
-#define GETCRSR_TXTONLY             0x0001
-#define GETCRSR_STARTOFLINE         0x0002
-#define GETCRSR_ENDOFLINE           0x0004
-#define GETCRSR_PREFERPORTIONSTART  0x0008
-
-#define LINE_SEP    '\x0A'
-
 class EditView;
 class EditEngine;
 class OutlinerSearchable;
@@ -103,6 +91,28 @@ namespace editeng {
     struct MisspellRanges;
 }
 
+#define DEL_LEFT    1
+#define DEL_RIGHT   2
+#define TRAVEL_X_DONTKNOW           0xFFFFFFFF
+#define CURSOR_BIDILEVEL_DONTKNOW   0xFFFF
+#define MAXCHARSINPARA              0x3FFF-CHARPOSGROW  // Max 16K, because WYSIWYG array
+#define LINE_SEP    '\x0A'
+
+#define ATTRSPECIAL_WHOLEWORD   1
+#define ATTRSPECIAL_EDGE        2
+
+enum class GetCursorFlags {
+    NONE                = 0x0000,
+    TextOnly            = 0x0001,
+    StartOfLine         = 0x0002,
+    EndOfLine           = 0x0004,
+    PreferPortionStart  = 0x0008,
+};
+namespace o3tl {
+    template<> struct typed_flags<GetCursorFlags> : is_typed_flags<GetCursorFlags, 0x0f> {};
+}
+
+
 struct DragAndDropInfo
 {
     Rectangle           aCurCursor;
@@ -234,7 +244,7 @@ private:
     long                nInvMore;
     EVControlBits       nControl;
     sal_uInt32          nTravelXPos;
-    sal_uInt16          nExtraCursorFlags;
+    GetCursorFlags      nExtraCursorFlags;
     sal_uInt16          nCursorBidiLevel;
     sal_uInt16          nScrollDiffX;
     bool                bReadOnly;
@@ -829,8 +839,8 @@ public:
     bool            HasParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ) const;
     const SfxPoolItem&  GetParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ) const;
 
-    Rectangle       PaMtoEditCursor( EditPaM aPaM, sal_uInt16 nFlags = 0 );
-    Rectangle       GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex, sal_uInt16 nFlags = 0 );
+    Rectangle       PaMtoEditCursor( EditPaM aPaM, GetCursorFlags nFlags = GetCursorFlags::NONE );
+    Rectangle       GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex, GetCursorFlags nFlags = GetCursorFlags::NONE );
 
     bool            IsModified() const      { return aEditDoc.IsModified(); }
     void            SetModifyFlag( bool b ) { aEditDoc.SetModified( b ); }
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 4de0042..43934f2 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -490,7 +490,7 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
             const EditLine& rLine = pParaPortion->GetLines()[nLine];
             if ( nInputEnd > rLine.GetEnd() )
                 nInputEnd = rLine.GetEnd();
-            Rectangle aR2 = PaMtoEditCursor( EditPaM( aPaM.GetNode(), nInputEnd ), GETCRSR_ENDOFLINE );
+            Rectangle aR2 = PaMtoEditCursor( EditPaM( aPaM.GetNode(), nInputEnd ), GetCursorFlags::EndOfLine );
             Rectangle aRect = pView->GetImpEditView()->GetWindowPos( aR1 );
             pView->GetWindow()->SetCursorRect( &aRect, aR2.Left()-aR1.Right() );
         }
@@ -924,7 +924,7 @@ EditPaM ImpEditEngine::CursorVisualStartEnd( EditView* pEditView, const EditPaM&
     const EditLine& rLine = pParaPortion->GetLines()[nLine];
     bool bEmptyLine = rLine.GetStart() == rLine.GetEnd();
 
-    pEditView->pImpEditView->nExtraCursorFlags = 0;
+    pEditView->pImpEditView->nExtraCursorFlags = GetCursorFlags::NONE;
 
     if ( !bEmptyLine )
     {
@@ -979,7 +979,7 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM
     const EditLine& rLine = pParaPortion->GetLines()[nLine];
     bool bEmptyLine = rLine.GetStart() == rLine.GetEnd();
 
-    pEditView->pImpEditView->nExtraCursorFlags = 0;
+    pEditView->pImpEditView->nExtraCursorFlags = GetCursorFlags::NONE;
 
     bool bParaRTL = IsRightToLeft( nPara );
 
@@ -2972,7 +2972,7 @@ EditPaM ImpEditEngine::InsertLineBreak(const EditSelection& aCurSel)
 
 //  Helper functions
 
-Rectangle ImpEditEngine::PaMtoEditCursor( EditPaM aPaM, sal_uInt16 nFlags )
+Rectangle ImpEditEngine::PaMtoEditCursor( EditPaM aPaM, GetCursorFlags nFlags )
 {
     OSL_ENSURE( GetUpdateMode(), "Must not be reached when Update=FALSE: PaMtoEditCursor" );
 
@@ -4113,13 +4113,13 @@ void ImpEditEngine::CalcHeight( ParaPortion* pPortion )
     }
 }
 
-Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex, sal_uInt16 nFlags )
+Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex, GetCursorFlags nFlags )
 {
     OSL_ENSURE( pPortion->IsVisible(), "Why GetEditCursor() for an invisible paragraph?" );
     OSL_ENSURE( IsFormatted() || GetTextRanger(), "GetEditCursor: Not formatted" );
 
     /*
-     GETCRSR_ENDOFLINE: If after the last character of a wrapped line, remaining
+     GetCursorFlags::EndOfLine: If after the last character of a wrapped line, remaining
      at the end of the line, not the beginning of the next one.
      Purpose:   - END => really after the last character
                 - Selection....
@@ -4137,7 +4137,7 @@ Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex,
     if (nLineCount == 0)
         return Rectangle();
     const EditLine* pLine = nullptr;
-    bool bEOL = ( nFlags & GETCRSR_ENDOFLINE ) != 0;
+    bool bEOL( nFlags & GetCursorFlags::EndOfLine );
     for (sal_Int32 nLine = 0; nLine < nLineCount; ++nLine)
     {
         const EditLine& rTmpLine = pPortion->GetLines()[nLine];
@@ -4172,24 +4172,24 @@ Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex,
     // Search within the line...
     long nX;
 
-    if ( ( nIndex == pLine->GetStart() ) && ( nFlags & GETCRSR_STARTOFLINE ) )
+    if ( ( nIndex == pLine->GetStart() ) && ( nFlags & GetCursorFlags::StartOfLine ) )
     {
         Range aXRange = GetLineXPosStartEnd( pPortion, pLine );
         nX = !IsRightToLeft( GetEditDoc().GetPos( pPortion->GetNode() ) ) ? aXRange.Min() : aXRange.Max();
     }
-    else if ( ( nIndex == pLine->GetEnd() ) && ( nFlags & GETCRSR_ENDOFLINE ) )
+    else if ( ( nIndex == pLine->GetEnd() ) && ( nFlags & GetCursorFlags::EndOfLine ) )
     {
         Range aXRange = GetLineXPosStartEnd( pPortion, pLine );
         nX = !IsRightToLeft( GetEditDoc().GetPos( pPortion->GetNode() ) ) ? aXRange.Max() : aXRange.Min();
     }
     else
     {
-        nX = GetXPos( pPortion, pLine, nIndex, ( nFlags & GETCRSR_PREFERPORTIONSTART ) != 0 );
+        nX = GetXPos( pPortion, pLine, nIndex, bool( nFlags & GetCursorFlags::PreferPortionStart ) );
     }
 
     aEditCursor.Left() = aEditCursor.Right() = nX;
 
-    if ( nFlags & GETCRSR_TXTONLY )
+    if ( nFlags & GetCursorFlags::TextOnly )
         aEditCursor.Top() = aEditCursor.Bottom() - pLine->GetTxtHeight() + 1;
     else
         aEditCursor.Top() = aEditCursor.Bottom() - std::min( pLine->GetTxtHeight(), pLine->GetHeight() ) + 1;
commit bc83fcc98e2380d3ab7acfa2826b64525e711f72
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Nov 22 16:25:08 2016 +0200

    small tidyup in SdrObjEditView::ApplyFormatPaintBrush
    
    Change-Id: I8c1797e78f644bd15eb6d26a96fcc3ed909c2aab

diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 2f618b0..c152b8c 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -2295,14 +2295,13 @@ void SdrObjEditView::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoChar
 {
     if( !mxSelectionController.is() || !mxSelectionController->ApplyFormatPaintBrush( rFormatSet, bNoCharacterFormats, bNoParagraphFormats ) )
     {
-        const SdrMarkList& rMarkList = GetMarkedObjectList();
-        SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
         OutlinerView* pOLV = GetTextEditOutlinerView();
-
-        const SfxItemSet& rShapeSet = pObj->GetMergedItemSet();
-
         if( !pOLV )
         {
+            const SdrMarkList& rMarkList = GetMarkedObjectList();
+            SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+            const SfxItemSet& rShapeSet = pObj->GetMergedItemSet();
+
             // if not in text edit mode (aka the user selected text or clicked on a word)
             // apply formatting attributes to selected shape
             // All formatting items (see ranges above) that are unequal in selected shape and
@@ -2323,9 +2322,11 @@ void SdrObjEditView::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoChar
 
             if( !bTextOnly )
             {
-                SfxItemSet aPaintSet( CreatePaintSet( GetFormatRangeImpl(false), *rShapeSet.GetPool(), rFormatSet, rShapeSet, bNoCharacterFormats, bNoParagraphFormats ) );
-                const bool bReplaceAll = false;
-                SetAttrToMarked(aPaintSet, bReplaceAll);
+                SfxItemSet aPaintSet( CreatePaintSet(
+                                        GetFormatRangeImpl(false), *rShapeSet.GetPool(),
+                                        rFormatSet, rShapeSet,
+                                        bNoCharacterFormats, bNoParagraphFormats ) );
+                SetAttrToMarked(aPaintSet, false/*bReplaceAll*/);
             }
 
             // now apply character and paragraph formatting to text, if the shape has any
@@ -2355,7 +2356,10 @@ void SdrObjEditView::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoChar
                 const bool bRemoveParaAttribs = !bNoParagraphFormats;
                 pOLV->RemoveAttribsKeepLanguages( bRemoveParaAttribs );
                 SfxItemSet aSet( pOLV->GetAttribs() );
-                SfxItemSet aPaintSet( CreatePaintSet(GetFormatRangeImpl(true), *aSet.GetPool(), rFormatSet, aSet, bNoCharacterFormats, bNoParagraphFormats ) );
+                SfxItemSet aPaintSet( CreatePaintSet(
+                                        GetFormatRangeImpl(true), *aSet.GetPool(),
+                                        rFormatSet, aSet,
+                                        bNoCharacterFormats, bNoParagraphFormats ) );
                 pOLV->SetAttribs( aPaintSet );
             }
         }


More information about the Libreoffice-commits mailing list