summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-30 10:34:39 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-01 09:19:50 +0200
commit5dccc6130242a67b6c471245d289cd4a0419602a (patch)
treedbf56e2954bb1f09f05aa6919164958430078198 /sw
parentaa703bc1253454f3783ea6314928505925a1b247 (diff)
loplugin:flatten in sw/core/draw..sw/core/edit
Change-Id: I8d62f001f3a13463d25b8ec16e3cabd43e3abd70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99898 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/draw/dcontact.cxx148
-rw-r--r--sw/source/core/draw/dflyobj.cxx234
-rw-r--r--sw/source/core/draw/dview.cxx136
-rw-r--r--sw/source/core/edit/acorrect.cxx66
-rw-r--r--sw/source/core/edit/autofmt.cxx94
-rw-r--r--sw/source/core/edit/edfcol.cxx54
-rw-r--r--sw/source/core/edit/editsh.cxx38
-rw-r--r--sw/source/core/edit/edlingu.cxx200
-rw-r--r--sw/source/core/edit/edsect.cxx30
-rw-r--r--sw/source/core/edit/edtox.cxx44
-rw-r--r--sw/source/core/edit/edundo.cxx30
11 files changed, 537 insertions, 537 deletions
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 54e931ac3821..028e6b3df807 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -215,21 +215,21 @@ void SwContact::MoveObjToVisibleLayer( SdrObject* _pDrawObj )
MoveObjToLayer( true, _pDrawObj );
// #i46297#
- if ( bNotify )
- {
- SwAnchoredObject* pAnchoredObj = GetAnchoredObj( _pDrawObj );
- assert(pAnchoredObj);
- ::setContextWritingMode( _pDrawObj, pAnchoredObj->GetAnchorFrameContainingAnchPos() );
- // Note: as-character anchored objects aren't registered at a page frame and
- // a notification of its background isn't needed.
- if ( pAnchoredObj->GetPageFrame() )
- {
- ::Notify_Background( _pDrawObj, pAnchoredObj->GetPageFrame(),
- pAnchoredObj->GetObjRect(), PrepareHint::FlyFrameArrive, true );
- }
+ if ( !bNotify )
+ return;
- pAnchoredObj->InvalidateObjPos();
+ SwAnchoredObject* pAnchoredObj = GetAnchoredObj( _pDrawObj );
+ assert(pAnchoredObj);
+ ::setContextWritingMode( _pDrawObj, pAnchoredObj->GetAnchorFrameContainingAnchPos() );
+ // Note: as-character anchored objects aren't registered at a page frame and
+ // a notification of its background isn't needed.
+ if ( pAnchoredObj->GetPageFrame() )
+ {
+ ::Notify_Background( _pDrawObj, pAnchoredObj->GetPageFrame(),
+ pAnchoredObj->GetObjRect(), PrepareHint::FlyFrameArrive, true );
}
+
+ pAnchoredObj->InvalidateObjPos();
}
/// method to move drawing object to corresponding invisible layer - #i18447#
@@ -915,31 +915,31 @@ static void lcl_NotifyBackgroundOfObj( SwDrawContact const & _rDrawContact,
// #i34640#
SwAnchoredObject* pAnchoredObj =
const_cast<SwAnchoredObject*>(_rDrawContact.GetAnchoredObj( &_rObj ));
- if ( pAnchoredObj && pAnchoredObj->GetAnchorFrame() )
+ if ( !(pAnchoredObj && pAnchoredObj->GetAnchorFrame()) )
+ return;
+
+ // #i34640# - determine correct page frame
+ SwPageFrame* pPageFrame = pAnchoredObj->FindPageFrameOfAnchor();
+ if( _pOldObjRect && pPageFrame )
{
- // #i34640# - determine correct page frame
- SwPageFrame* pPageFrame = pAnchoredObj->FindPageFrameOfAnchor();
- if( _pOldObjRect && pPageFrame )
+ SwRect aOldRect( *_pOldObjRect );
+ if( aOldRect.HasArea() )
{
- SwRect aOldRect( *_pOldObjRect );
- if( aOldRect.HasArea() )
- {
- // #i34640# - determine correct page frame
- SwPageFrame* pOldPageFrame = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(::FindPage( aOldRect, pPageFrame )));
- ::Notify_Background( &_rObj, pOldPageFrame, aOldRect,
- PrepareHint::FlyFrameLeave, true);
- }
- }
- // #i34640# - include spacing for wrapping
- SwRect aNewRect( pAnchoredObj->GetObjRectWithSpaces() );
- if( aNewRect.HasArea() && pPageFrame )
- {
- pPageFrame = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(::FindPage( aNewRect, pPageFrame )));
- ::Notify_Background( &_rObj, pPageFrame, aNewRect,
- PrepareHint::FlyFrameArrive, true );
+ // #i34640# - determine correct page frame
+ SwPageFrame* pOldPageFrame = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(::FindPage( aOldRect, pPageFrame )));
+ ::Notify_Background( &_rObj, pOldPageFrame, aOldRect,
+ PrepareHint::FlyFrameLeave, true);
}
- ClrContourCache( &_rObj );
}
+ // #i34640# - include spacing for wrapping
+ SwRect aNewRect( pAnchoredObj->GetObjRectWithSpaces() );
+ if( aNewRect.HasArea() && pPageFrame )
+ {
+ pPageFrame = const_cast<SwPageFrame*>(static_cast<const SwPageFrame*>(::FindPage( aNewRect, pPageFrame )));
+ ::Notify_Background( &_rObj, pPageFrame, aNewRect,
+ PrepareHint::FlyFrameArrive, true );
+ }
+ ClrContourCache( &_rObj );
}
void SwDrawContact::Changed( const SdrObject& rObj,
@@ -1032,32 +1032,32 @@ class NestedUserCallHdl
void AssertNestedUserCall()
{
- if ( IsNestedUserCall() )
+ if ( !IsNestedUserCall() )
+ return;
+
+ bool bTmpAssert( true );
+ // Currently its known, that a nested event SdrUserCallType::Resize
+ // could occur during parent user call SdrUserCallType::Inserted,
+ // SdrUserCallType::Delete and SdrUserCallType::Resize for edge objects.
+ // Also possible are nested SdrUserCallType::ChildResize events for
+ // edge objects
+ // Thus, assert all other combinations
+ if ( ( meParentUserCallEventType == SdrUserCallType::Inserted ||
+ meParentUserCallEventType == SdrUserCallType::Delete ||
+ meParentUserCallEventType == SdrUserCallType::Resize ) &&
+ mpDrawContact->meEventTypeOfCurrentUserCall == SdrUserCallType::Resize )
{
- bool bTmpAssert( true );
- // Currently its known, that a nested event SdrUserCallType::Resize
- // could occur during parent user call SdrUserCallType::Inserted,
- // SdrUserCallType::Delete and SdrUserCallType::Resize for edge objects.
- // Also possible are nested SdrUserCallType::ChildResize events for
- // edge objects
- // Thus, assert all other combinations
- if ( ( meParentUserCallEventType == SdrUserCallType::Inserted ||
- meParentUserCallEventType == SdrUserCallType::Delete ||
- meParentUserCallEventType == SdrUserCallType::Resize ) &&
- mpDrawContact->meEventTypeOfCurrentUserCall == SdrUserCallType::Resize )
- {
- bTmpAssert = false;
- }
- else if ( meParentUserCallEventType == SdrUserCallType::ChildResize &&
- mpDrawContact->meEventTypeOfCurrentUserCall == SdrUserCallType::ChildResize )
- {
- bTmpAssert = false;
- }
+ bTmpAssert = false;
+ }
+ else if ( meParentUserCallEventType == SdrUserCallType::ChildResize &&
+ mpDrawContact->meEventTypeOfCurrentUserCall == SdrUserCallType::ChildResize )
+ {
+ bTmpAssert = false;
+ }
- if ( bTmpAssert )
- {
- OSL_FAIL( "<SwDrawContact::Changed_(..)> - unknown nested <UserCall> event. This is serious." );
- }
+ if ( bTmpAssert )
+ {
+ OSL_FAIL( "<SwDrawContact::Changed_(..)> - unknown nested <UserCall> event. This is serious." );
}
}
};
@@ -1935,23 +1935,23 @@ void SwDrawContact::ChkPage()
maAnchoredDrawObj.GetAnchorFrame()->IsPageFrame() )
? GetPageFrame()
: FindPage( GetMaster()->GetCurrentBoundRect() );
- if ( GetPageFrame() != pPg )
+ if ( GetPageFrame() == pPg )
+ return;
+
+ // if drawing object is anchor in header/footer a change of the page
+ // is a dramatic change. Thus, completely re-connect to the layout
+ if ( maAnchoredDrawObj.GetAnchorFrame() &&
+ maAnchoredDrawObj.GetAnchorFrame()->FindFooterOrHeader() )
{
- // if drawing object is anchor in header/footer a change of the page
- // is a dramatic change. Thus, completely re-connect to the layout
- if ( maAnchoredDrawObj.GetAnchorFrame() &&
- maAnchoredDrawObj.GetAnchorFrame()->FindFooterOrHeader() )
- {
- ConnectToLayout();
- }
- else
- {
- // --> #i28701# - use methods <GetPageFrame()> and <SetPageFrame>
- if ( GetPageFrame() )
- GetPageFrame()->RemoveDrawObjFromPage( maAnchoredDrawObj );
- pPg->AppendDrawObjToPage( maAnchoredDrawObj );
- maAnchoredDrawObj.SetPageFrame( pPg );
- }
+ ConnectToLayout();
+ }
+ else
+ {
+ // --> #i28701# - use methods <GetPageFrame()> and <SetPageFrame>
+ if ( GetPageFrame() )
+ GetPageFrame()->RemoveDrawObjFromPage( maAnchoredDrawObj );
+ pPg->AppendDrawObjToPage( maAnchoredDrawObj );
+ maAnchoredDrawObj.SetPageFrame( pPg );
}
}
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index f794887fee77..02d4cfe29c56 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -191,19 +191,19 @@ namespace drawinglayer::primitive2d
{
void SwVirtFlyDrawObjPrimitive::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const
{
- if(!getOuterRange().isEmpty())
- {
- // currently this SW object has no primitive representation. As long as this is the case,
- // create invisible geometry to allow correct HitTest and BoundRect calculations for the
- // object. Use a filled primitive to get 'inside' as default object hit. The special cases from
- // the old SwVirtFlyDrawObj::CheckHit implementation are handled now in SwDrawView::PickObj;
- // this removed the 'hack' to get a view from inside model data or to react on null-tolerance
- // as it was done in the old implementation
- rContainer.push_back(
- createHiddenGeometryPrimitives2D(
- true,
- getOuterRange()));
- }
+ if(getOuterRange().isEmpty())
+ return;
+
+ // currently this SW object has no primitive representation. As long as this is the case,
+ // create invisible geometry to allow correct HitTest and BoundRect calculations for the
+ // object. Use a filled primitive to get 'inside' as default object hit. The special cases from
+ // the old SwVirtFlyDrawObj::CheckHit implementation are handled now in SwDrawView::PickObj;
+ // this removed the 'hack' to get a view from inside model data or to react on null-tolerance
+ // as it was done in the old implementation
+ rContainer.push_back(
+ createHiddenGeometryPrimitives2D(
+ true,
+ getOuterRange()));
}
bool SwVirtFlyDrawObjPrimitive::operator==(const BasePrimitive2D& rPrimitive) const
@@ -453,24 +453,24 @@ namespace
: mbMapModeRestored( false )
, mpOutDev( pViewShell->GetOut() )
{
- if ( pViewShell->getPrePostMapMode() != mpOutDev->GetMapMode() )
+ if ( pViewShell->getPrePostMapMode() == mpOutDev->GetMapMode() )
+ return;
+
+ mpOutDev->Push(PushFlags::MAPMODE);
+
+ GDIMetaFile* pMetaFile = mpOutDev->GetConnectMetaFile();
+ if ( pMetaFile &&
+ pMetaFile->IsRecord() && !pMetaFile->IsPause() )
{
- mpOutDev->Push(PushFlags::MAPMODE);
-
- GDIMetaFile* pMetaFile = mpOutDev->GetConnectMetaFile();
- if ( pMetaFile &&
- pMetaFile->IsRecord() && !pMetaFile->IsPause() )
- {
- OSL_FAIL( "MapMode restoration during meta file creation is somehow suspect - using <SetRelativeMapMode(..)>, but not sure, if correct." );
- mpOutDev->SetRelativeMapMode( pViewShell->getPrePostMapMode() );
- }
- else
- {
- mpOutDev->SetMapMode( pViewShell->getPrePostMapMode() );
- }
-
- mbMapModeRestored = true;
+ OSL_FAIL( "MapMode restoration during meta file creation is somehow suspect - using <SetRelativeMapMode(..)>, but not sure, if correct." );
+ mpOutDev->SetRelativeMapMode( pViewShell->getPrePostMapMode() );
}
+ else
+ {
+ mpOutDev->SetMapMode( pViewShell->getPrePostMapMode() );
+ }
+
+ mbMapModeRestored = true;
};
~RestoreMapMode()
@@ -498,36 +498,36 @@ void SwVirtFlyDrawObj::wrap_DoPaintObject(
// but no paints. IsPaintInProgress() depends on SW repaint, so, as long
// as SW paints self and calls DrawLayer() for Heaven and Hell, this will
// be correct
- if ( pShell && pShell->IsDrawingLayerPaintInProgress() )
- {
- bool bDrawObject(true);
+ if ( !(pShell && pShell->IsDrawingLayerPaintInProgress()) )
+ return;
- if ( !SwFlyFrame::IsPaint( const_cast<SwVirtFlyDrawObj*>(this), pShell ) )
- {
- bDrawObject = false;
- }
+ bool bDrawObject(true);
- if ( bDrawObject )
- {
- // if there's no viewport set, all fly-frames will be painted,
- // which is slow, wastes memory, and can cause other trouble.
- (void) rViewInformation; // suppress "unused parameter" warning
- assert(comphelper::LibreOfficeKit::isActive() || !rViewInformation.getViewport().isEmpty());
- if ( !m_pFlyFrame->IsFlyInContentFrame() )
- {
- // it is also necessary to restore the VCL MapMode from ViewInformation since e.g.
- // the VCL PixelRenderer resets it at the used OutputDevice. Unfortunately, this
- // excludes shears and rotates which are not expressible in MapMode.
- // OD #i102707#
- // new helper class to restore MapMode - restoration, only if
- // needed and consideration of paint for meta file creation .
- RestoreMapMode aRestoreMapModeIfNeeded( pShell );
-
- // paint the FlyFrame (use standard VCL-Paint)
- m_pFlyFrame->PaintSwFrame( *pShell->GetOut(), GetFlyFrame()->getFrameArea() );
- }
- }
+ if ( !SwFlyFrame::IsPaint( const_cast<SwVirtFlyDrawObj*>(this), pShell ) )
+ {
+ bDrawObject = false;
}
+
+ if ( !bDrawObject )
+ return;
+
+ // if there's no viewport set, all fly-frames will be painted,
+ // which is slow, wastes memory, and can cause other trouble.
+ (void) rViewInformation; // suppress "unused parameter" warning
+ assert(comphelper::LibreOfficeKit::isActive() || !rViewInformation.getViewport().isEmpty());
+ if ( m_pFlyFrame->IsFlyInContentFrame() )
+ return;
+
+ // it is also necessary to restore the VCL MapMode from ViewInformation since e.g.
+ // the VCL PixelRenderer resets it at the used OutputDevice. Unfortunately, this
+ // excludes shears and rotates which are not expressible in MapMode.
+ // OD #i102707#
+ // new helper class to restore MapMode - restoration, only if
+ // needed and consideration of paint for meta file creation .
+ RestoreMapMode aRestoreMapModeIfNeeded( pShell );
+
+ // paint the FlyFrame (use standard VCL-Paint)
+ m_pFlyFrame->PaintSwFrame( *pShell->GetOut(), GetFlyFrame()->getFrameArea() );
}
void SwVirtFlyDrawObj::TakeObjInfo( SdrObjTransformInfoRec& rInfo ) const
@@ -1093,32 +1093,32 @@ void SwVirtFlyDrawObj::NbcResize(const Point& rRef, const Fraction& xFact, const
//Position can also be changed, get new one
const Point aNewPos(bUseRightEdge ? aOutRect.Right() + 1 : aOutRect.Left(), aOutRect.Top());
- if ( aNewPos != aOldPos )
- {
- // Former late change in aOutRect by ChgSize
- // is now taken into account directly by calculating
- // aNewPos *after* calling ChgSize (see old code).
- // Still need to adapt aOutRect since the 'Move' is already applied
- // here (see ResizeRect) and it's the same SdrObject
- const Size aDeltaMove(
- aNewPos.X() - aOldPos.X(),
- aNewPos.Y() - aOldPos.Y());
- aOutRect.Move(-aDeltaMove.Width(), -aDeltaMove.Height());
-
- // Now, move as needed (no empty delta which was a hack anyways)
- if(bIsTransformableSwFrame)
- {
- // need to save aOutRect to FrameArea, will be restored to aOutRect in
- // SwVirtFlyDrawObj::NbcMove currently for TransformableSwFrames
- SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*GetFlyFrame());
- aFrm.setSwRect(aOutRect);
- }
+ if ( aNewPos == aOldPos )
+ return;
- // keep old hack - not clear what happens here
- bInResize = true;
- NbcMove(aDeltaMove);
- bInResize = false;
+ // Former late change in aOutRect by ChgSize
+ // is now taken into account directly by calculating
+ // aNewPos *after* calling ChgSize (see old code).
+ // Still need to adapt aOutRect since the 'Move' is already applied
+ // here (see ResizeRect) and it's the same SdrObject
+ const Size aDeltaMove(
+ aNewPos.X() - aOldPos.X(),
+ aNewPos.Y() - aOldPos.Y());
+ aOutRect.Move(-aDeltaMove.Width(), -aDeltaMove.Height());
+
+ // Now, move as needed (no empty delta which was a hack anyways)
+ if(bIsTransformableSwFrame)
+ {
+ // need to save aOutRect to FrameArea, will be restored to aOutRect in
+ // SwVirtFlyDrawObj::NbcMove currently for TransformableSwFrames
+ SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*GetFlyFrame());
+ aFrm.setSwRect(aOutRect);
}
+
+ // keep old hack - not clear what happens here
+ bInResize = true;
+ NbcMove(aDeltaMove);
+ bInResize = false;
}
void SwVirtFlyDrawObj::Move(const Size& rSiz)
@@ -1199,44 +1199,44 @@ SdrObjectUniquePtr SwVirtFlyDrawObj::getFullDragClone() const
void SwVirtFlyDrawObj::addCropHandles(SdrHdlList& rTarget) const
{
// RotGrfFlyFrame: Adapt to possible rotated Graphic contained in FlyFrame
- if(GetFlyFrame()->getFrameArea().HasArea())
- {
- // Use InnerBound, OuterBound (same as GetFlyFrame()->getFrameArea().SVRect())
- // may have a distance to InnerBound which needs to be taken into account.
- // The Graphic is mapped to InnerBound, as is the rotated Graphic.
- const basegfx::B2DRange aTargetRange(getInnerBound());
+ if(!GetFlyFrame()->getFrameArea().HasArea())
+ return;
- if(!aTargetRange.isEmpty())
- {
- // RotGrfFlyFrame3: get inner bounds/transformation
- const basegfx::B2DHomMatrix aTargetTransform(GetFlyFrame()->getFramePrintAreaTransformation());
-
- // break up matrix
- basegfx::B2DTuple aScale;
- basegfx::B2DTuple aTranslate;
- double fRotate(0.0);
- double fShearX(0.0);
- aTargetTransform.decompose(aScale, aTranslate, fRotate, fShearX);
- basegfx::B2DPoint aPos;
-
- aPos = aTargetTransform * basegfx::B2DPoint(0.0, 0.0);
- rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::UpperLeft, fShearX, fRotate));
- aPos = aTargetTransform * basegfx::B2DPoint(0.5, 0.0);
- rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Upper, fShearX, fRotate));
- aPos = aTargetTransform * basegfx::B2DPoint(1.0, 0.0);
- rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::UpperRight, fShearX, fRotate));
- aPos = aTargetTransform * basegfx::B2DPoint(0.0, 0.5);
- rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Left , fShearX, fRotate));
- aPos = aTargetTransform * basegfx::B2DPoint(1.0, 0.5);
- rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Right, fShearX, fRotate));
- aPos = aTargetTransform * basegfx::B2DPoint(0.0, 1.0);
- rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerLeft, fShearX, fRotate));
- aPos = aTargetTransform * basegfx::B2DPoint(0.5, 1.0);
- rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Lower, fShearX, fRotate));
- aPos = aTargetTransform * basegfx::B2DPoint(1.0, 1.0);
- rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerRight, fShearX, fRotate));
- }
- }
+ // Use InnerBound, OuterBound (same as GetFlyFrame()->getFrameArea().SVRect())
+ // may have a distance to InnerBound which needs to be taken into account.
+ // The Graphic is mapped to InnerBound, as is the rotated Graphic.
+ const basegfx::B2DRange aTargetRange(getInnerBound());
+
+ if(aTargetRange.isEmpty())
+ return;
+
+ // RotGrfFlyFrame3: get inner bounds/transformation
+ const basegfx::B2DHomMatrix aTargetTransform(GetFlyFrame()->getFramePrintAreaTransformation());
+
+ // break up matrix
+ basegfx::B2DTuple aScale;
+ basegfx::B2DTuple aTranslate;
+ double fRotate(0.0);
+ double fShearX(0.0);
+ aTargetTransform.decompose(aScale, aTranslate, fRotate, fShearX);
+ basegfx::B2DPoint aPos;
+
+ aPos = aTargetTransform * basegfx::B2DPoint(0.0, 0.0);
+ rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::UpperLeft, fShearX, fRotate));
+ aPos = aTargetTransform * basegfx::B2DPoint(0.5, 0.0);
+ rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Upper, fShearX, fRotate));
+ aPos = aTargetTransform * basegfx::B2DPoint(1.0, 0.0);
+ rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::UpperRight, fShearX, fRotate));
+ aPos = aTargetTransform * basegfx::B2DPoint(0.0, 0.5);
+ rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Left , fShearX, fRotate));
+ aPos = aTargetTransform * basegfx::B2DPoint(1.0, 0.5);
+ rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Right, fShearX, fRotate));
+ aPos = aTargetTransform * basegfx::B2DPoint(0.0, 1.0);
+ rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerLeft, fShearX, fRotate));
+ aPos = aTargetTransform * basegfx::B2DPoint(0.5, 1.0);
+ rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::Lower, fShearX, fRotate));
+ aPos = aTargetTransform * basegfx::B2DPoint(1.0, 1.0);
+ rTarget.AddHdl(std::make_unique<SdrCropHdl>(Point(basegfx::fround(aPos.getX()), basegfx::fround(aPos.getY())), SdrHdlKind::LowerRight, fShearX, fRotate));
}
// Macro
diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx
index 155339cbcc5d..f3f92be2b3f0 100644
--- a/sw/source/core/draw/dview.cxx
+++ b/sw/source/core/draw/dview.cxx
@@ -355,19 +355,54 @@ void SwDrawView::MoveRepeatedObjs( const SwAnchoredObject& _rMovedAnchoredObj,
}
// check, if 'repeated' objects exists.
- if ( aAnchoredObjs.size() > 1 )
+ if ( aAnchoredObjs.size() <= 1 )
+ return;
+
+ SdrPage* pDrawPage = GetModel()->GetPage( 0 );
+
+ // move 'repeated' ones to the same order number as the already moved one.
+ const size_t nNewPos = _rMovedAnchoredObj.GetDrawObj()->GetOrdNum();
+ while ( !aAnchoredObjs.empty() )
{
- SdrPage* pDrawPage = GetModel()->GetPage( 0 );
+ SwAnchoredObject* pAnchoredObj = aAnchoredObjs.back();
+ if ( pAnchoredObj != &_rMovedAnchoredObj )
+ {
+ pDrawPage->SetObjectOrdNum( pAnchoredObj->GetDrawObj()->GetOrdNum(),
+ nNewPos );
+ pDrawPage->RecalcObjOrdNums();
+ // adjustments for accessibility API
+ if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
+ {
+ const SwFlyFrame *pTmpFlyFrame = static_cast<SwFlyFrame*>(pAnchoredObj);
+ m_rImp.DisposeAccessibleFrame( pTmpFlyFrame );
+ m_rImp.AddAccessibleFrame( pTmpFlyFrame );
+ }
+ else
+ {
+ m_rImp.DisposeAccessibleObj(pAnchoredObj->GetDrawObj(), true);
+ m_rImp.AddAccessibleObj( pAnchoredObj->GetDrawObj() );
+ }
+ }
+ aAnchoredObjs.pop_back();
+ }
+ // move 'repeated' ones of 'child' objects
+ for ( SdrObject* pChildObj : _rMovedChildObjs )
+ {
+ {
+ const SwContact* pContact = ::GetUserCall( pChildObj );
+ assert(pContact && "SwDrawView::MoveRepeatedObjs(..) - missing contact object -> crash.");
+ pContact->GetAnchoredObjs( aAnchoredObjs );
+ }
// move 'repeated' ones to the same order number as the already moved one.
- const size_t nNewPos = _rMovedAnchoredObj.GetDrawObj()->GetOrdNum();
+ const size_t nTmpNewPos = pChildObj->GetOrdNum();
while ( !aAnchoredObjs.empty() )
{
SwAnchoredObject* pAnchoredObj = aAnchoredObjs.back();
- if ( pAnchoredObj != &_rMovedAnchoredObj )
+ if ( pAnchoredObj->GetDrawObj() != pChildObj )
{
pDrawPage->SetObjectOrdNum( pAnchoredObj->GetDrawObj()->GetOrdNum(),
- nNewPos );
+ nTmpNewPos );
pDrawPage->RecalcObjOrdNums();
// adjustments for accessibility API
if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
@@ -384,41 +419,6 @@ void SwDrawView::MoveRepeatedObjs( const SwAnchoredObject& _rMovedAnchoredObj,
}
aAnchoredObjs.pop_back();
}
-
- // move 'repeated' ones of 'child' objects
- for ( SdrObject* pChildObj : _rMovedChildObjs )
- {
- {
- const SwContact* pContact = ::GetUserCall( pChildObj );
- assert(pContact && "SwDrawView::MoveRepeatedObjs(..) - missing contact object -> crash.");
- pContact->GetAnchoredObjs( aAnchoredObjs );
- }
- // move 'repeated' ones to the same order number as the already moved one.
- const size_t nTmpNewPos = pChildObj->GetOrdNum();
- while ( !aAnchoredObjs.empty() )
- {
- SwAnchoredObject* pAnchoredObj = aAnchoredObjs.back();
- if ( pAnchoredObj->GetDrawObj() != pChildObj )
- {
- pDrawPage->SetObjectOrdNum( pAnchoredObj->GetDrawObj()->GetOrdNum(),
- nTmpNewPos );
- pDrawPage->RecalcObjOrdNums();
- // adjustments for accessibility API
- if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
- {
- const SwFlyFrame *pTmpFlyFrame = static_cast<SwFlyFrame*>(pAnchoredObj);
- m_rImp.DisposeAccessibleFrame( pTmpFlyFrame );
- m_rImp.AddAccessibleFrame( pTmpFlyFrame );
- }
- else
- {
- m_rImp.DisposeAccessibleObj(pAnchoredObj->GetDrawObj(), true);
- m_rImp.AddAccessibleObj( pAnchoredObj->GetDrawObj() );
- }
- }
- aAnchoredObjs.pop_back();
- }
- }
}
}
@@ -902,40 +902,40 @@ void SwDrawView::ReplaceMarkedDrawVirtObjs( SdrMarkView& _rMarkView )
SdrPageView* pDrawPageView = _rMarkView.GetSdrPageView();
const SdrMarkList& rMarkList = _rMarkView.GetMarkedObjectList();
- if( rMarkList.GetMarkCount() )
+ if( !rMarkList.GetMarkCount() )
+ return;
+
+ // collect marked objects in a local data structure
+ std::vector<SdrObject*> aMarkedObjs;
+ for( size_t i = 0; i < rMarkList.GetMarkCount(); ++i )
{
- // collect marked objects in a local data structure
- std::vector<SdrObject*> aMarkedObjs;
- for( size_t i = 0; i < rMarkList.GetMarkCount(); ++i )
- {
- SdrObject* pMarkedObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
- aMarkedObjs.push_back( pMarkedObj );
- }
- // unmark all objects
- _rMarkView.UnmarkAllObj();
- // re-mark objects, but for marked <SwDrawVirtObj>-objects marked its
- // reference object.
- while ( !aMarkedObjs.empty() )
+ SdrObject* pMarkedObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
+ aMarkedObjs.push_back( pMarkedObj );
+ }
+ // unmark all objects
+ _rMarkView.UnmarkAllObj();
+ // re-mark objects, but for marked <SwDrawVirtObj>-objects marked its
+ // reference object.
+ while ( !aMarkedObjs.empty() )
+ {
+ SdrObject* pMarkObj = aMarkedObjs.back();
+ if ( dynamic_cast< const SwDrawVirtObj *>( pMarkObj ) != nullptr )
{
- SdrObject* pMarkObj = aMarkedObjs.back();
- if ( dynamic_cast< const SwDrawVirtObj *>( pMarkObj ) != nullptr )
- {
- SdrObject* pRefObj = &(static_cast<SwDrawVirtObj*>(pMarkObj)->ReferencedObj());
- if ( !_rMarkView.IsObjMarked( pRefObj ) )
- {
- _rMarkView.MarkObj( pRefObj, pDrawPageView );
- }
- }
- else
+ SdrObject* pRefObj = &(static_cast<SwDrawVirtObj*>(pMarkObj)->ReferencedObj());
+ if ( !_rMarkView.IsObjMarked( pRefObj ) )
{
- _rMarkView.MarkObj( pMarkObj, pDrawPageView );
+ _rMarkView.MarkObj( pRefObj, pDrawPageView );
}
-
- aMarkedObjs.pop_back();
}
- // sort marked list in order to assure consistent state in drawing layer
- _rMarkView.SortMarkedObjects();
+ else
+ {
+ _rMarkView.MarkObj( pMarkObj, pDrawPageView );
+ }
+
+ aMarkedObjs.pop_back();
}
+ // sort marked list in order to assure consistent state in drawing layer
+ _rMarkView.SortMarkedObjects();
}
SfxViewShell* SwDrawView::GetSfxViewShell() const
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index f26f23732f40..d65607ef634e 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -648,43 +648,43 @@ void SwDontExpandItem::SaveDontExpandItems( const SwPosition& rPos )
void SwDontExpandItem::RestoreDontExpandItems( const SwPosition& rPos )
{
SwTextNode* pTextNd = rPos.nNode.GetNode().GetTextNode();
- if( pTextNd )
+ if( !pTextNd )
+ return;
+
+ const sal_Int32 nStart = rPos.nContent.GetIndex();
+ if( nStart == pTextNd->GetText().getLength() )
+ pTextNd->FormatToTextAttr( pTextNd );
+
+ if( !(pTextNd->GetpSwpHints() && pTextNd->GetpSwpHints()->Count()) )
+ return;
+
+ const size_t nSize = pTextNd->GetpSwpHints()->Count();
+ sal_Int32 nAttrStart;
+
+ for( size_t n = 0; n < nSize; ++n )
{
- const sal_Int32 nStart = rPos.nContent.GetIndex();
- if( nStart == pTextNd->GetText().getLength() )
- pTextNd->FormatToTextAttr( pTextNd );
+ SwTextAttr* pHt = pTextNd->GetpSwpHints()->Get( n );
+ nAttrStart = pHt->GetStart();
+ if( nAttrStart > nStart ) // beyond the area
+ break;
- if( pTextNd->GetpSwpHints() && pTextNd->GetpSwpHints()->Count() )
+ const sal_Int32* pAttrEnd;
+ if( nullptr != ( pAttrEnd = pHt->End() ) &&
+ ( ( nAttrStart < nStart &&
+ ( pHt->DontExpand() ? nStart < *pAttrEnd
+ : nStart <= *pAttrEnd )) ||
+ ( nStart == nAttrStart &&
+ ( nAttrStart == *pAttrEnd || !nStart ))) )
{
- const size_t nSize = pTextNd->GetpSwpHints()->Count();
- sal_Int32 nAttrStart;
-
- for( size_t n = 0; n < nSize; ++n )
+ const SfxPoolItem* pItem;
+ if( !m_pDontExpandItems || SfxItemState::SET != m_pDontExpandItems->
+ GetItemState( pHt->Which(), false, &pItem ) ||
+ *pItem != pHt->GetAttr() )
{
- SwTextAttr* pHt = pTextNd->GetpSwpHints()->Get( n );
- nAttrStart = pHt->GetStart();
- if( nAttrStart > nStart ) // beyond the area
- break;
-
- const sal_Int32* pAttrEnd;
- if( nullptr != ( pAttrEnd = pHt->End() ) &&
- ( ( nAttrStart < nStart &&
- ( pHt->DontExpand() ? nStart < *pAttrEnd
- : nStart <= *pAttrEnd )) ||
- ( nStart == nAttrStart &&
- ( nAttrStart == *pAttrEnd || !nStart ))) )
- {
- const SfxPoolItem* pItem;
- if( !m_pDontExpandItems || SfxItemState::SET != m_pDontExpandItems->
- GetItemState( pHt->Which(), false, &pItem ) ||
- *pItem != pHt->GetAttr() )
- {
- // The attribute was not previously set in this form in the
- // paragraph, so it can only be created through insert/copy
- // Because of that it is a candidate for DontExpand
- pHt->SetDontExpand( true );
- }
- }
+ // The attribute was not previously set in this form in the
+ // paragraph, so it can only be created through insert/copy
+ // Because of that it is a candidate for DontExpand
+ pHt->SetDontExpand( true );
}
}
}
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index df62cc71689c..48d5befd6308 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -1084,31 +1084,31 @@ bool SwAutoFormat::IsSentenceAtEnd(const SwTextFrame & rTextFrame)
/// Delete beginning and/or end in a node
void SwAutoFormat::DeleteLeadingTrailingBlanks(bool bStart, bool bEnd)
{
- if( m_aFlags.bAFormatByInput
+ if( !(m_aFlags.bAFormatByInput
? m_aFlags.bAFormatByInpDelSpacesAtSttEnd
- : m_aFlags.bAFormatDelSpacesAtSttEnd )
+ : m_aFlags.bAFormatDelSpacesAtSttEnd) )
+ return;
+
+ // delete blanks at the end of the current and at the beginning of the next one
+ m_aDelPam.DeleteMark();
+ TextFrameIndex nPos(GetLeadingBlanks(m_pCurTextFrame->GetText()));
+ if (bStart && TextFrameIndex(0) != nPos)
{
- // delete blanks at the end of the current and at the beginning of the next one
+ *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(TextFrameIndex(0));
+ m_aDelPam.SetMark();
+ *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(nPos);
+ DeleteSel( m_aDelPam );
+ m_aDelPam.DeleteMark();
+ }
+ nPos = TextFrameIndex(GetTrailingBlanks(m_pCurTextFrame->GetText()));
+ if (bEnd && TextFrameIndex(m_pCurTextFrame->GetText().getLength()) != nPos)
+ {
+ *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(
+ TextFrameIndex(m_pCurTextFrame->GetText().getLength()));
+ m_aDelPam.SetMark();
+ *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(nPos);
+ DeleteSel( m_aDelPam );
m_aDelPam.DeleteMark();
- TextFrameIndex nPos(GetLeadingBlanks(m_pCurTextFrame->GetText()));
- if (bStart && TextFrameIndex(0) != nPos)
- {
- *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(TextFrameIndex(0));
- m_aDelPam.SetMark();
- *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(nPos);
- DeleteSel( m_aDelPam );
- m_aDelPam.DeleteMark();
- }
- nPos = TextFrameIndex(GetTrailingBlanks(m_pCurTextFrame->GetText()));
- if (bEnd && TextFrameIndex(m_pCurTextFrame->GetText().getLength()) != nPos)
- {
- *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(
- TextFrameIndex(m_pCurTextFrame->GetText().getLength()));
- m_aDelPam.SetMark();
- *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(nPos);
- DeleteSel( m_aDelPam );
- m_aDelPam.DeleteMark();
- }
}
}
@@ -1287,37 +1287,37 @@ void SwAutoFormat::DelEmptyLine( bool bTstNextPara )
void SwAutoFormat::DelMoreLinesBlanks( bool bWithLineBreaks )
{
- if( m_aFlags.bAFormatByInput
+ if( !(m_aFlags.bAFormatByInput
? m_aFlags.bAFormatByInpDelSpacesBetweenLines
- : m_aFlags.bAFormatDelSpacesBetweenLines )
- {
- // delete all blanks on the left and right of the indentation
- m_aDelPam.DeleteMark();
+ : m_aFlags.bAFormatDelSpacesBetweenLines) )
+ return;
- SwTextFrameInfo aFInfo( m_pCurTextFrame );
- std::vector<std::pair<TextFrameIndex, TextFrameIndex>> spaces;
- aFInfo.GetSpaces(spaces, !m_aFlags.bAFormatByInput || bWithLineBreaks);
+ // delete all blanks on the left and right of the indentation
+ m_aDelPam.DeleteMark();
- // tdf#123285 iterate backwards - delete invalidates following indexes
- for (auto iter = spaces.rbegin(); iter != spaces.rend(); ++iter)
+ SwTextFrameInfo aFInfo( m_pCurTextFrame );
+ std::vector<std::pair<TextFrameIndex, TextFrameIndex>> spaces;
+ aFInfo.GetSpaces(spaces, !m_aFlags.bAFormatByInput || bWithLineBreaks);
+
+ // tdf#123285 iterate backwards - delete invalidates following indexes
+ for (auto iter = spaces.rbegin(); iter != spaces.rend(); ++iter)
+ {
+ auto & rSpaceRange(*iter);
+ assert(rSpaceRange.first != rSpaceRange.second);
+ bool const bHasBlanks = HasSelBlanks(
+ m_pCurTextFrame, rSpaceRange.first,
+ m_pCurTextFrame, rSpaceRange.second);
+ if (rSpaceRange.first != rSpaceRange.second)
{
- auto & rSpaceRange(*iter);
- assert(rSpaceRange.first != rSpaceRange.second);
- bool const bHasBlanks = HasSelBlanks(
- m_pCurTextFrame, rSpaceRange.first,
- m_pCurTextFrame, rSpaceRange.second);
- if (rSpaceRange.first != rSpaceRange.second)
+ *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(rSpaceRange.first);
+ m_aDelPam.SetMark();
+ *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(rSpaceRange.second);
+ DeleteSel(m_aDelPam);
+ if (!bHasBlanks)
{
- *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(rSpaceRange.first);
- m_aDelPam.SetMark();
- *m_aDelPam.GetPoint() = m_pCurTextFrame->MapViewToModelPos(rSpaceRange.second);
- DeleteSel(m_aDelPam);
- if (!bHasBlanks)
- {
- m_pDoc->getIDocumentContentOperations().InsertString(m_aDelPam, OUString(' '));
- }
- m_aDelPam.DeleteMark();
+ m_pDoc->getIDocumentContentOperations().InsertString(m_aDelPam, OUString(' '));
}
+ m_aDelPam.DeleteMark();
}
}
}
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 716d0b771f63..2f192ab8953d 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -2249,39 +2249,39 @@ void SwEditShell::FillByEx(SwTextFormatColl* pColl)
pCnt = sw::GetParaPropsNode(*GetLayout(), pCursor->GetPoint()->nNode);
}
const SfxItemSet* pSet = pCnt->GetpSwAttrSet();
- if( pSet )
+ if( !pSet )
+ return;
+
+ // JP 05.10.98: Special treatment if one of the attributes Break/PageDesc/NumRule(auto) is
+ // in the ItemSet. Otherwise there will be too much or wrong processing (NumRules!)
+ // Bug 57568
+
+ // Do NOT copy AutoNumRules into the template
+ const SfxPoolItem* pItem;
+ const SwNumRule* pRule = nullptr;
+ if (SfxItemState::SET == pSet->GetItemState(RES_BREAK, false)
+ || SfxItemState::SET == pSet->GetItemState(RES_PAGEDESC, false)
+ || (SfxItemState::SET == pSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem)
+ && nullptr != (pRule = GetDoc()->FindNumRulePtr(
+ static_cast<const SwNumRuleItem*>(pItem)->GetValue()))
+ && pRule->IsAutoRule()))
{
- // JP 05.10.98: Special treatment if one of the attributes Break/PageDesc/NumRule(auto) is
- // in the ItemSet. Otherwise there will be too much or wrong processing (NumRules!)
- // Bug 57568
-
- // Do NOT copy AutoNumRules into the template
- const SfxPoolItem* pItem;
- const SwNumRule* pRule = nullptr;
- if (SfxItemState::SET == pSet->GetItemState(RES_BREAK, false)
- || SfxItemState::SET == pSet->GetItemState(RES_PAGEDESC, false)
+ SfxItemSet aSet( *pSet );
+ aSet.ClearItem( RES_BREAK );
+ aSet.ClearItem( RES_PAGEDESC );
+
+ if (pRule
|| (SfxItemState::SET == pSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem)
&& nullptr != (pRule = GetDoc()->FindNumRulePtr(
static_cast<const SwNumRuleItem*>(pItem)->GetValue()))
&& pRule->IsAutoRule()))
- {
- SfxItemSet aSet( *pSet );
- aSet.ClearItem( RES_BREAK );
- aSet.ClearItem( RES_PAGEDESC );
-
- if (pRule
- || (SfxItemState::SET == pSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem)
- && nullptr != (pRule = GetDoc()->FindNumRulePtr(
- static_cast<const SwNumRuleItem*>(pItem)->GetValue()))
- && pRule->IsAutoRule()))
- aSet.ClearItem( RES_PARATR_NUMRULE );
-
- if( aSet.Count() )
- GetDoc()->ChgFormat(*pColl, aSet );
- }
- else
- GetDoc()->ChgFormat(*pColl, *pSet );
+ aSet.ClearItem( RES_PARATR_NUMRULE );
+
+ if( aSet.Count() )
+ GetDoc()->ChgFormat(*pColl, aSet );
}
+ else
+ GetDoc()->ChgFormat(*pColl, *pSet );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index 92474d253ef1..e4f26588d0af 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -503,28 +503,28 @@ OUString SwEditShell::GetDropText( const sal_Int32 nChars ) const
void SwEditShell::ReplaceDropText( const OUString &rStr, SwPaM* pPaM )
{
SwPaM* pCursor = pPaM ? pPaM : GetCursor();
- if( pCursor->GetPoint()->nNode == pCursor->GetMark()->nNode &&
- pCursor->GetNode().GetTextNode()->IsTextNode() )
- {
- StartAllAction();
+ if( !(pCursor->GetPoint()->nNode == pCursor->GetMark()->nNode &&
+ pCursor->GetNode().GetTextNode()->IsTextNode()) )
+ return;
- const SwNodeIndex& rNd = pCursor->GetPoint()->nNode;
- SwPaM aPam( rNd, rStr.getLength(), rNd, 0 );
- SwTextFrame const*const pTextFrame(static_cast<SwTextFrame const*>(
- rNd.GetNode().GetTextNode()->getLayoutFrame(GetLayout())));
- if (pTextFrame)
- {
- *aPam.GetPoint() = pTextFrame->MapViewToModelPos(TextFrameIndex(0));
- *aPam.GetMark() = pTextFrame->MapViewToModelPos(TextFrameIndex(
- std::min(rStr.getLength(), pTextFrame->GetText().getLength())));
- }
- if( !GetDoc()->getIDocumentContentOperations().Overwrite( aPam, rStr ) )
- {
- OSL_FAIL( "Doc->getIDocumentContentOperations().Overwrite(Str) failed." );
- }
+ StartAllAction();
- EndAllAction();
+ const SwNodeIndex& rNd = pCursor->GetPoint()->nNode;
+ SwPaM aPam( rNd, rStr.getLength(), rNd, 0 );
+ SwTextFrame const*const pTextFrame(static_cast<SwTextFrame const*>(
+ rNd.GetNode().GetTextNode()->getLayoutFrame(GetLayout())));
+ if (pTextFrame)
+ {
+ *aPam.GetPoint() = pTextFrame->MapViewToModelPos(TextFrameIndex(0));
+ *aPam.GetMark() = pTextFrame->MapViewToModelPos(TextFrameIndex(
+ std::min(rStr.getLength(), pTextFrame->GetText().getLength())));
}
+ if( !GetDoc()->getIDocumentContentOperations().Overwrite( aPam, rStr ) )
+ {
+ OSL_FAIL( "Doc->getIDocumentContentOperations().Overwrite(Str) failed." );
+ }
+
+ EndAllAction();
}
OUString SwEditShell::Calculate()
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index 99b36c1855c2..97f8cebfcbb6 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -1563,29 +1563,107 @@ void SwSpellIter::AddPortion(uno::Reference< XSpellAlternatives > const & xAl
SwEditShell *pMySh = GetSh();
OUString sText;
pMySh->GetSelectedText( sText );
- if(!sText.isEmpty())
+ if(sText.isEmpty())
+ return;
+
+ if(xAlt.is() || pGrammarResult != nullptr)
{
- if(xAlt.is() || pGrammarResult != nullptr)
+ CreatePortion(xAlt, pGrammarResult, false, false);
+ }
+ else
+ {
+ SwPaM *pCursor = GetSh()->GetCursor();
+ if ( *pCursor->GetPoint() > *pCursor->GetMark() )
+ pCursor->Exchange();
+ // save the start and end positions
+ SwPosition aStart(*pCursor->GetPoint());
+ SwPosition aEnd(*pCursor->GetMark());
+ // iterate over the text to find changes in language
+ // set the mark equal to the point
+ *pCursor->GetMark() = aStart;
+ SwTextNode* pTextNode = pCursor->GetNode().GetTextNode();
+ LanguageType eStartLanguage = lcl_GetLanguage(*GetSh());
+ SpellContentPosition aNextRedline = lcl_FindNextDeletedRedline(
+ rDeletedRedlines, aStart.nContent.GetIndex() );
+ if( aNextRedline.nLeft == aStart.nContent.GetIndex() )
{
- CreatePortion(xAlt, pGrammarResult, false, false);
+ // select until the end of the current redline
+ const sal_Int32 nEnd = aEnd.nContent.GetIndex() < aNextRedline.nRight ?
+ aEnd.nContent.GetIndex() : aNextRedline.nRight;
+ pCursor->GetPoint()->nContent.Assign( pTextNode, nEnd );
+ CreatePortion(xAlt, pGrammarResult, false, true);
+ aStart = *pCursor->End();
+ // search for next redline
+ aNextRedline = lcl_FindNextDeletedRedline(
+ rDeletedRedlines, aStart.nContent.GetIndex() );
}
- else
+ while(*pCursor->GetPoint() < aEnd)
{
- SwPaM *pCursor = GetSh()->GetCursor();
- if ( *pCursor->GetPoint() > *pCursor->GetMark() )
- pCursor->Exchange();
- // save the start and end positions
- SwPosition aStart(*pCursor->GetPoint());
- SwPosition aEnd(*pCursor->GetMark());
- // iterate over the text to find changes in language
- // set the mark equal to the point
- *pCursor->GetMark() = aStart;
- SwTextNode* pTextNode = pCursor->GetNode().GetTextNode();
- LanguageType eStartLanguage = lcl_GetLanguage(*GetSh());
- SpellContentPosition aNextRedline = lcl_FindNextDeletedRedline(
- rDeletedRedlines, aStart.nContent.GetIndex() );
- if( aNextRedline.nLeft == aStart.nContent.GetIndex() )
+ // #125786 in table cell with fixed row height the cursor might not move forward
+ if(!GetSh()->Right(1, CRSR_SKIP_CELLS))
+ break;
+
+ bool bField = false;
+ // read the character at the current position to check if it's a field
+ sal_Unicode const cChar =
+ pTextNode->GetText()[pCursor->GetMark()->nContent.GetIndex()];
+ if( CH_TXTATR_BREAKWORD == cChar || CH_TXTATR_INWORD == cChar)
+ {
+ const SwTextAttr* pTextAttr = pTextNode->GetTextAttrForCharAt(
+ pCursor->GetMark()->nContent.GetIndex() );
+ const sal_uInt16 nWhich = pTextAttr
+ ? pTextAttr->Which()
+ : RES_TXTATR_END;
+ switch (nWhich)
+ {
+ case RES_TXTATR_FIELD:
+ case RES_TXTATR_ANNOTATION:
+ case RES_TXTATR_FTN:
+ case RES_TXTATR_FLYCNT:
+ bField = true;
+ break;
+ }
+ }
+ else if (cChar == CH_TXT_ATR_FORMELEMENT)
{
+ SwPosition aPos(*pCursor->GetMark());
+ bField = pMySh->GetDoc()->getIDocumentMarkAccess()->getDropDownFor(aPos);
+ }
+
+ LanguageType eCurLanguage = lcl_GetLanguage(*GetSh());
+ bool bRedline = aNextRedline.nLeft == pCursor->GetPoint()->nContent.GetIndex();
+ // create a portion if the next character
+ // - is a field,
+ // - is at the beginning of a deleted redline
+ // - has a different language
+ if(bField || bRedline || eCurLanguage != eStartLanguage)
+ {
+ eStartLanguage = eCurLanguage;
+ // go one step back - the cursor currently selects the first character
+ // with a different language
+ // in the case of redlining it's different
+ if(eCurLanguage != eStartLanguage || bField)
+ *pCursor->GetPoint() = *pCursor->GetMark();
+ // set to the last start
+ *pCursor->GetMark() = aStart;
+ // create portion should only be called if a selection exists
+ // there's no selection if there's a field at the beginning
+ if(*pCursor->Start() != *pCursor->End())
+ CreatePortion(xAlt, pGrammarResult, false, false);
+ aStart = *pCursor->End();
+ // now export the field - if there is any
+ if(bField)
+ {
+ *pCursor->GetMark() = *pCursor->GetPoint();
+ GetSh()->Right(1, CRSR_SKIP_CELLS);
+ CreatePortion(xAlt, pGrammarResult, true, false);
+ aStart = *pCursor->End();
+ }
+ }
+ // if a redline start then create a portion for it
+ if(bRedline)
+ {
+ *pCursor->GetMark() = *pCursor->GetPoint();
// select until the end of the current redline
const sal_Int32 nEnd = aEnd.nContent.GetIndex() < aNextRedline.nRight ?
aEnd.nContent.GetIndex() : aNextRedline.nRight;
@@ -1596,89 +1674,11 @@ void SwSpellIter::AddPortion(uno::Reference< XSpellAlternatives > const & xAl
aNextRedline = lcl_FindNextDeletedRedline(
rDeletedRedlines, aStart.nContent.GetIndex() );
}
- while(*pCursor->GetPoint() < aEnd)
- {
- // #125786 in table cell with fixed row height the cursor might not move forward
- if(!GetSh()->Right(1, CRSR_SKIP_CELLS))
- break;
-
- bool bField = false;
- // read the character at the current position to check if it's a field
- sal_Unicode const cChar =
- pTextNode->GetText()[pCursor->GetMark()->nContent.GetIndex()];
- if( CH_TXTATR_BREAKWORD == cChar || CH_TXTATR_INWORD == cChar)
- {
- const SwTextAttr* pTextAttr = pTextNode->GetTextAttrForCharAt(
- pCursor->GetMark()->nContent.GetIndex() );
- const sal_uInt16 nWhich = pTextAttr
- ? pTextAttr->Which()
- : RES_TXTATR_END;
- switch (nWhich)
- {
- case RES_TXTATR_FIELD:
- case RES_TXTATR_ANNOTATION:
- case RES_TXTATR_FTN:
- case RES_TXTATR_FLYCNT:
- bField = true;
- break;
- }
- }
- else if (cChar == CH_TXT_ATR_FORMELEMENT)
- {
- SwPosition aPos(*pCursor->GetMark());
- bField = pMySh->GetDoc()->getIDocumentMarkAccess()->getDropDownFor(aPos);
- }
-
- LanguageType eCurLanguage = lcl_GetLanguage(*GetSh());
- bool bRedline = aNextRedline.nLeft == pCursor->GetPoint()->nContent.GetIndex();
- // create a portion if the next character
- // - is a field,
- // - is at the beginning of a deleted redline
- // - has a different language
- if(bField || bRedline || eCurLanguage != eStartLanguage)
- {
- eStartLanguage = eCurLanguage;
- // go one step back - the cursor currently selects the first character
- // with a different language
- // in the case of redlining it's different
- if(eCurLanguage != eStartLanguage || bField)
- *pCursor->GetPoint() = *pCursor->GetMark();
- // set to the last start
- *pCursor->GetMark() = aStart;
- // create portion should only be called if a selection exists
- // there's no selection if there's a field at the beginning
- if(*pCursor->Start() != *pCursor->End())
- CreatePortion(xAlt, pGrammarResult, false, false);
- aStart = *pCursor->End();
- // now export the field - if there is any
- if(bField)
- {
- *pCursor->GetMark() = *pCursor->GetPoint();
- GetSh()->Right(1, CRSR_SKIP_CELLS);
- CreatePortion(xAlt, pGrammarResult, true, false);
- aStart = *pCursor->End();
- }
- }
- // if a redline start then create a portion for it
- if(bRedline)
- {
- *pCursor->GetMark() = *pCursor->GetPoint();
- // select until the end of the current redline
- const sal_Int32 nEnd = aEnd.nContent.GetIndex() < aNextRedline.nRight ?
- aEnd.nContent.GetIndex() : aNextRedline.nRight;
- pCursor->GetPoint()->nContent.Assign( pTextNode, nEnd );
- CreatePortion(xAlt, pGrammarResult, false, true);
- aStart = *pCursor->End();
- // search for next redline
- aNextRedline = lcl_FindNextDeletedRedline(
- rDeletedRedlines, aStart.nContent.GetIndex() );
- }
- *pCursor->GetMark() = *pCursor->GetPoint();
- }
- pCursor->SetMark();
- *pCursor->GetMark() = aStart;
- CreatePortion(xAlt, pGrammarResult, false, false);
+ *pCursor->GetMark() = *pCursor->GetPoint();
}
+ pCursor->SetMark();
+ *pCursor->GetMark() = aStart;
+ CreatePortion(xAlt, pGrammarResult, false, false);
}
}
diff --git a/sw/source/core/edit/edsect.cxx b/sw/source/core/edit/edsect.cxx
index ba765eee408e..1eba3f95eb4c 100644
--- a/sw/source/core/edit/edsect.cxx
+++ b/sw/source/core/edit/edsect.cxx
@@ -397,25 +397,25 @@ void SwEditShell::DoSpecialInsert()
// get current node
SwPosition* pCursorPos = GetCursor()->GetPoint();
const SwNode* pInsertNode = lcl_SpecialInsertNode( pCursorPos );
- if( pInsertNode != nullptr )
- {
- StartAllAction();
+ if( pInsertNode == nullptr )
+ return;
- // adjust insert position to insert before start nodes and after end
- // nodes
- SwNodeIndex aInsertIndex( *pInsertNode,
- pInsertNode->IsStartNode() ? -1 : 0 );
- SwPosition aInsertPos( aInsertIndex );
+ StartAllAction();
- // insert a new text node, and set the cursor
- GetDoc()->getIDocumentContentOperations().AppendTextNode( aInsertPos );
- *pCursorPos = aInsertPos;
+ // adjust insert position to insert before start nodes and after end
+ // nodes
+ SwNodeIndex aInsertIndex( *pInsertNode,
+ pInsertNode->IsStartNode() ? -1 : 0 );
+ SwPosition aInsertPos( aInsertIndex );
- // call AttrChangeNotify for the UI
- CallChgLnk();
+ // insert a new text node, and set the cursor
+ GetDoc()->getIDocumentContentOperations().AppendTextNode( aInsertPos );
+ *pCursorPos = aInsertPos;
- EndAllAction();
- }
+ // call AttrChangeNotify for the UI
+ CallChgLnk();
+
+ EndAllAction();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx
index 20cc2df50eea..46ab7e7bcbf8 100644
--- a/sw/source/core/edit/edtox.cxx
+++ b/sw/source/core/edit/edtox.cxx
@@ -150,37 +150,37 @@ void SwEditShell::UpdateTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet)
{
assert(dynamic_cast<const SwTOXBaseSection*>(&rTOX) && "no TOXBaseSection!");
SwTOXBaseSection& rTOXSect = static_cast<SwTOXBaseSection&>(const_cast<SwTOXBase&>(rTOX));
- if (rTOXSect.GetFormat()->GetSectionNode())
- {
- SwDoc* pMyDoc = GetDoc();
- SwDocShell* pDocSh = pMyDoc->GetDocShell();
+ if (!rTOXSect.GetFormat()->GetSectionNode())
+ return;
- bool bInIndex = &rTOX == GetCurTOX();
- CurrShell aCurr( this );
- StartAllAction();
+ SwDoc* pMyDoc = GetDoc();
+ SwDocShell* pDocSh = pMyDoc->GetDocShell();
- ::StartProgress( STR_STATSTR_TOX_UPDATE, 0, 0, pDocSh );
+ bool bInIndex = &rTOX == GetCurTOX();
+ CurrShell aCurr( this );
+ StartAllAction();
- pMyDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::TOXCHANGE, nullptr);
+ ::StartProgress( STR_STATSTR_TOX_UPDATE, 0, 0, pDocSh );
- // create listing stub
- rTOXSect.Update(pSet, GetLayout());
+ pMyDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::TOXCHANGE, nullptr);
- // correct Cursor
- if( bInIndex )
- rTOXSect.SetPosAtStartEnd(*GetCursor()->GetPoint());
+ // create listing stub
+ rTOXSect.Update(pSet, GetLayout());
- // start formatting
- CalcLayout();
+ // correct Cursor
+ if( bInIndex )
+ rTOXSect.SetPosAtStartEnd(*GetCursor()->GetPoint());
+
+ // start formatting
+ CalcLayout();
- // insert page numbering
- rTOXSect.UpdatePageNum();
+ // insert page numbering
+ rTOXSect.UpdatePageNum();
- pMyDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::TOXCHANGE, nullptr);
+ pMyDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::TOXCHANGE, nullptr);
- ::EndProgress( pDocSh );
- EndAllAction();
- }
+ ::EndProgress( pDocSh );
+ EndAllAction();
}
/// Get current listing before or at the Cursor
diff --git a/sw/source/core/edit/edundo.cxx b/sw/source/core/edit/edundo.cxx
index 4d6fb3256468..cfff6b8fa108 100644
--- a/sw/source/core/edit/edundo.cxx
+++ b/sw/source/core/edit/edundo.cxx
@@ -222,25 +222,25 @@ static void lcl_SelectSdrMarkList( SwEditShell* pShell,
OSL_ENSURE( pShell != nullptr, "need shell!" );
OSL_ENSURE( pSdrMarkList != nullptr, "need mark list" );
- if( dynamic_cast<const SwFEShell*>( pShell) != nullptr )
+ if( dynamic_cast<const SwFEShell*>( pShell) == nullptr )
+ return;
+
+ SwFEShell* pFEShell = static_cast<SwFEShell*>( pShell );
+ bool bFirst = true;
+ for( size_t i = 0; i < pSdrMarkList->GetMarkCount(); ++i )
{
- SwFEShell* pFEShell = static_cast<SwFEShell*>( pShell );
- bool bFirst = true;
- for( size_t i = 0; i < pSdrMarkList->GetMarkCount(); ++i )
+ SdrObject *pObj = pSdrMarkList->GetMark( i )->GetMarkedSdrObj();
+ if( pObj )
{
- SdrObject *pObj = pSdrMarkList->GetMark( i )->GetMarkedSdrObj();
- if( pObj )
- {
- pFEShell->SelectObj( Point(), bFirst ? 0 : SW_ADD_SELECT, pObj );
- bFirst = false;
- }
+ pFEShell->SelectObj( Point(), bFirst ? 0 : SW_ADD_SELECT, pObj );
+ bFirst = false;
}
-
- // the old implementation would always unselect
- // objects, even if no new ones were selected. If this
- // is a problem, we need to re-work this a little.
- OSL_ENSURE( pSdrMarkList->GetMarkCount() != 0, "empty mark list" );
}
+
+ // the old implementation would always unselect
+ // objects, even if no new ones were selected. If this
+ // is a problem, we need to re-work this a little.
+ OSL_ENSURE( pSdrMarkList->GetMarkCount() != 0, "empty mark list" );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */