summaryrefslogtreecommitdiff
path: root/sw/source/core/layout/laycache.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/layout/laycache.cxx')
-rw-r--r--sw/source/core/layout/laycache.cxx136
1 files changed, 38 insertions, 98 deletions
diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx
index dbc59bc25fa5..60ac1238c19c 100644
--- a/sw/source/core/layout/laycache.cxx
+++ b/sw/source/core/layout/laycache.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -253,7 +254,7 @@ void SwLayoutCache::Write( SvStream &rStream, const SwDoc& rDoc )
pSub = pSub->GetNext();
}
pTab = pTab->GetFollow();
- ASSERT( pTab, "Table follow without master" );
+ OSL_ENSURE( pTab, "Table follow without master" );
}
}
do
@@ -291,7 +292,7 @@ void SwLayoutCache::Write( SvStream &rStream, const SwDoc& rDoc )
SwPageFrm *pTabPage = pTab->FindPageFrm();
if( pTabPage != pPage )
{
- ASSERT( pPage->GetPhyPageNum() <
+ OSL_ENSURE( pPage->GetPhyPageNum() <
pTabPage->GetPhyPageNum(),
"Looping Tableframes" );
pPage = pTabPage;
@@ -346,7 +347,7 @@ void SwLayoutCache::Write( SvStream &rStream, const SwDoc& rDoc )
}
}
-#ifdef DBG_UTIL
+#if OSL_DEBUG_LEVEL > 1
sal_Bool SwLayoutCache::CompareLayout( const SwDoc& rDoc ) const
{
if( !pImpl )
@@ -476,7 +477,7 @@ void SwLayoutCache::ClearImpl()
SwLayoutCache::~SwLayoutCache()
{
- ASSERT( !nLockCount, "Deleting a locked SwLayoutCache!?" );
+ OSL_ENSURE( !nLockCount, "Deleting a locked SwLayoutCache!?" );
delete pImpl;
}
@@ -544,7 +545,7 @@ SwLayHelper::~SwLayHelper()
{
if( pImpl )
{
- ASSERT( pDoc && pDoc->GetLayoutCache(), "Missing layoutcache" );
+ OSL_ENSURE( pDoc && pDoc->GetLayoutCache(), "Missing layoutcache" );
pDoc->GetLayoutCache()->UnlockImpl();
}
}
@@ -665,18 +666,18 @@ sal_Bool SwLayHelper::CheckInsertPage()
bNextPageOdd, bInsertEmpty, sal_False, rpPage->GetNext() );
if ( bEnd )
{
- ASSERT( rpPage->GetNext(), "Keine neue Seite?" );
+ OSL_ENSURE( rpPage->GetNext(), "Keine neue Seite?" );
do
{ rpPage = (SwPageFrm*)rpPage->GetNext();
} while ( rpPage->GetNext() );
}
else
{
- ASSERT( rpPage->GetNext(), "Keine neue Seite?" );
+ OSL_ENSURE( rpPage->GetNext(), "Keine neue Seite?" );
rpPage = (SwPageFrm*)rpPage->GetNext();
if ( rpPage->IsEmptyPage() )
{
- ASSERT( rpPage->GetNext(), "Keine neue Seite?" );
+ OSL_ENSURE( rpPage->GetNext(), "Keine neue Seite?" );
rpPage = (SwPageFrm*)rpPage->GetNext();
}
}
@@ -742,7 +743,7 @@ void lcl_ApplyWorkaroundForB6375613( SwFrm* p_pFirstFrmOnNewPage )
uno::UNO_QUERY );
try
{
- xDocInfo->setPropertyValue( rtl::OUString::createFromAscii("WorkaroundForB6375613Applied"), uno::makeAny( true ) );
+ xDocInfo->setPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WorkaroundForB6375613Applied")), uno::makeAny( true ) );
}
catch( uno::Exception& )
{
@@ -898,7 +899,7 @@ sal_Bool SwLayHelper::CheckInsert( sal_uLong nNodeIndex )
SwRowFrm* pHeadline = 0;
while( nRowIdx < nRepeat )
{
- ASSERT( pTab->GetTable()->GetTabLines()[ nRowIdx ], "Table ohne Zeilen?" );
+ OSL_ENSURE( pTab->GetTable()->GetTabLines()[ nRowIdx ], "Table ohne Zeilen?" );
pHeadline =
new SwRowFrm( *pTab->GetTable()->GetTabLines()[ nRowIdx ], pTab );
pHeadline->SetRepeatedHeadline( true );
@@ -1031,59 +1032,6 @@ void SwLayHelper::_CheckFlyCache( SwPageFrm* pPage )
SwSortedObjs &rObjs = *pPage->GetSortedObjs();
sal_uInt16 nPgNum = pPage->GetPhyPageNum();
-/*
-
- //
- // NOTE: This code assumes that all objects have already been
- // inserted into the drawing layout, so that the cached objects
- // can be identified by their ordnum. Unfortunately this function
- // is called with page n if page n+1 has been inserted. Thus
- // not all the objects have been inserted and the ordnums cannot
- // be used to identify the objects.
- //
-
- for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i ) // check objects
- {
- SdrObject *pO = rObjs[i];
- if ( pO->ISA(SwVirtFlyDrawObj) ) // a text frame?
- {
- SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pO)->GetFlyFrm();
- if( pFly->Frm().Left() == WEIT_WECH && pFly->GetAnchor() &&
- !pFly->GetAnchor()->FindFooterOrHeader() )
- { // Only frame with default position and not in header/footer
- const SwContact *pC = (SwContact*)GetUserCall(pO);
- if( pC )
- {
- sal_uLong nOrdNum = pO->GetOrdNum(); // the Id
- SwFlyCache* pFlyC;
- while( nFlyIdx < nFlyCount && ( pFlyC = pImpl->
- GetFlyCache(nFlyIdx) )->nPageNum < nPgNum)
- ++nFlyIdx;
- if( nFlyIdx < nFlyCount &&
- pFlyC->nPageNum == nPgNum )
- {
- sal_uInt16 nIdx = nFlyIdx;
- while( nIdx < nFlyCount && ( pFlyC = pImpl->
- GetFlyCache( nIdx ) )->nPageNum == nPgNum &&
- pFlyC->nOrdNum != nOrdNum )
- ++nIdx;
- if( nIdx < nFlyCount && pFlyC->nPageNum == nPgNum &&
- pFlyC->nOrdNum == nOrdNum )
- { // we get the stored information
- pFly->Frm().Pos().X() = pFlyC->Left() +
- pPage->Frm().Left();
- pFly->Frm().Pos().Y() = pFlyC->Top() +
- pPage->Frm().Top();
- pFly->Frm().Width( pFlyC->Width() );
- pFly->Frm().Height( pFlyC->Height() );
- }
- }
- }
- }
- }
- }
- */
-
//
// NOTE: Here we do not use the absolute ordnums but
// relative ordnums for the objects on this page.
@@ -1245,13 +1193,10 @@ SwLayCacheIoImpl::SwLayCacheIoImpl( SvStream& rStrm, sal_Bool bWrtMd ) :
sal_Bool SwLayCacheIoImpl::OpenRec( sal_uInt8 cType )
{
sal_Bool bRes = sal_True;
- size_t nLvl = aRecTypes.size();
- ASSERT( nLvl == aRecSizes.Count(), "OpenRec: Level" );
sal_uInt32 nPos = pStream->Tell();
if( bWriteMode )
{
- aRecTypes.push_back( cType );
- aRecSizes.Insert( nPos, nLvl );
+ aRecords.push_back( RecTypeSize(cType, nPos) );
*pStream << (sal_uInt32) 0;
}
else
@@ -1259,20 +1204,20 @@ sal_Bool SwLayCacheIoImpl::OpenRec( sal_uInt8 cType )
sal_uInt32 nVal;
*pStream >> nVal;
sal_uInt8 cRecTyp = (sal_uInt8)nVal;
- aRecTypes.push_back( cRecTyp );
- sal_uInt32 nSize = nVal >> 8;
- aRecSizes.Insert( nPos + nSize, nLvl );
if( !nVal || cRecTyp != cType ||
pStream->GetErrorCode() != SVSTREAM_OK || pStream->IsEof() )
{
- ASSERT( nVal, "OpenRec: Record-Header is 0" );
- ASSERT( cRecTyp == cType,
- "OpenRec: Wrong Record Type" );
- aRecTypes.back() = 0;
- aRecSizes[nLvl] = pStream->Tell();
+ OSL_ENSURE( nVal, "OpenRec: Record-Header is 0" );
+ OSL_ENSURE( cRecTyp == cType, "OpenRec: Wrong Record Type" );
+ aRecords.push_back( RecTypeSize(0, pStream->Tell()) );
bRes = sal_False;
bError = sal_True;
}
+ else
+ {
+ sal_uInt32 nSize = nVal >> 8;
+ aRecords.push_back( RecTypeSize(cRecTyp, nPos+nSize) );
+ }
}
return bRes;
}
@@ -1282,19 +1227,16 @@ sal_Bool SwLayCacheIoImpl::OpenRec( sal_uInt8 cType )
sal_Bool SwLayCacheIoImpl::CloseRec( sal_uInt8 )
{
sal_Bool bRes = sal_True;
- size_t nLvl = aRecTypes.size();
- ASSERT( nLvl == aRecSizes.Count(), "CloseRec: wrong Level" );
- ASSERT( nLvl, "CloseRec: no levels" );
- if( nLvl )
+ OSL_ENSURE( !aRecords.empty(), "CloseRec: no levels" );
+ if( !aRecords.empty() )
{
- nLvl--;
sal_uInt32 nPos = pStream->Tell();
if( bWriteMode )
{
- sal_uInt32 nBgn = aRecSizes[nLvl];
+ sal_uInt32 nBgn = aRecords.back().size;
pStream->Seek( nBgn );
sal_uInt32 nSize = nPos - nBgn;
- sal_uInt32 nVal = ( nSize << 8 ) | aRecTypes.back();
+ sal_uInt32 nVal = ( nSize << 8 ) | aRecords.back().type;
*pStream << nVal;
pStream->Seek( nPos );
if( pStream->GetError() != SVSTREAM_OK )
@@ -1302,8 +1244,8 @@ sal_Bool SwLayCacheIoImpl::CloseRec( sal_uInt8 )
}
else
{
- sal_uInt32 n = aRecSizes[nLvl];
- ASSERT( n >= nPos, "CloseRec: to much data read" );
+ sal_uInt32 n = aRecords.back().size;
+ OSL_ENSURE( n >= nPos, "CloseRec: to much data read" );
if( n != nPos )
{
pStream->Seek( n );
@@ -1313,9 +1255,7 @@ sal_Bool SwLayCacheIoImpl::CloseRec( sal_uInt8 )
if( pStream->GetErrorCode() != SVSTREAM_OK )
bRes = sal_False;
}
-
- aRecTypes.pop_back();
- aRecSizes.Remove( nLvl, 1 );
+ aRecords.pop_back();
}
if( !bRes )
@@ -1326,16 +1266,14 @@ sal_Bool SwLayCacheIoImpl::CloseRec( sal_uInt8 )
sal_uInt32 SwLayCacheIoImpl::BytesLeft()
{
- sal_uInt16 nLvl = aRecSizes.Count();
sal_uInt32 n = 0;
- if( !bError && nLvl )
+ if( !bError && !aRecords.empty() )
{
- sal_uInt32 nEndPos = aRecSizes[ nLvl-1 ];
+ sal_uInt32 nEndPos = aRecords.back().size;
sal_uInt32 nPos = pStream->Tell();
if( nEndPos > nPos )
n = nEndPos - nPos;
}
-
return n;
}
@@ -1360,13 +1298,13 @@ void SwLayCacheIoImpl::SkipRec()
{
sal_uInt8 c = Peek();
OpenRec( c );
- pStream->Seek( aRecSizes[aRecSizes.Count()-1] );
+ pStream->Seek( aRecords.back().size );
CloseRec( c );
}
sal_uInt8 SwLayCacheIoImpl::OpenFlagRec()
{
- ASSERT( !bWriteMode, "OpenFlagRec illegal in write mode" );
+ OSL_ENSURE( !bWriteMode, "OpenFlagRec illegal in write mode" );
sal_uInt8 cFlags;
*pStream >> cFlags;
nFlagRecEnd = pStream->Tell() + ( cFlags & 0x0F );
@@ -1375,9 +1313,9 @@ sal_uInt8 SwLayCacheIoImpl::OpenFlagRec()
void SwLayCacheIoImpl::OpenFlagRec( sal_uInt8 nFlags, sal_uInt8 nLen )
{
- ASSERT( bWriteMode, "OpenFlagRec illegal in read mode" );
- ASSERT( (nFlags & 0xF0) == 0, "illegal flags set" );
- ASSERT( nLen < 16, "wrong flag record length" );
+ OSL_ENSURE( bWriteMode, "OpenFlagRec illegal in read mode" );
+ OSL_ENSURE( (nFlags & 0xF0) == 0, "illegal flags set" );
+ OSL_ENSURE( nLen < 16, "wrong flag record length" );
sal_uInt8 cFlags = (nFlags << 4) + nLen;
*pStream << cFlags;
nFlagRecEnd = pStream->Tell() + nLen;
@@ -1387,12 +1325,14 @@ void SwLayCacheIoImpl::CloseFlagRec()
{
if( bWriteMode )
{
- ASSERT( pStream->Tell() == nFlagRecEnd, "Wrong amount of data written" );
+ OSL_ENSURE( pStream->Tell() == nFlagRecEnd, "Wrong amount of data written" );
}
else
{
- ASSERT( pStream->Tell() <= nFlagRecEnd, "To many data read" );
+ OSL_ENSURE( pStream->Tell() <= nFlagRecEnd, "To many data read" );
if( pStream->Tell() != nFlagRecEnd )
pStream->Seek( nFlagRecEnd );
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */