Files
libreoffice/sw/source/core/layout/flyincnt.cxx

307 lines
9.7 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 23:08:29 +00:00
#include "doc.hxx"
#include "frmtool.hxx"
#include "hints.hxx"
#include <fmtornt.hxx>
#include "txtfrm.hxx"
2000-09-18 23:08:29 +00:00
#include "flyfrms.hxx"
// OD 2004-01-19 #110582#
#include <dflyobj.hxx>
2000-09-18 23:08:29 +00:00
2012-02-13 11:37:23 +01:00
//from FlyCnt.cxx
2000-09-18 23:08:29 +00:00
void DeepCalc( const SwFrm *pFrm );
/*************************************************************************
|*
|* SwFlyInCntFrm::SwFlyInCntFrm(), ~SwFlyInCntFrm()
|*
|*************************************************************************/
SwFlyInCntFrm::SwFlyInCntFrm( SwFlyFrmFmt *pFmt, SwFrm* pSib, SwFrm *pAnch ) :
SwFlyFrm( pFmt, pSib, pAnch )
2000-09-18 23:08:29 +00:00
{
bInCnt = bInvalidLayout = bInvalidCntnt = sal_True;
SwTwips nRel = pFmt->GetVertOrient().GetPos();
// OD 2004-05-27 #i26791# - member <aRelPos> moved to <SwAnchoredObject>
Point aRelPos;
if( pAnch && pAnch->IsVertical() )
aRelPos.setX(pAnch->IsReverse() ? nRel : -nRel);
else
aRelPos.setY(nRel);
SetCurrRelPos( aRelPos );
2000-09-18 23:08:29 +00:00
}
SwFlyInCntFrm::~SwFlyInCntFrm()
{
2012-02-13 11:37:23 +01:00
//good bye
if ( !GetFmt()->GetDoc()->IsInDtor() && GetAnchorFrm() )
2000-09-18 23:08:29 +00:00
{
SwRect aTmp( GetObjRectWithSpaces() );
2000-09-18 23:08:29 +00:00
SwFlyInCntFrm::NotifyBackground( FindPageFrm(), aTmp, PREP_FLY_LEAVE );
}
}
// #i28701#
TYPEINIT1(SwFlyInCntFrm,SwFlyFrm);
2000-09-18 23:08:29 +00:00
/*************************************************************************
|*
|* SwFlyInCntFrm::SetRefPoint(),
|*
|*************************************************************************/
void SwFlyInCntFrm::SetRefPoint( const Point& rPoint,
const Point& rRelAttr,
const Point& rRelPos )
2000-09-18 23:08:29 +00:00
{
// OD 2004-05-27 #i26791# - member <aRelPos> moved to <SwAnchoredObject>
OSL_ENSURE( rPoint != aRef || rRelAttr != GetCurrRelPos(), "SetRefPoint: no change" );
SwFlyNotify *pNotify = NULL;
// No notify at a locked fly frame, if a fly frame is locked, there's
// already a SwFlyNotify object on the stack (MakeAll).
if( !IsLocked() )
pNotify = new SwFlyNotify( this );
2000-09-18 23:08:29 +00:00
aRef = rPoint;
SetCurrRelPos( rRelAttr );
SWRECTFN( GetAnchorFrm() )
(Frm().*fnRect->fnSetPos)( rPoint + rRelPos );
// #i68520#
InvalidateObjRectWithSpaces();
if( pNotify )
{
InvalidatePage();
mbValidPos = sal_False;
bInvalid = sal_True;
Calc();
delete pNotify;
}
2000-09-18 23:08:29 +00:00
}
/*************************************************************************
|*
|* SwFlyInCntFrm::Modify()
|*
|*************************************************************************/
void SwFlyInCntFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
2000-09-18 23:08:29 +00:00
{
bool bCallPrepare = false;
sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
2000-09-18 23:08:29 +00:00
if( RES_ATTRSET_CHG == nWhich )
{
if( SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->
GetItemState( RES_SURROUND, sal_False ) ||
2000-09-18 23:08:29 +00:00
SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->
GetItemState( RES_FRMMACRO, sal_False ) )
2000-09-18 23:08:29 +00:00
{
SwAttrSetChg aOld( *(SwAttrSetChg*)pOld );
SwAttrSetChg aNew( *(SwAttrSetChg*)pNew );
aOld.ClearItem( RES_SURROUND );
aNew.ClearItem( RES_SURROUND );
aOld.ClearItem( RES_FRMMACRO );
aNew.ClearItem( RES_FRMMACRO );
if( aNew.Count() )
{
SwFlyFrm::Modify( &aOld, &aNew );
bCallPrepare = true;
2000-09-18 23:08:29 +00:00
}
}
else if( ((SwAttrSetChg*)pNew)->GetChgSet()->Count())
{
SwFlyFrm::Modify( pOld, pNew );
bCallPrepare = true;
2000-09-18 23:08:29 +00:00
}
}
else if( nWhich != RES_SURROUND && RES_FRMMACRO != nWhich )
{
SwFlyFrm::Modify( pOld, pNew );
bCallPrepare = true;
2000-09-18 23:08:29 +00:00
}
if ( bCallPrepare && GetAnchorFrm() )
AnchorFrm()->Prepare( PREP_FLY_ATTR_CHG, GetFmt() );
2000-09-18 23:08:29 +00:00
}
/*************************************************************************
|*
|* SwFlyInCntFrm::Format()
|*
|* Here the content gets formatted initially.
2000-09-18 23:08:29 +00:00
|*
|*************************************************************************/
void SwFlyInCntFrm::Format( const SwBorderAttrs *pAttrs )
{
if ( !Frm().Height() )
{
2012-02-13 11:37:23 +01:00
Lock(); //don't format the anchor on the crook.
2000-09-18 23:08:29 +00:00
SwCntntFrm *pCntnt = ContainsCntnt();
while ( pCntnt )
{ pCntnt->Calc();
pCntnt = pCntnt->GetNextCntntFrm();
}
Unlock();
}
SwFlyFrm::Format( pAttrs );
}
/*************************************************************************
|*
|* SwFlyInCntFrm::MakeFlyPos()
|*
2012-02-13 11:37:23 +01:00
|* Description In contrast to other Frms we only calculate the RelPos
|* here. The absolute position is only calculated using SetAbsPos.
2000-09-18 23:08:29 +00:00
|*************************************************************************/
// OD 2004-03-23 #i26791#
//void SwFlyInCntFrm::MakeFlyPos()
void SwFlyInCntFrm::MakeObjPos()
2000-09-18 23:08:29 +00:00
{
if ( !mbValidPos )
2000-09-18 23:08:29 +00:00
{
mbValidPos = sal_True;
2000-09-18 23:08:29 +00:00
SwFlyFrmFmt *pFmt = (SwFlyFrmFmt*)GetFmt();
const SwFmtVertOrient &rVert = pFmt->GetVertOrient();
2012-02-13 11:37:23 +01:00
//Update the current values in the format if needed, during this we of
//course must not send any Modify.
const bool bVert = GetAnchorFrm()->IsVertical();
const bool bRev = GetAnchorFrm()->IsReverse();
SwTwips nOld = rVert.GetPos();
SwTwips nAct = bVert ? -GetCurrRelPos().X() : GetCurrRelPos().Y();
if( bRev )
nAct = -nAct;
if( nAct != nOld )
{
SwFmtVertOrient aVert( rVert );
aVert.SetPos( nAct );
2000-09-18 23:08:29 +00:00
pFmt->LockModify();
pFmt->SetFmtAttr( aVert );
2000-09-18 23:08:29 +00:00
pFmt->UnlockModify();
}
}
}
2011-04-18 12:37:38 -03:00
// #115759#
void SwFlyInCntFrm::_ActionOnInvalidation( const InvalidationType _nInvalid )
{
if ( INVALID_POS == _nInvalid || INVALID_ALL == _nInvalid )
AnchorFrm()->Prepare( PREP_FLY_ATTR_CHG, &GetFrmFmt() );
}
2000-09-18 23:08:29 +00:00
/*************************************************************************
|*
|* SwFlyInCntFrm::NotifyBackground()
|*
|*************************************************************************/
void SwFlyInCntFrm::NotifyBackground( SwPageFrm *, const SwRect& rRect,
PrepareHint eHint)
{
if ( eHint == PREP_FLY_ATTR_CHG )
AnchorFrm()->Prepare( PREP_FLY_ATTR_CHG );
2000-09-18 23:08:29 +00:00
else
AnchorFrm()->Prepare( eHint, (void*)&rRect );
2000-09-18 23:08:29 +00:00
}
/*************************************************************************
|*
|* SwFlyInCntFrm::GetRelPos()
|*
|*************************************************************************/
const Point SwFlyInCntFrm::GetRelPos() const
2000-09-18 23:08:29 +00:00
{
Calc();
return GetCurrRelPos();
2000-09-18 23:08:29 +00:00
}
/*************************************************************************
|*
|* SwFlyInCntFrm::RegistFlys()
|*
|*************************************************************************/
void SwFlyInCntFrm::RegistFlys()
{
// vgl. SwRowFrm::RegistFlys()
SwPageFrm *pPage = FindPageFrm();
2012-02-13 11:37:23 +01:00
OSL_ENSURE( pPage, "Register Flys without pages?" );
2000-09-18 23:08:29 +00:00
::RegistFlys( pPage, this );
}
/*************************************************************************
|*
|* SwFlyInCntFrm::MakeAll()
|*
|*************************************************************************/
void SwFlyInCntFrm::MakeAll()
{
// OD 2004-01-19 #110582#
if ( !GetFmt()->GetDoc()->IsVisibleLayerId( GetVirtDrawObj()->GetLayer() ) )
{
return;
}
if ( !GetAnchorFrm() || IsLocked() || IsColLocked() || !FindPageFrm() )
2000-09-18 23:08:29 +00:00
return;
2012-02-13 11:37:23 +01:00
Lock(); // The curtain falls
2000-09-18 23:08:29 +00:00
2012-02-13 11:37:23 +01:00
//does the notification in the DTor
2000-09-18 23:08:29 +00:00
const SwFlyNotify aNotify( this );
SwBorderAttrAccess aAccess( SwFrm::GetCache(), this );
const SwBorderAttrs &rAttrs = *aAccess.Get();
if ( IsClipped() )
mbValidSize = bHeightClipped = bWidthClipped = sal_False;
2000-09-18 23:08:29 +00:00
while ( !mbValidPos || !mbValidSize || !mbValidPrtArea )
2000-09-18 23:08:29 +00:00
{
2012-02-13 11:37:23 +01:00
//Only stop, if the flag is set!!
if ( !mbValidSize )
2000-09-18 23:08:29 +00:00
{
mbValidPrtArea = sal_False;
2000-09-18 23:08:29 +00:00
}
if ( !mbValidPrtArea )
2000-09-18 23:08:29 +00:00
MakePrtArea( rAttrs );
if ( !mbValidSize )
2000-09-18 23:08:29 +00:00
Format( &rAttrs );
if ( !mbValidPos )
{
// OD 2004-03-23 #i26791#
//MakeFlyPos();
MakeObjPos();
}
2000-09-18 23:08:29 +00:00
//
// re-activate clipping of as-character anchored Writer fly frames
// depending on compatibility option <ClipAsCharacterAnchoredWriterFlyFrames>
if ( mbValidPos && mbValidSize &&
GetFmt()->getIDocumentSettingAccess()->get( IDocumentSettingAccess::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME ) )
2000-09-18 23:08:29 +00:00
{
SwFrm* pFrm = AnchorFrm();
if ( Frm().Left() == (pFrm->Frm().Left()+pFrm->Prt().Left()) &&
2000-09-18 23:08:29 +00:00
Frm().Width() > pFrm->Prt().Width() )
{
Frm().Width( pFrm->Prt().Width() );
mbValidPrtArea = sal_False;
bWidthClipped = sal_True;
2000-09-18 23:08:29 +00:00
}
}
}
Unlock();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */