diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-14 09:11:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-15 09:48:37 +0100 |
commit | abe047f1e8c65e65d63077923fb051b32673fddd (patch) | |
tree | b5b329f0543d53706b3190c434cc708ac92569c1 /sd | |
parent | 9e922ced246d2c4d4554d66ba97eae1d2a02847f (diff) |
loplugin:flatten in sd/source/ui/func
Change-Id: I1d5d3ea51d012ade653aef70a17f2c173d31d3b9
Reviewed-on: https://gerrit.libreoffice.org/67833
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/func/fubullet.cxx | 242 | ||||
-rw-r--r-- | sd/source/ui/func/fuconarc.cxx | 52 | ||||
-rw-r--r-- | sd/source/ui/func/fuconbez.cxx | 46 | ||||
-rw-r--r-- | sd/source/ui/func/fuconrec.cxx | 298 | ||||
-rw-r--r-- | sd/source/ui/func/fucopy.cxx | 346 | ||||
-rw-r--r-- | sd/source/ui/func/fuexpand.cxx | 274 | ||||
-rw-r--r-- | sd/source/ui/func/fuformatpaintbrush.cxx | 40 | ||||
-rw-r--r-- | sd/source/ui/func/fuhhconv.cxx | 104 | ||||
-rw-r--r-- | sd/source/ui/func/fuinsert.cxx | 124 | ||||
-rw-r--r-- | sd/source/ui/func/fuinsfil.cxx | 194 | ||||
-rw-r--r-- | sd/source/ui/func/fulinend.cxx | 140 | ||||
-rw-r--r-- | sd/source/ui/func/fumorph.cxx | 324 | ||||
-rw-r--r-- | sd/source/ui/func/fuoaprms.cxx | 350 | ||||
-rw-r--r-- | sd/source/ui/func/fupage.cxx | 24 | ||||
-rw-r--r-- | sd/source/ui/func/fupoor.cxx | 113 | ||||
-rw-r--r-- | sd/source/ui/func/fuprlout.cxx | 146 | ||||
-rw-r--r-- | sd/source/ui/func/fuprobjs.cxx | 70 | ||||
-rw-r--r-- | sd/source/ui/func/fusearch.cxx | 48 | ||||
-rw-r--r-- | sd/source/ui/func/fusldlg.cxx | 184 | ||||
-rw-r--r-- | sd/source/ui/func/futext.cxx | 180 | ||||
-rw-r--r-- | sd/source/ui/func/fuvect.cxx | 51 | ||||
-rw-r--r-- | sd/source/ui/func/smarttag.cxx | 24 |
22 files changed, 1688 insertions, 1686 deletions
diff --git a/sd/source/ui/func/fubullet.cxx b/sd/source/ui/func/fubullet.cxx index 81dc443b5a7c..3f9527f92200 100644 --- a/sd/source/ui/func/fubullet.cxx +++ b/sd/source/ui/func/fubullet.cxx @@ -117,35 +117,35 @@ void FuBullet::InsertFormattingMark( sal_Unicode cMark ) } // insert string - if(pOV && pOL) - { - // prevent flickering - pOV->HideCursor(); - pOL->SetUpdateMode(false); + if(!(pOV && pOL)) + return; - // remove old selected text - pOV->InsertText( "" ); + // prevent flickering + pOV->HideCursor(); + pOL->SetUpdateMode(false); - // prepare undo - SfxUndoManager& rUndoMgr = pOL->GetUndoManager(); - rUndoMgr.EnterListAction(SdResId(STR_UNDO_INSERT_SPECCHAR), - "", 0, mpViewShell->GetViewShellBase().GetViewShellId() ); + // remove old selected text + pOV->InsertText( "" ); - // insert given text - OUString aStr( cMark ); - pOV->InsertText( aStr, true); + // prepare undo + SfxUndoManager& rUndoMgr = pOL->GetUndoManager(); + rUndoMgr.EnterListAction(SdResId(STR_UNDO_INSERT_SPECCHAR), + "", 0, mpViewShell->GetViewShellBase().GetViewShellId() ); - ESelection aSel = pOV->GetSelection(); - aSel.nStartPara = aSel.nEndPara; - aSel.nStartPos = aSel.nEndPos; - pOV->SetSelection(aSel); + // insert given text + OUString aStr( cMark ); + pOV->InsertText( aStr, true); - rUndoMgr.LeaveListAction(); + ESelection aSel = pOV->GetSelection(); + aSel.nStartPara = aSel.nEndPara; + aSel.nStartPos = aSel.nEndPos; + pOV->SetSelection(aSel); - // restart repainting - pOL->SetUpdateMode(true); - pOV->ShowCursor(); - } + rUndoMgr.LeaveListAction(); + + // restart repainting + pOL->SetUpdateMode(true); + pOV->ShowCursor(); } void FuBullet::InsertSpecialCharacter( SfxRequest const & rReq ) @@ -200,83 +200,83 @@ void FuBullet::InsertSpecialCharacter( SfxRequest const & rReq ) return; } - if (!aChars.isEmpty()) - { - OutlinerView* pOV = nullptr; - ::Outliner* pOL = nullptr; + if (aChars.isEmpty()) + return; - // determine depending on ViewShell Outliner and OutlinerView - if(dynamic_cast< const DrawViewShell *>( mpViewShell )) - { - pOV = mpView->GetTextEditOutlinerView(); - if (pOV) - { - pOL = mpView->GetTextEditOutliner(); - } - } - else if(dynamic_cast< const OutlineViewShell *>( mpViewShell )) - { - pOL = &static_cast<OutlineView*>(mpView)->GetOutliner(); - pOV = static_cast<OutlineView*>(mpView)->GetViewByWindow( - mpViewShell->GetActiveWindow()); - } + OutlinerView* pOV = nullptr; + ::Outliner* pOL = nullptr; - // insert special character + // determine depending on ViewShell Outliner and OutlinerView + if(dynamic_cast< const DrawViewShell *>( mpViewShell )) + { + pOV = mpView->GetTextEditOutlinerView(); if (pOV) { - // prevent flicker - pOV->HideCursor(); - pOL->SetUpdateMode(false); - - /* remember old attributes: - To do that, remove selected area before (it has to go anyway). - With that, we get unique attributes (and since there is no - DeleteSelected() in OutlinerView, it is deleted by inserting an - empty string). */ - pOV->InsertText( "" ); - - SfxItemSet aOldSet( mpDoc->GetPool(), svl::Items<EE_CHAR_FONTINFO, EE_CHAR_FONTINFO>{} ); - aOldSet.Put( pOV->GetAttribs() ); - - SfxUndoManager& rUndoMgr = pOL->GetUndoManager(); - ViewShellId nViewShellId = mpViewShell ? mpViewShell->GetViewShellBase().GetViewShellId() : ViewShellId(-1); - rUndoMgr.EnterListAction(SdResId(STR_UNDO_INSERT_SPECCHAR), - "", 0, nViewShellId ); - pOV->InsertText(aChars, true); - - // set attributes (set font) - SfxItemSet aSet(pOL->GetEmptyItemSet()); - SvxFontItem aFontItem (aFont.GetFamilyType(), aFont.GetFamilyName(), - aFont.GetStyleName(), aFont.GetPitch(), - aFont.GetCharSet(), - EE_CHAR_FONTINFO); - aSet.Put(aFontItem); - aFontItem.SetWhich(EE_CHAR_FONTINFO_CJK); - aSet.Put(aFontItem); - aFontItem.SetWhich(EE_CHAR_FONTINFO_CTL); - aSet.Put(aFontItem); - pOV->SetAttribs(aSet); - - ESelection aSel = pOV->GetSelection(); - aSel.nStartPara = aSel.nEndPara; - aSel.nStartPos = aSel.nEndPos; - pOV->SetSelection(aSel); - - // do not go ahead with setting attributes of special characters - pOV->GetOutliner()->QuickSetAttribs(aOldSet, aSel); - - rUndoMgr.LeaveListAction(); - - // show it again - pOL->SetUpdateMode(true); - pOV->ShowCursor(); + pOL = mpView->GetTextEditOutliner(); } } + else if(dynamic_cast< const OutlineViewShell *>( mpViewShell )) + { + pOL = &static_cast<OutlineView*>(mpView)->GetOutliner(); + pOV = static_cast<OutlineView*>(mpView)->GetViewByWindow( + mpViewShell->GetActiveWindow()); + } + + // insert special character + if (!pOV) + return; + + // prevent flicker + pOV->HideCursor(); + pOL->SetUpdateMode(false); + + /* remember old attributes: + To do that, remove selected area before (it has to go anyway). + With that, we get unique attributes (and since there is no + DeleteSelected() in OutlinerView, it is deleted by inserting an + empty string). */ + pOV->InsertText( "" ); + + SfxItemSet aOldSet( mpDoc->GetPool(), svl::Items<EE_CHAR_FONTINFO, EE_CHAR_FONTINFO>{} ); + aOldSet.Put( pOV->GetAttribs() ); + + SfxUndoManager& rUndoMgr = pOL->GetUndoManager(); + ViewShellId nViewShellId = mpViewShell ? mpViewShell->GetViewShellBase().GetViewShellId() : ViewShellId(-1); + rUndoMgr.EnterListAction(SdResId(STR_UNDO_INSERT_SPECCHAR), + "", 0, nViewShellId ); + pOV->InsertText(aChars, true); + + // set attributes (set font) + SfxItemSet aSet(pOL->GetEmptyItemSet()); + SvxFontItem aFontItem (aFont.GetFamilyType(), aFont.GetFamilyName(), + aFont.GetStyleName(), aFont.GetPitch(), + aFont.GetCharSet(), + EE_CHAR_FONTINFO); + aSet.Put(aFontItem); + aFontItem.SetWhich(EE_CHAR_FONTINFO_CJK); + aSet.Put(aFontItem); + aFontItem.SetWhich(EE_CHAR_FONTINFO_CTL); + aSet.Put(aFontItem); + pOV->SetAttribs(aSet); + + ESelection aSel = pOV->GetSelection(); + aSel.nStartPara = aSel.nEndPara; + aSel.nStartPos = aSel.nEndPos; + pOV->SetSelection(aSel); + + // do not go ahead with setting attributes of special characters + pOV->GetOutliner()->QuickSetAttribs(aOldSet, aSel); + + rUndoMgr.LeaveListAction(); + + // show it again + pOL->SetUpdateMode(true); + pOV->ShowCursor(); } void FuBullet::GetSlotState( SfxItemSet& rSet, ViewShell const * pViewShell, SfxViewFrame* pViewFrame ) { - if( SfxItemState::DEFAULT == rSet.GetItemState( SID_CHARMAP ) || + if( !(SfxItemState::DEFAULT == rSet.GetItemState( SID_CHARMAP ) || SfxItemState::DEFAULT == rSet.GetItemState( SID_CHARMAP_CONTROL ) || SfxItemState::DEFAULT == rSet.GetItemState( FN_INSERT_SOFT_HYPHEN ) || SfxItemState::DEFAULT == rSet.GetItemState( FN_INSERT_HARDHYPHEN ) || @@ -284,44 +284,44 @@ void FuBullet::GetSlotState( SfxItemSet& rSet, ViewShell const * pViewShell, Sfx SfxItemState::DEFAULT == rSet.GetItemState( SID_INSERT_RLM ) || SfxItemState::DEFAULT == rSet.GetItemState( SID_INSERT_LRM ) || SfxItemState::DEFAULT == rSet.GetItemState( SID_INSERT_ZWNBSP ) || - SfxItemState::DEFAULT == rSet.GetItemState( SID_INSERT_ZWSP )) - { - ::sd::View* pView = pViewShell ? pViewShell->GetView() : nullptr; - OutlinerView* pOLV = pView ? pView->GetTextEditOutlinerView() : nullptr; + SfxItemState::DEFAULT == rSet.GetItemState( SID_INSERT_ZWSP ))) + return; - const bool bTextEdit = pOLV; + ::sd::View* pView = pViewShell ? pViewShell->GetView() : nullptr; + OutlinerView* pOLV = pView ? pView->GetTextEditOutlinerView() : nullptr; - SvtCTLOptions aCTLOptions; - const bool bCtlEnabled = aCTLOptions.IsCTLFontEnabled(); + const bool bTextEdit = pOLV; - if(!bTextEdit ) - { - rSet.DisableItem(FN_INSERT_SOFT_HYPHEN); - rSet.DisableItem(FN_INSERT_HARDHYPHEN); - rSet.DisableItem(FN_INSERT_HARD_SPACE); - rSet.DisableItem(SID_INSERT_ZWNBSP); - rSet.DisableItem(SID_INSERT_ZWSP); - } + SvtCTLOptions aCTLOptions; + const bool bCtlEnabled = aCTLOptions.IsCTLFontEnabled(); - if( !bTextEdit && (dynamic_cast<OutlineViewShell const *>( pViewShell ) == nullptr) ) - { - rSet.DisableItem(SID_CHARMAP); - rSet.DisableItem(SID_CHARMAP_CONTROL); - } + if(!bTextEdit ) + { + rSet.DisableItem(FN_INSERT_SOFT_HYPHEN); + rSet.DisableItem(FN_INSERT_HARDHYPHEN); + rSet.DisableItem(FN_INSERT_HARD_SPACE); + rSet.DisableItem(SID_INSERT_ZWNBSP); + rSet.DisableItem(SID_INSERT_ZWSP); + } - if(!bTextEdit || !bCtlEnabled ) - { - rSet.DisableItem(SID_INSERT_RLM); - rSet.DisableItem(SID_INSERT_LRM); - } + if( !bTextEdit && (dynamic_cast<OutlineViewShell const *>( pViewShell ) == nullptr) ) + { + rSet.DisableItem(SID_CHARMAP); + rSet.DisableItem(SID_CHARMAP_CONTROL); + } - if( pViewFrame ) - { - SfxBindings& rBindings = pViewFrame->GetBindings(); + if(!bTextEdit || !bCtlEnabled ) + { + rSet.DisableItem(SID_INSERT_RLM); + rSet.DisableItem(SID_INSERT_LRM); + } - rBindings.SetVisibleState( SID_INSERT_RLM, bCtlEnabled ); - rBindings.SetVisibleState( SID_INSERT_LRM, bCtlEnabled ); - } + if( pViewFrame ) + { + SfxBindings& rBindings = pViewFrame->GetBindings(); + + rBindings.SetVisibleState( SID_INSERT_RLM, bCtlEnabled ); + rBindings.SetVisibleState( SID_INSERT_LRM, bCtlEnabled ); } } } // end of namespace sd diff --git a/sd/source/ui/func/fuconarc.cxx b/sd/source/ui/func/fuconarc.cxx index 4f7cf8c0252f..9ca9d9468733 100644 --- a/sd/source/ui/func/fuconarc.cxx +++ b/sd/source/ui/func/fuconarc.cxx @@ -75,32 +75,32 @@ void FuConstructArc::DoExecute( SfxRequest& rReq ) const SfxItemSet *pArgs = rReq.GetArgs (); - if (pArgs) - { - const SfxUInt32Item* pCenterX = rReq.GetArg<SfxUInt32Item>(ID_VAL_CENTER_X); - const SfxUInt32Item* pCenterY = rReq.GetArg<SfxUInt32Item>(ID_VAL_CENTER_Y); - const SfxUInt32Item* pAxisX = rReq.GetArg<SfxUInt32Item>(ID_VAL_AXIS_X); - const SfxUInt32Item* pAxisY = rReq.GetArg<SfxUInt32Item>(ID_VAL_AXIS_Y); - const SfxUInt32Item* pPhiStart = rReq.GetArg<SfxUInt32Item>(ID_VAL_ANGLESTART); - const SfxUInt32Item* pPhiEnd = rReq.GetArg<SfxUInt32Item>(ID_VAL_ANGLEEND); - - ::tools::Rectangle aNewRectangle (pCenterX->GetValue () - pAxisX->GetValue () / 2, - pCenterY->GetValue () - pAxisY->GetValue () / 2, - pCenterX->GetValue () + pAxisX->GetValue () / 2, - pCenterY->GetValue () + pAxisY->GetValue () / 2); - - Activate(); // sets aObjKind - SdrCircObj* pNewCircle = - new SdrCircObj( - mpView->getSdrModelFromSdrView(), - static_cast<SdrObjKind>(mpView->GetCurrentObjIdentifier()), - aNewRectangle, - static_cast<long>(pPhiStart->GetValue () * 10.0), - static_cast<long>(pPhiEnd->GetValue () * 10.0)); - SdrPageView *pPV = mpView->GetSdrPageView(); - - mpView->InsertObjectAtView(pNewCircle, *pPV, SdrInsertFlags::SETDEFLAYER); - } + if (!pArgs) + return; + + const SfxUInt32Item* pCenterX = rReq.GetArg<SfxUInt32Item>(ID_VAL_CENTER_X); + const SfxUInt32Item* pCenterY = rReq.GetArg<SfxUInt32Item>(ID_VAL_CENTER_Y); + const SfxUInt32Item* pAxisX = rReq.GetArg<SfxUInt32Item>(ID_VAL_AXIS_X); + const SfxUInt32Item* pAxisY = rReq.GetArg<SfxUInt32Item>(ID_VAL_AXIS_Y); + const SfxUInt32Item* pPhiStart = rReq.GetArg<SfxUInt32Item>(ID_VAL_ANGLESTART); + const SfxUInt32Item* pPhiEnd = rReq.GetArg<SfxUInt32Item>(ID_VAL_ANGLEEND); + + ::tools::Rectangle aNewRectangle (pCenterX->GetValue () - pAxisX->GetValue () / 2, + pCenterY->GetValue () - pAxisY->GetValue () / 2, + pCenterX->GetValue () + pAxisX->GetValue () / 2, + pCenterY->GetValue () + pAxisY->GetValue () / 2); + + Activate(); // sets aObjKind + SdrCircObj* pNewCircle = + new SdrCircObj( + mpView->getSdrModelFromSdrView(), + static_cast<SdrObjKind>(mpView->GetCurrentObjIdentifier()), + aNewRectangle, + static_cast<long>(pPhiStart->GetValue () * 10.0), + static_cast<long>(pPhiEnd->GetValue () * 10.0)); + SdrPageView *pPV = mpView->GetSdrPageView(); + + mpView->InsertObjectAtView(pNewCircle, *pPV, SdrInsertFlags::SETDEFLAYER); } bool FuConstructArc::MouseButtonDown( const MouseEvent& rMEvt ) diff --git a/sd/source/ui/func/fuconbez.cxx b/sd/source/ui/func/fuconbez.cxx index 1acc46a41f9c..978e27ddca3d 100644 --- a/sd/source/ui/func/fuconbez.cxx +++ b/sd/source/ui/func/fuconbez.cxx @@ -104,31 +104,31 @@ void FuConstructBezierPolygon::DoExecute( SfxRequest& rReq ) const SfxItemSet* pArgs = rReq.GetArgs(); - if( pArgs ) - { - const SfxPoolItem* pPoolItem = nullptr; - if( SfxItemState::SET == pArgs->GetItemState( SID_ADD_MOTION_PATH, true, &pPoolItem ) ) - maTargets = static_cast<const SfxUnoAnyItem*>( pPoolItem )->GetValue(); + if( !pArgs ) + return; - if (nSlotId == SID_DRAW_FREELINE_NOFILL) - { - const SfxUInt16Item* pTransparence = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1); - const SfxStringItem* pColor = rReq.GetArg<SfxStringItem>(FN_PARAM_2); - const SfxUInt16Item* pWidth = rReq.GetArg<SfxUInt16Item>(FN_PARAM_3); + const SfxPoolItem* pPoolItem = nullptr; + if( SfxItemState::SET == pArgs->GetItemState( SID_ADD_MOTION_PATH, true, &pPoolItem ) ) + maTargets = static_cast<const SfxUnoAnyItem*>( pPoolItem )->GetValue(); - if (pTransparence && pTransparence->GetValue() > 0) - { - mnTransparence = pTransparence->GetValue(); - } - if (pColor && !pColor->GetValue().isEmpty()) - { - msColor = pColor->GetValue(); - } - if (pWidth && pWidth->GetValue() > 0) - { - mnWidth = pWidth->GetValue(); - } - } + if (nSlotId != SID_DRAW_FREELINE_NOFILL) + return; + + const SfxUInt16Item* pTransparence = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1); + const SfxStringItem* pColor = rReq.GetArg<SfxStringItem>(FN_PARAM_2); + const SfxUInt16Item* pWidth = rReq.GetArg<SfxUInt16Item>(FN_PARAM_3); + + if (pTransparence && pTransparence->GetValue() > 0) + { + mnTransparence = pTransparence->GetValue(); + } + if (pColor && !pColor->GetValue().isEmpty()) + { + msColor = pColor->GetValue(); + } + if (pWidth && pWidth->GetValue() > 0) + { + mnWidth = pWidth->GetValue(); } } diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx index fff0fac7ce5c..bee469d76e09 100644 --- a/sd/source/ui/func/fuconrec.cxx +++ b/sd/source/ui/func/fuconrec.cxx @@ -613,7 +613,7 @@ static ::basegfx::B2DPolyPolygon getPolygon(const char* pResId, const SdrModel& void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj) { - if ( (rObj.GetObjIdentifier() == OBJ_EDGE && + if ( !((rObj.GetObjIdentifier() == OBJ_EDGE && nSlotId != SID_TOOL_CONNECTOR && nSlotId != SID_CONNECTOR_LINE && nSlotId != SID_CONNECTOR_LINES && @@ -624,177 +624,177 @@ void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj nSlotId == SID_LINE_ARROW_CIRCLE || nSlotId == SID_LINE_CIRCLE_ARROW || nSlotId == SID_LINE_ARROW_SQUARE || - nSlotId == SID_LINE_SQUARE_ARROW ) + nSlotId == SID_LINE_SQUARE_ARROW) ) + return; + + // set attributes of line start and ends + SdrModel& rModel(rObj.getSdrModelFromSdrObject()); + + // arrowhead + ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, rModel ) ); + if( !aArrow.count() ) + { + ::basegfx::B2DPolygon aNewArrow; + aNewArrow.append(::basegfx::B2DPoint(10.0, 0.0)); + aNewArrow.append(::basegfx::B2DPoint(0.0, 30.0)); + aNewArrow.append(::basegfx::B2DPoint(20.0, 30.0)); + aNewArrow.setClosed(true); + aArrow.append(aNewArrow); + } + + // Circles + ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, rModel ) ); + if( !aCircle.count() ) { - // set attributes of line start and ends - SdrModel& rModel(rObj.getSdrModelFromSdrObject()); + ::basegfx::B2DPolygon aNewCircle; + aNewCircle = ::basegfx::utils::createPolygonFromEllipse(::basegfx::B2DPoint(0.0, 0.0), 250.0, 250.0); + aNewCircle.setClosed(true); + aCircle.append(aNewCircle); + } + + // Square + ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, rModel ) ); + if( !aSquare.count() ) + { + ::basegfx::B2DPolygon aNewSquare; + aNewSquare.append(::basegfx::B2DPoint(0.0, 0.0)); + aNewSquare.append(::basegfx::B2DPoint(10.0, 0.0)); + aNewSquare.append(::basegfx::B2DPoint(10.0, 10.0)); + aNewSquare.append(::basegfx::B2DPoint(0.0, 10.0)); + aNewSquare.setClosed(true); + aSquare.append(aNewSquare); + } + + SfxItemSet aSet( mpDoc->GetPool() ); + mpView->GetAttributes( aSet ); - // arrowhead - ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, rModel ) ); - if( !aArrow.count() ) + // #i3908# Here, the default Line Start/End width for arrow construction is + // set. To have the same value in all situations (construction) in i3908 + // it was decided to change the default to 0.03 cm for all situations. + long nWidth = 300; // (1/100th mm) + + // determine line width and calculate with it the line end width + if( aSet.GetItemState( XATTR_LINEWIDTH ) != SfxItemState::DONTCARE ) + { + long nValue = aSet.Get( XATTR_LINEWIDTH ).GetValue(); + if( nValue > 0 ) + nWidth = nValue * 3; + } + + switch (nSlotId) + { + case SID_CONNECTOR_ARROWS: + case SID_CONNECTOR_LINE_ARROWS: + case SID_CONNECTOR_LINES_ARROWS: + case SID_CONNECTOR_CURVE_ARROWS: + case SID_LINE_ARROWS: { - ::basegfx::B2DPolygon aNewArrow; - aNewArrow.append(::basegfx::B2DPoint(10.0, 0.0)); - aNewArrow.append(::basegfx::B2DPoint(0.0, 30.0)); - aNewArrow.append(::basegfx::B2DPoint(20.0, 30.0)); - aNewArrow.setClosed(true); - aArrow.append(aNewArrow); + // connector with arrow ends + rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW), aArrow)); + rAttr.Put(XLineStartWidthItem(nWidth)); + rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW), aArrow)); + rAttr.Put(XLineEndWidthItem(nWidth)); } + break; - // Circles - ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, rModel ) ); - if( !aCircle.count() ) + case SID_CONNECTOR_ARROW_START: + case SID_CONNECTOR_LINE_ARROW_START: + case SID_CONNECTOR_LINES_ARROW_START: + case SID_CONNECTOR_CURVE_ARROW_START: + case SID_LINE_ARROW_START: + case SID_LINE_ARROW_CIRCLE: + case SID_LINE_ARROW_SQUARE: { - ::basegfx::B2DPolygon aNewCircle; - aNewCircle = ::basegfx::utils::createPolygonFromEllipse(::basegfx::B2DPoint(0.0, 0.0), 250.0, 250.0); - aNewCircle.setClosed(true); - aCircle.append(aNewCircle); + // connector with arrow start + rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW), aArrow)); + rAttr.Put(XLineStartWidthItem(nWidth)); } + break; - // Square - ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, rModel ) ); - if( !aSquare.count() ) + case SID_CONNECTOR_ARROW_END: + case SID_CONNECTOR_LINE_ARROW_END: + case SID_CONNECTOR_LINES_ARROW_END: + case SID_CONNECTOR_CURVE_ARROW_END: + case SID_LINE_ARROW_END: + case SID_LINE_CIRCLE_ARROW: + case SID_LINE_SQUARE_ARROW: { - ::basegfx::B2DPolygon aNewSquare; - aNewSquare.append(::basegfx::B2DPoint(0.0, 0.0)); - aNewSquare.append(::basegfx::B2DPoint(10.0, 0.0)); - aNewSquare.append(::basegfx::B2DPoint(10.0, 10.0)); - aNewSquare.append(::basegfx::B2DPoint(0.0, 10.0)); - aNewSquare.setClosed(true); - aSquare.append(aNewSquare); + // connector with arrow end + rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW), aArrow)); + rAttr.Put(XLineEndWidthItem(nWidth)); } + break; - SfxItemSet aSet( mpDoc->GetPool() ); - mpView->GetAttributes( aSet ); - - // #i3908# Here, the default Line Start/End width for arrow construction is - // set. To have the same value in all situations (construction) in i3908 - // it was decided to change the default to 0.03 cm for all situations. - long nWidth = 300; // (1/100th mm) - - // determine line width and calculate with it the line end width - if( aSet.GetItemState( XATTR_LINEWIDTH ) != SfxItemState::DONTCARE ) + case SID_CONNECTOR_CIRCLES: + case SID_CONNECTOR_LINE_CIRCLES: + case SID_CONNECTOR_LINES_CIRCLES: + case SID_CONNECTOR_CURVE_CIRCLES: { - long nValue = aSet.Get( XATTR_LINEWIDTH ).GetValue(); - if( nValue > 0 ) - nWidth = nValue * 3; + // connector with circle ends + rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle)); + rAttr.Put(XLineStartWidthItem(nWidth)); + rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle)); + rAttr.Put(XLineEndWidthItem(nWidth)); } + break; - switch (nSlotId) + case SID_CONNECTOR_CIRCLE_START: + case SID_CONNECTOR_LINE_CIRCLE_START: + case SID_CONNECTOR_LINES_CIRCLE_START: + case SID_CONNECTOR_CURVE_CIRCLE_START: { - case SID_CONNECTOR_ARROWS: - case SID_CONNECTOR_LINE_ARROWS: - case SID_CONNECTOR_LINES_ARROWS: - case SID_CONNECTOR_CURVE_ARROWS: - case SID_LINE_ARROWS: - { - // connector with arrow ends - rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW), aArrow)); - rAttr.Put(XLineStartWidthItem(nWidth)); - rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW), aArrow)); - rAttr.Put(XLineEndWidthItem(nWidth)); - } - break; - - case SID_CONNECTOR_ARROW_START: - case SID_CONNECTOR_LINE_ARROW_START: - case SID_CONNECTOR_LINES_ARROW_START: - case SID_CONNECTOR_CURVE_ARROW_START: - case SID_LINE_ARROW_START: - case SID_LINE_ARROW_CIRCLE: - case SID_LINE_ARROW_SQUARE: - { - // connector with arrow start - rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW), aArrow)); - rAttr.Put(XLineStartWidthItem(nWidth)); - } - break; - - case SID_CONNECTOR_ARROW_END: - case SID_CONNECTOR_LINE_ARROW_END: - case SID_CONNECTOR_LINES_ARROW_END: - case SID_CONNECTOR_CURVE_ARROW_END: - case SID_LINE_ARROW_END: - case SID_LINE_CIRCLE_ARROW: - case SID_LINE_SQUARE_ARROW: - { - // connector with arrow end - rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW), aArrow)); - rAttr.Put(XLineEndWidthItem(nWidth)); - } - break; - - case SID_CONNECTOR_CIRCLES: - case SID_CONNECTOR_LINE_CIRCLES: - case SID_CONNECTOR_LINES_CIRCLES: - case SID_CONNECTOR_CURVE_CIRCLES: - { - // connector with circle ends - rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle)); - rAttr.Put(XLineStartWidthItem(nWidth)); - rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle)); - rAttr.Put(XLineEndWidthItem(nWidth)); - } - break; - - case SID_CONNECTOR_CIRCLE_START: - case SID_CONNECTOR_LINE_CIRCLE_START: - case SID_CONNECTOR_LINES_CIRCLE_START: - case SID_CONNECTOR_CURVE_CIRCLE_START: - { - // connector with circle start - rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle)); - rAttr.Put(XLineStartWidthItem(nWidth)); - } - break; + // connector with circle start + rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle)); + rAttr.Put(XLineStartWidthItem(nWidth)); + } + break; - case SID_CONNECTOR_CIRCLE_END: - case SID_CONNECTOR_LINE_CIRCLE_END: - case SID_CONNECTOR_LINES_CIRCLE_END: - case SID_CONNECTOR_CURVE_CIRCLE_END: - { - // connector with circle ends - rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle)); - rAttr.Put(XLineEndWidthItem(nWidth)); - } - break; + case SID_CONNECTOR_CIRCLE_END: + case SID_CONNECTOR_LINE_CIRCLE_END: + case SID_CONNECTOR_LINES_CIRCLE_END: + case SID_CONNECTOR_CURVE_CIRCLE_END: + { + // connector with circle ends + rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle)); + rAttr.Put(XLineEndWidthItem(nWidth)); } + break; + } - // and again, for the still missing ends - switch (nSlotId) + // and again, for the still missing ends + switch (nSlotId) + { + case SID_LINE_ARROW_CIRCLE: { - case SID_LINE_ARROW_CIRCLE: - { - // circle end - rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle)); - rAttr.Put(XLineEndWidthItem(nWidth)); - } - break; + // circle end + rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle)); + rAttr.Put(XLineEndWidthItem(nWidth)); + } + break; - case SID_LINE_CIRCLE_ARROW: - { - // circle start - rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle)); - rAttr.Put(XLineStartWidthItem(nWidth)); - } - break; + case SID_LINE_CIRCLE_ARROW: + { + // circle start + rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle)); + rAttr.Put(XLineStartWidthItem(nWidth)); + } + break; - case SID_LINE_ARROW_SQUARE: - { - // square end - rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_SQUARE), aSquare)); - rAttr.Put(XLineEndWidthItem(nWidth)); - } - break; + case SID_LINE_ARROW_SQUARE: + { + // square end + rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_SQUARE), aSquare)); + rAttr.Put(XLineEndWidthItem(nWidth)); + } + break; - case SID_LINE_SQUARE_ARROW: - { - // square start - rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_SQUARE), aSquare)); - rAttr.Put(XLineStartWidthItem(nWidth)); - } - break; + case SID_LINE_SQUARE_ARROW: + { + // square start + rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_SQUARE), aSquare)); + rAttr.Put(XLineStartWidthItem(nWidth)); } + break; } } diff --git a/sd/source/ui/func/fucopy.cxx b/sd/source/ui/func/fucopy.cxx index f81d5ae4a0c2..18e7dbb5e1bf 100644 --- a/sd/source/ui/func/fucopy.cxx +++ b/sd/source/ui/func/fucopy.cxx @@ -64,226 +64,226 @@ rtl::Reference<FuPoor> FuCopy::Create( ViewShell* pViewSh, ::sd::Window* pWin, : void FuCopy::DoExecute( SfxRequest& rReq ) { - if( mpView->AreObjectsMarked() ) + if( !mpView->AreObjectsMarked() ) + return; + + // Undo + OUString aString( mpView->GetDescriptionOfMarkedObjects() ); + aString += " " + SdResId( STR_UNDO_COPYOBJECTS ); + mpView->BegUndo( aString ); + + const SfxItemSet* pArgs = rReq.GetArgs(); + + if( !pArgs ) { - // Undo - OUString aString( mpView->GetDescriptionOfMarkedObjects() ); - aString += " " + SdResId( STR_UNDO_COPYOBJECTS ); - mpView->BegUndo( aString ); + SfxItemSet aSet( mpViewShell->GetPool(), + svl::Items<ATTR_COPY_START, ATTR_COPY_END>{} ); - const SfxItemSet* pArgs = rReq.GetArgs(); + // indicate color attribute + SfxItemSet aAttr( mpDoc->GetPool() ); + mpView->GetAttributes( aAttr ); + const SfxPoolItem* pPoolItem = nullptr; - if( !pArgs ) + if( SfxItemState::SET == aAttr.GetItemState( XATTR_FILLSTYLE, true, &pPoolItem ) ) { - SfxItemSet aSet( mpViewShell->GetPool(), - svl::Items<ATTR_COPY_START, ATTR_COPY_END>{} ); + drawing::FillStyle eStyle = static_cast<const XFillStyleItem*>(pPoolItem)->GetValue(); - // indicate color attribute - SfxItemSet aAttr( mpDoc->GetPool() ); - mpView->GetAttributes( aAttr ); - const SfxPoolItem* pPoolItem = nullptr; - - if( SfxItemState::SET == aAttr.GetItemState( XATTR_FILLSTYLE, true, &pPoolItem ) ) + if( eStyle == drawing::FillStyle_SOLID && + SfxItemState::SET == aAttr.GetItemState( XATTR_FILLCOLOR, true, &pPoolItem ) ) { - drawing::FillStyle eStyle = static_cast<const XFillStyleItem*>(pPoolItem)->GetValue(); - - if( eStyle == drawing::FillStyle_SOLID && - SfxItemState::SET == aAttr.GetItemState( XATTR_FILLCOLOR, true, &pPoolItem ) ) - { - const XFillColorItem* pItem = static_cast<const XFillColorItem*>(pPoolItem); - XColorItem aXColorItem( ATTR_COPY_START_COLOR, pItem->GetName(), - pItem->GetColorValue() ); - aSet.Put( aXColorItem ); + const XFillColorItem* pItem = static_cast<const XFillColorItem*>(pPoolItem); + XColorItem aXColorItem( ATTR_COPY_START_COLOR, pItem->GetName(), + pItem->GetColorValue() ); + aSet.Put( aXColorItem ); - } } + } - SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractCopyDlg> pDlg(pFact->CreateCopyDlg(mpViewShell->GetFrameWeld(), aSet, mpView )); + SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); + ScopedVclPtr<AbstractCopyDlg> pDlg(pFact->CreateCopyDlg(mpViewShell->GetFrameWeld(), aSet, mpView )); - sal_uInt16 nResult = pDlg->Execute(); + sal_uInt16 nResult = pDlg->Execute(); - switch( nResult ) - { - case RET_OK: - pDlg->GetAttr( aSet ); - rReq.Done( aSet ); - pArgs = rReq.GetArgs(); - break; + switch( nResult ) + { + case RET_OK: + pDlg->GetAttr( aSet ); + rReq.Done( aSet ); + pArgs = rReq.GetArgs(); + break; - default: - { - pDlg.disposeAndClear(); - mpView->EndUndo(); - return; // Cancel - } + default: + { + pDlg.disposeAndClear(); + mpView->EndUndo(); + return; // Cancel } } + } - ::tools::Rectangle aRect; - sal_Int32 lWidth = 0, lHeight = 0, lSizeX = 0, lSizeY = 0, lAngle = 0; - sal_uInt16 nNumber = 0; - Color aStartColor, aEndColor; - bool bColor = false; - const SfxPoolItem* pPoolItem = nullptr; - - // Count - if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_NUMBER, true, &pPoolItem ) ) - nNumber = static_cast<const SfxUInt16Item*>( pPoolItem )->GetValue(); - - // translation - if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_MOVE_X, true, &pPoolItem ) ) - lSizeX = static_cast<const SfxInt32Item*>( pPoolItem )->GetValue(); - if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_MOVE_Y, true, &pPoolItem ) ) - lSizeY = static_cast<const SfxInt32Item*>( pPoolItem )->GetValue(); - if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_ANGLE, true, &pPoolItem ) ) - lAngle = static_cast<const SfxInt32Item*>( pPoolItem )->GetValue(); - - // scale - if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_WIDTH, true, &pPoolItem ) ) - lWidth = static_cast<const SfxInt32Item*>( pPoolItem )->GetValue(); - if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_HEIGHT, true, &pPoolItem ) ) - lHeight = static_cast<const SfxInt32Item*>( pPoolItem )->GetValue(); - - // start/end color - if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_START_COLOR, true, &pPoolItem ) ) - { - aStartColor = static_cast<const XColorItem*>( pPoolItem )->GetColorValue(); - bColor = true; - } - if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_END_COLOR, true, &pPoolItem ) ) - { - aEndColor = static_cast<const XColorItem*>( pPoolItem )->GetColorValue(); - if( aStartColor == aEndColor ) - bColor = false; - } - else + ::tools::Rectangle aRect; + sal_Int32 lWidth = 0, lHeight = 0, lSizeX = 0, lSizeY = 0, lAngle = 0; + sal_uInt16 nNumber = 0; + Color aStartColor, aEndColor; + bool bColor = false; + const SfxPoolItem* pPoolItem = nullptr; + + // Count + if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_NUMBER, true, &pPoolItem ) ) + nNumber = static_cast<const SfxUInt16Item*>( pPoolItem )->GetValue(); + + // translation + if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_MOVE_X, true, &pPoolItem ) ) + lSizeX = static_cast<const SfxInt32Item*>( pPoolItem )->GetValue(); + if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_MOVE_Y, true, &pPoolItem ) ) + lSizeY = static_cast<const SfxInt32Item*>( pPoolItem )->GetValue(); + if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_ANGLE, true, &pPoolItem ) ) + lAngle = static_cast<const SfxInt32Item*>( pPoolItem )->GetValue(); + + // scale + if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_WIDTH, true, &pPoolItem ) ) + lWidth = static_cast<const SfxInt32Item*>( pPoolItem )->GetValue(); + if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_HEIGHT, true, &pPoolItem ) ) + lHeight = static_cast<const SfxInt32Item*>( pPoolItem )->GetValue(); + + // start/end color + if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_START_COLOR, true, &pPoolItem ) ) + { + aStartColor = static_cast<const XColorItem*>( pPoolItem )->GetColorValue(); + bColor = true; + } + if( pArgs && SfxItemState::SET == pArgs->GetItemState( ATTR_COPY_END_COLOR, true, &pPoolItem ) ) + { + aEndColor = static_cast<const XColorItem*>( pPoolItem )->GetColorValue(); + if( aStartColor == aEndColor ) bColor = false; + } + else + bColor = false; - // remove handles - //HMHmpView->HideMarkHdl(); + // remove handles + //HMHmpView->HideMarkHdl(); - std::unique_ptr<SfxProgress> pProgress; - bool bWaiting = false; + std::unique_ptr<SfxProgress> pProgress; + bool bWaiting = false; - if( nNumber > 1 ) - { - OUString aStr( SdResId( STR_OBJECTS ) ); - aStr += " " + SdResId( STR_UNDO_COPYOBJECTS ); + if( nNumber > 1 ) + { + OUString aStr( SdResId( STR_OBJECTS ) ); + aStr += " " + SdResId( STR_UNDO_COPYOBJECTS ); - pProgress.reset(new SfxProgress( mpDocSh, aStr, nNumber )); - mpDocSh->SetWaitCursor( true ); - bWaiting = true; - } + pProgress.reset(new SfxProgress( mpDocSh, aStr, nNumber )); + mpDocSh->SetWaitCursor( true ); + bWaiting = true; + } - const SdrMarkList aMarkList( mpView->GetMarkedObjectList() ); - const size_t nMarkCount = aMarkList.GetMarkCount(); - SdrObject* pObj = nullptr; + const SdrMarkList aMarkList( mpView->GetMarkedObjectList() ); + const size_t nMarkCount = aMarkList.GetMarkCount(); + SdrObject* pObj = nullptr; - // calculate number of possible copies - aRect = mpView->GetAllMarkedRect(); + // calculate number of possible copies + aRect = mpView->GetAllMarkedRect(); - if( lWidth < 0 ) - { - long nTmp = ( aRect.Right() - aRect.Left() ) / -lWidth; - nNumber = static_cast<sal_uInt16>(std::min( nTmp, static_cast<long>(nNumber) )); - } + if( lWidth < 0 ) + { + long nTmp = ( aRect.Right() - aRect.Left() ) / -lWidth; + nNumber = static_cast<sal_uInt16>(std::min( nTmp, static_cast<long>(nNumber) )); + } - if( lHeight < 0 ) - { - long nTmp = ( aRect.Bottom() - aRect.Top() ) / -lHeight; - nNumber = static_cast<sal_uInt16>(std::min( nTmp, static_cast<long>(nNumber) )); - } + if( lHeight < 0 ) + { + long nTmp = ( aRect.Bottom() - aRect.Top() ) / -lHeight; + nNumber = static_cast<sal_uInt16>(std::min( nTmp, static_cast<long>(nNumber) )); + } - for( sal_uInt16 i = 1; i <= nNumber; i++ ) - { - if( pProgress ) - pProgress->SetState( i ); + for( sal_uInt16 i = 1; i <= nNumber; i++ ) + { + if( pProgress ) + pProgress->SetState( i ); - aRect = mpView->GetAllMarkedRect(); + aRect = mpView->GetAllMarkedRect(); - if( ( 1 == i ) && bColor ) - { - SfxItemSet aNewSet( mpViewShell->GetPool(), svl::Items<XATTR_FILLSTYLE, XATTR_FILLCOLOR>{} ); - aNewSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) ); - aNewSet.Put( XFillColorItem( OUString(), aStartColor ) ); - mpView->SetAttributes( aNewSet ); - } + if( ( 1 == i ) && bColor ) + { + SfxItemSet aNewSet( mpViewShell->GetPool(), svl::Items<XATTR_FILLSTYLE, XATTR_FILLCOLOR>{} ); + aNewSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) ); + aNewSet.Put( XFillColorItem( OUString(), aStartColor ) ); + mpView->SetAttributes( aNewSet ); + } - // make a copy of selected objects - mpView->CopyMarked(); + // make a copy of selected objects + mpView->CopyMarked(); - // get newly selected objects - SdrMarkList aCopyMarkList( mpView->GetMarkedObjectList() ); - const size_t nCopyMarkCount = aMarkList.GetMarkCount(); + // get newly selected objects + SdrMarkList aCopyMarkList( mpView->GetMarkedObjectList() ); + const size_t nCopyMarkCount = aMarkList.GetMarkCount(); - // set protection flags at marked copies to null - for( size_t j = 0; j < nCopyMarkCount; ++j ) - { - pObj = aCopyMarkList.GetMark( j )->GetMarkedSdrObj(); + // set protection flags at marked copies to null + for( size_t j = 0; j < nCopyMarkCount; ++j ) + { + pObj = aCopyMarkList.GetMark( j )->GetMarkedSdrObj(); - if( pObj ) - { - pObj->SetMoveProtect( false ); - pObj->SetResizeProtect( false ); - } + if( pObj ) + { + pObj->SetMoveProtect( false ); + pObj->SetResizeProtect( false ); } + } - Fraction aWidth( aRect.Right() - aRect.Left() + lWidth, aRect.Right() - aRect.Left() ); - Fraction aHeight( aRect.Bottom() - aRect.Top() + lHeight, aRect.Bottom() - aRect.Top() ); + Fraction aWidth( aRect.Right() - aRect.Left() + lWidth, aRect.Right() - aRect.Left() ); + Fraction aHeight( aRect.Bottom() - aRect.Top() + lHeight, aRect.Bottom() - aRect.Top() ); - if( mpView->IsResizeAllowed() ) - mpView->ResizeAllMarked( aRect.TopLeft(), aWidth, aHeight ); + if( mpView->IsResizeAllowed() ) + mpView->ResizeAllMarked( aRect.TopLeft(), aWidth, aHeight ); - if( mpView->IsRotateAllowed() ) - mpView->RotateAllMarked( aRect.Center(), lAngle ); + if( mpView->IsRotateAllowed() ) + mpView->RotateAllMarked( aRect.Center(), lAngle ); - if( mpView->IsMoveAllowed() ) - mpView->MoveAllMarked( Size( lSizeX, lSizeY ) ); + if( mpView->IsMoveAllowed() ) + mpView->MoveAllMarked( Size( lSizeX, lSizeY ) ); - // set protection flags at marked copies to original values - if( nMarkCount == nCopyMarkCount ) + // set protection flags at marked copies to original values + if( nMarkCount == nCopyMarkCount ) + { + for( size_t j = 0; j < nMarkCount; ++j ) { - for( size_t j = 0; j < nMarkCount; ++j ) + SdrObject* pSrcObj = aMarkList.GetMark( j )->GetMarkedSdrObj(); + SdrObject* pDstObj = aCopyMarkList.GetMark( j )->GetMarkedSdrObj(); + + if( pSrcObj && pDstObj && + ( pSrcObj->GetObjInventor() == pDstObj->GetObjInventor() ) && + ( pSrcObj->GetObjIdentifier() == pDstObj->GetObjIdentifier() ) ) { - SdrObject* pSrcObj = aMarkList.GetMark( j )->GetMarkedSdrObj(); - SdrObject* pDstObj = aCopyMarkList.GetMark( j )->GetMarkedSdrObj(); - - if( pSrcObj && pDstObj && - ( pSrcObj->GetObjInventor() == pDstObj->GetObjInventor() ) && - ( pSrcObj->GetObjIdentifier() == pDstObj->GetObjIdentifier() ) ) - { - pDstObj->SetMoveProtect( pSrcObj->IsMoveProtect() ); - pDstObj->SetResizeProtect( pSrcObj->IsResizeProtect() ); - } + pDstObj->SetMoveProtect( pSrcObj->IsMoveProtect() ); + pDstObj->SetResizeProtect( pSrcObj->IsResizeProtect() ); } } + } - if( bColor ) - { - // probably room for optimizations, but may can lead to rounding errors - sal_uInt8 nRed = aStartColor.GetRed() + static_cast<sal_uInt8>( ( static_cast<long>(aEndColor.GetRed()) - static_cast<long>(aStartColor.GetRed()) ) * static_cast<long>(i) / static_cast<long>(nNumber) ); - sal_uInt8 nGreen = aStartColor.GetGreen() + static_cast<sal_uInt8>( ( static_cast<long>(aEndColor.GetGreen()) - static_cast<long>(aStartColor.GetGreen()) ) * static_cast<long>(i) / static_cast<long>(nNumber) ); - sal_uInt8 nBlue = aStartColor.GetBlue() + static_cast<sal_uInt8>( ( static_cast<long>(aEndColor.GetBlue()) - static_cast<long>(aStartColor.GetBlue()) ) * static_cast<long>(i) / static_cast<long>(nNumber) ); - Color aNewColor( nRed, nGreen, nBlue ); - SfxItemSet aNewSet( mpViewShell->GetPool(), svl::Items<XATTR_FILLSTYLE, XATTR_FILLCOLOR>{} ); - aNewSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) ); - aNewSet.Put( XFillColorItem( OUString(), aNewColor ) ); - mpView->SetAttributes( aNewSet ); - } + if( bColor ) + { + // probably room for optimizations, but may can lead to rounding errors + sal_uInt8 nRed = aStartColor.GetRed() + static_cast<sal_uInt8>( ( static_cast<long>(aEndColor.GetRed()) - static_cast<long>(aStartColor.GetRed()) ) * static_cast<long>(i) / static_cast<long>(nNumber) ); + sal_uInt8 nGreen = aStartColor.GetGreen() + static_cast<sal_uInt8>( ( static_cast<long>(aEndColor.GetGreen()) - static_cast<long>(aStartColor.GetGreen()) ) * static_cast<long>(i) / static_cast<long>(nNumber) ); + sal_uInt8 nBlue = aStartColor.GetBlue() + static_cast<sal_uInt8>( ( static_cast<long>(aEndColor.GetBlue()) - static_cast<long>(aStartColor.GetBlue()) ) * static_cast<long>(i) / static_cast<long>(nNumber) ); + Color aNewColor( nRed, nGreen, nBlue ); + SfxItemSet aNewSet( mpViewShell->GetPool(), svl::Items<XATTR_FILLSTYLE, XATTR_FILLCOLOR>{} ); + aNewSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) ); + aNewSet.Put( XFillColorItem( OUString(), aNewColor ) ); + mpView->SetAttributes( aNewSet ); } + } - pProgress.reset(); + pProgress.reset(); - if ( bWaiting ) - mpDocSh->SetWaitCursor( false ); + if ( bWaiting ) + mpDocSh->SetWaitCursor( false ); - // show handles - mpView->AdjustMarkHdl(); //HMH sal_True ); - //HMHpView->ShowMarkHdl(); + // show handles + mpView->AdjustMarkHdl(); //HMH sal_True ); + //HMHpView->ShowMarkHdl(); - mpView->EndUndo(); - } + mpView->EndUndo(); } } // end of namespace diff --git a/sd/source/ui/func/fuexpand.cxx b/sd/source/ui/func/fuexpand.cxx index d38479ca9d80..4944caa7a055 100644 --- a/sd/source/ui/func/fuexpand.cxx +++ b/sd/source/ui/func/fuexpand.cxx @@ -87,171 +87,171 @@ void FuExpandPage::DoExecute( SfxRequest& ) i++; } - if (pActualPage) - { - SdOutliner aOutliner( mpDoc, OutlinerMode::OutlineObject ); - aOutliner.SetUpdateMode(false); - aOutliner.EnableUndo(false); + if (!pActualPage) + return; - if (mpDocSh) - aOutliner.SetRefDevice( SD_MOD()->GetVirtualRefDevice() ); + SdOutliner aOutliner( mpDoc, OutlinerMode::OutlineObject ); + aOutliner.SetUpdateMode(false); + aOutliner.EnableUndo(false); - aOutliner.SetDefTab( mpDoc->GetDefaultTabulator() ); - aOutliner.SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool())); + if (mpDocSh) + aOutliner.SetRefDevice( SD_MOD()->GetVirtualRefDevice() ); - SdrLayerIDSet aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers(); - sal_uInt16 nActualPageNum = pActualPage->GetPageNum(); - SdPage* pActualNotesPage = static_cast<SdPage*>(mpDoc->GetPage(nActualPageNum + 1)); - SdrTextObj* pActualOutline = static_cast<SdrTextObj*>(pActualPage->GetPresObj(PRESOBJ_OUTLINE)); + aOutliner.SetDefTab( mpDoc->GetDefaultTabulator() ); + aOutliner.SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool())); - if (pActualOutline) - { - const bool bUndo = mpView->IsUndoEnabled(); + SdrLayerIDSet aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers(); + sal_uInt16 nActualPageNum = pActualPage->GetPageNum(); + SdPage* pActualNotesPage = static_cast<SdPage*>(mpDoc->GetPage(nActualPageNum + 1)); + SdrTextObj* pActualOutline = static_cast<SdrTextObj*>(pActualPage->GetPresObj(PRESOBJ_OUTLINE)); - if( bUndo ) - mpView->BegUndo(SdResId(STR_UNDO_EXPAND_PAGE)); + if (pActualOutline) + { + const bool bUndo = mpView->IsUndoEnabled(); - // set current structuring-object into outliner - OutlinerParaObject* pParaObj = pActualOutline->GetOutlinerParaObject(); - aOutliner.SetText(*pParaObj); + if( bUndo ) + mpView->BegUndo(SdResId(STR_UNDO_EXPAND_PAGE)); - // remove hard paragraph- and character attributes - SfxItemSet aEmptyEEAttr(mpDoc->GetPool(), svl::Items<EE_ITEMS_START, EE_ITEMS_END>{}); - sal_Int32 nParaCount1 = aOutliner.GetParagraphCount(); + // set current structuring-object into outliner + OutlinerParaObject* pParaObj = pActualOutline->GetOutlinerParaObject(); + aOutliner.SetText(*pParaObj); - for (sal_Int32 nPara = 0; nPara < nParaCount1; nPara++) - { - aOutliner.RemoveCharAttribs(nPara); - aOutliner.SetParaAttribs(nPara, aEmptyEEAttr); - } + // remove hard paragraph- and character attributes + SfxItemSet aEmptyEEAttr(mpDoc->GetPool(), svl::Items<EE_ITEMS_START, EE_ITEMS_END>{}); + sal_Int32 nParaCount1 = aOutliner.GetParagraphCount(); - sal_uInt16 nPos = 2; - Paragraph* pPara = aOutliner.GetParagraph( 0 ); + for (sal_Int32 nPara = 0; nPara < nParaCount1; nPara++) + { + aOutliner.RemoveCharAttribs(nPara); + aOutliner.SetParaAttribs(nPara, aEmptyEEAttr); + } + + sal_uInt16 nPos = 2; + Paragraph* pPara = aOutliner.GetParagraph( 0 ); - while (pPara) + while (pPara) + { + sal_Int32 nParaPos = aOutliner.GetAbsPos( pPara ); + sal_Int16 nDepth = aOutliner.GetDepth( nParaPos ); + if ( nDepth == 0 ) { - sal_Int32 nParaPos = aOutliner.GetAbsPos( pPara ); - sal_Int16 nDepth = aOutliner.GetDepth( nParaPos ); - if ( nDepth == 0 ) + // page with title & structuring! + SdPage* pPage = mpDoc->AllocSdPage(false); + pPage->SetSize(pActualPage->GetSize() ); + pPage->SetBorder(pActualPage->GetLeftBorder(), + pActualPage->GetUpperBorder(), + pActualPage->GetRightBorder(), + pActualPage->GetLowerBorder() ); + pPage->SetName(OUString()); + + // insert page after current page + mpDoc->InsertPage(pPage, nActualPageNum + nPos); + nPos++; + + if( bUndo ) + mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pPage)); + + // use MasterPage of the current page + pPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage()); + pPage->SetLayoutName(pActualPage->GetLayoutName()); + pPage->SetAutoLayout(AUTOLAYOUT_TITLE_CONTENT, true); + pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); + + // notes-page + SdPage* pNotesPage = mpDoc->AllocSdPage(false); + pNotesPage->SetSize(pActualNotesPage->GetSize()); + pNotesPage->SetBorder(pActualNotesPage->GetLeftBorder(), + pActualNotesPage->GetUpperBorder(), + pActualNotesPage->GetRightBorder(), + pActualNotesPage->GetLowerBorder() ); + pNotesPage->SetPageKind(PageKind::Notes); + pNotesPage->SetName(OUString()); + + // insert page after current page + mpDoc->InsertPage(pNotesPage, nActualPageNum + nPos); + nPos++; + + if( bUndo ) + mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage)); + + // use MasterPage of the current page + pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage()); + pNotesPage->SetLayoutName(pActualNotesPage->GetLayoutName()); + pNotesPage->SetAutoLayout(pActualNotesPage->GetAutoLayout(), true); + pNotesPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); + + // create title text objects + SdrTextObj* pTextObj = static_cast<SdrTextObj*>(pPage->GetPresObj(PRESOBJ_TITLE)); + SAL_WARN_IF(!pTextObj, "sd.core", "worrying lack of PRESOBJ_TITLE object"); + if (!pTextObj) + continue; + + std::unique_ptr<OutlinerParaObject> pOutlinerParaObject = aOutliner.CreateParaObject( nParaPos, 1); + pOutlinerParaObject->SetOutlinerMode(OutlinerMode::TitleObject); + + if( pOutlinerParaObject->GetDepth(0) != -1 ) { - // page with title & structuring! - SdPage* pPage = mpDoc->AllocSdPage(false); - pPage->SetSize(pActualPage->GetSize() ); - pPage->SetBorder(pActualPage->GetLeftBorder(), - pActualPage->GetUpperBorder(), - pActualPage->GetRightBorder(), - pActualPage->GetLowerBorder() ); - pPage->SetName(OUString()); - - // insert page after current page - mpDoc->InsertPage(pPage, nActualPageNum + nPos); - nPos++; - - if( bUndo ) - mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pPage)); - - // use MasterPage of the current page - pPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage()); - pPage->SetLayoutName(pActualPage->GetLayoutName()); - pPage->SetAutoLayout(AUTOLAYOUT_TITLE_CONTENT, true); - pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); - - // notes-page - SdPage* pNotesPage = mpDoc->AllocSdPage(false); - pNotesPage->SetSize(pActualNotesPage->GetSize()); - pNotesPage->SetBorder(pActualNotesPage->GetLeftBorder(), - pActualNotesPage->GetUpperBorder(), - pActualNotesPage->GetRightBorder(), - pActualNotesPage->GetLowerBorder() ); - pNotesPage->SetPageKind(PageKind::Notes); - pNotesPage->SetName(OUString()); - - // insert page after current page - mpDoc->InsertPage(pNotesPage, nActualPageNum + nPos); - nPos++; - - if( bUndo ) - mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage)); - - // use MasterPage of the current page - pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage()); - pNotesPage->SetLayoutName(pActualNotesPage->GetLayoutName()); - pNotesPage->SetAutoLayout(pActualNotesPage->GetAutoLayout(), true); - pNotesPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); - - // create title text objects - SdrTextObj* pTextObj = static_cast<SdrTextObj*>(pPage->GetPresObj(PRESOBJ_TITLE)); - SAL_WARN_IF(!pTextObj, "sd.core", "worrying lack of PRESOBJ_TITLE object"); - if (!pTextObj) - continue; - - std::unique_ptr<OutlinerParaObject> pOutlinerParaObject = aOutliner.CreateParaObject( nParaPos, 1); - pOutlinerParaObject->SetOutlinerMode(OutlinerMode::TitleObject); - - if( pOutlinerParaObject->GetDepth(0) != -1 ) - { - std::unique_ptr<SdrOutliner> pTempOutl = SdrMakeOutliner(OutlinerMode::TitleObject, *mpDoc); + std::unique_ptr<SdrOutliner> pTempOutl = SdrMakeOutliner(OutlinerMode::TitleObject, *mpDoc); - pTempOutl->SetText( *pOutlinerParaObject ); + pTempOutl->SetText( *pOutlinerParaObject ); - pOutlinerParaObject.reset(); + pOutlinerParaObject.reset(); - pTempOutl->SetDepth( pTempOutl->GetParagraph( 0 ), -1 ); + pTempOutl->SetDepth( pTempOutl->GetParagraph( 0 ), -1 ); - pOutlinerParaObject = pTempOutl->CreateParaObject(); - } + pOutlinerParaObject = pTempOutl->CreateParaObject(); + } + + pTextObj->SetOutlinerParaObject(std::move(pOutlinerParaObject)); - pTextObj->SetOutlinerParaObject(std::move(pOutlinerParaObject)); + pTextObj->SetEmptyPresObj(false); - pTextObj->SetEmptyPresObj(false); + SfxStyleSheet* pSheet = pPage->GetStyleSheetForPresObj(PRESOBJ_TITLE); + pTextObj->NbcSetStyleSheet(pSheet, false); + + SdrTextObj* pOutlineObj = nullptr; + sal_Int32 nChildCount = aOutliner.GetChildCount(pPara); + if (nChildCount > 0) + pOutlineObj = static_cast<SdrTextObj*>( pPage->GetPresObj(PRESOBJ_OUTLINE) ); + if (pOutlineObj) + { + // create structuring text objects + std::unique_ptr<OutlinerParaObject> pOPO = aOutliner.CreateParaObject(++nParaPos, nChildCount); - SfxStyleSheet* pSheet = pPage->GetStyleSheetForPresObj(PRESOBJ_TITLE); - pTextObj->NbcSetStyleSheet(pSheet, false); + std::unique_ptr<SdrOutliner> pTempOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc); + pTempOutl->SetText( *pOPO ); - SdrTextObj* pOutlineObj = nullptr; - sal_Int32 nChildCount = aOutliner.GetChildCount(pPara); - if (nChildCount > 0) - pOutlineObj = static_cast<SdrTextObj*>( pPage->GetPresObj(PRESOBJ_OUTLINE) ); - if (pOutlineObj) + sal_Int32 nParaCount2 = pTempOutl->GetParagraphCount(); + sal_Int32 nPara; + for( nPara = 0; nPara < nParaCount2; nPara++ ) { - // create structuring text objects - std::unique_ptr<OutlinerParaObject> pOPO = aOutliner.CreateParaObject(++nParaPos, nChildCount); - - std::unique_ptr<SdrOutliner> pTempOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc); - pTempOutl->SetText( *pOPO ); - - sal_Int32 nParaCount2 = pTempOutl->GetParagraphCount(); - sal_Int32 nPara; - for( nPara = 0; nPara < nParaCount2; nPara++ ) - { - pTempOutl->SetDepth ( - pTempOutl->GetParagraph( nPara ), - pTempOutl->GetDepth( nPara ) - 1); - } - - pOPO = pTempOutl->CreateParaObject(); - pTempOutl.reset(); - - pOutlineObj->SetOutlinerParaObject( std::move(pOPO) ); - pOutlineObj->SetEmptyPresObj(false); - - // remove hard attributes (Flag to sal_True) - SfxItemSet aAttr(mpDoc->GetPool()); - aAttr.Put(XLineStyleItem(drawing::LineStyle_NONE)); - aAttr.Put(XFillStyleItem(drawing::FillStyle_NONE)); - pOutlineObj->SetMergedItemSet(aAttr); + pTempOutl->SetDepth ( + pTempOutl->GetParagraph( nPara ), + pTempOutl->GetDepth( nPara ) - 1); } - } - pPara = aOutliner.GetParagraph( ++nParaPos ); + pOPO = pTempOutl->CreateParaObject(); + pTempOutl.reset(); + + pOutlineObj->SetOutlinerParaObject( std::move(pOPO) ); + pOutlineObj->SetEmptyPresObj(false); + + // remove hard attributes (Flag to sal_True) + SfxItemSet aAttr(mpDoc->GetPool()); + aAttr.Put(XLineStyleItem(drawing::LineStyle_NONE)); + aAttr.Put(XFillStyleItem(drawing::FillStyle_NONE)); + pOutlineObj->SetMergedItemSet(aAttr); + } } - if( bUndo ) - mpView->EndUndo(); + pPara = aOutliner.GetParagraph( ++nParaPos ); } - mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_DELETE_PAGE, SfxCallMode::SYNCHRON | SfxCallMode::RECORD); + if( bUndo ) + mpView->EndUndo(); } + + mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_DELETE_PAGE, SfxCallMode::SYNCHRON | SfxCallMode::RECORD); } } // end of namespace sd diff --git a/sd/source/ui/func/fuformatpaintbrush.cxx b/sd/source/ui/func/fuformatpaintbrush.cxx index 3af7592c1fbb..4c018171b4ec 100644 --- a/sd/source/ui/func/fuformatpaintbrush.cxx +++ b/sd/source/ui/func/fuformatpaintbrush.cxx @@ -239,30 +239,30 @@ bool FuFormatPaintBrush::HasContentForThisType( SdrInventor nObjectInventor, sal void FuFormatPaintBrush::Paste( bool bNoCharacterFormats, bool bNoParagraphFormats ) { const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); - if( mxItemSet.get() && ( rMarkList.GetMarkCount() == 1 ) ) - { - SdrObject* pObj( nullptr ); - bool bUndo = mpDoc->IsUndoEnabled(); + if( !(mxItemSet.get() && ( rMarkList.GetMarkCount() == 1 )) ) + return; - if( bUndo && !mpView->GetTextEditOutlinerView() ) - pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + SdrObject* pObj( nullptr ); + bool bUndo = mpDoc->IsUndoEnabled(); - // n685123: ApplyFormatPaintBrush itself would store undo information - // except in a few cases (?) - if( pObj ) - { - OUString sLabel( mpViewShell->GetViewShellBase().RetrieveLabelFromCommand(".uno:FormatPaintbrush" ) ); - mpDoc->BegUndo( sLabel ); - if (dynamic_cast< sdr::table::SdrTableObj* >( pObj ) == nullptr) - mpDoc->AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoAttrObject( *pObj, false, true ) ); - } + if( bUndo && !mpView->GetTextEditOutlinerView() ) + pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - mpView->ApplyFormatPaintBrush( *mxItemSet, bNoCharacterFormats, bNoParagraphFormats ); + // n685123: ApplyFormatPaintBrush itself would store undo information + // except in a few cases (?) + if( pObj ) + { + OUString sLabel( mpViewShell->GetViewShellBase().RetrieveLabelFromCommand(".uno:FormatPaintbrush" ) ); + mpDoc->BegUndo( sLabel ); + if (dynamic_cast< sdr::table::SdrTableObj* >( pObj ) == nullptr) + mpDoc->AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoAttrObject( *pObj, false, true ) ); + } - if( pObj ) - { - mpDoc->EndUndo(); - } + mpView->ApplyFormatPaintBrush( *mxItemSet, bNoCharacterFormats, bNoParagraphFormats ); + + if( pObj ) + { + mpDoc->EndUndo(); } } diff --git a/sd/source/ui/func/fuhhconv.cxx b/sd/source/ui/func/fuhhconv.cxx index 8323c548f623..76ef9eba7b92 100644 --- a/sd/source/ui/func/fuhhconv.cxx +++ b/sd/source/ui/func/fuhhconv.cxx @@ -191,67 +191,67 @@ void FuHangulHanjaConversion::StartChineseConversion() //open ChineseTranslationDialog Reference< XComponentContext > xContext( ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one - if(xContext.is()) + if(!xContext.is()) + return; + + Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); + if(!xMCF.is()) + return; + + Reference< ui::dialogs::XExecutableDialog > xDialog( + xMCF->createInstanceWithContext("com.sun.star.linguistic2.ChineseTranslationDialog" + , xContext), UNO_QUERY); + Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY ); + if( xInit.is() ) { - Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); - if(xMCF.is()) + // initialize dialog + Reference< awt::XWindow > xDialogParentWindow; + Sequence<Any> aSeq(comphelper::InitAnyPropertySequence( + { + {"ParentWindow", uno::Any(xDialogParentWindow)} + })); + xInit->initialize( aSeq ); + + //execute dialog + sal_Int16 nDialogRet = xDialog->execute(); + if( RET_OK == nDialogRet ) { - Reference< ui::dialogs::XExecutableDialog > xDialog( - xMCF->createInstanceWithContext("com.sun.star.linguistic2.ChineseTranslationDialog" - , xContext), UNO_QUERY); - Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY ); - if( xInit.is() ) + //get some parameters from the dialog + bool bToSimplified = true; + bool bUseVariants = true; + bool bCommonTerms = true; + Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY ); + if( xProp.is() ) { - // initialize dialog - Reference< awt::XWindow > xDialogParentWindow; - Sequence<Any> aSeq(comphelper::InitAnyPropertySequence( + try { - {"ParentWindow", uno::Any(xDialogParentWindow)} - })); - xInit->initialize( aSeq ); - - //execute dialog - sal_Int16 nDialogRet = xDialog->execute(); - if( RET_OK == nDialogRet ) + xProp->getPropertyValue( "IsDirectionToSimplified" ) >>= bToSimplified; + xProp->getPropertyValue( "IsUseCharacterVariants" ) >>= bUseVariants; + xProp->getPropertyValue( "IsTranslateCommonTerms" ) >>= bCommonTerms; + } + catch( Exception& ) { - //get some parameters from the dialog - bool bToSimplified = true; - bool bUseVariants = true; - bool bCommonTerms = true; - Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY ); - if( xProp.is() ) - { - try - { - xProp->getPropertyValue( "IsDirectionToSimplified" ) >>= bToSimplified; - xProp->getPropertyValue( "IsUseCharacterVariants" ) >>= bUseVariants; - xProp->getPropertyValue( "IsTranslateCommonTerms" ) >>= bCommonTerms; - } - catch( Exception& ) - { - } - } - - //execute translation - LanguageType nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED; - LanguageType nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL; - sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0; - if( !bCommonTerms ) - nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER; - - vcl::Font aTargetFont = OutputDevice::GetDefaultFont( - DefaultFontType::CJK_PRESENTATION, - nTargetLang, GetDefaultFontFlags::OnlyOne ); - - StartConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, false ); - ConvertStyles( nTargetLang, &aTargetFont ); } } - Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY ); - if( xComponent.is() ) - xComponent->dispose(); + + //execute translation + LanguageType nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED; + LanguageType nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL; + sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0; + if( !bCommonTerms ) + nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER; + + vcl::Font aTargetFont = OutputDevice::GetDefaultFont( + DefaultFontType::CJK_PRESENTATION, + nTargetLang, GetDefaultFontFlags::OnlyOne ); + + StartConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, false ); + ConvertStyles( nTargetLang, &aTargetFont ); } } + Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY ); + if( xComponent.is() ) + xComponent->dispose(); } } // end of namespace diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx index ba2c64ae2856..847bc39a3858 100644 --- a/sd/source/ui/func/fuinsert.cxx +++ b/sd/source/ui/func/fuinsert.cxx @@ -247,32 +247,32 @@ void FuInsertClipboard::DoExecute( SfxRequest& ) //TODO/MBA: testing nFormatId = pDlg->GetFormat( aDataHelper ); - if( nFormatId != SotClipboardFormatId::NONE && aDataHelper.GetTransferable().is() ) + if( nFormatId == SotClipboardFormatId::NONE || !aDataHelper.GetTransferable().is() ) + return; + + sal_Int8 nAction = DND_ACTION_COPY; + DrawViewShell* pDrViewSh = nullptr; + + if (!mpView->InsertData( aDataHelper, + mpWindow->PixelToLogic( ::tools::Rectangle( Point(), mpWindow->GetOutputSizePixel() ).Center() ), + nAction, false, nFormatId )) { - sal_Int8 nAction = DND_ACTION_COPY; - DrawViewShell* pDrViewSh = nullptr; + pDrViewSh = dynamic_cast<DrawViewShell*>(mpViewShell); + } - if (!mpView->InsertData( aDataHelper, - mpWindow->PixelToLogic( ::tools::Rectangle( Point(), mpWindow->GetOutputSizePixel() ).Center() ), - nAction, false, nFormatId )) - { - pDrViewSh = dynamic_cast<DrawViewShell*>(mpViewShell); - } + if (!pDrViewSh) + return; - if (pDrViewSh) - { - INetBookmark aINetBookmark( "", "" ); - - if( ( aDataHelper.HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) && - aDataHelper.GetINetBookmark( SotClipboardFormatId::NETSCAPE_BOOKMARK, aINetBookmark ) ) || - ( aDataHelper.HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR ) && - aDataHelper.GetINetBookmark( SotClipboardFormatId::FILEGRPDESCRIPTOR, aINetBookmark ) ) || - ( aDataHelper.HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) && - aDataHelper.GetINetBookmark( SotClipboardFormatId::UNIFORMRESOURCELOCATOR, aINetBookmark ) ) ) - { - pDrViewSh->InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), "" ); - } - } + INetBookmark aINetBookmark( "", "" ); + + if( ( aDataHelper.HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) && + aDataHelper.GetINetBookmark( SotClipboardFormatId::NETSCAPE_BOOKMARK, aINetBookmark ) ) || + ( aDataHelper.HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR ) && + aDataHelper.GetINetBookmark( SotClipboardFormatId::FILEGRPDESCRIPTOR, aINetBookmark ) ) || + ( aDataHelper.HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) && + aDataHelper.GetINetBookmark( SotClipboardFormatId::UNIFORMRESOURCELOCATOR, aINetBookmark ) ) ) + { + pDrViewSh->InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), "" ); } } @@ -698,61 +698,61 @@ void FuInsertAVMedia::DoExecute( SfxRequest& rReq ) } bool bLink(true); - if (bAPI + if (!(bAPI #if HAVE_FEATURE_AVMEDIA - || ::avmedia::MediaWindow::executeMediaURLDialog(mpWindow ? mpWindow->GetFrameWeld() : nullptr, aURL, & bLink) + || ::avmedia::MediaWindow::executeMediaURLDialog(mpWindow ? mpWindow->GetFrameWeld() : nullptr, aURL, & bLink)) #endif ) - { - Size aPrefSize; + return; - if( mpWindow ) - mpWindow->EnterWait(); + Size aPrefSize; + + if( mpWindow ) + mpWindow->EnterWait(); #if HAVE_FEATURE_AVMEDIA - if( !::avmedia::MediaWindow::isMediaURL( aURL, "", true, &aPrefSize ) ) + if( !::avmedia::MediaWindow::isMediaURL( aURL, "", true, &aPrefSize ) ) + { + if( mpWindow ) + mpWindow->LeaveWait(); + + if( !bAPI ) + ::avmedia::MediaWindow::executeFormatErrorBox(mpWindow->GetFrameWeld()); + } + else + { + Point aPos; + Size aSize; + sal_Int8 nAction = DND_ACTION_COPY; + + if( aPrefSize.Width() && aPrefSize.Height() ) { if( mpWindow ) - mpWindow->LeaveWait(); - - if( !bAPI ) - ::avmedia::MediaWindow::executeFormatErrorBox(mpWindow->GetFrameWeld()); + aSize = mpWindow->PixelToLogic(aPrefSize, MapMode(MapUnit::Map100thMM)); + else + aSize = Application::GetDefaultDevice()->PixelToLogic(aPrefSize, MapMode(MapUnit::Map100thMM)); } else - { - Point aPos; - Size aSize; - sal_Int8 nAction = DND_ACTION_COPY; + aSize = Size( 5000, 5000 ); - if( aPrefSize.Width() && aPrefSize.Height() ) - { - if( mpWindow ) - aSize = mpWindow->PixelToLogic(aPrefSize, MapMode(MapUnit::Map100thMM)); - else - aSize = Application::GetDefaultDevice()->PixelToLogic(aPrefSize, MapMode(MapUnit::Map100thMM)); - } - else - aSize = Size( 5000, 5000 ); - - if( mpWindow ) - { - aPos = mpWindow->PixelToLogic( ::tools::Rectangle( aPos, mpWindow->GetOutputSizePixel() ).Center() ); - aPos.AdjustX( -(aSize.Width() >> 1) ); - aPos.AdjustY( -(aSize.Height() >> 1) ); - } + if( mpWindow ) + { + aPos = mpWindow->PixelToLogic( ::tools::Rectangle( aPos, mpWindow->GetOutputSizePixel() ).Center() ); + aPos.AdjustX( -(aSize.Width() >> 1) ); + aPos.AdjustY( -(aSize.Height() >> 1) ); + } - mpView->InsertMediaURL( aURL, nAction, aPos, aSize, bLink ) ; + mpView->InsertMediaURL( aURL, nAction, aPos, aSize, bLink ) ; - if( mpWindow ) - mpWindow->LeaveWait(); - } -#else if( mpWindow ) mpWindow->LeaveWait(); - (void) aPrefSize; - (void) bLink; -#endif } +#else + if( mpWindow ) + mpWindow->LeaveWait(); + (void) aPrefSize; + (void) bLink; +#endif } } // end of namespace sd diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx index 56e1ef51ad9c..2beb768db539 100644 --- a/sd/source/ui/func/fuinsfil.cxx +++ b/sd/source/ui/func/fuinsfil.cxx @@ -412,124 +412,124 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium) sal_uInt16 nRet = pDlg->Execute(); mpDocSh->SetWaitCursor( true ); - if( nRet == RET_OK ) - { - // selected file format: text, RTF or HTML (default is text) - EETextFormat nFormat = EETextFormat::Text; + if( nRet != RET_OK ) + return; + + // selected file format: text, RTF or HTML (default is text) + EETextFormat nFormat = EETextFormat::Text; - if( aFilterName.indexOf( "Rich") != -1 ) - nFormat = EETextFormat::Rtf; - else if( aFilterName.indexOf( "HTML" ) != -1 ) - nFormat = EETextFormat::Html; + if( aFilterName.indexOf( "Rich") != -1 ) + nFormat = EETextFormat::Rtf; + else if( aFilterName.indexOf( "HTML" ) != -1 ) + nFormat = EETextFormat::Html; - /* create our own outline since: - - it is possible that the document outliner is actually used in the - structuring mode - - the draw outliner of the drawing engine has to draw something in - between - - the global outliner could be used in SdPage::CreatePresObj */ - std::unique_ptr<SdrOutliner> pOutliner(new SdOutliner( mpDoc, OutlinerMode::TextObject )); + /* create our own outline since: + - it is possible that the document outliner is actually used in the + structuring mode + - the draw outliner of the drawing engine has to draw something in + between + - the global outliner could be used in SdPage::CreatePresObj */ + std::unique_ptr<SdrOutliner> pOutliner(new SdOutliner( mpDoc, OutlinerMode::TextObject )); - // set reference device - pOutliner->SetRefDevice( SD_MOD()->GetVirtualRefDevice() ); + // set reference device + pOutliner->SetRefDevice( SD_MOD()->GetVirtualRefDevice() ); - SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage(); - aLayoutName = pPage->GetLayoutName(); - sal_Int32 nIndex = aLayoutName.indexOf(SD_LT_SEPARATOR); - if( nIndex != -1 ) - aLayoutName = aLayoutName.copy(0, nIndex); + SdPage* pPage = static_cast<DrawViewShell*>(mpViewShell)->GetActualPage(); + aLayoutName = pPage->GetLayoutName(); + sal_Int32 nIndex = aLayoutName.indexOf(SD_LT_SEPARATOR); + if( nIndex != -1 ) + aLayoutName = aLayoutName.copy(0, nIndex); - pOutliner->SetPaperSize(pPage->GetSize()); + pOutliner->SetPaperSize(pPage->GetSize()); - SvStream* pStream = pMedium->GetInStream(); - assert(pStream && "No InStream!"); - pStream->Seek( 0 ); + SvStream* pStream = pMedium->GetInStream(); + assert(pStream && "No InStream!"); + pStream->Seek( 0 ); - ErrCode nErr = pOutliner->Read( *pStream, pMedium->GetBaseURL(), nFormat, mpDocSh->GetHeaderAttributes() ); + ErrCode nErr = pOutliner->Read( *pStream, pMedium->GetBaseURL(), nFormat, mpDocSh->GetHeaderAttributes() ); - if (nErr || pOutliner->GetEditEngine().GetText().isEmpty()) + if (nErr || pOutliner->GetEditEngine().GetText().isEmpty()) + { + std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(mpWindow->GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, SdResId(STR_READ_DATA_ERROR))); + xErrorBox->run(); + } + else + { + // is it a master page? + if (static_cast<DrawViewShell*>(mpViewShell)->GetEditMode() == EditMode::MasterPage && + !pPage->IsMasterPage()) { - std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(mpWindow->GetFrameWeld(), - VclMessageType::Warning, VclButtonsType::Ok, SdResId(STR_READ_DATA_ERROR))); - xErrorBox->run(); + pPage = static_cast<SdPage*>(&(pPage->TRG_GetMasterPage())); } - else - { - // is it a master page? - if (static_cast<DrawViewShell*>(mpViewShell)->GetEditMode() == EditMode::MasterPage && - !pPage->IsMasterPage()) - { - pPage = static_cast<SdPage*>(&(pPage->TRG_GetMasterPage())); - } - assert(pPage && "page not found"); + assert(pPage && "page not found"); - // if editing is going on right now, let it flow into this text object - OutlinerView* pOutlinerView = mpView->GetTextEditOutlinerView(); - if( pOutlinerView ) + // if editing is going on right now, let it flow into this text object + OutlinerView* pOutlinerView = mpView->GetTextEditOutlinerView(); + if( pOutlinerView ) + { + SdrObject* pObj = mpView->GetTextEditObject(); + if( pObj && + pObj->GetObjInventor() == SdrInventor::Default && + pObj->GetObjIdentifier() == OBJ_TITLETEXT && + pOutliner->GetParagraphCount() > 1 ) { - SdrObject* pObj = mpView->GetTextEditObject(); - if( pObj && - pObj->GetObjInventor() == SdrInventor::Default && - pObj->GetObjIdentifier() == OBJ_TITLETEXT && - pOutliner->GetParagraphCount() > 1 ) + // in title objects, only one paragraph is allowed + while ( pOutliner->GetParagraphCount() > 1 ) { - // in title objects, only one paragraph is allowed - while ( pOutliner->GetParagraphCount() > 1 ) - { - Paragraph* pPara = pOutliner->GetParagraph( 0 ); - sal_uLong nLen = pOutliner->GetText( pPara ).getLength(); - pOutliner->QuickDelete( ESelection( 0, nLen, 1, 0 ) ); - pOutliner->QuickInsertLineBreak( ESelection( 0, nLen, 0, nLen ) ); - } + Paragraph* pPara = pOutliner->GetParagraph( 0 ); + sal_uLong nLen = pOutliner->GetText( pPara ).getLength(); + pOutliner->QuickDelete( ESelection( 0, nLen, 1, 0 ) ); + pOutliner->QuickInsertLineBreak( ESelection( 0, nLen, 0, nLen ) ); } } + } - std::unique_ptr<OutlinerParaObject> pOPO = pOutliner->CreateParaObject(); + std::unique_ptr<OutlinerParaObject> pOPO = pOutliner->CreateParaObject(); - if (pOutlinerView) + if (pOutlinerView) + { + pOutlinerView->InsertText(*pOPO); + } + else + { + SdrRectObj* pTO = new SdrRectObj( + mpView->getSdrModelFromSdrView(), + OBJ_TEXT); + pTO->SetOutlinerParaObject(std::move(pOPO)); + + const bool bUndo = mpView->IsUndoEnabled(); + if( bUndo ) + mpView->BegUndo(SdResId(STR_UNDO_INSERT_TEXTFRAME)); + pPage->InsertObject(pTO); + + /* can be bigger as the maximal allowed size: + limit object size if necessary */ + Size aSize(pOutliner->CalcTextSize()); + Size aMaxSize = mpDoc->GetMaxObjSize(); + aSize.setHeight( std::min(aSize.Height(), aMaxSize.Height()) ); + aSize.setWidth( std::min(aSize.Width(), aMaxSize.Width()) ); + aSize = mpWindow->LogicToPixel(aSize); + + // put it at the center of the window + Size aTemp(mpWindow->GetOutputSizePixel()); + Point aPos(aTemp.Width() / 2, aTemp.Height() / 2); + aPos.AdjustX( -(aSize.Width() / 2) ); + aPos.AdjustY( -(aSize.Height() / 2) ); + aSize = mpWindow->PixelToLogic(aSize); + aPos = mpWindow->PixelToLogic(aPos); + pTO->SetLogicRect(::tools::Rectangle(aPos, aSize)); + + if (pDlg->IsLink()) { - pOutlinerView->InsertText(*pOPO); + pTO->SetTextLink(aFile, aFilterName ); } - else - { - SdrRectObj* pTO = new SdrRectObj( - mpView->getSdrModelFromSdrView(), - OBJ_TEXT); - pTO->SetOutlinerParaObject(std::move(pOPO)); - - const bool bUndo = mpView->IsUndoEnabled(); - if( bUndo ) - mpView->BegUndo(SdResId(STR_UNDO_INSERT_TEXTFRAME)); - pPage->InsertObject(pTO); - - /* can be bigger as the maximal allowed size: - limit object size if necessary */ - Size aSize(pOutliner->CalcTextSize()); - Size aMaxSize = mpDoc->GetMaxObjSize(); - aSize.setHeight( std::min(aSize.Height(), aMaxSize.Height()) ); - aSize.setWidth( std::min(aSize.Width(), aMaxSize.Width()) ); - aSize = mpWindow->LogicToPixel(aSize); - - // put it at the center of the window - Size aTemp(mpWindow->GetOutputSizePixel()); - Point aPos(aTemp.Width() / 2, aTemp.Height() / 2); - aPos.AdjustX( -(aSize.Width() / 2) ); - aPos.AdjustY( -(aSize.Height() / 2) ); - aSize = mpWindow->PixelToLogic(aSize); - aPos = mpWindow->PixelToLogic(aPos); - pTO->SetLogicRect(::tools::Rectangle(aPos, aSize)); - - if (pDlg->IsLink()) - { - pTO->SetTextLink(aFile, aFilterName ); - } - if( bUndo ) - { - mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoInsertObject(*pTO)); - mpView->EndUndo(); - } + if( bUndo ) + { + mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoInsertObject(*pTO)); + mpView->EndUndo(); } } } diff --git a/sd/source/ui/func/fulinend.cxx b/sd/source/ui/func/fulinend.cxx index 963cb05be7c7..81d3ca189ebf 100644 --- a/sd/source/ui/func/fulinend.cxx +++ b/sd/source/ui/func/fulinend.cxx @@ -55,90 +55,90 @@ void FuLineEnd::DoExecute( SfxRequest& ) { const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); - if( rMarkList.GetMarkCount() == 1 ) - { - const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - const SdrObject* pNewObj; - SdrObject* pConvPolyObj = nullptr; + if( rMarkList.GetMarkCount() != 1 ) + return; - if( dynamic_cast< const SdrPathObj *>( pObj ) != nullptr ) - { - pNewObj = pObj; - } - else + const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + const SdrObject* pNewObj; + SdrObject* pConvPolyObj = nullptr; + + if( dynamic_cast< const SdrPathObj *>( pObj ) != nullptr ) + { + pNewObj = pObj; + } + else + { + SdrObjTransformInfoRec aInfoRec; + pObj->TakeObjInfo( aInfoRec ); + + if( aInfoRec.bCanConvToPath && + pObj->GetObjInventor() == SdrInventor::Default && + pObj->GetObjIdentifier() != OBJ_GRUP ) + // bCanConvToPath is sal_True for group objects, + // but it crashes on ConvertToPathObj()! { - SdrObjTransformInfoRec aInfoRec; - pObj->TakeObjInfo( aInfoRec ); - - if( aInfoRec.bCanConvToPath && - pObj->GetObjInventor() == SdrInventor::Default && - pObj->GetObjIdentifier() != OBJ_GRUP ) - // bCanConvToPath is sal_True for group objects, - // but it crashes on ConvertToPathObj()! - { - pNewObj = pConvPolyObj = pObj->ConvertToPolyObj( true, false ); - - if( !pNewObj || dynamic_cast< const SdrPathObj *>( pNewObj ) == nullptr ) - return; // Cancel, additional security, but it does not help - // for group objects - } - else return; // Cancel + pNewObj = pConvPolyObj = pObj->ConvertToPolyObj( true, false ); + + if( !pNewObj || dynamic_cast< const SdrPathObj *>( pNewObj ) == nullptr ) + return; // Cancel, additional security, but it does not help + // for group objects } + else return; // Cancel + } - const ::basegfx::B2DPolyPolygon aPolyPolygon = static_cast<const SdrPathObj*>(pNewObj)->GetPathPoly(); + const ::basegfx::B2DPolyPolygon aPolyPolygon = static_cast<const SdrPathObj*>(pNewObj)->GetPathPoly(); - // Delete the created poly-object - SdrObject::Free( pConvPolyObj ); + // Delete the created poly-object + SdrObject::Free( pConvPolyObj ); - XLineEndListRef pLineEndList = mpDoc->GetLineEndList(); + XLineEndListRef pLineEndList = mpDoc->GetLineEndList(); - OUString aNewName( SdResId( STR_LINEEND ) ); - OUString aDesc( SdResId( STR_DESC_LINEEND ) ); - OUString aName; + OUString aNewName( SdResId( STR_LINEEND ) ); + OUString aDesc( SdResId( STR_DESC_LINEEND ) ); + OUString aName; - long nCount = pLineEndList->Count(); - long j = 1; - bool bDifferent = false; + long nCount = pLineEndList->Count(); + long j = 1; + bool bDifferent = false; - while( !bDifferent ) + while( !bDifferent ) + { + aName = aNewName + " " + OUString::number(j++); + bDifferent = true; + for( long i = 0; i < nCount && bDifferent; i++ ) { - aName = aNewName + " " + OUString::number(j++); - bDifferent = true; - for( long i = 0; i < nCount && bDifferent; i++ ) - { - if( aName == pLineEndList->GetLineEnd( i )->GetName() ) - bDifferent = false; - } + if( aName == pLineEndList->GetLineEnd( i )->GetName() ) + bDifferent = false; } + } - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSvxNameDialog> pDlg( pFact->CreateSvxNameDialog( nullptr, aName, aDesc ) ); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr<AbstractSvxNameDialog> pDlg( pFact->CreateSvxNameDialog( nullptr, aName, aDesc ) ); - pDlg->SetEditHelpId( HID_SD_NAMEDIALOG_LINEEND ); + pDlg->SetEditHelpId( HID_SD_NAMEDIALOG_LINEEND ); - if( pDlg->Execute() == RET_OK ) - { - pDlg->GetName( aName ); - bDifferent = true; - - for( long i = 0; i < nCount && bDifferent; i++ ) - { - if( aName == pLineEndList->GetLineEnd( i )->GetName() ) - bDifferent = false; - } - - if( bDifferent ) - { - pLineEndList->Insert(std::make_unique<XLineEndEntry>(aPolyPolygon, aName)); - } - else - { - std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(mpWindow ? mpWindow->GetFrameWeld() : nullptr, - VclMessageType::Warning, VclButtonsType::Ok, - SdResId(STR_WARN_NAME_DUPLICATE))); - xWarn->run(); - } - } + if( pDlg->Execute() != RET_OK ) + return; + + pDlg->GetName( aName ); + bDifferent = true; + + for( long i = 0; i < nCount && bDifferent; i++ ) + { + if( aName == pLineEndList->GetLineEnd( i )->GetName() ) + bDifferent = false; + } + + if( bDifferent ) + { + pLineEndList->Insert(std::make_unique<XLineEndEntry>(aPolyPolygon, aName)); + } + else + { + std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(mpWindow ? mpWindow->GetFrameWeld() : nullptr, + VclMessageType::Warning, VclButtonsType::Ok, + SdResId(STR_WARN_NAME_DUPLICATE))); + xWarn->run(); } } diff --git a/sd/source/ui/func/fumorph.cxx b/sd/source/ui/func/fumorph.cxx index e4a153d08160..09ad824f9a7a 100644 --- a/sd/source/ui/func/fumorph.cxx +++ b/sd/source/ui/func/fumorph.cxx @@ -77,106 +77,106 @@ void FuMorph::DoExecute( SfxRequest& ) { const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); - if(rMarkList.GetMarkCount() == 2) + if(rMarkList.GetMarkCount() != 2) + return; + + // create clones + SdrObject* pObj1 = rMarkList.GetMark(0)->GetMarkedSdrObj(); + SdrObject* pObj2 = rMarkList.GetMark(1)->GetMarkedSdrObj(); + SdrObject* pCloneObj1(pObj1->CloneSdrObject(pObj1->getSdrModelFromSdrObject())); + SdrObject* pCloneObj2(pObj2->CloneSdrObject(pObj2->getSdrModelFromSdrObject())); + + // delete text at clone, otherwise we do net get a correct PathObj + pCloneObj1->SetOutlinerParaObject(nullptr); + pCloneObj2->SetOutlinerParaObject(nullptr); + + // create path objects + SdrObject* pPolyObj1 = pCloneObj1->ConvertToPolyObj(false, false); + SdrObject* pPolyObj2 = pCloneObj2->ConvertToPolyObj(false, false); + SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); + ScopedVclPtr<AbstractMorphDlg> pDlg( pFact->CreateMorphDlg(mpWindow ? mpWindow->GetFrameWeld() : nullptr, pObj1, pObj2) ); + if(pPolyObj1 && pPolyObj2 && (pDlg->Execute() == RET_OK)) { - // create clones - SdrObject* pObj1 = rMarkList.GetMark(0)->GetMarkedSdrObj(); - SdrObject* pObj2 = rMarkList.GetMark(1)->GetMarkedSdrObj(); - SdrObject* pCloneObj1(pObj1->CloneSdrObject(pObj1->getSdrModelFromSdrObject())); - SdrObject* pCloneObj2(pObj2->CloneSdrObject(pObj2->getSdrModelFromSdrObject())); - - // delete text at clone, otherwise we do net get a correct PathObj - pCloneObj1->SetOutlinerParaObject(nullptr); - pCloneObj2->SetOutlinerParaObject(nullptr); - - // create path objects - SdrObject* pPolyObj1 = pCloneObj1->ConvertToPolyObj(false, false); - SdrObject* pPolyObj2 = pCloneObj2->ConvertToPolyObj(false, false); - SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractMorphDlg> pDlg( pFact->CreateMorphDlg(mpWindow ? mpWindow->GetFrameWeld() : nullptr, pObj1, pObj2) ); - if(pPolyObj1 && pPolyObj2 && (pDlg->Execute() == RET_OK)) - { - B2DPolyPolygonList_impl aPolyPolyList; - ::basegfx::B2DPolyPolygon aPolyPoly1; - ::basegfx::B2DPolyPolygon aPolyPoly2; + B2DPolyPolygonList_impl aPolyPolyList; + ::basegfx::B2DPolyPolygon aPolyPoly1; + ::basegfx::B2DPolyPolygon aPolyPoly2; - pDlg->SaveSettings(); + pDlg->SaveSettings(); - // #i48168# Not always is the pPolyObj1/pPolyObj2 a SdrPathObj, it may also be a group object - // containing SdrPathObjs. To get the polygons, I add two iters here - SdrObjListIter aIter1(*pPolyObj1); - SdrObjListIter aIter2(*pPolyObj2); + // #i48168# Not always is the pPolyObj1/pPolyObj2 a SdrPathObj, it may also be a group object + // containing SdrPathObjs. To get the polygons, I add two iters here + SdrObjListIter aIter1(*pPolyObj1); + SdrObjListIter aIter2(*pPolyObj2); - while(aIter1.IsMore()) - { - SdrObject* pObj = aIter1.Next(); - if(auto pPathObj = dynamic_cast< SdrPathObj *>( pObj )) - aPolyPoly1.append(pPathObj->GetPathPoly()); - } + while(aIter1.IsMore()) + { + SdrObject* pObj = aIter1.Next(); + if(auto pPathObj = dynamic_cast< SdrPathObj *>( pObj )) + aPolyPoly1.append(pPathObj->GetPathPoly()); + } - while(aIter2.IsMore()) - { - SdrObject* pObj = aIter2.Next(); - if(auto pPathObj = dynamic_cast< SdrPathObj *>( pObj )) - aPolyPoly2.append(pPathObj->GetPathPoly()); - } + while(aIter2.IsMore()) + { + SdrObject* pObj = aIter2.Next(); + if(auto pPathObj = dynamic_cast< SdrPathObj *>( pObj )) + aPolyPoly2.append(pPathObj->GetPathPoly()); + } - // perform morphing - if(aPolyPoly1.count() && aPolyPoly2.count()) + // perform morphing + if(aPolyPoly1.count() && aPolyPoly2.count()) + { + aPolyPoly1 = ::basegfx::utils::correctOrientations(aPolyPoly1); + aPolyPoly1.removeDoublePoints(); + ::basegfx::B2VectorOrientation eIsClockwise1(::basegfx::utils::getOrientation(aPolyPoly1.getB2DPolygon(0))); + + aPolyPoly2 = ::basegfx::utils::correctOrientations(aPolyPoly2); + aPolyPoly2.removeDoublePoints(); + ::basegfx::B2VectorOrientation eIsClockwise2(::basegfx::utils::getOrientation(aPolyPoly2.getB2DPolygon(0))); + + // set same orientation + if(eIsClockwise1 != eIsClockwise2) + aPolyPoly2.flip(); + + // force same poly count + if(aPolyPoly1.count() < aPolyPoly2.count()) + ImpAddPolys(aPolyPoly1, aPolyPoly2); + else if(aPolyPoly2.count() < aPolyPoly1.count()) + ImpAddPolys(aPolyPoly2, aPolyPoly1); + + // use orientation flag from dialog + if(!pDlg->IsOrientationFade()) + aPolyPoly2.flip(); + + // force same point counts + for( sal_uInt32 a(0); a < aPolyPoly1.count(); a++ ) { - aPolyPoly1 = ::basegfx::utils::correctOrientations(aPolyPoly1); - aPolyPoly1.removeDoublePoints(); - ::basegfx::B2VectorOrientation eIsClockwise1(::basegfx::utils::getOrientation(aPolyPoly1.getB2DPolygon(0))); - - aPolyPoly2 = ::basegfx::utils::correctOrientations(aPolyPoly2); - aPolyPoly2.removeDoublePoints(); - ::basegfx::B2VectorOrientation eIsClockwise2(::basegfx::utils::getOrientation(aPolyPoly2.getB2DPolygon(0))); - - // set same orientation - if(eIsClockwise1 != eIsClockwise2) - aPolyPoly2.flip(); - - // force same poly count - if(aPolyPoly1.count() < aPolyPoly2.count()) - ImpAddPolys(aPolyPoly1, aPolyPoly2); - else if(aPolyPoly2.count() < aPolyPoly1.count()) - ImpAddPolys(aPolyPoly2, aPolyPoly1); - - // use orientation flag from dialog - if(!pDlg->IsOrientationFade()) - aPolyPoly2.flip(); - - // force same point counts - for( sal_uInt32 a(0); a < aPolyPoly1.count(); a++ ) - { - ::basegfx::B2DPolygon aSub1(aPolyPoly1.getB2DPolygon(a)); - ::basegfx::B2DPolygon aSub2(aPolyPoly2.getB2DPolygon(a)); - - if(aSub1.count() < aSub2.count()) - ImpEqualizePolyPointCount(aSub1, aSub2); - else if(aSub2.count() < aSub1.count()) - ImpEqualizePolyPointCount(aSub2, aSub1); - - aPolyPoly1.setB2DPolygon(a, aSub1); - aPolyPoly2.setB2DPolygon(a, aSub2); - } - - ImpMorphPolygons(aPolyPoly1, aPolyPoly2, pDlg->GetFadeSteps(), aPolyPolyList); - - OUString aString(mpView->GetDescriptionOfMarkedObjects()); - aString += " " + SdResId(STR_UNDO_MORPHING); - - mpView->BegUndo(aString); - ImpInsertPolygons(aPolyPolyList, pDlg->IsAttributeFade(), pObj1, pObj2); - mpView->EndUndo(); + ::basegfx::B2DPolygon aSub1(aPolyPoly1.getB2DPolygon(a)); + ::basegfx::B2DPolygon aSub2(aPolyPoly2.getB2DPolygon(a)); + + if(aSub1.count() < aSub2.count()) + ImpEqualizePolyPointCount(aSub1, aSub2); + else if(aSub2.count() < aSub1.count()) + ImpEqualizePolyPointCount(aSub2, aSub1); + + aPolyPoly1.setB2DPolygon(a, aSub1); + aPolyPoly2.setB2DPolygon(a, aSub2); } - } - SdrObject::Free( pCloneObj1 ); - SdrObject::Free( pCloneObj2 ); - SdrObject::Free( pPolyObj1 ); - SdrObject::Free( pPolyObj2 ); + ImpMorphPolygons(aPolyPoly1, aPolyPoly2, pDlg->GetFadeSteps(), aPolyPolyList); + + OUString aString(mpView->GetDescriptionOfMarkedObjects()); + aString += " " + SdResId(STR_UNDO_MORPHING); + + mpView->BegUndo(aString); + ImpInsertPolygons(aPolyPolyList, pDlg->IsAttributeFade(), pObj1, pObj2); + mpView->EndUndo(); + } } + SdrObject::Free( pCloneObj1 ); + SdrObject::Free( pCloneObj2 ); + + SdrObject::Free( pPolyObj1 ); + SdrObject::Free( pPolyObj2 ); } static ::basegfx::B2DPolygon ImpGetExpandedPolygon( @@ -377,65 +377,65 @@ void FuMorph::ImpInsertPolygons( bIgnoreFill = true; } - if ( pPageView ) - { - SfxItemSet aSet( aSet1 ); - SdrObjGroup* pObjGroup = new SdrObjGroup(mpView->getSdrModelFromSdrView()); - SdrObjList* pObjList = pObjGroup->GetSubList(); - const size_t nCount = rPolyPolyList3D.size(); - const double fStep = 1. / ( nCount + 1 ); - const double fDelta = nEndLineWidth - nStartLineWidth; - double fFactor = fStep; - - aSet.Put( XLineStyleItem( drawing::LineStyle_SOLID ) ); - aSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) ); - - for ( size_t i = 0; i < nCount; i++, fFactor += fStep ) - { - const ::basegfx::B2DPolyPolygon& rPolyPoly3D = rPolyPolyList3D[ i ]; - SdrPathObj* pNewObj = new SdrPathObj( - mpView->getSdrModelFromSdrView(), - OBJ_POLY, - rPolyPoly3D); - - // line color - if ( bLineColor ) - { - const basegfx::BColor aLineColor(basegfx::interpolate(aStartLineCol.getBColor(), aEndLineCol.getBColor(), fFactor)); - aSet.Put( XLineColorItem( "", Color(aLineColor))); - } - else if ( bIgnoreLine ) - aSet.Put( XLineStyleItem( drawing::LineStyle_NONE ) ); + if ( !pPageView ) + return; - // fill color - if ( bFillColor ) - { - const basegfx::BColor aFillColor(basegfx::interpolate(aStartFillCol.getBColor(), aEndFillCol.getBColor(), fFactor)); - aSet.Put( XFillColorItem( "", Color(aFillColor))); - } - else if ( bIgnoreFill ) - aSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) ); - - // line width - if ( bLineWidth ) - aSet.Put( XLineWidthItem( nStartLineWidth + static_cast<long>( fFactor * fDelta + 0.5 ) ) ); + SfxItemSet aSet( aSet1 ); + SdrObjGroup* pObjGroup = new SdrObjGroup(mpView->getSdrModelFromSdrView()); + SdrObjList* pObjList = pObjGroup->GetSubList(); + const size_t nCount = rPolyPolyList3D.size(); + const double fStep = 1. / ( nCount + 1 ); + const double fDelta = nEndLineWidth - nStartLineWidth; + double fFactor = fStep; - pNewObj->SetMergedItemSetAndBroadcast(aSet); + aSet.Put( XLineStyleItem( drawing::LineStyle_SOLID ) ); + aSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) ); - pObjList->InsertObject( pNewObj ); + for ( size_t i = 0; i < nCount; i++, fFactor += fStep ) + { + const ::basegfx::B2DPolyPolygon& rPolyPoly3D = rPolyPolyList3D[ i ]; + SdrPathObj* pNewObj = new SdrPathObj( + mpView->getSdrModelFromSdrView(), + OBJ_POLY, + rPolyPoly3D); + + // line color + if ( bLineColor ) + { + const basegfx::BColor aLineColor(basegfx::interpolate(aStartLineCol.getBColor(), aEndLineCol.getBColor(), fFactor)); + aSet.Put( XLineColorItem( "", Color(aLineColor))); } + else if ( bIgnoreLine ) + aSet.Put( XLineStyleItem( drawing::LineStyle_NONE ) ); - if ( nCount ) + // fill color + if ( bFillColor ) { - pObjList->InsertObject( - pObj1->CloneSdrObject(pObj1->getSdrModelFromSdrObject()), - 0 ); - pObjList->InsertObject( - pObj2->CloneSdrObject(pObj2->getSdrModelFromSdrObject()) ); - - mpView->DeleteMarked(); - mpView->InsertObjectAtView( pObjGroup, *pPageView, SdrInsertFlags:: SETDEFLAYER ); + const basegfx::BColor aFillColor(basegfx::interpolate(aStartFillCol.getBColor(), aEndFillCol.getBColor(), fFactor)); + aSet.Put( XFillColorItem( "", Color(aFillColor))); } + else if ( bIgnoreFill ) + aSet.Put( XFillStyleItem( drawing::FillStyle_NONE ) ); + + // line width + if ( bLineWidth ) + aSet.Put( XLineWidthItem( nStartLineWidth + static_cast<long>( fFactor * fDelta + 0.5 ) ) ); + + pNewObj->SetMergedItemSetAndBroadcast(aSet); + + pObjList->InsertObject( pNewObj ); + } + + if ( nCount ) + { + pObjList->InsertObject( + pObj1->CloneSdrObject(pObj1->getSdrModelFromSdrObject()), + 0 ); + pObjList->InsertObject( + pObj2->CloneSdrObject(pObj2->getSdrModelFromSdrObject()) ); + + mpView->DeleteMarked(); + mpView->InsertObjectAtView( pObjGroup, *pPageView, SdrInsertFlags:: SETDEFLAYER ); } } @@ -482,29 +482,29 @@ void FuMorph::ImpMorphPolygons( B2DPolyPolygonList_impl& rPolyPolyList3D ) { - if(nSteps) + if(!nSteps) + return; + + const ::basegfx::B2DRange aStartPolySize(::basegfx::utils::getRange(rPolyPoly1)); + const ::basegfx::B2DPoint aStartCenter(aStartPolySize.getCenter()); + const ::basegfx::B2DRange aEndPolySize(::basegfx::utils::getRange(rPolyPoly2)); + const ::basegfx::B2DPoint aEndCenter(aEndPolySize.getCenter()); + const ::basegfx::B2DPoint aDelta(aEndCenter - aStartCenter); + const double fFactor(1.0 / (nSteps + 1)); + double fValue(0.0); + + for(sal_uInt16 i(0); i < nSteps; i++) { - const ::basegfx::B2DRange aStartPolySize(::basegfx::utils::getRange(rPolyPoly1)); - const ::basegfx::B2DPoint aStartCenter(aStartPolySize.getCenter()); - const ::basegfx::B2DRange aEndPolySize(::basegfx::utils::getRange(rPolyPoly2)); - const ::basegfx::B2DPoint aEndCenter(aEndPolySize.getCenter()); - const ::basegfx::B2DPoint aDelta(aEndCenter - aStartCenter); - const double fFactor(1.0 / (nSteps + 1)); - double fValue(0.0); - - for(sal_uInt16 i(0); i < nSteps; i++) - { - fValue += fFactor; - ::basegfx::B2DPolyPolygon aNewPolyPoly2D = ImpCreateMorphedPolygon(rPolyPoly1, rPolyPoly2, fValue); + fValue += fFactor; + ::basegfx::B2DPolyPolygon aNewPolyPoly2D = ImpCreateMorphedPolygon(rPolyPoly1, rPolyPoly2, fValue); - const ::basegfx::B2DRange aNewPolySize(::basegfx::utils::getRange(aNewPolyPoly2D)); - const ::basegfx::B2DPoint aNewS(aNewPolySize.getCenter()); - const ::basegfx::B2DPoint aRealS(aStartCenter + (aDelta * fValue)); - const ::basegfx::B2DPoint aDiff(aRealS - aNewS); + const ::basegfx::B2DRange aNewPolySize(::basegfx::utils::getRange(aNewPolyPoly2D)); + const ::basegfx::B2DPoint aNewS(aNewPolySize.getCenter()); + const ::basegfx::B2DPoint aRealS(aStartCenter + (aDelta * fValue)); + const ::basegfx::B2DPoint aDiff(aRealS - aNewS); - aNewPolyPoly2D.transform(basegfx::utils::createTranslateB2DHomMatrix(aDiff)); - rPolyPolyList3D.push_back( std::move(aNewPolyPoly2D) ); - } + aNewPolyPoly2D.transform(basegfx::utils::createTranslateB2DHomMatrix(aDiff)); + rPolyPolyList3D.push_back( std::move(aNewPolyPoly2D) ); } } diff --git a/sd/source/ui/func/fuoaprms.cxx b/sd/source/ui/func/fuoaprms.cxx index dd3fd2c8f277..fd2503fceb9c 100644 --- a/sd/source/ui/func/fuoaprms.cxx +++ b/sd/source/ui/func/fuoaprms.cxx @@ -594,7 +594,7 @@ void FuObjectAnimationParameters::DoExecute( SfxRequest& rReq ) nSecondPlayFullSet = ATTR_MISSING; // if any attribute is chosen - if (nEffectSet == ATTR_SET || + if (!(nEffectSet == ATTR_SET || nTextEffectSet == ATTR_SET || nSpeedSet == ATTR_SET || nAnimationSet == ATTR_SET || @@ -609,191 +609,191 @@ void FuObjectAnimationParameters::DoExecute( SfxRequest& rReq ) nSecondEffectSet == ATTR_SET || nSecondSpeedSet == ATTR_SET || nSecondSoundOnSet == ATTR_SET || - nSecondPlayFullSet == ATTR_SET) + nSecondPlayFullSet == ATTR_SET)) + return; + + // String for undo-group and list-action + OUString aComment(SdResId(STR_UNDO_ANIMATION)); + + // with 'following curves', we have an additional UndoAction + // therefore cling? here + pUndoMgr->EnterListAction(aComment, aComment, 0, mpViewShell->GetViewShellBase().GetViewShellId()); + + // create undo group + std::unique_ptr<SdUndoGroup> pUndoGroup(new SdUndoGroup(mpDoc)); + pUndoGroup->SetComment(aComment); + + // for the path effect, remember some stuff + SdrPathObj* pPath = nullptr; + if (eEffect == presentation::AnimationEffect_PATH && nEffectSet == ATTR_SET) { - // String for undo-group and list-action - OUString aComment(SdResId(STR_UNDO_ANIMATION)); + DBG_ASSERT(nCount == 2, "This effect expects two selected objects"); + SdrObject* pObject1 = rMarkList.GetMark(0)->GetMarkedSdrObj(); + SdrObject* pObject2 = rMarkList.GetMark(1)->GetMarkedSdrObj(); + SdrObjKind eKind1 = static_cast<SdrObjKind>(pObject1->GetObjIdentifier()); + SdrObjKind eKind2 = static_cast<SdrObjKind>(pObject2->GetObjIdentifier()); + SdrObject* pRunningObj = nullptr; + + if (pObject1->GetObjInventor() == SdrInventor::Default && + ((eKind1 == OBJ_LINE) || // 2 point line + (eKind1 == OBJ_PLIN) || // Polygon + (eKind1 == OBJ_PATHLINE))) // Bezier curve + { + pPath = static_cast<SdrPathObj*>(pObject1); + pRunningObj = pObject2; + } - // with 'following curves', we have an additional UndoAction - // therefore cling? here - pUndoMgr->EnterListAction(aComment, aComment, 0, mpViewShell->GetViewShellBase().GetViewShellId()); + if (pObject2->GetObjInventor() == SdrInventor::Default && + ((eKind2 == OBJ_LINE) || // 2 point line + (eKind2 == OBJ_PLIN) || // Polygon + (eKind2 == OBJ_PATHLINE))) // Bezier curve + { + pPath = static_cast<SdrPathObj*>(pObject2); + pRunningObj = pObject1; + } - // create undo group - std::unique_ptr<SdUndoGroup> pUndoGroup(new SdUndoGroup(mpDoc)); - pUndoGroup->SetComment(aComment); + assert(pRunningObj && pPath && "no curve found"); - // for the path effect, remember some stuff - SdrPathObj* pPath = nullptr; - if (eEffect == presentation::AnimationEffect_PATH && nEffectSet == ATTR_SET) + // push the running object to the end of the curve + if (pRunningObj) { - DBG_ASSERT(nCount == 2, "This effect expects two selected objects"); - SdrObject* pObject1 = rMarkList.GetMark(0)->GetMarkedSdrObj(); - SdrObject* pObject2 = rMarkList.GetMark(1)->GetMarkedSdrObj(); - SdrObjKind eKind1 = static_cast<SdrObjKind>(pObject1->GetObjIdentifier()); - SdrObjKind eKind2 = static_cast<SdrObjKind>(pObject2->GetObjIdentifier()); - SdrObject* pRunningObj = nullptr; - - if (pObject1->GetObjInventor() == SdrInventor::Default && - ((eKind1 == OBJ_LINE) || // 2 point line - (eKind1 == OBJ_PLIN) || // Polygon - (eKind1 == OBJ_PATHLINE))) // Bezier curve - { - pPath = static_cast<SdrPathObj*>(pObject1); - pRunningObj = pObject2; - } - - if (pObject2->GetObjInventor() == SdrInventor::Default && - ((eKind2 == OBJ_LINE) || // 2 point line - (eKind2 == OBJ_PLIN) || // Polygon - (eKind2 == OBJ_PATHLINE))) // Bezier curve - { - pPath = static_cast<SdrPathObj*>(pObject2); - pRunningObj = pObject1; - } - - assert(pRunningObj && pPath && "no curve found"); - - // push the running object to the end of the curve - if (pRunningObj) - { - ::tools::Rectangle aCurRect(pRunningObj->GetLogicRect()); - Point aCurCenter(aCurRect.Center()); - const ::basegfx::B2DPolyPolygon& rPolyPolygon = pPath->GetPathPoly(); - sal_uInt32 nNoOfPolygons(rPolyPolygon.count()); - const ::basegfx::B2DPolygon& aPolygon(rPolyPolygon.getB2DPolygon(nNoOfPolygons - 1)); - sal_uInt32 nPoints(aPolygon.count()); - const ::basegfx::B2DPoint aNewB2DCenter(aPolygon.getB2DPoint(nPoints - 1)); - const Point aNewCenter(FRound(aNewB2DCenter.getX()), FRound(aNewB2DCenter.getY())); - Size aDistance(aNewCenter.X() - aCurCenter.X(), aNewCenter.Y() - aCurCenter.Y()); - pRunningObj->Move(aDistance); - - pUndoMgr->AddUndoAction(mpDoc->GetSdrUndoFactory().CreateUndoMoveObject( *pRunningObj, aDistance)); - } + ::tools::Rectangle aCurRect(pRunningObj->GetLogicRect()); + Point aCurCenter(aCurRect.Center()); + const ::basegfx::B2DPolyPolygon& rPolyPolygon = pPath->GetPathPoly(); + sal_uInt32 nNoOfPolygons(rPolyPolygon.count()); + const ::basegfx::B2DPolygon& aPolygon(rPolyPolygon.getB2DPolygon(nNoOfPolygons - 1)); + sal_uInt32 nPoints(aPolygon.count()); + const ::basegfx::B2DPoint aNewB2DCenter(aPolygon.getB2DPoint(nPoints - 1)); + const Point aNewCenter(FRound(aNewB2DCenter.getX()), FRound(aNewB2DCenter.getY())); + Size aDistance(aNewCenter.X() - aCurCenter.X(), aNewCenter.Y() - aCurCenter.Y()); + pRunningObj->Move(aDistance); + + pUndoMgr->AddUndoAction(mpDoc->GetSdrUndoFactory().CreateUndoMoveObject( *pRunningObj, aDistance)); } + } + + for (size_t nObject = 0; nObject < nCount; ++nObject) + { + SdrObject* pObject = rMarkList.GetMark(nObject)->GetMarkedSdrObj(); - for (size_t nObject = 0; nObject < nCount; ++nObject) + pInfo = SdDrawDocument::GetAnimationInfo(pObject); + + bool bCreated = false; + if( !pInfo ) { - SdrObject* pObject = rMarkList.GetMark(nObject)->GetMarkedSdrObj(); - - pInfo = SdDrawDocument::GetAnimationInfo(pObject); - - bool bCreated = false; - if( !pInfo ) - { - pInfo = SdDrawDocument::GetShapeUserData(*pObject,true); - bCreated = true; - } - - // path object for 'following curves'? - if (eEffect == presentation::AnimationEffect_PATH && pObject == pPath) - { - SdAnimationPrmsUndoAction* pAction = new SdAnimationPrmsUndoAction - (mpDoc, pObject, bCreated); - pAction->SetActive(pInfo->mbActive, pInfo->mbActive); - pAction->SetEffect(pInfo->meEffect, pInfo->meEffect); - pAction->SetTextEffect(pInfo->meTextEffect, pInfo->meTextEffect); - pAction->SetSpeed(pInfo->meSpeed, pInfo->meSpeed); - pAction->SetDim(pInfo->mbDimPrevious, pInfo->mbDimPrevious); - pAction->SetDimColor(pInfo->maDimColor, pInfo->maDimColor); - pAction->SetDimHide(pInfo->mbDimHide, pInfo->mbDimHide); - pAction->SetSoundOn(pInfo->mbSoundOn, pInfo->mbSoundOn); - pAction->SetSound(pInfo->maSoundFile, pInfo->maSoundFile); - pAction->SetPlayFull(pInfo->mbPlayFull, pInfo->mbPlayFull); - pAction->SetClickAction(pInfo->meClickAction, pInfo->meClickAction); - pAction->SetBookmark(pInfo->GetBookmark(), pInfo->GetBookmark()); - pAction->SetVerb(pInfo->mnVerb, pInfo->mnVerb); - pAction->SetSecondEffect(pInfo->meSecondEffect, pInfo->meSecondEffect); - pAction->SetSecondSpeed(pInfo->meSecondSpeed, pInfo->meSecondSpeed); - pAction->SetSecondSoundOn(pInfo->mbSecondSoundOn, pInfo->mbSecondSoundOn); - pAction->SetSecondPlayFull(pInfo->mbSecondPlayFull, pInfo->mbSecondPlayFull); - pUndoGroup->AddAction(pAction); - - } - else - { - - // create undo action with old and new sizes - SdAnimationPrmsUndoAction* pAction = new SdAnimationPrmsUndoAction - (mpDoc, pObject, bCreated); - pAction->SetActive(pInfo->mbActive, bActive); - pAction->SetEffect(pInfo->meEffect, eEffect); - pAction->SetTextEffect(pInfo->meTextEffect, eTextEffect); - pAction->SetSpeed(pInfo->meSpeed, eSpeed); - pAction->SetDim(pInfo->mbDimPrevious, bFadeOut); - pAction->SetDimColor(pInfo->maDimColor, aFadeColor); - pAction->SetDimHide(pInfo->mbDimHide, bInvisible); - pAction->SetSoundOn(pInfo->mbSoundOn, bSoundOn); - pAction->SetSound(pInfo->maSoundFile, aSound); - pAction->SetPlayFull(pInfo->mbPlayFull, bPlayFull); - pAction->SetClickAction(pInfo->meClickAction, eClickAction); - pAction->SetBookmark(pInfo->GetBookmark(), aBookmark); - pAction->SetVerb(pInfo->mnVerb, static_cast<sal_uInt16>(pInfo->GetBookmark().toInt32()) ); - pAction->SetSecondEffect(pInfo->meSecondEffect, eSecondEffect); - pAction->SetSecondSpeed(pInfo->meSecondSpeed, eSecondSpeed); - pAction->SetSecondSoundOn(pInfo->mbSecondSoundOn, bSecondSoundOn); - pAction->SetSecondPlayFull(pInfo->mbSecondPlayFull,bSecondPlayFull); - pUndoGroup->AddAction(pAction); - - // insert new values at info block of the object - if (nAnimationSet == ATTR_SET) - pInfo->mbActive = bActive; - - if (nEffectSet == ATTR_SET) - pInfo->meEffect = eEffect; - - if (nTextEffectSet == ATTR_SET) - pInfo->meTextEffect = eTextEffect; - - if (nSpeedSet == ATTR_SET) - pInfo->meSpeed = eSpeed; - - if (nFadeOutSet == ATTR_SET) - pInfo->mbDimPrevious = bFadeOut; - - if (nFadeColorSet == ATTR_SET) - pInfo->maDimColor = aFadeColor; - - if (nInvisibleSet == ATTR_SET) - pInfo->mbDimHide = bInvisible; - - if (nSoundOnSet == ATTR_SET) - pInfo->mbSoundOn = bSoundOn; - - if (nSoundFileSet == ATTR_SET) - pInfo->maSoundFile = aSound; - - if (nPlayFullSet == ATTR_SET) - pInfo->mbPlayFull = bPlayFull; - - if (nClickActionSet == ATTR_SET) - pInfo->meClickAction = eClickAction; - - if (nBookmarkSet == ATTR_SET) - pInfo->SetBookmark( aBookmark ); - - if (nSecondEffectSet == ATTR_SET) - pInfo->meSecondEffect = eSecondEffect; - - if (nSecondSpeedSet == ATTR_SET) - pInfo->meSecondSpeed = eSecondSpeed; - - if (nSecondSoundOnSet == ATTR_SET) - pInfo->mbSecondSoundOn = bSecondSoundOn; - - if (nSecondPlayFullSet == ATTR_SET) - pInfo->mbSecondPlayFull = bSecondPlayFull; - - if (eClickAction == presentation::ClickAction_VERB) - pInfo->mnVerb = static_cast<sal_uInt16>(aBookmark.toInt32()); - } + pInfo = SdDrawDocument::GetShapeUserData(*pObject,true); + bCreated = true; } - // Set the Undo Group in of the Undo Manager - pUndoMgr->AddUndoAction(std::move(pUndoGroup)); - pUndoMgr->LeaveListAction(); - // Model changed - mpDoc->SetChanged(); + // path object for 'following curves'? + if (eEffect == presentation::AnimationEffect_PATH && pObject == pPath) + { + SdAnimationPrmsUndoAction* pAction = new SdAnimationPrmsUndoAction + (mpDoc, pObject, bCreated); + pAction->SetActive(pInfo->mbActive, pInfo->mbActive); + pAction->SetEffect(pInfo->meEffect, pInfo->meEffect); + pAction->SetTextEffect(pInfo->meTextEffect, pInfo->meTextEffect); + pAction->SetSpeed(pInfo->meSpeed, pInfo->meSpeed); + pAction->SetDim(pInfo->mbDimPrevious, pInfo->mbDimPrevious); + pAction->SetDimColor(pInfo->maDimColor, pInfo->maDimColor); + pAction->SetDimHide(pInfo->mbDimHide, pInfo->mbDimHide); + pAction->SetSoundOn(pInfo->mbSoundOn, pInfo->mbSoundOn); + pAction->SetSound(pInfo->maSoundFile, pInfo->maSoundFile); + pAction->SetPlayFull(pInfo->mbPlayFull, pInfo->mbPlayFull); + pAction->SetClickAction(pInfo->meClickAction, pInfo->meClickAction); + pAction->SetBookmark(pInfo->GetBookmark(), pInfo->GetBookmark()); + pAction->SetVerb(pInfo->mnVerb, pInfo->mnVerb); + pAction->SetSecondEffect(pInfo->meSecondEffect, pInfo->meSecondEffect); + pAction->SetSecondSpeed(pInfo->meSecondSpeed, pInfo->meSecondSpeed); + pAction->SetSecondSoundOn(pInfo->mbSecondSoundOn, pInfo->mbSecondSoundOn); + pAction->SetSecondPlayFull(pInfo->mbSecondPlayFull, pInfo->mbSecondPlayFull); + pUndoGroup->AddAction(pAction); + + } + else + { + + // create undo action with old and new sizes + SdAnimationPrmsUndoAction* pAction = new SdAnimationPrmsUndoAction + (mpDoc, pObject, bCreated); + pAction->SetActive(pInfo->mbActive, bActive); + pAction->SetEffect(pInfo->meEffect, eEffect); + pAction->SetTextEffect(pInfo->meTextEffect, eTextEffect); + pAction->SetSpeed(pInfo->meSpeed, eSpeed); + pAction->SetDim(pInfo->mbDimPrevious, bFadeOut); + pAction->SetDimColor(pInfo->maDimColor, aFadeColor); + pAction->SetDimHide(pInfo->mbDimHide, bInvisible); + pAction->SetSoundOn(pInfo->mbSoundOn, bSoundOn); + pAction->SetSound(pInfo->maSoundFile, aSound); + pAction->SetPlayFull(pInfo->mbPlayFull, bPlayFull); + pAction->SetClickAction(pInfo->meClickAction, eClickAction); + pAction->SetBookmark(pInfo->GetBookmark(), aBookmark); + pAction->SetVerb(pInfo->mnVerb, static_cast<sal_uInt16>(pInfo->GetBookmark().toInt32()) ); + pAction->SetSecondEffect(pInfo->meSecondEffect, eSecondEffect); + pAction->SetSecondSpeed(pInfo->meSecondSpeed, eSecondSpeed); + pAction->SetSecondSoundOn(pInfo->mbSecondSoundOn, bSecondSoundOn); + pAction->SetSecondPlayFull(pInfo->mbSecondPlayFull,bSecondPlayFull); + pUndoGroup->AddAction(pAction); + + // insert new values at info block of the object + if (nAnimationSet == ATTR_SET) + pInfo->mbActive = bActive; + + if (nEffectSet == ATTR_SET) + pInfo->meEffect = eEffect; + + if (nTextEffectSet == ATTR_SET) + pInfo->meTextEffect = eTextEffect; + + if (nSpeedSet == ATTR_SET) + pInfo->meSpeed = eSpeed; + + if (nFadeOutSet == ATTR_SET) + pInfo->mbDimPrevious = bFadeOut; + + if (nFadeColorSet == ATTR_SET) + pInfo->maDimColor = aFadeColor; + + if (nInvisibleSet == ATTR_SET) + pInfo->mbDimHide = bInvisible; + + if (nSoundOnSet == ATTR_SET) + pInfo->mbSoundOn = bSoundOn; + + if (nSoundFileSet == ATTR_SET) + pInfo->maSoundFile = aSound; + + if (nPlayFullSet == ATTR_SET) + pInfo->mbPlayFull = bPlayFull; + + if (nClickActionSet == ATTR_SET) + pInfo->meClickAction = eClickAction; + + if (nBookmarkSet == ATTR_SET) + pInfo->SetBookmark( aBookmark ); + + if (nSecondEffectSet == ATTR_SET) + pInfo->meSecondEffect = eSecondEffect; + + if (nSecondSpeedSet == ATTR_SET) + pInfo->meSecondSpeed = eSecondSpeed; + + if (nSecondSoundOnSet == ATTR_SET) + pInfo->mbSecondSoundOn = bSecondSoundOn; + + if (nSecondPlayFullSet == ATTR_SET) + pInfo->mbSecondPlayFull = bSecondPlayFull; + + if (eClickAction == presentation::ClickAction_VERB) + pInfo->mnVerb = static_cast<sal_uInt16>(aBookmark.toInt32()); + } } + // Set the Undo Group in of the Undo Manager + pUndoMgr->AddUndoAction(std::move(pUndoGroup)); + pUndoMgr->LeaveListAction(); + + // Model changed + mpDoc->SetChanged(); // not seen, therefore we do not need to invalidate at the bindings } diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx index cdd1db4b770a..4f84ee9df596 100644 --- a/sd/source/ui/func/fupage.cxx +++ b/sd/source/ui/func/fupage.cxx @@ -140,20 +140,20 @@ void FuPage::DoExecute( SfxRequest& ) mpPage = mpDrawViewShell->getCurrentPage(); } - if( mpPage ) + if( !mpPage ) + return; + + // if there are no arguments given, open the dialog + if( !mpArgs ) { - // if there are no arguments given, open the dialog - if( !mpArgs ) - { - mpView->SdrEndTextEdit(); - mpArgs = ExecuteDialog(mpWindow ? mpWindow->GetFrameWeld() : nullptr); - } + mpView->SdrEndTextEdit(); + mpArgs = ExecuteDialog(mpWindow ? mpWindow->GetFrameWeld() : nullptr); + } - // if we now have arguments, apply them to current page - if( mpArgs ) - { - ApplyItemSet( mpArgs ); - } + // if we now have arguments, apply them to current page + if( mpArgs ) + { + ApplyItemSet( mpArgs ); } } diff --git a/sd/source/ui/func/fupoor.cxx b/sd/source/ui/func/fupoor.cxx index ddf4866b95bb..a02e52ea0bae 100644 --- a/sd/source/ui/func/fupoor.cxx +++ b/sd/source/ui/func/fupoor.cxx @@ -125,36 +125,36 @@ void FuPoor::ForceScroll(const Point& aPixPos) { aScrollTimer.Stop(); - if ( !mpView->IsDragHelpLine() && !mpView->IsSetPageOrg() && - !SlideShow::IsRunning( mpViewShell->GetViewShellBase() ) ) - { - Point aPos = mpWindow->OutputToScreenPixel(aPixPos); - const ::tools::Rectangle& rRect = mpViewShell->GetAllWindowRect(); + if ( mpView->IsDragHelpLine() || mpView->IsSetPageOrg() || + SlideShow::IsRunning( mpViewShell->GetViewShellBase() ) ) + return; - if ( bNoScrollUntilInside ) - { - if ( rRect.IsInside(aPos) ) - bNoScrollUntilInside = false; - } - else - { - short dx = 0, dy = 0; + Point aPos = mpWindow->OutputToScreenPixel(aPixPos); + const ::tools::Rectangle& rRect = mpViewShell->GetAllWindowRect(); + + if ( bNoScrollUntilInside ) + { + if ( rRect.IsInside(aPos) ) + bNoScrollUntilInside = false; + } + else + { + short dx = 0, dy = 0; - if ( aPos.X() <= rRect.Left() ) dx = -1; - if ( aPos.X() >= rRect.Right() ) dx = 1; - if ( aPos.Y() <= rRect.Top() ) dy = -1; - if ( aPos.Y() >= rRect.Bottom() ) dy = 1; + if ( aPos.X() <= rRect.Left() ) dx = -1; + if ( aPos.X() >= rRect.Right() ) dx = 1; + if ( aPos.Y() <= rRect.Top() ) dy = -1; + if ( aPos.Y() >= rRect.Bottom() ) dy = 1; - if ( dx != 0 || dy != 0 ) + if ( dx != 0 || dy != 0 ) + { + if (bScrollable) { - if (bScrollable) - { - // scroll action in derived class - mpViewShell->ScrollLines(dx, dy); - aScrollTimer.Start(); - } - else if (! bDelayActive) StartDelayToScrollTimer (); + // scroll action in derived class + mpViewShell->ScrollLines(dx, dy); + aScrollTimer.Start(); } + else if (! bDelayActive) StartDelayToScrollTimer (); } } } @@ -937,18 +937,18 @@ void FuPoor::DoPasteUnformatted() */ IMPL_LINK_NOARG(FuPoor, DragHdl, Timer *, void) { - if( mpView ) - { - sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() ); - SdrHdl* pHdl = mpView->PickHandle(aMDPos); + if( !mpView ) + return; - if ( pHdl==nullptr && mpView->IsMarkedHit(aMDPos, nHitLog) - && !mpView->IsPresObjSelected(false) ) - { - mpWindow->ReleaseMouse(); - bIsInDragMode = true; - mpView->StartDrag( aMDPos, mpWindow ); - } + sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() ); + SdrHdl* pHdl = mpView->PickHandle(aMDPos); + + if ( pHdl==nullptr && mpView->IsMarkedHit(aMDPos, nHitLog) + && !mpView->IsPresObjSelected(false) ) + { + mpWindow->ReleaseMouse(); + bIsInDragMode = true; + mpView->StartDrag( aMDPos, mpWindow ); } } @@ -1043,30 +1043,31 @@ void FuPoor::ImpForceQuadratic(::tools::Rectangle& rRect) void FuPoor::SwitchLayer (sal_Int32 nOffset) { - if(auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell )) - { - // Calculate the new index. - sal_Int32 nIndex = pDrawViewShell->GetActiveTabLayerIndex() + nOffset; + auto pDrawViewShell = dynamic_cast<DrawViewShell *>( mpViewShell ); + if(!pDrawViewShell) + return; - // Make sure the new index lies inside the range of valid indices. - if (nIndex < 0) - nIndex = 0; - else if (nIndex >= pDrawViewShell->GetTabLayerCount ()) - nIndex = pDrawViewShell->GetTabLayerCount() - 1; + // Calculate the new index. + sal_Int32 nIndex = pDrawViewShell->GetActiveTabLayerIndex() + nOffset; - // Set the new active layer. - if (nIndex != pDrawViewShell->GetActiveTabLayerIndex ()) - { - LayerTabBar* pLayerTabControl = - static_cast<DrawViewShell*>(mpViewShell)->GetLayerTabControl(); - if (pLayerTabControl != nullptr) - pLayerTabControl->SendDeactivatePageEvent (); + // Make sure the new index lies inside the range of valid indices. + if (nIndex < 0) + nIndex = 0; + else if (nIndex >= pDrawViewShell->GetTabLayerCount ()) + nIndex = pDrawViewShell->GetTabLayerCount() - 1; - pDrawViewShell->SetActiveTabLayerIndex (nIndex); + // Set the new active layer. + if (nIndex != pDrawViewShell->GetActiveTabLayerIndex ()) + { + LayerTabBar* pLayerTabControl = + static_cast<DrawViewShell*>(mpViewShell)->GetLayerTabControl(); + if (pLayerTabControl != nullptr) + pLayerTabControl->SendDeactivatePageEvent (); - if (pLayerTabControl != nullptr) - pLayerTabControl->SendActivatePageEvent (); - } + pDrawViewShell->SetActiveTabLayerIndex (nIndex); + + if (pLayerTabControl != nullptr) + pLayerTabControl->SendActivatePageEvent (); } } diff --git a/sd/source/ui/func/fuprlout.cxx b/sd/source/ui/func/fuprlout.cxx index 9f33a572bd84..13548e66b6d5 100644 --- a/sd/source/ui/func/fuprlout.cxx +++ b/sd/source/ui/func/fuprlout.cxx @@ -195,92 +195,92 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq ) } } - if (!bError) + if (bError) + return; + + mpDocSh->SetWaitCursor( true ); + + /* Here, we only exchange masterpages, therefore the current page + remains the current page. To prevent calling PageOrderChangedHint + during insertion and extraction of the masterpages, we block. */ + /* That isn't quite right. If the masterpageview is active and you are + removing a masterpage, it's possible that you are removing the + current masterpage. So you have to call ResetActualPage ! */ + if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr && !bCheckMasters ) + static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(true); + + if (bLoad) { - mpDocSh->SetWaitCursor( true ); - - /* Here, we only exchange masterpages, therefore the current page - remains the current page. To prevent calling PageOrderChangedHint - during insertion and extraction of the masterpages, we block. */ - /* That isn't quite right. If the masterpageview is active and you are - removing a masterpage, it's possible that you are removing the - current masterpage. So you have to call ResetActualPage ! */ - if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr && !bCheckMasters ) - static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(true); - - if (bLoad) - { - OUString aFileName = aFile.getToken(0, DOCUMENT_TOKEN); - SdDrawDocument* pTempDoc = mpDoc->OpenBookmarkDoc( aFileName ); - - // #69581: If I chose the standard-template I got no filename and so I get no - // SdDrawDocument-Pointer. But the method SetMasterPage is able to handle - // a NULL-pointer as a Standard-template ( look at SdDrawDocument::SetMasterPage ) - OUString aLayoutName; - if( pTempDoc ) - aLayoutName = aFile.getToken(1, DOCUMENT_TOKEN); - for (auto nSelectedPage : aSelectedPageNums) - mpDoc->SetMasterPage(nSelectedPage, aLayoutName, pTempDoc, bMasterPage, bCheckMasters); - mpDoc->CloseBookmarkDoc(); - } - else - { - // use master page with the layout name aFile from current Doc - for (auto nSelectedPage : aSelectedPageNums) - mpDoc->SetMasterPage(nSelectedPage, aFile, mpDoc, bMasterPage, bCheckMasters); - } + OUString aFileName = aFile.getToken(0, DOCUMENT_TOKEN); + SdDrawDocument* pTempDoc = mpDoc->OpenBookmarkDoc( aFileName ); + + // #69581: If I chose the standard-template I got no filename and so I get no + // SdDrawDocument-Pointer. But the method SetMasterPage is able to handle + // a NULL-pointer as a Standard-template ( look at SdDrawDocument::SetMasterPage ) + OUString aLayoutName; + if( pTempDoc ) + aLayoutName = aFile.getToken(1, DOCUMENT_TOKEN); + for (auto nSelectedPage : aSelectedPageNums) + mpDoc->SetMasterPage(nSelectedPage, aLayoutName, pTempDoc, bMasterPage, bCheckMasters); + mpDoc->CloseBookmarkDoc(); + } + else + { + // use master page with the layout name aFile from current Doc + for (auto nSelectedPage : aSelectedPageNums) + mpDoc->SetMasterPage(nSelectedPage, aFile, mpDoc, bMasterPage, bCheckMasters); + } - // remove blocking - if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr && !bCheckMasters ) - static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(false); + // remove blocking + if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr && !bCheckMasters ) + static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(false); - // if the master page was visible, show it again - if (!aSelectedPages.empty()) + // if the master page was visible, show it again + if (!aSelectedPages.empty()) + { + if (bOnMaster) { - if (bOnMaster) - { - if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr) - { - ::sd::View* pView = - static_cast<DrawViewShell*>(mpViewShell)->GetView(); - for (auto pSelectedPage : aSelectedPages) - { - sal_uInt16 nPgNum = pSelectedPage->TRG_GetMasterPage().GetPageNum(); - - if (static_cast<DrawViewShell*>(mpViewShell)->GetPageKind() == PageKind::Notes) - nPgNum++; - - pView->HideSdrPage(); - pView->ShowSdrPage(pView->GetModel()->GetMasterPage(nPgNum)); - } - } - - // force update of TabBar - mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_MASTERPAGE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD); - } - else + if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr) { + ::sd::View* pView = + static_cast<DrawViewShell*>(mpViewShell)->GetView(); for (auto pSelectedPage : aSelectedPages) - pSelectedPage->SetAutoLayout(pSelectedPage->GetAutoLayout()); - } - } + { + sal_uInt16 nPgNum = pSelectedPage->TRG_GetMasterPage().GetPageNum(); - //Undo transfer to document selection - for (auto pPage : aUnselect) - mpDoc->SetSelected(pPage, false); + if (static_cast<DrawViewShell*>(mpViewShell)->GetPageKind() == PageKind::Notes) + nPgNum++; + pView->HideSdrPage(); + pView->ShowSdrPage(pView->GetModel()->GetMasterPage(nPgNum)); + } + } - // fake a mode change to repaint the page tab bar - if( auto pDrawViewSh = dynamic_cast<DrawViewShell *>( mpViewShell ) ) + // force update of TabBar + mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_MASTERPAGE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD); + } + else { - EditMode eMode = pDrawViewSh->GetEditMode(); - bool bLayer = pDrawViewSh->IsLayerModeActive(); - pDrawViewSh->ChangeEditMode( eMode, !bLayer ); - pDrawViewSh->ChangeEditMode( eMode, bLayer ); + for (auto pSelectedPage : aSelectedPages) + pSelectedPage->SetAutoLayout(pSelectedPage->GetAutoLayout()); } + } + + //Undo transfer to document selection + for (auto pPage : aUnselect) + mpDoc->SetSelected(pPage, false); - mpDocSh->SetWaitCursor( false ); + + // fake a mode change to repaint the page tab bar + if( auto pDrawViewSh = dynamic_cast<DrawViewShell *>( mpViewShell ) ) + { + EditMode eMode = pDrawViewSh->GetEditMode(); + bool bLayer = pDrawViewSh->IsLayerModeActive(); + pDrawViewSh->ChangeEditMode( eMode, !bLayer ); + pDrawViewSh->ChangeEditMode( eMode, bLayer ); } + + mpDocSh->SetWaitCursor( false ); } } // end of namespace sd diff --git a/sd/source/ui/func/fuprobjs.cxx b/sd/source/ui/func/fuprobjs.cxx index b46ebd9d0cc4..03eb1d8462b5 100644 --- a/sd/source/ui/func/fuprobjs.cxx +++ b/sd/source/ui/func/fuprobjs.cxx @@ -106,45 +106,45 @@ void FuPresentationObjects::DoExecute( SfxRequest& ) bUnique = true; } - if( bUnique ) + if( !bUnique ) + return; + + OUString aStyleName = aLayoutName + SD_LT_SEPARATOR; + PresentationObjects ePO; + + if( bPage ) + { + ePO = PO_TITLE; + aStyleName += STR_LAYOUT_TITLE; + } + else { - OUString aStyleName = aLayoutName + SD_LT_SEPARATOR; - PresentationObjects ePO; + ePO = static_cast<PresentationObjects>( PO_OUTLINE_1 + nDepth - 1 ); + aStyleName += STR_LAYOUT_OUTLINE " " + + OUString::number(nDepth); + } - if( bPage ) - { - ePO = PO_TITLE; - aStyleName += STR_LAYOUT_TITLE; - } - else - { - ePO = static_cast<PresentationObjects>( PO_OUTLINE_1 + nDepth - 1 ); - aStyleName += STR_LAYOUT_OUTLINE " " - + OUString::number(nDepth); - } + SfxStyleSheetBasePool* pStyleSheetPool = mpDocSh->GetStyleSheetPool(); + SfxStyleSheetBase* pStyleSheet = pStyleSheetPool->Find( aStyleName, SfxStyleFamily::Page ); + DBG_ASSERT(pStyleSheet, "StyleSheet missing"); - SfxStyleSheetBasePool* pStyleSheetPool = mpDocSh->GetStyleSheetPool(); - SfxStyleSheetBase* pStyleSheet = pStyleSheetPool->Find( aStyleName, SfxStyleFamily::Page ); - DBG_ASSERT(pStyleSheet, "StyleSheet missing"); + if( !pStyleSheet ) + return; - if( pStyleSheet ) - { - SfxStyleSheetBase& rStyleSheet = *pStyleSheet; - - SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSdPresLayoutTemplateDlg(mpDocSh, mpViewShell->GetFrameWeld(), - false, rStyleSheet, ePO, pStyleSheetPool)); - if( pDlg->Execute() == RET_OK ) - { - const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); - // Undo-Action - mpDocSh->GetUndoManager()->AddUndoAction( - std::make_unique<StyleSheetUndoAction>(mpDoc, static_cast<SfxStyleSheet*>(pStyleSheet), pOutSet)); - - pStyleSheet->GetItemSet().Put( *pOutSet ); - static_cast<SfxStyleSheet*>( pStyleSheet )->Broadcast( SfxHint( SfxHintId::DataChanged ) ); - } - } + SfxStyleSheetBase& rStyleSheet = *pStyleSheet; + + SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); + ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSdPresLayoutTemplateDlg(mpDocSh, mpViewShell->GetFrameWeld(), + false, rStyleSheet, ePO, pStyleSheetPool)); + if( pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + // Undo-Action + mpDocSh->GetUndoManager()->AddUndoAction( + std::make_unique<StyleSheetUndoAction>(mpDoc, static_cast<SfxStyleSheet*>(pStyleSheet), pOutSet)); + + pStyleSheet->GetItemSet().Put( *pOutSet ); + static_cast<SfxStyleSheet*>( pStyleSheet )->Broadcast( SfxHint( SfxHintId::DataChanged ) ); } } diff --git a/sd/source/ui/func/fusearch.cxx b/sd/source/ui/func/fusearch.cxx index c0e0c95ff461..88e1f564e7b5 100644 --- a/sd/source/ui/func/fusearch.cxx +++ b/sd/source/ui/func/fusearch.cxx @@ -108,35 +108,35 @@ void FuSearch::SearchAndReplace( const SvxSearchItem* pSearchItem ) if (pBase != nullptr) pViewShell = pBase->GetMainViewShell().get(); - if (pViewShell != nullptr) + if (pViewShell == nullptr) + return; + + if ( pSdOutliner && dynamic_cast< const DrawViewShell *>( pViewShell ) != nullptr && !bOwnOutliner ) { - if ( pSdOutliner && dynamic_cast< const DrawViewShell *>( pViewShell ) != nullptr && !bOwnOutliner ) - { - pSdOutliner->EndSpelling(); + pSdOutliner->EndSpelling(); - bOwnOutliner = true; - pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject ); - pSdOutliner->PrepareSpelling(); - } - else if ( pSdOutliner && dynamic_cast< const OutlineViewShell *>( pViewShell ) != nullptr && bOwnOutliner ) - { - pSdOutliner->EndSpelling(); - delete pSdOutliner; + bOwnOutliner = true; + pSdOutliner = new SdOutliner( mpDoc, OutlinerMode::TextObject ); + pSdOutliner->PrepareSpelling(); + } + else if ( pSdOutliner && dynamic_cast< const OutlineViewShell *>( pViewShell ) != nullptr && bOwnOutliner ) + { + pSdOutliner->EndSpelling(); + delete pSdOutliner; - bOwnOutliner = false; - pSdOutliner = mpDoc->GetOutliner(); - pSdOutliner->PrepareSpelling(); - } + bOwnOutliner = false; + pSdOutliner = mpDoc->GetOutliner(); + pSdOutliner->PrepareSpelling(); + } - if (pSdOutliner) - { - bool bEndSpelling = pSdOutliner->StartSearchAndReplace(pSearchItem); + if (pSdOutliner) + { + bool bEndSpelling = pSdOutliner->StartSearchAndReplace(pSearchItem); - if (bEndSpelling) - { - pSdOutliner->EndSpelling(); - pSdOutliner->PrepareSpelling(); - } + if (bEndSpelling) + { + pSdOutliner->EndSpelling(); + pSdOutliner->PrepareSpelling(); } } } diff --git a/sd/source/ui/func/fusldlg.cxx b/sd/source/ui/func/fusldlg.cxx index b2e9f28a400c..a783f98b4977 100644 --- a/sd/source/ui/func/fusldlg.cxx +++ b/sd/source/ui/func/fusldlg.cxx @@ -107,117 +107,117 @@ void FuSlideShowDlg::DoExecute( SfxRequest& ) SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); ScopedVclPtr<AbstractSdStartPresDlg> pDlg( pFact->CreateSdStartPresentationDlg(mpWindow ? mpWindow->GetFrameWeld() : nullptr, aDlgSet, aPageNameList, pCustomShowList) ); - if( pDlg->Execute() == RET_OK ) - { - OUString aPage; - long nValue32; - bool bValue; - bool bValuesChanged = false; - - pDlg->GetAttr( aDlgSet ); + if( pDlg->Execute() != RET_OK ) + return; - bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALL, SfxBoolItem ); - if ( bValue != rPresentationSettings.mbAll ) - { - bValuesChanged = true; - rPresentationSettings.mbAll = bValue; - // remove any previous existing slide - rPresentationSettings.maPresPage.clear(); - } + OUString aPage; + long nValue32; + bool bValue; + bool bValuesChanged = false; - if (!rPresentationSettings.mbAll) - { - aPage = ITEMVALUE( aDlgSet, ATTR_PRESENT_DIANAME, SfxStringItem ); - if( aPage != rPresentationSettings.maPresPage ) - { - bValuesChanged = true; - rPresentationSettings.maPresPage = aPage; - } - } + pDlg->GetAttr( aDlgSet ); - bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_CUSTOMSHOW, SfxBoolItem ); - if ( bValue != rPresentationSettings.mbCustomShow ) - { - bValuesChanged = true; - rPresentationSettings.mbCustomShow = bValue; - } + bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALL, SfxBoolItem ); + if ( bValue != rPresentationSettings.mbAll ) + { + bValuesChanged = true; + rPresentationSettings.mbAll = bValue; + // remove any previous existing slide + rPresentationSettings.maPresPage.clear(); + } - bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ENDLESS, SfxBoolItem ); - if ( bValue != rPresentationSettings.mbEndless ) + if (!rPresentationSettings.mbAll) + { + aPage = ITEMVALUE( aDlgSet, ATTR_PRESENT_DIANAME, SfxStringItem ); + if( aPage != rPresentationSettings.maPresPage ) { bValuesChanged = true; - rPresentationSettings.mbEndless = bValue; + rPresentationSettings.maPresPage = aPage; } + } - bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MANUEL, SfxBoolItem ); - if ( bValue != rPresentationSettings.mbManual ) - { - bValuesChanged = true; - rPresentationSettings.mbManual = bValue; - } + bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_CUSTOMSHOW, SfxBoolItem ); + if ( bValue != rPresentationSettings.mbCustomShow ) + { + bValuesChanged = true; + rPresentationSettings.mbCustomShow = bValue; + } - bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MOUSE, SfxBoolItem ); - if ( bValue != rPresentationSettings.mbMouseVisible ) - { - bValuesChanged = true; - rPresentationSettings.mbMouseVisible = bValue; - } + bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ENDLESS, SfxBoolItem ); + if ( bValue != rPresentationSettings.mbEndless ) + { + bValuesChanged = true; + rPresentationSettings.mbEndless = bValue; + } - bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_PEN, SfxBoolItem ); - if ( bValue != rPresentationSettings.mbMouseAsPen ) - { - bValuesChanged = true; - rPresentationSettings.mbMouseAsPen = bValue; - } + bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MANUEL, SfxBoolItem ); + if ( bValue != rPresentationSettings.mbManual ) + { + bValuesChanged = true; + rPresentationSettings.mbManual = bValue; + } - bValue = !ITEMVALUE( aDlgSet, ATTR_PRESENT_CHANGE_PAGE, SfxBoolItem ); - if ( bValue != rPresentationSettings.mbLockedPages ) - { - bValuesChanged = true; - rPresentationSettings.mbLockedPages = bValue; - } + bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_MOUSE, SfxBoolItem ); + if ( bValue != rPresentationSettings.mbMouseVisible ) + { + bValuesChanged = true; + rPresentationSettings.mbMouseVisible = bValue; + } - bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ANIMATION_ALLOWED, SfxBoolItem ); - if ( bValue != rPresentationSettings.mbAnimationAllowed ) - { - bValuesChanged = true; - rPresentationSettings.mbAnimationAllowed = bValue; - } + bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_PEN, SfxBoolItem ); + if ( bValue != rPresentationSettings.mbMouseAsPen ) + { + bValuesChanged = true; + rPresentationSettings.mbMouseAsPen = bValue; + } - bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALWAYS_ON_TOP, SfxBoolItem ); - if ( bValue != rPresentationSettings.mbAlwaysOnTop ) - { - bValuesChanged = true; - rPresentationSettings.mbAlwaysOnTop = bValue; - } + bValue = !ITEMVALUE( aDlgSet, ATTR_PRESENT_CHANGE_PAGE, SfxBoolItem ); + if ( bValue != rPresentationSettings.mbLockedPages ) + { + bValuesChanged = true; + rPresentationSettings.mbLockedPages = bValue; + } - bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_FULLSCREEN, SfxBoolItem ); - if ( bValue != rPresentationSettings.mbFullScreen ) - { - bValuesChanged = true; - rPresentationSettings.mbFullScreen = bValue; - } + bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ANIMATION_ALLOWED, SfxBoolItem ); + if ( bValue != rPresentationSettings.mbAnimationAllowed ) + { + bValuesChanged = true; + rPresentationSettings.mbAnimationAllowed = bValue; + } - nValue32 = ITEMVALUE( aDlgSet, ATTR_PRESENT_PAUSE_TIMEOUT, SfxUInt32Item ); - if( nValue32 != rPresentationSettings.mnPauseTimeout ) - { - bValuesChanged = true; - rPresentationSettings.mnPauseTimeout = nValue32; - } + bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_ALWAYS_ON_TOP, SfxBoolItem ); + if ( bValue != rPresentationSettings.mbAlwaysOnTop ) + { + bValuesChanged = true; + rPresentationSettings.mbAlwaysOnTop = bValue; + } - bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_SHOW_PAUSELOGO, SfxBoolItem ); - if ( bValue != rPresentationSettings.mbShowPauseLogo ) - { - bValuesChanged = true; - rPresentationSettings.mbShowPauseLogo = bValue; - } + bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_FULLSCREEN, SfxBoolItem ); + if ( bValue != rPresentationSettings.mbFullScreen ) + { + bValuesChanged = true; + rPresentationSettings.mbFullScreen = bValue; + } - pOptions->SetDisplay( ITEMVALUE( aDlgSet, ATTR_PRESENT_DISPLAY, SfxInt32Item ) ); + nValue32 = ITEMVALUE( aDlgSet, ATTR_PRESENT_PAUSE_TIMEOUT, SfxUInt32Item ); + if( nValue32 != rPresentationSettings.mnPauseTimeout ) + { + bValuesChanged = true; + rPresentationSettings.mnPauseTimeout = nValue32; + } - // is something has changed, we set the modified flag - if ( bValuesChanged ) - mpDoc->SetChanged(); + bValue = ITEMVALUE( aDlgSet, ATTR_PRESENT_SHOW_PAUSELOGO, SfxBoolItem ); + if ( bValue != rPresentationSettings.mbShowPauseLogo ) + { + bValuesChanged = true; + rPresentationSettings.mbShowPauseLogo = bValue; } + + pOptions->SetDisplay( ITEMVALUE( aDlgSet, ATTR_PRESENT_DISPLAY, SfxInt32Item ) ); + + // is something has changed, we set the modified flag + if ( bValuesChanged ) + mpDoc->SetChanged(); } } // end of namespace sd diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx index d68d55e09ec4..6f0dc98bac51 100644 --- a/sd/source/ui/func/futext.cxx +++ b/sd/source/ui/func/futext.cxx @@ -567,30 +567,30 @@ void FuText::ImpSetAttributesFitToSizeVertical(SdrTextObj* pTxtObj) void FuText::ImpSetAttributesFitCommon(SdrTextObj* pTxtObj) { // Normal Textobject - if (mpDoc->GetDocumentType() == DocumentType::Impress) - { - if( nSlotId == SID_ATTR_CHAR ) - { - // Impress text object (rescales to line height) - SfxItemSet aSet(mpViewShell->GetPool()); - aSet.Put(makeSdrTextMinFrameHeightItem(0)); - aSet.Put(makeSdrTextMaxFrameHeightItem(0)); - aSet.Put(makeSdrTextAutoGrowHeightItem(true)); - aSet.Put(makeSdrTextAutoGrowWidthItem(false)); - pTxtObj->SetMergedItemSet(aSet); - } - else if( nSlotId == SID_ATTR_CHAR_VERTICAL ) - { - SfxItemSet aSet(mpViewShell->GetPool()); - aSet.Put(makeSdrTextMinFrameWidthItem(0)); - aSet.Put(makeSdrTextMaxFrameWidthItem(0)); - aSet.Put(makeSdrTextAutoGrowWidthItem(true)); - aSet.Put(makeSdrTextAutoGrowHeightItem(false)); - pTxtObj->SetMergedItemSet(aSet); - } + if (mpDoc->GetDocumentType() != DocumentType::Impress) + return; - pTxtObj->AdjustTextFrameWidthAndHeight(); + if( nSlotId == SID_ATTR_CHAR ) + { + // Impress text object (rescales to line height) + SfxItemSet aSet(mpViewShell->GetPool()); + aSet.Put(makeSdrTextMinFrameHeightItem(0)); + aSet.Put(makeSdrTextMaxFrameHeightItem(0)); + aSet.Put(makeSdrTextAutoGrowHeightItem(true)); + aSet.Put(makeSdrTextAutoGrowWidthItem(false)); + pTxtObj->SetMergedItemSet(aSet); + } + else if( nSlotId == SID_ATTR_CHAR_VERTICAL ) + { + SfxItemSet aSet(mpViewShell->GetPool()); + aSet.Put(makeSdrTextMinFrameWidthItem(0)); + aSet.Put(makeSdrTextMaxFrameWidthItem(0)); + aSet.Put(makeSdrTextAutoGrowWidthItem(true)); + aSet.Put(makeSdrTextAutoGrowHeightItem(false)); + pTxtObj->SetMergedItemSet(aSet); } + + pTxtObj->AdjustTextFrameWidthAndHeight(); } bool FuText::MouseButtonUp(const MouseEvent& rMEvt) @@ -1145,39 +1145,39 @@ void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag) */ void FuText::DeleteDefaultText() { - if ( mxTextObj.is() && mxTextObj->IsEmptyPresObj() ) - { - SdPage* pPage = static_cast<SdPage*>( mxTextObj->getSdrPageFromSdrObject() ); + if ( !(mxTextObj.is() && mxTextObj->IsEmptyPresObj()) ) + return; - if (pPage) - { - PresObjKind ePresObjKind = pPage->GetPresObjKind(mxTextObj.get()); + SdPage* pPage = static_cast<SdPage*>( mxTextObj->getSdrPageFromSdrObject() ); - if ( (ePresObjKind == PRESOBJ_TITLE || - ePresObjKind == PRESOBJ_OUTLINE || - ePresObjKind == PRESOBJ_NOTES || - ePresObjKind == PRESOBJ_TEXT) && - !pPage->IsMasterPage() ) - { - ::Outliner* pOutliner = mpView->GetTextEditOutliner(); - SfxStyleSheet* pSheet = pOutliner->GetStyleSheet( 0 ); - bool bIsUndoEnabled = pOutliner->IsUndoEnabled(); - if( bIsUndoEnabled ) - pOutliner->EnableUndo(false); + if (!pPage) + return; - pOutliner->SetText( OUString(), pOutliner->GetParagraph( 0 ) ); + PresObjKind ePresObjKind = pPage->GetPresObjKind(mxTextObj.get()); - if( bIsUndoEnabled ) - pOutliner->EnableUndo(true); + if ( !((ePresObjKind == PRESOBJ_TITLE || + ePresObjKind == PRESOBJ_OUTLINE || + ePresObjKind == PRESOBJ_NOTES || + ePresObjKind == PRESOBJ_TEXT) && + !pPage->IsMasterPage()) ) + return; - if (pSheet && - (ePresObjKind == PRESOBJ_NOTES || ePresObjKind == PRESOBJ_TEXT)) - pOutliner->SetStyleSheet(0, pSheet); + ::Outliner* pOutliner = mpView->GetTextEditOutliner(); + SfxStyleSheet* pSheet = pOutliner->GetStyleSheet( 0 ); + bool bIsUndoEnabled = pOutliner->IsUndoEnabled(); + if( bIsUndoEnabled ) + pOutliner->EnableUndo(false); - mxTextObj->SetEmptyPresObj(true); - } - } - } + pOutliner->SetText( OUString(), pOutliner->GetParagraph( 0 ) ); + + if( bIsUndoEnabled ) + pOutliner->EnableUndo(true); + + if (pSheet && + (ePresObjKind == PRESOBJ_NOTES || ePresObjKind == PRESOBJ_TEXT)) + pOutliner->SetStyleSheet(0, pSheet); + + mxTextObj->SetEmptyPresObj(true); } bool FuText::RequestHelp(const HelpEvent& rHEvt) @@ -1232,65 +1232,65 @@ void FuText::ReceiveRequest(SfxRequest& rReq) // then we call the base class (besides others, nSlotId is NOT set there) FuPoor::ReceiveRequest(rReq); - if (nSlotId == SID_TEXTEDIT || mpViewShell->GetFrameView()->IsQuickEdit() || SID_ATTR_CHAR == nSlotId) - { - MouseEvent aMEvt(mpWindow->GetPointerPosPixel()); + if (!(nSlotId == SID_TEXTEDIT || mpViewShell->GetFrameView()->IsQuickEdit() || SID_ATTR_CHAR == nSlotId)) + return; - mxTextObj.reset(nullptr); + MouseEvent aMEvt(mpWindow->GetPointerPosPixel()); - if (nSlotId == SID_TEXTEDIT) + mxTextObj.reset(nullptr); + + if (nSlotId == SID_TEXTEDIT) + { + // are we currently editing? + if(!bTestText) + mxTextObj.reset( mpView->GetTextEditObject() ); + + if (!mxTextObj.is()) { - // are we currently editing? - if(!bTestText) - mxTextObj.reset( mpView->GetTextEditObject() ); + // Try to select an object + SdrPageView* pPV = mpView->GetSdrPageView(); + SdrViewEvent aVEvt; + mpView->PickAnything(aMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt); + mpView->MarkObj(aVEvt.pRootObj, pPV); - if (!mxTextObj.is()) + if (auto pSdrTextObj = dynamic_cast< SdrTextObj *>( aVEvt.pObj )) { - // Try to select an object - SdrPageView* pPV = mpView->GetSdrPageView(); - SdrViewEvent aVEvt; - mpView->PickAnything(aMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt); - mpView->MarkObj(aVEvt.pRootObj, pPV); - - if (auto pSdrTextObj = dynamic_cast< SdrTextObj *>( aVEvt.pObj )) - { - mxTextObj.reset( pSdrTextObj ); - } + mxTextObj.reset( pSdrTextObj ); } } - else if (mpView->AreObjectsMarked()) + } + else if (mpView->AreObjectsMarked()) + { + const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); + + if (rMarkList.GetMarkCount() == 1) { - const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - if (rMarkList.GetMarkCount() == 1) + if( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr) { - SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - - if( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr) - { - mxTextObj.reset( static_cast< SdrTextObj* >( pObj ) ); - } + mxTextObj.reset( static_cast< SdrTextObj* >( pObj ) ); } } + } - bool bQuickDrag = true; - - const SfxItemSet* pArgs = rReq.GetArgs(); + bool bQuickDrag = true; - if (pArgs + const SfxItemSet* pArgs = rReq.GetArgs(); - // test for type before using - && SID_TEXTEDIT == nSlotId - && SfxItemState::SET == pArgs->GetItemState(SID_TEXTEDIT) + if (pArgs - && static_cast<const SfxUInt16Item&>( pArgs->Get(SID_TEXTEDIT)).GetValue() == 2) - { - // selection with double click -> do not allow QuickDrag - bQuickDrag = false; - } + // test for type before using + && SID_TEXTEDIT == nSlotId + && SfxItemState::SET == pArgs->GetItemState(SID_TEXTEDIT) - SetInEditMode(aMEvt, bQuickDrag); + && static_cast<const SfxUInt16Item&>( pArgs->Get(SID_TEXTEDIT)).GetValue() == 2) + { + // selection with double click -> do not allow QuickDrag + bQuickDrag = false; } + + SetInEditMode(aMEvt, bQuickDrag); } void FuText::DoubleClick(const MouseEvent& ) diff --git a/sd/source/ui/func/fuvect.cxx b/sd/source/ui/func/fuvect.cxx index d7fa7dc25378..fc7fd0ee03a2 100644 --- a/sd/source/ui/func/fuvect.cxx +++ b/sd/source/ui/func/fuvect.cxx @@ -55,33 +55,34 @@ void FuVectorize::DoExecute( SfxRequest& ) { const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); - if( rMarkList.GetMarkCount() == 1 ) - { - SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + if( rMarkList.GetMarkCount() != 1 ) + return; + + SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + + auto pSdrGrafObj = dynamic_cast< const SdrGrafObj *>( pObj ); + if( !pSdrGrafObj ) + return; - if( auto pSdrGrafObj = dynamic_cast< const SdrGrafObj *>( pObj ) ) - { - SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSdVectorizeDlg> pDlg( - pFact->CreateSdVectorizeDlg(mpWindow ? mpWindow->GetFrameWeld() : nullptr, - pSdrGrafObj->GetGraphic().GetBitmapEx().GetBitmap(), mpDocSh ) ); - if( pDlg->Execute() == RET_OK ) - { - const GDIMetaFile& rMtf = pDlg->GetGDIMetaFile(); - SdrPageView* pPageView = mpView->GetSdrPageView(); + SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); + ScopedVclPtr<AbstractSdVectorizeDlg> pDlg( + pFact->CreateSdVectorizeDlg(mpWindow ? mpWindow->GetFrameWeld() : nullptr, + pSdrGrafObj->GetGraphic().GetBitmapEx().GetBitmap(), mpDocSh ) ); + if( pDlg->Execute() != RET_OK ) + return; - if( pPageView && rMtf.GetActionSize() ) - { - SdrGrafObj* pVectObj = static_cast<SdrGrafObj*>( pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject()) ); - OUString aStr( mpView->GetDescriptionOfMarkedObjects() ); - aStr += " " + SdResId( STR_UNDO_VECTORIZE ); - mpView->BegUndo( aStr ); - pVectObj->SetGraphic( rMtf ); - mpView->ReplaceObjectAtView( pObj, *pPageView, pVectObj ); - mpView->EndUndo(); - } - } - } + const GDIMetaFile& rMtf = pDlg->GetGDIMetaFile(); + SdrPageView* pPageView = mpView->GetSdrPageView(); + + if( pPageView && rMtf.GetActionSize() ) + { + SdrGrafObj* pVectObj = static_cast<SdrGrafObj*>( pObj->CloneSdrObject(pObj->getSdrModelFromSdrObject()) ); + OUString aStr( mpView->GetDescriptionOfMarkedObjects() ); + aStr += " " + SdResId( STR_UNDO_VECTORIZE ); + mpView->BegUndo( aStr ); + pVectObj->SetGraphic( rMtf ); + mpView->ReplaceObjectAtView( pObj, *pPageView, pVectObj ); + mpView->EndUndo(); } } diff --git a/sd/source/ui/func/smarttag.cxx b/sd/source/ui/func/smarttag.cxx index 0b2e531e1eed..5db90338d3bd 100644 --- a/sd/source/ui/func/smarttag.cxx +++ b/sd/source/ui/func/smarttag.cxx @@ -157,19 +157,19 @@ void SmartTagSet::Dispose() void SmartTagSet::select( const SmartTagReference& xTag ) { - if( mxSelectedTag != xTag ) - { - if( mxSelectedTag.is() ) - mxSelectedTag->deselect(); + if( mxSelectedTag == xTag ) + return; - mxSelectedTag = xTag; - mxSelectedTag->select(); - mrView.SetPossibilitiesDirty(); - if( mrView.GetMarkedObjectCount() > 0 ) - mrView.UnmarkAllObj(); - else - mrView.updateHandles(); - } + if( mxSelectedTag.is() ) + mxSelectedTag->deselect(); + + mxSelectedTag = xTag; + mxSelectedTag->select(); + mrView.SetPossibilitiesDirty(); + if( mrView.GetMarkedObjectCount() > 0 ) + mrView.UnmarkAllObj(); + else + mrView.updateHandles(); } void SmartTagSet::deselect() |