2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2001-05-29 11:41:34 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 13:46:16 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-05-29 11:41:34 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2001-05-29 11:41:34 +00:00
|
|
|
*
|
2008-04-10 13:46:16 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-05-29 11:41:34 +00:00
|
|
|
*
|
2008-04-10 13:46:16 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-05-29 11:41:34 +00:00
|
|
|
*
|
2008-04-10 13:46:16 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2001-05-29 11:41:34 +00:00
|
|
|
*
|
2008-04-10 13:46:16 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2001-05-29 11:41:34 +00:00
|
|
|
*
|
2008-04-10 13:46:16 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2001-05-29 11:41:34 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include <hintids.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/brkitem.hxx>
|
2001-05-29 11:41:34 +00:00
|
|
|
#include <tools/stream.hxx>
|
|
|
|
#include <doc.hxx>
|
|
|
|
#include <docstat.hxx>
|
|
|
|
#include <docary.hxx>
|
|
|
|
#include <fmtpdsc.hxx>
|
|
|
|
#include <laycache.hxx>
|
|
|
|
#include <layhelp.hxx>
|
|
|
|
#include <pagefrm.hxx>
|
|
|
|
#include <rootfrm.hxx>
|
|
|
|
#include <txtfrm.hxx>
|
|
|
|
#include <ndtxt.hxx>
|
|
|
|
#include <swtable.hxx>
|
|
|
|
#include <tabfrm.hxx>
|
|
|
|
#include <rowfrm.hxx>
|
|
|
|
#include <colfrm.hxx>
|
|
|
|
#include <bodyfrm.hxx>
|
|
|
|
#include <ndindex.hxx>
|
|
|
|
#include <sectfrm.hxx>
|
|
|
|
#include <frmfmt.hxx>
|
|
|
|
#include <fmtcntnt.hxx>
|
|
|
|
#include <pagedesc.hxx>
|
|
|
|
#include <frmtool.hxx>
|
2001-06-29 06:58:06 +00:00
|
|
|
#include <dflyobj.hxx>
|
|
|
|
#include <dcontact.hxx>
|
2010-06-13 15:22:56 +02:00
|
|
|
#include "viewopt.hxx"
|
|
|
|
#include "viewsh.hxx"
|
2001-06-29 06:58:06 +00:00
|
|
|
#include <flyfrm.hxx>
|
2004-08-02 13:10:26 +00:00
|
|
|
// OD 2004-05-24 #i28701#
|
|
|
|
#include <sortedobjs.hxx>
|
2011-04-16 16:19:09 -03:00
|
|
|
//
|
2006-05-04 12:57:21 +00:00
|
|
|
#include <pam.hxx>
|
|
|
|
#include <docsh.hxx>
|
|
|
|
#include <com/sun/star/document/XDocumentInfoSupplier.hpp>
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
|
|
|
|
2010-01-05 16:37:41 +01:00
|
|
|
#include <set>
|
|
|
|
|
|
|
|
|
2006-05-04 12:57:21 +00:00
|
|
|
using namespace ::com::sun::star;
|
2001-06-29 06:58:06 +00:00
|
|
|
|
2011-04-10 22:40:05 -03:00
|
|
|
/*
|
2001-05-29 11:41:34 +00:00
|
|
|
* Reading and writing of the layout cache.
|
|
|
|
* The layout cache is not necessary, but it improves
|
|
|
|
* the performance and reduces the text flow during
|
|
|
|
* the formatting.
|
|
|
|
* The layout cache contains the index of the paragraphs/tables
|
|
|
|
* at the top of every page, so it's possible to create
|
|
|
|
* the right count of pages and to distribute the document content
|
|
|
|
* to this pages before the formatting starts.
|
2011-04-10 22:40:05 -03:00
|
|
|
*/
|
2001-05-29 11:41:34 +00:00
|
|
|
|
|
|
|
void SwLayoutCache::Read( SvStream &rStream )
|
|
|
|
{
|
|
|
|
if( !pImpl )
|
|
|
|
{
|
|
|
|
pImpl = new SwLayCacheImpl;
|
|
|
|
if( !pImpl->Read( rStream ) )
|
|
|
|
{
|
|
|
|
delete pImpl;
|
|
|
|
pImpl = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwLayCacheImpl::Insert( sal_uInt16 nType, sal_uLong nIndex, xub_StrLen nOffset )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-07-25 16:44:02 +01:00
|
|
|
aType.push_back( nType );
|
2011-06-17 15:20:07 +01:00
|
|
|
std::vector<sal_uLong>::push_back( nIndex );
|
2010-10-05 20:01:23 +02:00
|
|
|
aOffset.push_back( nOffset );
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwLayCacheImpl::Read( SvStream& rStream )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
SwLayCacheIoImpl aIo( rStream, sal_False );
|
2001-05-29 11:41:34 +00:00
|
|
|
if( aIo.GetMajorVersion() > SW_LAYCACHE_IO_VERSION_MAJOR )
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2001-05-29 11:41:34 +00:00
|
|
|
|
2003-04-17 15:07:29 +00:00
|
|
|
// Due to an evil bug in the layout cache (#102759#), we cannot trust the
|
|
|
|
// sizes of fly frames which have been written using the "old" layout cache.
|
|
|
|
// This flag should indicate that we do not want to trust the width and
|
|
|
|
// height of fly frames
|
|
|
|
bUseFlyCache = aIo.GetMinorVersion() >= 1;
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt8 cFlags;
|
|
|
|
sal_uInt32 nIndex, nOffset;
|
2001-05-29 11:41:34 +00:00
|
|
|
|
|
|
|
aIo.OpenRec( SW_LAYCACHE_IO_REC_PAGES );
|
|
|
|
aIo.OpenFlagRec();
|
|
|
|
aIo.CloseFlagRec();
|
|
|
|
while( aIo.BytesLeft() && !aIo.HasError() )
|
|
|
|
{
|
|
|
|
switch( aIo.Peek() )
|
|
|
|
{
|
|
|
|
case SW_LAYCACHE_IO_REC_PARA:
|
|
|
|
aIo.OpenRec( SW_LAYCACHE_IO_REC_PARA );
|
|
|
|
cFlags = aIo.OpenFlagRec();
|
|
|
|
aIo.GetStream() >> nIndex;
|
|
|
|
if( (cFlags & 0x01) != 0 )
|
|
|
|
aIo.GetStream() >> nOffset;
|
|
|
|
else
|
|
|
|
nOffset = STRING_LEN;
|
|
|
|
aIo.CloseFlagRec();
|
|
|
|
Insert( SW_LAYCACHE_IO_REC_PARA, nIndex, (xub_StrLen)nOffset );
|
|
|
|
aIo.CloseRec( SW_LAYCACHE_IO_REC_PARA );
|
|
|
|
break;
|
|
|
|
case SW_LAYCACHE_IO_REC_TABLE:
|
|
|
|
aIo.OpenRec( SW_LAYCACHE_IO_REC_TABLE );
|
|
|
|
aIo.OpenFlagRec();
|
2001-10-17 10:38:53 +00:00
|
|
|
aIo.GetStream() >> nIndex
|
|
|
|
>> nOffset;
|
2001-05-29 11:41:34 +00:00
|
|
|
Insert( SW_LAYCACHE_IO_REC_TABLE, nIndex, (xub_StrLen)nOffset );
|
|
|
|
aIo.CloseFlagRec();
|
|
|
|
aIo.CloseRec( SW_LAYCACHE_IO_REC_TABLE );
|
|
|
|
break;
|
2001-06-29 06:58:06 +00:00
|
|
|
case SW_LAYCACHE_IO_REC_FLY:
|
|
|
|
{
|
|
|
|
aIo.OpenRec( SW_LAYCACHE_IO_REC_FLY );
|
|
|
|
aIo.OpenFlagRec();
|
|
|
|
aIo.CloseFlagRec();
|
2012-02-28 16:58:25 +00:00
|
|
|
sal_Int32 nX, nY, nW, nH;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPgNum;
|
2001-06-29 06:58:06 +00:00
|
|
|
aIo.GetStream() >> nPgNum >> nIndex
|
|
|
|
>> nX >> nY >> nW >> nH;
|
|
|
|
SwFlyCache* pFly = new SwFlyCache( nPgNum, nIndex, nX, nY, nW, nH );
|
2012-04-26 10:04:46 +02:00
|
|
|
aFlyCache.push_back( pFly );
|
2001-06-29 06:58:06 +00:00
|
|
|
aIo.CloseRec( SW_LAYCACHE_IO_REC_FLY );
|
|
|
|
break;
|
|
|
|
}
|
2001-05-29 11:41:34 +00:00
|
|
|
default:
|
|
|
|
aIo.SkipRec();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aIo.CloseRec( SW_LAYCACHE_IO_REC_PAGES );
|
|
|
|
|
|
|
|
return !aIo.HasError();
|
|
|
|
}
|
|
|
|
|
2011-04-10 22:40:05 -03:00
|
|
|
/*
|
2001-05-29 11:41:34 +00:00
|
|
|
* SwLayoutCache::Write(..)
|
|
|
|
* writes the index (more precise: the difference between
|
|
|
|
* the index and the first index of the document content)
|
|
|
|
* of the first paragraph/table at the top of every page.
|
|
|
|
* If at the top of a page is the rest of a paragraph/table
|
|
|
|
* from the bottom of the previous page, the character/row
|
|
|
|
* number is stored, too.
|
2001-06-29 06:58:06 +00:00
|
|
|
* The position, size and page number of the text frames
|
|
|
|
* are stored, too
|
2011-04-10 22:40:05 -03:00
|
|
|
*/
|
2001-05-29 11:41:34 +00:00
|
|
|
|
|
|
|
void SwLayoutCache::Write( SvStream &rStream, const SwDoc& rDoc )
|
|
|
|
{
|
2010-06-13 15:22:56 +02:00
|
|
|
if( rDoc.GetCurrentLayout() ) // the layout itself .. //swmod 080218
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
SwLayCacheIoImpl aIo( rStream, sal_True );
|
2001-05-29 11:41:34 +00:00
|
|
|
// We want to save the relative index, so we need the index
|
|
|
|
// of the first content
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nStartOfContent = rDoc.GetNodes().GetEndOfContent().
|
2006-08-14 15:27:24 +00:00
|
|
|
StartOfSectionNode()->GetIndex();
|
2001-05-29 11:41:34 +00:00
|
|
|
// The first page..
|
2010-06-13 15:22:56 +02:00
|
|
|
SwPageFrm* pPage = (SwPageFrm*)rDoc.GetCurrentLayout()->Lower(); //swmod 080218
|
2001-05-29 11:41:34 +00:00
|
|
|
|
|
|
|
aIo.OpenRec( SW_LAYCACHE_IO_REC_PAGES );
|
|
|
|
aIo.OpenFlagRec( 0, 0 );
|
|
|
|
aIo.CloseFlagRec();
|
|
|
|
while( pPage )
|
|
|
|
{
|
2001-06-29 06:58:06 +00:00
|
|
|
if( pPage->GetPrev() )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2001-06-29 06:58:06 +00:00
|
|
|
SwLayoutFrm* pLay = pPage->FindBodyCont();
|
|
|
|
SwFrm* pTmp = pLay ? pLay->ContainsAny() : NULL;
|
|
|
|
// We are only interested in paragraph or table frames,
|
|
|
|
// a section frames contains paragraphs/tables.
|
|
|
|
if( pTmp && pTmp->IsSctFrm() )
|
|
|
|
pTmp = ((SwSectionFrm*)pTmp)->ContainsAny();
|
|
|
|
|
|
|
|
if( pTmp ) // any content
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2001-06-29 06:58:06 +00:00
|
|
|
if( pTmp->IsTxtFrm() )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nNdIdx = ((SwTxtFrm*)pTmp)->GetNode()->GetIndex();
|
2001-05-29 11:41:34 +00:00
|
|
|
if( nNdIdx > nStartOfContent )
|
|
|
|
{
|
2001-06-29 06:58:06 +00:00
|
|
|
/* Open Paragraph Record */
|
|
|
|
aIo.OpenRec( SW_LAYCACHE_IO_REC_PARA );
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bFollow = ((SwTxtFrm*)pTmp)->IsFollow();
|
2001-06-29 06:58:06 +00:00
|
|
|
aIo.OpenFlagRec( bFollow ? 0x01 : 0x00,
|
|
|
|
bFollow ? 8 : 4 );
|
2001-05-29 11:41:34 +00:00
|
|
|
nNdIdx -= nStartOfContent;
|
2006-03-16 11:28:20 +00:00
|
|
|
aIo.GetStream() << static_cast<sal_uInt32>(nNdIdx);
|
2001-06-29 06:58:06 +00:00
|
|
|
if( bFollow )
|
2006-03-16 11:28:20 +00:00
|
|
|
aIo.GetStream() << static_cast<sal_uInt32>(((SwTxtFrm*)pTmp)->GetOfst());
|
2001-05-29 11:41:34 +00:00
|
|
|
aIo.CloseFlagRec();
|
2001-06-29 06:58:06 +00:00
|
|
|
/* Close Paragraph Record */
|
|
|
|
aIo.CloseRec( SW_LAYCACHE_IO_REC_PARA );
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
2001-06-29 06:58:06 +00:00
|
|
|
}
|
|
|
|
else if( pTmp->IsTabFrm() )
|
|
|
|
{
|
|
|
|
SwTabFrm* pTab = (SwTabFrm*)pTmp;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nOfst = STRING_LEN;
|
2001-06-29 06:58:06 +00:00
|
|
|
if( pTab->IsFollow() )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2001-06-29 06:58:06 +00:00
|
|
|
// If the table is a follow, we have to look for the
|
|
|
|
// master and to count all rows to get the row number
|
|
|
|
nOfst = 0;
|
2004-01-13 10:18:01 +00:00
|
|
|
if( pTab->IsFollow() )
|
|
|
|
pTab = pTab->FindMaster( true );
|
2001-06-29 06:58:06 +00:00
|
|
|
while( pTab != pTmp )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
|
|
|
SwFrm* pSub = pTab->Lower();
|
|
|
|
while( pSub )
|
|
|
|
{
|
|
|
|
++nOfst;
|
|
|
|
pSub = pSub->GetNext();
|
|
|
|
}
|
|
|
|
pTab = pTab->GetFollow();
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pTab, "Table follow without master" );
|
2001-06-29 06:58:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
do
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nNdIdx =
|
2001-06-29 06:58:06 +00:00
|
|
|
pTab->GetTable()->GetTableNode()->GetIndex();
|
|
|
|
if( nNdIdx > nStartOfContent )
|
|
|
|
{
|
|
|
|
/* Open Table Record */
|
|
|
|
aIo.OpenRec( SW_LAYCACHE_IO_REC_TABLE );
|
|
|
|
aIo.OpenFlagRec( 0, 8 );
|
|
|
|
nNdIdx -= nStartOfContent;
|
2006-03-16 11:28:20 +00:00
|
|
|
aIo.GetStream() << static_cast<sal_uInt32>(nNdIdx)
|
|
|
|
<< static_cast<sal_uInt32>(nOfst);
|
2001-06-29 06:58:06 +00:00
|
|
|
aIo.CloseFlagRec();
|
|
|
|
/* Close Table Record */
|
|
|
|
aIo.CloseRec( SW_LAYCACHE_IO_REC_TABLE );
|
|
|
|
}
|
|
|
|
// If the table has a follow on the next page,
|
|
|
|
// we know already the row number and store this
|
|
|
|
// immediately.
|
|
|
|
if( pTab->GetFollow() )
|
|
|
|
{
|
|
|
|
if( nOfst == STRING_LEN )
|
|
|
|
nOfst = 0;
|
|
|
|
do
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2001-06-29 06:58:06 +00:00
|
|
|
SwFrm* pSub = pTab->Lower();
|
|
|
|
while( pSub )
|
|
|
|
{
|
|
|
|
++nOfst;
|
|
|
|
pSub = pSub->GetNext();
|
|
|
|
}
|
|
|
|
pTab = pTab->GetFollow();
|
|
|
|
SwPageFrm *pTabPage = pTab->FindPageFrm();
|
|
|
|
if( pTabPage != pPage )
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pPage->GetPhyPageNum() <
|
2001-06-29 06:58:06 +00:00
|
|
|
pTabPage->GetPhyPageNum(),
|
|
|
|
"Looping Tableframes" );
|
|
|
|
pPage = pTabPage;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while ( pTab->GetFollow() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
} while( pTab );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( pPage->GetSortedObjs() )
|
|
|
|
{
|
2004-08-02 13:10:26 +00:00
|
|
|
SwSortedObjs &rObjs = *pPage->GetSortedObjs();
|
2011-01-17 15:06:54 +01:00
|
|
|
for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
|
2001-06-29 06:58:06 +00:00
|
|
|
{
|
2004-08-02 13:10:26 +00:00
|
|
|
SwAnchoredObject* pAnchoredObj = rObjs[i];
|
|
|
|
if ( pAnchoredObj->ISA(SwFlyFrm) )
|
2001-06-29 06:58:06 +00:00
|
|
|
{
|
2004-08-02 13:10:26 +00:00
|
|
|
SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
|
2012-03-21 23:26:30 +01:00
|
|
|
if( pFly->Frm().Left() != FAR_AWAY &&
|
2004-06-28 12:40:19 +00:00
|
|
|
!pFly->GetAnchorFrm()->FindFooterOrHeader() )
|
2001-06-29 06:58:06 +00:00
|
|
|
{
|
2004-08-02 13:10:26 +00:00
|
|
|
const SwContact *pC =
|
|
|
|
::GetUserCall(pAnchoredObj->GetDrawObj());
|
2001-06-29 06:58:06 +00:00
|
|
|
if( pC )
|
|
|
|
{
|
2006-03-16 11:28:20 +00:00
|
|
|
sal_uInt32 nOrdNum = pAnchoredObj->GetDrawObj()->GetOrdNum();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPageNum = pPage->GetPhyPageNum();
|
2001-06-29 06:58:06 +00:00
|
|
|
/* Open Fly Record */
|
|
|
|
aIo.OpenRec( SW_LAYCACHE_IO_REC_FLY );
|
|
|
|
aIo.OpenFlagRec( 0, 0 );
|
|
|
|
aIo.CloseFlagRec();
|
|
|
|
SwRect &rRct = pFly->Frm();
|
2006-03-16 11:28:20 +00:00
|
|
|
sal_Int32 nX = rRct.Left() - pPage->Frm().Left();
|
|
|
|
sal_Int32 nY = rRct.Top() - pPage->Frm().Top();
|
2001-06-29 06:58:06 +00:00
|
|
|
aIo.GetStream() << nPageNum << nOrdNum
|
2012-02-28 16:58:25 +00:00
|
|
|
<< nX << nY
|
|
|
|
<< static_cast<sal_Int32>(rRct.Width())
|
|
|
|
<< static_cast<sal_Int32>(rRct.Height());
|
2001-06-29 06:58:06 +00:00
|
|
|
/* Close Fly Record */
|
|
|
|
aIo.CloseRec( SW_LAYCACHE_IO_REC_FLY );
|
|
|
|
}
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
2001-06-29 06:58:06 +00:00
|
|
|
}
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pPage = (SwPageFrm*)pPage->GetNext();
|
|
|
|
}
|
|
|
|
aIo.CloseRec( SW_LAYCACHE_IO_REC_PAGES );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-24 00:52:00 +01:00
|
|
|
#ifdef DBG_UTIL
|
2001-05-29 11:41:34 +00:00
|
|
|
sal_Bool SwLayoutCache::CompareLayout( const SwDoc& rDoc ) const
|
|
|
|
{
|
2010-06-13 15:22:56 +02:00
|
|
|
if( !pImpl )
|
|
|
|
return sal_True;
|
|
|
|
const SwRootFrm *pRootFrm = rDoc.GetCurrentLayout();
|
2001-05-29 11:41:34 +00:00
|
|
|
sal_Bool bRet = sal_True;
|
2010-06-13 15:22:56 +02:00
|
|
|
if( pRootFrm )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nIndex = 0;
|
|
|
|
sal_uLong nStartOfContent = rDoc.GetNodes().GetEndOfContent().
|
2006-08-14 15:27:24 +00:00
|
|
|
StartOfSectionNode()->GetIndex();
|
2010-06-13 15:22:56 +02:00
|
|
|
SwPageFrm* pPage = (SwPageFrm*)pRootFrm->Lower();
|
2001-05-29 11:41:34 +00:00
|
|
|
if( pPage )
|
|
|
|
pPage = (SwPageFrm*)pPage->GetNext();
|
|
|
|
while( pPage )
|
|
|
|
{
|
2011-07-08 16:48:44 +02:00
|
|
|
if( nIndex >= pImpl->size() )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
|
|
|
if( bRet )
|
|
|
|
bRet = sal_False;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
SwLayoutFrm* pLay = pPage->FindBodyCont();
|
|
|
|
SwFrm* pTmp = pLay ? pLay->ContainsAny() : NULL;
|
|
|
|
if( pTmp && pTmp->IsSctFrm() )
|
|
|
|
pTmp = ((SwSectionFrm*)pTmp)->ContainsAny();
|
|
|
|
if( pTmp )
|
|
|
|
{
|
|
|
|
if( pTmp->IsTxtFrm() )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nNdIdx = ((SwTxtFrm*)pTmp)->GetNode()->GetIndex();
|
2001-05-29 11:41:34 +00:00
|
|
|
if( nNdIdx > nStartOfContent )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bFollow = ((SwTxtFrm*)pTmp)->IsFollow();
|
2001-05-29 11:41:34 +00:00
|
|
|
nNdIdx -= nStartOfContent;
|
|
|
|
if( pImpl->GetBreakIndex( nIndex ) != nNdIdx ||
|
|
|
|
SW_LAYCACHE_IO_REC_PARA !=
|
|
|
|
pImpl->GetBreakType( nIndex ) ||
|
|
|
|
( bFollow ? ((SwTxtFrm*)pTmp)->GetOfst()
|
|
|
|
: STRING_LEN ) != pImpl->GetBreakOfst( nIndex ) )
|
|
|
|
{
|
|
|
|
if( bRet )
|
|
|
|
bRet = sal_False;
|
|
|
|
}
|
|
|
|
++nIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( pTmp->IsTabFrm() )
|
|
|
|
{
|
|
|
|
SwTabFrm* pTab = (SwTabFrm*)pTmp;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nOfst = STRING_LEN;
|
2001-05-29 11:41:34 +00:00
|
|
|
if( pTab->IsFollow() )
|
|
|
|
{
|
|
|
|
nOfst = 0;
|
2004-01-13 10:18:01 +00:00
|
|
|
if( pTab->IsFollow() )
|
|
|
|
pTab = pTab->FindMaster( true );
|
2001-05-29 11:41:34 +00:00
|
|
|
while( pTab != pTmp )
|
|
|
|
{
|
|
|
|
SwFrm* pSub = pTab->Lower();
|
|
|
|
while( pSub )
|
|
|
|
{
|
|
|
|
++nOfst;
|
|
|
|
pSub = pSub->GetNext();
|
|
|
|
}
|
|
|
|
pTab = pTab->GetFollow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
do
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nNdIdx =
|
2001-05-29 11:41:34 +00:00
|
|
|
pTab->GetTable()->GetTableNode()->GetIndex();
|
|
|
|
if( nNdIdx > nStartOfContent )
|
|
|
|
{
|
|
|
|
nNdIdx -= nStartOfContent;
|
|
|
|
if( pImpl->GetBreakIndex( nIndex ) != nNdIdx ||
|
|
|
|
SW_LAYCACHE_IO_REC_TABLE !=
|
|
|
|
pImpl->GetBreakType( nIndex ) ||
|
|
|
|
nOfst != pImpl->GetBreakOfst( nIndex ) )
|
|
|
|
{
|
|
|
|
if( bRet )
|
|
|
|
bRet = sal_False;
|
|
|
|
}
|
|
|
|
++nIndex;
|
|
|
|
}
|
|
|
|
if( pTab->GetFollow() )
|
|
|
|
{
|
|
|
|
if( nOfst == STRING_LEN )
|
|
|
|
nOfst = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
SwFrm* pSub = pTab->Lower();
|
|
|
|
while( pSub )
|
|
|
|
{
|
|
|
|
++nOfst;
|
|
|
|
pSub = pSub->GetNext();
|
|
|
|
}
|
|
|
|
pTab = pTab->GetFollow();
|
|
|
|
SwPageFrm *pTabPage = pTab->FindPageFrm();
|
|
|
|
if( pTabPage != pPage )
|
|
|
|
{
|
|
|
|
pPage = pTabPage;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while ( pTab->GetFollow() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
} while( pTab );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pPage = (SwPageFrm*)pPage->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void SwLayoutCache::ClearImpl()
|
|
|
|
{
|
|
|
|
if( !IsLocked() )
|
|
|
|
{
|
|
|
|
delete pImpl;
|
|
|
|
pImpl = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SwLayoutCache::~SwLayoutCache()
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( !nLockCount, "Deleting a locked SwLayoutCache!?" );
|
2001-05-29 11:41:34 +00:00
|
|
|
delete pImpl;
|
|
|
|
}
|
|
|
|
|
2011-04-10 22:40:05 -03:00
|
|
|
/*
|
2001-05-29 11:41:34 +00:00
|
|
|
* SwActualSection,
|
|
|
|
* a help class to create not nested section frames
|
|
|
|
* for nested sections.
|
2011-04-10 22:40:05 -03:00
|
|
|
*/
|
2001-05-29 11:41:34 +00:00
|
|
|
|
|
|
|
SwActualSection::SwActualSection( SwActualSection *pUp,
|
|
|
|
SwSectionFrm *pSect,
|
|
|
|
SwSectionNode *pNd ) :
|
|
|
|
pUpper( pUp ),
|
|
|
|
pSectFrm( pSect ),
|
|
|
|
pSectNode( pNd )
|
|
|
|
{
|
|
|
|
if ( !pSectNode )
|
|
|
|
{
|
|
|
|
const SwNodeIndex *pIndex = pSect->GetFmt()->GetCntnt().GetCntntIdx();
|
2010-12-15 09:13:59 +01:00
|
|
|
pSectNode = pIndex->GetNode().FindSectionNode();
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-10 22:40:05 -03:00
|
|
|
/*
|
2001-05-29 11:41:34 +00:00
|
|
|
* SwLayHelper
|
|
|
|
* is the helper class, which utilizes the layout cache information
|
|
|
|
* to distribute the document content to the rigth pages.
|
|
|
|
* It's used by the _InsertCnt(..)-function.
|
|
|
|
* If there's no layout cache, the distibution to the pages is more
|
|
|
|
* a guess, but a guess with statistical background.
|
2011-04-10 22:40:05 -03:00
|
|
|
*/
|
2001-05-29 11:41:34 +00:00
|
|
|
|
|
|
|
SwLayHelper::SwLayHelper( SwDoc *pD, SwFrm* &rpF, SwFrm* &rpP, SwPageFrm* &rpPg,
|
2011-01-17 15:06:54 +01:00
|
|
|
SwLayoutFrm* &rpL, SwActualSection* &rpA, sal_Bool &rB,
|
|
|
|
sal_uLong nNodeIndex, sal_Bool bCache )
|
2001-05-29 11:41:34 +00:00
|
|
|
: rpFrm( rpF ), rpPrv( rpP ), rpPage( rpPg ), rpLay( rpL ),
|
|
|
|
rpActualSection( rpA ), rbBreakAfter(rB), pDoc(pD), nMaxParaPerPage( 25 ),
|
|
|
|
nParagraphCnt( bCache ? 0 : USHRT_MAX ), bFirst( bCache )
|
|
|
|
{
|
|
|
|
pImpl = pDoc->GetLayoutCache() ? pDoc->GetLayoutCache()->LockImpl() : NULL;
|
|
|
|
if( pImpl )
|
|
|
|
{
|
2001-06-22 06:56:05 +00:00
|
|
|
nMaxParaPerPage = 1000;
|
2006-08-14 15:27:24 +00:00
|
|
|
nStartOfContent = pDoc->GetNodes().GetEndOfContent().StartOfSectionNode()
|
2001-05-29 11:41:34 +00:00
|
|
|
->GetIndex();
|
|
|
|
nNodeIndex -= nStartOfContent;
|
|
|
|
nIndex = 0;
|
2001-06-29 06:58:06 +00:00
|
|
|
nFlyIdx = 0;
|
2011-06-17 15:20:07 +01:00
|
|
|
while( nIndex < pImpl->size() && (*pImpl)[ nIndex ] < nNodeIndex )
|
2001-05-29 11:41:34 +00:00
|
|
|
++nIndex;
|
2011-06-17 15:20:07 +01:00
|
|
|
if( nIndex >= pImpl->size() )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
|
|
|
pDoc->GetLayoutCache()->UnlockImpl();
|
|
|
|
pImpl = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nIndex = USHRT_MAX;
|
|
|
|
nStartOfContent = ULONG_MAX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SwLayHelper::~SwLayHelper()
|
|
|
|
{
|
|
|
|
if( pImpl )
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pDoc && pDoc->GetLayoutCache(), "Missing layoutcache" );
|
2001-05-29 11:41:34 +00:00
|
|
|
pDoc->GetLayoutCache()->UnlockImpl();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-10 22:40:05 -03:00
|
|
|
/*
|
2001-05-29 11:41:34 +00:00
|
|
|
* SwLayHelper::CalcPageCount() does not really calculate the page count,
|
|
|
|
* it returns the page count value from the layout cache, if available,
|
|
|
|
* otherwise it estimates the page count.
|
2011-04-10 22:40:05 -03:00
|
|
|
*/
|
2001-05-29 11:41:34 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong SwLayHelper::CalcPageCount()
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nPgCount;
|
2001-05-29 11:41:34 +00:00
|
|
|
SwLayCacheImpl *pCache = pDoc->GetLayoutCache() ?
|
|
|
|
pDoc->GetLayoutCache()->LockImpl() : NULL;
|
|
|
|
if( pCache )
|
|
|
|
{
|
2011-06-17 15:20:07 +01:00
|
|
|
nPgCount = pCache->size() + 1;
|
2001-05-29 11:41:34 +00:00
|
|
|
pDoc->GetLayoutCache()->UnlockImpl();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nPgCount = pDoc->GetDocStat().nPage;
|
|
|
|
if ( nPgCount <= 10 ) // no page insertion for less than 10 pages
|
|
|
|
nPgCount = 0;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nNdCount = pDoc->GetDocStat().nPara;
|
2001-05-29 11:41:34 +00:00
|
|
|
if ( nNdCount <= 1 )
|
|
|
|
{
|
|
|
|
//Estimates the number of paragraphs.
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nTmp = pDoc->GetNodes().GetEndOfContent().GetIndex() -
|
2001-05-29 11:41:34 +00:00
|
|
|
pDoc->GetNodes().GetEndOfExtras().GetIndex();
|
|
|
|
//Tables have a little overhead..
|
2012-06-20 16:36:51 +02:00
|
|
|
nTmp -= pDoc->GetTblFrmFmts()->size() * 25;
|
2001-05-29 11:41:34 +00:00
|
|
|
//Fly frames, too ..
|
|
|
|
nTmp -= (pDoc->GetNodes().GetEndOfAutotext().GetIndex() -
|
|
|
|
pDoc->GetNodes().GetEndOfInserts().GetIndex()) / 3 * 5;
|
|
|
|
if ( nTmp > 0 )
|
|
|
|
nNdCount = nTmp;
|
|
|
|
}
|
|
|
|
if ( nNdCount > 100 ) // no estimation below this value
|
|
|
|
{
|
|
|
|
if ( nPgCount > 0 )
|
|
|
|
nMaxParaPerPage = nNdCount / nPgCount;
|
|
|
|
else
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
nMaxParaPerPage = Max( sal_uLong(20),
|
|
|
|
sal_uLong(20 + nNdCount / 1000 * 3) );
|
|
|
|
const sal_uLong nMax = 53;
|
2001-05-29 11:41:34 +00:00
|
|
|
nMaxParaPerPage = Min( nMaxParaPerPage, nMax );
|
|
|
|
nPgCount = nNdCount / nMaxParaPerPage;
|
|
|
|
}
|
|
|
|
if ( nNdCount < 1000 )
|
|
|
|
nPgCount = 0;// no progress bar for small documents
|
2010-06-13 15:22:56 +02:00
|
|
|
ViewShell *pSh = 0;
|
|
|
|
if( rpLay && rpLay->getRootFrm() )
|
|
|
|
pSh = rpLay->getRootFrm()->GetCurrShell();
|
|
|
|
if( pSh && pSh->GetViewOptions()->getBrowseMode() )
|
2001-05-29 11:41:34 +00:00
|
|
|
nMaxParaPerPage *= 6;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nPgCount;
|
|
|
|
}
|
|
|
|
|
2011-04-10 22:40:05 -03:00
|
|
|
/*
|
2001-05-29 11:41:34 +00:00
|
|
|
* SwLayHelper::CheckInsertPage()
|
2011-01-17 15:06:54 +01:00
|
|
|
* inserts a page and return sal_True, if
|
2001-05-29 11:41:34 +00:00
|
|
|
* - the break after flag is set
|
|
|
|
* - the actual content wants a break before
|
|
|
|
* - the maximum count of paragraph/rows is reached
|
|
|
|
*
|
|
|
|
* The break after flag is set, if the actual content
|
|
|
|
* wants a break after.
|
2011-04-10 22:40:05 -03:00
|
|
|
*/
|
2001-05-29 11:41:34 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwLayHelper::CheckInsertPage()
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bEnd = 0 == rpPage->GetNext();
|
2004-11-16 14:47:00 +00:00
|
|
|
const SwAttrSet* pAttr = rpFrm->GetAttrSet();
|
|
|
|
const SvxFmtBreakItem& rBrk = pAttr->GetBreak();
|
|
|
|
const SwFmtPageDesc& rDesc = pAttr->GetPageDesc();
|
2011-04-18 12:37:38 -03:00
|
|
|
// #118195# Do not evaluate page description if frame
|
2004-11-16 14:47:00 +00:00
|
|
|
// is a follow frame!
|
|
|
|
const SwPageDesc* pDesc = rpFrm->IsFlowFrm() &&
|
|
|
|
SwFlowFrm::CastFlowFrm( rpFrm )->IsFollow() ?
|
|
|
|
0 :
|
|
|
|
rDesc.GetPageDesc();
|
2001-05-29 11:41:34 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bBrk = nParagraphCnt > nMaxParaPerPage || rbBreakAfter;
|
2001-05-29 11:41:34 +00:00
|
|
|
rbBreakAfter = rBrk.GetBreak() == SVX_BREAK_PAGE_AFTER ||
|
|
|
|
rBrk.GetBreak() == SVX_BREAK_PAGE_BOTH;
|
|
|
|
if ( !bBrk )
|
|
|
|
bBrk = rBrk.GetBreak() == SVX_BREAK_PAGE_BEFORE ||
|
|
|
|
rBrk.GetBreak() == SVX_BREAK_PAGE_BOTH;
|
|
|
|
|
|
|
|
if ( bBrk || pDesc )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPgNum = 0;
|
2001-05-29 11:41:34 +00:00
|
|
|
if ( !pDesc )
|
|
|
|
pDesc = rpPage->GetPageDesc()->GetFollow();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( 0 != (nPgNum = rDesc.GetNumOffset()) )
|
2011-01-17 15:06:54 +01:00
|
|
|
((SwRootFrm*)rpPage->GetUpper())->SetVirtPageNum(sal_True);
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bNextPageOdd = !rpPage->OnRightPage();
|
|
|
|
sal_Bool bInsertEmpty = sal_False;
|
2004-11-16 14:47:00 +00:00
|
|
|
if( nPgNum && bNextPageOdd != ( ( nPgNum % 2 ) != 0 ) )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2004-11-16 14:47:00 +00:00
|
|
|
bNextPageOdd = !bNextPageOdd;
|
2011-01-17 15:06:54 +01:00
|
|
|
bInsertEmpty = sal_True;
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
::InsertNewPage( (SwPageDesc&)*pDesc, rpPage->GetUpper(),
|
2012-07-04 10:43:56 +02:00
|
|
|
bNextPageOdd, nPgNum == 1, bInsertEmpty, sal_False, rpPage->GetNext() );
|
2001-05-29 11:41:34 +00:00
|
|
|
if ( bEnd )
|
|
|
|
{
|
2012-02-13 11:37:28 +01:00
|
|
|
OSL_ENSURE( rpPage->GetNext(), "No new page?" );
|
2001-05-29 11:41:34 +00:00
|
|
|
do
|
|
|
|
{ rpPage = (SwPageFrm*)rpPage->GetNext();
|
|
|
|
} while ( rpPage->GetNext() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-13 11:37:28 +01:00
|
|
|
OSL_ENSURE( rpPage->GetNext(), "No new page?" );
|
2001-05-29 11:41:34 +00:00
|
|
|
rpPage = (SwPageFrm*)rpPage->GetNext();
|
|
|
|
if ( rpPage->IsEmptyPage() )
|
|
|
|
{
|
2012-02-13 11:37:28 +01:00
|
|
|
OSL_ENSURE( rpPage->GetNext(), "No new page?" );
|
2001-05-29 11:41:34 +00:00
|
|
|
rpPage = (SwPageFrm*)rpPage->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rpLay = rpPage->FindBodyCont();
|
|
|
|
while( rpLay->Lower() )
|
|
|
|
rpLay = (SwLayoutFrm*)rpLay->Lower();
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_True;
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
|
2011-04-16 16:19:09 -03:00
|
|
|
//
|
2006-05-04 12:57:21 +00:00
|
|
|
bool lcl_HasTextFrmAnchoredObjs( SwTxtFrm* p_pTxtFrm )
|
|
|
|
{
|
|
|
|
bool bHasTextFrmAnchoredObjs( false );
|
|
|
|
|
2012-06-20 16:36:51 +02:00
|
|
|
const SwFrmFmts* pSpzFrmFmts = p_pTxtFrm->GetTxtNode()->GetDoc()->GetSpzFrmFmts();
|
|
|
|
for ( sal_uInt16 i = 0; i < pSpzFrmFmts->size(); ++i )
|
2006-05-04 12:57:21 +00:00
|
|
|
{
|
|
|
|
SwFrmFmt *pFmt = (SwFrmFmt*)(*pSpzFrmFmts)[i];
|
|
|
|
const SwFmtAnchor &rAnch = pFmt->GetAnchor();
|
|
|
|
if ( rAnch.GetCntntAnchor() &&
|
2010-01-05 16:37:41 +01:00
|
|
|
((rAnch.GetAnchorId() == FLY_AT_PARA) ||
|
|
|
|
(rAnch.GetAnchorId() == FLY_AT_CHAR)) &&
|
2006-05-04 12:57:21 +00:00
|
|
|
rAnch.GetCntntAnchor()->nNode.GetIndex() ==
|
|
|
|
p_pTxtFrm->GetTxtNode()->GetIndex() )
|
|
|
|
{
|
|
|
|
bHasTextFrmAnchoredObjs = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bHasTextFrmAnchoredObjs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcl_ApplyWorkaroundForB6375613( SwFrm* p_pFirstFrmOnNewPage )
|
|
|
|
{
|
|
|
|
SwTxtFrm* pFirstTextFrmOnNewPage = dynamic_cast<SwTxtFrm*>(p_pFirstFrmOnNewPage);
|
|
|
|
//
|
|
|
|
if ( pFirstTextFrmOnNewPage &&
|
|
|
|
!pFirstTextFrmOnNewPage->IsFollow() &&
|
|
|
|
pFirstTextFrmOnNewPage->GetTxt().Len() == 0 &&
|
|
|
|
lcl_HasTextFrmAnchoredObjs( pFirstTextFrmOnNewPage ) )
|
|
|
|
{
|
|
|
|
// apply page break before at this text frame to assure, that it doesn't flow backward.
|
|
|
|
const SvxBreak eBreak =
|
|
|
|
pFirstTextFrmOnNewPage->GetAttrSet()->GetBreak().GetBreak();
|
|
|
|
if ( eBreak == SVX_BREAK_NONE )
|
|
|
|
{
|
|
|
|
pFirstTextFrmOnNewPage->GetTxtNode()->LockModify();
|
|
|
|
SwDoc* pDoc( pFirstTextFrmOnNewPage->GetTxtNode()->GetDoc() );
|
2006-08-14 15:27:24 +00:00
|
|
|
IDocumentContentOperations* pIDCO = pFirstTextFrmOnNewPage->GetTxtNode()->getIDocumentContentOperations();
|
2006-05-04 12:57:21 +00:00
|
|
|
const SwPaM aTmpPaM( *(pFirstTextFrmOnNewPage->GetTxtNode()) );
|
CWS-TOOLING: integrate CWS odfmetadata3
2009-09-11 Michael Stahl merge DEV300_m58
2009-09-07 Michael Stahl SwFmtFld::Modify(): do nothing on RES_OBJECTDYING
2009-08-27 Michael Stahl #i91565#, #i91566#: TextPortionEnumerationTest.java: add test document
2009-08-27 Michael Stahl #i91565#, #i91566#: add complex test: TextPortionEnumerationTest.java
2009-08-27 Michael Stahl CLiteral::initialize(): zero-length literals probably not an error
2009-08-27 Michael Stahl #i91565#, #i91566#: offapi: new InContentMetadata and MetadataField services
adapt TextPortion for InContentMetadata
2009-08-27 Michael Stahl #i91564#: xmloff: load/store xml:id and RDFa for text:bookmark(-start).
2009-08-27 Michael Stahl #i91564#: sw core: add support for xml:id at bookmarks:
sw::mark::Bookmark: derive from Metadatable.
SwHistoryBookmark, SaveBookmark: store a MetadatableUndo.
ndcopy.cxx: lcl_CopyBookmarks(): copy the xml:id.
SwXBookmark: derive from MetadatableMixin.
2009-08-27 Michael Stahl #i91565#, #i91566#: xmloff: refactor ruby import so nested meta(-field) works:
remove XMLRubyHint_Impl.
XMLImpRubyContext_Impl::~XMLImpRubyContext_Impl(): insert ruby directly.
2009-08-27 Michael Stahl #i91565#, #i91566#: xmloff: fix text:meta(-field) import/export:
new XMLTextParagraphExport::exportTextField() overload for XTextField.
CreateAndInsertMark(): set xml:id after insertion.
fix meta(-field) service names, bugs etc.
2009-08-27 Michael Stahl #i91565#, #i91566#: sw text formatting: paint background of meta(-field) body:
SwFont: add member m_nMetaCount.
txttypes.hxx: add POR_META.
atrstck.cxx: handle RES_TXTATR_META(FIELD).
itrform2.cxx: SwTxtFormatter::WhichTxtPor(): create new class SwMetaPortion.
2009-08-27 Michael Stahl #i91566#: sw text formatting: display meta-field prefix and suffix:
SwAttrIter::GetAttr(): replace with call to GetTxtAttrForCharAt().
SwTxtFormatter::NewExtraPortion(): handle meta-field prefix.
SwTxtFormatter: new member m_nHintEndIndex.
SwTxtFormatter::WhichFirstPortion(): call TryNewNoLengthPortion().
SwTxtFormatter::TryNewNoLengthPortion(): new; handle suffix of meta-field.
SwTxtFormatter::UnderFlow(): UGLY HACK: decrement m_nHintEndIndex.
SwFldPortion: add flag m_bNoLength: portion has zero length (for suffix).
2009-08-27 Michael Stahl #i91565#, #i91566#: extend text:meta(-field) uno wrapper with XText interface:
unoobj.hxx: new CursorType CURSOR_META.
unoobj2.cxx: refactor SwXText implementation to ensure that when the SwXText
belongs to a SwXMeta, content is always inserted inside the meta(-field).
unoobj.cxx: new SwXTextCursor::ForceIntoMeta(): cursor stays in meta(-field).
unometa.hxx: SwXMeta implements XText, forwarding to a member SwXMetaText.
DocInsertStringSplitCR(), SwX*::attachToRange(), SwX*::DeleteAndInsert():
use FORCEHINTEXPAND hack to ensure insert into the meta(-field) at the end.
2009-08-27 Michael Stahl #i91565#, #i91566#: add text:meta(-field) uno wrapper to sw:
fmtmeta.hxx, fmtatr2.cxx: new class sw::MetaField, new sw::MetaFieldManager.
doc.hxx, docnew.cxx: new SwDoc::GetMetaFieldManager().
unocoll.hxx,.cxx: new SW_SERVICE_FIELDTYPE_METAFIELD, SW_SERVICE_TYPE_META.
unomap.hxx,.cxx: new PROPERTY_MAP_METAFIELD.
unoprnms.hxx: new UNO_NAME_META.
unoport.hxx: new PORTION_META; add "InContentMetadata" prop to SwXTextPortion.
new unometa.hxx: new class SwXMeta and SwXMetaField.
unofield.cxx: SwXFieldEnumeration: include meta-fields.
unoportenum.cxx: handle RES_TXTATR_META(FIELD) by using a portion list stack.
unotext.cxx: SwXText::insertTextContent(): handle meta(-field) as attribute.
2009-08-27 Michael Stahl #i91565#, #i91566#: ndhints.cxx: remove sort number from SwTxtAttrNesting
2009-08-27 Michael Stahl #i91565#, #i91566#: add support for hints with end and CH_TXTATR to sw core:
doc.hxx, docedt.cxx: replace SwDoc::Delete(), DeleteAndJoin(), ReplaceRange()
with wrappers that split at left-overlapped end+CH_TXTATR hints.
txatbase.hxx: new member SwTxtAttr::m_bHasDummyChar.
ndtxt.hxx: rename SwTxtNode::GetTxtAttr() to GetTxtAttrForCharAt().
ndtxt.cxx: SwTxtNode::CopyText(): copy end+CH_TXTATR hints iff copy CH_TXTATR.
txtatr2.cxx, thints.cxx: SwTxtMeta gets a CH_TXTATR.
2009-08-27 Michael Stahl #i91565#, #i91566#: add text:meta(-field) to sw core:
txatbase.hxx: new member SwTxtAttr::m_bNesting.
hintids.hxx: new ids RES_TXTATR_META, RES_TXTATR_METAFIELD.
txtatr.hxx: new base class SwTxtAttrNesting.
new hint SwTxtMeta.
SwTxtRuby derives from SwTxtAttrNesting.
txtinet.hxx: SwTxtINetFmt derives from SwTxtAttrNesting.
new header fmtmeta.hxx: new pool item SwFmtMeta. new class sw::Meta.
ndhints.hxx, thints.cxx: new method SwpHints::TryInsertNesting().
thints.cxx: refactoring: BuildPortions() no longer handles Ruby/Hyperlink,
but TryInsertNesting(), which also handles meta(-field).
SwTxtNode::InsertItem(): check if the hint is actually inserted.
ndhints.cxx: sort nesting hints based on sort number.
ndtxt.cxx: lcl_CopyHint(): handle copy of meta/meta-field.
2009-08-27 Michael Stahl enable expanding hints with m_bLockExpandFlag set:
add new InsertFlag: INS_FORCEHINTEXPAND.
add new SetAttrMode: SETATTR_FORCEHINTEXPAND.
rename SwEditShell::Insert() to Insert2() because changed signature fails
to compile when SwWrtShell tries to overwrite these non-virtual members...
SwWrtShell::Insert() sets FOCEHINTEXPAND if range was selected/deleted.
adapt SwUndoInsert to store flags.
2009-08-27 Michael Stahl change formal parameters of item insertion methods to type SetAttrMode
2009-08-27 Michael Stahl fix incorrect resetting of text attributes in SwUndoInsSection, SwUndoInserts
2009-08-27 Michael Stahl clean up SwTxtNode::CutImpl() and lcl_CopyHint()
2009-08-27 Michael Stahl rename SwDoc::Copy() to CopyRange(), and _Copy() to CopyImpl()
2009-08-27 Michael Stahl rename SwNodes::Move() to MoveRange(), and remove unused parameter
2009-08-27 Michael Stahl rename SwDoc::Move() to MoveRange()/MoveNodeRange()
2009-08-27 Michael Stahl rename SwDoc::Insert() to InsertString(), and remove sal_Unicode variant
2009-08-27 Michael Stahl rename SwDoc::Insert() to InsertPoolItem()/InsertItemSet()/InsertSwSection()
2009-08-27 Michael Stahl rename SwDoc::Replace() to ReplaceRange()
2009-08-27 Michael Stahl remove SwDoc::Overwrite() sal_Unicode variant
2009-08-27 Michael Stahl split up SwDoc::DeleteAndJoin(): factor out DeleteAndJoinWithRedline()
2009-08-27 Michael Stahl rename overloaded SwDoc::Delete() to DeleteRange()/DeleteTOXMark()
2009-08-27 Michael Stahl rename SwTxtNode::Copy() to CopyText()
2009-08-27 Michael Stahl rename SwTxtNode::Cut() to CutText(), and _Cut() to CutImpl()
2009-08-27 Michael Stahl rename SwTxtNode::Delete() to DeleteAttribute()/DeleteAttributes()
2009-08-27 Michael Stahl rename SwTxtNode::Replace() to ReplaceText(), and remove the xub_Unicode variant
2009-08-27 Michael Stahl rename SwTxtNode::Erase() to EraseText()
2009-08-27 Michael Stahl rename SwTxtNode::Insert() to InsertText(), and remove the xub_Unicode variant
2009-08-27 Michael Stahl clean up SwTxtNode::Update()
2009-08-27 Michael Stahl remove SwTxtAttr::RemoveFromPool() and make destructor non-public,
to be invoked by new method SwTxtAttr::Destroy()
2009-08-27 Michael Stahl ensure that SwDoc::Insert() for item (set) returns success indicator:
replace SwRegHistory constructor with method InsertItems(), returning bool.
refactor InsAttr() so that it checks if InsertItems() succeeds.
2009-08-27 Michael Stahl move SwXTextPortionEnumeration from unoobj.hxx to unoport.hxx
2009-08-27 Michael Stahl add missing SolarMutex in SwXTextPortion methods
2009-08-27 Michael Stahl SwXTextPortion: new member m_xTextField (so the TextField property need not
be returned indirectly via SwUnoCursorHelper).
factor out function CreateSwXTextField().
2009-08-27 Michael Stahl SwXTextPortion: remove PORTION_CONTROL_CHAR and implementation of XTextField
2009-08-27 Michael Stahl remove obsolete hint SwTxtHardBlank and formats SwFmtHardBlank/SwFmtSoftHyph
2009-08-27 Michael Stahl clean up SwTxtAttr and friends:
remove many accessor methods for obsolete (due to autofmt) char format items.
remove unused flag SwTxtAttr::m_bDontMergeAttr.
MakeRedlineTxtAttr() now dedicated function, no longer calls MakeTxtAttr().
2009-08-27 Michael Stahl remove obsolete attribute SwTxt2Lines
2009-08-27 Michael Stahl SwXTextPortionEnumeration: finish refactoring CreatePortions
change ExportHints so it always returns a text portion for hint w/ CH_TXTATR.
remove special case for handling end of paragraph.
unfortunately had to refactor the fieldmarks export as well (got in the way).
2009-08-27 Michael Stahl SwXTextPortionEnumeration: refactor CreatePortions: frames export
extract function ExportFrames() from CreatePortions().
remove (un)dead code that calls evil MovePara(fnParaCurr, fnParaEnd)
2009-08-27 Michael Stahl clean up SwXParaFrameEnumeration
2009-08-27 Michael Stahl CollectFrameAtNode: replace SwDependArr with STL based FrameDependList_t
2009-08-27 Michael Stahl SwXTextPortionEnumeration: tweak refmark/toxmark export
so ExportHints returns the portion for point marks
2009-08-27 Michael Stahl clean up SwXTextPortionEnumeration:
prefix members, remove casts, replace SvWeirdArray with STL, etc.
make CreatePortions() method a function, and remove lots of members.
extract fieldmarks function from CreatePortions.
2009-08-27 Michael Stahl remove FOREACHUNOPAM_START/END macros
2009-08-27 Michael Stahl clean up SwXTextPortion:
prefix members, remove casts, etc.
remove SwXRubyPortion: replace it with another SwXTextPortion constructor
2009-08-27 Michael Stahl #i102541# SwXReferenceMark::InsertRefMark(): use flag SETATTR_DONTEXPAND
2009-08-27 Michael Stahl rename SwTxtNode::Insert to SwTxtNode::InsertHint, and
fix constness in SwTxtNode::InsertItem
2009-08-27 Michael Stahl turn SwTxtNode::MakeTxtAttr() methods into global functions in ndhints.hxx
2009-08-27 Michael Stahl remove obsolete sw/inc/bookmrk.hxx
2009-08-27 Michael Stahl pam.cxx: fix ComparePosition functions (returned wrong result in one case)
2009-08-27 Michael Stahl #i103613# only import RDF metadata on normal open of a document
2009-09-11 kz CWS-TOOLING: integrate CWS impress176
2009-09-08 20:18:24 +0200 sj r275957 : fixed warning (shadowed variable)
2009-09-08 18:02:05 +0200 cl r275948 : #i104315# added missing tab pages
2009-09-08 17:35:18 +0200 cl r275947 : #i104866# fixed angle import
2009-09-08 17:32:53 +0200 cl r275946 : #i104841# fixed angle import
2009-09-08 17:01:25 +0200 cl r275943 : #i103935# fixed the SID_EVENTCONFIG mess
2009-09-08 14:32:57 +0200 sj r275928 : #i104685# only comments
2009-09-07 12:37:36 +0200 sj r275886 : #i104683# fixed import of bold/italic attributes for normal text shapes
2009-09-04 15:07:46 +0200 sj r275808 : #104689# fixed bullet color problem
2009-09-03 15:25:07 +0200 sj r275753 : #160200# added vertical alignment of table cells
2009-09-11 kz CWS-TOOLING: integrate CWS dv14
2009-09-10 15:16:32 +0200 sg r276035 : #160513# updated wfs scheme to accept ports
2009-09-10 07:41:47 +0200 dv r276019 : #i104942# Better renaming algorithmen
2009-08-31 13:41:11 +0200 dv r275604 : #160505# Setting APP1PRODUCTNAME must not overwrite APP1PRODUCTDEF
2009-09-11 kz CWS-TOOLING: integrate CWS jl131
2009-09-02 16:42:40 +0200 jl r275720 : #i97896#
2009-08-31 13:01:53 +0200 jl r275599 : CWS-TOOLING: rebase CWS jl131 to trunk@275331 (milestone: DEV300:m56)
2009-07-31 14:35:30 +0200 jl r274531 : CWS-TOOLING: rebase CWS jl131 to trunk@274203 (milestone: DEV300:m53)
2009-07-23 14:20:32 +0200 jl r274272 : #i79839# better error text when trying to modify shared layer without having write permission, eg. unopkg add --shared, unopkg remove --shared, unopkg reinstall --shared
2009-07-22 16:38:02 +0200 jl r274252 : #i97896# localize error message for lock file
2009-07-22 16:37:22 +0200 jl r274251 : #i80462# unprecise wording in updatedialog
2009-07-22 16:36:06 +0200 jl r274250 : #i97896# localize error message for lock file
2009-07-22 16:35:20 +0200 jl r274249 : #i97896# localize error message for lock file
2009-07-22 15:07:30 +0200 jl r274242 : #i98873# minimum java version is 1.5 since OOo 3.0
2009-09-11 kz CWS-TOOLING: integrate CWS changehc
2009-08-31 19:38:50 +0200 pl r275633 : remove dbug printf
2009-08-31 17:41:50 +0200 pl r275623 : CWS-TOOLING: rebase CWS changehc to trunk@275331 (milestone: DEV300:m56)
2009-07-15 19:45:46 +0200 pl r274028 : #i35482# use HC flag to decide high contrast mode
2009-07-15 17:40:52 +0200 pl r274020 : #i35482# use HC flag to decide high contrast mode
2009-07-15 17:39:50 +0200 pl r274019 : #i35482# update autohc correctly in MergeSystemSettings
2009-07-15 17:38:57 +0200 pl r274018 : #i35482# update autohc correctly in MergeSystemSettings
2009-09-11 kz CWS-TOOLING: integrate CWS notes10
2009-08-24 07:25:57 +0200 mod r275287 : 2009-07-26 02:38:32 +0200 mod r274343 : #i#i103645#
2009-07-26 02:01:53 +0200 mod r274342 : #i103645#
2009-07-26 01:52:42 +0200 mod r274341 : #i103490#
2009-07-22 08:31:48 +0200 mod r274215 : #i103373#
2009-07-15 00:55:11 +0200 mod r273987 : #i101419#
2009-07-14 07:07:55 +0200 mod r273956 : #i101419#
2009-07-14 07:07:43 +0200 mod r273955 : #i101419#
2009-07-14 07:02:10 +0200 mod r273954 : changes from notes9
2009-07-14 06:14:25 +0200 mod r273953 : #i103476#
2009-09-11 kz CWS-TOOLING: integrate CWS ab70
2009-09-10 15:12:54 +0200 jsk r276034 : #i85434# - mandatory automatic update test
2009-09-10 15:11:06 +0200 jsk r276033 : #i85434# - mandatory automatic update test
2009-09-02 09:49:24 +0200 ab r275698 : #i85434# Dialog Import
2009-09-11 kz CWS-TOOLING: integrate CWS hb32bugs02
2009-09-02 Henning Brinkmann #i102420# revert changes
2009-08-26 Henning Brinkmann merged DEV300_m56
2009-08-19 Henning Brinkmann merged DEV300_m55
2009-08-14 Henning Brinkmann merged changes from wntmsci12
2009-08-12 Henning Brinkmann Implemented NoSpaceEdit constructor and destructor in .cxx to allow compile with debug on wntmsci12.
2009-08-12 Henning Brinkmann Added some SW_DLLPUBLIC to make compilable on wntmsci12.
2009-08-11 Henning Brinkmann #i102420# dbg_out: surround output for SwNodes with <nodes-array>.
2009-08-10 Henning Brinkmann #i102420# rewritten debug output for SwNodes.
2009-08-07 Henning Brinkmann #i102420# debug _MoveNodes: output the destination, too. Break after two iterations.
2009-08-07 Henning Brinkmann #i102420# _MoveNodes: Additionally check if destination index is inside source => false
Check if current range was already handled => loop
Debug output current range
2009-08-06 Henning Brinkmann merged DEV300_m54
2009-08-06 Henning Brinkmann added master fix
2009-08-06 Henning Brinkmann debug output for SwNodeRange
2009-08-04 Henning Brinkmann #i102844# robustness: check for NULL pointer to prevent crash
2009-08-03 Henning Brinkmann #i103475# applied patch and verified
2009-08-03 Henning Brinkmann Removed code preventing build of sw with DEBUG.
2009-09-11 convert-repo update tags
2009-09-10 kz CWS-TOOLING: integrate CWS os2port06dev300
2009-09-05 22:49:00 +0200 ydario r275858 : #i99588# applied os2port06 diff to DEV300 tree.
2009-09-10 kz CWS-TOOLING: integrate CWS mingwport23
2009-08-29 07:07:53 +0200 tono r275555 : i#104522: mingw port graphite
2009-08-29 07:07:26 +0200 tono r275554 : i#104522: mingw port printf format fix
2009-09-10 kz CWS-TOOLING: integrate CWS mh232
2009-08-26 03:52:57 +0200 mh r275385 : #i102182# FreeBSD patch
2009-08-26 03:43:20 +0200 mh r275384 : #i101333# patch for FreeBSD
2009-08-26 03:11:20 +0200 mh r275383 : #i39230
2009-08-26 03:07:51 +0200 mh r275382 : #i39230# more space for initials field
2009-08-26 02:41:19 +0200 mh r275380 : #i39230# use vos::osecurity for reading the user name
2009-08-18 22:06:00 +0200 mh r275130 : #i104243#, line ending problem with newer perl
2009-08-18 21:53:21 +0200 mh r275129 : #i39230# read initials via getpwnam
2009-08-18 21:34:05 +0200 mh r275128 : enable CAIROCANVAS for Linux and Mac, #i88613#
2009-08-17 18:02:59 +0200 mh r275067 : #i95498# make compile with gcc3
2009-09-10 kz CWS-TOOLING: integrate CWS tkr24
2009-09-07 14:31:06 +0200 is r275898 : #160081# adding NO_LICENSE_INTO_COPYRIGHT
2009-09-10 releng #i10000# change KeyMapping to SingletonRef<framework::KeyMapping>
2009-09-11 convert-repo update tags
2009-09-10 kz CWS-TOOLING: integrate CWS os2port06dev300
2009-09-05 22:49:00 +0200 ydario r275858 : #i99588# applied os2port06 diff to DEV300 tree.
2009-09-10 kz CWS-TOOLING: integrate CWS mingwport23
2009-08-29 07:07:53 +0200 tono r275555 : i#104522: mingw port graphite
2009-08-29 07:07:26 +0200 tono r275554 : i#104522: mingw port printf format fix
2009-09-10 kz CWS-TOOLING: integrate CWS mh232
2009-08-26 03:52:57 +0200 mh r275385 : #i102182# FreeBSD patch
2009-08-26 03:43:20 +0200 mh r275384 : #i101333# patch for FreeBSD
2009-08-26 03:11:20 +0200 mh r275383 : #i39230
2009-08-26 03:07:51 +0200 mh r275382 : #i39230# more space for initials field
2009-08-26 02:41:19 +0200 mh r275380 : #i39230# use vos::osecurity for reading the user name
2009-08-18 22:06:00 +0200 mh r275130 : #i104243#, line ending problem with newer perl
2009-08-18 21:53:21 +0200 mh r275129 : #i39230# read initials via getpwnam
2009-08-18 21:34:05 +0200 mh r275128 : enable CAIROCANVAS for Linux and Mac, #i88613#
2009-08-17 18:02:59 +0200 mh r275067 : #i95498# make compile with gcc3
2009-09-10 kz CWS-TOOLING: integrate CWS tkr24
2009-09-07 14:31:06 +0200 is r275898 : #160081# adding NO_LICENSE_INTO_COPYRIGHT
2009-09-10 releng #i10000# change KeyMapping to SingletonRef<framework::KeyMapping>
2009-09-11 14:29:45 +00:00
|
|
|
pIDCO->InsertPoolItem( aTmpPaM,
|
|
|
|
SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0 );
|
2006-05-04 12:57:21 +00:00
|
|
|
pFirstTextFrmOnNewPage->GetTxtNode()->UnlockModify();
|
|
|
|
|
|
|
|
uno::Reference< document::XDocumentInfoSupplier > xDoc(
|
|
|
|
pDoc->GetDocShell()->GetBaseModel(),
|
|
|
|
uno::UNO_QUERY);
|
|
|
|
uno::Reference< beans::XPropertySet > xDocInfo(
|
|
|
|
xDoc->getDocumentInfo(),
|
|
|
|
uno::UNO_QUERY );
|
|
|
|
try
|
|
|
|
{
|
2010-10-27 11:38:46 +01:00
|
|
|
xDocInfo->setPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WorkaroundForB6375613Applied")), uno::makeAny( true ) );
|
2006-05-04 12:57:21 +00:00
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-10 22:40:05 -03:00
|
|
|
/*
|
2001-05-29 11:41:34 +00:00
|
|
|
* SwLayHelper::CheckInsert
|
|
|
|
* is the entry point for the _InsertCnt-function.
|
|
|
|
* The document content index is checked either it is
|
|
|
|
* in the layout cache either it's time to insert a page
|
|
|
|
* cause the maximal estimation of content per page is reached.
|
|
|
|
* A really big table or long paragraph may contains more than
|
|
|
|
* one page, in this case the needed count of pages will inserted.
|
2011-04-10 22:40:05 -03:00
|
|
|
*/
|
2001-05-29 11:41:34 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwLayHelper::CheckInsert( sal_uLong nNodeIndex )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
sal_Bool bLongTab = sal_False;
|
|
|
|
sal_uLong nMaxRowPerPage( 0 );
|
2001-05-29 11:41:34 +00:00
|
|
|
nNodeIndex -= nStartOfContent;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nRows( 0 );
|
2001-05-29 11:41:34 +00:00
|
|
|
if( rpFrm->IsTabFrm() )
|
|
|
|
{
|
|
|
|
//Inside a table counts every row as a paragraph
|
|
|
|
SwFrm *pLow = ((SwTabFrm*)rpFrm)->Lower();
|
|
|
|
nRows = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
++nRows;
|
|
|
|
pLow = pLow->GetNext();
|
|
|
|
} while ( pLow );
|
|
|
|
nParagraphCnt += nRows;
|
2001-10-17 10:38:53 +00:00
|
|
|
if( !pImpl && nParagraphCnt > nMaxParaPerPage + 10 )
|
|
|
|
{
|
2003-04-17 15:07:29 +00:00
|
|
|
// OD 09.04.2003 #108698# - improve heuristics:
|
|
|
|
// Assume that a table, which has more than three times the quantity
|
|
|
|
// of maximal paragraphs per page rows, consists of rows, which have
|
|
|
|
// the height of a normal paragraph. Thus, allow as much rows per page
|
|
|
|
// as much paragraphs are allowed.
|
|
|
|
if ( nRows > ( 3*nMaxParaPerPage ) )
|
2001-10-17 10:38:53 +00:00
|
|
|
{
|
2003-04-17 15:07:29 +00:00
|
|
|
nMaxRowPerPage = nMaxParaPerPage;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SwFrm *pTmp = ((SwTabFrm*)rpFrm)->Lower();
|
|
|
|
if( pTmp->GetNext() )
|
|
|
|
pTmp = pTmp->GetNext();
|
|
|
|
pTmp = ((SwRowFrm*)pTmp)->Lower();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nCnt = 0;
|
2003-04-17 15:07:29 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
++nCnt;
|
|
|
|
pTmp = pTmp->GetNext();
|
|
|
|
} while( pTmp );
|
2011-01-17 15:06:54 +01:00
|
|
|
nMaxRowPerPage = Max( sal_uLong(2), nMaxParaPerPage / nCnt );
|
2003-04-17 15:07:29 +00:00
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
bLongTab = sal_True;
|
2001-10-17 10:38:53 +00:00
|
|
|
}
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
++nParagraphCnt;
|
2011-06-17 15:20:07 +01:00
|
|
|
if( bFirst && pImpl && nIndex < pImpl->size() &&
|
2001-05-29 11:41:34 +00:00
|
|
|
pImpl->GetBreakIndex( nIndex ) == nNodeIndex &&
|
|
|
|
( pImpl->GetBreakOfst( nIndex ) < STRING_LEN ||
|
2011-06-17 15:20:07 +01:00
|
|
|
( ++nIndex < pImpl->size() &&
|
2001-05-29 11:41:34 +00:00
|
|
|
pImpl->GetBreakIndex( nIndex ) == nNodeIndex ) ) )
|
2011-01-17 15:06:54 +01:00
|
|
|
bFirst = sal_False;
|
2003-04-15 15:51:27 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2011-07-08 16:48:44 +02:00
|
|
|
sal_uLong nBreakIndex = ( pImpl && nIndex < pImpl->size() ) ?
|
2001-10-17 10:38:53 +00:00
|
|
|
pImpl->GetBreakIndex(nIndex) : 0xffff;
|
2007-09-27 08:03:52 +00:00
|
|
|
(void)nBreakIndex;
|
2001-10-17 10:38:53 +00:00
|
|
|
#endif
|
2003-04-17 15:07:29 +00:00
|
|
|
// OD 09.04.2003 #108698# - always split a big tables.
|
|
|
|
if ( !bFirst ||
|
|
|
|
( rpFrm->IsTabFrm() && bLongTab )
|
|
|
|
)
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nRowCount = 0;
|
2001-05-29 11:41:34 +00:00
|
|
|
do
|
|
|
|
{
|
2001-10-17 10:38:53 +00:00
|
|
|
if( pImpl || bLongTab )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2003-04-15 15:51:27 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2011-07-08 16:48:44 +02:00
|
|
|
sal_uLong nBrkIndex = ( pImpl && nIndex < pImpl->size() ) ?
|
2001-10-17 10:38:53 +00:00
|
|
|
pImpl->GetBreakIndex(nIndex) : 0xffff;
|
2007-09-27 08:03:52 +00:00
|
|
|
(void)nBrkIndex;
|
2001-10-17 10:38:53 +00:00
|
|
|
#endif
|
2001-05-29 11:41:34 +00:00
|
|
|
xub_StrLen nOfst = STRING_LEN;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nType = SW_LAYCACHE_IO_REC_PAGES;
|
2001-10-17 10:38:53 +00:00
|
|
|
if( bLongTab )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
|
|
|
rbBreakAfter = sal_True;
|
2007-09-27 08:03:52 +00:00
|
|
|
nOfst = static_cast<xub_StrLen>(nRowCount + nMaxRowPerPage);
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
2001-10-17 10:38:53 +00:00
|
|
|
else
|
|
|
|
{
|
2011-06-17 15:20:07 +01:00
|
|
|
while( nIndex < pImpl->size() &&
|
2001-10-17 10:38:53 +00:00
|
|
|
pImpl->GetBreakIndex(nIndex) < nNodeIndex)
|
|
|
|
++nIndex;
|
2011-06-17 15:20:07 +01:00
|
|
|
if( nIndex < pImpl->size() &&
|
2001-10-17 10:38:53 +00:00
|
|
|
pImpl->GetBreakIndex(nIndex) == nNodeIndex )
|
|
|
|
{
|
|
|
|
nType = pImpl->GetBreakType( nIndex );
|
|
|
|
nOfst = pImpl->GetBreakOfst( nIndex++ );
|
|
|
|
rbBreakAfter = sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-29 11:41:34 +00:00
|
|
|
if( nOfst < STRING_LEN )
|
|
|
|
{
|
|
|
|
sal_Bool bSplit = sal_False;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nRepeat( 0 );
|
2001-10-17 10:38:53 +00:00
|
|
|
if( !bLongTab && rpFrm->IsTxtFrm() &&
|
|
|
|
SW_LAYCACHE_IO_REC_PARA == nType &&
|
2001-05-29 11:41:34 +00:00
|
|
|
nOfst<((SwTxtFrm*)rpFrm)->GetTxtNode()->GetTxt().Len() )
|
|
|
|
bSplit = sal_True;
|
|
|
|
else if( rpFrm->IsTabFrm() && nRowCount < nOfst &&
|
2001-10-17 10:38:53 +00:00
|
|
|
( bLongTab || SW_LAYCACHE_IO_REC_TABLE == nType ) )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2004-05-03 12:47:10 +00:00
|
|
|
nRepeat = ((SwTabFrm*)rpFrm)->
|
|
|
|
GetTable()->GetRowsToRepeat();
|
|
|
|
bSplit = nOfst < nRows && nRowCount + nRepeat < nOfst;
|
2001-10-17 10:38:53 +00:00
|
|
|
bLongTab = bLongTab && bSplit;
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
if( bSplit )
|
|
|
|
{
|
|
|
|
rpFrm->InsertBehind( rpLay, rpPrv );
|
|
|
|
rpFrm->Frm().Pos() = rpLay->Frm().Pos();
|
|
|
|
rpFrm->Frm().Pos().Y() += 1;
|
|
|
|
rpPrv = rpFrm;
|
|
|
|
if( rpFrm->IsTabFrm() )
|
|
|
|
{
|
|
|
|
SwTabFrm* pTab = (SwTabFrm*)rpFrm;
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i33629#, #i29955#
|
2004-11-09 12:47:09 +00:00
|
|
|
::RegistFlys( pTab->FindPageFrm(), pTab );
|
2001-05-29 11:41:34 +00:00
|
|
|
SwFrm *pRow = pTab->Lower();
|
|
|
|
SwTabFrm *pFoll = new SwTabFrm( *pTab );
|
|
|
|
|
|
|
|
SwFrm *pPrv;
|
2004-05-03 12:47:10 +00:00
|
|
|
if( nRepeat > 0 )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
bDontCreateObjects = sal_True; //frmtool
|
2004-05-03 12:47:10 +00:00
|
|
|
|
|
|
|
// Insert new headlines:
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nRowIdx = 0;
|
2004-05-03 12:47:10 +00:00
|
|
|
SwRowFrm* pHeadline = 0;
|
|
|
|
while( nRowIdx < nRepeat )
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pTab->GetTable()->GetTabLines()[ nRowIdx ], "Table ohne Zeilen?" );
|
2004-05-03 12:47:10 +00:00
|
|
|
pHeadline =
|
2010-06-13 15:22:56 +02:00
|
|
|
new SwRowFrm( *pTab->GetTable()->GetTabLines()[ nRowIdx ], pTab );
|
2004-05-03 12:47:10 +00:00
|
|
|
pHeadline->SetRepeatedHeadline( true );
|
|
|
|
pHeadline->InsertBefore( pFoll, 0 );
|
|
|
|
pHeadline->RegistFlys();
|
|
|
|
|
|
|
|
++nRowIdx;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
bDontCreateObjects = sal_False;
|
2004-05-03 12:47:10 +00:00
|
|
|
pPrv = pHeadline;
|
2007-09-27 08:03:52 +00:00
|
|
|
nRows = nRows + nRepeat;
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
pPrv = 0;
|
|
|
|
while( pRow && nRowCount < nOfst )
|
|
|
|
{
|
|
|
|
pRow = pRow->GetNext();
|
|
|
|
++nRowCount;
|
|
|
|
}
|
|
|
|
while ( pRow )
|
|
|
|
{
|
|
|
|
SwFrm* pNxt = pRow->GetNext();
|
|
|
|
pRow->Remove();
|
|
|
|
pRow->InsertBehind( pFoll, pPrv );
|
|
|
|
pPrv = pRow;
|
|
|
|
pRow = pNxt;
|
|
|
|
}
|
|
|
|
rpFrm = pFoll;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SwTxtFrm *pNew = new SwTxtFrm( ((SwTxtFrm*)rpFrm)->
|
2010-06-13 15:22:56 +02:00
|
|
|
GetTxtNode(), rpFrm );
|
2001-05-29 11:41:34 +00:00
|
|
|
pNew->ManipOfst( nOfst );
|
|
|
|
pNew->SetFollow( ((SwTxtFrm*)rpFrm)->GetFollow() );
|
|
|
|
((SwTxtFrm*)rpFrm)->SetFollow( pNew );
|
|
|
|
rpFrm = pNew;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-29 06:58:06 +00:00
|
|
|
SwPageFrm* pLastPage = rpPage;
|
2001-05-29 11:41:34 +00:00
|
|
|
if( CheckInsertPage() )
|
|
|
|
{
|
2011-04-16 16:19:09 -03:00
|
|
|
//
|
2006-05-04 12:57:21 +00:00
|
|
|
if ( pDoc->ApplyWorkaroundForB6375613() )
|
|
|
|
{
|
|
|
|
lcl_ApplyWorkaroundForB6375613( rpFrm );
|
|
|
|
}
|
2001-06-29 06:58:06 +00:00
|
|
|
_CheckFlyCache( pLastPage );
|
2001-05-29 11:41:34 +00:00
|
|
|
if( rpPrv && rpPrv->IsTxtFrm() && !rpPrv->GetValidSizeFlag() )
|
|
|
|
rpPrv->Frm().Height( rpPrv->GetUpper()->Prt().Height() );
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
bRet = sal_True;
|
2001-05-29 11:41:34 +00:00
|
|
|
rpPrv = 0;
|
|
|
|
nParagraphCnt = 0;
|
|
|
|
|
|
|
|
if ( rpActualSection )
|
|
|
|
{
|
2012-02-13 11:37:28 +01:00
|
|
|
//Did the SectionFrm even have a content? If not, we can
|
|
|
|
//directly put it somewhere else
|
2001-05-29 11:41:34 +00:00
|
|
|
SwSectionFrm *pSct;
|
2002-11-15 10:07:52 +00:00
|
|
|
bool bInit = false;
|
2001-05-29 11:41:34 +00:00
|
|
|
if ( !rpActualSection->GetSectionFrm()->ContainsCntnt())
|
|
|
|
{
|
|
|
|
pSct = rpActualSection->GetSectionFrm();
|
|
|
|
pSct->Remove();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pSct = new SwSectionFrm(
|
2011-01-17 15:06:54 +01:00
|
|
|
*rpActualSection->GetSectionFrm(), sal_False );
|
2001-05-29 11:41:34 +00:00
|
|
|
rpActualSection->GetSectionFrm()->SimpleFormat();
|
2002-11-15 10:07:52 +00:00
|
|
|
bInit = true;
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
rpActualSection->SetSectionFrm( pSct );
|
|
|
|
pSct->InsertBehind( rpLay, 0 );
|
2001-11-13 14:21:55 +00:00
|
|
|
if( bInit )
|
|
|
|
pSct->Init();
|
2001-05-29 11:41:34 +00:00
|
|
|
pSct->Frm().Pos() = rpLay->Frm().Pos();
|
2012-02-13 11:37:28 +01:00
|
|
|
pSct->Frm().Pos().Y() += 1; //because of the notifications
|
2001-05-29 11:41:34 +00:00
|
|
|
|
|
|
|
rpLay = pSct;
|
|
|
|
if ( rpLay->Lower() && rpLay->Lower()->IsLayoutFrm() )
|
|
|
|
rpLay = rpLay->GetNextLayoutLeaf();
|
|
|
|
}
|
|
|
|
}
|
2011-06-17 15:20:07 +01:00
|
|
|
} while( bLongTab || ( pImpl && nIndex < pImpl->size() &&
|
2001-10-17 10:38:53 +00:00
|
|
|
(*pImpl)[ nIndex ] == nNodeIndex ) );
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
bFirst = sal_False;
|
2001-05-29 11:41:34 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2003-04-17 15:07:29 +00:00
|
|
|
struct SdrObjectCompare
|
|
|
|
{
|
|
|
|
bool operator()( const SdrObject* pF1, const SdrObject* pF2 ) const
|
|
|
|
{
|
|
|
|
return pF1->GetOrdNum() < pF2->GetOrdNum();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FlyCacheCompare
|
|
|
|
{
|
|
|
|
bool operator()( const SwFlyCache* pC1, const SwFlyCache* pC2 ) const
|
|
|
|
{
|
|
|
|
return pC1->nOrdNum < pC2->nOrdNum;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-04-10 22:40:05 -03:00
|
|
|
/*
|
2001-06-29 06:58:06 +00:00
|
|
|
* SwLayHelper::_CheckFlyCache(..)
|
|
|
|
* If a new page is inserted, the last page is analysed.
|
|
|
|
* If there are text frames with default position, the fly cache
|
|
|
|
* is checked, if these frames are stored in the cache.
|
2011-04-10 22:40:05 -03:00
|
|
|
*/
|
2001-06-29 06:58:06 +00:00
|
|
|
|
|
|
|
void SwLayHelper::_CheckFlyCache( SwPageFrm* pPage )
|
|
|
|
{
|
2001-06-29 07:18:46 +00:00
|
|
|
if( !pImpl || !pPage )
|
2001-06-29 06:58:06 +00:00
|
|
|
return;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nFlyCount = pImpl->GetFlyCount();
|
2001-06-29 06:58:06 +00:00
|
|
|
// Any text frames at the page, fly cache avaiable?
|
|
|
|
if( pPage->GetSortedObjs() && nFlyIdx < nFlyCount )
|
|
|
|
{
|
2004-08-02 13:10:26 +00:00
|
|
|
SwSortedObjs &rObjs = *pPage->GetSortedObjs();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPgNum = pPage->GetPhyPageNum();
|
2003-04-17 15:07:29 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// NOTE: Here we do not use the absolute ordnums but
|
|
|
|
// relative ordnums for the objects on this page.
|
|
|
|
|
|
|
|
// skip fly frames from pages before the current page
|
|
|
|
SwFlyCache* pFlyC;
|
|
|
|
while( nFlyIdx < nFlyCount && ( pFlyC = pImpl->
|
|
|
|
GetFlyCache(nFlyIdx) )->nPageNum < nPgNum)
|
|
|
|
++nFlyIdx;
|
|
|
|
|
|
|
|
// sort cached objects on this page by ordnum
|
|
|
|
std::set< const SwFlyCache*, FlyCacheCompare > aFlyCacheSet;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nIdx = nFlyIdx;
|
2003-04-17 15:07:29 +00:00
|
|
|
|
|
|
|
while( nIdx < nFlyCount && ( pFlyC = pImpl->
|
|
|
|
GetFlyCache( nIdx ) )->nPageNum == nPgNum )
|
|
|
|
{
|
|
|
|
aFlyCacheSet.insert( pFlyC );
|
|
|
|
++nIdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
// sort objects on this page by ordnum
|
|
|
|
std::set< const SdrObject*, SdrObjectCompare > aFlySet;
|
2011-01-17 15:06:54 +01:00
|
|
|
for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
|
2003-04-17 15:07:29 +00:00
|
|
|
{
|
2004-08-02 13:10:26 +00:00
|
|
|
SwAnchoredObject* pAnchoredObj = rObjs[i];
|
|
|
|
if ( pAnchoredObj->ISA(SwFlyFrm) ) // a text frame?
|
2003-04-17 15:07:29 +00:00
|
|
|
{
|
2004-08-02 13:10:26 +00:00
|
|
|
SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
|
2004-06-28 12:40:19 +00:00
|
|
|
if( pFly->GetAnchorFrm() &&
|
|
|
|
!pFly->GetAnchorFrm()->FindFooterOrHeader() )
|
2003-04-17 15:07:29 +00:00
|
|
|
{
|
2004-08-02 13:10:26 +00:00
|
|
|
const SwContact *pC = ::GetUserCall( pAnchoredObj->GetDrawObj() );
|
2003-04-17 15:07:29 +00:00
|
|
|
if( pC )
|
|
|
|
{
|
2004-08-02 13:10:26 +00:00
|
|
|
aFlySet.insert( pAnchoredObj->GetDrawObj() );
|
2003-04-17 15:07:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( aFlyCacheSet.size() == aFlySet.size() )
|
|
|
|
{
|
|
|
|
std::set< const SwFlyCache*, FlyCacheCompare >::iterator aFlyCacheSetIt =
|
|
|
|
aFlyCacheSet.begin();
|
|
|
|
std::set< const SdrObject*, SdrObjectCompare >::iterator aFlySetIt =
|
|
|
|
aFlySet.begin();
|
|
|
|
|
|
|
|
while ( aFlyCacheSetIt != aFlyCacheSet.end() )
|
|
|
|
{
|
2007-09-27 08:03:52 +00:00
|
|
|
const SwFlyCache* pFlyCache = *aFlyCacheSetIt;
|
2003-04-17 15:07:29 +00:00
|
|
|
SwFlyFrm* pFly = ((SwVirtFlyDrawObj*)*aFlySetIt)->GetFlyFrm();
|
|
|
|
|
2012-03-21 23:26:30 +01:00
|
|
|
if ( pFly->Frm().Left() == FAR_AWAY )
|
2003-04-17 15:07:29 +00:00
|
|
|
{
|
|
|
|
// we get the stored information
|
2007-09-27 08:03:52 +00:00
|
|
|
pFly->Frm().Pos().X() = pFlyCache->Left() +
|
2003-04-17 15:07:29 +00:00
|
|
|
pPage->Frm().Left();
|
2007-09-27 08:03:52 +00:00
|
|
|
pFly->Frm().Pos().Y() = pFlyCache->Top() +
|
2003-04-17 15:07:29 +00:00
|
|
|
pPage->Frm().Top();
|
|
|
|
if ( pImpl->IsUseFlyCache() )
|
|
|
|
{
|
2007-09-27 08:03:52 +00:00
|
|
|
pFly->Frm().Width( pFlyCache->Width() );
|
|
|
|
pFly->Frm().Height( pFlyCache->Height() );
|
2003-04-17 15:07:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
++aFlyCacheSetIt;
|
|
|
|
++aFlySetIt;
|
|
|
|
}
|
|
|
|
}
|
2001-06-29 06:58:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-10 22:40:05 -03:00
|
|
|
/*
|
2001-06-29 06:58:06 +00:00
|
|
|
* SwLayHelper::CheckPageFlyCache(..)
|
|
|
|
* looks for the given text frame in the fly cache and sets
|
|
|
|
* the position and size, if possible.
|
|
|
|
* The fly cache is sorted by pages and we start searching with the given page.
|
|
|
|
* If we found the page number in the fly cache, we set
|
|
|
|
* the rpPage parameter to the right page, if possible.
|
2011-04-10 22:40:05 -03:00
|
|
|
*/
|
2001-06-29 06:58:06 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwLayHelper::CheckPageFlyCache( SwPageFrm* &rpPage, SwFlyFrm* pFly )
|
2001-06-29 06:58:06 +00:00
|
|
|
{
|
2004-06-28 12:40:19 +00:00
|
|
|
if( !pFly->GetAnchorFrm() || !pFly->GetVirtDrawObj() ||
|
|
|
|
pFly->GetAnchorFrm()->FindFooterOrHeader() )
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
|
|
|
sal_Bool bRet = sal_False;
|
2001-06-29 06:58:06 +00:00
|
|
|
SwDoc* pDoc = rpPage->GetFmt()->GetDoc();
|
|
|
|
SwLayCacheImpl *pCache = pDoc->GetLayoutCache() ?
|
|
|
|
pDoc->GetLayoutCache()->LockImpl() : NULL;
|
|
|
|
if( pCache )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPgNum = rpPage->GetPhyPageNum();
|
|
|
|
sal_uInt16 nIdx = 0;
|
|
|
|
sal_uInt16 nCnt = pCache->GetFlyCount();
|
|
|
|
sal_uLong nOrdNum = pFly->GetVirtDrawObj()->GetOrdNum();
|
2007-09-27 08:03:52 +00:00
|
|
|
SwFlyCache* pFlyC = 0;
|
2003-04-17 15:07:29 +00:00
|
|
|
|
|
|
|
// skip fly frames from pages before the current page
|
2001-06-29 06:58:06 +00:00
|
|
|
while( nIdx < nCnt &&
|
|
|
|
nPgNum > (pFlyC = pCache->GetFlyCache( nIdx ))->nPageNum )
|
|
|
|
++nIdx;
|
2003-04-17 15:07:29 +00:00
|
|
|
|
2001-06-29 06:58:06 +00:00
|
|
|
while( nIdx < nCnt &&
|
|
|
|
nOrdNum != (pFlyC = pCache->GetFlyCache( nIdx ))->nOrdNum )
|
|
|
|
++nIdx;
|
|
|
|
if( nIdx < nCnt )
|
|
|
|
{
|
|
|
|
SwPageFrm *pPage = rpPage;
|
|
|
|
while( pPage && pPage->GetPhyPageNum() < pFlyC->nPageNum )
|
|
|
|
pPage = (SwPageFrm*)pPage->GetNext();
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i43266# - if the found page is an empty page,
|
2005-03-23 10:53:43 +00:00
|
|
|
// take the previous one (take next one, if previous one doesn't exists)
|
|
|
|
if ( pPage && pPage->IsEmptyPage() )
|
|
|
|
{
|
|
|
|
pPage = static_cast<SwPageFrm*>( pPage->GetPrev()
|
|
|
|
? pPage->GetPrev()
|
|
|
|
: pPage->GetNext() );
|
|
|
|
}
|
2001-06-29 06:58:06 +00:00
|
|
|
if( pPage )
|
|
|
|
{
|
|
|
|
rpPage = pPage;
|
|
|
|
pFly->Frm().Pos().X() = pFlyC->Left() + pPage->Frm().Left();
|
|
|
|
pFly->Frm().Pos().Y() = pFlyC->Top() + pPage->Frm().Top();
|
2003-04-17 15:07:29 +00:00
|
|
|
if ( pCache->IsUseFlyCache() )
|
|
|
|
{
|
|
|
|
pFly->Frm().Width( pFlyC->Width() );
|
|
|
|
pFly->Frm().Height( pFlyC->Height() );
|
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
bRet = sal_True;
|
2001-06-29 06:58:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pDoc->GetLayoutCache()->UnlockImpl();
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2001-05-29 11:41:34 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
SwLayCacheIoImpl::SwLayCacheIoImpl( SvStream& rStrm, sal_Bool bWrtMd ) :
|
2001-05-29 11:41:34 +00:00
|
|
|
pStream( &rStrm ),
|
|
|
|
nMajorVersion(SW_LAYCACHE_IO_VERSION_MAJOR),
|
|
|
|
nMinorVersion(SW_LAYCACHE_IO_VERSION_MINOR),
|
|
|
|
bWriteMode( bWrtMd ),
|
2011-01-17 15:06:54 +01:00
|
|
|
bError( sal_False )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
|
|
|
if( bWriteMode )
|
|
|
|
*pStream << nMajorVersion
|
|
|
|
<< nMinorVersion;
|
|
|
|
|
|
|
|
else
|
|
|
|
*pStream >> nMajorVersion
|
|
|
|
>> nMinorVersion;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwLayCacheIoImpl::OpenRec( sal_uInt8 cType )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bRes = sal_True;
|
|
|
|
sal_uInt32 nPos = pStream->Tell();
|
2001-05-29 11:41:34 +00:00
|
|
|
if( bWriteMode )
|
|
|
|
{
|
2011-02-03 16:09:53 +00:00
|
|
|
aRecords.push_back( RecTypeSize(cType, nPos) );
|
2011-01-17 15:06:54 +01:00
|
|
|
*pStream << (sal_uInt32) 0;
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt32 nVal;
|
2001-05-29 11:41:34 +00:00
|
|
|
*pStream >> nVal;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt8 cRecTyp = (sal_uInt8)nVal;
|
2001-05-29 11:41:34 +00:00
|
|
|
if( !nVal || cRecTyp != cType ||
|
|
|
|
pStream->GetErrorCode() != SVSTREAM_OK || pStream->IsEof() )
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( nVal, "OpenRec: Record-Header is 0" );
|
2011-02-03 16:09:53 +00:00
|
|
|
OSL_ENSURE( cRecTyp == cType, "OpenRec: Wrong Record Type" );
|
|
|
|
aRecords.push_back( RecTypeSize(0, pStream->Tell()) );
|
2001-05-29 11:41:34 +00:00
|
|
|
bRes = sal_False;
|
2011-01-17 15:06:54 +01:00
|
|
|
bError = sal_True;
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
2011-02-03 16:09:53 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sal_uInt32 nSize = nVal >> 8;
|
|
|
|
aRecords.push_back( RecTypeSize(cRecTyp, nPos+nSize) );
|
|
|
|
}
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
return bRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close record
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwLayCacheIoImpl::CloseRec( sal_uInt8 )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bRes = sal_True;
|
2011-02-03 16:09:53 +00:00
|
|
|
OSL_ENSURE( !aRecords.empty(), "CloseRec: no levels" );
|
|
|
|
if( !aRecords.empty() )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt32 nPos = pStream->Tell();
|
2001-05-29 11:41:34 +00:00
|
|
|
if( bWriteMode )
|
|
|
|
{
|
2011-03-14 16:51:14 +00:00
|
|
|
sal_uInt32 nBgn = aRecords.back().size;
|
2001-05-29 11:41:34 +00:00
|
|
|
pStream->Seek( nBgn );
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt32 nSize = nPos - nBgn;
|
2011-03-14 16:51:14 +00:00
|
|
|
sal_uInt32 nVal = ( nSize << 8 ) | aRecords.back().type;
|
2001-05-29 11:41:34 +00:00
|
|
|
*pStream << nVal;
|
|
|
|
pStream->Seek( nPos );
|
|
|
|
if( pStream->GetError() != SVSTREAM_OK )
|
2011-01-17 15:06:54 +01:00
|
|
|
bRes = sal_False;
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-14 16:51:14 +00:00
|
|
|
sal_uInt32 n = aRecords.back().size;
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( n >= nPos, "CloseRec: to much data read" );
|
2001-05-29 11:41:34 +00:00
|
|
|
if( n != nPos )
|
|
|
|
{
|
|
|
|
pStream->Seek( n );
|
|
|
|
if( n < nPos )
|
2011-01-17 15:06:54 +01:00
|
|
|
bRes = sal_False;
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
if( pStream->GetErrorCode() != SVSTREAM_OK )
|
2011-01-17 15:06:54 +01:00
|
|
|
bRes = sal_False;
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
2011-02-03 16:09:53 +00:00
|
|
|
aRecords.pop_back();
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !bRes )
|
2011-01-17 15:06:54 +01:00
|
|
|
bError = sal_True;
|
2001-05-29 11:41:34 +00:00
|
|
|
|
|
|
|
return bRes;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt32 SwLayCacheIoImpl::BytesLeft()
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt32 n = 0;
|
2011-02-03 16:09:53 +00:00
|
|
|
if( !bError && !aRecords.empty() )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-03-14 16:51:14 +00:00
|
|
|
sal_uInt32 nEndPos = aRecords.back().size;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt32 nPos = pStream->Tell();
|
2001-05-29 11:41:34 +00:00
|
|
|
if( nEndPos > nPos )
|
|
|
|
n = nEndPos - nPos;
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt8 SwLayCacheIoImpl::Peek()
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt8 c = 0;
|
2001-05-29 11:41:34 +00:00
|
|
|
if( !bError )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt32 nPos = pStream->Tell();
|
2001-05-29 11:41:34 +00:00
|
|
|
*pStream >> c;
|
|
|
|
pStream->Seek( nPos );
|
|
|
|
if( pStream->GetErrorCode() != SVSTREAM_OK )
|
|
|
|
{
|
|
|
|
c = 0;
|
2011-01-17 15:06:54 +01:00
|
|
|
bError = sal_True;
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwLayCacheIoImpl::SkipRec()
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt8 c = Peek();
|
2001-05-29 11:41:34 +00:00
|
|
|
OpenRec( c );
|
2011-02-03 16:09:53 +00:00
|
|
|
pStream->Seek( aRecords.back().size );
|
2001-05-29 11:41:34 +00:00
|
|
|
CloseRec( c );
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt8 SwLayCacheIoImpl::OpenFlagRec()
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( !bWriteMode, "OpenFlagRec illegal in write mode" );
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt8 cFlags;
|
2001-05-29 11:41:34 +00:00
|
|
|
*pStream >> cFlags;
|
|
|
|
nFlagRecEnd = pStream->Tell() + ( cFlags & 0x0F );
|
|
|
|
return (cFlags >> 4);
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwLayCacheIoImpl::OpenFlagRec( sal_uInt8 nFlags, sal_uInt8 nLen )
|
2001-05-29 11:41:34 +00:00
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( bWriteMode, "OpenFlagRec illegal in read mode" );
|
|
|
|
OSL_ENSURE( (nFlags & 0xF0) == 0, "illegal flags set" );
|
|
|
|
OSL_ENSURE( nLen < 16, "wrong flag record length" );
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt8 cFlags = (nFlags << 4) + nLen;
|
2001-05-29 11:41:34 +00:00
|
|
|
*pStream << cFlags;
|
|
|
|
nFlagRecEnd = pStream->Tell() + nLen;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwLayCacheIoImpl::CloseFlagRec()
|
|
|
|
{
|
|
|
|
if( bWriteMode )
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pStream->Tell() == nFlagRecEnd, "Wrong amount of data written" );
|
2001-05-29 11:41:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pStream->Tell() <= nFlagRecEnd, "To many data read" );
|
2001-05-29 11:41:34 +00:00
|
|
|
if( pStream->Tell() != nFlagRecEnd )
|
|
|
|
pStream->Seek( nFlagRecEnd );
|
|
|
|
}
|
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|