LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/layout - flyincnt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 113 133 85.0 %
Date: 2013-07-09 Functions: 17 19 89.5 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      21             : #include "cntfrm.hxx"
      22             : #include "doc.hxx"
      23             : #include "flyfrm.hxx"
      24             : #include "frmtool.hxx"
      25             : #include "frmfmt.hxx"
      26             : #include "hints.hxx"
      27             : #include <fmtornt.hxx>
      28             : #include <fmtfsize.hxx>
      29             : #include "txtfrm.hxx"       //fuer IsLocked()
      30             : #include "flyfrms.hxx"
      31             : // OD 2004-01-19 #110582#
      32             : #include <dflyobj.hxx>
      33             : 
      34             : //from FlyCnt.cxx
      35             : void DeepCalc( const SwFrm *pFrm );
      36             : 
      37             : /*************************************************************************
      38             : |*
      39             : |*  SwFlyInCntFrm::SwFlyInCntFrm(), ~SwFlyInCntFrm()
      40             : |*
      41             : |*************************************************************************/
      42         189 : SwFlyInCntFrm::SwFlyInCntFrm( SwFlyFrmFmt *pFmt, SwFrm* pSib, SwFrm *pAnch ) :
      43         189 :     SwFlyFrm( pFmt, pSib, pAnch )
      44             : {
      45         189 :     bInCnt = bInvalidLayout = bInvalidCntnt = sal_True;
      46         189 :     SwTwips nRel = pFmt->GetVertOrient().GetPos();
      47             :     // OD 2004-05-27 #i26791# - member <aRelPos> moved to <SwAnchoredObject>
      48         189 :     Point aRelPos;
      49         189 :     if( pAnch && pAnch->IsVertical() )
      50           0 :         aRelPos.setX(pAnch->IsReverse() ? nRel : -nRel);
      51             :     else
      52         189 :         aRelPos.setY(nRel);
      53         189 :     SetCurrRelPos( aRelPos );
      54         189 : }
      55             : 
      56         567 : SwFlyInCntFrm::~SwFlyInCntFrm()
      57             : {
      58             :     //good bye
      59         189 :     if ( !GetFmt()->GetDoc()->IsInDtor() && GetAnchorFrm() )
      60             :     {
      61         189 :         SwRect aTmp( GetObjRectWithSpaces() );
      62         189 :         SwFlyInCntFrm::NotifyBackground( FindPageFrm(), aTmp, PREP_FLY_LEAVE );
      63             :     }
      64         378 : }
      65             : 
      66             : // #i28701#
      67        7941 : TYPEINIT1(SwFlyInCntFrm,SwFlyFrm);
      68             : /*************************************************************************
      69             : |*
      70             : |*  SwFlyInCntFrm::SetRefPoint(),
      71             : |*
      72             : |*************************************************************************/
      73         315 : void SwFlyInCntFrm::SetRefPoint( const Point& rPoint,
      74             :                                  const Point& rRelAttr,
      75             :                                  const Point& rRelPos )
      76             : {
      77             :     // OD 2004-05-27 #i26791# - member <aRelPos> moved to <SwAnchoredObject>
      78             :     OSL_ENSURE( rPoint != aRef || rRelAttr != GetCurrRelPos(), "SetRefPoint: no change" );
      79         315 :     SwFlyNotify *pNotify = NULL;
      80             :     // No notify at a locked fly frame, if a fly frame is locked, there's
      81             :     // already a SwFlyNotify object on the stack (MakeAll).
      82         315 :     if( !IsLocked() )
      83         315 :         pNotify = new SwFlyNotify( this );
      84         315 :     aRef = rPoint;
      85         315 :     SetCurrRelPos( rRelAttr );
      86         315 :     SWRECTFN( GetAnchorFrm() )
      87         315 :     (Frm().*fnRect->fnSetPos)( rPoint + rRelPos );
      88             :     // #i68520#
      89         315 :     InvalidateObjRectWithSpaces();
      90         315 :     if( pNotify )
      91             :     {
      92         315 :         InvalidatePage();
      93         315 :         mbValidPos = sal_False;
      94         315 :         bInvalid  = sal_True;
      95         315 :         Calc();
      96         315 :         delete pNotify;
      97             :     }
      98         315 : }
      99             : 
     100             : /*************************************************************************
     101             : |*
     102             : |*  SwFlyInCntFrm::Modify()
     103             : |*
     104             : |*************************************************************************/
     105          25 : void SwFlyInCntFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
     106             : {
     107          25 :     bool bCallPrepare = false;
     108          25 :     sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
     109          25 :     if( RES_ATTRSET_CHG == nWhich )
     110             :     {
     111          20 :         if( SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->
     112          18 :             GetItemState( RES_SURROUND, sal_False ) ||
     113           8 :             SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->
     114           8 :             GetItemState( RES_FRMMACRO, sal_False ) )
     115             :         {
     116           2 :             SwAttrSetChg aOld( *(SwAttrSetChg*)pOld );
     117           4 :             SwAttrSetChg aNew( *(SwAttrSetChg*)pNew );
     118             : 
     119           2 :             aOld.ClearItem( RES_SURROUND );
     120           2 :             aNew.ClearItem( RES_SURROUND );
     121           2 :             aOld.ClearItem( RES_FRMMACRO );
     122           2 :             aNew.ClearItem( RES_FRMMACRO );
     123           2 :             if( aNew.Count() )
     124             :             {
     125           0 :                 SwFlyFrm::Modify( &aOld, &aNew );
     126           0 :                 bCallPrepare = true;
     127           2 :             }
     128             :         }
     129           8 :         else if( ((SwAttrSetChg*)pNew)->GetChgSet()->Count())
     130             :         {
     131           8 :             SwFlyFrm::Modify( pOld, pNew );
     132           8 :             bCallPrepare = true;
     133             :         }
     134             :     }
     135          15 :     else if( nWhich != RES_SURROUND && RES_FRMMACRO != nWhich )
     136             :     {
     137          15 :         SwFlyFrm::Modify( pOld, pNew );
     138          15 :         bCallPrepare = true;
     139             :     }
     140             : 
     141          25 :     if ( bCallPrepare && GetAnchorFrm() )
     142          23 :         AnchorFrm()->Prepare( PREP_FLY_ATTR_CHG, GetFmt() );
     143          25 : }
     144             : /*************************************************************************
     145             : |*
     146             : |*  SwFlyInCntFrm::Format()
     147             : |*
     148             : |*  Here the content gets formatted initially.
     149             : |*
     150             : |*************************************************************************/
     151         395 : void SwFlyInCntFrm::Format( const SwBorderAttrs *pAttrs )
     152             : {
     153         395 :     if ( !Frm().Height() )
     154             :     {
     155           0 :         Lock(); //don't format the anchor on the crook.
     156           0 :         SwCntntFrm *pCntnt = ContainsCntnt();
     157           0 :         while ( pCntnt )
     158           0 :         {   pCntnt->Calc();
     159           0 :             pCntnt = pCntnt->GetNextCntntFrm();
     160             :         }
     161           0 :         Unlock();
     162             :     }
     163         395 :     SwFlyFrm::Format( pAttrs );
     164         395 : }
     165             : /*************************************************************************
     166             : |*
     167             : |*  SwFlyInCntFrm::MakeFlyPos()
     168             : |*
     169             : |*  Description         In contrast to other Frms we only calculate the RelPos
     170             : |*      here. The absolute position is only calculated using SetAbsPos.
     171             : |*************************************************************************/
     172             : // OD 2004-03-23 #i26791#
     173             : //void SwFlyInCntFrm::MakeFlyPos()
     174         508 : void SwFlyInCntFrm::MakeObjPos()
     175             : {
     176         508 :     if ( !mbValidPos )
     177             :     {
     178         508 :         mbValidPos = sal_True;
     179         508 :         SwFlyFrmFmt *pFmt = (SwFlyFrmFmt*)GetFmt();
     180         508 :         const SwFmtVertOrient &rVert = pFmt->GetVertOrient();
     181             :         //Update the current values in the format if needed, during this we of
     182             :         //course must not send any Modify.
     183         508 :         const bool bVert = GetAnchorFrm()->IsVertical();
     184         508 :         const bool bRev = GetAnchorFrm()->IsReverse();
     185         508 :         SwTwips nOld = rVert.GetPos();
     186         508 :         SwTwips nAct = bVert ? -GetCurrRelPos().X() : GetCurrRelPos().Y();
     187         508 :         if( bRev )
     188           0 :             nAct = -nAct;
     189         508 :         if( nAct != nOld )
     190             :         {
     191         243 :             SwFmtVertOrient aVert( rVert );
     192         243 :             aVert.SetPos( nAct );
     193         243 :             pFmt->LockModify();
     194         243 :             pFmt->SetFmtAttr( aVert );
     195         243 :             pFmt->UnlockModify();
     196             :         }
     197             :     }
     198         508 : }
     199             : 
     200             : // #115759#
     201         228 : void SwFlyInCntFrm::_ActionOnInvalidation( const InvalidationType _nInvalid )
     202             : {
     203         228 :     if ( INVALID_POS == _nInvalid || INVALID_ALL == _nInvalid )
     204          18 :         AnchorFrm()->Prepare( PREP_FLY_ATTR_CHG, &GetFrmFmt() );
     205         228 : }
     206             : /*************************************************************************
     207             : |*
     208             : |*  SwFlyInCntFrm::NotifyBackground()
     209             : |*
     210             : |*************************************************************************/
     211         406 : void SwFlyInCntFrm::NotifyBackground( SwPageFrm *, const SwRect& rRect,
     212             :                                        PrepareHint eHint)
     213             : {
     214         406 :     if ( eHint == PREP_FLY_ATTR_CHG )
     215           0 :         AnchorFrm()->Prepare( PREP_FLY_ATTR_CHG );
     216             :     else
     217         406 :         AnchorFrm()->Prepare( eHint, (void*)&rRect );
     218         406 : }
     219             : 
     220             : /*************************************************************************
     221             : |*
     222             : |*  SwFlyInCntFrm::GetRelPos()
     223             : |*
     224             : |*************************************************************************/
     225          50 : const Point SwFlyInCntFrm::GetRelPos() const
     226             : {
     227          50 :     Calc();
     228          50 :     return GetCurrRelPos();
     229             : }
     230             : 
     231             : /*************************************************************************
     232             : |*
     233             : |*  SwFlyInCntFrm::RegistFlys()
     234             : |*
     235             : |*************************************************************************/
     236         176 : void SwFlyInCntFrm::RegistFlys()
     237             : {
     238             :     // vgl. SwRowFrm::RegistFlys()
     239         176 :     SwPageFrm *pPage = FindPageFrm();
     240             :     OSL_ENSURE( pPage, "Register Flys without pages?" );
     241         176 :     ::RegistFlys( pPage, this );
     242         176 : }
     243             : 
     244             : /*************************************************************************
     245             : |*
     246             : |*  SwFlyInCntFrm::MakeAll()
     247             : |*
     248             : |*************************************************************************/
     249         698 : void SwFlyInCntFrm::MakeAll()
     250             : {
     251             :     // OD 2004-01-19 #110582#
     252         698 :     if ( !GetFmt()->GetDoc()->IsVisibleLayerId( GetVirtDrawObj()->GetLayer() ) )
     253             :     {
     254           0 :         return;
     255             :     }
     256             : 
     257         698 :     if ( !GetAnchorFrm() || IsLocked() || IsColLocked() || !FindPageFrm() )
     258           0 :         return;
     259             : 
     260         698 :     Lock(); // The curtain falls
     261             : 
     262             :         //does the notification in the DTor
     263         698 :     const SwFlyNotify aNotify( this );
     264        1396 :     SwBorderAttrAccess aAccess( SwFrm::GetCache(), this );
     265         698 :     const SwBorderAttrs &rAttrs = *aAccess.Get();
     266             : 
     267         698 :     if ( IsClipped() )
     268           0 :         mbValidSize = bHeightClipped = bWidthClipped = sal_False;
     269             : 
     270        2094 :     while ( !mbValidPos || !mbValidSize || !mbValidPrtArea )
     271             :     {
     272             :         //Only stop, if the flag is set!!
     273         698 :         if ( !mbValidSize )
     274             :         {
     275         395 :             mbValidPrtArea = sal_False;
     276             :         }
     277             : 
     278         698 :         if ( !mbValidPrtArea )
     279         395 :             MakePrtArea( rAttrs );
     280             : 
     281         698 :         if ( !mbValidSize )
     282         395 :             Format( &rAttrs );
     283             : 
     284         698 :         if ( !mbValidPos )
     285             :         {
     286             :             // OD 2004-03-23 #i26791#
     287             :             //MakeFlyPos();
     288         508 :             MakeObjPos();
     289             :         }
     290             : 
     291             :         //
     292             :         // re-activate clipping of as-character anchored Writer fly frames
     293             :         // depending on compatibility option <ClipAsCharacterAnchoredWriterFlyFrames>
     294        1396 :         if ( mbValidPos && mbValidSize &&
     295         698 :              GetFmt()->getIDocumentSettingAccess()->get( IDocumentSettingAccess::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME ) )
     296             :         {
     297           0 :             SwFrm* pFrm = AnchorFrm();
     298           0 :             if ( Frm().Left() == (pFrm->Frm().Left()+pFrm->Prt().Left()) &&
     299           0 :                  Frm().Width() > pFrm->Prt().Width() )
     300             :             {
     301           0 :                 Frm().Width( pFrm->Prt().Width() );
     302           0 :                 mbValidPrtArea = sal_False;
     303           0 :                 bWidthClipped = sal_True;
     304             :             }
     305             :         }
     306             :     }
     307        1396 :     Unlock();
     308          99 : }
     309             : 
     310             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10