1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/shl.hxx>
21 #include <hintids.hxx>
23 #include <swtypes.hxx>
24 #include <sfx2/objface.hxx>
25 #include <sfx2/request.hxx>
26 #include <sfx2/bindings.hxx>
27 #include <svl/aeitem.hxx>
28 #include <svx/svdview.hxx>
29 #include <vcl/msgbox.hxx>
30 #include <svl/srchitem.hxx>
31 #include <svl/whiter.hxx>
32 #include <svx/swframevalidation.hxx>
33 #include <svx/anchorid.hxx>
34 #include <sfx2/htmlmode.hxx>
36 #include <fmtornt.hxx>
38 #include <swmodule.hxx>
42 #include <viewopt.hxx>
43 #include <dcontact.hxx>
46 #include <drawbase.hxx>
47 #include <drwbassh.hxx>
48 #include <swdtflvr.hxx>
49 #include <svx/svdogrp.hxx>
50 #include <svx/svdpage.hxx>
51 #include <svx/svditer.hxx>
54 #define SwDrawBaseShell
55 #include <sfx2/msg.hxx>
56 #include <swslots.hxx>
57 #include <svx/svxdlg.hxx>
58 #include <svx/dialogs.hrc>
59 #include "swabstdlg.hxx"
62 #include <com/sun/star/text/HoriOrientation.hpp>
63 #include <com/sun/star/text/VertOrientation.hpp>
64 #include <com/sun/star/text/RelOrientation.hpp>
66 #include <IDocumentDrawModelAccess.hxx>
68 using namespace ::com::sun::star
;
70 SFX_IMPL_INTERFACE(SwDrawBaseShell
, SwBaseShell
, SW_RES(0))
74 TYPEINIT1(SwDrawBaseShell
,SwBaseShell
)
76 SwDrawBaseShell::SwDrawBaseShell(SwView
&_rView
):
79 GetShell().NoEdit(true);
81 SwEditWin
& rWin
= GetView().GetEditWin();
83 rWin
.SetBezierMode(SID_BEZIER_MOVE
);
85 if ( !_rView
.GetDrawFuncPtr() )
86 _rView
.GetEditWin().StdDrawMode( OBJ_NONE
, sal_True
);
88 SwTransferable::CreateSelection( GetShell() );
91 SwDrawBaseShell::~SwDrawBaseShell()
95 SwTransferable::ClearSelection( GetShell() );
98 void SwDrawBaseShell::Execute(SfxRequest
&rReq
)
100 SwWrtShell
*pSh
= &GetShell();
101 SdrView
* pSdrView
= pSh
->GetDrawView();
102 const SfxItemSet
*pArgs
= rReq
.GetArgs();
103 sal_uInt16 nSlotId
= rReq
.GetSlot();
104 sal_Bool bChanged
= pSdrView
->GetModel()->IsChanged();
105 pSdrView
->GetModel()->SetChanged(sal_False
);
106 const SfxPoolItem
* pItem
= 0;
108 pArgs
->GetItemState(nSlotId
, sal_False
, &pItem
);
110 //Special case align by menu
111 if(pItem
&& nSlotId
== SID_OBJECT_ALIGN
)
113 OSL_ENSURE(PTR_CAST(SfxEnumItem
, pItem
),"SfxEnumItem expected");
114 nSlotId
= nSlotId
+ ((const SfxEnumItem
*)pItem
)->GetValue();
118 sal_Bool bAlignPossible
= pSh
->IsAlignPossible();
120 sal_Bool bTopParam
= sal_True
, bBottomParam
= sal_True
;
121 bool bNotify
= false;
123 SfxBindings
& rBind
= GetView().GetViewFrame()->GetBindings();
127 case FN_DRAW_WRAP_DLG
:
129 if(pSdrView
->AreObjectsMarked())
133 const SdrMarkList
& rMarkList
= pSdrView
->GetMarkedObjectList();
134 if( rMarkList
.GetMark(0) != 0 )
136 SfxItemSet
aSet(GetPool(), RES_SURROUND
, RES_SURROUND
,
137 RES_ANCHOR
, RES_ANCHOR
,
138 RES_LR_SPACE
, RES_UL_SPACE
,
139 SID_HTML_MODE
, SID_HTML_MODE
,
140 FN_DRAW_WRAP_DLG
, FN_DRAW_WRAP_DLG
,
143 aSet
.Put(SfxBoolItem(SID_HTML_MODE
,
144 0 != ::GetHtmlMode(pSh
->GetView().GetDocShell())));
146 aSet
.Put(SfxInt16Item(FN_DRAW_WRAP_DLG
, pSh
->GetLayerId()));
148 pSh
->GetObjAttr(aSet
);
149 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
150 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
152 SfxAbstractDialog
* pDlg
= pFact
->CreateSwWrapDlg( GetView().GetWindow(), aSet
, pSh
, sal_True
, RC_DLG_SWWRAPDLG
);
153 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
155 if (pDlg
->Execute() == RET_OK
)
157 const SfxPoolItem
* pWrapItem
;
158 const SfxItemSet
* pOutSet
= pDlg
->GetOutputItemSet();
159 if(SFX_ITEM_SET
== pOutSet
->GetItemState(FN_DRAW_WRAP_DLG
, sal_False
, &pWrapItem
))
161 short nLayer
= ((const SfxInt16Item
*)pWrapItem
)->GetValue();
163 pSh
->SelectionToHeaven();
165 pSh
->SelectionToHell();
168 pSh
->SetObjAttr(*pOutSet
);
177 case SID_ATTR_TRANSFORM
:
179 if(pSdrView
->AreObjectsMarked())
183 const SdrMarkList
& rMarkList
= pSdrView
->GetMarkedObjectList();
184 if( rMarkList
.GetMark(0) != 0 )
186 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
187 SfxAbstractTabDialog
*pDlg
=NULL
;
188 bool bCaption
= false;
190 // Allowed anchorages:
191 short nAnchor
= pSh
->GetAnchorId();
192 sal_uInt16 nAllowedAnchors
= SVX_OBJ_AT_CNTNT
| SVX_OBJ_IN_CNTNT
| SVX_OBJ_PAGE
;
193 sal_uInt16 nHtmlMode
= ::GetHtmlMode(pSh
->GetView().GetDocShell());
195 if ( pSh
->IsFlyInFly() )
196 nAllowedAnchors
|= SVX_OBJ_AT_FLY
;
198 if (pObj
->GetObjIdentifier() == OBJ_CAPTION
)
203 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
206 AbstractSvxCaptionDialog
* pCaptionDlg
=
207 pFact
->CreateCaptionDialog( NULL
, pSdrView
, nAllowedAnchors
);
208 pCaptionDlg
->SetValidateFramePosLink( LINK(this, SwDrawBaseShell
, ValidatePosition
) );
210 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
215 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
219 AbstractSvxTransformTabDialog
* pTransform
=
220 pFact
->CreateSvxTransformTabDialog( NULL
, NULL
, pSdrView
, nAllowedAnchors
);
221 pTransform
->SetValidateFramePosLink( LINK(this, SwDrawBaseShell
, ValidatePosition
) );
223 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
226 SfxItemSet
aNewAttr(pSdrView
->GetGeoAttrFromMarked());
228 const sal_uInt16
* pRange
= pDlg
->GetInputRanges( *aNewAttr
.GetPool() );
229 SfxItemSet
aSet( *aNewAttr
.GetPool(), pRange
);
230 FieldUnit eMetric
= ::GetDfltMetric(0 != dynamic_cast<SwWebView
*>(&GetView()));
231 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< sal_uInt16
>(eMetric
)) );
233 aSet
.Put( aNewAttr
, sal_False
);
236 pSdrView
->GetAttributes( aSet
);
238 aSet
.Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR
, nAnchor
));
241 aSet
.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT
, pSh
->IsFrmVertical(sal_True
, bRTL
, bVertL2R
)));
242 aSet
.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_RTL_TEXT
, bRTL
));
244 SwFrmFmt
* pFrmFmt
= FindFrmFmt( pObj
);
246 aSet
.Put( pFrmFmt
->GetFmtAttr(RES_FOLLOW_TEXT_FLOW
) );
248 SwFmtVertOrient
aVOrient((const SwFmtVertOrient
&)pFrmFmt
->GetFmtAttr(RES_VERT_ORIENT
));
249 aSet
.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_ORIENT
, aVOrient
.GetVertOrient()));
250 aSet
.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_RELATION
, aVOrient
.GetRelationOrient() ));
251 aSet
.Put(SfxInt32Item(SID_ATTR_TRANSFORM_VERT_POSITION
, aVOrient
.GetPos()));
253 SwFmtHoriOrient
aHOrient((const SwFmtHoriOrient
&)pFrmFmt
->GetFmtAttr(RES_HORI_ORIENT
));
254 aSet
.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_ORIENT
, aHOrient
.GetHoriOrient()));
255 aSet
.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_RELATION
, aHOrient
.GetRelationOrient() ));
256 aSet
.Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR
, aHOrient
.IsPosToggle()));
257 aSet
.Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION
, aHOrient
.GetPos()));
259 aSet
.Put(SfxUInt16Item(SID_HTML_MODE
, nHtmlMode
));
261 pDlg
->SetInputSet( &aSet
);
263 if (pDlg
->Execute() == RET_OK
)
265 const SfxItemSet
* pOutSet
= pDlg
->GetOutputItemSet();
266 pSh
->StartAllAction();
269 pSh
->StartUndo(UNDO_INSFMTATTR
);
271 pSdrView
->SetGeoAttrToMarked(*pOutSet
);
274 pSdrView
->SetAttributes(*pOutSet
);
277 SFX_ITEM_SET
!= pOutSet
->GetItemState(
278 SID_ATTR_TRANSFORM_POS_X
, sal_False
) &&
279 SFX_ITEM_SET
!= pOutSet
->GetItemState(
280 SID_ATTR_TRANSFORM_POS_Y
, sal_False
);
282 SfxItemSet
aFrmAttrSet(GetPool(), RES_FRMATR_BEGIN
, RES_FRMATR_END
- 1);
284 bool bSingleSelection
= rMarkList
.GetMarkCount() == 1;
286 const SfxPoolItem
* pAnchorItem
;
287 if(SFX_ITEM_SET
== pOutSet
->GetItemState(
288 SID_ATTR_TRANSFORM_ANCHOR
, sal_False
, &pAnchorItem
))
290 if(!bSingleSelection
)
291 pSh
->ChgAnchor(((const SfxInt16Item
*)pAnchorItem
)
292 ->GetValue(), false, bPosCorr
);
295 SwFmtAnchor
aAnchor(pFrmFmt
->GetAnchor());
296 aAnchor
.SetType((RndStdIds
)((const SfxInt16Item
*)pAnchorItem
)->GetValue());
297 aFrmAttrSet
.Put( aAnchor
);
300 const SfxPoolItem
* pHoriOrient
= 0;
301 const SfxPoolItem
* pHoriRelation
= 0;
302 const SfxPoolItem
* pHoriPosition
= 0;
303 const SfxPoolItem
* pHoriMirror
= 0;
304 pOutSet
->GetItemState(SID_ATTR_TRANSFORM_HORI_ORIENT
, sal_False
, &pHoriOrient
);
305 pOutSet
->GetItemState(SID_ATTR_TRANSFORM_HORI_RELATION
, sal_False
, &pHoriRelation
);
306 pOutSet
->GetItemState(SID_ATTR_TRANSFORM_HORI_POSITION
, sal_False
, &pHoriPosition
);
307 pOutSet
->GetItemState(SID_ATTR_TRANSFORM_HORI_MIRROR
, sal_False
, &pHoriMirror
);
308 if(pHoriOrient
|| pHoriRelation
|| pHoriPosition
|| pHoriMirror
)
311 aHOrient
.SetHoriOrient(
312 static_cast<const SfxInt16Item
*>(pHoriOrient
)->GetValue());
314 aHOrient
.SetRelationOrient(
315 static_cast<const SfxInt16Item
*>(pHoriRelation
)->GetValue());
317 aHOrient
.SetPos( static_cast<const SfxInt32Item
*>(pHoriPosition
)->GetValue());
319 aHOrient
.SetPosToggle( static_cast<const SfxBoolItem
*>(pHoriMirror
)->GetValue());
320 aFrmAttrSet
.Put(aHOrient
);
323 const SfxPoolItem
* pVertOrient
= 0;
324 const SfxPoolItem
* pVertRelation
= 0;
325 const SfxPoolItem
* pVertPosition
= 0;
326 pOutSet
->GetItemState(SID_ATTR_TRANSFORM_VERT_ORIENT
, sal_False
, &pVertOrient
);
327 pOutSet
->GetItemState(SID_ATTR_TRANSFORM_VERT_RELATION
, sal_False
, &pVertRelation
);
328 pOutSet
->GetItemState(SID_ATTR_TRANSFORM_VERT_POSITION
, sal_False
, &pVertPosition
);
329 if(pVertOrient
|| pVertRelation
|| pVertPosition
)
332 aVOrient
.SetVertOrient(
333 static_cast<const SfxInt16Item
*>(pVertOrient
)->GetValue());
335 aVOrient
.SetRelationOrient(
336 static_cast<const SfxInt16Item
*>(pVertRelation
)->GetValue());
338 aVOrient
.SetPos( static_cast<const SfxInt32Item
*>(pVertPosition
)->GetValue());
339 aFrmAttrSet
.Put( aVOrient
);
341 const SfxPoolItem
* pFollowItem
= 0;
342 pOutSet
->GetItemState(RES_FOLLOW_TEXT_FLOW
, sal_False
, &pFollowItem
);
344 aFrmAttrSet
.Put(*pFollowItem
);
346 if(aFrmAttrSet
.Count())
347 pSh
->SetDrawingAttr(aFrmAttrSet
);
349 rBind
.InvalidateAll(sal_False
);
352 pSh
->EndUndo( UNDO_INSFMTATTR
);
362 pSdrView
->SetGeoAttrToMarked( *pArgs
);
370 if (pSh
->IsObjSelected() && !pSdrView
->IsTextEdit())
374 if( GetView().IsDrawRotate() )
376 pSh
->SetDragMode( SDRDRAG_MOVE
);
377 GetView().FlipDrawRotate();
381 pSh
->DelSelectedObj();
384 GetView().GetEditWin().IsObjectSelect() )
386 // If basic call, then back to the text shell, because the
387 // Basic otherwise has no possibility to return.
388 if (GetView().GetDrawFuncPtr())
390 GetView().GetDrawFuncPtr()->Deactivate();
391 GetView().SetDrawFuncPtr(NULL
);
393 GetView().LeaveDrawCreate(); // Switch to selection mode
396 if (pSh
->IsSelFrmMode())
398 pSh
->LeaveSelFrmMode();
406 if (pSh
->IsObjSelected() > 1 && pSh
->IsGroupAllowed())
408 pSh
->GroupSelection();
409 rBind
.Invalidate(SID_UNGROUP
);
414 if (pSh
->IsGroupSelected())
416 pSh
->UnGroupSelection();
417 rBind
.Invalidate(SID_GROUP
);
421 case SID_ENTER_GROUP
:
422 if (pSh
->IsGroupSelected())
424 pSdrView
->EnterMarkedGroup();
425 rBind
.InvalidateAll(sal_False
);
429 case SID_LEAVE_GROUP
:
430 if (pSdrView
->IsGroupEntered())
432 pSdrView
->LeaveOneGroup();
433 rBind
.Invalidate(SID_ENTER_GROUP
);
434 rBind
.Invalidate(SID_UNGROUP
);
438 case SID_OBJECT_ALIGN_LEFT
:
439 case SID_OBJECT_ALIGN_CENTER
:
440 case SID_OBJECT_ALIGN_RIGHT
:
441 case SID_OBJECT_ALIGN_UP
:
442 case SID_OBJECT_ALIGN_MIDDLE
:
443 case SID_OBJECT_ALIGN_DOWN
:
445 if ( bAlignPossible
)
447 const SdrMarkList
& rMarkList
= pSdrView
->GetMarkedObjectList();
448 if( rMarkList
.GetMarkCount() == 1 && bAlignPossible
)
449 { // Do not align objects to each other
450 sal_uInt16 nAnchor
= pSh
->GetAnchorId();
451 if (nAnchor
== FLY_AS_CHAR
)
453 sal_Int16 nVertOrient
= -1;
457 case SID_OBJECT_ALIGN_UP
:
458 nVertOrient
= text::VertOrientation::TOP
;
460 case SID_OBJECT_ALIGN_MIDDLE
:
461 nVertOrient
= text::VertOrientation::CENTER
;
463 case SID_OBJECT_ALIGN_DOWN
:
464 nVertOrient
= text::VertOrientation::BOTTOM
;
469 if (nVertOrient
!= -1)
472 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
473 SwFrmFmt
* pFrmFmt
= FindFrmFmt( pObj
);
474 SwFmtVertOrient
aVOrient((SwFmtVertOrient
&)pFrmFmt
->GetFmtAttr(RES_VERT_ORIENT
));
475 aVOrient
.SetVertOrient( nVertOrient
);
476 pFrmFmt
->SetFmtAttr(aVOrient
);
481 if (nAnchor
== FLY_AT_PARA
)
482 break; // Do not align frames of an anchored paragraph
488 case SID_OBJECT_ALIGN_LEFT
:
489 pSdrView
->AlignMarkedObjects(SDRHALIGN_LEFT
, SDRVALIGN_NONE
);
491 case SID_OBJECT_ALIGN_CENTER
:
492 pSdrView
->AlignMarkedObjects(SDRHALIGN_CENTER
, SDRVALIGN_NONE
);
494 case SID_OBJECT_ALIGN_RIGHT
:
495 pSdrView
->AlignMarkedObjects(SDRHALIGN_RIGHT
, SDRVALIGN_NONE
);
497 case SID_OBJECT_ALIGN_UP
:
498 pSdrView
->AlignMarkedObjects(SDRHALIGN_NONE
, SDRVALIGN_TOP
);
500 case SID_OBJECT_ALIGN_MIDDLE
:
501 pSdrView
->AlignMarkedObjects(SDRHALIGN_NONE
, SDRVALIGN_CENTER
);
503 case SID_OBJECT_ALIGN_DOWN
:
504 pSdrView
->AlignMarkedObjects(SDRHALIGN_NONE
, SDRVALIGN_BOTTOM
);
513 bTopParam
= sal_False
;
515 case SID_FRAME_TO_TOP
:
516 pSh
->SelectionToTop( bTopParam
);
520 bBottomParam
= sal_False
;
522 case SID_FRAME_TO_BOTTOM
:
523 pSh
->SelectionToBottom( bBottomParam
);
530 if(1L == pSdrView
->GetMarkedObjectCount())
533 SdrObject
* pSelected
= pSdrView
->GetMarkedObjectByIndex(0L);
534 OSL_ENSURE(pSelected
, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
535 String
aName(pSelected
->GetName());
537 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
538 OSL_ENSURE(pFact
, "Dialogdiet fail!");
539 AbstractSvxObjectNameDialog
* pDlg
= pFact
->CreateSvxObjectNameDialog(NULL
, aName
);
540 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
542 pDlg
->SetCheckNameHdl(LINK(this, SwDrawBaseShell
, CheckGroupShapeNameHdl
));
544 if(RET_OK
== pDlg
->Execute())
546 pDlg
->GetName(aName
);
547 pSelected
->SetName(aName
);
558 case FN_TITLE_DESCRIPTION_SHAPE
:
562 if(1L == pSdrView
->GetMarkedObjectCount())
564 SdrObject
* pSelected
= pSdrView
->GetMarkedObjectByIndex(0L);
565 OSL_ENSURE(pSelected
, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
566 String
aTitle(pSelected
->GetTitle());
567 String
aDescription(pSelected
->GetDescription());
569 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
570 OSL_ENSURE(pFact
, "Dialogdiet fail!");
571 AbstractSvxObjectTitleDescDialog
* pDlg
= pFact
->CreateSvxObjectTitleDescDialog(NULL
, aTitle
, aDescription
);
572 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
574 if(RET_OK
== pDlg
->Execute())
576 pDlg
->GetTitle(aTitle
);
577 pDlg
->GetDescription(aDescription
);
579 pSelected
->SetTitle(aTitle
);
580 pSelected
->SetDescription(aDescription
);
592 OSL_ENSURE(!this, "wrong Dispatcher");
597 if(nSlotId
>= SID_OBJECT_ALIGN_LEFT
&& nSlotId
<= SID_OBJECT_ALIGN_DOWN
)
598 rBind
.Invalidate(SID_ATTR_LONG_LRSPACE
);
599 if (pSdrView
->GetModel()->IsChanged())
602 pSdrView
->GetModel()->SetChanged(sal_True
);
603 // 40220: After Delete from DrawObjecs over the API GPF through self-destruction
605 GetView().AttrChangedNotify(pSh
); // Shell switch if applicable...
609 // Checks whether a given name is allowed for a group shape
611 IMPL_LINK( SwDrawBaseShell
, CheckGroupShapeNameHdl
, AbstractSvxNameDialog
*, pNameDialog
)
613 SwWrtShell
&rSh
= GetShell();
614 SdrView
*pSdrView
= rSh
.GetDrawView();
615 const SdrMarkList
& rMarkList
= pSdrView
->GetMarkedObjectList();
616 OSL_ENSURE(rMarkList
.GetMarkCount() == 1, "wrong draw selection");
617 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
618 const String sCurrentName
= pObj
->GetName();
620 pNameDialog
->GetName(sNewName
);
622 if(!sNewName
.Len() || sCurrentName
== sNewName
)
627 SdrModel
* pModel
= rSh
.getIDocumentDrawModelAccess()->GetDrawModel();
628 SdrObjListIter
aIter( *(pModel
->GetPage(0)), IM_DEEPWITHGROUPS
);
629 while( aIter
.IsMore() )
631 SdrObject
* pTempObj
= aIter
.Next();
632 if ( pObj
!= pTempObj
&& pTempObj
->GetName().equals(sNewName
) )
642 void SwDrawBaseShell::GetState(SfxItemSet
& rSet
)
644 SwWrtShell
&rSh
= GetShell();
645 SdrView
* pSdrView
= rSh
.GetDrawViewWithValidMarkList();
646 SfxWhichIter
aIter( rSet
);
647 sal_uInt16 nWhich
= aIter
.FirstWhich();
648 sal_Bool bProtected
= rSh
.IsSelObjProtected(FLYPROTECT_CONTENT
);
650 if (!bProtected
) // Look in the parent
651 bProtected
|= rSh
.IsSelObjProtected( FLYPROTECT_CONTENT
|FLYPROTECT_PARENT
) != 0;
657 case FN_DRAW_WRAP_DLG
:
658 case SID_ATTR_TRANSFORM
:
659 case SID_FRAME_TO_TOP
:
660 case SID_FRAME_TO_BOTTOM
:
665 if( bProtected
|| !rSh
.IsObjSelected() )
666 rSet
.DisableItem( nWhich
);
669 if ( rSh
.IsObjSelected() < 2 || bProtected
|| !rSh
.IsGroupAllowed() )
670 rSet
.DisableItem( nWhich
);
673 if ( !rSh
.IsGroupSelected() || bProtected
)
674 rSet
.DisableItem( nWhich
);
676 case SID_ENTER_GROUP
:
677 if ( !rSh
.IsGroupSelected() )
678 rSet
.DisableItem( nWhich
);
680 case SID_LEAVE_GROUP
:
681 if ( !pSdrView
->IsGroupEntered() )
682 rSet
.DisableItem( nWhich
);
684 case SID_OBJECT_ALIGN_LEFT
:
685 case SID_OBJECT_ALIGN_CENTER
:
686 case SID_OBJECT_ALIGN_RIGHT
:
687 case SID_OBJECT_ALIGN_UP
:
688 case SID_OBJECT_ALIGN_MIDDLE
:
689 case SID_OBJECT_ALIGN_DOWN
:
690 case SID_OBJECT_ALIGN
:
691 if ( !rSh
.IsAlignPossible() || bProtected
)
692 rSet
.DisableItem( nWhich
);
695 SfxAllEnumItem
aEnumItem(nWhich
, USHRT_MAX
);
696 const SdrMarkList
& rMarkList
= pSdrView
->GetMarkedObjectList();
697 //if only one object is selected it can only be vertically
698 // aligned because it is character bound
699 if( rMarkList
.GetMarkCount() == 1 )
701 aEnumItem
.DisableValue(SID_OBJECT_ALIGN_LEFT
);
702 aEnumItem
.DisableValue(SID_OBJECT_ALIGN_CENTER
);
703 aEnumItem
.DisableValue(SID_OBJECT_ALIGN_RIGHT
);
711 if(1L != pSdrView
->GetMarkedObjectCount())
713 rSet
.DisableItem( nWhich
);
719 case FN_TITLE_DESCRIPTION_SHAPE
:
721 const bool bIsWebView(NULL
!= dynamic_cast<SwWebView
*>(&GetView()));
723 if(!bIsWebView
&& 1L != pSdrView
->GetMarkedObjectCount())
725 rSet
.DisableItem( nWhich
);
730 nWhich
= aIter
.NextWhich();
734 void SwDrawBaseShell::GetDrawAttrStateForIFBX( SfxItemSet
& rSet
)
736 SwWrtShell
*pSh
= &GetShell();
737 SdrView
* pSdrView
= pSh
->GetDrawView();
738 const SdrMarkList
& rMarkList
= pSdrView
->GetMarkedObjectList();
739 if( rMarkList
.GetMark(0) != 0 )
741 SfxItemSet
aNewAttr(pSdrView
->GetGeoAttrFromMarked());
742 rSet
.Put(aNewAttr
,false);
746 sal_Bool
SwDrawBaseShell::Disable(SfxItemSet
& rSet
, sal_uInt16 nWhich
)
748 sal_Bool bDisable
= GetShell().IsSelObjProtected(FLYPROTECT_CONTENT
);
753 rSet
.DisableItem( nWhich
);
756 SfxWhichIter
aIter( rSet
);
757 nWhich
= aIter
.FirstWhich();
760 rSet
.DisableItem( nWhich
);
761 nWhich
= aIter
.NextWhich();
769 // Validate of drawing positions
771 IMPL_LINK(SwDrawBaseShell
, ValidatePosition
, SvxSwFrameValidation
*, pValidation
)
773 SwWrtShell
*pSh
= &GetShell();
774 pValidation
->nMinHeight
= MINFLY
;
775 pValidation
->nMinWidth
= MINFLY
;
779 // OD 18.09.2003 #i18732# - adjustment for allowing vertical position
780 // aligned to page for fly frame anchored to paragraph or to character.
781 const RndStdIds eAnchorType
= static_cast<RndStdIds
>(pValidation
->nAnchorType
);
782 const SwPosition
* pCntntPos
= 0;
783 SdrView
* pSdrView
= pSh
->GetDrawView();
784 const SdrMarkList
& rMarkList
= pSdrView
->GetMarkedObjectList();
785 if( rMarkList
.GetMarkCount() == 1 )
787 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
788 SwFrmFmt
* pFrmFmt
= FindFrmFmt( pObj
);
789 pCntntPos
= pFrmFmt
->GetAnchor().GetCntntAnchor();
792 pSh
->CalcBoundRect( aBoundRect
, eAnchorType
,
793 pValidation
->nHRelOrient
,
794 pValidation
->nVRelOrient
,
796 pValidation
->bFollowTextFlow
,
797 pValidation
->bMirror
, NULL
, &pValidation
->aPercentSize
);
799 sal_Bool
bIsInVertical( sal_False
);
803 bIsInVertical
= pSh
->IsFrmVertical(sal_True
, bRTL
, bVertL2R
);
807 Point
aPos(aBoundRect
.Pos());
808 long nTmp
= aPos
.X();
811 Size
aSize(aBoundRect
.SSize());
812 nTmp
= aSize
.Width();
813 aSize
.Width() = aSize
.Height();
814 aSize
.Height() = nTmp
;
815 aBoundRect
.Chg( aPos
, aSize
);
816 //exchange width/height to enable correct values
817 nTmp
= pValidation
->nWidth
;
818 pValidation
->nWidth
= pValidation
->nHeight
;
819 pValidation
->nHeight
= nTmp
;
821 if ((eAnchorType
== FLY_AT_PAGE
) || (eAnchorType
== FLY_AT_FLY
))
824 pValidation
->nMinHPos
= aBoundRect
.Left();
825 pValidation
->nMinVPos
= aBoundRect
.Top();
826 SwTwips nH
= pValidation
->nHPos
;
827 SwTwips nV
= pValidation
->nVPos
;
829 if (pValidation
->nHPos
+ pValidation
->nWidth
> aBoundRect
.Right())
831 if (pValidation
->nHoriOrient
== text::HoriOrientation::NONE
)
833 pValidation
->nHPos
-= ((pValidation
->nHPos
+ pValidation
->nWidth
) - aBoundRect
.Right());
834 nH
= pValidation
->nHPos
;
837 pValidation
->nWidth
= aBoundRect
.Right() - pValidation
->nHPos
;
840 if (pValidation
->nHPos
+ pValidation
->nWidth
> aBoundRect
.Right())
841 pValidation
->nWidth
= aBoundRect
.Right() - pValidation
->nHPos
;
843 if (pValidation
->nVPos
+ pValidation
->nHeight
> aBoundRect
.Bottom())
845 if (pValidation
->nVertOrient
== text::VertOrientation::NONE
)
847 pValidation
->nVPos
-= ((pValidation
->nVPos
+ pValidation
->nHeight
) - aBoundRect
.Bottom());
848 nV
= pValidation
->nVPos
;
851 pValidation
->nHeight
= aBoundRect
.Bottom() - pValidation
->nVPos
;
854 if (pValidation
->nVPos
+ pValidation
->nHeight
> aBoundRect
.Bottom())
855 pValidation
->nHeight
= aBoundRect
.Bottom() - pValidation
->nVPos
;
857 if ( pValidation
->nVertOrient
!= text::VertOrientation::NONE
)
858 nV
= aBoundRect
.Top();
860 if ( pValidation
->nHoriOrient
!= text::HoriOrientation::NONE
)
861 nH
= aBoundRect
.Left();
863 pValidation
->nMaxHPos
= aBoundRect
.Right() - pValidation
->nWidth
;
864 pValidation
->nMaxHeight
= aBoundRect
.Bottom() - nV
;
866 pValidation
->nMaxVPos
= aBoundRect
.Bottom() - pValidation
->nHeight
;
867 pValidation
->nMaxWidth
= aBoundRect
.Right() - nH
;
869 else if ((eAnchorType
== FLY_AT_PARA
) || (eAnchorType
== FLY_AT_CHAR
))
871 if (pValidation
->nHPos
+ pValidation
->nWidth
> aBoundRect
.Right())
873 if (pValidation
->nHoriOrient
== text::HoriOrientation::NONE
)
875 pValidation
->nHPos
-= ((pValidation
->nHPos
+ pValidation
->nWidth
) - aBoundRect
.Right());
878 pValidation
->nWidth
= aBoundRect
.Right() - pValidation
->nHPos
;
881 // OD 29.09.2003 #i17567#, #i18732# - consider following the text flow
882 // and alignment at page areas.
883 const bool bMaxVPosAtBottom
= !pValidation
->bFollowTextFlow
||
884 pValidation
->nVRelOrient
== text::RelOrientation::PAGE_FRAME
||
885 pValidation
->nVRelOrient
== text::RelOrientation::PAGE_PRINT_AREA
;
887 SwTwips nTmpMaxVPos
= ( bMaxVPosAtBottom
888 ? aBoundRect
.Bottom()
889 : aBoundRect
.Height() ) -
890 pValidation
->nHeight
;
891 if ( pValidation
->nVPos
> nTmpMaxVPos
)
893 if (pValidation
->nVertOrient
== text::VertOrientation::NONE
)
895 pValidation
->nVPos
= nTmpMaxVPos
;
899 pValidation
->nHeight
= ( bMaxVPosAtBottom
900 ? aBoundRect
.Bottom()
901 : aBoundRect
.Height() ) - pValidation
->nVPos
;
906 pValidation
->nMinHPos
= aBoundRect
.Left();
907 pValidation
->nMaxHPos
= aBoundRect
.Right() - pValidation
->nWidth
;
909 pValidation
->nMinVPos
= aBoundRect
.Top();
910 // OD 26.09.2003 #i17567#, #i18732# - determine maximum vertical position
911 if ( bMaxVPosAtBottom
)
913 pValidation
->nMaxVPos
= aBoundRect
.Bottom() - pValidation
->nHeight
;
917 pValidation
->nMaxVPos
= aBoundRect
.Height() - pValidation
->nHeight
;
920 // Maximum width height
921 const SwTwips nH
= ( pValidation
->nHoriOrient
!= text::HoriOrientation::NONE
)
923 : pValidation
->nHPos
;
924 const SwTwips nV
= ( pValidation
->nVertOrient
!= text::VertOrientation::NONE
)
926 : pValidation
->nVPos
;
927 pValidation
->nMaxHeight
= pValidation
->nMaxVPos
+ pValidation
->nHeight
- nV
;
928 pValidation
->nMaxWidth
= pValidation
->nMaxHPos
+ pValidation
->nWidth
- nH
;
930 else if (eAnchorType
== FLY_AS_CHAR
)
932 pValidation
->nMinHPos
= 0;
933 pValidation
->nMaxHPos
= 0;
935 pValidation
->nMaxHeight
= aBoundRect
.Height();
936 pValidation
->nMaxWidth
= aBoundRect
.Width();
938 pValidation
->nMaxVPos
= aBoundRect
.Height();
939 pValidation
->nMinVPos
= -aBoundRect
.Height() + pValidation
->nHeight
;
940 if (pValidation
->nMaxVPos
< pValidation
->nMinVPos
)
942 pValidation
->nMinVPos
= pValidation
->nMaxVPos
;
943 pValidation
->nMaxVPos
= -aBoundRect
.Height();
948 //restore width/height exchange
949 long nTmp
= pValidation
->nWidth
;
950 pValidation
->nWidth
= pValidation
->nHeight
;
951 pValidation
->nHeight
= nTmp
;
954 if (pValidation
->nMaxWidth
< pValidation
->nWidth
)
955 pValidation
->nWidth
= pValidation
->nMaxWidth
;
956 if (pValidation
->nMaxHeight
< pValidation
->nHeight
)
957 pValidation
->nHeight
= pValidation
->nMaxHeight
;
961 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */