xref: /aoo41x/main/sw/source/ui/shells/drwbassh.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <tools/shl.hxx>
29cdf0e10cSrcweir #include <hintids.hxx>
30cdf0e10cSrcweir #include <helpid.h>
31cdf0e10cSrcweir #include <swtypes.hxx>
32cdf0e10cSrcweir #include <sfx2/objface.hxx>
33cdf0e10cSrcweir #include <sfx2/request.hxx>
34cdf0e10cSrcweir #include <sfx2/bindings.hxx>
35cdf0e10cSrcweir #include <svl/aeitem.hxx>
36cdf0e10cSrcweir #include <svx/svdview.hxx>
37cdf0e10cSrcweir #include <vcl/msgbox.hxx>
38cdf0e10cSrcweir #include <svl/srchitem.hxx>
39cdf0e10cSrcweir #include <svl/whiter.hxx>
40cdf0e10cSrcweir #include <svx/swframevalidation.hxx>
41cdf0e10cSrcweir #include <svx/anchorid.hxx>
42cdf0e10cSrcweir #include <svx/htmlmode.hxx>
43cdf0e10cSrcweir #include <uitool.hxx>
44cdf0e10cSrcweir #include <fmtornt.hxx>
45cdf0e10cSrcweir #include <cmdid.h>
46cdf0e10cSrcweir #include <swmodule.hxx>
47cdf0e10cSrcweir #include <wrtsh.hxx>
48cdf0e10cSrcweir #include <wview.hxx>
49cdf0e10cSrcweir #include <edtwin.hxx>
50cdf0e10cSrcweir #include <viewopt.hxx>
51cdf0e10cSrcweir #include <dcontact.hxx>
52cdf0e10cSrcweir #include <frmfmt.hxx>
53cdf0e10cSrcweir #include <wrap.hxx>
54cdf0e10cSrcweir #include <drawbase.hxx>
55cdf0e10cSrcweir #include <drwbassh.hxx>
56cdf0e10cSrcweir #include <swdtflvr.hxx>
57cdf0e10cSrcweir #include <svx/svdogrp.hxx>
58cdf0e10cSrcweir #include <svx/svdpage.hxx>
59cdf0e10cSrcweir #include <svx/svditer.hxx>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #include <shells.hrc>
62cdf0e10cSrcweir #define SwDrawBaseShell
63cdf0e10cSrcweir #include <sfx2/msg.hxx>
64cdf0e10cSrcweir #include <swslots.hxx>
65cdf0e10cSrcweir #include <svx/svxdlg.hxx>
66cdf0e10cSrcweir #include <svx/dialogs.hrc>
67cdf0e10cSrcweir #include "swabstdlg.hxx"
68cdf0e10cSrcweir #include "dialog.hrc"
69cdf0e10cSrcweir #include <swundo.hxx>
70cdf0e10cSrcweir #include <com/sun/star/text/HoriOrientation.hpp>
71cdf0e10cSrcweir #include <com/sun/star/text/VertOrientation.hpp>
72cdf0e10cSrcweir #include <com/sun/star/text/RelOrientation.hpp>
73cdf0e10cSrcweir 
74cdf0e10cSrcweir #include <IDocumentDrawModelAccess.hxx>
75cdf0e10cSrcweir 
76cdf0e10cSrcweir using namespace ::com::sun::star;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir SFX_IMPL_INTERFACE(SwDrawBaseShell, SwBaseShell, SW_RES(0))
79cdf0e10cSrcweir {
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir TYPEINIT1(SwDrawBaseShell,SwBaseShell)
83cdf0e10cSrcweir 
84cdf0e10cSrcweir /*--------------------------------------------------------------------
85cdf0e10cSrcweir 	Beschreibung:
86cdf0e10cSrcweir  --------------------------------------------------------------------*/
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 
89cdf0e10cSrcweir SwDrawBaseShell::SwDrawBaseShell(SwView &_rView):
90cdf0e10cSrcweir     SwBaseShell( _rView )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	GetShell().NoEdit(sal_True);
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	SwEditWin& rWin = GetView().GetEditWin();
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	rWin.SetBezierMode(SID_BEZIER_MOVE);
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     if ( !_rView.GetDrawFuncPtr() )
99cdf0e10cSrcweir         _rView.GetEditWin().StdDrawMode( OBJ_NONE, sal_True );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	SwTransferable::CreateSelection( GetShell() );
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir /*--------------------------------------------------------------------
105cdf0e10cSrcweir 	Beschreibung:
106cdf0e10cSrcweir  --------------------------------------------------------------------*/
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 
109cdf0e10cSrcweir SwDrawBaseShell::~SwDrawBaseShell()
110cdf0e10cSrcweir {
111cdf0e10cSrcweir 	GetView().ExitDraw();
112cdf0e10cSrcweir 	GetShell().Edit();
113cdf0e10cSrcweir 	SwTransferable::ClearSelection( GetShell() );
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir /*--------------------------------------------------------------------
117cdf0e10cSrcweir 	Beschreibung:
118cdf0e10cSrcweir  --------------------------------------------------------------------*/
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 
121cdf0e10cSrcweir void SwDrawBaseShell::Execute(SfxRequest &rReq)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir 	SwWrtShell *pSh = &GetShell();
124cdf0e10cSrcweir 	SdrView*	pSdrView = pSh->GetDrawView();
125cdf0e10cSrcweir 	const SfxItemSet *pArgs = rReq.GetArgs();
126cdf0e10cSrcweir 	sal_uInt16		nSlotId = rReq.GetSlot();
127cdf0e10cSrcweir 	sal_Bool		bChanged = pSdrView->GetModel()->IsChanged();
128cdf0e10cSrcweir 	pSdrView->GetModel()->SetChanged(sal_False);
129cdf0e10cSrcweir 	const SfxPoolItem* pItem = 0;
130cdf0e10cSrcweir 	if(pArgs)
131cdf0e10cSrcweir 		pArgs->GetItemState(nSlotId, sal_False, &pItem);
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	//Sonderfall Align per Menue
134cdf0e10cSrcweir 	if(pItem && nSlotId == SID_OBJECT_ALIGN)
135cdf0e10cSrcweir 	{
136cdf0e10cSrcweir 		DBG_ASSERT(PTR_CAST(SfxEnumItem, pItem),"SfxEnumItem erwartet");
137cdf0e10cSrcweir         nSlotId = nSlotId + ((const SfxEnumItem*)pItem)->GetValue();
138cdf0e10cSrcweir 		nSlotId++;
139cdf0e10cSrcweir 	}
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	sal_Bool bAlignPossible = pSh->IsAlignPossible();
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 	sal_Bool bTopParam = sal_True, bBottomParam = sal_True;
144cdf0e10cSrcweir 	sal_Bool bNotify = sal_False;
145cdf0e10cSrcweir 	sal_Bool bDone = sal_False;
146cdf0e10cSrcweir 	SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	switch (nSlotId)
149cdf0e10cSrcweir 	{
150cdf0e10cSrcweir 		case FN_DRAW_WRAP_DLG:
151cdf0e10cSrcweir 		{
152cdf0e10cSrcweir 			if(pSdrView->AreObjectsMarked())
153cdf0e10cSrcweir 			{
154cdf0e10cSrcweir 				if(!pArgs)
155cdf0e10cSrcweir 				{
156cdf0e10cSrcweir 					const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
157cdf0e10cSrcweir 					if( rMarkList.GetMark(0) != 0 )
158cdf0e10cSrcweir 					{
159cdf0e10cSrcweir 						SfxItemSet aSet(GetPool(),	RES_SURROUND, RES_SURROUND,
160cdf0e10cSrcweir 													RES_ANCHOR, RES_ANCHOR,
161cdf0e10cSrcweir 													RES_LR_SPACE, RES_UL_SPACE,
162cdf0e10cSrcweir 													SID_HTML_MODE, SID_HTML_MODE,
163cdf0e10cSrcweir 													FN_DRAW_WRAP_DLG, FN_DRAW_WRAP_DLG,
164cdf0e10cSrcweir 													0);
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 						aSet.Put(SfxBoolItem(SID_HTML_MODE,
167cdf0e10cSrcweir 							0 != ::GetHtmlMode(pSh->GetView().GetDocShell())));
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 						aSet.Put(SfxInt16Item(FN_DRAW_WRAP_DLG, pSh->GetLayerId()));
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 						pSh->GetObjAttr(aSet);
172cdf0e10cSrcweir                         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
173cdf0e10cSrcweir                         DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
174cdf0e10cSrcweir 
175cdf0e10cSrcweir                         SfxAbstractDialog* pDlg = pFact->CreateSwWrapDlg( GetView().GetWindow(), aSet, pSh, sal_True, RC_DLG_SWWRAPDLG );
176cdf0e10cSrcweir                         DBG_ASSERT(pDlg, "Dialogdiet fail!");
177cdf0e10cSrcweir 
178cdf0e10cSrcweir                         if (pDlg->Execute() == RET_OK)
179cdf0e10cSrcweir 						{
180cdf0e10cSrcweir                             const SfxPoolItem* pWrapItem;
181cdf0e10cSrcweir                             const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
182cdf0e10cSrcweir                             if(SFX_ITEM_SET == pOutSet->GetItemState(FN_DRAW_WRAP_DLG, sal_False, &pWrapItem))
183cdf0e10cSrcweir 							{
184cdf0e10cSrcweir                                 short nLayer = ((const SfxInt16Item*)pWrapItem)->GetValue();
185cdf0e10cSrcweir 								if (nLayer == 1)
186cdf0e10cSrcweir 									pSh->SelectionToHeaven();
187cdf0e10cSrcweir 								else
188cdf0e10cSrcweir 									pSh->SelectionToHell();
189cdf0e10cSrcweir 							}
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 							pSh->SetObjAttr(*pOutSet);
192cdf0e10cSrcweir 						}
193cdf0e10cSrcweir                     delete pDlg;
194cdf0e10cSrcweir 					}
195cdf0e10cSrcweir 				}
196cdf0e10cSrcweir 			}
197cdf0e10cSrcweir 		}
198cdf0e10cSrcweir 		break;
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 		case SID_ATTR_TRANSFORM:
201cdf0e10cSrcweir 		{
202cdf0e10cSrcweir 			if(pSdrView->AreObjectsMarked())
203cdf0e10cSrcweir 			{
204cdf0e10cSrcweir 				if(!pArgs)
205cdf0e10cSrcweir 				{
206cdf0e10cSrcweir 					const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
207cdf0e10cSrcweir 					if( rMarkList.GetMark(0) != 0 )
208cdf0e10cSrcweir 					{
209cdf0e10cSrcweir 						SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
210cdf0e10cSrcweir                         SfxAbstractTabDialog *pDlg=NULL;
211cdf0e10cSrcweir 						sal_Bool bCaption = sal_False;
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 						// Erlaubte Verankerungen:
214cdf0e10cSrcweir                         short nAnchor = pSh->GetAnchorId();
215cdf0e10cSrcweir 						sal_uInt16 nAllowedAnchors = SVX_OBJ_AT_CNTNT|SVX_OBJ_IN_CNTNT;
216cdf0e10cSrcweir 						sal_uInt16 nHtmlMode = ::GetHtmlMode(pSh->GetView().GetDocShell());
217cdf0e10cSrcweir 
218cdf0e10cSrcweir                         if( !((HTMLMODE_ON & nHtmlMode) && (0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS))) )
219cdf0e10cSrcweir 							nAllowedAnchors |= SVX_OBJ_PAGE;
220cdf0e10cSrcweir 						if ( pSh->IsFlyInFly() )
221cdf0e10cSrcweir 							nAllowedAnchors |= SVX_OBJ_AT_FLY;
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 						if (pObj->GetObjIdentifier() == OBJ_CAPTION )
224cdf0e10cSrcweir 							bCaption = sal_True;
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 						if (bCaption)
227cdf0e10cSrcweir                         {
228cdf0e10cSrcweir 							SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
229cdf0e10cSrcweir 							if ( pFact )
230cdf0e10cSrcweir 							{
231cdf0e10cSrcweir                                 AbstractSvxCaptionDialog* pCaptionDlg =
232cdf0e10cSrcweir                                         pFact->CreateCaptionDialog( NULL, pSdrView, nAllowedAnchors );
233cdf0e10cSrcweir                                 pCaptionDlg->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) );
234cdf0e10cSrcweir                                 pDlg = pCaptionDlg;
235cdf0e10cSrcweir                                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
236cdf0e10cSrcweir 							}
237cdf0e10cSrcweir 						}
238cdf0e10cSrcweir 						else
239cdf0e10cSrcweir 						{
240cdf0e10cSrcweir 							SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
241cdf0e10cSrcweir 							if ( pFact )
242cdf0e10cSrcweir 							{
243cdf0e10cSrcweir 
244cdf0e10cSrcweir                                 AbstractSvxTransformTabDialog* pTransform =
245cdf0e10cSrcweir                                             pFact->CreateSvxTransformTabDialog( NULL, NULL, pSdrView, nAllowedAnchors );
246cdf0e10cSrcweir                                 pTransform->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) );
247cdf0e10cSrcweir                                 pDlg = pTransform;
248cdf0e10cSrcweir                                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
249cdf0e10cSrcweir 							}
250cdf0e10cSrcweir 						}
251cdf0e10cSrcweir 						SfxItemSet aNewAttr(pSdrView->GetGeoAttrFromMarked());
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 						const sal_uInt16* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
254cdf0e10cSrcweir 						SfxItemSet aSet( *aNewAttr.GetPool(), pRange );
255cdf0e10cSrcweir                         FieldUnit eMetric = ::GetDfltMetric(0 != dynamic_cast<SwWebView*>(&GetView()));
256cdf0e10cSrcweir                         SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 						aSet.Put( aNewAttr, sal_False );
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 						if (bCaption)
261cdf0e10cSrcweir 							pSdrView->GetAttributes( aSet );
262cdf0e10cSrcweir 
263cdf0e10cSrcweir                         aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR, nAnchor));
264cdf0e10cSrcweir                         sal_Bool bRTL;
265cdf0e10cSrcweir                         sal_Bool bVertL2R;
266cdf0e10cSrcweir                         aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT, pSh->IsFrmVertical(sal_True, bRTL, bVertL2R)));
267cdf0e10cSrcweir                         aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_RTL_TEXT, bRTL));
268cdf0e10cSrcweir 
269cdf0e10cSrcweir                         SwFrmFmt* pFrmFmt = FindFrmFmt( pObj );
270cdf0e10cSrcweir 
271cdf0e10cSrcweir                         aSet.Put( pFrmFmt->GetFmtAttr(RES_FOLLOW_TEXT_FLOW) );
272cdf0e10cSrcweir 
273cdf0e10cSrcweir                         SwFmtVertOrient aVOrient((const SwFmtVertOrient&)pFrmFmt->GetFmtAttr(RES_VERT_ORIENT));
274cdf0e10cSrcweir                         aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_ORIENT, aVOrient.GetVertOrient()));
275cdf0e10cSrcweir                         aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_RELATION, aVOrient.GetRelationOrient() ));
276cdf0e10cSrcweir                         aSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_VERT_POSITION, aVOrient.GetPos()));
277cdf0e10cSrcweir 
278cdf0e10cSrcweir                         SwFmtHoriOrient aHOrient((const SwFmtHoriOrient&)pFrmFmt->GetFmtAttr(RES_HORI_ORIENT));
279cdf0e10cSrcweir                         aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_ORIENT, aHOrient.GetHoriOrient()));
280cdf0e10cSrcweir                         aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_RELATION, aHOrient.GetRelationOrient() ));
281cdf0e10cSrcweir                         aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR, aHOrient.IsPosToggle()));
282cdf0e10cSrcweir                         aSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION, aHOrient.GetPos()));
283cdf0e10cSrcweir 
284cdf0e10cSrcweir                         aSet.Put(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 						pDlg->SetInputSet( &aSet );
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 						if (pDlg->Execute() == RET_OK)
289cdf0e10cSrcweir 						{
290cdf0e10cSrcweir 							const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
291cdf0e10cSrcweir 							pSh->StartAllAction();
292cdf0e10cSrcweir 
293cdf0e10cSrcweir                             // --> OD 2004-07-14 #i30451#
294cdf0e10cSrcweir                             pSh->StartUndo(UNDO_INSFMTATTR);
295cdf0e10cSrcweir 
296cdf0e10cSrcweir                             pSdrView->SetGeoAttrToMarked(*pOutSet);
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 							if (bCaption)
299cdf0e10cSrcweir 								pSdrView->SetAttributes(*pOutSet);
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 							sal_Bool bPosCorr =
302cdf0e10cSrcweir 								SFX_ITEM_SET != pOutSet->GetItemState(
303cdf0e10cSrcweir 									SID_ATTR_TRANSFORM_POS_X, sal_False ) &&
304cdf0e10cSrcweir 								SFX_ITEM_SET != pOutSet->GetItemState(
305cdf0e10cSrcweir 									SID_ATTR_TRANSFORM_POS_Y, sal_False );
306cdf0e10cSrcweir 
307cdf0e10cSrcweir                             SfxItemSet aFrmAttrSet(GetPool(), RES_FRMATR_BEGIN, RES_FRMATR_END - 1);
308cdf0e10cSrcweir 
309cdf0e10cSrcweir                             bool bSingleSelection = rMarkList.GetMarkCount() == 1;
310cdf0e10cSrcweir 
311cdf0e10cSrcweir                             const SfxPoolItem* pAnchorItem;
312cdf0e10cSrcweir                             if(SFX_ITEM_SET == pOutSet->GetItemState(
313cdf0e10cSrcweir                                 SID_ATTR_TRANSFORM_ANCHOR, sal_False, &pAnchorItem))
314cdf0e10cSrcweir                             {
315cdf0e10cSrcweir                                 if(!bSingleSelection)
316cdf0e10cSrcweir                                     pSh->ChgAnchor(((const SfxInt16Item*)pAnchorItem)
317cdf0e10cSrcweir                                             ->GetValue(), sal_False, bPosCorr );
318cdf0e10cSrcweir                                 else
319cdf0e10cSrcweir                                 {
320cdf0e10cSrcweir                                     SwFmtAnchor aAnchor(pFrmFmt->GetAnchor());
321cdf0e10cSrcweir                                     aAnchor.SetType((RndStdIds)((const SfxInt16Item*)pAnchorItem)->GetValue());
322cdf0e10cSrcweir                                     aFrmAttrSet.Put( aAnchor );
323cdf0e10cSrcweir                                 }
324cdf0e10cSrcweir                             }
325cdf0e10cSrcweir                             const SfxPoolItem* pHoriOrient = 0;
326cdf0e10cSrcweir                             const SfxPoolItem* pHoriRelation = 0;
327cdf0e10cSrcweir                             const SfxPoolItem* pHoriPosition = 0;
328cdf0e10cSrcweir                             const SfxPoolItem* pHoriMirror = 0;
329cdf0e10cSrcweir                             pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_ORIENT, sal_False, &pHoriOrient);
330cdf0e10cSrcweir                             pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_RELATION, sal_False, &pHoriRelation);
331cdf0e10cSrcweir                             pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_POSITION, sal_False, &pHoriPosition);
332cdf0e10cSrcweir                             pOutSet->GetItemState(SID_ATTR_TRANSFORM_HORI_MIRROR, sal_False, &pHoriMirror);
333cdf0e10cSrcweir                             if(pHoriOrient || pHoriRelation || pHoriPosition || pHoriMirror)
334cdf0e10cSrcweir                             {
335cdf0e10cSrcweir                                 if(pHoriOrient)
336cdf0e10cSrcweir                                     aHOrient.SetHoriOrient(
337cdf0e10cSrcweir                                           static_cast<const SfxInt16Item*>(pHoriOrient)->GetValue());
338cdf0e10cSrcweir                                 if(pHoriRelation)
339cdf0e10cSrcweir                                     aHOrient.SetRelationOrient(
340cdf0e10cSrcweir                                               static_cast<const SfxInt16Item*>(pHoriRelation)->GetValue());
341cdf0e10cSrcweir                                 if(pHoriPosition)
342cdf0e10cSrcweir                                     aHOrient.SetPos( static_cast<const SfxInt32Item*>(pHoriPosition)->GetValue());
343cdf0e10cSrcweir                                 if(pHoriMirror)
344cdf0e10cSrcweir                                     aHOrient.SetPosToggle( static_cast<const SfxBoolItem*>(pHoriMirror)->GetValue());
345cdf0e10cSrcweir                                 aFrmAttrSet.Put(aHOrient);
346cdf0e10cSrcweir                             }
347cdf0e10cSrcweir 
348cdf0e10cSrcweir                             const SfxPoolItem* pVertOrient = 0;
349cdf0e10cSrcweir                             const SfxPoolItem* pVertRelation = 0;
350cdf0e10cSrcweir                             const SfxPoolItem* pVertPosition = 0;
351cdf0e10cSrcweir                             pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_ORIENT, sal_False, &pVertOrient);
352cdf0e10cSrcweir                             pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_RELATION, sal_False, &pVertRelation);
353cdf0e10cSrcweir                             pOutSet->GetItemState(SID_ATTR_TRANSFORM_VERT_POSITION, sal_False, &pVertPosition);
354cdf0e10cSrcweir                             if(pVertOrient || pVertRelation || pVertPosition )
355cdf0e10cSrcweir                             {
356cdf0e10cSrcweir                                 if(pVertOrient)
357cdf0e10cSrcweir                                     aVOrient.SetVertOrient(
358cdf0e10cSrcweir                                         static_cast<const SfxInt16Item*>(pVertOrient)->GetValue());
359cdf0e10cSrcweir                                 if(pVertRelation)
360cdf0e10cSrcweir                                     aVOrient.SetRelationOrient(
361cdf0e10cSrcweir                                         static_cast<const SfxInt16Item*>(pVertRelation)->GetValue());
362cdf0e10cSrcweir                                 if(pVertPosition)
363cdf0e10cSrcweir                                     aVOrient.SetPos( static_cast<const SfxInt32Item*>(pVertPosition)->GetValue());
364cdf0e10cSrcweir                                 aFrmAttrSet.Put( aVOrient );
365cdf0e10cSrcweir                             }
366cdf0e10cSrcweir                             const SfxPoolItem* pFollowItem = 0;
367cdf0e10cSrcweir                             pOutSet->GetItemState(RES_FOLLOW_TEXT_FLOW, sal_False, &pFollowItem);
368cdf0e10cSrcweir                             if(pFollowItem)
369cdf0e10cSrcweir                                 aFrmAttrSet.Put(*pFollowItem);
370cdf0e10cSrcweir 
371cdf0e10cSrcweir                             if(aFrmAttrSet.Count())
372cdf0e10cSrcweir                                 pSh->SetDrawingAttr(aFrmAttrSet);
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 							rBind.InvalidateAll(sal_False);
375cdf0e10cSrcweir 
376cdf0e10cSrcweir                             // --> OD 2004-07-14 #i30451#
377cdf0e10cSrcweir                             pSh->EndUndo( UNDO_INSFMTATTR );
378cdf0e10cSrcweir 
379cdf0e10cSrcweir                             pSh->EndAllAction();
380cdf0e10cSrcweir 						}
381cdf0e10cSrcweir 						delete pDlg;
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 					}
384cdf0e10cSrcweir 				}
385cdf0e10cSrcweir 			}
386cdf0e10cSrcweir 		}
387cdf0e10cSrcweir 		break;
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 		case SID_DELETE:
390cdf0e10cSrcweir 		case FN_BACKSPACE:
391cdf0e10cSrcweir 			if (pSh->IsObjSelected() && !pSdrView->IsTextEdit())
392cdf0e10cSrcweir 			{
393cdf0e10cSrcweir 				bDone = sal_True;
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 				if( GetView().IsDrawRotate() )
396cdf0e10cSrcweir 				{
397cdf0e10cSrcweir 					pSh->SetDragMode( SDRDRAG_MOVE );
398cdf0e10cSrcweir 					GetView().FlipDrawRotate();
399cdf0e10cSrcweir 				}
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 				pSh->SetModified();
402cdf0e10cSrcweir 				pSh->DelSelectedObj();
403cdf0e10cSrcweir 
404cdf0e10cSrcweir                 if (rReq.IsAPI() ||
405cdf0e10cSrcweir                     GetView().GetEditWin().IsObjectSelect() )
406cdf0e10cSrcweir 				{
407cdf0e10cSrcweir                     // Wenn Basic-Aufruf, dann zurueck in die Textshell, da das
408cdf0e10cSrcweir                     // Basic sonst keine Rueckkehrmoeglichkeit hat.
409cdf0e10cSrcweir 					if (GetView().GetDrawFuncPtr())
410cdf0e10cSrcweir 					{
411cdf0e10cSrcweir 						GetView().GetDrawFuncPtr()->Deactivate();
412cdf0e10cSrcweir 						GetView().SetDrawFuncPtr(NULL);
413cdf0e10cSrcweir 					}
414cdf0e10cSrcweir 					GetView().LeaveDrawCreate();	// In Selektionsmode wechseln
415cdf0e10cSrcweir 				}
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 				if (pSh->IsSelFrmMode())
418cdf0e10cSrcweir 				{
419cdf0e10cSrcweir 					pSh->LeaveSelFrmMode();
420cdf0e10cSrcweir                     // #105852# FME
421cdf0e10cSrcweir //                   pSh->NoEdit();
422cdf0e10cSrcweir 				}
423cdf0e10cSrcweir 				bNotify = sal_True;
424cdf0e10cSrcweir 			}
425cdf0e10cSrcweir 			break;
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 		case SID_GROUP:
428cdf0e10cSrcweir 			if (pSh->IsObjSelected() > 1 && pSh->IsGroupAllowed())
429cdf0e10cSrcweir 			{
430cdf0e10cSrcweir 				pSh->GroupSelection();	// Objekt gruppieren
431cdf0e10cSrcweir 				rBind.Invalidate(SID_UNGROUP);
432cdf0e10cSrcweir 			}
433cdf0e10cSrcweir 			break;
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 		case SID_UNGROUP:
436cdf0e10cSrcweir 			if (pSh->IsGroupSelected())
437cdf0e10cSrcweir 			{
438cdf0e10cSrcweir 				pSh->UnGroupSelection();	// Objektgruppierung aufheben
439cdf0e10cSrcweir 				rBind.Invalidate(SID_GROUP);
440cdf0e10cSrcweir 			}
441cdf0e10cSrcweir 			break;
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 		case SID_ENTER_GROUP:
444cdf0e10cSrcweir 			if (pSh->IsGroupSelected())
445cdf0e10cSrcweir 			{
446cdf0e10cSrcweir 				pSdrView->EnterMarkedGroup();
447cdf0e10cSrcweir 				rBind.InvalidateAll(sal_False);
448cdf0e10cSrcweir 			}
449cdf0e10cSrcweir 			break;
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 		case SID_LEAVE_GROUP:
452cdf0e10cSrcweir 			if (pSdrView->IsGroupEntered())
453cdf0e10cSrcweir 			{
454cdf0e10cSrcweir 				pSdrView->LeaveOneGroup();
455cdf0e10cSrcweir 				rBind.Invalidate(SID_ENTER_GROUP);
456cdf0e10cSrcweir 				rBind.Invalidate(SID_UNGROUP);
457cdf0e10cSrcweir 			}
458cdf0e10cSrcweir 			break;
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 		case SID_OBJECT_ALIGN_LEFT:
461cdf0e10cSrcweir 		case SID_OBJECT_ALIGN_CENTER:
462cdf0e10cSrcweir 		case SID_OBJECT_ALIGN_RIGHT:
463cdf0e10cSrcweir 		case SID_OBJECT_ALIGN_UP:
464cdf0e10cSrcweir 		case SID_OBJECT_ALIGN_MIDDLE:
465cdf0e10cSrcweir 		case SID_OBJECT_ALIGN_DOWN:
466cdf0e10cSrcweir 		{
467cdf0e10cSrcweir 			if ( bAlignPossible )
468cdf0e10cSrcweir 			{
469cdf0e10cSrcweir 				const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
470cdf0e10cSrcweir 				if( rMarkList.GetMarkCount() == 1 && bAlignPossible )
471cdf0e10cSrcweir 				{	// Objekte nicht aneinander ausrichten
472cdf0e10cSrcweir 
473cdf0e10cSrcweir 					sal_uInt16 nAnchor = pSh->GetAnchorId();
474cdf0e10cSrcweir                     if (nAnchor == FLY_AS_CHAR)
475cdf0e10cSrcweir                     {
476cdf0e10cSrcweir                         sal_Int16 nVertOrient = -1;
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 						switch (nSlotId)
479cdf0e10cSrcweir 						{
480cdf0e10cSrcweir 							case SID_OBJECT_ALIGN_UP:
481cdf0e10cSrcweir                                 nVertOrient = text::VertOrientation::TOP;
482cdf0e10cSrcweir 								break;
483cdf0e10cSrcweir 							case SID_OBJECT_ALIGN_MIDDLE:
484cdf0e10cSrcweir                                 nVertOrient = text::VertOrientation::CENTER;
485cdf0e10cSrcweir 								break;
486cdf0e10cSrcweir 							case SID_OBJECT_ALIGN_DOWN:
487cdf0e10cSrcweir                                 nVertOrient = text::VertOrientation::BOTTOM;
488cdf0e10cSrcweir 								break;
489cdf0e10cSrcweir 							default:
490cdf0e10cSrcweir 								break;
491cdf0e10cSrcweir 						}
492cdf0e10cSrcweir 						if (nVertOrient != -1)
493cdf0e10cSrcweir 						{
494cdf0e10cSrcweir 							pSh->StartAction();
495cdf0e10cSrcweir 							SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
496cdf0e10cSrcweir 							SwFrmFmt* pFrmFmt = FindFrmFmt( pObj );
497cdf0e10cSrcweir                             SwFmtVertOrient aVOrient((SwFmtVertOrient&)pFrmFmt->GetFmtAttr(RES_VERT_ORIENT));
498cdf0e10cSrcweir                             aVOrient.SetVertOrient( nVertOrient );
499cdf0e10cSrcweir                             pFrmFmt->SetFmtAttr(aVOrient);
500cdf0e10cSrcweir 							pSh->EndAction();
501cdf0e10cSrcweir 						}
502cdf0e10cSrcweir 						break;
503cdf0e10cSrcweir                     }
504cdf0e10cSrcweir                     if (nAnchor == FLY_AT_PARA)
505cdf0e10cSrcweir 						break;	// Absatzverankerte Rahmen nicht ausrichten
506cdf0e10cSrcweir 				}
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 				pSh->StartAction();
509cdf0e10cSrcweir 				switch (nSlotId)
510cdf0e10cSrcweir 				{
511cdf0e10cSrcweir 					case SID_OBJECT_ALIGN_LEFT:
512cdf0e10cSrcweir 						pSdrView->AlignMarkedObjects(SDRHALIGN_LEFT, SDRVALIGN_NONE);
513cdf0e10cSrcweir 						break;
514cdf0e10cSrcweir 					case SID_OBJECT_ALIGN_CENTER:
515cdf0e10cSrcweir 						pSdrView->AlignMarkedObjects(SDRHALIGN_CENTER, SDRVALIGN_NONE);
516cdf0e10cSrcweir 						break;
517cdf0e10cSrcweir 					case SID_OBJECT_ALIGN_RIGHT:
518cdf0e10cSrcweir 						pSdrView->AlignMarkedObjects(SDRHALIGN_RIGHT, SDRVALIGN_NONE);
519cdf0e10cSrcweir 						break;
520cdf0e10cSrcweir 					case SID_OBJECT_ALIGN_UP:
521cdf0e10cSrcweir 						pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_TOP);
522cdf0e10cSrcweir 						break;
523cdf0e10cSrcweir 					case SID_OBJECT_ALIGN_MIDDLE:
524cdf0e10cSrcweir 						pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_CENTER);
525cdf0e10cSrcweir 						break;
526cdf0e10cSrcweir 					case SID_OBJECT_ALIGN_DOWN:
527cdf0e10cSrcweir 						pSdrView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_BOTTOM);
528cdf0e10cSrcweir 						break;
529cdf0e10cSrcweir 				}
530cdf0e10cSrcweir 				pSh->EndAction();
531cdf0e10cSrcweir 			}
532cdf0e10cSrcweir 		}
533cdf0e10cSrcweir 		break;
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 		case FN_FRAME_UP:
536cdf0e10cSrcweir 			bTopParam = sal_False;
537cdf0e10cSrcweir 			/* no break */
538cdf0e10cSrcweir 		case SID_FRAME_TO_TOP:
539cdf0e10cSrcweir 			pSh->SelectionToTop( bTopParam );
540cdf0e10cSrcweir 			break;
541cdf0e10cSrcweir 
542cdf0e10cSrcweir 		case FN_FRAME_DOWN:
543cdf0e10cSrcweir 			bBottomParam = sal_False;
544cdf0e10cSrcweir 			/* no break */
545cdf0e10cSrcweir 		case SID_FRAME_TO_BOTTOM:
546cdf0e10cSrcweir 			pSh->SelectionToBottom( bBottomParam );
547cdf0e10cSrcweir 			break;
548cdf0e10cSrcweir 
549cdf0e10cSrcweir 		case FN_NAME_SHAPE:
550cdf0e10cSrcweir 		{
551cdf0e10cSrcweir             bDone = sal_True;
552cdf0e10cSrcweir 
553cdf0e10cSrcweir 			if(1L == pSdrView->GetMarkedObjectCount())
554cdf0e10cSrcweir 			{
555cdf0e10cSrcweir 				// #i68101#
556cdf0e10cSrcweir 				SdrObject* pSelected = pSdrView->GetMarkedObjectByIndex(0L);
557cdf0e10cSrcweir 				OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
558cdf0e10cSrcweir 				String aName(pSelected->GetName());
559cdf0e10cSrcweir 
560cdf0e10cSrcweir 				SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
561cdf0e10cSrcweir 				OSL_ENSURE(pFact, "Dialogdiet fail!");
562cdf0e10cSrcweir 				AbstractSvxObjectNameDialog* pDlg = pFact->CreateSvxObjectNameDialog(NULL, aName);
563cdf0e10cSrcweir 				OSL_ENSURE(pDlg, "Dialogdiet fail!");
564cdf0e10cSrcweir 
565cdf0e10cSrcweir 	            pDlg->SetCheckNameHdl(LINK(this, SwDrawBaseShell, CheckGroupShapeNameHdl));
566cdf0e10cSrcweir 
567cdf0e10cSrcweir 				if(RET_OK == pDlg->Execute())
568cdf0e10cSrcweir 				{
569cdf0e10cSrcweir 					pDlg->GetName(aName);
570cdf0e10cSrcweir 					pSelected->SetName(aName);
571cdf0e10cSrcweir 					pSh->SetModified();
572cdf0e10cSrcweir 				}
573cdf0e10cSrcweir 
574cdf0e10cSrcweir 				delete pDlg;
575cdf0e10cSrcweir 			}
576cdf0e10cSrcweir 
577cdf0e10cSrcweir 			break;
578cdf0e10cSrcweir 		}
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 		// #i68101#
581cdf0e10cSrcweir 		case FN_TITLE_DESCRIPTION_SHAPE:
582cdf0e10cSrcweir 		{
583cdf0e10cSrcweir             bDone = sal_True;
584cdf0e10cSrcweir 
585cdf0e10cSrcweir 			if(1L == pSdrView->GetMarkedObjectCount())
586cdf0e10cSrcweir 			{
587cdf0e10cSrcweir 				SdrObject* pSelected = pSdrView->GetMarkedObjectByIndex(0L);
588cdf0e10cSrcweir 				OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
589cdf0e10cSrcweir 				String aTitle(pSelected->GetTitle());
590cdf0e10cSrcweir 				String aDescription(pSelected->GetDescription());
591cdf0e10cSrcweir 
592cdf0e10cSrcweir 				SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
593cdf0e10cSrcweir 				OSL_ENSURE(pFact, "Dialogdiet fail!");
594cdf0e10cSrcweir 				AbstractSvxObjectTitleDescDialog* pDlg = pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription);
595cdf0e10cSrcweir 				OSL_ENSURE(pDlg, "Dialogdiet fail!");
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 				if(RET_OK == pDlg->Execute())
598cdf0e10cSrcweir 				{
599cdf0e10cSrcweir 					pDlg->GetTitle(aTitle);
600cdf0e10cSrcweir 					pDlg->GetDescription(aDescription);
601cdf0e10cSrcweir 
602cdf0e10cSrcweir 					pSelected->SetTitle(aTitle);
603cdf0e10cSrcweir 					pSelected->SetDescription(aDescription);
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 					pSh->SetModified();
606cdf0e10cSrcweir 				}
607cdf0e10cSrcweir 
608cdf0e10cSrcweir 				delete pDlg;
609cdf0e10cSrcweir 			}
610cdf0e10cSrcweir 
611cdf0e10cSrcweir 			break;
612cdf0e10cSrcweir 		}
613cdf0e10cSrcweir 
614cdf0e10cSrcweir 		default:
615cdf0e10cSrcweir 			DBG_ASSERT(!this, "falscher Dispatcher");
616cdf0e10cSrcweir 			return;
617cdf0e10cSrcweir 	}
618cdf0e10cSrcweir 	if(!bDone)
619cdf0e10cSrcweir 	{
620cdf0e10cSrcweir 		if(nSlotId >= SID_OBJECT_ALIGN_LEFT && nSlotId <= SID_OBJECT_ALIGN_DOWN)
621cdf0e10cSrcweir 			rBind.Invalidate(SID_ATTR_LONG_LRSPACE);
622cdf0e10cSrcweir 		if (pSdrView->GetModel()->IsChanged())
623cdf0e10cSrcweir 			pSh->SetModified();
624cdf0e10cSrcweir 		else if (bChanged)
625cdf0e10cSrcweir 			pSdrView->GetModel()->SetChanged(sal_True);
626cdf0e10cSrcweir 		// 40220: Nach dem Loeschen von DrawObjekten ueber die API GPF durch Selbstzerstoerung
627cdf0e10cSrcweir 		if(bNotify)
628cdf0e10cSrcweir 			GetView().AttrChangedNotify(pSh); // ggf Shellwechsel...
629cdf0e10cSrcweir 	}
630cdf0e10cSrcweir }
631cdf0e10cSrcweir /* -----------------------------27.02.2002 15:27------------------------------
632cdf0e10cSrcweir     Checks whether a given name is allowed for a group shape
633cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
634cdf0e10cSrcweir IMPL_LINK( SwDrawBaseShell, CheckGroupShapeNameHdl, AbstractSvxNameDialog*, pNameDialog )
635cdf0e10cSrcweir {
636cdf0e10cSrcweir     SwWrtShell          &rSh = GetShell();
637cdf0e10cSrcweir     SdrView *pSdrView = rSh.GetDrawView();
638cdf0e10cSrcweir     const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
639cdf0e10cSrcweir     DBG_ASSERT(rMarkList.GetMarkCount() == 1, "wrong draw selection");
640cdf0e10cSrcweir     SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
641cdf0e10cSrcweir     const String sCurrentName = pObj->GetName();
642cdf0e10cSrcweir     String sNewName;
643cdf0e10cSrcweir     pNameDialog->GetName(sNewName);
644cdf0e10cSrcweir     long nRet = 0;
645cdf0e10cSrcweir     if(!sNewName.Len() || sCurrentName == sNewName)
646cdf0e10cSrcweir         nRet = 1;
647cdf0e10cSrcweir     else
648cdf0e10cSrcweir     {
649cdf0e10cSrcweir         nRet = 1;
650cdf0e10cSrcweir         SdrModel* pModel = rSh.getIDocumentDrawModelAccess()->GetDrawModel();
651cdf0e10cSrcweir         // --> OD 2006-03-09 #i51726# - all drawing objects can be named now.
652cdf0e10cSrcweir         // consider also drawing objects inside group objects
653cdf0e10cSrcweir //        SdrPage* pPage = pModel->GetPage(0);
654cdf0e10cSrcweir //        sal_uInt32 nCount = pPage->GetObjCount();
655cdf0e10cSrcweir //        for( sal_uInt32 i=0; i< nCount; i++ )
656cdf0e10cSrcweir //        {
657cdf0e10cSrcweir //            SdrObject* pTemp = pPage->GetObj(i);
658cdf0e10cSrcweir //            if(pObj != pTemp && pTemp->ISA(SdrObjGroup) && pTemp->GetName() == sNewName)
659cdf0e10cSrcweir //            {
660cdf0e10cSrcweir //                nRet = 0;
661cdf0e10cSrcweir //                break;
662cdf0e10cSrcweir //            }
663cdf0e10cSrcweir //        }
664cdf0e10cSrcweir         SdrObjListIter aIter( *(pModel->GetPage(0)), IM_DEEPWITHGROUPS );
665cdf0e10cSrcweir         while( aIter.IsMore() )
666cdf0e10cSrcweir         {
667cdf0e10cSrcweir             SdrObject* pTempObj = aIter.Next();
668cdf0e10cSrcweir             if ( pObj != pTempObj && pTempObj->GetName() == sNewName )
669cdf0e10cSrcweir             {
670cdf0e10cSrcweir                 nRet = 0;
671cdf0e10cSrcweir                 break;
672cdf0e10cSrcweir             }
673cdf0e10cSrcweir         }
674cdf0e10cSrcweir         // <--
675cdf0e10cSrcweir     }
676cdf0e10cSrcweir     return nRet;
677cdf0e10cSrcweir }
678cdf0e10cSrcweir /*--------------------------------------------------------------------
679cdf0e10cSrcweir 	Beschreibung:
680cdf0e10cSrcweir  --------------------------------------------------------------------*/
681cdf0e10cSrcweir void SwDrawBaseShell::GetState(SfxItemSet& rSet)
682cdf0e10cSrcweir {
683cdf0e10cSrcweir 	SwWrtShell &rSh = GetShell();
684cdf0e10cSrcweir 	SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
685cdf0e10cSrcweir 	SfxWhichIter aIter( rSet );
686cdf0e10cSrcweir 	sal_uInt16 nWhich = aIter.FirstWhich();
687cdf0e10cSrcweir 	sal_Bool bProtected = rSh.IsSelObjProtected(FLYPROTECT_CONTENT);
688cdf0e10cSrcweir 
689cdf0e10cSrcweir 	if (!bProtected)	// Im Parent nachsehen
690cdf0e10cSrcweir 		bProtected |= rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0;
691cdf0e10cSrcweir 
692cdf0e10cSrcweir 	while( nWhich )
693cdf0e10cSrcweir 	{
694cdf0e10cSrcweir 		switch( nWhich )
695cdf0e10cSrcweir 		{
696cdf0e10cSrcweir 			case FN_DRAW_WRAP_DLG:
697cdf0e10cSrcweir 			case SID_ATTR_TRANSFORM:
698cdf0e10cSrcweir 			case SID_FRAME_TO_TOP:
699cdf0e10cSrcweir 			case SID_FRAME_TO_BOTTOM:
700cdf0e10cSrcweir 			case FN_FRAME_UP:
701cdf0e10cSrcweir 			case FN_FRAME_DOWN:
702cdf0e10cSrcweir 			case SID_DELETE:
703cdf0e10cSrcweir 			case FN_BACKSPACE:
704cdf0e10cSrcweir 				if( bProtected || !rSh.IsObjSelected() )
705cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
706cdf0e10cSrcweir 				break;
707cdf0e10cSrcweir 			case SID_GROUP:
708cdf0e10cSrcweir 				if ( rSh.IsObjSelected() < 2 || bProtected || !rSh.IsGroupAllowed() )
709cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
710cdf0e10cSrcweir 				break;
711cdf0e10cSrcweir 			case SID_UNGROUP:
712cdf0e10cSrcweir 				if ( !rSh.IsGroupSelected() || bProtected )
713cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
714cdf0e10cSrcweir 				break;
715cdf0e10cSrcweir 			case SID_ENTER_GROUP:
716cdf0e10cSrcweir 				if ( !rSh.IsGroupSelected() )
717cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
718cdf0e10cSrcweir 				break;
719cdf0e10cSrcweir 			case SID_LEAVE_GROUP:
720cdf0e10cSrcweir 				if ( !pSdrView->IsGroupEntered() )
721cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
722cdf0e10cSrcweir 				break;
723cdf0e10cSrcweir 			case SID_OBJECT_ALIGN_LEFT:
724cdf0e10cSrcweir 			case SID_OBJECT_ALIGN_CENTER:
725cdf0e10cSrcweir 			case SID_OBJECT_ALIGN_RIGHT:
726cdf0e10cSrcweir 			case SID_OBJECT_ALIGN_UP:
727cdf0e10cSrcweir 			case SID_OBJECT_ALIGN_MIDDLE:
728cdf0e10cSrcweir 			case SID_OBJECT_ALIGN_DOWN:
729cdf0e10cSrcweir 			case SID_OBJECT_ALIGN:
730cdf0e10cSrcweir 				if ( !rSh.IsAlignPossible() || bProtected )
731cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
732cdf0e10cSrcweir 				else
733cdf0e10cSrcweir 				{
734cdf0e10cSrcweir                     SfxAllEnumItem aEnumItem(nWhich, USHRT_MAX);
735cdf0e10cSrcweir                     const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
736cdf0e10cSrcweir                     //if only one object is selected it can only be vertically
737cdf0e10cSrcweir                     // aligned because it is character bound
738cdf0e10cSrcweir                     if( rMarkList.GetMarkCount() == 1 )
739cdf0e10cSrcweir                     {
740cdf0e10cSrcweir                         aEnumItem.DisableValue(SID_OBJECT_ALIGN_LEFT);
741cdf0e10cSrcweir                         aEnumItem.DisableValue(SID_OBJECT_ALIGN_CENTER);
742cdf0e10cSrcweir                         aEnumItem.DisableValue(SID_OBJECT_ALIGN_RIGHT);
743cdf0e10cSrcweir                     }
744cdf0e10cSrcweir                     rSet.Put(aEnumItem);
745cdf0e10cSrcweir 				}
746cdf0e10cSrcweir 				break;
747cdf0e10cSrcweir 
748cdf0e10cSrcweir 			case FN_NAME_SHAPE :
749cdf0e10cSrcweir 				{
750cdf0e10cSrcweir 					if(1L != pSdrView->GetMarkedObjectCount())
751cdf0e10cSrcweir 					{
752cdf0e10cSrcweir 						rSet.DisableItem( nWhich );
753cdf0e10cSrcweir 					}
754cdf0e10cSrcweir 				}
755cdf0e10cSrcweir 				break;
756cdf0e10cSrcweir 
757cdf0e10cSrcweir 			// #i68101#
758cdf0e10cSrcweir 			case FN_TITLE_DESCRIPTION_SHAPE:
759cdf0e10cSrcweir 				{
760cdf0e10cSrcweir                     const bool bIsWebView(NULL != dynamic_cast<SwWebView*>(&GetView()));
761cdf0e10cSrcweir 
762cdf0e10cSrcweir 					if(!bIsWebView && 1L != pSdrView->GetMarkedObjectCount())
763cdf0e10cSrcweir 					{
764cdf0e10cSrcweir 						rSet.DisableItem( nWhich );
765cdf0e10cSrcweir 					}
766cdf0e10cSrcweir 				}
767cdf0e10cSrcweir 				break;
768cdf0e10cSrcweir         }
769cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
770cdf0e10cSrcweir 	}
771cdf0e10cSrcweir }
772cdf0e10cSrcweir 
773cdf0e10cSrcweir /*--------------------------------------------------------------------
774cdf0e10cSrcweir 	Beschreibung:
775cdf0e10cSrcweir  --------------------------------------------------------------------*/
776cdf0e10cSrcweir 
777cdf0e10cSrcweir 
778cdf0e10cSrcweir sal_Bool SwDrawBaseShell::Disable(SfxItemSet& rSet, sal_uInt16 nWhich)
779cdf0e10cSrcweir {
780cdf0e10cSrcweir 	sal_Bool bDisable = GetShell().IsSelObjProtected(FLYPROTECT_CONTENT);
781cdf0e10cSrcweir 
782cdf0e10cSrcweir 	if (bDisable)
783cdf0e10cSrcweir 	{
784cdf0e10cSrcweir 		if (nWhich)
785cdf0e10cSrcweir 			rSet.DisableItem( nWhich );
786cdf0e10cSrcweir 		else
787cdf0e10cSrcweir 		{
788cdf0e10cSrcweir 			SfxWhichIter aIter( rSet );
789cdf0e10cSrcweir 			nWhich = aIter.FirstWhich();
790cdf0e10cSrcweir 			while (nWhich)
791cdf0e10cSrcweir 			{
792cdf0e10cSrcweir 				rSet.DisableItem( nWhich );
793cdf0e10cSrcweir 				nWhich = aIter.NextWhich();
794cdf0e10cSrcweir 			}
795cdf0e10cSrcweir 		}
796cdf0e10cSrcweir 	}
797cdf0e10cSrcweir 
798cdf0e10cSrcweir 	return bDisable;
799cdf0e10cSrcweir }
800cdf0e10cSrcweir 
801cdf0e10cSrcweir /*-- 09.03.2004 13:15:03---------------------------------------------------
802cdf0e10cSrcweir     Validate of drawing positions
803cdf0e10cSrcweir   -----------------------------------------------------------------------*/
804cdf0e10cSrcweir IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation*, pValidation )
805cdf0e10cSrcweir {
806cdf0e10cSrcweir     SwWrtShell *pSh = &GetShell();
807cdf0e10cSrcweir     pValidation->nMinHeight = MINFLY;
808cdf0e10cSrcweir     pValidation->nMinWidth =  MINFLY;
809cdf0e10cSrcweir 
810cdf0e10cSrcweir     SwRect aBoundRect;
811cdf0e10cSrcweir 
812cdf0e10cSrcweir     // OD 18.09.2003 #i18732# - adjustment for allowing vertical position
813cdf0e10cSrcweir     //      aligned to page for fly frame anchored to paragraph or to character.
814cdf0e10cSrcweir     const RndStdIds eAnchorType = static_cast<RndStdIds >(pValidation->nAnchorType);
815cdf0e10cSrcweir     const SwPosition* pCntntPos = 0;
816cdf0e10cSrcweir     SdrView*  pSdrView = pSh->GetDrawView();
817cdf0e10cSrcweir     const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
818cdf0e10cSrcweir     if( rMarkList.GetMarkCount() == 1 )
819cdf0e10cSrcweir     {
820cdf0e10cSrcweir         SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
821cdf0e10cSrcweir         SwFrmFmt* pFrmFmt = FindFrmFmt( pObj );
822cdf0e10cSrcweir         pCntntPos = pFrmFmt->GetAnchor().GetCntntAnchor();
823cdf0e10cSrcweir     }
824cdf0e10cSrcweir 
825cdf0e10cSrcweir     pSh->CalcBoundRect( aBoundRect, eAnchorType,
826cdf0e10cSrcweir                            pValidation->nHRelOrient,
827cdf0e10cSrcweir                            pValidation->nVRelOrient,
828cdf0e10cSrcweir                            pCntntPos,
829cdf0e10cSrcweir                            pValidation->bFollowTextFlow,
830cdf0e10cSrcweir                            pValidation->bMirror, NULL, &pValidation->aPercentSize);
831cdf0e10cSrcweir 
832cdf0e10cSrcweir     sal_Bool bIsInVertical( sal_False );
833cdf0e10cSrcweir     {
834cdf0e10cSrcweir         sal_Bool bRTL;
835cdf0e10cSrcweir         sal_Bool bVertL2R;
836cdf0e10cSrcweir         bIsInVertical = pSh->IsFrmVertical(sal_True, bRTL, bVertL2R);
837cdf0e10cSrcweir     }
838cdf0e10cSrcweir     if(bIsInVertical)
839cdf0e10cSrcweir     {
840cdf0e10cSrcweir         Point aPos(aBoundRect.Pos());
841cdf0e10cSrcweir         long nTmp = aPos.X();
842cdf0e10cSrcweir         aPos.X() = aPos.Y();
843cdf0e10cSrcweir         aPos.Y() = nTmp;
844cdf0e10cSrcweir         Size aSize(aBoundRect.SSize());
845cdf0e10cSrcweir         nTmp = aSize.Width();
846cdf0e10cSrcweir         aSize.Width() = aSize.Height();
847cdf0e10cSrcweir         aSize.Height() = nTmp;
848cdf0e10cSrcweir         aBoundRect.Chg( aPos, aSize );
849cdf0e10cSrcweir         //exchange width/height to enable correct values
850cdf0e10cSrcweir         nTmp = pValidation->nWidth;
851cdf0e10cSrcweir         pValidation->nWidth = pValidation->nHeight;
852cdf0e10cSrcweir         pValidation->nHeight = nTmp;
853cdf0e10cSrcweir     }
854cdf0e10cSrcweir     if ((eAnchorType == FLY_AT_PAGE) || (eAnchorType == FLY_AT_FLY))
855cdf0e10cSrcweir     {
856cdf0e10cSrcweir         // MinimalPosition
857cdf0e10cSrcweir         pValidation->nMinHPos = aBoundRect.Left();
858cdf0e10cSrcweir         pValidation->nMinVPos = aBoundRect.Top();
859cdf0e10cSrcweir         SwTwips nH = pValidation->nHPos;
860cdf0e10cSrcweir         SwTwips nV = pValidation->nVPos;
861cdf0e10cSrcweir 
862cdf0e10cSrcweir         if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
863cdf0e10cSrcweir         {
864cdf0e10cSrcweir             if (pValidation->nHoriOrient == text::HoriOrientation::NONE)
865cdf0e10cSrcweir             {
866cdf0e10cSrcweir                 pValidation->nHPos -= ((pValidation->nHPos + pValidation->nWidth) - aBoundRect.Right());
867cdf0e10cSrcweir                 nH = pValidation->nHPos;
868cdf0e10cSrcweir             }
869cdf0e10cSrcweir             else
870cdf0e10cSrcweir                 pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
871cdf0e10cSrcweir         }
872cdf0e10cSrcweir 
873cdf0e10cSrcweir         if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
874cdf0e10cSrcweir             pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
875cdf0e10cSrcweir 
876cdf0e10cSrcweir         if (pValidation->nVPos + pValidation->nHeight > aBoundRect.Bottom())
877cdf0e10cSrcweir         {
878cdf0e10cSrcweir             if (pValidation->nVertOrient == text::VertOrientation::NONE)
879cdf0e10cSrcweir             {
880cdf0e10cSrcweir                 pValidation->nVPos -= ((pValidation->nVPos + pValidation->nHeight) - aBoundRect.Bottom());
881cdf0e10cSrcweir                 nV = pValidation->nVPos;
882cdf0e10cSrcweir             }
883cdf0e10cSrcweir             else
884cdf0e10cSrcweir                 pValidation->nHeight = aBoundRect.Bottom() - pValidation->nVPos;
885cdf0e10cSrcweir         }
886cdf0e10cSrcweir 
887cdf0e10cSrcweir         if (pValidation->nVPos + pValidation->nHeight > aBoundRect.Bottom())
888cdf0e10cSrcweir             pValidation->nHeight = aBoundRect.Bottom() - pValidation->nVPos;
889cdf0e10cSrcweir 
890cdf0e10cSrcweir         if ( pValidation->nVertOrient != text::VertOrientation::NONE )
891cdf0e10cSrcweir             nV = aBoundRect.Top();
892cdf0e10cSrcweir 
893cdf0e10cSrcweir         if ( pValidation->nHoriOrient != text::HoriOrientation::NONE )
894cdf0e10cSrcweir             nH = aBoundRect.Left();
895cdf0e10cSrcweir 
896cdf0e10cSrcweir         pValidation->nMaxHPos   = aBoundRect.Right()  - pValidation->nWidth;
897cdf0e10cSrcweir         pValidation->nMaxHeight = aBoundRect.Bottom() - nV;
898cdf0e10cSrcweir 
899cdf0e10cSrcweir         pValidation->nMaxVPos   = aBoundRect.Bottom() - pValidation->nHeight;
900cdf0e10cSrcweir         pValidation->nMaxWidth  = aBoundRect.Right()  - nH;
901cdf0e10cSrcweir     }
902cdf0e10cSrcweir     else if ((eAnchorType == FLY_AT_PARA) || (eAnchorType == FLY_AT_CHAR))
903cdf0e10cSrcweir     {
904cdf0e10cSrcweir         if (pValidation->nHPos + pValidation->nWidth > aBoundRect.Right())
905cdf0e10cSrcweir         {
906cdf0e10cSrcweir             if (pValidation->nHoriOrient == text::HoriOrientation::NONE)
907cdf0e10cSrcweir             {
908cdf0e10cSrcweir                 pValidation->nHPos -= ((pValidation->nHPos + pValidation->nWidth) - aBoundRect.Right());
909cdf0e10cSrcweir             }
910cdf0e10cSrcweir             else
911cdf0e10cSrcweir                 pValidation->nWidth = aBoundRect.Right() - pValidation->nHPos;
912cdf0e10cSrcweir         }
913cdf0e10cSrcweir 
914cdf0e10cSrcweir         // OD 29.09.2003 #i17567#, #i18732# - consider following the text flow
915cdf0e10cSrcweir         // and alignment at page areas.
916cdf0e10cSrcweir         const bool bMaxVPosAtBottom = !pValidation->bFollowTextFlow ||
917cdf0e10cSrcweir                                       pValidation->nVRelOrient == text::RelOrientation::PAGE_FRAME ||
918cdf0e10cSrcweir                                       pValidation->nVRelOrient == text::RelOrientation::PAGE_PRINT_AREA;
919cdf0e10cSrcweir         {
920cdf0e10cSrcweir             SwTwips nTmpMaxVPos = ( bMaxVPosAtBottom
921cdf0e10cSrcweir                                     ? aBoundRect.Bottom()
922cdf0e10cSrcweir                                     : aBoundRect.Height() ) -
923cdf0e10cSrcweir                                   pValidation->nHeight;
924cdf0e10cSrcweir             if ( pValidation->nVPos > nTmpMaxVPos )
925cdf0e10cSrcweir             {
926cdf0e10cSrcweir                 if (pValidation->nVertOrient == text::VertOrientation::NONE)
927cdf0e10cSrcweir                 {
928cdf0e10cSrcweir                     pValidation->nVPos = nTmpMaxVPos;
929cdf0e10cSrcweir                 }
930cdf0e10cSrcweir                 else
931cdf0e10cSrcweir                 {
932cdf0e10cSrcweir                     pValidation->nHeight = ( bMaxVPosAtBottom
933cdf0e10cSrcweir                                      ? aBoundRect.Bottom()
934cdf0e10cSrcweir                                      : aBoundRect.Height() ) - pValidation->nVPos;
935cdf0e10cSrcweir                 }
936cdf0e10cSrcweir             }
937cdf0e10cSrcweir         }
938cdf0e10cSrcweir 
939cdf0e10cSrcweir         pValidation->nMinHPos  = aBoundRect.Left();
940cdf0e10cSrcweir         pValidation->nMaxHPos  = aBoundRect.Right() - pValidation->nWidth;
941cdf0e10cSrcweir 
942cdf0e10cSrcweir         pValidation->nMinVPos  = aBoundRect.Top();
943cdf0e10cSrcweir         // OD 26.09.2003 #i17567#, #i18732# - determine maximum vertical position
944cdf0e10cSrcweir         if ( bMaxVPosAtBottom )
945cdf0e10cSrcweir         {
946cdf0e10cSrcweir             pValidation->nMaxVPos  = aBoundRect.Bottom() - pValidation->nHeight;
947cdf0e10cSrcweir         }
948cdf0e10cSrcweir         else
949cdf0e10cSrcweir         {
950cdf0e10cSrcweir             pValidation->nMaxVPos  = aBoundRect.Height() - pValidation->nHeight;
951cdf0e10cSrcweir         }
952cdf0e10cSrcweir 
953cdf0e10cSrcweir         // Maximale Breite Hoehe
954cdf0e10cSrcweir         const SwTwips nH = ( pValidation->nHoriOrient != text::HoriOrientation::NONE )
955cdf0e10cSrcweir                            ? aBoundRect.Left()
956cdf0e10cSrcweir                            : pValidation->nHPos;
957cdf0e10cSrcweir         const SwTwips nV = ( pValidation->nVertOrient != text::VertOrientation::NONE )
958cdf0e10cSrcweir                            ? aBoundRect.Top()
959cdf0e10cSrcweir                            : pValidation->nVPos;
960cdf0e10cSrcweir         pValidation->nMaxHeight  = pValidation->nMaxVPos + pValidation->nHeight - nV;
961cdf0e10cSrcweir         pValidation->nMaxWidth   = pValidation->nMaxHPos + pValidation->nWidth - nH;
962cdf0e10cSrcweir     }
963cdf0e10cSrcweir     else if (eAnchorType == FLY_AS_CHAR)
964cdf0e10cSrcweir     {
965cdf0e10cSrcweir         pValidation->nMinHPos = 0;
966cdf0e10cSrcweir         pValidation->nMaxHPos = 0;
967cdf0e10cSrcweir 
968cdf0e10cSrcweir         pValidation->nMaxHeight = aBoundRect.Height();
969cdf0e10cSrcweir         pValidation->nMaxWidth  = aBoundRect.Width();
970cdf0e10cSrcweir 
971cdf0e10cSrcweir         pValidation->nMaxVPos   = aBoundRect.Height();
972cdf0e10cSrcweir         pValidation->nMinVPos   = -aBoundRect.Height() + pValidation->nHeight;
973cdf0e10cSrcweir         if (pValidation->nMaxVPos < pValidation->nMinVPos)
974cdf0e10cSrcweir         {
975cdf0e10cSrcweir             pValidation->nMinVPos = pValidation->nMaxVPos;
976cdf0e10cSrcweir             pValidation->nMaxVPos = -aBoundRect.Height();
977cdf0e10cSrcweir         }
978cdf0e10cSrcweir     }
979cdf0e10cSrcweir     if(bIsInVertical)
980cdf0e10cSrcweir     {
981cdf0e10cSrcweir         //restore width/height exchange
982cdf0e10cSrcweir         long nTmp = pValidation->nWidth;
983cdf0e10cSrcweir         pValidation->nWidth = pValidation->nHeight;
984cdf0e10cSrcweir         pValidation->nHeight = nTmp;
985cdf0e10cSrcweir     }
986cdf0e10cSrcweir 
987cdf0e10cSrcweir     if (pValidation->nMaxWidth < pValidation->nWidth)
988cdf0e10cSrcweir         pValidation->nWidth = pValidation->nMaxWidth;
989cdf0e10cSrcweir     if (pValidation->nMaxHeight < pValidation->nHeight)
990cdf0e10cSrcweir         pValidation->nHeight = pValidation->nMaxHeight;
991cdf0e10cSrcweir     return 0;
992cdf0e10cSrcweir }
993cdf0e10cSrcweir 
994cdf0e10cSrcweir 
995cdf0e10cSrcweir 
996cdf0e10cSrcweir 
997