LCOV - code coverage report
Current view: top level - sw/source/ui/frmdlg - frmmgr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 272 0.0 %
Date: 2012-08-25 Functions: 0 24 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 320 0.0 %

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

Generated by: LCOV version 1.10