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

Generated by: LCOV version 1.10