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