1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #include <cmdid.h>
21 #include <hintids.hxx>
22
23 #include <svl/stritem.hxx>
24 #include <editeng/protitem.hxx>
25 #include <editeng/boxitem.hxx>
26 #include <editeng/opaqitem.hxx>
27 #include <editeng/lrspitem.hxx>
28 #include <editeng/ulspitem.hxx>
29 #include <editeng/shaditem.hxx>
30 #include <svx/swframevalidation.hxx>
31 #include <svx/xdef.hxx>
32 #include <svx/svxids.hrc>
33 #include <fmtclds.hxx>
34 #include <wrtsh.hxx>
35 #include <view.hxx>
36 #include <viewopt.hxx>
37 #include <uitool.hxx>
38 #include <frmmgr.hxx>
39 #include <format.hxx>
40 #include <mdiexp.hxx>
41 #include <poolfmt.hxx>
42 #include <com/sun/star/text/HoriOrientation.hpp>
43 #include <com/sun/star/text/VertOrientation.hpp>
44 #include <com/sun/star/text/RelOrientation.hpp>
45 #include <grfatr.hxx>
46
47 using namespace ::com::sun::star;
48
49 static sal_uInt16 aFrameMgrRange[] = {
50 RES_FRMATR_BEGIN, RES_FRMATR_END-1, // 87-129
51
52 // RotGrfFlyFrame: Support here, but seems not to be
53 // added in range of m_pOwnSh->GetFlyFrameAttr result
54 // (see below). Tried to find, but could not identify
55 RES_GRFATR_ROTATION, RES_GRFATR_ROTATION, // 132
56
57 // FillAttribute support
58 XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1014-1033
59
60 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
61 FN_SET_FRM_NAME, FN_SET_FRM_NAME,
62 0};
63
64 // determine frame attributes via Shell
SwFlyFrameAttrMgr(bool bNew,SwWrtShell * pSh,Frmmgr_Type nType)65 SwFlyFrameAttrMgr::SwFlyFrameAttrMgr( bool bNew, SwWrtShell* pSh, Frmmgr_Type nType ) :
66 m_aSet( static_cast<SwAttrPool&>(pSh->GetAttrPool()), aFrameMgrRange ),
67 m_pOwnSh( pSh ),
68 m_bAbsPos( false ),
69 m_bNewFrame( bNew ),
70 m_bIsInVertical( false ),
71 m_bIsInVerticalL2R( false )
72 {
73 if ( m_bNewFrame )
74 {
75 sal_uInt16 nId;
76 switch ( nType )
77 {
78 case Frmmgr_Type::TEXT: nId = RES_POOLFRM_FRAME; break;
79 case Frmmgr_Type::OLE: nId = RES_POOLFRM_OLE; break;
80 case Frmmgr_Type::GRF: nId = RES_POOLFRM_GRAPHIC; break;
81 // set defaults:
82 default: nId=0; break;
83 }
84 m_aSet.SetParent( &m_pOwnSh->GetFormatFromPool( nId )->GetAttrSet());
85 m_aSet.Put( SwFormatFrameSize( ATT_MIN_SIZE, DFLT_WIDTH, DFLT_HEIGHT ));
86 if ( 0 != ::GetHtmlMode(pSh->GetView().GetDocShell()) )
87 m_aSet.Put( SwFormatHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::PRINT_AREA ) );
88
89 if (nType == Frmmgr_Type::GRF || nType == Frmmgr_Type::OLE)
90 {
91 m_aSet.Put(SwFormatAnchor(RndStdIds::FLY_AT_CHAR));
92 }
93 }
94 else if ( nType == Frmmgr_Type::NONE )
95 {
96 m_pOwnSh->GetFlyFrameAttr( m_aSet );
97 bool bRightToLeft;
98 m_bIsInVertical = m_pOwnSh->IsFrameVertical(true, bRightToLeft, m_bIsInVerticalL2R);
99 }
100 ::PrepareBoxInfo( m_aSet, *m_pOwnSh );
101 }
102
SwFlyFrameAttrMgr(bool bNew,SwWrtShell * pSh,const SfxItemSet & rSet)103 SwFlyFrameAttrMgr::SwFlyFrameAttrMgr( bool bNew, SwWrtShell* pSh, const SfxItemSet &rSet ) :
104 m_aSet( rSet ),
105 m_pOwnSh( pSh ),
106 m_bAbsPos( false ),
107 m_bNewFrame( bNew ),
108 m_bIsInVertical(false),
109 m_bIsInVerticalL2R(false)
110 {
111 if(!bNew)
112 {
113 bool bRightToLeft;
114 m_bIsInVertical = pSh->IsFrameVertical(true, bRightToLeft, m_bIsInVerticalL2R);
115 }
116 }
117
118 // Initialise
UpdateAttrMgr()119 void SwFlyFrameAttrMgr::UpdateAttrMgr()
120 {
121 if ( !m_bNewFrame && m_pOwnSh->IsFrameSelected() )
122 m_pOwnSh->GetFlyFrameAttr( m_aSet );
123 ::PrepareBoxInfo( m_aSet, *m_pOwnSh );
124 }
125
UpdateFlyFrame_()126 void SwFlyFrameAttrMgr::UpdateFlyFrame_()
127 {
128 const SfxPoolItem* pItem = nullptr;
129
130 if (m_aSet.GetItemState(FN_SET_FRM_NAME, false, &pItem) == SfxItemState::SET)
131 m_pOwnSh->SetFlyName(static_cast<const SfxStringItem *>(pItem)->GetValue());
132
133 m_pOwnSh->SetModified();
134
135 if ( m_bAbsPos )
136 {
137 m_pOwnSh->SetFlyPos( m_aAbsPos );
138 m_bAbsPos = false;
139 }
140 }
141
142 // change existing Fly-Frame
UpdateFlyFrame()143 void SwFlyFrameAttrMgr::UpdateFlyFrame()
144 {
145 OSL_ENSURE( m_pOwnSh->IsFrameSelected(),
146 "no frame selected or no shell, update not possible");
147
148 if( m_pOwnSh->IsFrameSelected() )
149 {
150 //JP 6.8.2001: set never an invalid anchor into the core.
151 const SfxPoolItem *pGItem, *pItem;
152 if( SfxItemState::SET == m_aSet.GetItemState( RES_ANCHOR, false, &pItem ))
153 {
154 SfxItemSet aGetSet( *m_aSet.GetPool(), svl::Items<RES_ANCHOR, RES_ANCHOR>{} );
155 if( m_pOwnSh->GetFlyFrameAttr( aGetSet ) && 1 == aGetSet.Count() &&
156 SfxItemState::SET == aGetSet.GetItemState( RES_ANCHOR, false, &pGItem )
157 && static_cast<const SwFormatAnchor*>(pGItem)->GetAnchorId() ==
158 static_cast<const SwFormatAnchor*>(pItem)->GetAnchorId() )
159 m_aSet.ClearItem( RES_ANCHOR );
160 }
161
162 // return wg. BASIC
163 if( m_aSet.Count() )
164 {
165 m_pOwnSh->StartAllAction();
166 m_pOwnSh->SetFlyFrameAttr( m_aSet );
167 UpdateFlyFrame_();
168 m_pOwnSh->EndAllAction();
169 }
170 }
171 }
172
173 // insert frame
InsertFlyFrame()174 void SwFlyFrameAttrMgr::InsertFlyFrame()
175 {
176 m_pOwnSh->StartAllAction();
177
178 bool bRet = nullptr != m_pOwnSh->NewFlyFrame( m_aSet );
179
180 // turn on the right mode at the shell, frame got selected automatically.
181 if ( bRet )
182 {
183 UpdateFlyFrame_();
184 m_pOwnSh->EnterSelFrameMode();
185 FrameNotify(m_pOwnSh, FLY_DRAG_START);
186 }
187 m_pOwnSh->EndAllAction();
188 }
189
190 // Insert frames of type eAnchorType. Position and size are being set explicitly.
191 // Not-allowed values of the enumeration type get corrected.
InsertFlyFrame(RndStdIds eAnchorType,const Point & rPos,const Size & rSize)192 void SwFlyFrameAttrMgr::InsertFlyFrame(RndStdIds eAnchorType,
193 const Point &rPos,
194 const Size &rSize )
195 {
196 OSL_ENSURE( eAnchorType == RndStdIds::FLY_AT_PAGE ||
197 eAnchorType == RndStdIds::FLY_AT_PARA ||
198 eAnchorType == RndStdIds::FLY_AT_CHAR ||
199 eAnchorType == RndStdIds::FLY_AT_FLY ||
200 eAnchorType == RndStdIds::FLY_AS_CHAR, "invalid frame type" );
201
202 SetPos( rPos );
203
204 SetSize( rSize );
205 SetAnchor( eAnchorType );
206 InsertFlyFrame();
207 }
208
209 // set anchor
SetAnchor(RndStdIds eId)210 void SwFlyFrameAttrMgr::SetAnchor( RndStdIds eId )
211 {
212 sal_uInt16 nPhyPageNum, nVirtPageNum;
213 m_pOwnSh->GetPageNum( nPhyPageNum, nVirtPageNum );
214
215 m_aSet.Put( SwFormatAnchor( eId, nPhyPageNum ) );
216 if ((RndStdIds::FLY_AT_PAGE == eId) || (RndStdIds::FLY_AT_PARA == eId) || (RndStdIds::FLY_AT_CHAR == eId)
217 || (RndStdIds::FLY_AT_FLY == eId))
218 {
219 SwFormatVertOrient aVertOrient( GetVertOrient() );
220 SwFormatHoriOrient aHoriOrient( GetHoriOrient() );
221 aHoriOrient.SetRelationOrient( text::RelOrientation::FRAME );
222 aVertOrient.SetRelationOrient( text::RelOrientation::FRAME );
223 m_aSet.Put( aVertOrient );
224 m_aSet.Put( aHoriOrient );
225 }
226 }
227
228 // set the attribute for columns
SetCol(const SwFormatCol & rCol)229 void SwFlyFrameAttrMgr::SetCol( const SwFormatCol &rCol )
230 {
231 m_aSet.Put( rCol );
232 }
233
234 // set absolute position
SetAbsPos(const Point & rPoint)235 void SwFlyFrameAttrMgr::SetAbsPos( const Point& rPoint )
236 {
237 m_bAbsPos = true;
238 m_aAbsPos = rPoint;
239 SwFormatVertOrient aVertOrient( GetVertOrient() );
240 SwFormatHoriOrient aHoriOrient( GetHoriOrient() );
241 aHoriOrient.SetHoriOrient( text::HoriOrientation::NONE );
242 aVertOrient.SetVertOrient( text::VertOrientation::NONE );
243 m_aSet.Put( aVertOrient );
244 m_aSet.Put( aHoriOrient );
245 }
246
247 // check metrics for correctness
ValidateMetrics(SvxSwFrameValidation & rVal,const SwPosition * pToCharContentPos,bool bOnlyPercentRefValue)248 void SwFlyFrameAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal,
249 const SwPosition* pToCharContentPos,
250 bool bOnlyPercentRefValue )
251 {
252 if (!bOnlyPercentRefValue)
253 {
254 rVal.nMinHeight = MINFLY + CalcTopSpace() + CalcBottomSpace();
255 rVal.nMinWidth = MINFLY + CalcLeftSpace()+ CalcRightSpace();
256 }
257
258 SwRect aBoundRect;
259
260 // OD 18.09.2003 #i18732# - adjustment for allowing vertical position
261 // aligned to page for fly frame anchored to paragraph or to character.
262 const RndStdIds eAnchorType = rVal.nAnchorType;
263 const SwFormatFrameSize& rSize = m_aSet.Get(RES_FRM_SIZE);
264 m_pOwnSh->CalcBoundRect( aBoundRect, eAnchorType,
265 rVal.nHRelOrient,
266 rVal.nVRelOrient,
267 pToCharContentPos,
268 rVal.bFollowTextFlow,
269 rVal.bMirror, nullptr, &rVal.aPercentSize,
270 &rSize);
271
272 if (bOnlyPercentRefValue)
273 return;
274
275 // #mongolianlayout#
276 if ( m_bIsInVertical || m_bIsInVerticalL2R )
277 {
278 Point aPos(aBoundRect.Pos());
279 long nTmp = aPos.X();
280 aPos.setX( aPos.Y() );
281 aPos.setY( nTmp );
282 Size aSize(aBoundRect.SSize());
283 nTmp = aSize.Width();
284 aSize.setWidth( aSize.Height() );
285 aSize.setHeight( nTmp );
286 aBoundRect.Chg( aPos, aSize );
287 //exchange width/height to enable correct values
288 nTmp = rVal.nWidth;
289 rVal.nWidth = rVal.nHeight;
290 rVal.nHeight = nTmp;
291 }
292 if ((eAnchorType == RndStdIds::FLY_AT_PAGE) || (eAnchorType == RndStdIds::FLY_AT_FLY))
293 {
294 // MinimalPosition
295 rVal.nMinHPos = aBoundRect.Left();
296 rVal.nMinVPos = aBoundRect.Top();
297 SwTwips nH = rVal.nHPos;
298 SwTwips nV = rVal.nVPos;
299
300 if (rVal.nHPos + rVal.nWidth > aBoundRect.Right())
301 {
302 if (rVal.nHoriOrient == text::HoriOrientation::NONE)
303 {
304 rVal.nHPos -= ((rVal.nHPos + rVal.nWidth) - aBoundRect.Right());
305 nH = rVal.nHPos;
306 }
307 else
308 rVal.nWidth = aBoundRect.Right() - rVal.nHPos;
309 }
310
311 if (rVal.nHPos + rVal.nWidth > aBoundRect.Right())
312 rVal.nWidth = aBoundRect.Right() - rVal.nHPos;
313
314 if (rVal.nVPos + rVal.nHeight > aBoundRect.Bottom())
315 {
316 if (rVal.nVertOrient == text::VertOrientation::NONE)
317 {
318 rVal.nVPos -= ((rVal.nVPos + rVal.nHeight) - aBoundRect.Bottom());
319 nV = rVal.nVPos;
320 }
321 else
322 rVal.nHeight = aBoundRect.Bottom() - rVal.nVPos;
323 }
324
325 if (rVal.nVPos + rVal.nHeight > aBoundRect.Bottom())
326 rVal.nHeight = aBoundRect.Bottom() - rVal.nVPos;
327
328 if ( rVal.nVertOrient != text::VertOrientation::NONE )
329 nV = aBoundRect.Top();
330
331 if ( rVal.nHoriOrient != text::HoriOrientation::NONE )
332 nH = aBoundRect.Left();
333
334 rVal.nMaxHPos = aBoundRect.Right() - rVal.nWidth;
335 rVal.nMaxHeight = aBoundRect.Bottom() - nV;
336
337 rVal.nMaxVPos = aBoundRect.Bottom() - rVal.nHeight;
338 rVal.nMaxWidth = aBoundRect.Right() - nH;
339 }
340 // OD 12.11.2003 #i22341# - handle to character anchored objects vertical
341 // aligned at character or top of line in a special case
342 else if ((eAnchorType == RndStdIds::FLY_AT_PARA) ||
343 ((eAnchorType == RndStdIds::FLY_AT_CHAR) &&
344 (rVal.nVRelOrient != text::RelOrientation::CHAR) &&
345 (rVal.nVRelOrient != text::RelOrientation::TEXT_LINE) ) )
346 {
347 if (rVal.nHPos + rVal.nWidth > aBoundRect.Right())
348 {
349 if (rVal.nHoriOrient == text::HoriOrientation::NONE)
350 {
351 rVal.nHPos -= ((rVal.nHPos + rVal.nWidth) - aBoundRect.Right());
352 }
353 else
354 rVal.nWidth = aBoundRect.Right() - rVal.nHPos;
355 }
356
357 // OD 29.09.2003 #i17567#, #i18732# - consider following the text flow
358 // and alignment at page areas.
359 const bool bMaxVPosAtBottom = !rVal.bFollowTextFlow ||
360 rVal.nVRelOrient == text::RelOrientation::PAGE_FRAME ||
361 rVal.nVRelOrient == text::RelOrientation::PAGE_PRINT_AREA;
362 {
363 SwTwips nTmpMaxVPos = ( bMaxVPosAtBottom
364 ? aBoundRect.Bottom()
365 : aBoundRect.Height() ) -
366 rVal.nHeight;
367 if ( rVal.nVPos > nTmpMaxVPos )
368 {
369 if (rVal.nVertOrient == text::VertOrientation::NONE)
370 {
371 rVal.nVPos = nTmpMaxVPos;
372 }
373 else
374 {
375 rVal.nHeight = ( bMaxVPosAtBottom
376 ? aBoundRect.Bottom()
377 : aBoundRect.Height() ) - rVal.nVPos;
378 }
379 }
380 }
381
382 rVal.nMinHPos = aBoundRect.Left();
383 rVal.nMaxHPos = aBoundRect.Right() - rVal.nWidth;
384
385 rVal.nMinVPos = aBoundRect.Top();
386 // OD 26.09.2003 #i17567#, #i18732# - determine maximum vertical position
387 if ( bMaxVPosAtBottom )
388 {
389 rVal.nMaxVPos = aBoundRect.Bottom() - rVal.nHeight;
390 }
391 else
392 {
393 rVal.nMaxVPos = aBoundRect.Height() - rVal.nHeight;
394 }
395
396 // maximum width height
397 const SwTwips nH = ( rVal.nHoriOrient != text::HoriOrientation::NONE )
398 ? aBoundRect.Left()
399 : rVal.nHPos;
400 const SwTwips nV = ( rVal.nVertOrient != text::VertOrientation::NONE )
401 ? aBoundRect.Top()
402 : rVal.nVPos;
403 rVal.nMaxHeight = rVal.nMaxVPos + rVal.nHeight - nV;
404 rVal.nMaxWidth = rVal.nMaxHPos + rVal.nWidth - nH;
405 }
406 // OD 12.11.2003 #i22341# - special case for to character anchored objects
407 // vertical aligned at character or top of line.
408 // Note: (1) positive vertical values are positions above the top of line
409 // (2) negative vertical values are positions below the top of line
410 else if ( (eAnchorType == RndStdIds::FLY_AT_CHAR) &&
411 ( rVal.nVRelOrient == text::RelOrientation::CHAR ||
412 rVal.nVRelOrient == text::RelOrientation::TEXT_LINE ) )
413 {
414 // determine horizontal values
415 rVal.nMinHPos = aBoundRect.Left();
416
417 rVal.nMaxHPos = aBoundRect.Right() - rVal.nWidth;
418 if (rVal.nHPos + rVal.nWidth > aBoundRect.Right())
419 {
420 if (rVal.nHoriOrient == text::HoriOrientation::NONE)
421 {
422 rVal.nHPos -= ((rVal.nHPos + rVal.nWidth) - aBoundRect.Right());
423 }
424 else
425 rVal.nWidth = aBoundRect.Right() - rVal.nHPos;
426 }
427
428 const SwTwips nH = ( rVal.nHoriOrient != text::HoriOrientation::NONE )
429 ? aBoundRect.Left()
430 : rVal.nHPos;
431 rVal.nMaxWidth = rVal.nMaxHPos + rVal.nWidth - nH;
432
433 // determine vertical values
434 rVal.nMinVPos = -( aBoundRect.Bottom() - rVal.nHeight );
435 if ( rVal.nVPos < rVal.nMinVPos &&
436 rVal.nVertOrient == text::VertOrientation::NONE )
437 {
438 rVal.nVPos = rVal.nMinVPos;
439 }
440
441 rVal.nMaxVPos = -aBoundRect.Top();
442 if ( rVal.nVPos > rVal.nMaxVPos &&
443 rVal.nVertOrient == text::VertOrientation::NONE )
444 {
445 rVal.nVPos = rVal.nMaxVPos;
446 }
447
448 if ( rVal.nVertOrient == text::VertOrientation::NONE )
449 {
450 rVal.nMaxHeight = aBoundRect.Bottom() + rVal.nVPos;
451 }
452 else
453 {
454 rVal.nMaxHeight = aBoundRect.Height();
455 }
456 }
457 else if ( eAnchorType == RndStdIds::FLY_AS_CHAR )
458 {
459 rVal.nMinHPos = 0;
460 rVal.nMaxHPos = 0;
461
462 rVal.nMaxHeight = aBoundRect.Height();
463 rVal.nMaxWidth = aBoundRect.Width();
464
465 rVal.nMaxVPos = aBoundRect.Height();
466 rVal.nMinVPos = -aBoundRect.Height() + rVal.nHeight;
467 if (rVal.nMaxVPos < rVal.nMinVPos)
468 {
469 rVal.nMinVPos = rVal.nMaxVPos;
470 rVal.nMaxVPos = -aBoundRect.Height();
471 }
472 }
473 // #mongolianlayout#
474 if ( m_bIsInVertical || m_bIsInVerticalL2R )
475 {
476 //restore width/height exchange
477 long nTmp = rVal.nWidth;
478 rVal.nWidth = rVal.nHeight;
479 rVal.nHeight = nTmp;
480 }
481
482 if (rVal.nMaxWidth < rVal.nWidth)
483 rVal.nWidth = rVal.nMaxWidth;
484 if (rVal.nMaxHeight < rVal.nHeight)
485 rVal.nHeight = rVal.nMaxHeight;
486 }
487
488 // correction for border
CalcTopSpace()489 SwTwips SwFlyFrameAttrMgr::CalcTopSpace()
490 {
491 const SvxShadowItem& rShadow = GetShadow();
492 const SvxBoxItem& rBox = GetBox();
493 return rShadow.CalcShadowSpace(SvxShadowItemSide::TOP ) + rBox.CalcLineSpace(SvxBoxItemLine::TOP);
494 }
495
CalcBottomSpace()496 SwTwips SwFlyFrameAttrMgr::CalcBottomSpace()
497 {
498 const SvxShadowItem& rShadow = GetShadow();
499 const SvxBoxItem& rBox = GetBox();
500 return rShadow.CalcShadowSpace(SvxShadowItemSide::BOTTOM) + rBox.CalcLineSpace(SvxBoxItemLine::BOTTOM);
501 }
502
CalcLeftSpace()503 SwTwips SwFlyFrameAttrMgr::CalcLeftSpace()
504 {
505 const SvxShadowItem& rShadow = GetShadow();
506 const SvxBoxItem& rBox = GetBox();
507 return rShadow.CalcShadowSpace(SvxShadowItemSide::LEFT) + rBox.CalcLineSpace(SvxBoxItemLine::LEFT);
508 }
509
CalcRightSpace()510 SwTwips SwFlyFrameAttrMgr::CalcRightSpace()
511 {
512 const SvxShadowItem& rShadow = GetShadow();
513 const SvxBoxItem& rBox = GetBox();
514 return rShadow.CalcShadowSpace(SvxShadowItemSide::RIGHT) + rBox.CalcLineSpace(SvxBoxItemLine::RIGHT);
515 }
516
517 // erase attribute from the set
DelAttr(sal_uInt16 nId)518 void SwFlyFrameAttrMgr::DelAttr( sal_uInt16 nId )
519 {
520 m_aSet.ClearItem( nId );
521 }
522
SetLRSpace(long nLeft,long nRight)523 void SwFlyFrameAttrMgr::SetLRSpace( long nLeft, long nRight )
524 {
525 OSL_ENSURE( LONG_MAX != nLeft && LONG_MAX != nRight, "Which border to set?" );
526
527 SvxLRSpaceItem aTmp( m_aSet.Get( RES_LR_SPACE ) );
528 if( LONG_MAX != nLeft )
529 aTmp.SetLeft( sal_uInt16(nLeft) );
530 if( LONG_MAX != nRight )
531 aTmp.SetRight( sal_uInt16(nRight) );
532 m_aSet.Put( aTmp );
533 }
534
SetULSpace(long nTop,long nBottom)535 void SwFlyFrameAttrMgr::SetULSpace( long nTop, long nBottom )
536 {
537 OSL_ENSURE(LONG_MAX != nTop && LONG_MAX != nBottom, "Which border to set?" );
538
539 SvxULSpaceItem aTmp( m_aSet.Get( RES_UL_SPACE ) );
540 if( LONG_MAX != nTop )
541 aTmp.SetUpper( sal_uInt16(nTop) );
542 if( LONG_MAX != nBottom )
543 aTmp.SetLower( sal_uInt16(nBottom) );
544 m_aSet.Put( aTmp );
545 }
546
SetPos(const Point & rPoint)547 void SwFlyFrameAttrMgr::SetPos( const Point& rPoint )
548 {
549 SwFormatVertOrient aVertOrient( GetVertOrient() );
550 SwFormatHoriOrient aHoriOrient( GetHoriOrient() );
551
552 aHoriOrient.SetPos ( rPoint.X() );
553 aHoriOrient.SetHoriOrient( text::HoriOrientation::NONE );
554
555 aVertOrient.SetPos ( rPoint.Y() );
556 aVertOrient.SetVertOrient( text::VertOrientation::NONE );
557
558 m_aSet.Put( aVertOrient );
559 m_aSet.Put( aHoriOrient );
560 }
561
SetHorzOrientation(sal_Int16 eOrient)562 void SwFlyFrameAttrMgr::SetHorzOrientation( sal_Int16 eOrient )
563 {
564 SwFormatHoriOrient aHoriOrient( GetHoriOrient() );
565 aHoriOrient.SetHoriOrient( eOrient );
566 m_aSet.Put( aHoriOrient );
567 }
568
SetVertOrientation(sal_Int16 eOrient)569 void SwFlyFrameAttrMgr::SetVertOrientation( sal_Int16 eOrient )
570 {
571 SwFormatVertOrient aVertOrient( GetVertOrient() );
572 aVertOrient.SetVertOrient( eOrient );
573 m_aSet.Put( aVertOrient );
574 }
575
SetHeightSizeType(SwFrameSize eType)576 void SwFlyFrameAttrMgr::SetHeightSizeType( SwFrameSize eType )
577 {
578 SwFormatFrameSize aSize( GetFrameSize() );
579 aSize.SetHeightSizeType( eType );
580 m_aSet.Put( aSize );
581 }
582
SetRotation(sal_uInt16 nOld,sal_uInt16 nNew,const Size & rUnrotatedSize)583 void SwFlyFrameAttrMgr::SetRotation(sal_uInt16 nOld, sal_uInt16 nNew, const Size& rUnrotatedSize)
584 {
585 // RotGrfFlyFrame: Central handling of real change of rotation here, all adaptations use this.
586 // Adaptation of pos/size may be wanted in the future. Already tried to keep last Size in
587 // UnrotatedSize in the SwRotationGrf Item, but this will lead to various problems. Also tried
588 // to use m_aSet.Put(...) as in other methods (also tried read methods for Rotation/UnrotatedSize) but
589 // somehow the needed ID (RES_GRFATR_ROTATION) is *not* in the SfxItemSet of the Frame, so for
590 // now set directly. Undo/Redo is preserved by AttributeChange
591 if(nOld != nNew)
592 {
593 m_pOwnSh->SetAttrItem(SwRotationGrf(nNew, rUnrotatedSize));
594 }
595 }
596
SetSize(const Size & rSize)597 void SwFlyFrameAttrMgr::SetSize( const Size& rSize )
598 {
599 SwFormatFrameSize aSize( GetFrameSize() );
600 aSize.SetSize(Size(std::max(rSize.Width(), long(MINFLY)), std::max(rSize.Height(), long(MINFLY))));
601 m_aSet.Put( aSize );
602 }
603
SetAttrSet(const SfxItemSet & rSet)604 void SwFlyFrameAttrMgr::SetAttrSet(const SfxItemSet& rSet)
605 {
606 m_aSet.ClearItem();
607 m_aSet.Put( rSet );
608 }
609
610 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
611