xref: /trunk/main/sw/source/ui/frmdlg/frmmgr.cxx (revision 3f09c2ce)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #include "cmdid.h"
28 #include "hintids.hxx"
29 
30 #include <svl/stritem.hxx>
31 #include <editeng/protitem.hxx>
32 #include <editeng/boxitem.hxx>
33 #include <editeng/opaqitem.hxx>
34 #include <editeng/lrspitem.hxx>
35 #include <editeng/ulspitem.hxx>
36 #include <editeng/shaditem.hxx>
37 #include <svx/swframevalidation.hxx>
38 #include <svx/xdef.hxx>
39 #include <fmtclds.hxx>
40 #include "wrtsh.hxx"
41 #include "view.hxx"
42 #include "viewopt.hxx"
43 #include "uitool.hxx"
44 #include "frmmgr.hxx"
45 #include "format.hxx"
46 #include "mdiexp.hxx"
47 #include "poolfmt.hxx"
48 #include <com/sun/star/text/TextContentAnchorType.hpp>
49 #include <com/sun/star/text/HoriOrientation.hpp>
50 #include <com/sun/star/text/VertOrientation.hpp>
51 #include <com/sun/star/text/RelOrientation.hpp>
52 
53 using namespace ::com::sun::star;
54 //using namespace text;
55 
56 static sal_uInt16 __FAR_DATA aFrmMgrRange[] = {
57 							RES_FRMATR_BEGIN, RES_FRMATR_END-1,
58 
59                             //UUUU FillAttribute support
60                             XATTR_FILL_FIRST, XATTR_FILL_LAST,
61 
62 							SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
63 							FN_SET_FRM_NAME, FN_SET_FRM_NAME,
64 							0};
65 
66 /*--------------------------------------------------------------------
67 	 Beschreibung: Rahmen-Attribute ueber Shell ermitteln
68  --------------------------------------------------------------------*/
69 
SwFlyFrmAttrMgr(sal_Bool bNew,SwWrtShell * pSh,sal_uInt8 nType)70 SwFlyFrmAttrMgr::SwFlyFrmAttrMgr( sal_Bool bNew, SwWrtShell* pSh, sal_uInt8 nType ) :
71     aSet( (SwAttrPool&)pSh->GetAttrPool(), aFrmMgrRange ),
72     pOwnSh( pSh ),
73     bAbsPos( sal_False ),
74     bNewFrm( bNew ),
75     bIsInVertical( sal_False ),
76     bIsInVerticalL2R( sal_False )
77 {
78 	if ( bNewFrm )
79 	{
80 		// Defaults einstellen:
81         sal_uInt16 nId = 0;
82 		switch ( nType )
83 		{
84 			case FRMMGR_TYPE_TEXT:	nId = RES_POOLFRM_FRAME;	break;
85 			case FRMMGR_TYPE_OLE:	nId = RES_POOLFRM_OLE;		break;
86 			case FRMMGR_TYPE_GRF:	nId = RES_POOLFRM_GRAPHIC;	break;
87 		}
88 		aSet.SetParent( &pOwnSh->GetFmtFromPool( nId )->GetAttrSet());
89 		aSet.Put( SwFmtFrmSize( ATT_MIN_SIZE, DFLT_WIDTH, DFLT_HEIGHT ));
90 		if ( 0 != ::GetHtmlMode(pSh->GetView().GetDocShell()) )
91             aSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::PRINT_AREA ) );
92 	}
93 	else if ( nType == FRMMGR_TYPE_NONE )
94     {
95 		pOwnSh->GetFlyFrmAttr( aSet );
96         sal_Bool bRightToLeft;
97         bIsInVertical = pOwnSh->IsFrmVertical(sal_True, bRightToLeft, bIsInVerticalL2R);
98     }
99 	::PrepareBoxInfo( aSet, *pOwnSh );
100 }
101 
SwFlyFrmAttrMgr(sal_Bool bNew,SwWrtShell * pSh,const SfxItemSet & rSet)102 SwFlyFrmAttrMgr::SwFlyFrmAttrMgr( sal_Bool bNew, SwWrtShell* pSh, const SfxItemSet &rSet ) :
103     aSet( rSet ),
104     pOwnSh( pSh ),
105 	bAbsPos( sal_False ),
106 	bNewFrm( bNew ),
107 	bIsInVertical(sal_False),
108     bIsInVerticalL2R(sal_False)
109 {
110 	if(!bNew)
111 	{
112 		sal_Bool bRightToLeft;
113         bIsInVertical = pSh->IsFrmVertical(sal_True, bRightToLeft, bIsInVerticalL2R);
114 	}
115 }
116 
117 
118 /*--------------------------------------------------------------------
119 	 Beschreibung:	Initialisieren
120  --------------------------------------------------------------------*/
121 
UpdateAttrMgr()122 void SwFlyFrmAttrMgr::UpdateAttrMgr()
123 {
124 	if ( !bNewFrm && pOwnSh->IsFrmSelected() )
125 		pOwnSh->GetFlyFrmAttr( aSet );
126 	::PrepareBoxInfo( aSet, *pOwnSh );
127 }
128 
_UpdateFlyFrm()129 void SwFlyFrmAttrMgr::_UpdateFlyFrm()
130 {
131 	const SfxPoolItem* pItem = 0;
132 
133 	if (aSet.GetItemState(FN_SET_FRM_NAME, sal_False, &pItem) == SFX_ITEM_SET)
134 		pOwnSh->SetFlyName(((SfxStringItem *)pItem)->GetValue());
135 
136 	pOwnSh->SetModified();
137 
138 	if ( bAbsPos )
139 	{
140 		pOwnSh->SetFlyPos( aAbsPos );
141 		bAbsPos = sal_False;
142 	}
143 }
144 
145 /*--------------------------------------------------------------------
146 	Beschreibung: Bestehenden Fly-Frame aendern
147  --------------------------------------------------------------------*/
148 
UpdateFlyFrm()149 void SwFlyFrmAttrMgr::UpdateFlyFrm()
150 {
151 	ASSERT( pOwnSh->IsFrmSelected(),
152 		"Kein Rahmen selektiert oder keine Shell, Update nicht moeglich");
153 
154 	if( pOwnSh->IsFrmSelected() )
155 	{
156 		//JP 6.8.2001: set never an invalid anchor into the core.
157 		const SfxPoolItem *pGItem, *pItem;
158 		if( SFX_ITEM_SET == aSet.GetItemState( RES_ANCHOR, sal_False, &pItem ))
159 		{
160 			SfxItemSet aGetSet( *aSet.GetPool(), RES_ANCHOR, RES_ANCHOR );
161 			if( pOwnSh->GetFlyFrmAttr( aGetSet ) && 1 == aGetSet.Count() &&
162 				SFX_ITEM_SET == aGetSet.GetItemState( RES_ANCHOR, sal_False, &pGItem )
163 				&& ((SwFmtAnchor*)pGItem)->GetAnchorId() ==
164 				   ((SwFmtAnchor*)pItem)->GetAnchorId() )
165 				aSet.ClearItem( RES_ANCHOR );
166 		}
167 
168 		// return wg. BASIC
169 		if( aSet.Count() )
170 		{
171 			pOwnSh->StartAllAction();
172 			pOwnSh->SetFlyFrmAttr( aSet );
173 			_UpdateFlyFrm();
174 			pOwnSh->EndAllAction();
175 		}
176 	}
177 }
178 
179 /*--------------------------------------------------------------------
180 	 Beschreibung:	Rahmen einfuegen
181  --------------------------------------------------------------------*/
182 
InsertFlyFrm()183 sal_Bool SwFlyFrmAttrMgr::InsertFlyFrm()
184 {
185 	pOwnSh->StartAllAction();
186 
187 	sal_Bool bRet = 0 != pOwnSh->NewFlyFrm( aSet );
188 
189 	// richtigen Mode an der Shell einschalten, Rahmen wurde aut. selektiert.
190 	if ( bRet )
191 	{
192 		_UpdateFlyFrm();
193 		pOwnSh->EnterSelFrmMode();
194 		FrameNotify(pOwnSh, FLY_DRAG_START);
195 	}
196 	pOwnSh->EndAllAction();
197 	return bRet;
198 }
199 
200 /*------------------------------------------------------------------------
201  Beschreibung:	Rahmen des Typs eAnchorType einfuegen. Position und
202 				Groesse werden explizit angegeben.
203 				Nicht erlaubte Werte des Aufzaehlungstypes werden
204 				korrigiert.
205 ------------------------------------------------------------------------*/
206 
InsertFlyFrm(RndStdIds eAnchorType,const Point & rPos,const Size & rSize,sal_Bool bAbs)207 void SwFlyFrmAttrMgr::InsertFlyFrm(RndStdIds	eAnchorType,
208 								   const Point	&rPos,
209 								   const Size	&rSize,
210 								   sal_Bool bAbs )
211 {
212     ASSERT( eAnchorType == FLY_AT_PAGE ||
213             eAnchorType == FLY_AT_PARA ||
214             eAnchorType == FLY_AT_CHAR ||
215             eAnchorType == FLY_AT_FLY  ||
216             eAnchorType == FLY_AS_CHAR,     "invalid frame type" );
217 
218 	if ( bAbs )
219 		SetAbsPos( rPos );
220 	else
221 		SetPos( rPos );
222 
223 	SetSize( rSize );
224 	SetAnchor( eAnchorType );
225 	InsertFlyFrm();
226 }
227 
228 /*--------------------------------------------------------------------
229 	 Beschreibung:	Anker setzen
230  --------------------------------------------------------------------*/
231 
SetAnchor(RndStdIds eId)232 void SwFlyFrmAttrMgr::SetAnchor( RndStdIds eId )
233 {
234 	sal_uInt16 nPhyPageNum, nVirtPageNum;
235 	pOwnSh->GetPageNum( nPhyPageNum, nVirtPageNum );
236 
237 	aSet.Put( SwFmtAnchor( eId, nPhyPageNum ) );
238     if ((FLY_AT_PAGE == eId) || (FLY_AT_PARA == eId) || (FLY_AT_CHAR == eId)
239         || (FLY_AT_FLY == eId))
240     {
241 		SwFmtVertOrient aVertOrient( GetVertOrient() );
242 		SwFmtHoriOrient aHoriOrient( GetHoriOrient() );
243         aHoriOrient.SetRelationOrient( text::RelOrientation::FRAME );
244         aVertOrient.SetRelationOrient( text::RelOrientation::FRAME );
245 		aSet.Put( aVertOrient );
246 		aSet.Put( aHoriOrient );
247 	}
248 }
249 
250 /*------------------------------------------------------------------------
251  Beschreibung:	Setzen des Attributs fuer Spalten
252 ------------------------------------------------------------------------*/
253 
SetCol(const SwFmtCol & rCol)254 void SwFlyFrmAttrMgr::SetCol( const SwFmtCol &rCol )
255 {
256 	aSet.Put( rCol );
257 }
258 /*--------------------------------------------------------------------
259 	 Beschreibung:	Absolute Position setzen
260  --------------------------------------------------------------------*/
261 
SetAbsPos(const Point & rPoint)262 void SwFlyFrmAttrMgr::SetAbsPos( const Point& rPoint )
263 {
264 	bAbsPos = sal_True;
265 	aAbsPos = rPoint;
266 
267 	SwFmtVertOrient aVertOrient( GetVertOrient() );
268 	SwFmtHoriOrient aHoriOrient( GetHoriOrient() );
269     aHoriOrient.SetHoriOrient( text::HoriOrientation::NONE );
270     aVertOrient.SetVertOrient( text::VertOrientation::NONE );
271 	aSet.Put( aVertOrient );
272 	aSet.Put( aHoriOrient );
273 }
274 
275 /*--------------------------------------------------------------------
276 	Beschreibung: Metriken auf Korrektheit pruefen
277  --------------------------------------------------------------------*/
ValidateMetrics(SvxSwFrameValidation & rVal,const SwPosition * pToCharCntntPos,sal_Bool bOnlyPercentRefValue)278 void SwFlyFrmAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal,
279         const SwPosition* pToCharCntntPos,
280         sal_Bool bOnlyPercentRefValue )
281 {
282 	if (!bOnlyPercentRefValue)
283 	{
284 		rVal.nMinHeight = MINFLY + CalcTopSpace() + CalcBottomSpace();
285 		rVal.nMinWidth =  MINFLY + CalcLeftSpace()+ CalcRightSpace();
286 	}
287 
288 	SwRect aBoundRect;
289 
290     // OD 18.09.2003 #i18732# - adjustment for allowing vertical position
291     //      aligned to page for fly frame anchored to paragraph or to character.
292     const RndStdIds eAnchorType = static_cast<RndStdIds >(rVal.nAnchorType);
293     pOwnSh->CalcBoundRect( aBoundRect, eAnchorType,
294                            rVal.nHRelOrient,
295                            rVal.nVRelOrient,
296                            pToCharCntntPos,
297                            rVal.bFollowTextFlow,
298                            rVal.bMirror, NULL, &rVal.aPercentSize);
299 
300 	if (bOnlyPercentRefValue)
301 		return;
302 
303     // --> OD 2009-09-01 #mongolianlayout#
304     if ( bIsInVertical || bIsInVerticalL2R )
305     // <--
306     {
307         Point aPos(aBoundRect.Pos());
308         long nTmp = aPos.X();
309         aPos.X() = aPos.Y();
310         aPos.Y() = nTmp;
311         Size aSize(aBoundRect.SSize());
312         nTmp = aSize.Width();
313         aSize.Width() = aSize.Height();
314         aSize.Height() = nTmp;
315         aBoundRect.Chg( aPos, aSize );
316         //exchange width/height to enable correct values
317         nTmp = rVal.nWidth;
318         rVal.nWidth = rVal.nHeight;
319         rVal.nHeight = nTmp;
320     }
321     if ((eAnchorType == FLY_AT_PAGE) || (eAnchorType == FLY_AT_FLY))
322 	{
323 		// MinimalPosition
324 		rVal.nMinHPos = aBoundRect.Left();
325 		rVal.nMinVPos = aBoundRect.Top();
326 		SwTwips nH = rVal.nHPos;
327 		SwTwips nV = rVal.nVPos;
328 
329 		if (rVal.nHPos + rVal.nWidth > aBoundRect.Right())
330 		{
331             if (rVal.nHoriOrient == text::HoriOrientation::NONE)
332 			{
333 				rVal.nHPos -= ((rVal.nHPos + rVal.nWidth) - aBoundRect.Right());
334 				nH = rVal.nHPos;
335 			}
336 			else
337 				rVal.nWidth = aBoundRect.Right() - rVal.nHPos;
338 		}
339 
340 		if (rVal.nHPos + rVal.nWidth > aBoundRect.Right())
341 			rVal.nWidth = aBoundRect.Right() - rVal.nHPos;
342 
343 		if (rVal.nVPos + rVal.nHeight > aBoundRect.Bottom())
344 		{
345             if (rVal.nVertOrient == text::VertOrientation::NONE)
346 			{
347 				rVal.nVPos -= ((rVal.nVPos + rVal.nHeight) - aBoundRect.Bottom());
348 				nV = rVal.nVPos;
349 			}
350 			else
351 				rVal.nHeight = aBoundRect.Bottom() - rVal.nVPos;
352 		}
353 
354 		if (rVal.nVPos + rVal.nHeight > aBoundRect.Bottom())
355 			rVal.nHeight = aBoundRect.Bottom() - rVal.nVPos;
356 
357         if ( rVal.nVertOrient != text::VertOrientation::NONE )
358 			nV = aBoundRect.Top();
359 
360         if ( rVal.nHoriOrient != text::HoriOrientation::NONE )
361 			nH = aBoundRect.Left();
362 
363 		rVal.nMaxHPos	= aBoundRect.Right()  - rVal.nWidth;
364 		rVal.nMaxHeight = aBoundRect.Bottom() - nV;
365 
366 		rVal.nMaxVPos	= aBoundRect.Bottom() - rVal.nHeight;
367 		rVal.nMaxWidth	= aBoundRect.Right()  - nH;
368 	}
369     // OD 12.11.2003 #i22341# - handle to character anchored objects vertical
370     // aligned at character or top of line in a special case
371     else if ((eAnchorType == FLY_AT_PARA) ||
372                 ((eAnchorType == FLY_AT_CHAR) &&
373                 !(rVal.nVRelOrient == text::RelOrientation::CHAR) &&
374                 !(rVal.nVRelOrient == text::RelOrientation::TEXT_LINE) ) )
375 	{
376 		if (rVal.nHPos + rVal.nWidth > aBoundRect.Right())
377 		{
378             if (rVal.nHoriOrient == text::HoriOrientation::NONE)
379 			{
380 				rVal.nHPos -= ((rVal.nHPos + rVal.nWidth) - aBoundRect.Right());
381 			}
382 			else
383 				rVal.nWidth = aBoundRect.Right() - rVal.nHPos;
384 		}
385 
386         // OD 29.09.2003 #i17567#, #i18732# - consider following the text flow
387         // and alignment at page areas.
388         const bool bMaxVPosAtBottom = !rVal.bFollowTextFlow ||
389                                       rVal.nVRelOrient == text::RelOrientation::PAGE_FRAME ||
390                                       rVal.nVRelOrient == text::RelOrientation::PAGE_PRINT_AREA;
391         {
392             SwTwips nTmpMaxVPos = ( bMaxVPosAtBottom
393                                     ? aBoundRect.Bottom()
394                                     : aBoundRect.Height() ) -
395                                   rVal.nHeight;
396             if ( rVal.nVPos > nTmpMaxVPos )
397             {
398                 if (rVal.nVertOrient == text::VertOrientation::NONE)
399                 {
400                     rVal.nVPos = nTmpMaxVPos;
401                 }
402                 else
403                 {
404                     rVal.nHeight = ( bMaxVPosAtBottom
405                                      ? aBoundRect.Bottom()
406                                      : aBoundRect.Height() ) - rVal.nVPos;
407                 }
408             }
409         }
410 
411         rVal.nMinHPos  = aBoundRect.Left();
412         rVal.nMaxHPos  = aBoundRect.Right() - rVal.nWidth;
413 
414 		rVal.nMinVPos  = aBoundRect.Top();
415         // OD 26.09.2003 #i17567#, #i18732# - determine maximum vertical position
416         if ( bMaxVPosAtBottom )
417         {
418             rVal.nMaxVPos  = aBoundRect.Bottom() - rVal.nHeight;
419         }
420         else
421         {
422             rVal.nMaxVPos  = aBoundRect.Height() - rVal.nHeight;
423         }
424 
425 		// Maximale Breite Hoehe
426         const SwTwips nH = ( rVal.nHoriOrient != text::HoriOrientation::NONE )
427                            ? aBoundRect.Left()
428                            : rVal.nHPos;
429         const SwTwips nV = ( rVal.nVertOrient != text::VertOrientation::NONE )
430                            ? aBoundRect.Top()
431                            : rVal.nVPos;
432 		rVal.nMaxHeight  = rVal.nMaxVPos + rVal.nHeight - nV;
433 		rVal.nMaxWidth	 = rVal.nMaxHPos + rVal.nWidth - nH;
434 	}
435     // OD 12.11.2003 #i22341# - special case for to character anchored objects
436     // vertical aligned at character or top of line.
437     // Note: (1) positive vertical values are positions above the top of line
438     //       (2) negative vertical values are positions below the top of line
439     else if ( (eAnchorType == FLY_AT_CHAR) &&
440               ( rVal.nVRelOrient == text::RelOrientation::CHAR ||
441                 rVal.nVRelOrient == text::RelOrientation::TEXT_LINE ) )
442     {
443         // determine horizontal values
444         rVal.nMinHPos  = aBoundRect.Left();
445 
446         rVal.nMaxHPos  = aBoundRect.Right() - rVal.nWidth;
447         if (rVal.nHPos + rVal.nWidth > aBoundRect.Right())
448         {
449             if (rVal.nHoriOrient == text::HoriOrientation::NONE)
450             {
451                 rVal.nHPos -= ((rVal.nHPos + rVal.nWidth) - aBoundRect.Right());
452             }
453             else
454                 rVal.nWidth = aBoundRect.Right() - rVal.nHPos;
455         }
456 
457         const SwTwips nH = ( rVal.nHoriOrient != text::HoriOrientation::NONE )
458                            ? aBoundRect.Left()
459                            : rVal.nHPos;
460         rVal.nMaxWidth   = rVal.nMaxHPos + rVal.nWidth - nH;
461 
462         // determine vertical values
463         rVal.nMinVPos = -( aBoundRect.Bottom() - rVal.nHeight );
464         if ( rVal.nVPos < rVal.nMinVPos &&
465              rVal.nVertOrient == text::VertOrientation::NONE )
466         {
467             rVal.nVPos = rVal.nMinVPos;
468         }
469 
470         rVal.nMaxVPos  = -aBoundRect.Top();
471         if ( rVal.nVPos > rVal.nMaxVPos &&
472              rVal.nVertOrient == text::VertOrientation::NONE )
473         {
474             rVal.nVPos = rVal.nMaxVPos;
475         }
476 
477         if ( rVal.nVertOrient == text::VertOrientation::NONE )
478         {
479             rVal.nMaxHeight = aBoundRect.Bottom() + rVal.nVPos;
480         }
481         else
482         {
483             rVal.nMaxHeight = aBoundRect.Height();
484         }
485     }
486     else if ( eAnchorType == FLY_AS_CHAR )
487 	{
488 		rVal.nMinHPos = 0;
489 		rVal.nMaxHPos = 0;
490 
491 		rVal.nMaxHeight = aBoundRect.Height();
492 		rVal.nMaxWidth	= aBoundRect.Width();
493 
494 		rVal.nMaxVPos	= aBoundRect.Height();
495 		rVal.nMinVPos	= -aBoundRect.Height() + rVal.nHeight;
496 		if (rVal.nMaxVPos < rVal.nMinVPos)
497 		{
498 			rVal.nMinVPos = rVal.nMaxVPos;
499 			rVal.nMaxVPos = -aBoundRect.Height();
500 		}
501 	}
502     // --> OD 2009-09-01 #mongolianlayout#
503     if ( bIsInVertical || bIsInVerticalL2R )
504     // <--
505     {
506         //restore width/height exchange
507         long nTmp = rVal.nWidth;
508         rVal.nWidth = rVal.nHeight;
509         rVal.nHeight = nTmp;
510     }
511 
512     if (rVal.nMaxWidth < rVal.nWidth)
513 		rVal.nWidth = rVal.nMaxWidth;
514 	if (rVal.nMaxHeight < rVal.nHeight)
515 		rVal.nHeight = rVal.nMaxHeight;
516 }
517 
518 /*--------------------------------------------------------------------
519 	Beschreibung: Korrektur fuer Umrandung
520  --------------------------------------------------------------------*/
521 
CalcTopSpace()522 SwTwips SwFlyFrmAttrMgr::CalcTopSpace()
523 {
524 	const SvxShadowItem& rShadow = GetShadow();
525 	const SvxBoxItem& 	 rBox 	 = GetBox();
526 	return rShadow.CalcShadowSpace(SHADOW_TOP ) + rBox.CalcLineSpace(BOX_LINE_TOP);
527 }
528 
CalcBottomSpace()529 SwTwips SwFlyFrmAttrMgr::CalcBottomSpace()
530 {
531 	const SvxShadowItem& rShadow = GetShadow();
532 	const SvxBoxItem& rBox 		 = GetBox();
533 	return rShadow.CalcShadowSpace(SHADOW_BOTTOM) + rBox.CalcLineSpace(BOX_LINE_BOTTOM);
534 }
535 
CalcLeftSpace()536 SwTwips SwFlyFrmAttrMgr::CalcLeftSpace()
537 {
538 	const SvxShadowItem& rShadow = GetShadow();
539 	const SvxBoxItem&	 rBox 	 = GetBox();
540 	return rShadow.CalcShadowSpace(SHADOW_LEFT) + rBox.CalcLineSpace(BOX_LINE_LEFT);
541 }
542 
CalcRightSpace()543 SwTwips SwFlyFrmAttrMgr::CalcRightSpace()
544 {
545 	const SvxShadowItem& rShadow = GetShadow();
546 	const SvxBoxItem&	 rBox 	 = GetBox();
547 	return rShadow.CalcShadowSpace(SHADOW_RIGHT) + rBox.CalcLineSpace(BOX_LINE_RIGHT);
548 }
549 
550 
551 /*--------------------------------------------------------------------
552 	Beschreibung: Attribut aus dem Set loeschen
553  --------------------------------------------------------------------*/
DelAttr(sal_uInt16 nId)554 void SwFlyFrmAttrMgr::DelAttr( sal_uInt16 nId )
555 {
556 	aSet.ClearItem( nId );
557 }
558 
SetLRSpace(long nLeft,long nRight)559 void SwFlyFrmAttrMgr::SetLRSpace( long nLeft, long nRight )
560 {
561 	ASSERT( LONG_MAX != nLeft && LONG_MAX != nRight, "Welchen Raend setzen?" );
562 
563 	SvxLRSpaceItem aTmp( (SvxLRSpaceItem&)aSet.Get( RES_LR_SPACE ) );
564 	if( LONG_MAX != nLeft )
565 		aTmp.SetLeft( sal_uInt16(nLeft) );
566 	if( LONG_MAX != nRight )
567 		aTmp.SetRight( sal_uInt16(nRight) );
568 	aSet.Put( aTmp );
569 }
570 
SetULSpace(long nTop,long nBottom)571 void SwFlyFrmAttrMgr::SetULSpace( long nTop, long nBottom )
572 {
573 	ASSERT(LONG_MAX != nTop && LONG_MAX != nBottom, "Welchen Raend setzen?" );
574 
575 	SvxULSpaceItem aTmp( (SvxULSpaceItem&)aSet.Get( RES_UL_SPACE ) );
576 	if( LONG_MAX != nTop )
577 		aTmp.SetUpper( sal_uInt16(nTop) );
578 	if( LONG_MAX != nBottom )
579 		aTmp.SetLower( sal_uInt16(nBottom) );
580 	aSet.Put( aTmp );
581 }
582 
SetPos(const Point & rPoint)583 void SwFlyFrmAttrMgr::SetPos( const Point& rPoint )
584 {
585 	SwFmtVertOrient aVertOrient( GetVertOrient() );
586 	SwFmtHoriOrient aHoriOrient( GetHoriOrient() );
587 
588 	aHoriOrient.SetPos		 ( rPoint.X() );
589     aHoriOrient.SetHoriOrient( text::HoriOrientation::NONE  );
590 
591 	aVertOrient.SetPos		 ( rPoint.Y() );
592     aVertOrient.SetVertOrient( text::VertOrientation::NONE  );
593 
594 	aSet.Put( aVertOrient );
595 	aSet.Put( aHoriOrient );
596 }
597 
SetHorzOrientation(sal_Int16 eOrient)598 void SwFlyFrmAttrMgr::SetHorzOrientation( sal_Int16 eOrient )
599 {
600 	SwFmtHoriOrient aHoriOrient( GetHoriOrient() );
601 	aHoriOrient.SetHoriOrient( eOrient );
602 	aSet.Put( aHoriOrient );
603 }
604 
SetVertOrientation(sal_Int16 eOrient)605 void SwFlyFrmAttrMgr::SetVertOrientation( sal_Int16 eOrient )
606 {
607 	SwFmtVertOrient aVertOrient( GetVertOrient() );
608     aVertOrient.SetVertOrient( eOrient );
609 	aSet.Put( aVertOrient );
610 }
611 
SetHeightSizeType(SwFrmSize eType)612 void SwFlyFrmAttrMgr::SetHeightSizeType( SwFrmSize eType )
613 {
614 	SwFmtFrmSize aSize( GetFrmSize() );
615     aSize.SetHeightSizeType( eType );
616 	aSet.Put( aSize );
617 }
618 
SetSize(const Size & rSize)619 void SwFlyFrmAttrMgr::SetSize( const Size& rSize )
620 {
621 	SwFmtFrmSize aSize( GetFrmSize() );
622 	aSize.SetSize(Size(Max(rSize.Width(), long(MINFLY)), Max(rSize.Height(), long(MINFLY))));
623 	aSet.Put( aSize );
624 }
625 
SetAttrSet(const SfxItemSet & rSet)626 void SwFlyFrmAttrMgr::SetAttrSet(const SfxItemSet& rSet)
627 {
628 	aSet.ClearItem();
629 	aSet.Put( rSet );
630 }
631