2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 23:16:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 18:17:47 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:17:47 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:17:47 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:17:47 +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.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:17:47 +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).
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:17:47 +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.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include "scitems.hxx"
|
|
|
|
#include <svx/algitem.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/boxitem.hxx>
|
|
|
|
#include <editeng/bolnitem.hxx>
|
|
|
|
#include <editeng/frmdiritem.hxx>
|
|
|
|
#include <editeng/shaditem.hxx>
|
2010-09-15 12:28:47 +02:00
|
|
|
#include <editeng/editobj.hxx>
|
2010-10-05 11:19:10 -04:00
|
|
|
#include <editeng/justifyitem.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/poolcach.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/fontitem.hxx>
|
2009-10-19 13:22:39 +02:00
|
|
|
#include <unotools/fontcvt.hxx>
|
2001-08-10 17:02:39 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
#include "attarray.hxx"
|
|
|
|
#include "global.hxx"
|
|
|
|
#include "document.hxx"
|
|
|
|
#include "docpool.hxx"
|
|
|
|
#include "patattr.hxx"
|
|
|
|
#include "stlsheet.hxx"
|
|
|
|
#include "stlpool.hxx"
|
|
|
|
#include "markarr.hxx"
|
|
|
|
#include "rechead.hxx"
|
|
|
|
#include "globstr.hrc"
|
2010-06-23 13:38:34 +02:00
|
|
|
#include "segmenttree.hxx"
|
2010-09-15 12:28:47 +02:00
|
|
|
#include "cell.hxx"
|
2011-08-23 14:25:38 +02:00
|
|
|
#include <rtl/strbuf.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
// STATIC DATA -----------------------------------------------------------
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2011-03-25 15:51:46 +01:00
|
|
|
using ::editeng::SvxBorderLine;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
ScAttrArray::ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc ) :
|
2000-09-18 23:16:46 +00:00
|
|
|
nCol( nNewCol ),
|
|
|
|
nTab( nNewTab ),
|
|
|
|
pDocument( pDoc )
|
|
|
|
{
|
2001-11-05 11:16:00 +00:00
|
|
|
nCount = nLimit = 1;
|
2000-09-18 23:16:46 +00:00
|
|
|
pData = new ScAttrEntry[1];
|
|
|
|
if (pData)
|
|
|
|
{
|
|
|
|
pData[0].nRow = MAXROW;
|
2010-10-22 09:28:50 +01:00
|
|
|
pData[0].pPattern = pDocument->GetDefPattern(); // no put
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ScAttrArray::~ScAttrArray()
|
|
|
|
{
|
2011-03-10 21:12:56 +01:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2000-09-18 23:16:46 +00:00
|
|
|
TestData();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (pData)
|
|
|
|
{
|
|
|
|
ScDocumentPool* pDocPool = pDocument->GetPool();
|
2004-06-04 09:18:56 +00:00
|
|
|
for (SCSIZE i=0; i<nCount; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
pDocPool->Remove(*pData[i].pPattern);
|
|
|
|
|
|
|
|
delete[] pData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2011-03-10 21:12:56 +01:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2000-09-18 23:16:46 +00:00
|
|
|
void ScAttrArray::TestData() const
|
|
|
|
{
|
2009-08-25 13:53:16 +00:00
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nErr = 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (pData)
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nPos;
|
2004-03-12 11:18:38 +00:00
|
|
|
for (nPos=0; nPos<nCount; nPos++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
if (nPos > 0)
|
2000-09-18 23:16:46 +00:00
|
|
|
if (pData[nPos].pPattern == pData[nPos-1].pPattern || pData[nPos].nRow <= pData[nPos-1].nRow)
|
|
|
|
++nErr;
|
|
|
|
if (pData[nPos].pPattern->Which() != ATTR_PATTERN)
|
|
|
|
++nErr;
|
|
|
|
}
|
2001-11-05 11:16:00 +00:00
|
|
|
if ( nPos && pData[nPos-1].nRow != MAXROW )
|
|
|
|
++nErr;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
if (nErr)
|
|
|
|
{
|
2011-07-21 09:26:30 +01:00
|
|
|
rtl::OStringBuffer aMsg;
|
|
|
|
aMsg.append(static_cast<sal_Int32>(nErr));
|
|
|
|
aMsg.append(RTL_CONSTASCII_STRINGPARAM(
|
|
|
|
" errors in attribute array, column "));
|
|
|
|
aMsg.append(static_cast<sal_Int32>(nCol));
|
|
|
|
OSL_FAIL(aMsg.getStr());
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-25 13:53:16 +00:00
|
|
|
#endif
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
void ScAttrArray::Reset( const ScPatternAttr* pPattern, bool bAlloc )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (pData)
|
|
|
|
{
|
|
|
|
ScDocumentPool* pDocPool = pDocument->GetPool();
|
|
|
|
const ScPatternAttr* pOldPattern;
|
|
|
|
ScAddress aAdrStart( nCol, 0, nTab );
|
|
|
|
ScAddress aAdrEnd ( nCol, 0, nTab );
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
for (SCSIZE i=0; i<nCount; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// ensure that attributing changes text width of cell
|
2000-09-18 23:16:46 +00:00
|
|
|
pOldPattern = pData[i].pPattern;
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bNumFormatChanged;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
|
|
|
|
pPattern->GetItemSet(), pOldPattern->GetItemSet() ) )
|
|
|
|
{
|
|
|
|
aAdrStart.SetRow( i ? pData[i-1].nRow+1 : 0 );
|
|
|
|
aAdrEnd .SetRow( pData[i].nRow );
|
|
|
|
pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
|
|
|
|
}
|
|
|
|
pDocPool->Remove(*pOldPattern);
|
|
|
|
}
|
|
|
|
delete[] pData;
|
|
|
|
|
2009-09-07 15:38:19 +00:00
|
|
|
if (pDocument->IsStreamValid(nTab))
|
2011-03-10 16:55:21 -05:00
|
|
|
pDocument->SetStreamValid(nTab, false);
|
2009-09-07 15:38:19 +00:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
if (bAlloc)
|
|
|
|
{
|
2001-11-05 11:16:00 +00:00
|
|
|
nCount = nLimit = 1;
|
2000-09-18 23:16:46 +00:00
|
|
|
pData = new ScAttrEntry[1];
|
|
|
|
if (pData)
|
|
|
|
{
|
|
|
|
ScPatternAttr* pNewPattern = (ScPatternAttr*) &pDocPool->Put(*pPattern);
|
|
|
|
pData[0].nRow = MAXROW;
|
|
|
|
pData[0].pPattern = pNewPattern;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-05 11:16:00 +00:00
|
|
|
nCount = nLimit = 0;
|
2010-10-22 09:28:50 +01:00
|
|
|
pData = NULL; // should be immediately occupied again
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::Concat(SCSIZE nPos)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bRet = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (pData && (nPos < nCount))
|
|
|
|
{
|
|
|
|
if (nPos > 0)
|
|
|
|
{
|
|
|
|
if (pData[nPos - 1].pPattern == pData[nPos].pPattern)
|
|
|
|
{
|
|
|
|
pData[nPos - 1].nRow = pData[nPos].nRow;
|
|
|
|
pDocument->GetPool()->Remove(*pData[nPos].pPattern);
|
|
|
|
memmove(&pData[nPos], &pData[nPos + 1], (nCount - nPos - 1) * sizeof(ScAttrEntry));
|
|
|
|
pData[nCount - 1].pPattern = NULL;
|
|
|
|
pData[nCount - 1].nRow = 0;
|
|
|
|
nCount--;
|
|
|
|
nPos--;
|
2011-11-10 15:21:48 +01:00
|
|
|
bRet = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nPos + 1 < nCount)
|
|
|
|
{
|
|
|
|
if (pData[nPos + 1].pPattern == pData[nPos].pPattern)
|
|
|
|
{
|
|
|
|
pData[nPos].nRow = pData[nPos + 1].nRow;
|
|
|
|
pDocument->GetPool()->Remove(*pData[nPos].pPattern);
|
|
|
|
memmove(&pData[nPos + 1], &pData[nPos + 2], (nCount - nPos - 2) * sizeof(ScAttrEntry));
|
|
|
|
pData[nCount - 1].pPattern = NULL;
|
|
|
|
pData[nCount - 1].nRow = 0;
|
|
|
|
nCount--;
|
2011-11-10 15:21:48 +01:00
|
|
|
bRet = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::Search( SCROW nRow, SCSIZE& nIndex ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
long nHi = static_cast<long>(nCount) - 1;
|
|
|
|
long i = 0;
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bFound = (nCount == 1);
|
2000-09-18 23:16:46 +00:00
|
|
|
if (pData)
|
|
|
|
{
|
2011-01-09 21:11:58 +00:00
|
|
|
long nLo = 0;
|
|
|
|
long nStartRow = 0;
|
|
|
|
long nEndRow = 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
while ( !bFound && nLo <= nHi )
|
|
|
|
{
|
|
|
|
i = (nLo + nHi) / 2;
|
|
|
|
if (i > 0)
|
2004-06-04 09:18:56 +00:00
|
|
|
nStartRow = (long) pData[i - 1].nRow;
|
2000-09-18 23:16:46 +00:00
|
|
|
else
|
|
|
|
nStartRow = -1;
|
2004-06-04 09:18:56 +00:00
|
|
|
nEndRow = (long) pData[i].nRow;
|
|
|
|
if (nEndRow < (long) nRow)
|
2000-09-18 23:16:46 +00:00
|
|
|
nLo = ++i;
|
|
|
|
else
|
2004-06-04 09:18:56 +00:00
|
|
|
if (nStartRow >= (long) nRow)
|
2000-09-18 23:16:46 +00:00
|
|
|
nHi = --i;
|
|
|
|
else
|
2011-11-10 15:21:48 +01:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-03-10 16:55:21 -05:00
|
|
|
bFound = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if (bFound)
|
2004-06-04 09:18:56 +00:00
|
|
|
nIndex=(SCSIZE)i;
|
2000-09-18 23:16:46 +00:00
|
|
|
else
|
|
|
|
nIndex=0;
|
|
|
|
return bFound;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
const ScPatternAttr* ScAttrArray::GetPattern( SCROW nRow ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE i;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (Search( nRow, i ))
|
|
|
|
return pData[i].pPattern;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
const ScPatternAttr* ScAttrArray::GetPatternRange( SCROW& rStartRow,
|
|
|
|
SCROW& rEndRow, SCROW nRow ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( Search( nRow, nIndex ) )
|
|
|
|
{
|
|
|
|
if ( nIndex > 0 )
|
|
|
|
rStartRow = pData[nIndex-1].nRow + 1;
|
|
|
|
else
|
|
|
|
rStartRow = 0;
|
|
|
|
rEndRow = pData[nIndex].nRow;
|
|
|
|
return pData[nIndex].pPattern;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
void ScAttrArray::SetPattern( SCROW nRow, const ScPatternAttr* pPattern, bool bPutToPool )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
SetPatternArea( nRow, nRow, pPattern, bPutToPool );
|
|
|
|
}
|
|
|
|
|
2010-09-15 12:28:47 +02:00
|
|
|
void ScAttrArray::RemoveCellCharAttribs( SCROW nStartRow, SCROW nEndRow,
|
|
|
|
const ScPatternAttr* pPattern, ScEditDataArray* pDataArray )
|
|
|
|
{
|
|
|
|
for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
|
|
|
|
{
|
|
|
|
ScBaseCell* pCell;
|
|
|
|
pDocument->GetCell(nCol, nRow, nTab, pCell);
|
|
|
|
if (pCell && pCell->GetCellType() == CELLTYPE_EDIT)
|
|
|
|
{
|
|
|
|
EditTextObject* pOldData = NULL;
|
|
|
|
ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell);
|
|
|
|
if (pDataArray)
|
|
|
|
pOldData = pEditCell->GetData()->Clone();
|
|
|
|
pEditCell->RemoveCharAttribs(*pPattern);
|
|
|
|
if (pDataArray)
|
|
|
|
{
|
|
|
|
EditTextObject* pNewData = pEditCell->GetData()->Clone();
|
|
|
|
pDataArray->AddItem(nTab, nCol, nRow, pOldData, pNewData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-09-15 12:28:47 +02:00
|
|
|
void ScAttrArray::SetPatternArea(SCROW nStartRow, SCROW nEndRow, const ScPatternAttr *pPattern,
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bPutToPool, ScEditDataArray* pDataArray )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
if (ValidRow(nStartRow) && ValidRow(nEndRow))
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (bPutToPool)
|
|
|
|
pPattern = (const ScPatternAttr*) &pDocument->GetPool()->Put(*pPattern);
|
|
|
|
|
|
|
|
if ((nStartRow == 0) && (nEndRow == MAXROW))
|
|
|
|
Reset(pPattern);
|
|
|
|
else
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nNeeded = nCount + 2;
|
2001-11-05 11:16:00 +00:00
|
|
|
if ( nLimit < nNeeded )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-11-05 11:16:00 +00:00
|
|
|
nLimit += SC_ATTRARRAY_DELTA;
|
|
|
|
if ( nLimit < nNeeded )
|
|
|
|
nLimit = nNeeded;
|
|
|
|
ScAttrEntry* pNewData = new ScAttrEntry[nLimit];
|
|
|
|
memcpy( pNewData, pData, nCount*sizeof(ScAttrEntry) );
|
|
|
|
delete[] pData;
|
|
|
|
pData = pNewData;
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-11-05 11:16:00 +00:00
|
|
|
ScAddress aAdrStart( nCol, 0, nTab );
|
|
|
|
ScAddress aAdrEnd ( nCol, 0, nTab );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE ni = 0; // number of entries in beginning
|
|
|
|
SCSIZE nx = 0; // track position
|
|
|
|
SCROW ns = 0; // start row of track position
|
2001-11-05 11:16:00 +00:00
|
|
|
if ( nStartRow > 0 )
|
|
|
|
{
|
|
|
|
// skip beginning
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex;
|
2001-11-05 11:16:00 +00:00
|
|
|
Search( nStartRow, nIndex );
|
|
|
|
ni = nIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
if ( ni > 0 )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-11-05 11:16:00 +00:00
|
|
|
nx = ni;
|
|
|
|
ns = pData[ni-1].nRow+1;
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// ensure that attributing changes text width of cell
|
|
|
|
// otherwise, conditional formats need to be reset or deleted
|
2001-11-05 11:16:00 +00:00
|
|
|
while ( ns <= nEndRow )
|
|
|
|
{
|
|
|
|
const SfxItemSet& rNewSet = pPattern->GetItemSet();
|
|
|
|
const SfxItemSet& rOldSet = pData[nx].pPattern->GetItemSet();
|
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bNumFormatChanged;
|
2001-11-05 11:16:00 +00:00
|
|
|
if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
|
|
|
|
rNewSet, rOldSet ) )
|
|
|
|
{
|
|
|
|
aAdrStart.SetRow( Max(nStartRow,ns) );
|
|
|
|
aAdrEnd .SetRow( Min(nEndRow,pData[nx].nRow) );
|
|
|
|
pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2001-11-05 11:16:00 +00:00
|
|
|
ns = pData[nx].nRow + 1;
|
|
|
|
nx++;
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-11-05 11:16:00 +00:00
|
|
|
// continue modifying data array
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nInsert; // insert position (MAXROWCOUNT := no insert)
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bCombined = false;
|
|
|
|
bool bSplit = false;
|
2001-11-05 11:16:00 +00:00
|
|
|
if ( nStartRow > 0 )
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
nInsert = MAXROWCOUNT;
|
2001-11-05 11:16:00 +00:00
|
|
|
if ( pData[ni].pPattern != pPattern )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-11-05 11:16:00 +00:00
|
|
|
if ( ni == 0 || (pData[ni-1].nRow < nStartRow - 1) )
|
|
|
|
{ // may be a split or a simple insert or just a shrink,
|
|
|
|
// row adjustment is done further down
|
2001-11-05 18:06:24 +00:00
|
|
|
if ( pData[ni].nRow > nEndRow )
|
2011-11-10 15:21:48 +01:00
|
|
|
bSplit = true;
|
2001-11-05 11:16:00 +00:00
|
|
|
ni++;
|
|
|
|
nInsert = ni;
|
|
|
|
}
|
|
|
|
else if ( ni > 0 && pData[ni-1].nRow == nStartRow - 1 )
|
|
|
|
nInsert = ni;
|
|
|
|
}
|
|
|
|
if ( ni > 0 && pData[ni-1].pPattern == pPattern )
|
|
|
|
{ // combine
|
|
|
|
pData[ni-1].nRow = nEndRow;
|
2004-06-04 09:18:56 +00:00
|
|
|
nInsert = MAXROWCOUNT;
|
2011-11-10 15:21:48 +01:00
|
|
|
bCombined = true;
|
2001-11-05 11:16:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nInsert = 0;
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nj = ni; // stop position of range to replace
|
2001-11-05 11:16:00 +00:00
|
|
|
while ( nj < nCount && pData[nj].nRow <= nEndRow )
|
|
|
|
nj++;
|
2002-01-18 11:00:38 +00:00
|
|
|
if ( !bSplit )
|
|
|
|
{
|
|
|
|
if ( nj < nCount && pData[nj].pPattern == pPattern )
|
|
|
|
{ // combine
|
|
|
|
if ( ni > 0 )
|
|
|
|
{
|
|
|
|
if ( pData[ni-1].pPattern == pPattern )
|
|
|
|
{ // adjacent entries
|
|
|
|
pData[ni-1].nRow = pData[nj].nRow;
|
|
|
|
nj++;
|
|
|
|
}
|
2002-01-18 15:58:59 +00:00
|
|
|
else if ( ni == nInsert )
|
2002-01-18 11:00:38 +00:00
|
|
|
pData[ni-1].nRow = nStartRow - 1; // shrink
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2004-06-04 09:18:56 +00:00
|
|
|
nInsert = MAXROWCOUNT;
|
2011-11-10 15:21:48 +01:00
|
|
|
bCombined = true;
|
2001-11-05 11:16:00 +00:00
|
|
|
}
|
2002-01-18 11:00:38 +00:00
|
|
|
else if ( ni > 0 && ni == nInsert )
|
|
|
|
pData[ni-1].nRow = nStartRow - 1; // shrink
|
2001-11-05 11:16:00 +00:00
|
|
|
}
|
|
|
|
ScDocumentPool* pDocPool = pDocument->GetPool();
|
|
|
|
if ( bSplit )
|
|
|
|
{ // duplicate splitted entry in pool
|
|
|
|
pDocPool->Put( *pData[ni-1].pPattern );
|
|
|
|
}
|
|
|
|
if ( ni < nj )
|
|
|
|
{ // remove middle entries
|
2004-06-04 09:18:56 +00:00
|
|
|
for ( SCSIZE nk=ni; nk<nj; nk++)
|
2001-11-05 11:16:00 +00:00
|
|
|
{ // remove entries from pool
|
|
|
|
pDocPool->Remove( *pData[nk].pPattern );
|
|
|
|
}
|
|
|
|
if ( !bCombined )
|
|
|
|
{ // replace one entry
|
|
|
|
pData[ni].nRow = nEndRow;
|
|
|
|
pData[ni].pPattern = pPattern;
|
|
|
|
ni++;
|
2004-06-04 09:18:56 +00:00
|
|
|
nInsert = MAXROWCOUNT;
|
2001-11-05 11:16:00 +00:00
|
|
|
}
|
|
|
|
if ( ni < nj )
|
|
|
|
{ // remove entries
|
|
|
|
memmove( pData + ni, pData + nj, (nCount - nj) * sizeof(ScAttrEntry) );
|
|
|
|
nCount -= nj - ni;
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2007-02-27 10:59:23 +00:00
|
|
|
if ( nInsert < sal::static_int_cast<SCSIZE>(MAXROWCOUNT) )
|
2001-11-05 11:16:00 +00:00
|
|
|
{ // insert or append new entry
|
|
|
|
if ( nInsert <= nCount )
|
|
|
|
{
|
|
|
|
if ( !bSplit )
|
|
|
|
memmove( pData + nInsert + 1, pData + nInsert,
|
|
|
|
(nCount - nInsert) * sizeof(ScAttrEntry) );
|
|
|
|
else
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-11-05 11:16:00 +00:00
|
|
|
memmove( pData + nInsert + 2, pData + nInsert,
|
|
|
|
(nCount - nInsert) * sizeof(ScAttrEntry) );
|
|
|
|
pData[nInsert+1] = pData[nInsert-1];
|
|
|
|
nCount++;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2001-11-05 11:16:00 +00:00
|
|
|
}
|
|
|
|
if ( nInsert )
|
|
|
|
pData[nInsert-1].nRow = nStartRow - 1;
|
|
|
|
pData[nInsert].nRow = nEndRow;
|
|
|
|
pData[nInsert].pPattern = pPattern;
|
2010-09-15 12:28:47 +02:00
|
|
|
|
|
|
|
// Remove character attributes from these cells if the pattern
|
|
|
|
// is applied during normal session.
|
|
|
|
if (pDataArray)
|
|
|
|
RemoveCellCharAttribs(nStartRow, nEndRow, pPattern, pDataArray);
|
|
|
|
|
2001-11-05 11:16:00 +00:00
|
|
|
nCount++;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2009-09-07 15:38:19 +00:00
|
|
|
|
|
|
|
if (pDocument->IsStreamValid(nTab))
|
2011-03-10 16:55:21 -05:00
|
|
|
pDocument->SetStreamValid(nTab, false);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-10 21:12:56 +01:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2000-09-18 23:16:46 +00:00
|
|
|
TestData();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
void ScAttrArray::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, ScStyleSheet* pStyle )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
if (ValidRow(nStartRow) && ValidRow(nEndRow))
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nPos;
|
|
|
|
SCROW nStart=0;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (!Search( nStartRow, nPos ))
|
|
|
|
{
|
2011-03-01 19:05:02 +01:00
|
|
|
OSL_FAIL("Search Failure");
|
2000-09-18 23:16:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScAddress aAdrStart( nCol, 0, nTab );
|
|
|
|
ScAddress aAdrEnd ( nCol, 0, nTab );
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
const ScPatternAttr* pOldPattern = pData[nPos].pPattern;
|
|
|
|
ScPatternAttr* pNewPattern = new ScPatternAttr(*pOldPattern);
|
|
|
|
pNewPattern->SetStyleSheet(pStyle);
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nY1 = nStart;
|
|
|
|
SCROW nY2 = pData[nPos].nRow;
|
2000-09-18 23:16:46 +00:00
|
|
|
nStart = pData[nPos].nRow + 1;
|
|
|
|
|
2001-07-02 18:36:20 +00:00
|
|
|
if ( *pNewPattern == *pOldPattern )
|
|
|
|
{
|
|
|
|
// keep the original pattern (might be default)
|
|
|
|
// pNewPattern is deleted below
|
|
|
|
nPos++;
|
|
|
|
}
|
|
|
|
else if ( nY1 < nStartRow || nY2 > nEndRow )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (nY1 < nStartRow) nY1=nStartRow;
|
|
|
|
if (nY2 > nEndRow) nY2=nEndRow;
|
2011-11-10 15:21:48 +01:00
|
|
|
SetPatternArea( nY1, nY2, pNewPattern, true );
|
2000-09-18 23:16:46 +00:00
|
|
|
Search( nStart, nPos );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// ensure attributing changes text width of cell; otherwise
|
|
|
|
// there aren't (yet) template format changes
|
2000-09-18 23:16:46 +00:00
|
|
|
const SfxItemSet& rNewSet = pNewPattern->GetItemSet();
|
|
|
|
const SfxItemSet& rOldSet = pOldPattern->GetItemSet();
|
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bNumFormatChanged;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
|
|
|
|
rNewSet, rOldSet ) )
|
|
|
|
{
|
|
|
|
aAdrStart.SetRow( nPos ? pData[nPos-1].nRow+1 : 0 );
|
|
|
|
aAdrEnd .SetRow( pData[nPos].nRow );
|
|
|
|
pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
|
|
|
|
}
|
|
|
|
|
|
|
|
pDocument->GetPool()->Remove(*pData[nPos].pPattern);
|
|
|
|
pData[nPos].pPattern = (const ScPatternAttr*)
|
|
|
|
&pDocument->GetPool()->Put(*pNewPattern);
|
|
|
|
if (Concat(nPos))
|
|
|
|
Search(nStart, nPos);
|
|
|
|
else
|
|
|
|
nPos++;
|
|
|
|
}
|
|
|
|
delete pNewPattern;
|
|
|
|
}
|
2004-06-04 09:18:56 +00:00
|
|
|
while ((nStart <= nEndRow) && (nPos < nCount));
|
2009-09-07 15:38:19 +00:00
|
|
|
|
|
|
|
if (pDocument->IsStreamValid(nTab))
|
2011-03-10 16:55:21 -05:00
|
|
|
pDocument->SetStreamValid(nTab, false);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-03-10 21:12:56 +01:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2000-09-18 23:16:46 +00:00
|
|
|
TestData();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// const cast, otherwise it will be too inefficient/complicated
|
|
|
|
#define SET_LINECOLOR(dest,c) \
|
|
|
|
if ((dest)) \
|
|
|
|
{ \
|
|
|
|
((SvxBorderLine*)(dest))->SetColor((c)); \
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
#define SET_LINE(dest,src) \
|
|
|
|
if ((dest)) \
|
|
|
|
{ \
|
|
|
|
SvxBorderLine* pCast = (SvxBorderLine*)(dest); \
|
2012-07-03 21:26:13 +02:00
|
|
|
pCast->SetBorderLineStyle( (src)->GetBorderLineStyle() ); \
|
2010-12-24 10:00:15 +01:00
|
|
|
pCast->SetWidth( (src)->GetWidth( ) ); \
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
|
2011-11-10 15:21:48 +01:00
|
|
|
const SvxBorderLine* pLine, bool bColorOnly )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if ( bColorOnly && !pLine )
|
|
|
|
return;
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
if (ValidRow(nStartRow) && ValidRow(nEndRow))
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nPos;
|
|
|
|
SCROW nStart=0;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (!Search( nStartRow, nPos ))
|
|
|
|
{
|
2011-03-01 19:05:02 +01:00
|
|
|
OSL_FAIL("Search failure");
|
2000-09-18 23:16:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
const ScPatternAttr* pOldPattern = pData[nPos].pPattern;
|
2004-09-20 12:44:37 +00:00
|
|
|
const SfxItemSet& rOldSet = pOldPattern->GetItemSet();
|
|
|
|
const SfxPoolItem* pBoxItem = 0;
|
2011-11-10 15:21:48 +01:00
|
|
|
SfxItemState eState = rOldSet.GetItemState( ATTR_BORDER, true, &pBoxItem );
|
2004-09-20 12:44:37 +00:00
|
|
|
const SfxPoolItem* pTLBRItem = 0;
|
2011-11-10 15:21:48 +01:00
|
|
|
SfxItemState eTLBRState = rOldSet.GetItemState( ATTR_BORDER_TLBR, true, &pTLBRItem );
|
2004-09-20 12:44:37 +00:00
|
|
|
const SfxPoolItem* pBLTRItem = 0;
|
2011-11-10 15:21:48 +01:00
|
|
|
SfxItemState eBLTRState = rOldSet.GetItemState( ATTR_BORDER_BLTR, true, &pBLTRItem );
|
2004-09-20 12:44:37 +00:00
|
|
|
|
|
|
|
if ( (SFX_ITEM_SET == eState) || (SFX_ITEM_SET == eTLBRState) || (SFX_ITEM_SET == eBLTRState) )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
ScPatternAttr* pNewPattern = new ScPatternAttr(*pOldPattern);
|
2004-09-20 12:44:37 +00:00
|
|
|
SfxItemSet& rNewSet = pNewPattern->GetItemSet();
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nY1 = nStart;
|
|
|
|
SCROW nY2 = pData[nPos].nRow;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-09-20 12:44:37 +00:00
|
|
|
SvxBoxItem* pNewBoxItem = pBoxItem ? (SvxBoxItem*)pBoxItem->Clone() : 0;
|
|
|
|
SvxLineItem* pNewTLBRItem = pTLBRItem ? (SvxLineItem*)pTLBRItem->Clone() : 0;
|
|
|
|
SvxLineItem* pNewBLTRItem = pBLTRItem ? (SvxLineItem*)pBLTRItem->Clone() : 0;
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// fetch line and update attributes with parameters
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if ( !pLine )
|
|
|
|
{
|
2004-09-20 12:44:37 +00:00
|
|
|
if( pNewBoxItem )
|
|
|
|
{
|
|
|
|
if ( pNewBoxItem->GetTop() ) pNewBoxItem->SetLine( NULL, BOX_LINE_TOP );
|
|
|
|
if ( pNewBoxItem->GetBottom() ) pNewBoxItem->SetLine( NULL, BOX_LINE_BOTTOM );
|
|
|
|
if ( pNewBoxItem->GetLeft() ) pNewBoxItem->SetLine( NULL, BOX_LINE_LEFT );
|
|
|
|
if ( pNewBoxItem->GetRight() ) pNewBoxItem->SetLine( NULL, BOX_LINE_RIGHT );
|
|
|
|
}
|
|
|
|
if( pNewTLBRItem && pNewTLBRItem->GetLine() )
|
|
|
|
pNewTLBRItem->SetLine( 0 );
|
|
|
|
if( pNewBLTRItem && pNewBLTRItem->GetLine() )
|
|
|
|
pNewBLTRItem->SetLine( 0 );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( bColorOnly )
|
|
|
|
{
|
|
|
|
Color aColor( pLine->GetColor() );
|
2004-09-20 12:44:37 +00:00
|
|
|
if( pNewBoxItem )
|
|
|
|
{
|
|
|
|
SET_LINECOLOR( pNewBoxItem->GetTop(), aColor );
|
|
|
|
SET_LINECOLOR( pNewBoxItem->GetBottom(), aColor );
|
|
|
|
SET_LINECOLOR( pNewBoxItem->GetLeft(), aColor );
|
|
|
|
SET_LINECOLOR( pNewBoxItem->GetRight(), aColor );
|
|
|
|
}
|
|
|
|
if( pNewTLBRItem )
|
|
|
|
SET_LINECOLOR( pNewTLBRItem->GetLine(), aColor );
|
|
|
|
if( pNewBLTRItem )
|
|
|
|
SET_LINECOLOR( pNewBLTRItem->GetLine(), aColor );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-09-20 12:44:37 +00:00
|
|
|
if( pNewBoxItem )
|
|
|
|
{
|
|
|
|
SET_LINE( pNewBoxItem->GetTop(), pLine );
|
|
|
|
SET_LINE( pNewBoxItem->GetBottom(), pLine );
|
|
|
|
SET_LINE( pNewBoxItem->GetLeft(), pLine );
|
|
|
|
SET_LINE( pNewBoxItem->GetRight(), pLine );
|
|
|
|
}
|
|
|
|
if( pNewTLBRItem )
|
|
|
|
SET_LINE( pNewTLBRItem->GetLine(), pLine );
|
|
|
|
if( pNewBLTRItem )
|
|
|
|
SET_LINE( pNewBLTRItem->GetLine(), pLine );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-20 12:44:37 +00:00
|
|
|
if( pNewBoxItem ) rNewSet.Put( *pNewBoxItem );
|
|
|
|
if( pNewTLBRItem ) rNewSet.Put( *pNewTLBRItem );
|
|
|
|
if( pNewBLTRItem ) rNewSet.Put( *pNewBLTRItem );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
nStart = pData[nPos].nRow + 1;
|
|
|
|
|
|
|
|
if ( nY1 < nStartRow || nY2 > nEndRow )
|
|
|
|
{
|
|
|
|
if (nY1 < nStartRow) nY1=nStartRow;
|
|
|
|
if (nY2 > nEndRow) nY2=nEndRow;
|
2011-11-10 15:21:48 +01:00
|
|
|
SetPatternArea( nY1, nY2, pNewPattern, true );
|
2000-09-18 23:16:46 +00:00
|
|
|
Search( nStart, nPos );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// remove from pool ?
|
2000-09-18 23:16:46 +00:00
|
|
|
pDocument->GetPool()->Remove(*pData[nPos].pPattern);
|
|
|
|
pData[nPos].pPattern = (const ScPatternAttr*)
|
|
|
|
&pDocument->GetPool()->Put(*pNewPattern);
|
|
|
|
|
|
|
|
if (Concat(nPos))
|
|
|
|
Search(nStart, nPos);
|
|
|
|
else
|
|
|
|
nPos++;
|
|
|
|
}
|
2004-09-20 12:44:37 +00:00
|
|
|
delete pNewBoxItem;
|
|
|
|
delete pNewTLBRItem;
|
|
|
|
delete pNewBLTRItem;
|
2000-09-18 23:16:46 +00:00
|
|
|
delete pNewPattern;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nStart = pData[nPos].nRow + 1;
|
|
|
|
nPos++;
|
|
|
|
}
|
|
|
|
}
|
2004-06-04 09:18:56 +00:00
|
|
|
while ((nStart <= nEndRow) && (nPos < nCount));
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef SET_LINECOLOR
|
|
|
|
#undef SET_LINE
|
|
|
|
|
|
|
|
|
2010-09-15 12:28:47 +02:00
|
|
|
void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache, ScEditDataArray* pDataArray )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-03-10 21:12:56 +01:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2000-09-18 23:16:46 +00:00
|
|
|
TestData();
|
|
|
|
#endif
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
if (ValidRow(nStartRow) && ValidRow(nEndRow))
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nPos;
|
|
|
|
SCROW nStart=0;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (!Search( nStartRow, nPos ))
|
|
|
|
{
|
2011-03-01 19:05:02 +01:00
|
|
|
OSL_FAIL("Search Failure");
|
2000-09-18 23:16:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScAddress aAdrStart( nCol, 0, nTab );
|
|
|
|
ScAddress aAdrEnd ( nCol, 0, nTab );
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
const ScPatternAttr* pOldPattern = pData[nPos].pPattern;
|
2011-11-10 15:21:48 +01:00
|
|
|
const ScPatternAttr* pNewPattern = (const ScPatternAttr*) &pCache->ApplyTo( *pOldPattern, true );
|
2000-09-18 23:16:46 +00:00
|
|
|
ScDocumentPool::CheckRef( *pOldPattern );
|
|
|
|
ScDocumentPool::CheckRef( *pNewPattern );
|
|
|
|
if (pNewPattern != pOldPattern)
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nY1 = nStart;
|
|
|
|
SCROW nY2 = pData[nPos].nRow;
|
2000-09-18 23:16:46 +00:00
|
|
|
nStart = pData[nPos].nRow + 1;
|
|
|
|
|
|
|
|
if ( nY1 < nStartRow || nY2 > nEndRow )
|
|
|
|
{
|
|
|
|
if (nY1 < nStartRow) nY1=nStartRow;
|
|
|
|
if (nY2 > nEndRow) nY2=nEndRow;
|
2010-09-15 12:28:47 +02:00
|
|
|
SetPatternArea( nY1, nY2, pNewPattern, false, pDataArray );
|
2000-09-18 23:16:46 +00:00
|
|
|
Search( nStart, nPos );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// ensure attributing changes text-width of cell
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
const SfxItemSet& rNewSet = pNewPattern->GetItemSet();
|
|
|
|
const SfxItemSet& rOldSet = pOldPattern->GetItemSet();
|
|
|
|
|
2011-11-05 07:00:32 +01:00
|
|
|
bool bNumFormatChanged;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged,
|
|
|
|
rNewSet, rOldSet ) )
|
|
|
|
{
|
|
|
|
aAdrStart.SetRow( nPos ? pData[nPos-1].nRow+1 : 0 );
|
|
|
|
aAdrEnd .SetRow( pData[nPos].nRow );
|
|
|
|
pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
|
|
|
|
}
|
|
|
|
|
|
|
|
pDocument->GetPool()->Remove(*pData[nPos].pPattern);
|
|
|
|
pData[nPos].pPattern = pNewPattern;
|
|
|
|
if (Concat(nPos))
|
|
|
|
Search(nStart, nPos);
|
|
|
|
else
|
|
|
|
++nPos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nStart = pData[nPos].nRow + 1;
|
|
|
|
++nPos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (nStart <= nEndRow);
|
2009-09-07 15:38:19 +00:00
|
|
|
|
|
|
|
if (pDocument->IsStreamValid(nTab))
|
2011-03-10 16:55:21 -05:00
|
|
|
pDocument->SetStreamValid(nTab, false);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-03-10 21:12:56 +01:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2000-09-18 23:16:46 +00:00
|
|
|
TestData();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-10-04 14:12:42 -04:00
|
|
|
bool ScAttrArray::SetAttrEntries(ScAttrEntry* pNewData, SCSIZE nSize)
|
|
|
|
{
|
|
|
|
if (pData)
|
|
|
|
{
|
|
|
|
ScDocumentPool* pDocPool = pDocument->GetPool();
|
|
|
|
for (SCSIZE i=0; i<nCount; i++)
|
|
|
|
pDocPool->Remove(*pData[i].pPattern);
|
|
|
|
|
|
|
|
delete[] pData;
|
|
|
|
}
|
|
|
|
|
|
|
|
pData = pNewData;
|
|
|
|
nCount = nLimit = nSize;
|
|
|
|
return true;
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
void lcl_MergeDeep( SfxItemSet& rMergeSet, const SfxItemSet& rSource )
|
|
|
|
{
|
|
|
|
const SfxPoolItem* pNewItem;
|
|
|
|
const SfxPoolItem* pOldItem;
|
2011-01-17 13:20:22 +01:00
|
|
|
for (sal_uInt16 nId=ATTR_PATTERN_START; nId<=ATTR_PATTERN_END; nId++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// pMergeSet has no parent
|
2011-03-10 16:55:21 -05:00
|
|
|
SfxItemState eOldState = rMergeSet.GetItemState( nId, false, &pOldItem );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
if ( eOldState == SFX_ITEM_DEFAULT )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-10 15:21:48 +01:00
|
|
|
SfxItemState eNewState = rSource.GetItemState( nId, true, &pNewItem );
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( eNewState == SFX_ITEM_SET )
|
|
|
|
{
|
|
|
|
if ( *pNewItem != rMergeSet.GetPool()->GetDefaultItem(nId) )
|
|
|
|
rMergeSet.InvalidateItem( nId );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( eOldState == SFX_ITEM_SET ) // Item gesetzt
|
|
|
|
{
|
2011-11-10 15:21:48 +01:00
|
|
|
SfxItemState eNewState = rSource.GetItemState( nId, true, &pNewItem );
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( eNewState == SFX_ITEM_SET )
|
|
|
|
{
|
|
|
|
if ( pNewItem != pOldItem ) // beide gepuhlt
|
|
|
|
rMergeSet.InvalidateItem( nId );
|
|
|
|
}
|
|
|
|
else // Default
|
|
|
|
{
|
|
|
|
if ( *pOldItem != rSource.GetPool()->GetDefaultItem(nId) )
|
|
|
|
rMergeSet.InvalidateItem( nId );
|
|
|
|
}
|
|
|
|
}
|
2010-10-22 09:28:50 +01:00
|
|
|
// Dontcare remains Dontcare
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
void ScAttrArray::MergePatternArea( SCROW nStartRow, SCROW nEndRow,
|
2011-11-10 15:21:48 +01:00
|
|
|
ScMergePatternState& rState, bool bDeep ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
if (ValidRow(nStartRow) && ValidRow(nEndRow))
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nPos;
|
|
|
|
SCROW nStart=0;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (!Search( nStartRow, nPos ))
|
|
|
|
{
|
2011-03-01 19:05:02 +01:00
|
|
|
OSL_FAIL("Search failure");
|
2000-09-18 23:16:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// similar patterns must not be repeated
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
const ScPatternAttr* pPattern = pData[nPos].pPattern;
|
2005-03-29 12:29:55 +00:00
|
|
|
if ( pPattern != rState.pOld1 && pPattern != rState.pOld2 )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
const SfxItemSet& rThisSet = pPattern->GetItemSet();
|
2005-03-29 12:29:55 +00:00
|
|
|
if (rState.pItemSet)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (bDeep)
|
2005-03-29 12:29:55 +00:00
|
|
|
lcl_MergeDeep( *rState.pItemSet, rThisSet );
|
2000-09-18 23:16:46 +00:00
|
|
|
else
|
2011-03-10 16:55:21 -05:00
|
|
|
rState.pItemSet->MergeValues( rThisSet, false );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// first pattern - copied from parent
|
2005-03-29 12:29:55 +00:00
|
|
|
rState.pItemSet = new SfxItemSet( *rThisSet.GetPool(), rThisSet.GetRanges() );
|
|
|
|
rState.pItemSet->Set( rThisSet, bDeep );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2005-03-29 12:29:55 +00:00
|
|
|
rState.pOld2 = rState.pOld1;
|
|
|
|
rState.pOld1 = pPattern;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nStart = pData[nPos].nRow + 1;
|
|
|
|
++nPos;
|
|
|
|
}
|
|
|
|
while (nStart <= nEndRow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// assemble border
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool lcl_TestAttr( const SvxBorderLine* pOldLine, const SvxBorderLine* pNewLine,
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt8& rModified, const SvxBorderLine*& rpNew )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (rModified == SC_LINE_DONTCARE)
|
2011-03-10 16:55:21 -05:00
|
|
|
return false; // don't go again
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if (rModified == SC_LINE_EMPTY)
|
|
|
|
{
|
|
|
|
rModified = SC_LINE_SET;
|
|
|
|
rpNew = pNewLine;
|
2011-03-10 16:55:21 -05:00
|
|
|
return true; // initial value
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pOldLine == pNewLine)
|
|
|
|
{
|
|
|
|
rpNew = pOldLine;
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pOldLine && pNewLine)
|
|
|
|
if (*pOldLine == *pNewLine)
|
|
|
|
{
|
|
|
|
rpNew = pOldLine;
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rModified = SC_LINE_DONTCARE;
|
|
|
|
rpNew = NULL;
|
2011-03-10 16:55:21 -05:00
|
|
|
return true; // another line -> don't care
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void lcl_MergeToFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
|
|
|
|
ScLineFlags& rFlags, const ScPatternAttr* pPattern,
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bLeft, SCCOL nDistRight, bool bTop, SCROW nDistBottom )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// right/bottom border set when connected together
|
2000-09-18 23:16:46 +00:00
|
|
|
const ScMergeAttr& rMerge = (const ScMergeAttr&)pPattern->GetItem(ATTR_MERGE);
|
|
|
|
if ( rMerge.GetColMerge() == nDistRight + 1 )
|
|
|
|
nDistRight = 0;
|
|
|
|
if ( rMerge.GetRowMerge() == nDistBottom + 1 )
|
|
|
|
nDistBottom = 0;
|
|
|
|
|
|
|
|
const SvxBoxItem* pCellFrame = (SvxBoxItem*) &pPattern->GetItemSet().Get( ATTR_BORDER );
|
|
|
|
const SvxBorderLine* pLeftAttr = pCellFrame->GetLeft();
|
|
|
|
const SvxBorderLine* pRightAttr = pCellFrame->GetRight();
|
|
|
|
const SvxBorderLine* pTopAttr = pCellFrame->GetTop();
|
|
|
|
const SvxBorderLine* pBottomAttr = pCellFrame->GetBottom();
|
|
|
|
const SvxBorderLine* pNew;
|
|
|
|
|
|
|
|
if (bTop)
|
|
|
|
{
|
|
|
|
if (lcl_TestAttr( pLineOuter->GetTop(), pTopAttr, rFlags.nTop, pNew ))
|
|
|
|
pLineOuter->SetLine( pNew, BOX_LINE_TOP );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (lcl_TestAttr( pLineInner->GetHori(), pTopAttr, rFlags.nHori, pNew ))
|
|
|
|
pLineInner->SetLine( pNew, BOXINFO_LINE_HORI );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nDistBottom == 0)
|
|
|
|
{
|
|
|
|
if (lcl_TestAttr( pLineOuter->GetBottom(), pBottomAttr, rFlags.nBottom, pNew ))
|
|
|
|
pLineOuter->SetLine( pNew, BOX_LINE_BOTTOM );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (lcl_TestAttr( pLineInner->GetHori(), pBottomAttr, rFlags.nHori, pNew ))
|
|
|
|
pLineInner->SetLine( pNew, BOXINFO_LINE_HORI );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bLeft)
|
|
|
|
{
|
|
|
|
if (lcl_TestAttr( pLineOuter->GetLeft(), pLeftAttr, rFlags.nLeft, pNew ))
|
|
|
|
pLineOuter->SetLine( pNew, BOX_LINE_LEFT );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (lcl_TestAttr( pLineInner->GetVert(), pLeftAttr, rFlags.nVert, pNew ))
|
|
|
|
pLineInner->SetLine( pNew, BOXINFO_LINE_VERT );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nDistRight == 0)
|
|
|
|
{
|
|
|
|
if (lcl_TestAttr( pLineOuter->GetRight(), pRightAttr, rFlags.nRight, pNew ))
|
|
|
|
pLineOuter->SetLine( pNew, BOX_LINE_RIGHT );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (lcl_TestAttr( pLineInner->GetVert(), pRightAttr, rFlags.nVert, pNew ))
|
|
|
|
pLineInner->SetLine( pNew, BOXINFO_LINE_VERT );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ScAttrArray::MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner,
|
|
|
|
ScLineFlags& rFlags,
|
2011-11-10 15:21:48 +01:00
|
|
|
SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
const ScPatternAttr* pPattern;
|
|
|
|
|
|
|
|
if (nStartRow == nEndRow)
|
|
|
|
{
|
|
|
|
pPattern = GetPattern( nStartRow );
|
2011-11-10 15:21:48 +01:00
|
|
|
lcl_MergeToFrame( pLineOuter, pLineInner, rFlags, pPattern, bLeft, nDistRight, true, 0 );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pPattern = GetPattern( nStartRow );
|
2011-11-10 15:21:48 +01:00
|
|
|
lcl_MergeToFrame( pLineOuter, pLineInner, rFlags, pPattern, bLeft, nDistRight, true,
|
2000-09-18 23:16:46 +00:00
|
|
|
nEndRow-nStartRow );
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nStartIndex;
|
|
|
|
SCSIZE nEndIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
Search( nStartRow+1, nStartIndex );
|
|
|
|
Search( nEndRow-1, nEndIndex );
|
2004-06-04 09:18:56 +00:00
|
|
|
for (SCSIZE i=nStartIndex; i<=nEndIndex; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
pPattern = (ScPatternAttr*) pData[i].pPattern;
|
2011-03-10 16:55:21 -05:00
|
|
|
lcl_MergeToFrame( pLineOuter, pLineInner, rFlags, pPattern, bLeft, nDistRight, false,
|
2004-06-04 09:18:56 +00:00
|
|
|
nEndRow - Min( pData[i].nRow, (SCROW)(nEndRow-1) ) );
|
2010-10-22 09:28:50 +01:00
|
|
|
// nDistBottom here always > 0
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pPattern = GetPattern( nEndRow );
|
2011-03-10 16:55:21 -05:00
|
|
|
lcl_MergeToFrame( pLineOuter, pLineInner, rFlags, pPattern, bLeft, nDistRight, false, 0 );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-10-22 09:28:50 +01:00
|
|
|
// apply border
|
2000-09-18 23:16:46 +00:00
|
|
|
//
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// ApplyFrame - on an entry into the array
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::ApplyFrame( const SvxBoxItem* pBoxItem,
|
2000-09-18 23:16:46 +00:00
|
|
|
const SvxBoxInfoItem* pBoxInfoItem,
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nStartRow, SCROW nEndRow,
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bLeft, SCCOL nDistRight, bool bTop, SCROW nDistBottom )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-05-21 13:29:51 +02:00
|
|
|
OSL_ENSURE( pBoxItem && pBoxInfoItem, "Linienattribute fehlen!" );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
const ScPatternAttr* pPattern = GetPattern( nStartRow );
|
|
|
|
const SvxBoxItem* pOldFrame = (const SvxBoxItem*)
|
|
|
|
&pPattern->GetItemSet().Get( ATTR_BORDER );
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// right/bottom border set when connected together
|
2000-09-18 23:16:46 +00:00
|
|
|
const ScMergeAttr& rMerge = (const ScMergeAttr&)pPattern->GetItem(ATTR_MERGE);
|
|
|
|
if ( rMerge.GetColMerge() == nDistRight + 1 )
|
|
|
|
nDistRight = 0;
|
|
|
|
if ( rMerge.GetRowMerge() == nDistBottom + 1 )
|
|
|
|
nDistBottom = 0;
|
|
|
|
|
2001-03-12 07:49:54 +00:00
|
|
|
SvxBoxItem aNewFrame( *pOldFrame );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if ( bLeft ? pBoxInfoItem->IsValid(VALID_LEFT) : pBoxInfoItem->IsValid(VALID_VERT) )
|
2001-03-12 07:49:54 +00:00
|
|
|
aNewFrame.SetLine( bLeft ? pBoxItem->GetLeft() : pBoxInfoItem->GetVert(),
|
2000-09-18 23:16:46 +00:00
|
|
|
BOX_LINE_LEFT );
|
|
|
|
if ( (nDistRight==0) ? pBoxInfoItem->IsValid(VALID_RIGHT) : pBoxInfoItem->IsValid(VALID_VERT) )
|
2001-03-12 07:49:54 +00:00
|
|
|
aNewFrame.SetLine( (nDistRight==0) ? pBoxItem->GetRight() : pBoxInfoItem->GetVert(),
|
2000-09-18 23:16:46 +00:00
|
|
|
BOX_LINE_RIGHT );
|
|
|
|
if ( bTop ? pBoxInfoItem->IsValid(VALID_TOP) : pBoxInfoItem->IsValid(VALID_HORI) )
|
2001-03-12 07:49:54 +00:00
|
|
|
aNewFrame.SetLine( bTop ? pBoxItem->GetTop() : pBoxInfoItem->GetHori(),
|
2000-09-18 23:16:46 +00:00
|
|
|
BOX_LINE_TOP );
|
|
|
|
if ( (nDistBottom==0) ? pBoxInfoItem->IsValid(VALID_BOTTOM) : pBoxInfoItem->IsValid(VALID_HORI) )
|
2001-03-12 07:49:54 +00:00
|
|
|
aNewFrame.SetLine( (nDistBottom==0) ? pBoxItem->GetBottom() : pBoxInfoItem->GetHori(),
|
2000-09-18 23:16:46 +00:00
|
|
|
BOX_LINE_BOTTOM );
|
|
|
|
|
2001-03-12 07:49:54 +00:00
|
|
|
if (aNewFrame == *pOldFrame)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2001-03-12 07:49:54 +00:00
|
|
|
// nothing to do
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-12 07:49:54 +00:00
|
|
|
SfxItemPoolCache aCache( pDocument->GetPool(), &aNewFrame );
|
2000-09-18 23:16:46 +00:00
|
|
|
ApplyCacheArea( nStartRow, nEndRow, &aCache );
|
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
return true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ScAttrArray::ApplyBlockFrame( const SvxBoxItem* pLineOuter, const SvxBoxInfoItem* pLineInner,
|
2011-11-10 15:21:48 +01:00
|
|
|
SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (nStartRow == nEndRow)
|
2011-11-10 15:21:48 +01:00
|
|
|
ApplyFrame( pLineOuter, pLineInner, nStartRow, nEndRow, bLeft, nDistRight, true, 0 );
|
2000-09-18 23:16:46 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ApplyFrame( pLineOuter, pLineInner, nStartRow, nStartRow, bLeft, nDistRight,
|
2011-11-10 15:21:48 +01:00
|
|
|
true, nEndRow-nStartRow );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
if ( nEndRow > nStartRow+1 ) // inner part available?
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nStartIndex;
|
|
|
|
SCSIZE nEndIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
Search( nStartRow+1, nStartIndex );
|
|
|
|
Search( nEndRow-1, nEndIndex );
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nTmpStart = nStartRow+1;
|
|
|
|
SCROW nTmpEnd;
|
|
|
|
for (SCSIZE i=nStartIndex; i<=nEndIndex;)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
nTmpEnd = Min( (SCROW)(nEndRow-1), (SCROW)(pData[i].nRow) );
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bChanged = ApplyFrame( pLineOuter, pLineInner, nTmpStart, nTmpEnd,
|
2011-03-10 16:55:21 -05:00
|
|
|
bLeft, nDistRight, false, nEndRow-nTmpEnd );
|
2000-09-18 23:16:46 +00:00
|
|
|
nTmpStart = nTmpEnd+1;
|
|
|
|
if (bChanged)
|
|
|
|
{
|
|
|
|
Search(nTmpStart, i);
|
|
|
|
Search(nEndRow-1, nEndIndex);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
ApplyFrame( pLineOuter, pLineInner, nEndRow, nEndRow, bLeft, nDistRight, false, 0 );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long lcl_LineSize( const SvxBorderLine& rLine )
|
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// only one line -> half width, min. 20
|
|
|
|
// double line -> half line spacing + (per min. 20)
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
long nTotal = 0;
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nWidth = Max( rLine.GetOutWidth(), rLine.GetInWidth() );
|
|
|
|
sal_uInt16 nDist = rLine.GetDistance();
|
2000-09-18 23:16:46 +00:00
|
|
|
if (nDist)
|
|
|
|
{
|
2011-05-21 13:29:51 +02:00
|
|
|
OSL_ENSURE( rLine.GetOutWidth() && rLine.GetInWidth(),
|
2010-10-22 09:28:50 +01:00
|
|
|
"Line has a distance, but only a width?" );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
nTotal += ( nDist > 20 ) ? nDist : 20;
|
|
|
|
nTotal += ( nWidth > 20 ) ? nWidth : 20;
|
|
|
|
}
|
|
|
|
else if (nWidth)
|
|
|
|
nTotal += ( nWidth > 20 ) ? nWidth : 20;
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// also halved ?
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
return nTotal;
|
|
|
|
}
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// Test if field contains specific attribute
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
bool ScAttrArray::HasAttrib( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nStartIndex;
|
|
|
|
SCSIZE nEndIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
Search( nRow1, nStartIndex );
|
|
|
|
Search( nRow2, nEndIndex );
|
2010-03-09 09:38:03 -05:00
|
|
|
bool bFound = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
for (SCSIZE i=nStartIndex; i<=nEndIndex && !bFound; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
const ScPatternAttr* pPattern = pData[i].pPattern;
|
|
|
|
if ( nMask & HASATTR_MERGED )
|
|
|
|
{
|
|
|
|
const ScMergeAttr* pMerge =
|
|
|
|
(const ScMergeAttr*) &pPattern->GetItem( ATTR_MERGE );
|
|
|
|
if ( pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1 )
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
if ( nMask & ( HASATTR_OVERLAPPED | HASATTR_NOTOVERLAPPED | HASATTR_AUTOFILTER ) )
|
|
|
|
{
|
|
|
|
const ScMergeFlagAttr* pMergeFlag =
|
|
|
|
(const ScMergeFlagAttr*) &pPattern->GetItem( ATTR_MERGE_FLAG );
|
|
|
|
if ( (nMask & HASATTR_OVERLAPPED) && pMergeFlag->IsOverlapped() )
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( (nMask & HASATTR_NOTOVERLAPPED) && !pMergeFlag->IsOverlapped() )
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( (nMask & HASATTR_AUTOFILTER) && pMergeFlag->HasAutoFilter() )
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
if ( nMask & HASATTR_LINES )
|
|
|
|
{
|
|
|
|
const SvxBoxItem* pBox =
|
|
|
|
(const SvxBoxItem*) &pPattern->GetItem( ATTR_BORDER );
|
|
|
|
if ( pBox->GetLeft() || pBox->GetRight() || pBox->GetTop() || pBox->GetBottom() )
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
if ( nMask & HASATTR_SHADOW )
|
|
|
|
{
|
|
|
|
const SvxShadowItem* pShadow =
|
|
|
|
(const SvxShadowItem*) &pPattern->GetItem( ATTR_SHADOW );
|
|
|
|
if ( pShadow->GetLocation() != SVX_SHADOW_NONE )
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
if ( nMask & HASATTR_CONDITIONAL )
|
|
|
|
{
|
|
|
|
const SfxUInt32Item* pConditional =
|
|
|
|
(const SfxUInt32Item*) &pPattern->GetItem( ATTR_CONDITIONAL );
|
|
|
|
if ( pConditional->GetValue() != 0 )
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
if ( nMask & HASATTR_PROTECTED )
|
|
|
|
{
|
|
|
|
const ScProtectionAttr* pProtect =
|
|
|
|
(const ScProtectionAttr*) &pPattern->GetItem( ATTR_PROTECTION );
|
|
|
|
if ( pProtect->GetProtection() || pProtect->GetHideCell() )
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
if ( nMask & HASATTR_ROTATE )
|
|
|
|
{
|
|
|
|
const SfxInt32Item* pRotate =
|
|
|
|
(const SfxInt32Item*) &pPattern->GetItem( ATTR_ROTATE_VALUE );
|
2008-01-29 14:15:32 +00:00
|
|
|
// 90 or 270 degrees is former SvxOrientationItem - only look for other values
|
|
|
|
// (see ScPatternAttr::GetCellOrientation)
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Int32 nAngle = pRotate->GetValue();
|
2008-01-29 14:15:32 +00:00
|
|
|
if ( nAngle != 0 && nAngle != 9000 && nAngle != 27000 )
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
if ( nMask & HASATTR_NEEDHEIGHT )
|
|
|
|
{
|
2004-08-02 15:53:31 +00:00
|
|
|
if (pPattern->GetCellOrientation() != SVX_ORIENTATION_STANDARD)
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
else if (((const SfxBoolItem&)pPattern->GetItem( ATTR_LINEBREAK )).GetValue())
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
else if ((SvxCellHorJustify)((const SvxHorJustifyItem&)pPattern->
|
|
|
|
GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SVX_HOR_JUSTIFY_BLOCK)
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
else if (((const SfxUInt32Item&)pPattern->GetItem( ATTR_CONDITIONAL )).GetValue())
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
else if (((const SfxInt32Item&)pPattern->GetItem( ATTR_ROTATE_VALUE )).GetValue())
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
if ( nMask & ( HASATTR_SHADOW_RIGHT | HASATTR_SHADOW_DOWN ) )
|
|
|
|
{
|
|
|
|
const SvxShadowItem* pShadow =
|
|
|
|
(const SvxShadowItem*) &pPattern->GetItem( ATTR_SHADOW );
|
|
|
|
SvxShadowLocation eLoc = pShadow->GetLocation();
|
|
|
|
if ( nMask & HASATTR_SHADOW_RIGHT )
|
|
|
|
if ( eLoc == SVX_SHADOW_TOPRIGHT || eLoc == SVX_SHADOW_BOTTOMRIGHT )
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( nMask & HASATTR_SHADOW_DOWN )
|
|
|
|
if ( eLoc == SVX_SHADOW_BOTTOMLEFT || eLoc == SVX_SHADOW_BOTTOMRIGHT )
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2003-03-26 17:07:02 +00:00
|
|
|
if ( nMask & HASATTR_RTL )
|
|
|
|
{
|
|
|
|
const SvxFrameDirectionItem& rDirection =
|
|
|
|
(const SvxFrameDirectionItem&) pPattern->GetItem( ATTR_WRITINGDIR );
|
|
|
|
if ( rDirection.GetValue() == FRMDIR_HORI_RIGHT_TOP )
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2003-03-26 17:07:02 +00:00
|
|
|
}
|
2004-02-03 11:16:26 +00:00
|
|
|
if ( nMask & HASATTR_RIGHTORCENTER )
|
|
|
|
{
|
|
|
|
// called only if the sheet is LTR, so physical=logical alignment can be assumed
|
|
|
|
SvxCellHorJustify eHorJust = (SvxCellHorJustify)
|
|
|
|
((const SvxHorJustifyItem&) pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue();
|
|
|
|
if ( eHorJust == SVX_HOR_JUSTIFY_RIGHT || eHorJust == SVX_HOR_JUSTIFY_CENTER )
|
2010-03-09 09:38:03 -05:00
|
|
|
bFound = true;
|
2004-02-03 11:16:26 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bFound;
|
|
|
|
}
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// Area around any given summaries expand and adapt any MergeFlag (bRefresh)
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow,
|
2004-06-04 09:18:56 +00:00
|
|
|
SCCOL& rPaintCol, SCROW& rPaintRow,
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bRefresh )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
const ScPatternAttr* pPattern;
|
|
|
|
const ScMergeAttr* pItem;
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nStartIndex;
|
|
|
|
SCSIZE nEndIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
Search( nStartRow, nStartIndex );
|
|
|
|
Search( nEndRow, nEndIndex );
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bFound = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
for (SCSIZE i=nStartIndex; i<=nEndIndex; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
pPattern = pData[i].pPattern;
|
|
|
|
pItem = (const ScMergeAttr*) &pPattern->GetItem( ATTR_MERGE );
|
2004-06-04 09:18:56 +00:00
|
|
|
SCsCOL nCountX = pItem->GetColMerge();
|
|
|
|
SCsROW nCountY = pItem->GetRowMerge();
|
2000-09-18 23:16:46 +00:00
|
|
|
if (nCountX>1 || nCountY>1)
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nThisRow = (i>0) ? pData[i-1].nRow+1 : 0;
|
|
|
|
SCCOL nMergeEndCol = nThisCol + nCountX - 1;
|
|
|
|
SCROW nMergeEndRow = nThisRow + nCountY - 1;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (nMergeEndCol > rPaintCol && nMergeEndCol <= MAXCOL)
|
|
|
|
rPaintCol = nMergeEndCol;
|
|
|
|
if (nMergeEndRow > rPaintRow && nMergeEndRow <= MAXROW)
|
|
|
|
rPaintRow = nMergeEndRow;
|
2011-11-10 15:21:48 +01:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if (bRefresh)
|
|
|
|
{
|
|
|
|
if ( nMergeEndCol > nThisCol )
|
|
|
|
pDocument->ApplyFlagsTab( nThisCol+1, nThisRow, nMergeEndCol, pData[i].nRow,
|
|
|
|
nTab, SC_MF_HOR );
|
|
|
|
if ( nMergeEndRow > nThisRow )
|
|
|
|
pDocument->ApplyFlagsTab( nThisCol, nThisRow+1, nThisCol, nMergeEndRow,
|
|
|
|
nTab, SC_MF_VER );
|
|
|
|
if ( nMergeEndCol > nThisCol && nMergeEndRow > nThisRow )
|
|
|
|
pDocument->ApplyFlagsTab( nThisCol+1, nThisRow+1, nMergeEndCol, nMergeEndRow,
|
|
|
|
nTab, SC_MF_HOR | SC_MF_VER );
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
Search( nThisRow, i ); // Data changed
|
2000-09-18 23:16:46 +00:00
|
|
|
Search( nStartRow, nStartIndex );
|
|
|
|
Search( nEndRow, nEndIndex );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bFound;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::RemoveAreaMerge(SCROW nStartRow, SCROW nEndRow)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bFound = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
const ScPatternAttr* pPattern;
|
|
|
|
const ScMergeAttr* pItem;
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
Search( nStartRow, nIndex );
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nThisStart = (nIndex>0) ? pData[nIndex-1].nRow+1 : 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (nThisStart < nStartRow)
|
|
|
|
nThisStart = nStartRow;
|
|
|
|
|
|
|
|
while ( nThisStart <= nEndRow )
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nThisEnd = pData[nIndex].nRow;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (nThisEnd > nEndRow)
|
|
|
|
nThisEnd = nEndRow;
|
|
|
|
|
|
|
|
pPattern = pData[nIndex].pPattern;
|
|
|
|
pItem = (const ScMergeAttr*) &pPattern->GetItem( ATTR_MERGE );
|
2004-06-04 09:18:56 +00:00
|
|
|
SCsCOL nCountX = pItem->GetColMerge();
|
|
|
|
SCsROW nCountY = pItem->GetRowMerge();
|
2000-09-18 23:16:46 +00:00
|
|
|
if (nCountX>1 || nCountY>1)
|
|
|
|
{
|
|
|
|
const ScMergeAttr* pAttr = (const ScMergeAttr*)
|
|
|
|
&pDocument->GetPool()->GetDefaultItem( ATTR_MERGE );
|
|
|
|
const ScMergeFlagAttr* pFlagAttr = (const ScMergeFlagAttr*)
|
|
|
|
&pDocument->GetPool()->GetDefaultItem( ATTR_MERGE_FLAG );
|
|
|
|
|
2011-05-21 13:29:51 +02:00
|
|
|
OSL_ENSURE( nCountY==1 || nThisStart==nThisEnd, "What's up?" );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
SCCOL nThisCol = nCol;
|
|
|
|
SCCOL nMergeEndCol = nThisCol + nCountX - 1;
|
|
|
|
SCROW nMergeEndRow = nThisEnd + nCountY - 1;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// ApplyAttr for areas
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
for (SCROW nThisRow = nThisStart; nThisRow <= nThisEnd; nThisRow++)
|
2000-09-18 23:16:46 +00:00
|
|
|
pDocument->ApplyAttr( nThisCol, nThisRow, nTab, *pAttr );
|
|
|
|
|
|
|
|
ScPatternAttr* pNewPattern = new ScPatternAttr( pDocument->GetPool() );
|
|
|
|
SfxItemSet* pSet = &pNewPattern->GetItemSet();
|
|
|
|
pSet->Put( *pFlagAttr );
|
|
|
|
pDocument->ApplyPatternAreaTab( nThisCol, nThisStart, nMergeEndCol, nMergeEndRow,
|
|
|
|
nTab, *pNewPattern );
|
|
|
|
delete pNewPattern;
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
Search( nThisEnd, nIndex ); // data changed
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
++nIndex;
|
2004-06-04 09:18:56 +00:00
|
|
|
if ( nIndex < nCount )
|
2000-09-18 23:16:46 +00:00
|
|
|
nThisStart = pData[nIndex-1].nRow+1;
|
|
|
|
else
|
2010-10-22 09:28:50 +01:00
|
|
|
nThisStart = MAXROW+1; // End
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bFound;
|
|
|
|
}
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// Remove field, but leave MergeFlags
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
void ScAttrArray::DeleteAreaSafe(SCROW nStartRow, SCROW nEndRow)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-10 15:21:48 +01:00
|
|
|
SetPatternAreaSafe( nStartRow, nEndRow, pDocument->GetDefPattern(), true );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
void ScAttrArray::SetPatternAreaSafe( SCROW nStartRow, SCROW nEndRow,
|
2011-11-10 15:21:48 +01:00
|
|
|
const ScPatternAttr* pWantedPattern, bool bDefault )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
const ScPatternAttr* pOldPattern;
|
|
|
|
const ScMergeFlagAttr* pItem;
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex;
|
|
|
|
SCROW nRow;
|
|
|
|
SCROW nThisRow;
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bFirstUse = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
Search( nStartRow, nIndex );
|
|
|
|
nThisRow = (nIndex>0) ? pData[nIndex-1].nRow+1 : 0;
|
|
|
|
while ( nThisRow <= nEndRow )
|
|
|
|
{
|
|
|
|
pOldPattern = pData[nIndex].pPattern;
|
|
|
|
if (pOldPattern != pWantedPattern) //! else-Zweig ?
|
|
|
|
{
|
|
|
|
if (nThisRow < nStartRow) nThisRow = nStartRow;
|
|
|
|
nRow = pData[nIndex].nRow;
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nAttrRow = Min( (SCROW)nRow, (SCROW)nEndRow );
|
2000-09-18 23:16:46 +00:00
|
|
|
pItem = (const ScMergeFlagAttr*) &pOldPattern->GetItem( ATTR_MERGE_FLAG );
|
|
|
|
|
|
|
|
if (pItem->IsOverlapped() || pItem->HasAutoFilter())
|
|
|
|
{
|
2011-02-27 23:59:21 +01:00
|
|
|
// default-constructing a ScPatternAttr for DeleteArea doesn't work
|
2003-04-08 15:18:57 +00:00
|
|
|
// because it would have no cell style information.
|
|
|
|
// Instead, the document's GetDefPattern is copied. Since it is passed as
|
|
|
|
// pWantedPattern, no special treatment of default is needed here anymore.
|
|
|
|
ScPatternAttr* pNewPattern = new ScPatternAttr( *pWantedPattern );
|
2000-09-18 23:16:46 +00:00
|
|
|
SfxItemSet* pSet = &pNewPattern->GetItemSet();
|
|
|
|
pSet->Put( *pItem );
|
2011-11-10 15:21:48 +01:00
|
|
|
SetPatternArea( nThisRow, nAttrRow, pNewPattern, true );
|
2000-09-18 23:16:46 +00:00
|
|
|
delete pNewPattern;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( !bDefault )
|
|
|
|
{
|
|
|
|
if (bFirstUse)
|
2011-03-10 16:55:21 -05:00
|
|
|
bFirstUse = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
else
|
2010-10-22 09:28:50 +01:00
|
|
|
// it's in the pool
|
|
|
|
pDocument->GetPool()->Put( *pWantedPattern );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
SetPatternArea( nThisRow, nAttrRow, pWantedPattern );
|
|
|
|
}
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
Search( nThisRow, nIndex ); // data changed
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
++nIndex;
|
|
|
|
nThisRow = pData[nIndex-1].nRow+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::ApplyFlags( SCROW nStartRow, SCROW nEndRow, sal_Int16 nFlags )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
const ScPatternAttr* pOldPattern;
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Int16 nOldValue;
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex;
|
|
|
|
SCROW nRow;
|
|
|
|
SCROW nThisRow;
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bChanged = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
Search( nStartRow, nIndex );
|
|
|
|
nThisRow = (nIndex>0) ? pData[nIndex-1].nRow+1 : 0;
|
|
|
|
if (nThisRow < nStartRow) nThisRow = nStartRow;
|
|
|
|
|
|
|
|
while ( nThisRow <= nEndRow )
|
|
|
|
{
|
|
|
|
pOldPattern = pData[nIndex].pPattern;
|
|
|
|
nOldValue = ((const ScMergeFlagAttr*) &pOldPattern->GetItem( ATTR_MERGE_FLAG ))->GetValue();
|
|
|
|
if ( (nOldValue | nFlags) != nOldValue )
|
|
|
|
{
|
|
|
|
nRow = pData[nIndex].nRow;
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nAttrRow = Min( (SCROW)nRow, (SCROW)nEndRow );
|
2000-09-18 23:16:46 +00:00
|
|
|
ScPatternAttr aNewPattern(*pOldPattern);
|
|
|
|
aNewPattern.GetItemSet().Put( ScMergeFlagAttr( nOldValue | nFlags ) );
|
2011-03-10 16:55:21 -05:00
|
|
|
SetPatternArea( nThisRow, nAttrRow, &aNewPattern, true );
|
2010-10-22 09:28:50 +01:00
|
|
|
Search( nThisRow, nIndex ); // data changed
|
2011-03-10 16:55:21 -05:00
|
|
|
bChanged = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
++nIndex;
|
|
|
|
nThisRow = pData[nIndex-1].nRow+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::RemoveFlags( SCROW nStartRow, SCROW nEndRow, sal_Int16 nFlags )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
const ScPatternAttr* pOldPattern;
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Int16 nOldValue;
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex;
|
|
|
|
SCROW nRow;
|
|
|
|
SCROW nThisRow;
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bChanged = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
Search( nStartRow, nIndex );
|
|
|
|
nThisRow = (nIndex>0) ? pData[nIndex-1].nRow+1 : 0;
|
|
|
|
if (nThisRow < nStartRow) nThisRow = nStartRow;
|
|
|
|
|
|
|
|
while ( nThisRow <= nEndRow )
|
|
|
|
{
|
|
|
|
pOldPattern = pData[nIndex].pPattern;
|
|
|
|
nOldValue = ((const ScMergeFlagAttr*) &pOldPattern->GetItem( ATTR_MERGE_FLAG ))->GetValue();
|
|
|
|
if ( (nOldValue & ~nFlags) != nOldValue )
|
|
|
|
{
|
|
|
|
nRow = pData[nIndex].nRow;
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nAttrRow = Min( (SCROW)nRow, (SCROW)nEndRow );
|
2000-09-18 23:16:46 +00:00
|
|
|
ScPatternAttr aNewPattern(*pOldPattern);
|
|
|
|
aNewPattern.GetItemSet().Put( ScMergeFlagAttr( nOldValue & ~nFlags ) );
|
2011-03-10 16:55:21 -05:00
|
|
|
SetPatternArea( nThisRow, nAttrRow, &aNewPattern, true );
|
2010-10-22 09:28:50 +01:00
|
|
|
Search( nThisRow, nIndex ); // data changed
|
2011-03-10 16:55:21 -05:00
|
|
|
bChanged = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
++nIndex;
|
|
|
|
nThisRow = pData[nIndex-1].nRow+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
void ScAttrArray::ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
const ScPatternAttr* pOldPattern;
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex;
|
|
|
|
SCROW nRow;
|
|
|
|
SCROW nThisRow;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
Search( nStartRow, nIndex );
|
|
|
|
nThisRow = (nIndex>0) ? pData[nIndex-1].nRow+1 : 0;
|
|
|
|
if (nThisRow < nStartRow) nThisRow = nStartRow;
|
|
|
|
|
|
|
|
while ( nThisRow <= nEndRow )
|
|
|
|
{
|
|
|
|
pOldPattern = pData[nIndex].pPattern;
|
|
|
|
if ( pOldPattern->HasItemsSet( pWhich ) )
|
|
|
|
{
|
|
|
|
ScPatternAttr aNewPattern(*pOldPattern);
|
|
|
|
aNewPattern.ClearItems( pWhich );
|
|
|
|
|
|
|
|
nRow = pData[nIndex].nRow;
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nAttrRow = Min( (SCROW)nRow, (SCROW)nEndRow );
|
2011-03-10 16:55:21 -05:00
|
|
|
SetPatternArea( nThisRow, nAttrRow, &aNewPattern, true );
|
2010-10-22 09:28:50 +01:00
|
|
|
Search( nThisRow, nIndex ); // data changed
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
++nIndex;
|
|
|
|
nThisRow = pData[nIndex-1].nRow+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
void ScAttrArray::ChangeIndent( SCROW nStartRow, SCROW nEndRow, bool bIncrement )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
Search( nStartRow, nIndex );
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nThisStart = (nIndex>0) ? pData[nIndex-1].nRow+1 : 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (nThisStart < nStartRow) nThisStart = nStartRow;
|
|
|
|
|
|
|
|
while ( nThisStart <= nEndRow )
|
|
|
|
{
|
|
|
|
const ScPatternAttr* pOldPattern = pData[nIndex].pPattern;
|
|
|
|
const SfxItemSet& rOldSet = pOldPattern->GetItemSet();
|
|
|
|
const SfxPoolItem* pItem;
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bNeedJust = ( rOldSet.GetItemState( ATTR_HOR_JUSTIFY, false, &pItem ) != SFX_ITEM_SET
|
2000-09-18 23:16:46 +00:00
|
|
|
|| ((const SvxHorJustifyItem*)pItem)->GetValue() != SVX_HOR_JUSTIFY_LEFT );
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nOldValue = ((const SfxUInt16Item&)rOldSet.Get( ATTR_INDENT )).GetValue();
|
|
|
|
sal_uInt16 nNewValue = nOldValue;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( bIncrement )
|
|
|
|
{
|
|
|
|
if ( nNewValue < SC_MAX_INDENT )
|
|
|
|
{
|
|
|
|
nNewValue += SC_INDENT_STEP;
|
|
|
|
if ( nNewValue > SC_MAX_INDENT ) nNewValue = SC_MAX_INDENT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( nNewValue > 0 )
|
|
|
|
{
|
|
|
|
if ( nNewValue > SC_INDENT_STEP )
|
|
|
|
nNewValue -= SC_INDENT_STEP;
|
|
|
|
else
|
|
|
|
nNewValue = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bNeedJust || nNewValue != nOldValue )
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nThisEnd = pData[nIndex].nRow;
|
|
|
|
SCROW nAttrRow = Min( nThisEnd, nEndRow );
|
2000-09-18 23:16:46 +00:00
|
|
|
ScPatternAttr aNewPattern(*pOldPattern);
|
|
|
|
aNewPattern.GetItemSet().Put( SfxUInt16Item( ATTR_INDENT, nNewValue ) );
|
|
|
|
if ( bNeedJust )
|
|
|
|
aNewPattern.GetItemSet().Put(
|
|
|
|
SvxHorJustifyItem( SVX_HOR_JUSTIFY_LEFT, ATTR_HOR_JUSTIFY ) );
|
2011-11-10 15:21:48 +01:00
|
|
|
SetPatternArea( nThisStart, nAttrRow, &aNewPattern, true );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
nThisStart = nThisEnd + 1;
|
2010-10-22 09:28:50 +01:00
|
|
|
Search( nThisStart, nIndex ); // data changed
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
nThisStart = pData[nIndex].nRow + 1;
|
2000-09-18 23:16:46 +00:00
|
|
|
++nIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
SCsROW ScAttrArray::GetNextUnprotected( SCsROW nRow, bool bUp ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
long nRet = nRow;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (VALIDROW(nRow))
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
Search(nRow, nIndex);
|
|
|
|
while (((const ScProtectionAttr&)pData[nIndex].pPattern->
|
|
|
|
GetItem(ATTR_PROTECTION)).GetProtection())
|
|
|
|
{
|
|
|
|
if (bUp)
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
if (nIndex==0)
|
2010-10-22 09:28:50 +01:00
|
|
|
return -1; // not found
|
2004-06-04 09:18:56 +00:00
|
|
|
--nIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
nRet = pData[nIndex].nRow;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nRet = pData[nIndex].nRow+1;
|
|
|
|
++nIndex;
|
|
|
|
if (nIndex>=nCount)
|
2010-10-22 09:28:50 +01:00
|
|
|
return MAXROW+1; // not found
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
2010-06-23 13:38:34 +02:00
|
|
|
void ScAttrArray::FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nStart = 0;
|
|
|
|
SCSIZE nPos = 0;
|
|
|
|
while (nPos < nCount)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nEnd = pData[nPos].nRow;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (pData[nPos].pPattern->GetStyleSheet() == pStyleSheet)
|
|
|
|
{
|
2010-06-23 13:38:34 +02:00
|
|
|
rUsedRows.setTrue(nStart, nEnd);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if (bReset)
|
|
|
|
{
|
|
|
|
ScPatternAttr* pNewPattern = new ScPatternAttr(*pData[nPos].pPattern);
|
|
|
|
pDocument->GetPool()->Remove(*pData[nPos].pPattern);
|
|
|
|
pNewPattern->SetStyleSheet( (ScStyleSheet*)
|
|
|
|
pDocument->GetStyleSheetPool()->
|
|
|
|
Find( ScGlobal::GetRscString(STR_STYLENAME_STANDARD),
|
|
|
|
SFX_STYLE_FAMILY_PARA,
|
|
|
|
SFXSTYLEBIT_AUTO | SCSTYLEBIT_STANDARD ) );
|
|
|
|
pData[nPos].pPattern = (const ScPatternAttr*)
|
|
|
|
&pDocument->GetPool()->Put(*pNewPattern);
|
|
|
|
delete pNewPattern;
|
|
|
|
|
|
|
|
if (Concat(nPos))
|
|
|
|
{
|
|
|
|
Search(nStart, nPos);
|
2010-10-22 09:28:50 +01:00
|
|
|
--nPos; // because ++ at end
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nStart = nEnd + 1;
|
|
|
|
++nPos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::IsStyleSheetUsed( const ScStyleSheet& rStyle,
|
|
|
|
bool bGatherAllStyles ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bIsUsed = false;
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nPos = 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
while ( nPos < nCount )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-12-05 15:09:00 +00:00
|
|
|
const ScStyleSheet* pStyle = pData[nPos].pPattern->GetStyleSheet();
|
|
|
|
if ( pStyle )
|
|
|
|
{
|
|
|
|
pStyle->SetUsage( ScStyleSheet::USED );
|
|
|
|
if ( pStyle == &rStyle )
|
|
|
|
{
|
|
|
|
if ( !bGatherAllStyles )
|
2011-11-10 15:21:48 +01:00
|
|
|
return true;
|
|
|
|
bIsUsed = true;
|
2002-12-05 15:09:00 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
nPos++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bIsUsed;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::IsEmpty() const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (nCount == 1)
|
|
|
|
{
|
|
|
|
if ( pData[0].pPattern != pDocument->GetDefPattern() )
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
else
|
2011-11-10 15:21:48 +01:00
|
|
|
return true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::GetFirstVisibleAttr( SCROW& rFirstRow ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-05-21 13:29:51 +02:00
|
|
|
OSL_ENSURE( nCount, "nCount == 0" );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bFound = false;
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nStart = 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2005-02-21 14:57:17 +00:00
|
|
|
// Skip first entry if more than 1 row.
|
|
|
|
// Entries at the end are not skipped, GetFirstVisibleAttr may be larger than GetLastVisibleAttr.
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2005-02-21 14:57:17 +00:00
|
|
|
SCSIZE nVisStart = 1;
|
|
|
|
while ( nVisStart < nCount && pData[nVisStart].pPattern->IsVisibleEqual(*pData[nVisStart-1].pPattern) )
|
|
|
|
++nVisStart;
|
|
|
|
if ( nVisStart >= nCount || pData[nVisStart-1].nRow > 0 ) // more than 1 row?
|
|
|
|
nStart = nVisStart;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2005-02-21 14:57:17 +00:00
|
|
|
while ( nStart < nCount && !bFound )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if ( pData[nStart].pPattern->IsVisible() )
|
|
|
|
{
|
|
|
|
rFirstRow = nStart ? ( pData[nStart-1].nRow + 1 ) : 0;
|
2011-11-10 15:21:48 +01:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
++nStart;
|
|
|
|
}
|
|
|
|
|
2005-02-21 14:57:17 +00:00
|
|
|
return bFound;
|
|
|
|
}
|
|
|
|
|
|
|
|
// size (rows) of a range of attributes after cell content where the search is stopped
|
|
|
|
// (more than a default page size, 2*42 because it's as good as any number)
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2005-02-21 14:57:17 +00:00
|
|
|
const SCROW SC_VISATTR_STOP = 84;
|
|
|
|
|
2012-07-09 01:40:58 +02:00
|
|
|
bool ScAttrArray::GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData, bool bFullFormattedArea ) const
|
2005-02-21 14:57:17 +00:00
|
|
|
{
|
2012-05-14 18:18:25 +02:00
|
|
|
OSL_ENSURE( nCount, "nCount == 0" );
|
|
|
|
|
2005-02-21 14:57:17 +00:00
|
|
|
// #i30830# changed behavior:
|
|
|
|
// ignore all attributes starting with the first run of SC_VISATTR_STOP equal rows
|
|
|
|
// below the last content cell
|
|
|
|
|
|
|
|
if ( nLastData == MAXROW )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2005-02-21 14:57:17 +00:00
|
|
|
rLastRow = MAXROW; // can't look for attributes below MAXROW
|
2011-11-10 15:21:48 +01:00
|
|
|
return true;
|
2005-02-21 14:57:17 +00:00
|
|
|
}
|
|
|
|
|
2012-05-14 18:18:25 +02:00
|
|
|
// Quick check: last data row in or immediately preceding a run that is the
|
|
|
|
// last attribution down to the end, e.g. default style or column style.
|
|
|
|
SCSIZE nPos = nCount - 1;
|
|
|
|
SCROW nStartRow = (nPos ? pData[nPos-1].nRow + 1 : 0);
|
|
|
|
if (nStartRow <= nLastData + 1)
|
2005-02-21 14:57:17 +00:00
|
|
|
{
|
2012-05-14 18:18:25 +02:00
|
|
|
if (bFullFormattedArea && pData[nPos].pPattern->IsVisible())
|
|
|
|
{
|
|
|
|
rLastRow = pData[nPos].nRow;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Ignore here a few rows if data happens to end within
|
|
|
|
// SC_VISATTR_STOP rows before MAXROW.
|
|
|
|
rLastRow = nLastData;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2005-02-21 14:57:17 +00:00
|
|
|
|
2012-05-14 18:18:25 +02:00
|
|
|
// Find a run below last data row.
|
|
|
|
bool bFound = false;
|
|
|
|
Search( nLastData, nPos );
|
|
|
|
while ( nPos < nCount )
|
|
|
|
{
|
|
|
|
// find range of visually equal formats
|
2012-05-24 12:37:57 +02:00
|
|
|
SCSIZE nEndPos = nPos;
|
2012-05-14 18:18:25 +02:00
|
|
|
while ( nEndPos < nCount-1 &&
|
|
|
|
pData[nEndPos].pPattern->IsVisibleEqual( *pData[nEndPos+1].pPattern))
|
|
|
|
++nEndPos;
|
2012-05-24 12:37:57 +02:00
|
|
|
SCROW nAttrStartRow = ( nPos > 0 ) ? ( pData[nPos-1].nRow + 1 ) : 0;
|
2005-02-21 14:57:17 +00:00
|
|
|
if ( nAttrStartRow <= nLastData )
|
|
|
|
nAttrStartRow = nLastData + 1;
|
|
|
|
SCROW nAttrSize = pData[nEndPos].nRow + 1 - nAttrStartRow;
|
2012-03-27 05:14:06 +02:00
|
|
|
if ( nAttrSize >= SC_VISATTR_STOP && !bFullFormattedArea )
|
2012-05-14 18:18:25 +02:00
|
|
|
break; // while, ignore this range and below
|
|
|
|
else if ( pData[nEndPos].pPattern->IsVisible() )
|
2005-02-21 14:57:17 +00:00
|
|
|
{
|
|
|
|
rLastRow = pData[nEndPos].nRow;
|
2011-11-10 15:21:48 +01:00
|
|
|
bFound = true;
|
2005-02-21 14:57:17 +00:00
|
|
|
}
|
2012-05-24 12:37:57 +02:00
|
|
|
nPos = nEndPos + 1;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 14:57:17 +00:00
|
|
|
return bFound;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
Search( nStartRow, nIndex );
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nThisStart = nStartRow;
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bFound = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
while ( nIndex < nCount && nThisStart <= nEndRow && !bFound )
|
|
|
|
{
|
|
|
|
if ( pData[nIndex].pPattern->IsVisible() )
|
2011-11-10 15:21:48 +01:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
nThisStart = pData[nIndex].nRow + 1;
|
|
|
|
++nIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bFound;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::IsVisibleEqual( const ScAttrArray& rOther,
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nStartRow, SCROW nEndRow ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bEqual = true;
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nThisPos = 0;
|
|
|
|
SCSIZE nOtherPos = 0;
|
|
|
|
if ( nStartRow > 0 )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
Search( nStartRow, nThisPos );
|
|
|
|
rOther.Search( nStartRow, nOtherPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
while ( nThisPos<nCount && nOtherPos<rOther.nCount && bEqual )
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nThisRow = pData[nThisPos].nRow;
|
|
|
|
SCROW nOtherRow = rOther.pData[nOtherPos].nRow;
|
2000-09-18 23:16:46 +00:00
|
|
|
const ScPatternAttr* pThisPattern = pData[nThisPos].pPattern;
|
|
|
|
const ScPatternAttr* pOtherPattern = rOther.pData[nOtherPos].pPattern;
|
|
|
|
bEqual = ( pThisPattern == pOtherPattern ||
|
|
|
|
pThisPattern->IsVisibleEqual(*pOtherPattern) );
|
|
|
|
|
|
|
|
if ( nThisRow >= nOtherRow )
|
|
|
|
{
|
|
|
|
if ( nOtherRow >= nEndRow ) break;
|
|
|
|
++nOtherPos;
|
|
|
|
}
|
|
|
|
if ( nThisRow <= nOtherRow )
|
|
|
|
{
|
|
|
|
if ( nThisRow >= nEndRow ) break;
|
|
|
|
++nThisPos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bEqual;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::IsAllEqual( const ScAttrArray& rOther, SCROW nStartRow, SCROW nEndRow ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// summarised with IsVisibleEqual
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bEqual = true;
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nThisPos = 0;
|
|
|
|
SCSIZE nOtherPos = 0;
|
|
|
|
if ( nStartRow > 0 )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
Search( nStartRow, nThisPos );
|
|
|
|
rOther.Search( nStartRow, nOtherPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
while ( nThisPos<nCount && nOtherPos<rOther.nCount && bEqual )
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nThisRow = pData[nThisPos].nRow;
|
|
|
|
SCROW nOtherRow = rOther.pData[nOtherPos].nRow;
|
2000-09-18 23:16:46 +00:00
|
|
|
const ScPatternAttr* pThisPattern = pData[nThisPos].pPattern;
|
|
|
|
const ScPatternAttr* pOtherPattern = rOther.pData[nOtherPos].pPattern;
|
|
|
|
bEqual = ( pThisPattern == pOtherPattern );
|
|
|
|
|
|
|
|
if ( nThisRow >= nOtherRow )
|
|
|
|
{
|
|
|
|
if ( nOtherRow >= nEndRow ) break;
|
|
|
|
++nOtherPos;
|
|
|
|
}
|
|
|
|
if ( nThisRow <= nOtherRow )
|
|
|
|
{
|
|
|
|
if ( nThisRow >= nEndRow ) break;
|
|
|
|
++nThisPos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bEqual;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::TestInsertCol( SCROW nStartRow, SCROW nEndRow) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// Horizontal aggregate are not allowed to be moved out; if whole summary,
|
|
|
|
// here is not recognized
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bTest = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (!IsEmpty())
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex = 0;
|
|
|
|
if ( nStartRow > 0 )
|
2000-09-18 23:16:46 +00:00
|
|
|
Search( nStartRow, nIndex );
|
|
|
|
|
|
|
|
for ( ; nIndex < nCount; nIndex++ )
|
|
|
|
{
|
|
|
|
if ( ((const ScMergeFlagAttr&)pData[nIndex].pPattern->
|
|
|
|
GetItem(ATTR_MERGE_FLAG)).IsHorOverlapped() )
|
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
bTest = false; // may not be pushed out
|
2000-09-18 23:16:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-10-22 09:28:50 +01:00
|
|
|
if ( pData[nIndex].nRow >= nEndRow ) // end of range
|
2000-09-18 23:16:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bTest;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::TestInsertRow( SCSIZE nSize ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// if 1st row pushed out is vertically overlapped, summary would be broken
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if (pData)
|
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// MAXROW + 1 - nSize = 1st row pushed out
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nFirstLost = nCount-1;
|
2007-02-27 10:59:23 +00:00
|
|
|
while ( nFirstLost && pData[nFirstLost-1].nRow >= sal::static_int_cast<SCROW>(MAXROW + 1 - nSize) )
|
2000-09-18 23:16:46 +00:00
|
|
|
--nFirstLost;
|
|
|
|
|
|
|
|
if ( ((const ScMergeFlagAttr&)pData[nFirstLost].pPattern->
|
|
|
|
GetItem(ATTR_MERGE_FLAG)).IsVerOverlapped() )
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
return true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
void ScAttrArray::InsertRow( SCROW nStartRow, SCSIZE nSize )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (!pData)
|
|
|
|
return;
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
SCROW nSearch = nStartRow > 0 ? nStartRow - 1 : 0; // expand predecessor
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
Search( nSearch, nIndex );
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// set ScMergeAttr may not be extended (so behind delete again)
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bDoMerge = ((const ScMergeAttr&) pData[nIndex].pPattern->GetItem(ATTR_MERGE)).IsMerged();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nRemove = 0;
|
|
|
|
SCSIZE i;
|
2000-09-18 23:16:46 +00:00
|
|
|
for (i = nIndex; i < nCount-1; i++)
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nNew = pData[i].nRow + nSize;
|
2010-10-22 09:28:50 +01:00
|
|
|
if ( nNew >= MAXROW ) // at end?
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
nNew = MAXROW;
|
|
|
|
if (!nRemove)
|
2010-10-22 09:28:50 +01:00
|
|
|
nRemove = i+1; // remove the following?
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
pData[i].nRow = nNew;
|
|
|
|
}
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// Remove entries at end ?
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if (nRemove && nRemove < nCount)
|
|
|
|
DeleteRange( nRemove, nCount-1 );
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
if (bDoMerge) // extensively repair (again) ScMergeAttr
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// ApplyAttr for areas
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
const SfxPoolItem& rDef = pDocument->GetPool()->GetDefaultItem( ATTR_MERGE );
|
2007-02-27 10:59:23 +00:00
|
|
|
for (SCSIZE nAdd=0; nAdd<nSize; nAdd++)
|
|
|
|
pDocument->ApplyAttr( nCol, nStartRow+nAdd, nTab, rDef );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// reply inserts in this area not summarized
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2009-07-03 11:00:47 +00:00
|
|
|
// Don't duplicate the merge flags in the inserted row.
|
2010-01-21 07:54:11 +00:00
|
|
|
// #i108488# SC_MF_SCENARIO has to be allowed.
|
|
|
|
RemoveFlags( nStartRow, nStartRow+nSize-1, SC_MF_HOR | SC_MF_VER | SC_MF_AUTO | SC_MF_BUTTON );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
void ScAttrArray::DeleteRow( SCROW nStartRow, SCSIZE nSize )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (pData)
|
|
|
|
{
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bFirst=true;
|
2007-02-27 10:59:23 +00:00
|
|
|
SCSIZE nStartIndex = 0;
|
|
|
|
SCSIZE nEndIndex = 0;
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE i;
|
2003-12-01 16:49:17 +00:00
|
|
|
|
|
|
|
for ( i = 0; i < nCount-1; i++)
|
2007-02-27 10:59:23 +00:00
|
|
|
if (pData[i].nRow >= nStartRow && pData[i].nRow <= sal::static_int_cast<SCROW>(nStartRow+nSize-1))
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (bFirst)
|
|
|
|
{
|
|
|
|
nStartIndex = i;
|
2011-03-10 16:55:21 -05:00
|
|
|
bFirst = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
nEndIndex = i;
|
|
|
|
}
|
|
|
|
if (!bFirst)
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nStart;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (nStartIndex==0)
|
|
|
|
nStart = 0;
|
|
|
|
else
|
|
|
|
nStart = pData[nStartIndex-1].nRow + 1;
|
|
|
|
|
|
|
|
if (nStart < nStartRow)
|
|
|
|
{
|
|
|
|
pData[nStartIndex].nRow = nStartRow - 1;
|
|
|
|
++nStartIndex;
|
|
|
|
}
|
|
|
|
if (nEndIndex >= nStartIndex)
|
|
|
|
{
|
|
|
|
DeleteRange( nStartIndex, nEndIndex );
|
|
|
|
if (nStartIndex > 0)
|
|
|
|
if ( pData[nStartIndex-1].pPattern == pData[nStartIndex].pPattern )
|
|
|
|
DeleteRange( nStartIndex-1, nStartIndex-1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < nCount-1; i++)
|
|
|
|
if (pData[i].nRow >= nStartRow)
|
|
|
|
pData[i].nRow -= nSize;
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// Below does not follow the pattern to detect pressure ranges;
|
|
|
|
// instead, only remove merge flags.
|
2000-09-18 23:16:46 +00:00
|
|
|
RemoveFlags( MAXROW-nSize+1, MAXROW, SC_MF_HOR | SC_MF_VER | SC_MF_AUTO );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
void ScAttrArray::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
ScDocumentPool* pDocPool = pDocument->GetPool();
|
2004-06-04 09:18:56 +00:00
|
|
|
for (SCSIZE i = nStartIndex; i <= nEndIndex; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
pDocPool->Remove(*pData[i].pPattern);
|
|
|
|
|
|
|
|
memmove( &pData[nStartIndex], &pData[nEndIndex + 1], (nCount - nEndIndex - 1) * sizeof(ScAttrEntry) );
|
|
|
|
nCount -= nEndIndex-nStartIndex+1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
void ScAttrArray::DeleteArea(SCROW nStartRow, SCROW nEndRow)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
RemoveAreaMerge( nStartRow, nEndRow ); // remove from combined flags
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if ( !HasAttrib( nStartRow, nEndRow, HASATTR_OVERLAPPED | HASATTR_AUTOFILTER) )
|
|
|
|
SetPatternArea( nStartRow, nEndRow, pDocument->GetDefPattern() );
|
|
|
|
else
|
2010-10-22 09:28:50 +01:00
|
|
|
DeleteAreaSafe( nStartRow, nEndRow ); // leave merge flags
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
void ScAttrArray::DeleteHardAttr(SCROW nStartRow, SCROW nEndRow)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
const ScPatternAttr* pDefPattern = pDocument->GetDefPattern();
|
|
|
|
const ScPatternAttr* pOldPattern;
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex;
|
|
|
|
SCROW nRow;
|
|
|
|
SCROW nThisRow;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
Search( nStartRow, nIndex );
|
|
|
|
nThisRow = (nIndex>0) ? pData[nIndex-1].nRow+1 : 0;
|
|
|
|
if (nThisRow < nStartRow) nThisRow = nStartRow;
|
|
|
|
|
|
|
|
while ( nThisRow <= nEndRow )
|
|
|
|
{
|
|
|
|
pOldPattern = pData[nIndex].pPattern;
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
if ( pOldPattern->GetItemSet().Count() ) // hard attributes ?
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
nRow = pData[nIndex].nRow;
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nAttrRow = Min( (SCROW)nRow, (SCROW)nEndRow );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
ScPatternAttr aNewPattern(*pOldPattern);
|
|
|
|
SfxItemSet& rSet = aNewPattern.GetItemSet();
|
2011-01-17 13:20:22 +01:00
|
|
|
for (sal_uInt16 nId = ATTR_PATTERN_START; nId <= ATTR_PATTERN_END; nId++)
|
2000-09-18 23:16:46 +00:00
|
|
|
if (nId != ATTR_MERGE && nId != ATTR_MERGE_FLAG)
|
|
|
|
rSet.ClearItem(nId);
|
|
|
|
|
|
|
|
if ( aNewPattern == *pDefPattern )
|
2011-03-10 16:55:21 -05:00
|
|
|
SetPatternArea( nThisRow, nAttrRow, pDefPattern, false );
|
2000-09-18 23:16:46 +00:00
|
|
|
else
|
2011-11-10 15:21:48 +01:00
|
|
|
SetPatternArea( nThisRow, nAttrRow, &aNewPattern, true );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
Search( nThisRow, nIndex ); // data changed
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
++nIndex;
|
|
|
|
nThisRow = pData[nIndex-1].nRow+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
|
|
|
|
// move within a document
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
void ScAttrArray::MoveTo(SCROW nStartRow, SCROW nEndRow, ScAttrArray& rAttrArray)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nStart = nStartRow;
|
|
|
|
for (SCSIZE i = 0; i < nCount; i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-10 15:21:48 +01:00
|
|
|
if ((pData[i].nRow >= nStartRow) && ((i==0) ? true : pData[i-1].nRow < nEndRow))
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// copy (bPutToPool=TRUE)
|
2004-06-04 09:18:56 +00:00
|
|
|
rAttrArray.SetPatternArea( nStart, Min( (SCROW)pData[i].nRow, (SCROW)nEndRow ),
|
2011-11-10 15:21:48 +01:00
|
|
|
pData[i].pPattern, true );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2004-06-04 09:18:56 +00:00
|
|
|
nStart = Max( (SCROW)nStart, (SCROW)(pData[i].nRow + 1) );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
DeleteArea(nStartRow, nEndRow);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// copy between documents (Clipboard)
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
void ScAttrArray::CopyArea( SCROW nStartRow, SCROW nEndRow, long nDy, ScAttrArray& rAttrArray,
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Int16 nStripFlags )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
nStartRow -= nDy; // Source
|
2000-09-18 23:16:46 +00:00
|
|
|
nEndRow -= nDy;
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nDestStart = Max((long)((long)nStartRow + nDy), (long) 0);
|
|
|
|
SCROW nDestEnd = Min((long)((long)nEndRow + nDy), (long) MAXROW);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
ScDocumentPool* pSourceDocPool = pDocument->GetPool();
|
|
|
|
ScDocumentPool* pDestDocPool = rAttrArray.pDocument->GetPool();
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bSamePool = (pSourceDocPool==pDestDocPool);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
for (SCSIZE i = 0; (i < nCount) && (nDestStart <= nDestEnd); i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (pData[i].nRow >= nStartRow)
|
|
|
|
{
|
|
|
|
const ScPatternAttr* pOldPattern = pData[i].pPattern;
|
|
|
|
const ScPatternAttr* pNewPattern;
|
|
|
|
|
|
|
|
if (IsDefaultItem( pOldPattern ))
|
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
// default: nothing changed
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
pNewPattern = (const ScPatternAttr*)
|
|
|
|
&pDestDocPool->GetDefaultItem( ATTR_PATTERN );
|
|
|
|
}
|
|
|
|
else if ( nStripFlags )
|
|
|
|
{
|
|
|
|
ScPatternAttr* pTmpPattern = new ScPatternAttr( *pOldPattern );
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Int16 nNewFlags = 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( nStripFlags != SC_MF_ALL )
|
|
|
|
nNewFlags = ((const ScMergeFlagAttr&)pTmpPattern->GetItem(ATTR_MERGE_FLAG)).
|
|
|
|
GetValue() & ~nStripFlags;
|
|
|
|
|
|
|
|
if ( nNewFlags )
|
|
|
|
pTmpPattern->GetItemSet().Put( ScMergeFlagAttr( nNewFlags ) );
|
|
|
|
else
|
|
|
|
pTmpPattern->GetItemSet().ClearItem( ATTR_MERGE_FLAG );
|
|
|
|
|
|
|
|
if (bSamePool)
|
|
|
|
pNewPattern = (ScPatternAttr*) &pDestDocPool->Put(*pTmpPattern);
|
|
|
|
else
|
|
|
|
pNewPattern = pTmpPattern->PutInPool( rAttrArray.pDocument, pDocument );
|
|
|
|
delete pTmpPattern;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (bSamePool)
|
|
|
|
pNewPattern = (ScPatternAttr*) &pDestDocPool->Put(*pOldPattern);
|
|
|
|
else
|
|
|
|
pNewPattern = pOldPattern->PutInPool( rAttrArray.pDocument, pDocument );
|
|
|
|
}
|
|
|
|
|
|
|
|
rAttrArray.SetPatternArea(nDestStart,
|
2004-06-04 09:18:56 +00:00
|
|
|
Min((SCROW)(pData[i].nRow + nDy), nDestEnd), pNewPattern);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2001-11-06 13:11:25 +00:00
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// when pasting from clipboard and skipping filtered rows, the adjusted
|
|
|
|
// end position can be negative
|
2004-06-04 09:18:56 +00:00
|
|
|
nDestStart = Max((long)nDestStart, (long)(pData[i].nRow + nDy + 1));
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
|
|
|
|
// leave flags
|
|
|
|
// summarized with CopyArea
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
void ScAttrArray::CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, long nDy, ScAttrArray& rAttrArray )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-10-22 09:28:50 +01:00
|
|
|
nStartRow -= nDy; // Source
|
2000-09-18 23:16:46 +00:00
|
|
|
nEndRow -= nDy;
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nDestStart = Max((long)((long)nStartRow + nDy), (long) 0);
|
|
|
|
SCROW nDestEnd = Min((long)((long)nEndRow + nDy), (long) MAXROW);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if ( !rAttrArray.HasAttrib( nDestStart, nDestEnd, HASATTR_OVERLAPPED ) )
|
|
|
|
{
|
|
|
|
CopyArea( nStartRow+nDy, nEndRow+nDy, nDy, rAttrArray );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScDocumentPool* pSourceDocPool = pDocument->GetPool();
|
|
|
|
ScDocumentPool* pDestDocPool = rAttrArray.pDocument->GetPool();
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bSamePool = (pSourceDocPool==pDestDocPool);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
for (SCSIZE i = 0; (i < nCount) && (nDestStart <= nDestEnd); i++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (pData[i].nRow >= nStartRow)
|
|
|
|
{
|
|
|
|
const ScPatternAttr* pOldPattern = pData[i].pPattern;
|
|
|
|
const ScPatternAttr* pNewPattern;
|
|
|
|
|
|
|
|
if (bSamePool)
|
|
|
|
pNewPattern = (ScPatternAttr*) &pDestDocPool->Put(*pOldPattern);
|
|
|
|
else
|
|
|
|
pNewPattern = pOldPattern->PutInPool( rAttrArray.pDocument, pDocument );
|
|
|
|
|
|
|
|
rAttrArray.SetPatternAreaSafe(nDestStart,
|
2011-03-10 16:55:21 -05:00
|
|
|
Min((SCROW)(pData[i].nRow + nDy), nDestEnd), pNewPattern, false);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2001-11-06 13:11:25 +00:00
|
|
|
|
2010-10-22 09:28:50 +01:00
|
|
|
// when pasting from clipboard and skipping filtered rows, the adjusted
|
|
|
|
// end position can be negative
|
2004-06-04 09:18:56 +00:00
|
|
|
nDestStart = Max((long)nDestStart, (long)(pData[i].nRow + nDy + 1));
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
SCsROW ScAttrArray::SearchStyle( SCsROW nRow, const ScStyleSheet* pSearchStyle,
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bUp, ScMarkArray* pMarkArray )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-11-10 15:21:48 +01:00
|
|
|
bool bFound = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if (pMarkArray)
|
|
|
|
{
|
|
|
|
nRow = pMarkArray->GetNextMarked( nRow, bUp );
|
2004-06-04 09:18:56 +00:00
|
|
|
if (!VALIDROW(nRow))
|
2000-09-18 23:16:46 +00:00
|
|
|
return nRow;
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
Search(nRow, nIndex);
|
|
|
|
const ScPatternAttr* pPattern = pData[nIndex].pPattern;
|
|
|
|
|
2004-06-04 09:18:56 +00:00
|
|
|
while (nIndex < nCount && !bFound)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (pPattern->GetStyleSheet() == pSearchStyle)
|
|
|
|
{
|
|
|
|
if (pMarkArray)
|
|
|
|
{
|
|
|
|
nRow = pMarkArray->GetNextMarked( nRow, bUp );
|
2004-06-04 09:18:56 +00:00
|
|
|
SCROW nStart = nIndex ? pData[nIndex-1].nRow+1 : 0;
|
|
|
|
if (nRow >= nStart && nRow <= pData[nIndex].nRow)
|
2011-11-10 15:21:48 +01:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
2011-11-10 15:21:48 +01:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!bFound)
|
|
|
|
{
|
|
|
|
if (bUp)
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
if (nIndex==0)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
nIndex = nCount;
|
|
|
|
nRow = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
--nIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
nRow = pData[nIndex].nRow;
|
|
|
|
pPattern = pData[nIndex].pPattern;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nRow = pData[nIndex].nRow+1;
|
|
|
|
++nIndex;
|
2004-06-04 09:18:56 +00:00
|
|
|
if (nIndex<nCount)
|
2000-09-18 23:16:46 +00:00
|
|
|
pPattern = pData[nIndex].pPattern;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-21 13:29:51 +02:00
|
|
|
OSL_ENSURE( bFound || !ValidRow(nRow), "Internal failure in in ScAttrArray::SearchStyle" );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
return nRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
bool ScAttrArray::SearchStyleRange( SCsROW& rRow, SCsROW& rEndRow,
|
|
|
|
const ScStyleSheet* pSearchStyle, bool bUp, ScMarkArray* pMarkArray )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCsROW nStartRow = SearchStyle( rRow, pSearchStyle, bUp, pMarkArray );
|
2000-09-18 23:16:46 +00:00
|
|
|
if (VALIDROW(nStartRow))
|
|
|
|
{
|
2004-06-04 09:18:56 +00:00
|
|
|
SCSIZE nIndex;
|
2000-09-18 23:16:46 +00:00
|
|
|
Search(nStartRow,nIndex);
|
|
|
|
|
|
|
|
rRow = nStartRow;
|
|
|
|
if (bUp)
|
|
|
|
{
|
|
|
|
if (nIndex>0)
|
|
|
|
rEndRow = pData[nIndex-1].nRow + 1;
|
|
|
|
else
|
|
|
|
rEndRow = 0;
|
|
|
|
if (pMarkArray)
|
|
|
|
{
|
2011-11-10 15:21:48 +01:00
|
|
|
SCROW nMarkEnd = pMarkArray->GetMarkEnd( nStartRow, true );
|
2000-09-18 23:16:46 +00:00
|
|
|
if (nMarkEnd>rEndRow)
|
|
|
|
rEndRow = nMarkEnd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rEndRow = pData[nIndex].nRow;
|
|
|
|
if (pMarkArray)
|
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
SCROW nMarkEnd = pMarkArray->GetMarkEnd( nStartRow, false );
|
2000-09-18 23:16:46 +00:00
|
|
|
if (nMarkEnd<rEndRow)
|
|
|
|
rEndRow = nMarkEnd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-10 15:21:48 +01:00
|
|
|
return true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 15:59:00 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|