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